fix(sync): prevent kit/bax price sync from overwriting individual CRM prices

Three code paths could overwrite CRM list prices with wrong values when
web unit (50 buc) differs from ROA unit (100 buc):

- price_sync_service: kit path now skips components that have their own
  ARTICOLE_TERTI mapping (individual path handles them with correct ÷0.5)
- validation_service: sync_prices_from_order now skips bax SKUs
  (cantitate_roa > 1) in addition to multi-component kits
- pack_import_comenzi: skip negative kit discount (markup), ROUND prices
  to nzecimale_pretv decimals

Also adds:
- SQL script for 6 ARTICOLE_TERTI mappings (cantitate_roa=0.5) for cup
  articles where web=50buc, ROA=100buc/set
- Oracle schema reference documentation

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Claude Agent
2026-03-25 19:05:49 +00:00
parent f315aad14c
commit 47b5723f92
5 changed files with 195 additions and 6 deletions

View File

@@ -542,8 +542,9 @@ def sync_prices_from_order(orders, mapped_codmat_data: dict, direct_id_map: dict
kit_discount_codmat = (settings or {}).get("kit_discount_codmat", "")
skip_codmats = {transport_codmat, discount_codmat, kit_discount_codmat} - {""}
# Build set of kit SKUs (>1 component)
kit_skus = {sku for sku, comps in mapped_codmat_data.items() if len(comps) > 1}
# Build set of kit/bax SKUs (>1 component, or single component with cantitate_roa > 1)
kit_skus = {sku for sku, comps in mapped_codmat_data.items()
if len(comps) > 1 or (len(comps) == 1 and (comps[0].get("cantitate_roa") or 1) > 1)}
updated = []
own_conn = conn is None