Skip to content

Dev#21

Merged
xukki241 merged 4 commits intomainfrom
dev
Mar 28, 2026
Merged

Dev#21
xukki241 merged 4 commits intomainfrom
dev

Conversation

@xukki241
Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings March 28, 2026 14:29
@xukki241 xukki241 merged commit 90a83b8 into main Mar 28, 2026
6 checks passed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates dev/deploy seed data and deployment automation, and aligns the CRM advertisement stats test with the current service behavior.

Changes:

  • Removed/trimmed seeded entities related to deleted product/variant(s) (notably Coca-Cola) across SQL seed scripts.
  • Simplified AdvertisementServiceTest#getStats expectations to match the current AdvertisementService#getStats output.
  • Updated CD workflow to run git commands via git -C "$DEPLOY_PATH" with a sudo fallback when repo ownership/permissions prevent normal git operations.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
deploy/fix_seed.sql Updates deploy-time seed fix script for products/variants and related tables (still seeds unit_conversions).
backend/src/test/java/com/smalltrend/service/crm/AdvertisementServiceTest.java Removes contract-value/expiry assertions so the test matches the simplified stats returned by the service.
backend/src/main/resources/data.sql Updates application seed data to remove deleted products/variants and dependent rows; also removes unit_conversions seeding.
.github/workflows/cd.yml Makes deployment repo sync more robust by using git -C and sudo fallback for root-owned .git.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


-- PRODUCT COMBO ITEMS
INSERT INTO `product_combo_items` VALUES (37,0,0,0,2,1,NULL,2,2,4),(38,0,0,0,1,1,NULL,1,2,5),(41,0,0,0,1,1,NULL,1,3,1),(42,0,0,0,1,1,NULL,1,3,13),(43,0,0,0,2,1,NULL,2,1,5),(44,0,0,0,1,1,NULL,1,1,17),(45,0,0,0,4,1,NULL,4,1,10),(46,0,0,0,2,1,NULL,2,4,5),(47,0,0,0,2,1,NULL,2,4,4),(48,0,0,0,1,1,NULL,1,5,6),(49,0,0,0,1,1,NULL,1,5,14),(50,0,0,0,1,1,NULL,1,5,20),(51,0,0,0,1,1,NULL,1,5,23),(54,0,0,0,2,1,NULL,2,9,4),(55,0,0,0,2,1,NULL,2,9,18),(56,0,0,0,2,1,NULL,2,9,5),(57,0,0,0,3,1,NULL,3,6,12),(58,0,0,0,3,1,NULL,3,6,13);
INSERT INTO `product_combo_items` VALUES (38,0,0,0,1,1,NULL,1,2,5),(41,0,0,0,1,1,NULL,1,3,1),(42,0,0,0,1,1,NULL,1,3,13),(43,0,0,0,2,1,NULL,2,1,5),(44,0,0,0,1,1,NULL,1,1,17),(45,0,0,0,4,1,NULL,4,1,10),(46,0,0,0,2,1,NULL,2,4,5),(48,0,0,0,1,1,NULL,1,5,6),(49,0,0,0,1,1,NULL,1,5,14),(50,0,0,0,1,1,NULL,1,5,20),(51,0,0,0,1,1,NULL,1,5,23),(55,0,0,0,2,1,NULL,2,9,18),(56,0,0,0,2,1,NULL,2,9,5),(57,0,0,0,3,1,NULL,3,6,12),(58,0,0,0,3,1,NULL,3,6,13);
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

product_combo_items was changed to remove items that referenced the deleted Coca-Cola variant, but the related combo definitions/descriptions still mention Coca (e.g. combo "CB-DRINK-1" / "2 lon Coca..."). This leaves seed data internally inconsistent (combo contents no longer match what the combo claims to contain). Either update the combo descriptions/pricing to match the new items, or keep the required variants/items.

Copilot uses AI. Check for mistakes.
-- 8.2 UNIT CONVERSIONS (Conversion between units for variants)
-- Example: 1 carton (THUNG) = 12 boxes (HOP), 1 pack (LOC) = 4 boxes
INSERT INTO `unit_conversions` VALUES (15,48.0000,'',1,0.00,3,27),(16,30.0000,'',1,360000.00,3,4);
-- removed unit_conversions for deleted variants (Coca-Cola / Vinamilk dâu)
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data.sql no longer seeds any rows into unit_conversions (it now only has a comment), but deploy/fix_seed.sql still truncates and inserts at least one unit_conversions row. This will lead to different unit-conversion behavior between environments that use data.sql vs the deploy seed script. Consider keeping unit_conversions seeding consistent across both files (either seed the same rows in both, or remove them from both).

Copilot uses AI. Check for mistakes.
-- 8.2 UNIT CONVERSIONS (Conversion between units for variants)
-- Example: 1 carton (THUNG) = 12 boxes (HOP), 1 pack (LOC) = 4 boxes
INSERT INTO `unit_conversions` (id,conversion_factor,description,is_active,sell_price,to_unit_id,variant_id) VALUES (15,48.0000,'',1,0.00,3,27),(16,30.0000,'',1,360000.00,3,4);
INSERT INTO `unit_conversions` (id,conversion_factor,description,is_active,sell_price,to_unit_id,variant_id) VALUES (15,48.0000,'',1,0.00,3,28);
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unit_conversions is still being truncated and then seeded here, but backend/src/main/resources/data.sql no longer seeds unit_conversions at all. This risks environment drift (local/dev/test DBs created from data.sql will behave differently than deployed DBs patched with fix_seed.sql). Align the unit_conversions seed strategy between these two scripts.

Suggested change
INSERT INTO `unit_conversions` (id,conversion_factor,description,is_active,sell_price,to_unit_id,variant_id) VALUES (15,48.0000,'',1,0.00,3,28);
-- NOTE: Seeding for `unit_conversions` removed to align with backend/src/main/resources/data.sql

Copilot uses AI. Check for mistakes.

-- 19. SALE ORDER ITEMS
INSERT INTO `sale_order_items` VALUES (1,0.00,2400.00,26400.00,NULL,'Coca Cola 330ml',2,'COCA-330ML',12000.00,1,4),(2,0.00,2400.00,26400.00,NULL,'Oishi Snack',3,'OISHI-50G',8000.00,1,5),(3,2000.00,4800.00,52800.00,NULL,'Fresh Milk 1L',2,'VMILK-1L',25000.00,2,1),(4,3000.00,4500.00,46500.00,NULL,'Nescafe 3in1',1,'NESCAFE-200G',45000.00,2,3),(5,0.00,3000.00,33000.00,'1 sản phẩm bị lỗi vỏ hộp','Dove Soap 90g',2,'DOVE-90G',15000.00,3,2),(6,0.00,0.00,175000.00,'Migrated from legacy sales_order_items','Fresh Milk 1L',7,'VMILK-1L',25000.00,4,1),(7,0.00,0.00,95000.00,'Migrated from legacy sales_order_items','Dove Soap 90g',4,'DOVE-90G',23750.00,5,2),(8,0.00,0.00,57999.96,'Migrated from legacy sales_order_items','Nescafe 3in1',12,'NESCAFE-200G',4833.33,6,3),(9,0.00,0.00,120000.00,'Migrated from legacy sales_order_items','Coca Cola 330ml',10,'COCA-330ML',12000.00,7,4),(10,0.00,0.00,67000.00,'Migrated from legacy sales_order_items','Oishi Snack',5,'OISHI-50G',13400.00,8,5),(11,0.00,0.00,24000.00,NULL,'Coca Cola 330ml',2,'COCA-330ML',12000.00,9,4),(12,0.00,0.00,24000.00,NULL,'Oishi Snack',3,'OISHI-50G',8000.00,9,5),(13,0.00,0.00,50000.00,NULL,'Fresh Milk 1L',2,'VMILK-1L',25000.00,10,1),(14,0.00,0.00,45000.00,NULL,'Nescafe 3in1',1,'NESCAFE-200G',45000.00,10,3),(15,0.00,0.00,30000.00,NULL,'Dove Soap 90g',2,'DOVE-90G',15000.00,11,2),(16,0.00,0.00,25000.00,NULL,'Fresh Milk 1L',1,'VMILK-1L',25000.00,12,1),(17,0.00,0.00,60000.00,NULL,'Coca Cola 330ml',5,'COCA-330ML',12000.00,13,4),(18,0.00,0.00,32000.00,NULL,'Oishi Snack',4,'OISHI-50G',8000.00,13,5),(19,0.00,0.00,36000.00,NULL,'Coca Cola 330ml',3,'COCA-330ML',12000.00,14,4),(20,0.00,0.00,15000.00,NULL,'Dove Soap 90g',1,'DOVE-90G',15000.00,14,2),(21,0.00,0.00,75000.00,NULL,'Fresh Milk 1L',3,'VMILK-1L',25000.00,15,1),(22,0.00,0.00,90000.00,NULL,'Nescafe 3in1',2,'NESCAFE-200G',45000.00,15,3),(23,0.00,0.00,40000.00,NULL,'Oishi Snack',5,'OISHI-50G',8000.00,16,5),(24,0.00,0.00,50000.00,NULL,'Fresh Milk 1L',2,'VMILK-1L',25000.00,17,1),(25,0.00,0.00,45000.00,NULL,'Dove Soap 90g',3,'DOVE-90G',15000.00,17,2),(26,0.00,0.00,72000.00,NULL,'Coca Cola 330ml',6,'COCA-330ML',12000.00,18,4);
INSERT INTO `sale_order_items` VALUES (2,0.00,2400.00,26400.00,NULL,'Oishi Snack',3,'OISHI-50G',8000.00,1,5),(3,2000.00,4800.00,52800.00,NULL,'Fresh Milk 1L',2,'VMILK-1L',25000.00,2,1),(4,3000.00,4500.00,46500.00,NULL,'Nescafe 3in1',1,'NESCAFE-200G',45000.00,2,3),(5,0.00,3000.00,33000.00,'1 sản phẩm bị lỗi vỏ hộp','Dove Soap 90g',2,'DOVE-90G',15000.00,3,2),(6,0.00,0.00,175000.00,'Migrated from legacy sales_order_items','Fresh Milk 1L',7,'VMILK-1L',25000.00,4,1),(7,0.00,0.00,95000.00,'Migrated from legacy sales_order_items','Dove Soap 90g',4,'DOVE-90G',23750.00,5,2),(8,0.00,0.00,57999.96,'Migrated from legacy sales_order_items','Nescafe 3in1',12,'NESCAFE-200G',4833.33,6,3),(10,0.00,0.00,67000.00,'Migrated from legacy sales_order_items','Oishi Snack',5,'OISHI-50G',13400.00,8,5),(12,0.00,0.00,24000.00,NULL,'Oishi Snack',3,'OISHI-50G',8000.00,9,5),(13,0.00,0.00,50000.00,NULL,'Fresh Milk 1L',2,'VMILK-1L',25000.00,10,1),(14,0.00,0.00,45000.00,NULL,'Nescafe 3in1',1,'NESCAFE-200G',45000.00,10,3),(15,0.00,0.00,30000.00,NULL,'Dove Soap 90g',2,'DOVE-90G',15000.00,11,2),(16,0.00,0.00,25000.00,NULL,'Fresh Milk 1L',1,'VMILK-1L',25000.00,12,1),(18,0.00,0.00,32000.00,NULL,'Oishi Snack',4,'OISHI-50G',8000.00,13,5),(20,0.00,0.00,15000.00,NULL,'Dove Soap 90g',1,'DOVE-90G',15000.00,14,2),(21,0.00,0.00,75000.00,NULL,'Fresh Milk 1L',3,'VMILK-1L',25000.00,15,1),(22,0.00,0.00,90000.00,NULL,'Nescafe 3in1',2,'NESCAFE-200G',45000.00,15,3),(23,0.00,0.00,40000.00,NULL,'Oishi Snack',5,'OISHI-50G',8000.00,16,5),(24,0.00,0.00,50000.00,NULL,'Fresh Milk 1L',2,'VMILK-1L',25000.00,17,1),(25,0.00,0.00,45000.00,NULL,'Dove Soap 90g',3,'DOVE-90G',15000.00,17,2);
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After removing Coca-Cola-related rows from sale_order_items, the seeded sale_orders rows (e.g. order id=1 subtotal/tax/total) are now inconsistent with the remaining line items. This can break any code that trusts the persisted order totals (reports, invoices, loyalty calculations). Update the affected sale_orders totals to match the remaining items, or keep corresponding line items so totals remain consistent.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants