Tag: blanks

  • Fulfillment – Daily Changelog – October 28, 2025

    Fulfillment – Daily Changelog – October 28, 2025

    Changelog – October 28, 2025

    POD Category Inventory System Implementation

    Overview

    Implemented a comprehensive Print on Demand (POD) inventory system that tracks blank garments by category or specific style. This allows for flexible inventory management where POD inventory is separate from regular blank inventory, enabling better tracking for print-on-demand orders.

    Database Changes

    1. New Migration: add_pod_blank_inventory.sql

    • Added blank_category_id column to warehouse_items table
    • Added new item type 'pod_blank' to warehouse items
    • Created database views:
    • v_pod_category_inventory – Aggregated POD inventory by category
    • v_pod_style_inventory – POD inventory for style-specific items
    • Added indexes for performance optimization
    • Warehouse items can now have either garment_id (specific style) OR blank_category_id (category-based)

    TypeScript Type Updates

    Updated src/types/warehouse-inventory.ts

    • Added 'pod_blank' to WarehouseItemType enum
    • Added blank_category_id field to WarehouseItem interface
    • Added category relation type for warehouse items
    • Created new POD-specific types:
    • PODCategoryInventory – Category-based inventory with size aggregation
    • PODStyleInventory – Style-specific inventory with size breakdown
    • PODInventoryResponse – API response structure for POD inventory

    Backend API Changes

    1. Updated src/app/api/warehouse-inventory/route.ts

    • Modified queries to include blank_category_id field
    • Added joins with blank_categories table
    • Updated response mapping to include category information
    • All warehouse inventory queries now return category data when applicable

    2. New API Endpoint: src/app/api/warehouse-inventory/pod/route.ts

    • GET /api/warehouse-inventory/pod – Fetches POD blanks with category aggregation
    • Returns separate arrays for category-based and style-specific inventory
    • Aggregates quantities by size across all styles in a category
    • Supports filtering by storage location

    3. Updated src/app/api/products/[id]/route.ts

    • Modified GET endpoint to join with blank_categories table
    • Returns category information in product data
    • Updated both initial fetch and PATCH update queries
    • Category data now available at product level

    Frontend Components

    1. Updated Product Cards

    Files: src/components/products/product-card.tsx, src/components/products/product-wide-card-view.tsx

    • Products using categories now display:
    • “Category” badge
    • Category name instead of individual styles
    • Category color information
    • Falls back to showing individual styles if no category is set

    2. Product Details Section

    File: src/components/products/product-sections/product-details.tsx

    • Already had category selection UI
    • Now properly displays selected category
    • Shows styles within the category with preference ranking

    3. New POD Inventory Page

    File: src/components/warehouse-inventory/pod-inventory-view.tsx

    • Dedicated view for POD inventory
    • Features:
    • Sub-tabs for “Blanks” and “Transfers”
    • Two separate inventory tables:
      • Category Inventory Table: Aggregates quantities across all styles in each category
      • Style-Specific Inventory Table: Shows POD items with specific style assignments
    • Size-based matrix view
    • Expandable rows to see contributing warehouse items
    • “Add POD Item” button

    4. New POD Blank Item Dialog

    File: src/components/warehouse-inventory/pod-blank-item-dialog.tsx

    • Create POD blank inventory items with full size/quantity support
    • Two selection modes:
    • Category Mode: Select a blank category (any style from category can be used)
    • Style Mode: Select specific style + color
    • Auto-generates item names based on selection
    • Size & Quantity Selector:
    • Automatically filters sizes based on category/style size category
    • Checkbox interface for selecting sizes
    • Quantity input for each selected size
    • Creates warehouse_item_variants and warehouse_variant_inventory records
    • Supports:
    • Category or style selection
    • Multiple sizes with quantities
    • Storage location assignment (required)
    • Description and notes
    • Name customization

    5. Updated Warehouse Inventory Page

    File: src/app/(authenticated)/warehouse-inventory/page.tsx

    • Added new “Print on Demand” tab between “Blank Garment Inventory” and “Staging Inventory”
    • Loads PODInventoryView component

    Features Implemented

    1. Category-Based Inventory Tracking
    • Warehouse items can be linked to blank categories instead of specific styles
    • System aggregates quantities across all styles in a category
    • Flexible for situations where any style from a category can fulfill an order
    1. Style-Specific POD Inventory
    • Still supports tracking specific style+color combinations
    • Useful for POD items that must use a particular garment
    1. Product Category Display
    • Products using categories show this clearly on product cards
    • Category name and color displayed prominently
    • No longer shows confusing “No styles assigned” when category is set
    1. Dedicated POD Tab
    • Separate inventory view specifically for POD items
    • Clean separation from regular blank inventory
    • Easy to see what’s available for POD orders
    1. Add POD Items
    • Comprehensive dialog for adding new POD inventory
    • Choose between category or style-specific
    • Select multiple sizes and enter quantities
    • Auto-naming for consistency
    • One-step process to create item with inventory

    Database Schema Summary

    -- New column
    ALTER TABLE warehouse_items 
    ADD COLUMN blank_category_id INTEGER REFERENCES blank_categories(id);
    
    -- New item type
    warehouse_items.item_type: 'pod_blank'
    
    -- New views
    v_pod_category_inventory
    v_pod_style_inventory

    Next Steps (Not Implemented Yet)

    1. Work Order Integration
    • Automatic inventory deduction when work orders are created
    • Style selection based on preference rank and availability
    1. Transfers Integration
    • Link transfers to POD inventory
    • Show POD transfers in the Transfers sub-tab
    1. Inventory Import
    • Update warehouse import dialog to support pod_blank type
    • CSV import with category references
    1. Bulk Adjustment
    • Allow editing quantities for existing POD items
    • Support transferring between storage locations
    1. Testing
    • Create test POD inventory items
    • Verify category display on product cards
    • Test POD inventory views and aggregation

    Recent Update: Size & Quantity Selector

    Enhanced the POD Blank Item Dialog to include a comprehensive size and quantity selector:

    • Smart Size Filtering: Automatically shows only relevant sizes based on the selected category or style’s size category
    • Checkbox Selection: Clean interface for selecting which sizes to add
    • Inline Quantity Entry: Enter quantities directly for each selected size
    • Multi-Size Creation: Creates all warehouse variants and inventory records in one transaction
    • Validation: Requires at least one size to be selected and a storage location
    • Smart Defaults: Storage location automatically defaults to “Print on Demand Supply” location

    Bug Fixes:

    1. Created missing /api/sizes endpoint that was preventing the size selector from loading. The endpoint fetches all sizes from the database, ordered by size category and display order.
    2. Updated /api/warehouse-items POST endpoint to include blank_category_id in the INSERT statement, fixing the “INSERT has more target columns than expressions” error.
    3. Enhanced /api/warehouse-items POST endpoint to handle multiple sizes at once – when a sizes array is provided, it creates warehouse_item_variants and warehouse_variant_inventory records for each size in a single transaction.
    4. Updated POD blank item dialog mutation to send sizes array to the API instead of trying to call non-existent variant/inventory endpoints.
    5. Fixed duplicate key constraint violation by appending size name to variant_name (e.g., “POD – 50/50 Medium Black T-Shirt – S”) to ensure uniqueness across multiple size variants.

    This completes the POD item creation workflow – you can now add fully-functional POD inventory items with sizes and quantities in one step!

    POD Inventory Management Features

    Incremental Inventory Addition:

    • POD items now work like real inventory – you can add stock incrementally to the same item
    • When adding inventory for a category/style that already exists, the system:
    1. Finds the existing warehouse item for that category/style+color
    2. Adds new sizes as variants if they don’t exist
    3. Updates quantities for existing sizes (adds to current stock)
    • Example workflow:
    • First time: Add 3 Small → creates “POD – 50/50 Medium Black T-Shirt” with 3 S
    • Later: Add 6 Large → adds to the same item, now has 3 S and 6 L
    • Later: Add 2 more Small → updates to 5 S and 6 L
    • No more duplicate warehouse items for the same category!

    Adjust Inventory & Delete POD Items:

    • Added Edit and Delete buttons to each warehouse item in the POD inventory view
    • Click the chevron next to a category row to expand and see contributing warehouse items
    • Each item shows an Edit button (pencil icon) and Delete button (trash icon)

    Edit/Adjust Inventory:

    • Opens a visual inventory adjustment dialog
    • Shows current quantities for all sizes in a grid layout
    • Adjust quantities with:
    • + / – buttons for quick adjustments
    • Direct input to set exact adjustment amounts
    • Visual preview showing: Current → Adjustment → New Total
    • Supports adding new sizes (enter positive number for sizes with 0 qty)
    • Supports reducing quantities (enter negative numbers, can’t go below 0)
    • Batch apply all changes at once
    • Real-time validation prevents negative quantities
    • Changes are highlighted in green (additions) or red (reductions)

    Delete Items:

    • Delete button performs force deletion – removes the warehouse item AND all associated inventory:
    • Deletes all warehouse_item_variants
    • Deletes all warehouse_variant_inventory records
    • Deletes warehouse_inventory aggregates
    • Shows detailed confirmation dialog before deletion
    • Perfect for cleaning up duplicate items or removing discontinued POD items
    • API supports ?force=true parameter to cascade delete all related records

    Notes

    • Regular blank inventory remains unchanged and separate
    • Work order inventory deduction will be implemented in a future phase
    • POD items are fully functional with complete size/quantity management
    • Color is determined by the category (for category-based items) or the selected style color (for style-specific items)
  • Fulfillment – Daily Changelog – October 20, 2025

    Fulfillment – Daily Changelog – October 20, 2025

    Changelog – October 20, 2025

    🎯 Blank Category Assignment Feature Implementation

    Overview

    Implemented the ability to assign blank categories to products instead of individual styles, allowing for more flexible inventory management and automatic SKU creation across multiple interchangeable styles.

    🚀 New Features

    Product Details – Blank Category Assignment

    • Added category selection UI in product details page
    • Toggle between Individual Styles and Blank Category modes
    • Category dropdown with live preview of styles in selected category
    • Automatic SKU creation for all styles in assigned category
    • Preference ranking display showing which style is default

    UI Components

    • Radio button toggle for choosing between individual styles vs category
    • Category selector dropdown with style preview
    • Real-time style display showing brand, name, and preference ranking
    • Visual feedback for current assignment mode

    🔧 Technical Implementation

    Database & API Integration

    • Leveraged existing /api/products/[id]/assign-category endpoint
    • Automatic variant_sku creation for all styles in category
    • Priority-based SKU assignment using preference rankings
    • Default style marking for highest preference (rank 1)

    Form State Management

    • Added blank_category_id to form schema and validation
    • Local state management for UI mode switching
    • Form change detection including category assignments
    • Mutual exclusivity between individual styles and categories

    Type System Updates

    • Enhanced MamaTriedProduct interface with blank_category_id field
    • Added BlankCategory import for type safety
    • Form validation for category assignment

    📊 Data Flow

    Category Assignment Process

    1. User selects “Blank Category” mode
    2. Chooses category from dropdown
    3. System displays all styles in category with preference rankings
    4. On save, calls assign-category API
    5. Creates variant_skus for all styles based on size/color combinations
    6. Sets priority and default based on preference rankings

    SKU Management

    • For each variant (size + color): Creates one variant_sku per style in category
    • Example: 8 sizes × 1 color × 2 styles = 16 variant_sku records
    • Priority matching: Uses preference_rank from category_styles table
    • Default assignment: Highest preference (rank 1) marked as default

    🎨 User Experience

    Visual Design

    • Clean toggle interface with clear mode indicators
    • Category preview showing all styles with rankings
    • Real-time feedback on form changes
    • Consistent styling with existing product details form

    Workflow Integration

    • Seamless switching between individual styles and categories
    • Preserved existing functionality for individual style management
    • Clear visual indicators for current assignment mode
    • Form validation prevents conflicting assignments

    🔍 Files Modified

    Core Implementation

    • src/types/mama-tried.ts – Added blank_category_id to product interface
    • src/components/products/product-sections/product-details.tsx – Main UI implementation

    Key Changes

    • Form schema updates with blank_category_id field
    • React Query integration for fetching categories
    • Local state management for UI mode switching
    • Form submission logic with category assignment API calls
    • Conditional rendering based on assignment mode

    🧪 Testing & Validation

    Functionality Verified

    • Button interactions working correctly
    • Category selection displaying proper styles
    • Form state updates reflecting user choices
    • Style display showing brand, name, and preference rankings
    • Mode switching between individual and category

    Data Integrity

    • Category data loading with style relationships
    • Preference rankings displaying correctly
    • Form validation preventing invalid states
    • API integration ready for category assignment

    🚧 Current Status

    Completed

    • ✅ UI implementation with toggle buttons
    • ✅ Category selection and display
    • ✅ Style preview with preference rankings
    • ✅ Form state management
    • ✅ Type system integration

    In Progress

    • 🔄 Persistence testing – Category assignments not persisting after save
    • 🔄 API debugging – Investigating category assignment API calls
    • 🔄 Form submission – Ensuring proper data flow to backend

    🎯 Next Steps

    Immediate Tasks

    1. Debug persistence issue – Category assignments not saving
    2. Verify API integration – Ensure assign-category endpoint is called
    3. Test end-to-end flow – Complete category assignment workflow
    4. Remove debug code – Clean up temporary debugging elements

    Future Enhancements

    • Bulk category assignment for multiple products
    • Category inventory dashboard for monitoring
    • Dynamic style updates when categories change
    • Advanced preference management for style selection

    📝 Notes

    Technical Decisions

    • Used local state instead of form.watch() for better UI responsiveness
    • Maintained backward compatibility with existing individual styles
    • Leveraged existing API rather than creating new endpoints
    • Preserved form validation and change detection

    User Impact

    • No breaking changes to existing workflows
    • Enhanced flexibility for inventory management
    • Simplified SKU management for interchangeable styles
    • Better scalability for products with multiple style options