From 1b54c2d370ef70daa310d753ac2647547ca876c2 Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Tue, 7 Nov 2023 00:48:22 -0500 Subject: [PATCH] vault backup: 2023-11-07 00:48:22 --- sql/get_guidance.pg.sql | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/sql/get_guidance.pg.sql b/sql/get_guidance.pg.sql index 06d137c..7bda696 100644 --- a/sql/get_guidance.pg.sql +++ b/sql/get_guidance.pg.sql @@ -19,6 +19,7 @@ DECLARE _rslt jsonb; _targ jsonb; _list jsonb; + _iidx jsonb; BEGIN --_item := 'AMK06000G18B054'; @@ -31,9 +32,9 @@ BEGIN ----------------base product-------------------------------- SELECT - m.part_group, i.v1ds,i.v0ds + m.part_group, i.v1ds,i.v0ds,jsonb_build_object('assc',i.assc,'majg',i.majg::int,'coltier',i.coltier) idxk INTO - _mold,_v1ds ,_v0ds + _mold,_v1ds ,_v0ds, _iidx FROM "CMS.CUSLG".itemmv i INNER JOIN rlarp.molds m ON @@ -42,7 +43,7 @@ BEGIN i.item = _item; --RAISE NOTICE 'mold %', _mold; --RAISE NOTICE 'v1ds %', _v1ds; - _rslt := jsonb_build_object('mold',_mold,'v1ds',_v1ds,'v0ds',_v0ds); + _rslt := jsonb_build_object('mold',_mold,'v1ds',_v1ds,'v0ds',_v0ds)||_iidx; ----------------channel------------------------------------- @@ -80,6 +81,29 @@ BEGIN --RAISE NOTICE 'target: %', jsonb_pretty(_targ); _rslt := _rslt||COALESCE(_targ,'{}'::jsonb); + ----------------inflation index----------------------------- + SELECT + jsonb_build_object( + 'iidx' + ,jsonb_build_object( + priority + ,min(factor) + ) + ) + INTO + _iidx + FROM + rlarp.costindex + WHERE + timeframe @> current_date + AND ( + attr @> _iidx + OR attr @> jsonb_build_object('stlc',_mold) + ) + GROUP BY + priority; + --RAISE NOTICE 'target: %', jsonb_pretty(_targ); + _rslt := _rslt||COALESCE(_iidx,'{}'::jsonb); ----------------list ppricing------------------------------- SELECT coalesce(rlarp.get_list(_bill, _ship, _item, _qty),'{}'::jsonb) INTO _list; _rslt := _rslt||_list;