fix bridge pricing
This commit is contained in:
parent
0922862c80
commit
b81261af3f
@ -11,6 +11,8 @@ export function apply_guidance(doc: any) {
|
|||||||
const fxrate = doc.customer?.fxrate;
|
const fxrate = doc.customer?.fxrate;
|
||||||
let anchorPrice = null;
|
let anchorPrice = null;
|
||||||
let anchorSource = null;
|
let anchorSource = null;
|
||||||
|
let custPrice = null;
|
||||||
|
let custSource = null;
|
||||||
let guidance = {};
|
let guidance = {};
|
||||||
let calcCeiling = null;
|
let calcCeiling = null;
|
||||||
let finalReason = "";
|
let finalReason = "";
|
||||||
@ -25,12 +27,15 @@ export function apply_guidance(doc: any) {
|
|||||||
// if there is no customer anchor price use target
|
// if there is no customer anchor price use target
|
||||||
if (earlyPrice) {
|
if (earlyPrice) {
|
||||||
// translate alternate product history to current product quoted
|
// translate alternate product history to current product quoted
|
||||||
anchorPrice = Number((earlyPrice * bridgePremium).toFixed(5));
|
custPrice = Number((earlyPrice * bridgePremium).toFixed(5));
|
||||||
|
anchorPrice = custPrice;
|
||||||
// --------if the price needs bridged, add the details to the description--------
|
// --------if the price needs bridged, add the details to the description--------
|
||||||
if (bridgePremium === 1) {
|
if (bridgePremium === 1) {
|
||||||
anchorSource = earlySeason + ' Customer Price ' + earlyPrice;
|
anchorSource = earlySeason + ' Customer Price ' + earlyPrice;
|
||||||
|
custSource = anchorSource;
|
||||||
} else {
|
} else {
|
||||||
anchorSource = earlySeason + ' Similar (' + altHist + ') Customer Price ' + earlyPrice + ' x ' + bridgePremium + ' = ' + anchorPrice;
|
anchorSource = earlySeason + ' Similar (' + altHist + ') Customer Price ' + earlyPrice + ' x ' + bridgePremium + ' = ' + anchorPrice;
|
||||||
|
custSource = anchorSource;
|
||||||
}
|
}
|
||||||
// --------after the early price is translated see if target is still less-------
|
// --------after the early price is translated see if target is still less-------
|
||||||
if (targetPrice < anchorPrice) {
|
if (targetPrice < anchorPrice) {
|
||||||
@ -55,6 +60,8 @@ export function apply_guidance(doc: any) {
|
|||||||
}
|
}
|
||||||
guidance.AnchorPrice = anchorPrice;
|
guidance.AnchorPrice = anchorPrice;
|
||||||
guidance.AnchorSource = anchorSource;
|
guidance.AnchorSource = anchorSource;
|
||||||
|
guidance.CustAnchorPrice = custPrice;
|
||||||
|
guidance.CustAnchorSource = custSource;
|
||||||
guidance.InflationFactor = inflationFactor;
|
guidance.InflationFactor = inflationFactor;
|
||||||
guidance.Ceiling = calcCeiling;
|
guidance.Ceiling = calcCeiling;
|
||||||
guidance.FinalPrice = finalPrice;
|
guidance.FinalPrice = finalPrice;
|
||||||
|
@ -144,7 +144,7 @@ BEGIN
|
|||||||
|
|
||||||
----------------price history-------------------------------
|
----------------price history-------------------------------
|
||||||
SELECT jsonb_build_object('hist',rlarp.get_hist(_mold, _v1ds, _cust, substring(_chan,1,1))) INTO _hist;
|
SELECT jsonb_build_object('hist',rlarp.get_hist(_mold, _v1ds, _cust, substring(_chan,1,1))) INTO _hist;
|
||||||
--RAISE NOTICE 'history %', _hist;
|
--RAISE NOTICE 'history %', jsonb_pretty(_hist);
|
||||||
|
|
||||||
----------------target pricing------------------------------
|
----------------target pricing------------------------------
|
||||||
SELECT
|
SELECT
|
||||||
@ -213,7 +213,7 @@ BEGIN
|
|||||||
--RAISE NOTICE 'add list: %', jsonb_pretty(_pricing);
|
--RAISE NOTICE 'add list: %', jsonb_pretty(_pricing);
|
||||||
|
|
||||||
----------------get premium for quote hist gap--------------
|
----------------get premium for quote hist gap--------------
|
||||||
SELECT coalesce(rlarp.get_premium(_stlc, _seas, (SELECT xchan FROM _chx WHERE chan = _chan),_rslt->'hist'->'cust'->>'ds', _v1ds),'{}'::jsonb) INTO _prem;
|
SELECT coalesce(rlarp.get_premium(_stlc, _seas, (SELECT xchan FROM _chx WHERE chan = _chan),_hist->'hist'->'cust'->>'ds', _v1ds),'{}'::jsonb) INTO _prem;
|
||||||
_pricing := jsonb_build_object('pricing',_pricing||_prem);
|
_pricing := jsonb_build_object('pricing',_pricing||_prem);
|
||||||
--RAISE NOTICE 'add bridge: %', jsonb_pretty(_pricing);
|
--RAISE NOTICE 'add bridge: %', jsonb_pretty(_pricing);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user