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; _prem jsonb;
_mold text; _mold text;
_item text; _item text;
_unti text;
_pltq numeric;
_cust text; _cust text;
_curr text; _curr text;
_rate numeric; _rate numeric;
@ -62,11 +64,13 @@ BEGIN
,item ,item
,idxk ,idxk
,prefer ,prefer
,(SELECT unti FROM "CMS.CUSLG".itemm WHERE item = best.item)
INTO INTO
_mold _mold
,_item ,_item
,_iidx ,_iidx
,_itemr ,_itemr
,_unti
FROM FROM
( (
SELECT SELECT
@ -94,17 +98,37 @@ BEGIN
ORDER BY ORDER BY
prefer DESC prefer DESC
LIMIT 1; LIMIT 1;
_product := jsonb_build_object( _product :=
'product',
jsonb_build_object( jsonb_build_object(
'mold',_mold 'mold',_mold
,'item',_item ,'item',_item
,'itemrel',_itemr ,'itemrel',_itemr
,'iidx',_iidx ,'iidx',_iidx
) ,'unti',_unti
); );
--RAISE NOTICE 'item data %', jsonb_pretty(_product||_input); --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------------------------------------- ----------------channel-------------------------------------
SELECT rlarp.channel_code(_bill, _ship) INTO _chan; SELECT rlarp.channel_code(_bill, _ship) INTO _chan;