This commit is contained in:
Paul Trowbridge 2021-01-08 14:51:59 -05:00
commit 397b309a55
7 changed files with 458 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*.swp
*.swo

View File

@ -0,0 +1,104 @@
WITH
pc AS (
SELECT
STLC
,COALESCE(COLTIER,'') COLTIER
,coalesce(BRANDING,'' ) branding
,COALESCE(ACCS ,'') ACCS
,COALESCE(SUFF,'') SUFFIX
----price 1 -----------------
,PCKG PCKG1
,1 VOLL1
,PCKG VOL1_UOM
,PACK VOL1_PRICE
----price 2 -----------------
,PCKG PCKG2
,1 VOLl2
,'PLT' VOL2_UOM
,MP VOL2_PRICE
----price 3 -----------------
,'PLT' PCKG3
,1 VOLL3
,'PLT' VOL33_UOM
,BULK VOL3_PRICE
FROM
rlarp.PCORE P
)
,colors AS (
SELECT
pc.STLC
,pc.COLTIER
,pc.branding
,pc.ACCS
,pc.SUFFIX
,listagg( DISTINCT ltrim(rtrim(i.COLC)),', ') clist
----price 1 -----------------
,pc.PCKG1
,pc.VOLL1
,pc.VOL1_UOM
,pc.VOL1_PRICE
----price 2 -----------------
,pc.PCKG2
,pc.VOLl2
,pc.VOL2_UOM
,pc.VOL2_PRICE
----price 3 -----------------
,pc.PCKG1
,pc.VOLL3
,pc.VOL33_UOM
,pc.VOL3_PRICE
FROM
pc
LEFT OUTER JOIN RLARP.ITEMM i ON
i.STLC = pc.stlc
AND i.COLTIER = pc.coltier
--relax relationship to pick up any colors that we run for the mold and color tier
--AND COALESCE(i.BRANDING,'') = pc.branding
--AND COALESCE(i.ACCS,'') = pc.ACCS
--AND COALESCE(i.SUFFIX,'') = pc.suffix
AND APLNT <> 'I'
GROUP BY
pc.STLC
,pc.COLTIER
,pc.branding
,pc.ACCS
,pc.SUFFIX
----price 1 -----------------
,pc.PCKG1
,pc.VOLL1
,pc.VOL1_UOM
,pc.VOL1_PRICE
----price 2 -----------------
,pc.PCKG2
,pc.VOLl2
,pc.VOL2_UOM
,pc.VOL2_PRICE
----price 3 -----------------
,pc.PCKG1
,pc.VOLL3
,pc.VOL33_UOM
,pc.VOL3_PRICE
)
,items AS (
SELECT
pc.STLC
,pc.coltier
,pc.branding
,pc.accs
,pc.suffix
,row_number() OVER (PARTITION BY pc.stlc, pc.coltier, pc.branding, pc.accs, pc.suffix ORDER BY item DESC) seq
,item
,pckg1
,vol1_uom
,'PC' to_uom
FROM
pc
LEFT OUTER JOIN RLARP.ITEMM i ON
i.STLC = pc.stlc
--AND i.COLTIER = pc.coltier
AND COALESCE(i.BRANDING,'') = pc.branding
AND COALESCE(i.ACCS,'') = pc.ACCS
AND COALESCE(i.SUFFIX,'') = pc.suffix
AND APLNT <> 'I'
)
SELECT * FROM items where seq = 1

View File

@ -0,0 +1,117 @@
WITH
pc AS materialized (
SELECT
STLC
,COALESCE(COLTIER,'') COLTIER
,coalesce(BRANDING,'' ) branding
,COALESCE(ACCS ,'') ACCS
,COALESCE(SUFF,'') SUFFIX
----price 1 -----------------
,PCKG PCKG1
,1 VOLL1
,PCKG VOL1_UOM
,PACK VOL1_PRICE
----price 2 -----------------
,PCKG PCKG2
,1 VOLl2
,'PLT' VOL2_UOM
,MP VOL2_PRICE
----price 3 -----------------
,'PLT' PCKG3
,1 VOLL3
,'PLT' VOL3_UOM
,BULK VOL3_PRICE
FROM
rlarp.PCORE P
)
,colors AS (
SELECT
pc.STLC
,pc.COLTIER
,pc.branding
,pc.ACCS
,pc.SUFFIX
,string_agg( DISTINCT ltrim(rtrim(i.COLC)),', ') clist
----price 1 -----------------
,pc.PCKG1
,pc.VOLL1
,pc.VOL1_UOM
,pc.VOL1_PRICE
----price 2 -----------------
,pc.PCKG2
,pc.VOLl2
,pc.VOL2_UOM
,pc.VOL2_PRICE
----price 3 -----------------
,pc.PCKG1
,pc.VOLL3
,pc.VOL3_UOM
,pc.VOL3_PRICE
FROM
pc
LEFT OUTER JOIN RLARP.ITEMMv i ON
i.STLC = pc.stlc
AND i.COLTIER = pc.coltier
--relax relationship to pick up any colors that we run for the mold and color tier
--AND COALESCE(i.BRANDING,'') = pc.branding
--AND COALESCE(i.ACCS,'') = pc.ACCS
--AND COALESCE(i.SUFFIX,'') = pc.suffix
AND APLNT <> 'I'
GROUP BY
pc.STLC
,pc.COLTIER
,pc.branding
,pc.ACCS
,pc.SUFFIX
----price 1 -----------------
,pc.PCKG1
,pc.VOLL1
,pc.VOL1_UOM
,pc.VOL1_PRICE
----price 2 -----------------
,pc.PCKG2
,pc.VOLl2
,pc.VOL2_UOM
,pc.VOL2_PRICE
----price 3 -----------------
,pc.PCKG1
,pc.VOLL3
,pc.VOL3_UOM
,pc.VOL3_PRICE
)
-----------since joining to the item master will be differnt for the last bulk columm---------------
-----------must first pivot the data out then join based on the type of row-------------------------
,items_init AS (
SELECT
pc.STLC
,pc.coltier
,pc.branding
,pc.accs
,pc.suffix
,row_number() OVER (PARTITION BY pc.stlc, pc.coltier, pc.branding, pc.accs, pc.suffix ORDER BY item DESC) seq
,item
,vol1_uom
,vol2_uom
,vol3_uom
,'PC' to_uom
FROM
pc
LEFT OUTER JOIN RLARP.ITEMMv i ON
i.STLC = pc.stlc
--AND i.COLTIER = pc.coltier
AND COALESCE(i.BRANDING,'') = pc.branding
AND COALESCE(i.ACCS,'') = pc.ACCS
AND COALESCE(i.SUFFIX,'') = pc.suffix
AND APLNT <> 'I'
)
,items AS (
SELECT * FROM items_init where seq = 1
)
,uom AS (
SELECT item partn, vol1_uom from_uom, 'pc' to_uom FROM items_init
UNION ALL
SELECT item partn, vol2_uom from_uom, 'pc' to_uom FROM items_init
UNION ALL
SELECT item partn, vol3_uom from_uom, 'pc' to_uom FROM items_init
)
SELECT * FROM uom

13
db_schema/setup.db2.sql Normal file
View File

@ -0,0 +1,13 @@
CREATE TABLE RLARP.PCORE (
STLC VARCHAR(8)
COLTIER VARCHAR(1)
BRANDING VARCHAR(8)
ACCS VARCHAR(2)
SUFF VARCHAR(4)
PCKG VARCHAR(3)
PACK DECIMAL(7,2)
MP DECIMAL(7,2)
BULK DECIMAL(7,2)
);
COMMENT ON TABLE rlarp.pcore IS 'core price list - mold + attributies and 3 static volume breaks';

26
readme.md Normal file
View File

@ -0,0 +1,26 @@
Start with a generic listing of conceptual prices and build a full-20 part listing with volume breaks denominated in per 1000 units.
| stlc | coltier | branding | accs | suff | pckg | pack | mp | bulk |
| -------- | ------- | -------- | ---- | ---- | ---- | ------- | ---- | ------- |
| HTO10752 | B | | S | | CSE | 1337.61 | 1157 | 1099.15 |
| HTO10752 | B | | SH | | CSE | 1337.61 | 1157 | 1099.15 |
| HTO10752 | B | | | | CSE | 1337.61 | 1157 | 1099.15 |
| HTO10752 | T | | S | | CSE | 1337.61 | 1157 | 1099.15 |
| HTO10752 | T | | SH | | CSE | 1337.61 | 1157 | 1099.15 |
| HTO10752 | T | | | | CSE | 1337.61 | 1157 | 1099.15 |
| HTO10752 | L | | S | | CSE | 1337.61 | 1157 | 1099.15 |
| HTO10752 | L | | SH | | CSE | 1337.61 | 1157 | 1099.15 |
| HTO10752 | L | | | | CSE | 1337.61 | 1157 | 1099.15 |
The mold plus basic attributes form a conceptual framework, and have to be attributed to full-20 codes in order for this to work:
* mold/part group: first 8 digits (`rlarp.itemm.styc`)
* color tier: `rlarp.itemm.coltier`
* branding: `rlarp.branding`
* accessories: `rlarp.accs_ps`
* suffix: `rlarp.suffix`
* package: `rlarp.uomp`
Any part numbers that match these columns in rlarp.itemm would qualify for listed pricing.
The only exception is that the "bulk column" only applies to `uomp` value `PLT` (bulk pricing only applies to part numbers with `PLT` default pack unit (`v6cntr`))
the accs_ps and suff columns in `itemm` are calculated and not materialized anywhere, and are a large dependency

196
vba/pricelist.frm Normal file
View File

@ -0,0 +1,196 @@
VERSION 5.00
Begin {C62A69F0-16DC-11CE-9E98-00AA00574A4F} pricelist
Caption = "Price List Name"
ClientHeight = 7995
ClientLeft = 120
ClientTop = 465
ClientWidth = 11865
OleObjectBlob = "pricelist.frx":0000
StartUpPosition = 1 'CenterOwner
End
Attribute VB_Name = "pricelist"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public proceed As Boolean
Private pl() As String
Private plv() As Variant
Private plfv() As Variant
Private Sub bCANCEL_Click()
proceed = False
Me.Hide
End Sub
Private Sub bOK_Click()
If tbPATH = "" Then
MsgBox ("no directory specified")
Exit Sub
End If
proceed = True
Me.Hide
End Sub
Private Sub bPICK_Click()
'--------Open file-------------
Set fd = Application.FileDialog(msoFileDialogFolderPicker)
fd.Show
tbPATH.Text = fd.SelectedItems(1)
End Sub
Private Sub cbInactive_Click()
End Sub
Private Sub cbLIST_Change()
Dim plc() As String
plc = pl
Call FL.x.TBLp_FilterSingle(plc, 0, cbLIST.value, True)
If UBound(plc, 2) = 0 Then Exit Sub
Me.tbD1 = plc(1, 1)
Me.tbD2 = plc(2, 1)
Me.tbD3 = plc(3, 1)
End Sub
Private Sub lbLIST_Click()
Dim i As Long
For i = 1 To lbLIST.ListCount
If lbLIST.Selected(i) Then
cbLIST.value = lbLIST.list(i, 0)
Exit Sub
End If
Next i
Me.cbHDR.value = "3 - Update"
End Sub
Private Sub UserForm_Initialize()
proceed = False
Dim x() As Variant
Dim i As Long
ReDim x(3)
x(1) = "1 - New"
x(2) = "2 - Replace"
x(3) = "3 - Update"
Dim dtl() As Variant
ReDim dtl(3)
dtl(1) = "1 - Add"
dtl(2) = "2 - Update"
dtl(3) = "3 - Delete"
cbHDR.list = x
cbDTL.list = dtl
' If login.tbP = "" Then
' login.Show
' If Not login.proceed Then Exit Sub
' If Not FL.x.ADOp_OpenCon(0, ISeries, "S7830956", False, "PTROWBRIDG", "password") Then
' MsgBox (FL.x.ADOo_errstring)
' Exit Sub
' End If
' End If
If Not FL.x.ADOp_OpenCon(1, ISeries, "S7830956", False, "PTROWBRIDG", "password") Then
MsgBox (FL.x.ADOo_errstring)
Exit Sub
End If
pl = FL.x.ADOp_SelectS(1, "SELECT plcode, d1,d2,d3 FROM RLARP.PLM p ORDER BY plcode", True, 1000, True)
Call FL.x.ADOp_CloseCon(1)
ReDim plv(1 To UBound(pl, 2))
For i = 1 To UBound(pl, 2)
plv(i) = pl(0, i)
Next i
plfv = FL.x.TBLp_StringToVar(FL.x.TBLp_Transpose(pl))
cbLIST.list = plv
lbLIST.list = plfv
'lbHEAD.ColumnCount = lbHist.ColumnCount
'lbHEAD.ColumnWidths = lbHist.ColumnWidths
Call FL.x.frmListBoxHeader(lbHEAD, lbLIST, "plcode", "descr1", "descr2", "descr3")
End Sub
Private Sub UserForm_Terminate()
proceed = False
End Sub
Sub load_lists()
Dim x() As Variant
Dim i As Long
ReDim x(3)
x(1) = "1 - New"
x(2) = "2 - Replace"
x(3) = "3 - Update"
Dim dtl() As Variant
ReDim dtl(3)
dtl(1) = "1 - Add"
dtl(2) = "2 - Update"
dtl(3) = "3 - Delete"
cbHDR.list = x
cbDTL.list = dtl
' If login.tbP = "" Then
' login.Show
' If Not login.proceed Then Exit Sub
' If Not FL.x.ADOp_OpenCon(0, ISeries, "S7830956", False, "PTROWBRIDG", "") Then
' MsgBox (FL.x.ADOo_errstring)
' Exit Sub
' End If
' End If
If Not FL.x.ADOp_OpenCon(1, ISeries, "S7830956", False, "PTROWBRIDG", "") Then
MsgBox (FL.x.ADOo_errstring)
Exit Sub
End If
pl = FL.x.ADOp_SelectS(1, "SELECT plcode, d1, d2, d3 FROM RLARP.PLM p ORDER BY plcode", True, 1000, True)
Call FL.x.ADOp_CloseCon(1)
ReDim plv(1 To UBound(pl, 2))
For i = 1 To UBound(pl, 2)
plv(i) = pl(0, i)
Next i
plfv = FL.x.TBLp_StringToVar(FL.x.TBLp_Transpose(pl))
cbLIST.list = plv
lbLIST.list = plfv
'lbHEAD.ColumnCount = lbHist.ColumnCount
'lbHEAD.ColumnWidths = lbHist.ColumnWidths
Call FL.x.frmListBoxHeader(lbHEAD, lbLIST, "plcode", "d1", "d2", "d3")
End Sub

BIN
vba/pricelist.frx Normal file

Binary file not shown.