Refactor: Complete barcodeImage removal and hub3aText migration
This commit completes the migration from storing bitmap barcodes to using decoded HUB-3A text strings, removing all legacy code while maintaining backward compatibility during the transition period. Database & Server Actions: - billActions: Removed commented legacy barcodeImage code - locationActions: Updated field references in projections - monthActions: Use hub3aText when copying bills to new months - printActions: Support both hub3aText and barcodeImage during migration - Added @deprecated annotation to barcodeImage field - Filter includes bills with either field - Pass both fields to support gradual migration Barcode Decoder: - Removed barcodeImage field from DecodeResult type - Deleted copyBarcodeImage() function (58 lines) - No longer generating bitmaps during decode - Barcodes now generated on-demand from hub3aText - Cleaner separation: decoder extracts text, component renders barcode UI Components: - Pdf417Barcode: Added optional className prop for styling flexibility - Removed unnecessary wrapper div - Conditional styling (use className or default dimensions) - PrintPreview: Use Pdf417Barcode component with fallback to legacy barcodeImage - ViewBillCard: Major cleanup and migration support - Removed unused imports (React, updateOrAddBill, useLocale) - Removed unused middleware function - Removed unused variables and hidden input - Prefer hub3aText with Pdf417Barcode, fallback to barcodeImage - Clear legacy support comments Migration Strategy: All rendering code now follows the pattern: 1. Prefer hub3aText (new field) when available 2. Fallback to barcodeImage (legacy field) if needed 3. Clear comments marking legacy support code 4. Allows gradual migration without breaking existing bills Benefits: - More efficient storage (text vs base64 bitmap) - Barcodes generated on-demand (not stored) - Cleaner, more maintainable code - Consistent use of Pdf417Barcode component - Removed ~60 lines of unused code 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -146,7 +146,6 @@ export const updateOrAddBill = withUser(async (user:AuthenticatedUser, locationI
|
||||
|
||||
const billPaid = formData.get('billPaid') === 'on';
|
||||
const billedTo = (formData.get('billedTo') as BilledTo) ?? BilledTo.Tenant;
|
||||
// const barcodeImage = formData.get('barcodeImage')?.valueOf() as string; // LEGACY FIELD - not used anymore
|
||||
const hub3aText = formData.get('hub3aText')?.valueOf() as string;
|
||||
|
||||
// update the bill in the mongodb
|
||||
@@ -165,7 +164,6 @@ export const updateOrAddBill = withUser(async (user:AuthenticatedUser, locationI
|
||||
"bills.$[elem].attachment": billAttachment,
|
||||
"bills.$[elem].notes": billNotes,
|
||||
"bills.$[elem].payedAmount": payedAmount,
|
||||
// "bills.$[elem].barcodeImage": barcodeImage, // LEGACY FIELD - not used anymore
|
||||
"bills.$[elem].hub3aText": hub3aText,
|
||||
|
||||
}: {
|
||||
@@ -174,7 +172,6 @@ export const updateOrAddBill = withUser(async (user:AuthenticatedUser, locationI
|
||||
"bills.$[elem].billedTo": billedTo,
|
||||
"bills.$[elem].notes": billNotes,
|
||||
"bills.$[elem].payedAmount": payedAmount,
|
||||
// "bills.$[elem].barcodeImage": barcodeImage, // LEGACY FIELD - not used anymore
|
||||
"bills.$[elem].hub3aText": hub3aText,
|
||||
};
|
||||
|
||||
@@ -201,7 +198,6 @@ export const updateOrAddBill = withUser(async (user:AuthenticatedUser, locationI
|
||||
attachment: billAttachment,
|
||||
notes: billNotes,
|
||||
payedAmount,
|
||||
// barcodeImage, // LEGACY FIELD - not used anymore
|
||||
hub3aText,
|
||||
};
|
||||
|
||||
@@ -266,7 +262,6 @@ export const updateOrAddBill = withUser(async (user:AuthenticatedUser, locationI
|
||||
attachment: null, // No attachment for subsequent months
|
||||
notes: billNotes,
|
||||
payedAmount: null,
|
||||
// barcodeImage: undefined, // LEGACY FIELD - not used anymore
|
||||
hub3aText: undefined,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user