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_idcolumn towarehouse_itemstable - Added new item type
'pod_blank'to warehouse items - Created database views:
v_pod_category_inventory– Aggregated POD inventory by categoryv_pod_style_inventory– POD inventory for style-specific items- Added indexes for performance optimization
- Warehouse items can now have either
garment_id(specific style) ORblank_category_id(category-based)
TypeScript Type Updates
Updated src/types/warehouse-inventory.ts
- Added
'pod_blank'toWarehouseItemTypeenum - Added
blank_category_idfield toWarehouseIteminterface - Added
categoryrelation type for warehouse items - Created new POD-specific types:
PODCategoryInventory– Category-based inventory with size aggregationPODStyleInventory– Style-specific inventory with size breakdownPODInventoryResponse– API response structure for POD inventory
Backend API Changes
1. Updated src/app/api/warehouse-inventory/route.ts
- Modified queries to include
blank_category_idfield - Added joins with
blank_categoriestable - 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_categoriestable - 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
- 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
- Style-Specific POD Inventory
- Still supports tracking specific style+color combinations
- Useful for POD items that must use a particular garment
- 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
- 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
- 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)
- Work Order Integration
- Automatic inventory deduction when work orders are created
- Style selection based on preference rank and availability
- Transfers Integration
- Link transfers to POD inventory
- Show POD transfers in the Transfers sub-tab
- Inventory Import
- Update warehouse import dialog to support
pod_blanktype - CSV import with category references
- Bulk Adjustment
- Allow editing quantities for existing POD items
- Support transferring between storage locations
- 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:
- Created missing
/api/sizesendpoint that was preventing the size selector from loading. The endpoint fetches all sizes from the database, ordered by size category and display order. - Updated
/api/warehouse-itemsPOST endpoint to includeblank_category_idin the INSERT statement, fixing the “INSERT has more target columns than expressions” error. - Enhanced
/api/warehouse-itemsPOST endpoint to handle multiple sizes at once – when asizesarray is provided, it creates warehouse_item_variants and warehouse_variant_inventory records for each size in a single transaction. - Updated POD blank item dialog mutation to send sizes array to the API instead of trying to call non-existent variant/inventory endpoints.
- 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:
- Finds the existing warehouse item for that category/style+color
- Adds new sizes as variants if they don’t exist
- 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=trueparameter 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)
