Tag: invoicing

  • Fulfillment – Daily Changelog – September 17, 2025

    Fulfillment – Daily Changelog – September 17, 2025

    2025-09-17 – Invoice Creation Flow Redesign

    Problem Solved

    • Fixed unreliable automatic QuickBooks sending during invoice creation that was causing failures and frustration
    • Eliminated need to navigate to separate invoices page to send invoices to QuickBooks after creation

    New Invoice Creation Workflow

    • Removed problematic automatic QuickBooks integration from invoice creation API that was failing due to timing issues
    • Created new success dialog that appears immediately after invoice creation
    • Added immediate QuickBooks sending options without leaving the creation flow

    User Experience Improvements

    • Success dialog shows all created invoices with details (invoice number, customer, amount)
    • Individual “Send to QuickBooks” buttons for each invoice
    • “Send All to QuickBooks” button to send all invoices at once
    • Real-time status updates showing success/failure for each QuickBooks send attempt
    • Clear visual feedback with badges showing sent/not sent/failed status

    Technical Changes

    • Modified /api/invoices route to remove automatic QuickBooks sending after transaction commit
    • Created new InvoiceCreationSuccess component for post-creation QuickBooks integration
    • Updated InvoiceDialog component to use new success flow instead of automatic sending
    • Maintained proven QuickBooks sending logic from existing manual process

    Benefits

    • Reliable invoice creation – no more failures due to QuickBooks timing issues
    • Streamlined workflow – create invoices and send to QuickBooks in one flow
    • Better error handling – clear feedback on what succeeded/failed
    • Flexible sending – send individual invoices or all at once
    • No navigation required – everything happens in one dialog

    Impact

    • Eliminates the frustrating “failed” messages during invoice creation
    • Reduces workflow from 3 steps (create → navigate → send) to 2 steps (create → send)
    • Uses the same proven QuickBooks integration that works reliably in manual mode
    • Provides immediate feedback and control over QuickBooks synchronization

    Testing Status

    • Ready for testing during next invoice creation cycle
    • Falls back to existing manual QuickBooks sending process if needed

    Shipping Address Update System – Final Fixes

    Webhook Validation Improvements

    • Fixed webhook payload validation to prevent database errors from malformed Shopify webhooks
    • Added order ID validation before processing to avoid NaN conversion errors
    • Improved error handling for incomplete webhook payloads

    Badge Display Issues Resolved

    • Fixed false positive badges showing on all orders due to sync process setting shipping_updated_at incorrectly
    • Cleared test order flags while preserving legitimate address change indicators
    • Restored proper badge for order #5303 – the original real address change that caused shipping issues

    System Status

    • Webhook system working – successfully processes address changes from Shopify
    • Badge system accurate – only shows for legitimate address changes after order creation
    • Ready for production – system will properly flag future customer address changes
  • Fulfillment – Daily Changelog – September 12, 2025

    2025-09-12 – Invoice Pricing and QuickBooks Integration Fixes

    Critical Invoice Pricing Corrections

    • Fixed invoice pricing logic to prevent charging retail prices instead of cost prices
    • Updated invoice API to prioritize: wholesale_price (raffle stickers) → variant cost_priceblank_price + print_price → fallback to $0
    • Removed retail price fallback that was incorrectly charging customers full retail amounts
    • Fixed product save API to preserve wholesale_price and flat_shipping_charge values when not explicitly provided

    QuickBooks Integration Improvements

    • Resolved “Object Not Found” (610) errors in QuickBooks invoice creation
    • Updated intuit-invoice.ts to properly handle shipping line items and respect quickbooks_line_item_id from database
    • Fixed ItemRef mapping to use correct QuickBooks item IDs for different line item types
    • Improved error handling for inactive QuickBooks items

    Invoice Creation Workflow

    • Fixed two-step process for automatic QuickBooks sending: Modified invoice creation API to properly handle “Automatically send to QuickBooks” option
    • Root cause identified: QuickBooks sending was happening within the same database transaction, causing failures when trying to query invoice relationships that weren’t fully committed yet
    • Solution implemented: QuickBooks sending now happens AFTER database transaction is committed, using fresh database connections
    • Technical changes: Moved QuickBooks integration logic to post-transaction phase in /api/invoices route
    • UI updates: Enhanced success messaging to properly handle both invoice creation and QuickBooks sending results
    • Testing status: Ready for testing during next invoice creation cycle (current invoices already processed)

    Impact

    • Mixed orders now correctly charge cost prices for inventory items and wholesale prices for raffle stickers
    • QuickBooks integration errors resolved for proper invoice synchronization
    • Pricing accuracy restored across all invoice types