You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
User Story: As a restaurant manager, I want to manually trigger Square sales data synchronization with CostFX, so that I can control when sales data is imported and validate the sync process step-by-step.
Acceptance Scenarios:
Manual Sales Sync: Given my restaurant has sales in Square, When I trigger a manual sales sync through the API, Then all transactions from the specified date range should be imported for cost analysis
Large Volume Handling: Given busy days with 1000+ transactions, When CostFX syncs sales data, Then all transactions should be processed without timeout errors or missing data
Menu Item Mapping: Given my Square sales show specific menu items sold, When CostFX processes this data, Then each menu item should be properly linked to its recipe ingredients for usage calculations
Duplicate Prevention: Given the same transaction might be synced multiple times, When CostFX imports sales data, Then duplicate transactions should be ignored to prevent inflated usage calculations
Historical Backfill: Given I'm setting up CostFX for the first time, When I connect my Square account, Then I should be able to manually import sales history from a specified date range for immediate analysis
Stepped Sync Process: Given I want to validate each sync phase, When I trigger a sales sync, Then I should be able to run raw data sync separately from transformation (like inventory sync)
Technical Implementation Checklist
(Developer Tasks)
Description:
Implement manual Square sales transaction synchronization with menu item mapping, following the same stepped pattern as SquareInventorySyncService.
Technical Acceptance Criteria:
Manual sync endpoint for Square order transactions (no automatic scheduling)
Two-phase sync: (1) Raw data to Tier 1, (2) Optional transform to Tier 2
Map orders to menu items and ingredients
Handle refunds and modifications
Sales data aggregation by time periods
Menu item to recipe mapping logic
Performance optimization for high-volume locations
Historical data backfill capability (date range parameters)
The recipe variance analysis system (requested by Dave for the halibut vendor example) requires the sales_transactions table to calculate revenue impact:
✅ sales_transactions table with proper schema (already defined)
✅ Link to inventory_item_id via source tracking (already planned)
✅ source_pos_item_id for linking to menu items (already in schema)
✅ Date range query support with indexes (already planned)
✅ Sales count aggregation capability (query pattern, not new code)
No Scope Changes Required
The current Issue #21 scope already provides everything needed for recipe variance. The recipe variance issues (41-43) will:
Use the same sales_transactions table
Query via recipe_menu_item_links → square_menu_items → sales_transactions
Aggregate sales counts for variance × volume calculations
This comment is for awareness and priority planning only - no changes to Issue #21 deliverables needed.
Priority: P0 - Critical
Estimate: 4 days
Dependencies: Task 6 (Issue #20)
Product Acceptance Criteria
(Customer Value)
User Story: As a restaurant manager, I want to manually trigger Square sales data synchronization with CostFX, so that I can control when sales data is imported and validate the sync process step-by-step.
Acceptance Scenarios:
Technical Implementation Checklist
(Developer Tasks)
Description:
Implement manual Square sales transaction synchronization with menu item mapping, following the same stepped pattern as SquareInventorySyncService.
Technical Acceptance Criteria:
Technical Details:
Phase: 3 - Square Data Synchronization (2 weeks)
Epic: Square-First Multi-POS Integration
📋 Additional Downstream Dependencies
This issue now has additional dependencies beyond the original theoretical usage calculations:
New Dependencies (Recipe Variance Analysis)
Why These Depend on Issue #21
The recipe variance analysis system (requested by Dave for the halibut vendor example) requires the
sales_transactionstable to calculate revenue impact:Data Flow for Recipe Variance
What Recipe Variance Issues Need from Issue #21
✅
sales_transactionstable with proper schema (already defined)✅ Link to
inventory_item_idvia source tracking (already planned)✅
source_pos_item_idfor linking to menu items (already in schema)✅ Date range query support with indexes (already planned)
✅ Sales count aggregation capability (query pattern, not new code)
No Scope Changes Required
The current Issue #21 scope already provides everything needed for recipe variance. The recipe variance issues (41-43) will:
sales_transactionstablerecipe_menu_item_links→square_menu_items→sales_transactionsThis comment is for awareness and priority planning only - no changes to Issue #21 deliverables needed.
Timeline Impact:
Related Documentation:
docs/RECIPE_VARIANCE_ANALYSIS_PLAN.mdfor full architecturedocs/RECIPE_VARIANCE_DEPENDENCY_ANALYSIS.mdfor dependency details