@@ -76,3 +76,62 @@ for (let line of lines) {
7676
7777fs . writeFileSync ( outFile , out . join ( '\n' ) , 'utf8' ) ;
7878console . log ( `Lọc & Xử lý xong! Đã xuất ra file ${ outFile } ` ) ;
79+ let sql = '-- ==========================================================\n' ;
80+ sql += '-- DỮ LIỆU BÙ ĐẮP CHO CÁC BẢNG BỊ LỖI SCHEMA TRANSACTIONS\n' ;
81+ sql += '-- ==========================================================\n\n' ;
82+ sql += 'SET FOREIGN_KEY_CHECKS = 0;\n\n' ;
83+
84+ const addMock = ( table , cols , values ) => {
85+ sql += `TRUNCATE TABLE ${ table } ;\n` ;
86+ sql += `INSERT INTO \`${ table } \` (${ cols } ) VALUES \n(${ values } );\n\n` ;
87+ }
88+
89+ // 1. Sale Orders
90+ addMock ( 'sale_orders' ,
91+ '`id`, `order_code`, `customer_id`, `cashier_id`, `cash_register_id`, `order_date`, `subtotal`, `tax_amount`, `discount_amount`, `total_amount`, `payment_method`, `status`, `notes`, `created_at`, `updated_at`' ,
92+ "1, 'ORD-202603-001', 1, 1, 1, '2026-03-28 10:00:00', 50000, 0, 0, 50000, 'CASH', 'COMPLETED', 'Đơn MOCK 1', '2026-03-28 10:00:00', '2026-03-28 10:00:00'" ) ;
93+ addMock ( 'sale_order_items' ,
94+ '`id`, `sale_order_id`, `product_variant_id`, `product_name`, `sku`, `quantity`, `unit_price`, `line_discount_amount`, `line_tax_amount`, `line_total_amount`, `notes`' ,
95+ "1, 1, 1, 'Mock Product', 'SKU-001', 2, 25000, 0, 0, 50000, ''" ) ;
96+
97+ // 2. Purchase Orders
98+ addMock ( 'purchase_orders' ,
99+ '`id`, `order_number`, `supplier_id`, `contract_id`, `created_by`, `location_id`, `order_date`, `expected_delivery_date`, `actual_delivery_date`, `status`, `subtotal`, `tax_amount`, `tax_percent`, `discount_amount`, `shipping_fee`, `paid_amount`, `total_amount`, `notes`, `rejection_reason`, `shortage_reason`, `shortage_submitted_at`, `manager_decision`, `manager_decision_note`, `manager_decided_at`, `created_at`, `updated_at`' ,
100+ "1, 'PO-202603-001', 1, null, 1, 1, '2026-03-28', '2026-03-29', '2026-03-29', 'COMPLETED', 100000, 0, 0, 0, 0, 100000, 100000, 'Mock', null, null, null, null, null, null, '2026-03-28 10:00:00', '2026-03-28 10:00:00'" ) ;
101+ addMock ( 'purchase_order_items' ,
102+ '`id`, `purchase_order_id`, `variant_id`, `quantity`, `unit_cost`, `total_cost`, `received_quantity`, `notes`, `expiry_date`' ,
103+ "1, 1, 1, 10, 10000, 100000, 10, 'Mock', '2030-01-01'" ) ;
104+
105+ // 3. Inventory Counts
106+ addMock ( 'inventory_counts' ,
107+ '`id`, `code`, `status`, `location_id`, `total_shortage_value`, `total_overage_value`, `total_difference_value`, `created_by`, `confirmed_by`, `created_at`, `confirmed_at`' ,
108+ "1, 'IC-202603-001', 'CONFIRMED', 1, 0, 0, 0, 1, 1, '2026-03-28 10:00:00', '2026-03-28 10:05:00'" ) ;
109+ addMock ( 'inventory_count_items' ,
110+ '`id`, `inventory_count_id`, `batch_id`, `system_quantity`, `actual_quantity`, `difference_quantity`, `difference_value`, `reason`' ,
111+ "1, 1, 1, 10, 10, 0, 0, 'Match'" ) ;
112+
113+ // 4. Disposal Vouchers
114+ addMock ( 'disposal_vouchers' ,
115+ '`id`, `code`, `location_id`, `status`, `reason_type`, `notes`, `total_items`, `total_quantity`, `total_value`, `created_by`, `created_at`, `confirmed_by`, `confirmed_at`, `rejection_reason`, `version`' ,
116+ "1, 'DV-202603-001', 1, 'CONFIRMED', 'DAMAGED', 'Mock Notes', 1, 5, 50000, 1, '2026-03-28 10:00:00', 1, '2026-03-28 10:05:00', null, 1" ) ;
117+ addMock ( 'disposal_voucher_items' ,
118+ '`id`, `disposal_voucher_id`, `batch_id`, `product_id`, `batch_code`, `quantity`, `unit_cost`, `total_cost`, `expiry_date`' ,
119+ "1, 1, 1, 1, 'BATCH-001', 5, 10000, 50000, '2030-01-01'" ) ;
120+
121+ // 5. Product Combos
122+ addMock ( 'product_combos' ,
123+ '`id`, `combo_code`, `combo_name`, `description`, `image_url`, `original_price`, `combo_price`, `saved_amount`, `discount_percent`, `valid_from`, `valid_to`, `is_active`, `max_quantity_per_order`, `total_sold`, `stock_limit`, `combo_type`, `is_featured`, `display_order`, `tags`, `status`, `created_by_id`, `updated_at`, `category_id`' ,
124+ "1, 'CB-SNACK-VIP', 'Combo Snack VIP', 'Mock', '', 150000, 120000, 30000, 20, '2026-01-01', '2026-12-31', 1, 5, 0, 0, 'VIP', 0, 1, 'New', 'ACTIVE', 1, '2026-03-28 10:00:00', 1" ) ;
125+ addMock ( 'product_combo_items' ,
126+ '`id`, `combo_id`, `product_variant_id`, `min_quantity`, `max_quantity`, `is_optional`, `can_substitute`, `display_order`, `notes`' ,
127+ "1, 1, 1, 1, 1, 0, 0, 1, 'None'" ) ;
128+
129+ // 6. Price Expiry Alert Logs
130+ addMock ( 'price_expiry_alert_logs' ,
131+ '`id`, `variant_price_id`, `alert_date`, `sent_at`' ,
132+ "1, 1, '2026-03-28', '2026-03-28 10:15:00'" ) ;
133+
134+ sql += 'SET FOREIGN_KEY_CHECKS = 1;\n' ;
135+
136+ fs . appendFileSync ( 'deploy/fix_seed.sql' , sql , 'utf8' ) ;
137+ console . log ( 'Appended fully parsed Mock data to deploy/fix_seed.sql' ) ;
0 commit comments