Improve barcode detection in documents with graphics and text by implementing
a multi-strategy horizontal slicing approach:
- Split documents into overlapping horizontal sections (5,4,3,2,1, or full)
- Decode each section separately to isolate individual barcodes
- Use 2% overlap between sections to avoid missing boundary codes
- Return the strategy that detects the most barcodes
- Early exit optimization when fewer codes are found
Also fix error handling to use Error objects instead of string literals.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Delete custom PDF417 generator and renderer now that all components use zxing-wasm/writer. Removes Pdf417Barcode component, generateBarcode, and renderBarcode utilities.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Remove @zxing/browser and @zxing/library dependencies as they have been fully replaced by zxing-wasm. Delete old barcodeDecoder.ts file which is no longer used after migration to barcodeDecoderWasm.ts.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Remove canvas splitting logic since zxing-wasm natively supports multiple barcode detection with maxNumberOfSymbols parameter. Reduces code by 69 lines and improves performance by requiring only a single decode call per canvas. Set maxNumberOfSymbols to 10 for realistic utility bill use case.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Replace @zxing/browser with zxing-wasm for better performance and smaller WebAssembly bundle size (919KB). Added middleware exclusion for .wasm files to prevent i18n routing interference.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Add getLocationsByMonth server action with aggregation pipeline to calculate hasAttachment
- Add updateMonth server action for bulk bill status updates with path revalidation
- Create multi-bill-edit page at /home/multi-bill-edit/[year]/[month]
- Implement MultiBillEdit component with toggle functionality for all bills
- Add BillToggleBadge component integration for consistent bill display
- Add "set all as paid/unpaid" toggle button for batch operations
- Implement server-side redirect with success message after save
- Add Suspense boundary with loading skeleton
- Update translations for multi-bill-edit feature (Croatian and English)
- Ensure data freshness with unstable_noStore and revalidatePath
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Changes:
- Add console.log statements for shareId validation failures in locationActions
- Replace DocumentIcon with TicketIcon for proof-of-payment downloads (consistency)
- Add teal color to all proof-of-payment icons for visual distinction
- Adjust vertical alignment of icons for better visual alignment with text
Debug logging helps troubleshoot:
- shareId extraction failures
- Checksum validation failures
- Location not found errors
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Changes:
- Secure uploadUtilBillsProofOfPayment with checksum validation
- Update ViewLocationCard to accept and use shareId prop
- Update ViewBillCard to accept shareId and use it for uploads
- Update ViewBillBadge to pass shareId to bill detail pages
- Add client-side validation check for shareId before upload
- Update back button links to use shareId
Security improvements:
- Both per-bill and combined uploads now validate checksum and TTL
- IP-based rate limiting applied to both upload types
- PDF magic bytes validation for both upload types
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Add generateShareLink() for owners to create share URLs with checksums
- Add validateShareAccess() to validate checksum and TTL on tenant visits
- Implement automatic TTL reset (10 days → 1 hour after first visit)
- Include automatic cleanup of expired shares
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Added cache revalidation to ensure ViewLocationCard reflects uploaded
proof of payment when navigating back from ViewBillCard:
- Server-side: Added revalidatePath() to upload actions in billActions
and locationActions to invalidate Next.js server cache
- Client-side: Added router.refresh() calls in ViewBillCard and
ViewLocationCard to refresh client router cache after successful upload
This maintains the current UX (no redirect on upload) while ensuring
fresh data is displayed on navigation.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Fixed mixed inclusion/exclusion projection that caused error:
"Cannot do inclusion on field bills.proofOfPayment.uploadedAt in exclusion projection"
Changed projection to use exclusion-only:
- Exclude bills.attachment (not needed in upload context)
- Exclude bills.proofOfPayment.fileContentsBase64 (large file data)
- Include all other fields implicitly (including uploadedAt for existence check)
This reduces data transfer while maintaining MongoDB projection compatibility.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Updated uploadProofOfPayment to expect 'proofOfPayment' field name
instead of 'utilBillsProofOfPayment' for semantic clarity
- Removed old not-found.tsx from deprecated route structure
- Added required environment variables for file upload validation:
- MAX_BILL_ATTACHMENT_UPLOAD_SIZE_KB=1024
- MAX_PROOF_OF_PAYMENT_UPLOAD_SIZE_KB=1024
- Updated package-lock.json with peer dependency metadata
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Frontend changes:
- Added ViewBillCard proof of payment upload for per-bill mode
- Conditional rendering based on proofOfPaymentType
- File upload with PDF validation and loading states
- Download link to /share/proof-of-payment/per-bill/
- Updated LocationCard to use new utilBillsProofOfPayment field structure
Backend changes:
- Updated locationActions with improved file validation
- File size validation using MAX_PROOF_OF_PAYMENT_UPLOAD_SIZE_KB
- PDF type validation before database operations
- Enhanced serializeAttachment with FileAttachment type
- Updated database projections for optimized queries
- Updated monthActions to use consolidated field name
- Updated proof-of-payment download route with new field names
Data structure migration:
- Replaced utilBillsProofOfPaymentAttachment + utilBillsProofOfPaymentUploadedAt
with single utilBillsProofOfPayment object containing uploadedAt
- Consistent use of FileAttachment type across all upload functions
Translations:
- Added upload-proof-of-payment-legend and upload-proof-of-payment-label
to bill-edit-form section in both English and Croatian
This completes the proof of payment feature implementation for both
combined (location-level) and per-bill modes.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Implemented uploadProofOfPayment function for per-bill proof of payment
- Validates file size using MAX_PROOF_OF_PAYMENT_UPLOAD_SIZE_KB env variable
- Validates PDF file type
- Prevents duplicate uploads with existence check
- Uses optimized database projection to minimize data transfer
- Updates specific bill using MongoDB array filters
- Refactored file validation in updateOrAddBill
- Moved validation before serialization for fail-fast behavior
- Added configurable file size limit from environment variable
- Added PDF type validation
- Improved error messages with specific validation failures
- Updated serializeAttachment function
- Changed return type from BillAttachment to FileAttachment
- Added uploadedAt timestamp to attachment object
- Removed unsafe type cast
- Code formatting improvements throughout
- Consistent spacing and indentation
- Better TypeScript typing
This completes the per-bill proof of payment feature implementation.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Renamed BillAttachment to FileAttachment for better generalization
- Added uploadedAt field to FileAttachment (consolidates timestamp)
- Renamed utilBillsProofOfPaymentAttachment to utilBillsProofOfPayment
- Removed separate utilBillsProofOfPaymentUploadedAt field (now in FileAttachment)
- Added rentProofOfPayment field to BillingLocation for rent-specific proof
- Added proofOfPayment field to Bill interface for per-bill attachments
- Removed unused imports (ObjectId, inter)
This refactoring enables both "combined" (location-level) and "per-bill"
proof of payment attachment strategies.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Enhanced the proof of payment attachment feature with the following improvements:
- Renamed field from `proofOfPaymentAttachmentType` to `proofOfPaymentType` for consistency
- Added "none" option allowing users to disable proof of payment attachments
- Changed default value from "combined" to "none" for better UX
- Repositioned section in form after payment instructions (more logical flow)
- Added conditional warning when "combined" is selected without payment method
- Updated translations with emojis and improved tooltips for all options
- Backend validation and database operations updated to support new field structure
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Update location tracking to record when tenant views a location rather than just whether they've seen it. This provides better audit trail and enables future features like viewing history.
Changes:
- Convert seenByTenant (boolean) to seenByTenantAt (Date) in database schema
- Update setSeenByTenantAt action to store timestamp instead of boolean flag
- Modify LocationCard UI to display when location was seen by tenant
- Update all references across locationActions, monthActions, and view components
- Remove unused imports from ViewLocationCard
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Move authenticated home page from /[locale] to /[locale]/home
- Move login page from /[locale]/login to /[locale] (new landing page)
- Move all restricted pages (bill, location, year-month, print, account) under /[locale]/home
- Simplify middleware to protect all routes under /home instead of using publicPages array
- Update auth config: change signIn page from /login to /
- Update SignInButton callback URL to redirect to /home after login
- Update all internal links throughout the application to reflect new structure
- Update server action redirects in navigationActions.ts
- Public share routes (/share/*) remain unchanged
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Move user settings form to dedicated /account/settings route
- Update PageHeader icon from Settings to AccountCircle for clarity
- Update debug log labels in auth config for better readability
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Add ownerRevolutProfileName field validation when enableRevolutPayment is true
- Validate profile name must start with '@' and contain only letters and numbers
- Add required field validation for Revolut profile name
- Add English and Croatian error messages for validation failures
- Update State type to include ownerRevolutProfileName errors
Validation regex: /^@[a-zA-Z0-9]+$/
Valid examples: @john123, @ivan, @user2024
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Replace generateTenantCode boolean field with tenantPaymentMethod enum ("none" | "iban" | "revolut")
- Update LocationEditForm to use dropdown select instead of toggle for payment method selection
- Consolidate multiple useState hooks into single formValues state object
- Change from defaultValue to controlled components with value/onChange pattern
- Add hidden inputs to preserve tenant data when payment method is not selected
- Update validation logic to check tenantPaymentMethod === "iban"
- Update ViewLocationCard to use new tenantPaymentMethod field
- Add Croatian translations for new dropdown options
This provides better scalability for adding future payment methods and improves form state management.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Replace showPaymentInstructionsInMonthlyStatement dropdown with enableIbanPayment and enableRevolutPayment boolean toggles
- Update UserSettingsForm to use separate fieldsets for IBAN and Revolut with independent toggle switches
- Add hidden inputs to preserve values when toggles are disabled
- Update validation logic to check enableIbanPayment instead of show2dCodeInMonthlyStatement
- Reorganize translation keys to match new structure (iban-* and revolut-* prefixes)
- Update ViewLocationCard to use enableIbanPayment field
This provides better UX by allowing users to enable both payment methods simultaneously if needed.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Add NoteBox component for displaying warning messages with icon
- Add Revolut profile name field to user settings schema
- Update UserSettingsForm to support payment instruction selection (disabled/IBAN/Revolut)
- Add Croatian and English translations for new payment options
- Reserve fields for future per-instruction enable/disable functionality
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Updated PDF.js library to version 4.10.38 for improved PDF rendering
and barcode scanning capabilities.
Changes:
- package.json: Updated pdfjs-dist dependency to ^4.10.38
- package-lock.json: Updated dependency tree
- public/pdf.worker.min.mjs: Updated PDF.js worker file
- app/lib/pdf/barcodeDecoder.ts: Removed unused import
This is a minor version update within v4, maintaining API compatibility
while receiving bug fixes and improvements.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
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>
Database & Types:
- Added hub3aText field to Bill interface in db-types.ts
- Marked barcodeImage as @deprecated legacy field
Server Actions:
- Updated billActions to read/write hub3aText instead of barcodeImage
- Commented out legacy barcodeImage code with migration notes
Barcode Decoder:
- Renamed image2canvas to file2canvas for clarity
- Added new image2canvas function for base64 encoded images (migration support)
- Added hub3aText to DecodeResult type
- Exported decodeFromImage function for legacy data migration
- Updated decoding logic to extract and return hub3aText
UI Components:
- Refactored Pdf417Barcode to accept hub3aText string instead of PaymentParams
- Removed EncodePayment call from Pdf417Barcode (now expects pre-encoded text)
- Updated ViewLocationCard to encode payment params before passing to Pdf417Barcode
This completes the refactoring from storing bitmap images to storing decoded
HUB-3A payment strings, providing more efficient storage and easier data manipulation.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Changes:
- Updated BillingLocation interface:
- Added utilBillsProofOfPaymentAttachment field (BillAttachment type)
- Added server action uploadUtilBillsProofOfPayment:
- Validates PDF file type
- Serializes file attachment to base64
- Stores attachment in BillingLocation document
- Returns success/error status
- Updated ViewLocationCard component:
- Added file upload input with PDF-only accept
- Implemented handleFileChange with immediate upload
- Added upload state management (isUploading, uploadError, attachment)
- Shows spinner while uploading
- Input disabled during upload
- Conditionally renders file input or download link
- Link displayed after successful upload
- Created route handler for serving proof of payment PDFs:
- GET /share/proof-of-payment/[id]/route.tsx
- Fetches attachment from database
- Converts base64 to binary
- Returns PDF with proper headers
- Added not-found page for proof of payment route
- Updated middleware to include proof-of-payment in public pages
- Added translations:
- en: "Upload proof of payment (PDF only)"
- hr: "Priložite potvrdu o uplati:"
File uploads immediately on selection without page reload.
Only PDF files accepted with client and server-side validation.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Changes:
- Updated formatCurrency function:
- Added currencyCode parameter with EUR default
- Implemented Intl.NumberFormat for proper currency formatting
- Added fallback for invalid currency codes
- Updated component hierarchy to pass currency:
- HomePage: Fetch userSettings and pass to MonthLocationList
- MonthLocationList: Accept and pass currency to child components
- LocationCard: Accept currency prop and use in formatCurrency
- MonthCard: Accept currency prop and use in formatCurrency
- ViewLocationCard: Pass currency from userSettings to formatCurrency
- Removed hardcoded $ symbols, now using proper currency formatting
All currency amounts now display with the user's selected currency code
from their settings, using locale-appropriate formatting (hr-HR).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Changes:
- Updated UserSettings interface: town -> ownerTown
- Updated userSettingsActions.ts:
- Changed State type to use ownerTown
- Added max length validation (27 characters) to FormSchema
- Updated validation refinement to check ownerTown
- Updated form data parsing to read ownerTown
- Updated database write operations to use ownerTown
- Updated UserSettingsForm.tsx:
- Changed state tracking to use ownerTown
- Updated validation check to reference ownerTown
- Updated input field: id, name, maxLength={27}
- Updated ViewLocationCard.tsx to use ownerTown instead of town
- Updated English translations:
- town-label -> owner-town-label: "Your Postal Code and Town"
- town-placeholder -> owner-town-placeholder
- town-required -> owner-town-required
- Updated Croatian translations with corresponding ownerTown keys
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Changes:
- Updated UserSettings interface: street -> ownerStreet
- Updated userSettingsActions.ts:
- Changed State type to use ownerStreet
- Added max length validation (25 characters) to FormSchema
- Updated validation refinement to check ownerStreet
- Updated form data parsing to read ownerStreet
- Updated database write operations to use ownerStreet
- Updated UserSettingsForm.tsx:
- Changed state tracking to use ownerStreet
- Updated validation check to reference ownerStreet
- Updated input field: id, name, maxLength={25}
- Updated ViewLocationCard.tsx to use ownerStreet instead of street
- Updated English translations:
- street-label -> owner-street-label: "Your Street and House Number"
- street-placeholder -> owner-street-placeholder
- street-required -> owner-street-required
- Updated Croatian translations with corresponding ownerStreet keys
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Renamed firstName to ownerName in UserSettings interface
- Updated UserSettingsForm field to accept full name (first and last)
- Set maximum length to 25 characters for owner name field
- Updated all database operations to use ownerName
- Changed English label from "First Name" to "Your First and Last Name"
- Updated Croatian translations to match (Vaše ime i prezime)
- Updated form validation schema and error messages
- Removed old lastName-related translations
- Updated ViewLocationCard to use ownerName for recipient
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Removed lastName from UserSettings interface
- Updated UserSettingsForm to remove lastName input field
- Removed lastName from all database operations
- Updated form validation schema to remove lastName validation
- Updated ViewLocationCard to use only firstName for recipient name
- Removed lastName from user settings form state tracking
- Updated Croatian translations to reflect changes
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>