fix: kit discount amount + price sync no auto-insert + repackaging kit detection

Kit discount: v_disc_amt is per-kit, not per-unit — remove division by
v_cantitate_web so discount lines compute correctly (e.g. -2 x 5 = -10).

Price sync: stop auto-inserting missing articles into price policies
(was inserting with wrong proc_tvav from GoMag). Log warning instead.

Kit detection: extend to single-component repackagings (cantitate_roa > 1)
in both PL/SQL package and price sync/validation services.

Add repackaging kit pricing test for separate_line and distributed modes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Claude Agent
2026-03-21 11:04:09 +00:00
parent 10c1afca01
commit 61ae58ef25
6 changed files with 245 additions and 49 deletions

View File

@@ -450,8 +450,10 @@ def validate_kit_component_prices(mapped_codmat_data: dict, id_pol: int,
try:
with conn.cursor() as cur:
for sku, components in mapped_codmat_data.items():
if len(components) <= 1:
continue # Not a kit
if len(components) == 0:
continue
if len(components) == 1 and (components[0].get("cantitate_roa") or 1) <= 1:
continue # True 1:1 mapping, no kit pricing needed
sku_missing = []
for comp in components:
cont = str(comp.get("cont") or "").strip()