include pallet quantity in product info

This commit is contained in:
Paul Trowbridge 2023-11-13 12:59:45 -05:00
parent 7919160ecc
commit a5acb798b4

View File

@ -13,6 +13,8 @@ DECLARE
_prem jsonb;
_mold text;
_item text;
_unti text;
_pltq numeric;
_cust text;
_curr text;
_rate numeric;
@ -62,11 +64,13 @@ BEGIN
,item
,idxk
,prefer
,(SELECT unti FROM "CMS.CUSLG".itemm WHERE item = best.item)
INTO
_mold
,_item
,_iidx
,_itemr
,_unti
FROM
(
SELECT
@ -94,17 +98,37 @@ BEGIN
ORDER BY
prefer DESC
LIMIT 1;
_product := jsonb_build_object(
'product',
_product :=
jsonb_build_object(
'mold',_mold
,'item',_item
,'itemrel',_itemr
,'iidx',_iidx
)
);
,'unti',_unti
);
--RAISE NOTICE 'item data %', jsonb_pretty(_product||_input);
----------------pallet quantity-----------------------------
SELECT
ROUND(uom.nm/uom.dm,1) pltq
INTO
_pltq
FROM
(
SELECT
jsonb_agg(row_to_json(d)::jsonb) jdoc
FROM
(
select distinct
_item partn
,'PLT' fu
,_unti tu
) d
) c
JOIN LATERAL rlarp.uom_array(c.jdoc) uom ON TRUE;
_product := jsonb_build_object('product',_product||jsonb_build_object('pltq',_pltq));
----------------channel-------------------------------------
SELECT rlarp.channel_code(_bill, _ship) INTO _chan;