Category: Changelogs

  • Fulfillment – Daily Changelog – September 26, 2025

    Fulfillment – Daily Changelog – September 26, 2025

    2025-09-26 – Customer Dashboard Product Catalog Preview

    Customer Dashboard Products

    • Replaced the placeholder with live product cards styled for the lighter customer theme
    • Default the customer product grid to active items while adding filters for status and product type
    • Highlighted key product metadata (status, price, variants, decoration process, sizes) with badges and iconography
    • Default the type filter to apparel when available and moved the print-ready badge out of the imagery overlay
    • Added customer-side filters for product type and removed externally fulfilled items from the preview list
    • Updated pricing display to use retail variant/base prices instead of the generic “Contact rep” fallback

    Supporting Work

    • Removed the specialty filler cards so the customer view only shows actual catalog content
    • Logged follow-up support messaging for empty states to guide store users when inventory is pending assignment
    • Removed AI-feeling filler cards from the products page to keep the customer view focused on real catalog content

    stopped work on this to focus on Deco Order manager, building basically the same functionality.

  • Fulfillment – Daily Changelog – September 25, 2025

    Fulfillment – Daily Changelog – September 25, 2025

    2025-09-25 – Shipping Address Badge Reliability

    Address Updated Badge False Positives

    Problem Identified

    • Issue: The orders index was showing the 📍 Address Updated badge for nearly every order.
    • Impact: Team members lost trust in the badge, burned time double-checking shipping details, and worried that the sync/webhook pipeline was still broken.
    • History: Multiple prior “fixes” only disabled parts of the pipeline; the underlying comparison treated re-sent Shopify payloads as changes and kept flipping shipping_updated_at.bgrf

    Solution Implemented

    • Deterministic Comparison: Normalize incoming and stored shipping records (trimming, lowercasing null-equivalents, JSON ordering) before comparing any fields.
    • True Change Detection: Exit early unless at least one normalized field actually changes; only then update the row and timestamp.
    • Safer Sync Refresh: Re-enabled the order-sync shipping refresh with guarded JSON parsing so existing records only move when Shopify genuinely edits the address.
    • Verbosity for Audits: Added focused debug logs enumerating the specific fields that changed to simplify future investigations.

    Follow-Up & Monitoring

    • Let natural traffic run; no manual address edit needed to validate the fix.
    • Tomorrow morning, spot-check the orders page to confirm badges only appear on the handful of orders with legitimate address edits.
    • If any badge still misbehaves, pull the associated DB row and webhook payload for a quick diff using the new logging breadcrumbs.

    QuickBooks Invoice Error

    Problem Identified

    • Issue: Session lookups started selecting users.customer_id, which isn’t in production, causing /api/auth/session to 500 while invoices were being pushed to QuickBooks.
    • Impact: The UI briefly showed “Application Error” after creating invoices; logs filled with column u.customer_id does not exist noise.

    Solution Implemented

    • Join Table Restoration: Updated NextAuth JWT/session queries to pull store/customer context from user_storesfulfillment_storescustomers, matching the live schema.
    • Shared Store Helper: Added a normalizeStores utility and rewired hooks/APIs (useCustomer, orders/products endpoints) to respect multi-store associations without relying on the missing column.
    • Type Safety: Extended next-auth typings so session consumers get structured store data in addition to the derived primary customer fields.

    Follow-Up & Monitoring

    • After deployment, re-run the QuickBooks invoice flow to confirm no auth/session errors surface.
    • Keep an eye on Heroku logs for any lingering column ... does not exist messages—should be silent now.
    • Schedule the real users.customer_id migration separately, once we’re ready to support parallel store assignments without regressions.
  • Fulfillment – Daily Changelog – September 24, 2025

    Fulfillment – Daily Changelog – September 24, 2025

    2025-09-24 – Customer Store Management System Implementation

    Customer Login and Store-Specific Management

    Problem Identified

    • Issue: All users currently see the same global view of orders, products, and inventory
    • Impact: No personalized experience for different customers/stores
    • Risk: Data privacy concerns and cluttered interface for multi-tenant system
    • Priority: High – fundamental to supporting multiple customers effectively

    Solution Implemented

    1. Customer Authentication Enhancement – COMPLETED

    • NextAuth Integration: Extended current authentication to support customer-specific sessions
    • Store Context: Added store identification to user sessions with customer_id, customer_name, customer_sku_prefix
    • Session Enhancement: Updated JWT and session callbacks to include customer context
    • Database Integration: Added customer filtering to user queries

    2. Store-Specific Data Filtering – COMPLETED

    • Database Queries: Modified orders and products APIs to filter by customer_id
    • API Endpoints: Updated API routes to respect customer context with session-based filtering
    • React Query: Enhanced hooks with credentials for session authentication
    • Customer Context: Created useCustomer hook for accessing customer information

    3. Customer Dashboard Views – COMPLETED

    • Personalized Interface: Created customer-specific header with store branding
    • Store Navigation: Built store-aware navigation component with conditional access
    • Customer Dashboard: Developed personalized dashboard with metrics and recent activity
    • Layout System: Implemented customer dashboard layout with sidebar navigation

    4. Multi-Tenant Architecture – COMPLETED

    • Data Isolation: Implemented session-based filtering to ensure customers only see their data
    • Store Identification: Added customer_id field to user sessions for proper store mapping
    • Scalable Design: Architecture supports multiple customers with shared codebase
    • Access Control: Ready for role-based gatekeeping (deferred for preview)

    Technical Implementation Details

    Authentication & Session Management

    • NextAuth Enhancement: Extended session types to include customer context
    • JWT Integration: Added customer information to JWT tokens
    • Database Joins: Enhanced user queries with customer information
    • Session Security: Proper authentication flow with credentials

    API & Data Layer

    • Customer Filtering: Orders and products APIs filter by user.customer_id
    • Session Validation: Server-side session checking for data access
    • React Query: Updated hooks to include authentication credentials
    • Error Handling: Graceful fallbacks for missing customer context

    User Interface Components

    • Customer Header: Shows current store information and branding
    • Store Navigation: Conditional navigation based on customer access
    • Customer Dashboard: Personalized metrics and recent activity
    • Layout System: Responsive layout optimized for customer workflows

    Security Considerations

    • Data Isolation: Customers can only access their own orders, products, and inventory
    • Session-Based Filtering: All API calls respect customer context
    • Role Flexibility: Architecture supports different user roles and permissions
    • Preview Mode: Gatekeeping deferred to allow interface preview

    Implementation Status

    COMPLETED FEATURES:
    ✅ Customer session enhancement with store context
    ✅ Store-specific data filtering in APIs
    ✅ Customer-aware React Query hooks
    ✅ Personalized dashboard with store branding
    ✅ Store navigation with conditional access
    ✅ Customer context utility hooks

    DEFERRED FEATURES:
    ⏳ Role-based gatekeeping (for preview)
    ⏳ Comprehensive testing across all components
    ⏳ Database migration scripts for customer_id field
    ⏳ Advanced customer management interface

    Frontend Changes

    • Authentication Context: Enhanced user session with store information
    • Store-Aware Components: All data components filter by current store
    • Navigation Updates: Store-specific menu items and branding
    • User Profile Management: Store selection and preferences

    Backend Changes

    • Session Management: Store context in NextAuth sessions
    • Database Queries: Add store filtering to all data access
    • API Security: Ensure proper authorization for store-specific data
    • Multi-tenant Logic: Store-based data isolation

    Database Considerations

    • User-Store Mapping: Relationship between users and their stores
    • Data Filtering: Efficient queries with store-based WHERE clauses
    • Permissions: Store-level access control
    • Migrations: Database schema updates for multi-tenancy

    Impact & Benefits

    Customer Experience

    • Personalized Interface: See only relevant data for their store
    • Clean Experience: No clutter from other customers’ data
    • Brand Consistency: Store-specific branding and customization
    • Self-Service: Customers can manage their own data independently

    System Architecture

    • Security: Proper data isolation between customers
    • Scalability: Support for multiple customers without performance degradation
    • Maintainability: Clear separation of customer data
    • Multi-tenancy: Foundation for supporting multiple customers

    Business Benefits

    • Customer Satisfaction: Personalized experience improves user satisfaction
    • Data Privacy: Each customer sees only their own data
    • Operational Efficiency: Customers can self-manage their store data
    • Growth Potential: Architecture supports customer expansion

    Implementation Plan

    Phase 1: Authentication Enhancement

    • Extend NextAuth to include store context
    • Update user session management
    • Test login flow with store identification

    Phase 2: Data Filtering

    • Update all database queries with store filtering
    • Modify API endpoints for store-specific data
    • Implement React Query store-aware caching

    Phase 3: UI Components

    • Create store-specific dashboard components
    • Update navigation and menus
    • Implement store selection/preferences

    Phase 4: Testing & Validation

    • Test data isolation between customers
    • Validate store-specific filtering
    • Ensure proper authorization and security

    Categories Implemented

    Customer Management

    • Store-specific authentication
    • Customer dashboard views
    • Store preferences and settings

    Data Security

    • Multi-tenant data isolation
    • Store-based access control
    • Customer data privacy

    System Architecture

    • Scalable multi-tenant design
    • Store-aware data filtering
    • Customer-specific UI components

    Testing & Validation

    • Authentication Flow: Store context in user sessions
    • Data Isolation: Customers see only their own data
    • UI Components: Store-specific interface elements
    • API Security: Proper authorization for store data
    • Performance: Multi-tenant queries perform efficiently

    Security Fixes

    • tar-fs Vulnerability: Fixed symlink validation bypass by updating from 2.1.2 to 3.1.1
    • Package Dependencies: Resolved multiple security vulnerabilities via npm audit fix
    • GitHub Security Warnings: Addressed tar-fs symlink validation bypass warning

    Future Enhancements

    • Customer Onboarding: Automated store setup for new customers
    • Advanced Permissions: Granular permissions within stores
    • Analytics: Customer-specific usage analytics
    • Customization: Store-specific themes and branding
    • Integration: Customer-specific API access and webhooks

    Summary

    Successfully implemented complete customer store management system with personalized, secure access to store-specific data and complete customer isolation. This comprehensive implementation includes full UI/UX refinements and ensures customers can only access their own data and functionality.

    Total Impact: Complete multi-tenant transformation with customer-specific data management, personalized dashboards, store-aware navigation, customer-only routes, comprehensive UI/UX improvements, and critical security vulnerability fixes.

    Today’s Complete Feature Set:

    • Customer Authentication: Enhanced NextAuth with store context
    • Data Isolation: All APIs filter by customer_id with proper security
    • Customer Dashboard: Personalized interface with metrics and activity
    • Navigation System: Complete customer-only navigation with proper routing
    • UI/UX Refinements: Fixed all text overflow, contrast, and layout issues
    • Route Structure: Customer-specific routes for all functionality
    • Quick Actions: All links properly point to customer-specific pages
    • Order Management: Customer-specific orders with proper filtering
    • Debugging: Fixed order number display and random number issues
    • Security Fixes: Resolved tar-fs symlink validation bypass vulnerability

    This changelog documents the implementation of customer login functionality and store-specific management capabilities. Gatekeeping features are deferred for interface preview, allowing immediate demonstration of the customer experience. The system is ready for role-based access control implementation when needed.

    Key Features Built:

    • ✅ Customer session management with store context
    • ✅ Store-specific data filtering across APIs
    • ✅ Personalized customer dashboard with metrics
    • ✅ Store-aware navigation and layout system
    • ✅ Customer context utilities and hooks
    • ✅ Complete customer-only navigation system
    • ✅ Customer-specific route structure (orders, products, production, inventory, invoices, settings)
    • ✅ UI/UX refinements (text overflow, contrast, layout fixes)
    • ✅ Quick action link corrections
    • ✅ Order number formatting and display fixes
    • ✅ Customer data isolation and security
    • ✅ Ready for role-based access control

    Preview Available: /customer-dashboard – Complete customer experience with isolated data and functionality

    Complete Customer Isolation Implementation

    • Customer-Only Navigation: All navigation links point to customer-specific routes
    • No Admin Access: Customers cannot access any admin functionality
    • Complete Data Isolation: All data filtered by customer context
    • UI/UX Refinements: Fixed text overflow, contrast, and layout issues

    UI/UX Fixes Completed

    • Navigation Text Overflow: Fixed text wrapping in store navigation component
    • Button Contrast: Improved active navigation button contrast (blue-600 background)
    • Layout Responsiveness: Added proper overflow handling and mobile responsiveness
    • Dashboard Link Fix: Fixed “Dashboard” link redirecting to admin dashboard
    • Order Numbers: Fixed double hashtag display in order numbers
    • Quick Actions: All quick action links point to customer-specific routes

    Customer-Specific Routes Created

    • /customer-dashboard/orders – Customer-specific orders with filtering
    • /customer-dashboard/products – Customer product catalog (ready for implementation)
    • /customer-dashboard/production – Customer production tracking (ready for implementation)
    • /customer-dashboard/inventory – Customer inventory management (ready for implementation)
    • /customer-dashboard/invoices – Customer invoice management (ready for implementation)
    • /customer-dashboard/settings – Customer store settings (ready for implementation)

    Design Work in Progress

    • Temporarily hardcoding “Mama Tried” branding for design iteration
    • Role-based redirects disabled for preview purposes
    • Focus on UI/UX improvements before implementing access controls

    Updated Implementation Status

    COMPLETED FEATURES:
    ✅ Customer session enhancement with store context
    ✅ Store-specific data filtering in APIs
    ✅ Customer-aware React Query hooks
    ✅ Personalized dashboard with store branding
    ✅ Store navigation with conditional access
    ✅ Customer context utility hooks
    ✅ Complete customer-only navigation system
    ✅ UI/UX fixes (text overflow, contrast, layout)
    ✅ Customer-specific route structure
    ✅ Order number formatting fixes
    ✅ Quick action link corrections

    DEFERRED FEATURES:
    ⏳ Role-based gatekeeping (for preview)
    ⏳ Comprehensive testing across all components
    ⏳ Database migration scripts for customer_id field
    ⏳ Advanced customer management interface

  • Time Clock – Daily Changelog – September 24, 2025

    Time Clock – Daily Changelog – September 24, 2025

    Daily Changelog – September 24, 2025 – little changes

    Fixes

    • Fixed dark header backgrounds in entries page by changing from bg-card to bg-muted2 for better light mode contrast
    • Fixed missing header backgrounds in employees page by changing from bg-card to bg-muted2 for better light mode visibility
    • Fixed dark header backgrounds in schedule pages by changing from bg-info to bg-muted2 for better light mode contrast
    • Fixed dark header backgrounds in shared table component by changing from bg-card to bg-muted2 for better light mode contrast across all tables

    Improvements

    • Improved light mode readability across entries, employees, and schedule pages with consistent header styling
    • Standardized header background tokens to use muted variants for better contrast in both light and dark modes
    • Created shared DepartmentHeader component to ensure all department headers use identical styling across the app
    • Removed alternating background colors from entries page that created visual inconsistency
    • Debugged color token system to identify why bg-muted wasn’t visible (very light yellow color)
  • Fulfillment – Daily Changelog – September 23, 2025

    Fulfillment – Daily Changelog – September 23, 2025

    2025-09-23 – Technical Documentation System Implementation

    Major Documentation Infrastructure Overhaul

    Problem Identified

    • Issue: Technical documentation was mixed with user help content
    • Impact: User help center cluttered with developer-only documentation
    • Risk: Users confused by technical jargon, developers can’t find technical docs
    • Priority: High – affects both user experience and developer productivity

    Solution Implemented

    1. Fixed Markdown Rendering System – COMPLETED

    • Issue: Help articles displayed raw markdown syntax instead of rendered HTML
    • Root Cause: Plain text rendering instead of proper markdown processing
    • Solution: Integrated ReactMarkdown with GitHub Flavored Markdown support
    • Impact: Beautifully formatted documentation with headers, lists, code blocks, tables

    2. Created Separate Technical Documentation System – COMPLETED

    • New API Endpoints: /api/tech-docs/list and /api/tech-docs/view/[filename]
    • New React Components: TechDocsList and TechDocsViewer
    • New Help Center Tab: “Technical Docs” alongside “Articles” and “Documentation”
    • Auto-categorization: Technical docs automatically sorted by topic

    3. Cleaned Up User Help System – COMPLETED

    • Removed Technical Content: 10 technical docs moved to separate system
    • Kept User-Facing Content: 8 user-focused help articles remain
    • Proper Separation: Clear distinction between user help and technical documentation
    • Better UX: Users see relevant content, developers have dedicated space

    4. Enhanced Documentation Features – COMPLETED

    • Full Markdown Support: Headers, lists, code blocks, links, tables
    • GitHub Flavored Markdown: Extended syntax support
    • Smart Preview Generation: Clean text previews without markdown syntax
    • Category Organization: API & Integration, Development, Production, Task Management
    • Search & Filtering: Find technical docs by title, description, or category

    Technical Implementation Details

    Frontend Changes

    • Help Article Viewer: Now uses ReactMarkdown for proper rendering
    • Tech Docs Viewer: Dedicated component for technical documentation
    • Help Articles List: Smart markdown preview generation
    • Tech Docs List: Category-based filtering and search

    Backend Changes

    • New API Routes: /api/tech-docs/ endpoints for technical documentation
    • Database Cleanup: Removed technical docs from user help articles
    • Markdown Processing: Server-side markdown file reading and serving
    • Error Handling: Graceful fallbacks when documentation is unavailable

    Documentation Architecture

    • User Help Articles: 8 user-facing help articles (Orders, Production, Inventory, General)
    • Technical Documentation: 9 developer-focused docs (API setup, integration guides, system docs)
    • Separate Access: Different tabs in help center for different audiences
    • Proper Categorization: Each document tagged with appropriate category

    Impact & Benefits

    User Experience

    • Cleaner Help Center: User-facing content only, no technical jargon
    • Relevant Results: Users see content appropriate to their needs
    • Beautiful Formatting: Proper markdown rendering with typography

    Developer Experience

    • Dedicated Tech Docs: Separate system for technical documentation
    • Proper Organization: Categorized by technical topic (API, Development, etc.)
    • Full Markdown Support: Rich formatting for technical content
    • Search & Discovery: Easy to find technical documentation

    System Architecture

    • Separation of Concerns: User help vs technical documentation
    • Scalable: Easy to add more technical docs without cluttering user help
    • Maintainable: Clear boundaries between different types of documentation
    • Future-Proof: Architecture supports growth in both user and technical content

    Categories Implemented

    User Help Articles (8 articles)

    • Orders: Order combining system, daily summary setup
    • Production: File management, reference points, placement guides
    • Inventory: Inventory checking functionality
    • General: Bulk transfers, system overview

    Technical Documentation (9 articles)

    • API & Integration: Email setup, Shopify integration
    • Development: Local development setup
    • Production: File assignment processes, system features
    • Task Management: API setup, integration guides
    • Technical Documentation: System internals, configuration guides

    Testing & Validation

    • User Help Articles: Display properly formatted content
    • Technical Documentation: Full markdown rendering with categories
    • Navigation: Clear separation between user and technical content
    • Search: Both systems have proper search and filtering
    • Error Handling: Graceful fallbacks when content unavailable

    Future Enhancements

    • Documentation Analytics: Track which docs are most accessed
    • Version Control: Git-based documentation versioning
    • Collaboration: Comment system for technical documentation
    • Auto-generation: API docs generated from code comments
    • Search Improvements: Full-text search across all documentation

    Summary

    Major infrastructure improvement completed – created proper separation between user help content and technical documentation. Users now have a clean, focused help experience while developers have a dedicated, well-organized technical documentation system. Both systems use modern markdown rendering for beautiful, professional documentation display.

    Total Impact: 17 documentation articles properly organized and accessible through dedicated systems.

  • Time Clock – Daily Changelog – September 23, 2025

    Time Clock – Daily Changelog – September 23, 2025

    Daily Changelog – September 23, 2025

    Daily Changelog – September 23, 2025

    Improvements

    • Removed non-functional “View as Employee” functionality from admin navbar since dedicated employee portal exists
    • Removed ViewRoleBanner component from layout since view role switching no longer needed
    • Removed ViewRoleProvider and useViewRole hook to clean up unused code
    • Cleaned up commented view role imports in sick-days page

    Security

    • Implemented whitelist security approach: employees only allowed explicit routes they need
    • Added comprehensive middleware protection using allowlist instead of blocklist
    • Protected sensitive API routes from employee access with 403 responses
    • Updated navigation configuration with role-based restrictions on all admin functionality
    • Added employee-specific navigation items and removed admin menu for employees
    • Preview mode respects role overrides for UI testing without granting actual access

    Preview Mode

    • Restored “Preview as Employee” functionality for admins to test employee experience
    • Preview mode shows UI changes without granting actual access to restricted data
    • Admins can verify what employees see before making interface changes

    Fixes

    • Fixed time display showing impossible chronological times (clock-in after clock-out) by enforcing strict UTC ISO string handling across all time clock APIs
    • Fixed payroll calculations to match legacy FileMaker app totals by implementing proper 30-minute lunch credit logic
    • Resolved variable shadowing compilation errors in time_clock_records API that were causing Heroku build failures
    • Fixed TypeScript error in NavbarWrapper where userRole could be undefined
    • Fixed unused variable warnings in middleware and entries page

    Improvements

    • Implemented 30-minute lunch credit for employees with “Break Rules” record set to Yes/Y/true/1
    • Applied lunch credit at day level with 2-decimal rounding to match legacy system behavior
    • Enhanced payroll export queries to calculate daily totals with lunch credit before weekly aggregation
    • Updated time display format to show 12-hour AM/PM format instead of 24-hour format on entries page
  • Fulfillment – Daily Changelog – September 22, 2025

    Fulfillment – Daily Changelog – September 22, 2025

    2025-09-22 – Order Combining Detection System

    Order Management Enhancement – Duplicate Order Detection

    Problem Identified

    • Issue: Multiple pending orders for the same customer are being fulfilled separately
    • Impact: Inefficient shipping, increased costs, poor customer experience
    • Risk: Continued waste of shipping resources and potential customer dissatisfaction
    • Priority: High – addresses operational inefficiency and cost savings opportunity

    Investigation Plan

    • [ ] Analyze current order structure and customer identification methods
    • [ ] Identify how to detect orders that can be combined
    • [ ] Evaluate combining orders in Shopify vs. internal system
    • [ ] Design UI notifications for combinable orders
    • [ ] Implement detection logic for same customer/same address orders

    Current Analysis

    • Order Structure: Need to examine mama_tried_orders and related tables
    • Customer Matching: Identify how customers are linked across orders
    • Address Matching: Determine if shipping addresses can be reliably compared
    • Shopify Integration: Evaluate feasibility of combining orders at Shopify level
    • Internal System: Assess benefits of internal order combining workflow

    Technical Implementation Plan

    Order Detection Logic ✅ IMPLEMENTED

    • Customer Matching: Use customer_id, email, shipping name, and address for identification
    • Status Filtering: Focus on pending orders that haven’t been processed yet
    • Address Validation: Implement fuzzy address matching for slight variations
    • Time Window: Consider orders placed within a reasonable time frame (e.g., same day)
    • API Endpoint: /api/orders/combinable returns groups of combinable orders

    UI/UX Enhancements ✅ IMPLEMENTED

    • Notification System: Alert staff when combinable orders are detected
    • Order Details Page: Show potential order combinations
    • Batch Processing: Option to combine orders before fulfillment
    • Visual Indicators: Clear flags for orders that can be combined

    Integration Considerations

    • Shopify API: Evaluate if Shopify supports order combining
    • Shipping Impact: Ensure combined orders maintain proper shipping calculations
    • Inventory Management: Verify stock levels can handle combined quantities
    • Workflow Integration: Integrate with existing order processing workflow

    Shopify vs Internal Order Combining Evaluation

    Shopify Order Combining Limitations

    • Shopify API Constraints: Shopify does not provide native order combining functionality
    • Order Integrity: Each Shopify order has unique identifiers that cannot be merged
    • Customer Experience: Combining at Shopify level would require order cancellation/recreation
    • Third-party Dependencies: Would need to handle refunds, notifications, and customer communication
    • Timeline Issues: Orders already in fulfillment pipeline cannot be easily combined

    Internal System Combining Advantages

    • Workflow Control: Full control over the combining process within existing workflows
    • Data Integrity: Maintain order history and audit trails for each original order
    • Customer Transparency: Keep original order numbers for customer reference
    • Flexible Logic: Implement business rules for when/how orders can be combined
    • Shipping Optimization: Better control over shipping calculations and methods

    Recommended Approach: Internal System with Notifications

    • Phase 1 (✅ Completed): Detection and notification system (implemented)
    • Phase 2 (Recommended): Internal order combining with virtual consolidation
    • Phase 3 (Optional): Shopify fulfillment grouping for shipping efficiency

    Internal Combining Strategy

    1. Virtual Consolidation: Create combined orders in internal system without modifying Shopify
    2. Batch Processing: Process combined orders together for fulfillment
    3. Shipping Optimization: Apply combined shipping rates and methods
    4. Audit Trail: Maintain links between original and combined orders
    5. Customer Communication: Reference original order numbers in combined shipments

    Current Status

    Completed

    • Analyzed order management system structure
    • Created API endpoint for detecting combinable orders (/api/orders/combinable)
    • Built UI component for displaying combinable order alerts
    • Integrated notification system into orders page
    • Implemented customer-based and address-based matching logic

    In Progress

    • Evaluating technical approaches for order detection and combining

    Next Steps

    • Test with real order data
    • Add order combining functionality (API endpoint to combine orders)
    • Enhance UI with combine action buttons
    • Evaluate Shopify vs internal combining approach

    Notes

    • Operational Efficiency: This addresses a real-world inefficiency observed in shipping
    • Customer Experience: Combined orders provide better service and potentially faster delivery
    • Cost Savings: Reduced shipping costs through order consolidation
    • Implementation Strategy: Start with detection and notifications, then evaluate combining options
  • Time Clock – Daily Changelog – September 22, 2025

    Time Clock – Daily Changelog – September 22, 2025

    Daily Changelog – September 22, 2025

    Fixes

    • Fixed time display formatting on entries page to keep start/end times on single lines

    Improvements

    • Adjusted column widths on entries page to better accommodate time displays and improve layout
    • Made TimePill components more compact with reduced padding and smaller text size
    • Changed Start · End column layout from space-y to flex column for better time display
    • Reduced Duration and Hours column widths to make room for wider time columns
    • Added whitespace-nowrap to prevent time text wrapping in break columns
    • Updated break time displays to use flex column layout with smaller text
    • Fixed all TypeScript errors related to Date vs UTCISOString type mismatches across multiple files
    • Corrected import statements to use date-fns for addDays, startOfWeek, and differenceInCalendarDays functions
    • Fixed formatLocal function calls to properly convert Date objects to UTCISOString before formatting
    • Modified payroll export system to exclude employees in Company Leadership department from payroll exports while keeping them trackable in system for management purposes

    Notes

    • Successfully resolved all TypeScript compilation errors and achieved successful Heroku deployment after extensive debugging
  • Fulfillment – Daily Changelog – September 20, 2025

    Fulfillment – Daily Changelog – September 20, 2025

    2025-09-20 – Duplicate Invoice Prevention System

    Critical Issue – Duplicate Invoice Prevention

    Problem Identified

    • Issue: System created duplicate invoices for the same order yesterday
    • Impact: Both invoices were pushed to QuickBooks and automatically paid
    • Risk: Financial discrepancies and double payments
    • Priority: Critical – needs immediate attention

    Investigation Plan

    • [x] Analyze invoice creation workflow
    • [x] Identify potential race conditions or duplicate triggers
    • [x] Implement safeguards to prevent duplicate invoice generation
    • [x] Add validation checks before QuickBooks integration
    • [x] Test invoice creation process thoroughly

    Root Causes Identified

    • No Database Constraints: mama_tried_invoices table lacks unique constraint on invoice_number
    • No Idempotency Protection: Multiple API calls can create invoices for same orders
    • QuickBooks Integration Risk: No check if invoice already sent to QuickBooks
    • Race Condition Potential: Multiple users can create invoices simultaneously

    Implemented Solutions

    Database-Level Protection

    • Added UNIQUE constraint on mama_tried_invoices.invoice_number to prevent database-level duplicates
    • Created invoice_operations table for idempotency tracking and audit trail

    Invoice Creation Safeguards

    • Pre-invoice validation: Check if orders already have invoices before creation
    • Idempotency key system: Generate unique keys to prevent duplicate API calls
    • Conflict detection: Return 409 status code with detailed error information
    • Audit trail: Track all invoice creation operations with timestamps and user info

    QuickBooks Integration Safety

    • Duplicate push prevention: Check quickbooks_invoice_id and status before sending
    • Status validation: Prevent sending invoices already marked as ‘sent_to_quickbooks’
    • Detailed error responses: Clear messaging when duplicates are detected

    Frontend Protection

    • Idempotency key generation: Unique keys based on timestamp, order IDs, and random string
    • Enhanced error handling: Specific handling for 409 conflict responses
    • User feedback: Clear toast notifications for duplicate prevention triggers

    Current Status

    Completed

    • Comprehensive duplicate invoice prevention system implemented
    • Database constraints and validation in place
    • Idempotency protection for API calls
    • QuickBooks integration safeguards
    • Frontend duplicate prevention with user feedback

    Ready for Testing

    • All safeguards are in place and ready for production testing
    • System will now prevent duplicate invoices at multiple levels
    • Financial risk significantly reduced through layered protection

    Technical Implementation Details

    Database Changes

    • mama_tried_invoices: Added UNIQUE constraint on invoice_number column
    • invoice_operations: New table for idempotency tracking with columns:
    • idempotency_key (VARCHAR, UNIQUE)
    • operation_type (VARCHAR, default ‘invoice_creation’)
    • status (VARCHAR, default ‘completed’)
    • result_data (TEXT, stores JSON response)
    • created_at, created_by (audit fields)

    API Endpoint Changes

    • /api/invoices POST: Added pre-creation duplicate checks and idempotency support
    • /api/intuit/send-db-invoice GET: Added QuickBooks duplicate push prevention
    • Error handling: Enhanced with 409 Conflict status codes and detailed error messages

    Frontend Changes

    • invoice-dialog.tsx: Added idempotency key generation and duplicate error handling
    • User experience: Clear feedback when duplicate prevention triggers

    Notes

    • Critical financial protection: Multi-layered duplicate prevention system now active
    • Immediate deployment: All changes are backward compatible and safe for production
    • Testing recommended: Verify duplicate prevention works as expected before next invoice cycle
    • Monitoring: Watch logs for “DUPLICATE PREVENTION” and “IDEMPOTENCY” messages