=== STOCK RECEIPT DATA STRUCTURE TEST === ✅ COMPLETE EXAMPLE DATA STRUCTURE: { "supplier_name": "ABC Suppliers Ltd", "supplier_invoice_number": "INV-2025-001", "supplier_invoice_date": "2025-10-15", "supplier_reference": "PO-123", "warehouse_id": 1, "posting_date": "2025-10-17", "remarks": "Test receipt", "transport_mode": "Road", "vehicle_number": "MH-12-AB-1234", "driver_name": "John Doe", "driver_contact": "9876543210", "quality_inspection_required": false, "quality_status": "PENDING", "lines": [ { "product_variant_id": 374, "warehouse_id": 1, "base_qty": 100, "base_uom": "SQM", "rate": 100, "rate_uom": "RM", "base_uom_rate": 50, "amount": 5000, "line_remarks": null, "uom_entries": [ { "uom_id": 7, "uom_code": "RM", "qty": 50, "factor_to_base": 2, "qty_in_base": 100, "is_base": false, "context": "stock" }, { "uom_id": 5, "uom_code": "SQM", "qty": 100, "factor_to_base": 1, "qty_in_base": 100, "is_base": true, "context": "stock" } ] } ] } === VALIDATION CHECKLIST === ✅ supplier_name - REQUIRED ✅ supplier_invoice_number - REQUIRED ✅ warehouse_id - REQUIRED ✅ posting_date - REQUIRED ✅ lines array - REQUIRED (min 1 line) Per Line Item: ✅ product_variant_id - REQUIRED ✅ warehouse_id - REQUIRED ✅ base_qty - REQUIRED (>0) ✅ base_uom - REQUIRED ✅ rate - REQUIRED (>0.01) ✅ rate_uom - REQUIRED ✅ base_uom_rate - REQUIRED (>0.01) ✅ uom_entries array - REQUIRED Per UOM Entry: ✅ uom_id - REQUIRED (exists in uom_master) ✅ uom_code - REQUIRED ✅ qty - REQUIRED (>0.0001) ✅ is_base - REQUIRED (boolean) ✅ factor_to_base - OPTIONAL (default 1.0) ✅ qty_in_base - OPTIONAL (calculated if not provided) ✅ context - OPTIONAL (default 'stock') === DATABASE STRUCTURE === stock_receipt_headers └─ id, document_number, posting_date, supplier_name, etc. stock_receipt_lines └─ id, header_id, product_variant_id, base_qty, base_uom, rate, rate_uom, base_uom_rate, amount stock_receipt_line_uoms (NEW STRUCTURE) └─ id, stock_receipt_line_id, uom_id ✅, uom_code, qty_entered, factor_to_base, qty_in_base, is_base ⚠️ company_id column REMOVED ✅ uom_id column ADDED (foreign key to uom_master) === CALCULATION EXAMPLE === Scenario: Product with RM and SQM UOMs - Width: 2 meters - Conversion: 1 RM = qty × WIDTH = qty × 2 SQM User Input: - Rate: 100 per RM - RM Quantity: 50 - SQM Quantity: 100 (auto-calculated: 50 × 2) Calculations: - Total Amount = Rate × Rate UOM Qty = 100 × 50 = 5000 - Base Rate = Total Amount ÷ Base Qty = 5000 ÷ 100 = 50 per SQM - Line Amount = Base Qty × Base Rate = 100 × 50 = 5000 Result JSON: { product_variant_id: 374, base_qty: 100.0, base_uom: 'SQM', rate: 100.0, rate_uom: 'RM', base_uom_rate: 50.0, ← CALCULATED amount: 5000.0, uom_entries: [ {uom_id: 7, uom_code: 'RM', qty: 50, is_base: false, qty_in_base: 100}, {uom_id: 5, uom_code: 'SQM', qty: 100, is_base: true, qty_in_base: 100} ] } ✅ DATA STRUCTURE READY FOR BACKEND!