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

@@ -45,6 +45,14 @@ INSERT INTO NOM_ARTICOLE (
-3, SYSDATE
);
-- Price entry for CAF01 in default price policy (id_pol=1)
-- Used for single-component repackaging kit pricing test
MERGE INTO crm_politici_pret_art dst
USING (SELECT 1 AS id_pol, 9999001 AS id_articol FROM DUAL) src
ON (dst.id_pol = src.id_pol AND dst.id_articol = src.id_articol)
WHEN NOT MATCHED THEN INSERT (id_pol, id_articol, pret, proc_tvav)
VALUES (src.id_pol, src.id_articol, 51.50, 19);
-- Create test mappings in ARTICOLE_TERTI
-- CAFE100 -> CAF01 (repackaging: 10x1kg = 1x10kg web package)
INSERT INTO ARTICOLE_TERTI (sku, codmat, cantitate_roa, procent_pret, activ)