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:
@@ -66,6 +66,7 @@
|
||||
-- 20.03.2026 - kit pricing extins pt reambalari single-component (cantitate_roa > 1)
|
||||
-- 21.03.2026 - diagnostic detaliat discount kit (id_pol, id_art, codmat in eroare)
|
||||
-- 21.03.2026 - fix discount amount: v_disc_amt e per-kit, nu se imparte la v_cantitate_web
|
||||
-- 25.03.2026 - skip negative kit discount (markup), ROUND prices to nzecimale_pretv
|
||||
-- ====================================================================
|
||||
CREATE OR REPLACE PACKAGE PACK_IMPORT_COMENZI AS
|
||||
|
||||
@@ -284,6 +285,9 @@ CREATE OR REPLACE PACKAGE BODY PACK_IMPORT_COMENZI AS
|
||||
v_kit_disc_count PLS_INTEGER := 0;
|
||||
v_kit_disc_found BOOLEAN;
|
||||
|
||||
-- Zecimale pret vanzare (din optiuni firma, default 2)
|
||||
v_nzec_pretv PLS_INTEGER := NVL(TO_NUMBER(pack_sesiune.getoptiunefirma(USER, 'PPRETV')), 2);
|
||||
|
||||
-- pljson
|
||||
l_json_articole CLOB := p_json_articole;
|
||||
v_json_arr pljson_list;
|
||||
@@ -492,8 +496,10 @@ CREATE OR REPLACE PACKAGE BODY PACK_IMPORT_COMENZI AS
|
||||
END IF;
|
||||
|
||||
-- pret_ajustat = pret_cu_tva - discount_share / cantitate_roa
|
||||
v_pret_ajustat := v_kit_comps(i_comp).pret_cu_tva -
|
||||
(v_discount_share / v_kit_comps(i_comp).cantitate_roa);
|
||||
v_pret_ajustat := ROUND(
|
||||
v_kit_comps(i_comp).pret_cu_tva -
|
||||
(v_discount_share / v_kit_comps(i_comp).cantitate_roa),
|
||||
v_nzec_pretv);
|
||||
|
||||
BEGIN
|
||||
merge_or_insert_articol(
|
||||
@@ -578,8 +584,8 @@ CREATE OR REPLACE PACKAGE BODY PACK_IMPORT_COMENZI AS
|
||||
v_vat_disc_alloc := v_vat_disc_alloc + v_disc_amt;
|
||||
END IF;
|
||||
|
||||
IF v_disc_amt != 0 THEN
|
||||
v_unit_pret := v_disc_amt;
|
||||
IF v_disc_amt > 0 THEN
|
||||
v_unit_pret := ROUND(v_disc_amt, v_nzec_pretv);
|
||||
|
||||
-- Search for existing entry with same (ptva, pret) to merge qty
|
||||
v_kit_disc_found := FALSE;
|
||||
|
||||
Reference in New Issue
Block a user