From c9b90ad22bcca8f8fbeaabada093f3c1cc6702a1 Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Tue, 21 Oct 2025 09:38:10 -0400 Subject: [PATCH] use bill-to price level if there is no ship-to level --- procs/matrix_guidance.pg.sql | 18 +++++++++++++++--- procs/single_price_call.ms.sql | 2 +- procs/single_price_call.pg.sql | 2 +- procs/single_price_call_func.ms.sql | 2 +- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/procs/matrix_guidance.pg.sql b/procs/matrix_guidance.pg.sql index 11f3ad6..92d1db9 100644 --- a/procs/matrix_guidance.pg.sql +++ b/procs/matrix_guidance.pg.sql @@ -97,7 +97,11 @@ BEGIN SELECT q.ctid, CASE SUBSTRING(bc.cclass, 2, 3) - WHEN 'DIS' THEN CASE SUBSTRING(sc.cclass, 2, 3) WHEN 'DIS' THEN 'WHS' ELSE 'DRP' END + WHEN 'DIS' THEN + CASE SUBSTRING(sc.cclass, 2, 3) + WHEN 'DIS' THEN 'WHS' + ELSE 'DRP' + END ELSE 'DIR' END AS chan, CASE SUBSTRING(bc.cclass, 2, 3) @@ -105,12 +109,20 @@ BEGIN ELSE COALESCE(sc.tier, bc.tier) END AS tier, CASE SUBSTRING(bc.cclass, 2, 3) - WHEN 'DIS' THEN CASE SUBSTRING(sc.cclass, 2, 3) WHEN 'DIS' THEN bc.dba ELSE sc.dba END + WHEN 'DIS' THEN + CASE SUBSTRING(sc.cclass, 2, 3) + WHEN 'DIS' THEN bc.dba + ELSE sc.dba + END ELSE bc.dba END AS cust, i.mpck AS pltq, CASE SUBSTRING(bc.cclass, 2, 3) - WHEN 'DIS' THEN CASE SUBSTRING(sc.cclass, 2, 3) WHEN 'DIS' THEN sc.plevel ELSE bc.plevel END + WHEN 'DIS' THEN + CASE SUBSTRING(sc.cclass, 2, 3) + WHEN 'DIS' THEN COALESCE(sc.plevel,bc.plevel) + ELSE bc.plevel + END ELSE bc.plevel END AS plevel, i.partgroup AS partgroup, diff --git a/procs/single_price_call.ms.sql b/procs/single_price_call.ms.sql index 7d82d35..9ea04b7 100644 --- a/procs/single_price_call.ms.sql +++ b/procs/single_price_call.ms.sql @@ -182,7 +182,7 @@ BEGIN CASE SUBSTRING(bc.cclass, 2, 3) WHEN 'DIS' THEN CASE SUBSTRING(sc.cclass, 2, 3) - WHEN 'DIS' THEN sc.plevel + WHEN 'DIS' THEN COALESCE(sc.plevel,bc.plevel) ELSE bc.plevel END ELSE bc.plevel diff --git a/procs/single_price_call.pg.sql b/procs/single_price_call.pg.sql index 20adab3..1d76703 100644 --- a/procs/single_price_call.pg.sql +++ b/procs/single_price_call.pg.sql @@ -184,7 +184,7 @@ BEGIN CASE SUBSTRING(bc.cclass, 2, 3) WHEN 'DIS' THEN CASE SUBSTRING(sc.cclass, 2, 3) - WHEN 'DIS' THEN sc.plevel + WHEN 'DIS' THEN COALESCE(sc.plevel,bc.plevel) ELSE bc.plevel END ELSE bc.plevel diff --git a/procs/single_price_call_func.ms.sql b/procs/single_price_call_func.ms.sql index 7641bd0..c99d43b 100644 --- a/procs/single_price_call_func.ms.sql +++ b/procs/single_price_call_func.ms.sql @@ -78,7 +78,7 @@ BEGIN CASE SUBSTRING(bc.cclass, 2, 3) WHEN 'DIS' THEN CASE SUBSTRING(sc.cclass, 2, 3) - WHEN 'DIS' THEN sc.plevel + WHEN 'DIS' THEN COALESCE(sc.plevel,bc.plevel) ELSE bc.plevel END ELSE bc.plevel