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:
@@ -154,6 +154,12 @@ async def run_catalog_price_sync(run_id: str):
|
||||
if is_kit:
|
||||
for comp in mapped_data[sku]:
|
||||
comp_codmat = comp["codmat"]
|
||||
|
||||
# Skip components that have their own ARTICOLE_TERTI mapping
|
||||
# (they'll be synced with correct cantitate_roa in individual path)
|
||||
if comp_codmat in mapped_data:
|
||||
continue
|
||||
|
||||
comp_product = products_by_sku.get(comp_codmat)
|
||||
if not comp_product:
|
||||
continue # Component not in GoMag as standalone product
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user