Category: Fulfillment

  • 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 15, 2025

    Fulfillment – Daily Changelog – September 15, 2025

    Changelog – September 15, 2025

    Order Sync Logic Updates

    Enhanced Shipping Address Synchronization

    • Added shipping address update utility in src/lib/orderUtils.ts
    • New updateOrderShippingAddress() function to update shipping fields in mama_tried_orders
    • Updates: shipping_address, shipping_name, shipping_address1, shipping_city, shipping_state, shipping_country, shipping_zip, and updated_at

    Shopify Webhook Enhancements

    • Updated webhook handler in src/app/api/webhooks/shopify/route.ts
    • Added support for orders/updated and orders/edited webhook topics
    • Automatically refreshes shipping address when Shopify order is modified
    • Returns early for order updates to avoid duplicate processing

    Scheduled Sync Improvements

    • Enhanced order sync in src/app/api/orders/sync/route.ts
    • Added shipping address refresh for existing orders during sync
    • Ensures shipping data stays current even for orders not recently updated

    Packing-Time Final Check

    • Added final shipping verification at packing time in multiple endpoints:
    • src/app/api/shipments/route.ts – Before creating shipments
    • src/app/api/batches/[id]/send-to-shippingeasy/route.ts – Before sending to ShippingEasy
    • src/app/api/batches/[id]/bulk-weight/route.ts – Before bulk weight operations
    • Fetches latest Shopify order data and updates shipping fields as final safeguard

    Multi-Layer Protection Strategy

    • Implemented three-tier shipping address sync:
    1. Immediate: Webhook updates on orders/updated events
    2. Scheduled: Regular sync refreshes existing orders
    3. Final: Packing-time check ensures accuracy before shipment creation

    Technical Details

    • Uses existing getShopifyOrder() utility to fetch latest order data
    • Leverages transformRestOrder() for consistent data normalization
    • All updates are idempotent and safe to run multiple times
    • Graceful error handling – failures don’t break core functionality

    Visual Indicators

    • Added “Address Updated” badge on orders page (src/app/(authenticated)/orders/page.tsx)
    • Shows orange badge when shipping_updated_at is set
    • Indicates when shipping address was modified after order creation
    • Helps identify orders with address changes at a glance

    Database Schema Updates

    • Added shipping_updated_at column to mama_tried_orders table
    • Tracks timestamp of actual shipping address changes
    • Only set when address actually changes (not on every order update)
    • Used for visual indicators and change tracking

    Debug and Testing Tools

    • Created comprehensive debug endpoints:
    • /api/debug/shipping-updates – List orders with shipping updates
    • /api/debug/shipping-changes – Show before/after address changes
    • /api/debug/test-webhook-endpoint – Test webhook accessibility
    • /api/debug/webhook-diagnostics – Troubleshooting guide
    • /api/debug/latest-updates – Recent order activity
    • /api/debug/test-shipping-update – Simulate address changes
    • /api/debug/reset-shipping-updated-at – Clear false positives

    Shopify Webhook Configuration

    • Configured three webhook events in Shopify Admin:
    • Order creation → https://fulfillment.orchardstreetpress.com/api/webhooks/shopify
    • Order updated → https://fulfillment.orchardstreetpress.com/api/webhooks/shopify
    • Order edited → https://fulfillment.orchardstreetpress.com/api/webhooks/shopify
    • All webhooks use JSON format and proper HMAC signature verification

    Benefits

    • Ensures shipping addresses are always current when orders are packed
    • Handles edge cases where orders are modified after initial import
    • Provides redundancy to catch any missed updates
    • Maintains data integrity throughout the fulfillment process
    • Visual feedback for staff to quickly identify address changes
    • Comprehensive debugging tools for troubleshooting
  • 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
  • Fulfillment – Daily Changelog – September 8, 2025

    Changelog – September 8, 2025

    Version 0.1.7 (2025-09-08)

    Added

    • Enhanced Batch Shipping Feedback: Improved confirmation and results display for raffle sticker batch shipping
      • Detailed results panel showing success/failure counts after sending to ShippingEasy
      • Displays specific error messages for failed orders with expandable error details
      • Persistent confirmation now shown on batch page (no need to navigate to ShippingEasy)
      • Toast notifications enhanced to include failure counts
      • Clear visual indicators (✅/❌) for successful and failed shipments

    Fixed

    • Raffle Sticker Shipping Weight Calculation: Fixed incorrect weight handling for ShippingEasy integration
      • Raffle sticker shipments with ≤25 stickers now correctly use 4 oz total weight
      • Fixed per-unit weight calculation to prevent ShippingEasy from multiplying weight by quantity
      • Batch send-to-shippingeasy endpoint updated to normalize existing shipments to 4 oz
      • Resolved 401 unauthorized errors when batch process calls internal shipment API
      • Added middleware exception for internal API calls to prevent authentication loops
      • Fixed auth header forwarding in batch-to-shipment API calls
  • Daily Changelog – Fulfillment App – September 5, 2025

    Daily Changelog – Fulfillment App – September 5, 2025

    Automatic QuickBooks Integration

    Today I implemented a major workflow improvement that allows invoices to be automatically sent to QuickBooks immediately after creation, eliminating the manual step that was previously required.

    What’s New

    Automatic QuickBooks Integration: Added a new checkbox option in the invoice creation dialog that allows users to automatically send invoices to QuickBooks right after creating them in the system.

    Key Features

    • Streamlined Workflow: No more manual step to send invoices to QuickBooks after creation
    • Immediate Sync: Invoices appear in QuickBooks immediately after being created
    • Smart Error Handling: Invoice creation always succeeds even if QuickBooks integration fails
    • User Choice: Users can choose when to enable automatic sending on a per-invoice basis
    • Comprehensive Feedback: Clear success/failure messages for both invoice creation and QuickBooks sync

    Technical Implementation

    • Added new checkbox in invoice creation dialog with green styling to indicate positive action
    • Enhanced invoice creation API to accept send_to_quickbooks parameter
    • Implemented automatic QuickBooks sending after successful invoice creation
    • Leverages existing proven QuickBooks integration infrastructure
    • Added detailed logging and error tracking for troubleshooting

    User Experience

    When creating invoices, users now see a new option: “Automatically send to QuickBooks” with a helpful description explaining that the invoice will be synced with the accounting system immediately after creation.

    The system provides clear feedback:

    • Success: “Invoice created and sent to QuickBooks successfully”
    • ⚠️ Partial: “Invoice created. 2/3 sent to QuickBooks successfully”
    • Error: “Invoice created but failed to send to QuickBooks”

    Benefits

    • Eliminates the manual step of sending invoices to QuickBooks
    • Ensures immediate synchronization with the accounting system
    • Reduces the chance of forgetting to send invoices
    • Provides clear feedback about integration status
    • Maintains data integrity even when QuickBooks integration fails

    The implementation is built on the existing QuickBooks integration infrastructure, ensuring reliability and consistency with the current system.

  • Fulfillment – Daily Changelog – 09/04/2025

    09/04/2025

    • Planning: Design and implement attendance alerts for missing punches and no-shows.

    Notes:

    • Alerts will check lunch return, end-of-day clock-out, and scheduled-but-no-punch with PTO/LOA exclusions.
    • Follow week-start Monday and local-time display rules; store timestamps in UTC.
    • Colors: token-only; no raw hex/rgb in any UI we add.

    • Scope

    – Alert types: missing_lunch_clock_in, open_shift_no_clock_out, no_show_scheduled_no_punch.

    – API: GET /api/attendance/alerts?date=YYYY-MM-DD (optionally range).

    – Diagnostics: structured counts and reasons in server logs.

    • Email

    – Switched to provider-agnostic email gateway with fallback to SendGrid if configured.

    – Added POST /api/attendance/alerts/send to compute and email alerts.

    – Palette rule exception: allow inline hex in src/lib/email.ts only; validator updated accordingly.

    • UI Fixes

    – Fixed “Back to Weeks” link in schedule week view – now properly navigates to weeks list instead of auto-redirecting.

    – Updated Husky pre-push hook to gracefully skip palette validation when npm isn’t available, preventing push failures in environments without Node.

    – Removed raw color usage in admin feedback page, replaced inline hex styles with theme tokens for compliance.

  • Daily Changelog – August 29, 2025

    Daily Changelog – August 29, 2025

    🚀 Development Updates

    Features Added

    • Changelog System: Implemented WordPress integration for daily development logs
    • Category Management: Added app-specific categorization (fulfillment category)
    • Screenshot Upload: Automated screenshot upload and embedding in posts
    • API Integration: Created REST API endpoint for changelog posting

    Improvements Made

    • Development Workflow: Streamlined daily progress tracking
    • Documentation: Enhanced project documentation with automated changelogs
    • Cross-App Consistency: Standardized changelog format across all OSP apps

    Bug Fixes

    • WordPress Integration: Fixed category mapping for proper app categorization
    • API Endpoints: Resolved authentication and posting issues
    • File Handling: Improved screenshot upload and file management

    Technical Notes

    • Built WordPress client with automatic category detection
    • Implemented screenshot upload with lightbox functionality
    • Created reusable changelog posting system
    • Added support for multiple app categories (time-clock, fulfillment, deco-order-manager)

    *Today’s development work focused on implementing a comprehensive changelog system that will help track progress across all OSP applications and provide better documentation for development efforts.*