Tag: batching

  • Fulfillment – Daily Changelog – October 29, 2025

    Fulfillment – Daily Changelog – October 29, 2025

    Changelog – October 29, 2025

    🚀 New Features & Improvements

    Raffle Sticker Batch Page Enhancements

    • Visual Order Grouping: Split domestic orders into two distinct sections on raffle sticker batch page
    • “Single Sticker Orders” section for orders with exactly 1 sticker
    • “Multiple Sticker Orders” section for orders with 2+ stickers
    • Each section shows order count and total sticker count for easy packing workflow
    • Color-Coded Quantity Badges: Added brand-approved color-coded badges to quantity display
    • Single sticker (1): Gray – subtle, low priority
    • 2-5 stickers: Green – moderate attention
    • 6-10 stickers: Blue – higher attention
    • 11+ stickers: Primary gold – highest attention
    • Section-Specific Selection: Each order group has its own “Select All” checkbox while maintaining global selection functionality
    • Packing Workflow Optimization: Visual grouping makes it easier to prepare packages by quantity, improving packing efficiency

    4×6 Packing Label Enhancements

    • Multiple Quantity Badge: Added prominent visual indicator on 4×6 packing labels for orders with more than 1 sticker
    • Black badge displaying “X STICKERS” appears in header area next to order number
    • Only shows when quantity > 1 to draw attention to multi-sticker orders
    • Prevents packing errors by making quantity immediately apparent
    • Label Generation Updates: Modified both production and debug label routes to calculate and display total quantity
    • Updated label header layout to accommodate badge
    • Bold, high-contrast styling ensures visibility during physical packing

    Avery Packing Label Enhancements (5160 & 5167)

    • Quantity Badge on Sticky Labels: Added visual quantity badges to Avery label formats for multi-item orders
    • Displays total item quantity (e.g., “3”) in a bold black badge next to order number
    • Works on both Avery 5160 (30 labels/sheet) and Avery 5167 (80 labels/sheet) formats
    • Compact sizing optimized for small label dimensions
    • Only appears when order has more than 1 item
    • Order Picking Optimization: Helps employees quickly identify orders requiring multiple items during pick/pack operations
    • High-contrast black badge with white text for instant visibility
    • Positioned next to order number in flexible layout
    • Scales appropriately for compact (5167) vs standard (5160) label sizes

    🔧 Technical Improvements

    Frontend Components

    • src/app/(authenticated)/batches/[id]/raffle-page.tsx:
    • Added useMemo hook to group domestic orders by quantity
    • Created getQuantityBadgeColor helper function for color-coded badges
    • Created renderOrderRow helper function to DRY up order table rendering
    • Split single orders table into two sections with independent selection logic
    • Updated selection handlers to work across both order groups

    API Route Updates

    • src/app/api/orders/labels-4x6/route.ts: Added quantity badge logic to production 4×6 label generation
    • src/app/api/orders/labels-4x6/debug/route.ts: Added quantity badge logic to debug 4×6 label generation
    • Calculate total quantity across all line items
    • Conditionally render badge HTML when quantity > 1
    • Updated CSS to style badge with high visibility
    • src/app/api/orders/labels/route.ts: Added quantity badge support for Avery label formats (5160 & 5167)
    • Added .order-with-badge and .qty-badge CSS classes
    • Implemented flexible layout to accommodate badge next to order number
    • Responsive sizing for both compact (5167) and standard (5160) formats
    • Uses existing itemCount field which contains total quantity sum

    Styling Updates

    • Added .order-info CSS class for flexible layout of order number and badge
    • Added .qty-badge CSS class with bold styling (black background, white text, increased letter-spacing)
    • Updated header alignment from align-items: baseline to align-items: flex-start for proper badge positioning

    🎯 User Experience Improvements

    • Packing Efficiency: Visual separation of single vs. multiple sticker orders streamlines the physical packing process
    • Error Prevention: Prominent quantity badges on labels reduce risk of packing incorrect number of stickers
    • Quick Identification: Color-coded badges allow instant recognition of order complexity at a glance
    • Workflow Preservation: All existing functionality (send to ShippingEasy, bulk operations) remains unchanged

    Files Modified: 4
    Major Features Added: Order quantity grouping, visual quantity badges on all label types (4×6 packing lists & Avery sticky labels)
    Focus: Packing workflow optimization and error prevention for physical fulfillment operations

    🖨️ Packing Lists Overhaul (Batches)

    • Fixed print layout to hide all app UI (nav, sidebar, submenus) and only render packing lists
    • Ensured one page per order with reliable page breaks and no blank pages
    • Added manual Print button plus auto-print after data load
    • Added professional header:
    • Mama Tried logo and business address (4188 S. Kinnickinnic Ave., St Francis, WI 53235)
    • Moved order number and date to top-right; removed duplicate “#” prefix
    • Removed unused icon import to satisfy lint and unblock deploy

    Files:

    • src/app/(authenticated)/batches/[id]/packing-lists/page.tsx
    • src/app/api/batches/[id]/bulk-packing-lists/route.ts
    • src/app/api/batches/[id]/packing-list/route.ts

    🧰 Database Transaction Leak Remediation (Critical)

    • Audited and fixed transaction handling across 24+ API routes (29 transactions)
    • Replaced db.query('BEGIN'|'COMMIT'|'ROLLBACK') with per-request client via db.connect()
    • Added finally { client.release() } and 10s statement timeout on transactions
    • Resolved pool exhaustion that previously froze the app under load

    Representative routes fixed (subset):

    • orders/[id]/create-reprint, orders/fix-line-items
    • products/* (tags, files, production-files, display-files, toggle-pod, placement-preview)
    • warehouse-items/*, warehouse-inventory/* (transfer, move, reserve, import, pod)
    • navbar/*, available-pages, settings/batch-stages, price-*, roles/*, users/public-pages, art-file-previews

    📦 Warehouse & POD Inventory Improvements

    • Added POD inventory endpoints and UI dialogs
    • Introduced migration for POD blank inventory
    • Fixed lint in inventory dialogs to allow deployment

    Files:

    • database_migrations/add_pod_blank_inventory.sql
    • src/app/api/warehouse-inventory/pod/route.ts
    • src/components/warehouse-inventory/{pod-inventory-view,adjust-pod-inventory-dialog,pod-blank-item-dialog}.tsx

    🛍️ Shopify Product Metadata Sync in Order Processing

    • Added metadata sync from Shopify during order import to improve product classification
    • Order processing now continues even if metadata sync fails (better resilience)

    Files:

    • src/lib/orderUtils.ts
    • ORDER_TYPE_FIX.md

    🔤 New Supporting APIs

    • Added sizes API route to support inventory/product flows

    Files:

    • src/app/api/sizes/route.ts
  • Fulfillment – Daily Changelog – October 22, 2025

    Fulfillment – Daily Changelog – October 22, 2025

    Changelog – October 22, 2025

    📋 Planning & Preparation

    New Batch Page Development Planning

    • Requirements Analysis: Analyzed requirements for new batch page functionality including:
    • Individual shipment creation per order
    • Individual packing lists per order instead of per batch
    • Bulk printing capabilities for multiple packing lists
    • Work order generation with proper page structure
    • ShippingEasy integration for real shipment sending

    Database Schema Investigation

    • Column Analysis: Investigated mama_tried_orders table structure to identify missing columns (shipping_address2, shipping_phone)
    • Relationship Mapping: Analyzed relationships between orders, line items, variants, and products for proper data fetching
    • Color Data Research: Investigated color information storage in blank_style_colors table for packing list display

    Print System Research

    • Layout Analysis: Studied existing working print layouts from individual packing lists
    • Page Break Strategy: Planned approach for multiple packing lists with proper page breaks
    • Print Style Architecture: Designed print style system for consistent formatting across different document types

    Workflow Design

    • User Experience Planning: Designed simplified workflow for new batch page to “just work” without inventory check impediments
    • Bulk Operations Design: Planned bulk printing and shipment creation workflows
    • Error Handling Strategy: Designed approach for bypassing inventory checks while maintaining data integrity

    🔍 Technical Investigation

    API Endpoint Analysis

    • Existing Endpoints: Reviewed current API endpoints for packing lists, shipments, and ShippingEasy integration
    • Data Flow Mapping: Traced data flow from database to frontend for packing list generation
    • Connection Management: Investigated database connection pool issues causing “too many clients” errors

    Print Layout Challenges

    • Browser Print Behavior: Researched browser print behavior for multiple documents
    • CSS Print Media: Analyzed CSS print media query limitations and solutions
    • Page Break Implementation: Studied different approaches for forcing page breaks between documents

    Database Connection Issues

    • Connection Leak Analysis: Investigated causes of database connection limit errors
    • Pool Management: Analyzed current database connection management patterns
    • Optimization Strategy: Planned approach for shared connection pool usage

    📝 Documentation Preparation

    Requirements Documentation

    • Feature Specifications: Documented requirements for new batch page functionality
    • User Stories: Defined user stories for individual vs bulk operations
    • Acceptance Criteria: Established criteria for successful implementation

    Technical Documentation

    • Database Schema Notes: Documented findings about missing columns and relationships
    • API Design: Planned new API endpoints for bulk operations
    • Print System Architecture: Documented planned print system improvements

    🎯 Strategic Planning

    Development Priorities

    • Critical Path Identification: Identified critical path for new batch page functionality
    • Risk Assessment: Assessed risks of inventory check bypass and mitigation strategies
    • Testing Strategy: Planned testing approach for print layouts and bulk operations

    User Experience Goals

    • Simplicity Focus: Emphasized “just works” philosophy for new batch page
    • Efficiency Goals: Planned bulk operations to improve workflow efficiency
    • Error Prevention: Designed error handling to prevent common workflow blockers

    Note: October 22nd appears to have been primarily a planning and investigation day, with the actual implementation work committed on October 23rd. This day focused on understanding requirements, investigating technical challenges, and planning the implementation approach for the new batch page enhancements.

    Key Focus Areas:

    • New batch page functionality planning
    • Database schema investigation
    • Print system architecture design
    • Workflow simplification strategy
    • Technical risk assessment and mitigation planning