Category: Changelogs

  • Time Clock – Daily Changelog – September 19, 2025

    Time Clock – Daily Changelog – September 19, 2025

    Daily Changelog – September 19, 2025

    Fixes

    • Fixed holiday date display issue in calendar settings where Labor Day showed as Aug 31 instead of Sep 1 by changing formatLocal() to formatDateOnlyLocal() in HolidaysSection.tsx, resolving timezone conversion error for date-only strings

    Improvements

    • Updated payroll export to include holiday_hours totals in total_holiday_hours and summed into total_hours on API api/payroll/export, improving accuracy for holiday weeks

    New

    • Added daily holiday hours generator API api/holiday-hours/generate to upsert paid holiday entries per eligible employee based on master schedules (8 or 10 hours), enabling automatic holiday population
    • Added script scripts/generate-holiday-hours.js with npm command npm run holiday:generate to trigger holiday generation via deployed app URL, allowing Heroku Scheduler or manual runs
    • Added unified time-off entries API api/time-off/entries to combine PTO requests and holiday hours into single dataset with employee names and filtering
    • Added time-off entries page time-off/entries with data table showing all vacation and holiday entries across employees, accessible from navigation menu
    • Backfilled holiday hours for Memorial Day 2025 and Labor Day 2025 for all eligible employees using deployed script

    Notes

    • Holiday generator script initially failed due to API changes not being deployed; resolved after deployment
    • Time-off entries page initially showed future empty holiday placeholders; fixed by defaulting includeCalendar=false to hide scheduled holidays until actual entries exist
  • Fulfillment – Daily Changelog – September 19, 2025

    Fulfillment – Daily Changelog – September 19, 2025

    2025-09-19 – Shipping Address Badge System Fixes

    Critical Bug Fixes

    Fixed False Positive “Address Updated” Badges

    • Problem: Every order was showing “📍 Address Updated” badge even when no shipping changes occurred
    • Root Cause: Both webhook handler and sync process were calling updateOrderShippingAddress with faulty comparison logic
    • Solution: Temporarily disabled automatic shipping address updates in both webhook and sync processes
    • Result: Only legitimate address changes now show the badge (e.g., order #5303 from 8/29)

    Database Cleanup

    • Cleared all false positive shipping_updated_at timestamps from recent orders
    • Restored only the legitimate shipping update for order #5303
    • Prevented system from appearing unreliable to staff/customers

    Code Changes

    • src/app/api/webhooks/shopify/route.ts: Disabled updateOrderShippingAddress calls in webhook handler
    • src/app/api/orders/sync/route.ts: Disabled shipping updates during order sync process
    • Database: Reset shipping_updated_at values to prevent false badge displays

    Build & Deployment Fixes

    Fixed Multiple Build Errors

    • JSX Syntax Error: Fixed missing fragment wrapper in invoice-dialog.tsx
    • Import Path Error: Corrected useToast import path in invoice-creation-success.tsx
    • Linting Errors: Commented out unused variables and fixed unescaped entities
    • Route Conflict: Removed duplicate API route causing Next.js build failures

    Current Status

    Working

    • Badge system now shows accurate shipping address change indicators
    • Invoice creation flow functional
    • Build and deployment process stable

    Root cause: updateOrderShippingAddress comparison logic is faulty – treats every address as “changed”

    What needs to be done RIGHT NOW:

    1. Debug the address comparison in updateOrderShippingAddress function
    2. Fix the logic so it only flags actual changes
    3. Re-enable webhook and sync shipping updates
    4. Test with real address changes to make sure it works

    System Reliability

    • Address root cause of frequent Friday system failures
    • Implement better testing for critical workflows
    • Consider staging environment for testing changes
  • Time Clock – Daily Changelog – September 18, 2025

    Time Clock – Daily Changelog – September 18, 2025

    Daily Changelog – September 18, 2025

    Fixes

    • Fixed missing calendar entries causing schedule generation failures by adding auto-creation of calendar entries in generateWeeklySchedulesRefactored function
    • Resolved “generate more weeks” functionality breaking when calendar entries don’t exist for future dates
    • Added defensive programming to schedule generation to automatically create missing calendar dates instead of failing
    • Fixed PTO requests API to return date fields as plain text strings using ::text casting to prevent timezone conversion of date-only values
    • Resolved date display issues where manual PTO requests showed incorrect dates due to UTC timestamp conversion in API layer

    Improvements

    • Enhanced schedule generation robustness by ensuring calendar entries exist before attempting to generate schedules
    • Added automatic calendar entry creation for any missing dates during schedule generation process
    • Cleaned up import modal styling by removing unprofessional emojis and fixing contrast issues with yellow file upload button
    • Improved schedule page layout with proper button grouping, spacing between header and content, and better department section separation
    • Fixed cramped UI elements across multiple pages by adding appropriate gaps and breathing room
    • Enhanced payroll export page to automatically select the most recent relevant pay period instead of defaulting to blank selection
    • Fixed payroll export SQL GROUP BY error by adding missing columns to GROUP BY clause
    • Added CSV export functionality to payroll export API with proper Content-Disposition headers for file downloads
    • Simplified payroll export query to resolve complex recursive CTE issues causing data retrieval failures
    • Added defensive programming to payroll export frontend to handle non-numeric values with Number() conversion
  • Time Clock – Daily Changelog – September 17, 2025

    Time Clock – Daily Changelog – September 17, 2025

    Daily Changelog – September 17, 2025

    Fixes

    • Fixed timezone display issues in PTO request dates where date-only values (2025-10-20) were being incorrectly interpreted as UTC and shifted by timezone conversion, causing 10/20 to display as 10/19
    • Updated time-off-requests page to use formatDateOnlyLocal instead of formatLocal for proper date-only formatting
    • Fixed DateTime.fromISO calls in employee portal, main dashboard, and leave of absence components to specify America/Chicago timezone for date-only strings
    • Resolved date shifting in FileMaker PTO import display where imported 10/20 and 11/20 requests appeared as 10/19 and 11/19 in frontend
    • Fixed PTO import functions to use simple date component parsing instead of timezone-aware parseAppDate for date-only values
    • Removed unnecessary timezone conversion from both FileMaker PTO import and regular PTO import routes
    • Standardized date-only parsing across all import functions to match time clock import approach (direct MM/DD/YYYY to YYYY-MM-DD conversion)
    • Resolved massive TypeScript build regression where 208+ errors were caused by systematic removal of date-fns imports while leaving function calls intact
    • Restored missing date-fns imports to 23+ files including format, parseISO, addDays, startOfWeek functions
    • Fixed duplicate DateTime import causing webpack compilation failure in payroll pay-periods page
    • Fixed UTCISOString type casting errors across 15+ components by adding proper type assertions
    • Fixed Luxon DateTime method calls (.toISOString() → .toISO(), .getTime() → .toJSDate().getTime())
    • Resolved import conflicts in time.ts library where date-fns functions conflicted with existing implementations
    • Fixed missing fs import in wordpress-simple.ts and various API route type errors
    • Installed missing @types/luxon and date-fns packages to restore proper TypeScript definitions
    • Fixed function declaration order issues where useEffect hooks referenced functions before they were declared
  • 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
  • Time Clock – Daily Changelog – September 16, 2025

    Time Clock – Daily Changelog – September 16, 2025

    Daily Changelog – September 16, 2025

    Improvements

    • Changed agent terminology from “PTO” to “vacation” throughout system prompts and interface to match company usage
    • Added confirmation step to agent time off requests – agent now presents request details for user approval before submitting
    • Improved agent response format to display natural text instead of raw JSON in conversation history
    • Enhanced agent system prompt to default to “vacation” type unless user specifies sick leave, personal time, or other types

    Fixes

    • Fixed 400+ linting violations across 70+ files by removing eslint.ignoreDuringBuilds and typescript.ignoreBuildErrors from next.config.ts
    • Replaced all Date instantiations with proper time library functions from src/lib/time.ts
    • Converted all date-fns imports to use centralized time utilities
    • Fixed TypeScript any types with proper type definitions
    • Removed unused variables and imports across codebase
    • Achieved 100% reduction in linting violations (400+ → 0)

    Notes

    • Agent now follows two-step process: confirm_time_off tool for user confirmation, then create_time_off_request after approval
    • Build process now properly enforces code quality standards and will fail on violations
  • 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
  • Time Clock – Daily Changelog – September 15, 2025

    Daily Changelog – September 15, 2025

    Fixes

    • Fixed break constraint violation in time clock import by adding validation to skip breaks with identical start/end times
    • Updated import scripts to check break_end > break_start before insertion in all import processes
    • Added logging for invalid breaks to help debug future import issues
    • Prevented database constraint violation errors during time clock data import

    Notes

    • Import process now handles edge cases where break start and end times are identical
    • All import scripts (Python and JavaScript) now include proper break validation
  • 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
  • Time Clock – Daily Changelog – September 10, 2025

    Daily Changelog – September 10, 2025

    New

    • Implemented comprehensive profile management system with personal information, preferences, and settings
    • Added pronoun selection with common options (he/him, she/her, they/them) plus custom input for zie/zir, xe/xem, etc.
    • Created avatar upload functionality and profile picture management
    • Added email notification preferences with granular control over different notification types
    • Implemented profile visibility settings to control what information is shown to other users
    • Built tabbed interface for organized profile management (Personal, Notifications, Privacy)
    • Added bio field and phone number management for enhanced user profiles
    • Implemented improved time-off request flow with clear form labels and confirmation step
    • Added “First day off” and “Last day off” labels with helper text to eliminate confusion
    • Created confirmation dialog showing time off period and first day back at work
    • Added smart validation to detect when employees include their first day back in requests

    Fixes

    • Fixed time-off request approval blocking when employees have insufficient PTO balance
    • Modified database function to allow partial PTO deductions for approved requests
    • Updated email approval route to properly handle PTO deductions and respect use_pto flag
    • Removed approval reversions when PTO deduction fails to allow unpaid time off approvals
    • Fixed green-on-green contrast issue in success messages across multiple components
    • Updated AlertBanner and other components to use proper foreground colors for text readability
    • Created automated contrast validation and fix scripts to prevent future color contrast issues
    • Fixed 50 additional contrast violations across 15 files using automated script
    • Added pre-commit hook to prevent contrast violations from being committed
    • Created missing UI components (Textarea, Switch, Tabs) that were causing deployment failures on Heroku
    • Fixed module resolution errors for @/components/ui/textarea, @/components/ui/switch, and @/components/ui/tabs in profile page
    • Updated UI component index.ts to export the new components following existing patterns
    • Fixed custom pronouns input field functionality in profile page – now properly shows and allows typing when “Custom…” is selected
    • Simplified pronoun options to only include the most common ones (he/him, she/her, they/them) with custom input for any other preferences

    Improvements

    • Updated both employee portal and admin time-off request forms with consistent UX
    • Added gentle warning for common Friday-to-Monday mistake pattern
    • Changed form submission flow to show confirmation before final submission