From 93314e7a6a8673903fceb563209131dafb126e0a Mon Sep 17 00:00:00 2001 From: Claude Agent Date: Fri, 20 Mar 2026 00:16:37 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20bridge=20SKU=E2=86=92policy=20mapping=20?= =?UTF-8?q?for=20ARTICOLE=5FTERTI=20mapped=20articles?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit codmat_policy_map had CODMAT keys only, but build_articles_json looks up by GoMag SKU — mapped articles like FRSETP250 never got per-article id_pol, causing Oracle to use default sales policy and fail when price exists only in production policy. Co-Authored-By: Claude Opus 4.6 (1M context) --- api/app/services/sync_service.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/api/app/services/sync_service.py b/api/app/services/sync_service.py index 1c385da..c5b65da 100644 --- a/api/app/services/sync_service.py +++ b/api/app/services/sync_service.py @@ -499,6 +499,17 @@ async def run_sync(id_pol: int = None, id_sectie: int = None, run_id: str = None conn, mapped_id_map, cota_tva=cota_tva ) + # Add SKU → policy entries for mapped articles (1:1 and kits) + # codmat_policy_map has CODMAT keys, but build_articles_json + # looks up by GoMag SKU — bridge the gap here + if codmat_policy_map and mapped_codmat_data: + for sku, entries in mapped_codmat_data.items(): + if len(entries) == 1: + # 1:1 mapping: SKU inherits the CODMAT's policy + codmat = entries[0]["codmat"] + if codmat in codmat_policy_map: + codmat_policy_map[sku] = codmat_policy_map[codmat] + # Pass codmat_policy_map to import via app_settings if codmat_policy_map: app_settings["_codmat_policy_map"] = codmat_policy_map