Compare commits
3 Commits
12c17b0be6
...
86225ea7e5
Author | SHA1 | Date | |
---|---|---|---|
|
86225ea7e5 | ||
|
fde6c97964 | ||
|
81174b5d57 |
@ -382,15 +382,15 @@ End Function
|
||||
|
||||
Public Function ARRAYp_MakeInteger(ParamArray items()) As Integer()
|
||||
|
||||
Dim x() As Integer
|
||||
Dim X() As Integer
|
||||
Dim i As Integer
|
||||
ReDim x(UBound(items))
|
||||
ReDim X(UBound(items))
|
||||
|
||||
For i = 0 To UBound(items())
|
||||
x(i) = items(i)
|
||||
X(i) = items(i)
|
||||
Next i
|
||||
|
||||
ARRAYp_MakeInteger = x
|
||||
ARRAYp_MakeInteger = X
|
||||
|
||||
End Function
|
||||
|
||||
@ -604,15 +604,17 @@ Sub frmListBoxHeader(ByRef hdr As MSForms.listbox, ByRef det As MSForms.listbox,
|
||||
'lbHEAD.ZOrder (0)
|
||||
hdr.SpecialEffect = fmSpecialEffectFlat
|
||||
'hdr.BackColor = RGB(200, 200, 200)
|
||||
hdr.Height = 10
|
||||
'hdr.Height = 15
|
||||
|
||||
' align header to body (should be done last!)
|
||||
hdr.width = det.width
|
||||
hdr.Left = det.Left
|
||||
hdr.Top = det.Top - (hdr.Height - 1)
|
||||
hdr.Top = det.Top - (hdr.Height + 3)
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
Public Function IntersectsWith(Range1 As Range, Range2 As Range) As Boolean
|
||||
IntersectsWith = Not Application.Intersect(Range1, Range2) Is Nothing
|
||||
End Function
|
||||
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
VERSION 5.00
|
||||
Begin {C62A69F0-16DC-11CE-9E98-00AA00574A4F} build
|
||||
Caption = "UserForm1"
|
||||
ClientHeight = 3015
|
||||
Caption = "Change the Mix"
|
||||
ClientHeight = 1590
|
||||
ClientLeft = 120
|
||||
ClientTop = 465
|
||||
ClientWidth = 8100
|
||||
ClientWidth = 10725
|
||||
OleObjectBlob = "build.frx":0000
|
||||
StartUpPosition = 1 'CenterOwner
|
||||
End
|
||||
@ -13,61 +13,27 @@ Attribute VB_GlobalNameSpace = False
|
||||
Attribute VB_Creatable = False
|
||||
Attribute VB_PredeclaredId = True
|
||||
Attribute VB_Exposed = False
|
||||
Public part As String
|
||||
Public bill As String
|
||||
Public ship As String
|
||||
Public useval As Boolean
|
||||
Option Explicit
|
||||
|
||||
Private Sub cbBill_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
|
||||
Select Case KeyCode
|
||||
Case 13
|
||||
Public useval As Boolean
|
||||
|
||||
Private Sub cmdCancel_Click()
|
||||
useval = False
|
||||
Me.Hide
|
||||
End Sub
|
||||
|
||||
Private Sub cmdOK_Click()
|
||||
useval = True
|
||||
Me.Hide
|
||||
Case 27
|
||||
useval = False
|
||||
Me.Hide
|
||||
End Select
|
||||
End Sub
|
||||
|
||||
|
||||
Private Sub cbPart_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
|
||||
|
||||
Select Case KeyCode
|
||||
Case 13
|
||||
useval = True
|
||||
Me.Hide
|
||||
Case 27
|
||||
useval = False
|
||||
Me.Hide
|
||||
End Select
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
Private Sub cbShip_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
|
||||
Select Case KeyCode
|
||||
Case 13
|
||||
useval = True
|
||||
Me.Hide
|
||||
Case 27
|
||||
useval = False
|
||||
Me.Hide
|
||||
End Select
|
||||
End Sub
|
||||
|
||||
Private Sub UserForm_Activate()
|
||||
Public Sub Initialize(part As String, billTo As String, shipTo As String)
|
||||
cbPart.list = shSupportingData.ListObjects("ITEM").DataBodyRange.Value
|
||||
cbPart.Value = part
|
||||
cbBill.list = shSupportingData.ListObjects("CUSTOMER").DataBodyRange.Value
|
||||
cbBill.Value = billTo
|
||||
cbShip.list = shSupportingData.ListObjects("CUSTOMER").DataBodyRange.Value
|
||||
cbShip.Value = shipTo
|
||||
|
||||
useval = False
|
||||
|
||||
cbPart.value = part
|
||||
cbBill.value = bill
|
||||
cbShip.value = ship
|
||||
|
||||
cbPart.list = shSupportingData.ListObjects("ITEM").DataBodyRange.value
|
||||
cbBill.list = shSupportingData.ListObjects("CUSTOMER").DataBodyRange.value
|
||||
cbShip.list = shSupportingData.ListObjects("CUSTOMER").DataBodyRange.value
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
|
BIN
VBA/build.frx
BIN
VBA/build.frx
Binary file not shown.
@ -1,7 +1,7 @@
|
||||
VERSION 5.00
|
||||
Begin {C62A69F0-16DC-11CE-9E98-00AA00574A4F} changes
|
||||
Caption = "History"
|
||||
ClientHeight = 7785
|
||||
ClientHeight = 7815
|
||||
ClientLeft = 120
|
||||
ClientTop = 465
|
||||
ClientWidth = 16710
|
||||
@ -13,93 +13,40 @@ Attribute VB_GlobalNameSpace = False
|
||||
Attribute VB_Creatable = False
|
||||
Attribute VB_PredeclaredId = True
|
||||
Attribute VB_Exposed = False
|
||||
Private x As Variant
|
||||
Private X As Variant
|
||||
|
||||
Private Sub cbCancel_Click()
|
||||
|
||||
Me.Hide
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub cbUndo_Click()
|
||||
|
||||
|
||||
Call Me.delete_selected
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub lbHist_Change()
|
||||
|
||||
Dim i As Integer
|
||||
|
||||
For i = 0 To Me.lbHist.ListCount - 1
|
||||
If Me.lbHist.Selected(i) Then
|
||||
Me.tbPrint.value = x(i, 7)
|
||||
Me.tbPrint.Value = X(i, 7)
|
||||
Exit Sub
|
||||
End If
|
||||
Next i
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
Private Sub lbHist_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
|
||||
|
||||
Select Case KeyCode
|
||||
Case 46
|
||||
Call Me.delete_selected
|
||||
Case 27
|
||||
Call Me.Hide
|
||||
End Select
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
Private Sub UserForm_Activate()
|
||||
|
||||
Dim fail As Boolean
|
||||
|
||||
'x = handler.list_changes("{""user"":""" & Application.UserName & """}", fail)
|
||||
x = handler.list_changes("{""scenario"":{""quota_rep_descr"":""" & shData.Cells(2, 5) & """}}", fail)
|
||||
X = handler.list_changes("{""scenario"":{""quota_rep_descr"":""" & shData.Cells(2, 5) & """}}", fail)
|
||||
If fail Then
|
||||
Me.Hide
|
||||
Exit Sub
|
||||
End If
|
||||
Me.lbHist.list = x
|
||||
|
||||
lbHEAD.ColumnCount = lbHist.ColumnCount
|
||||
lbHEAD.ColumnWidths = lbHist.ColumnWidths
|
||||
|
||||
' add header elements
|
||||
lbHEAD.clear
|
||||
lbHEAD.AddItem
|
||||
lbHEAD.list(0, 0) = "Modifier"
|
||||
lbHEAD.list(0, 1) = "Owner"
|
||||
lbHEAD.list(0, 2) = "When"
|
||||
lbHEAD.list(0, 3) = "Tag"
|
||||
lbHEAD.list(0, 4) = "Comment"
|
||||
lbHEAD.list(0, 5) = "Sales"
|
||||
lbHEAD.list(0, 6) = "id"
|
||||
Me.lbHist.list = X
|
||||
Call Utils.frmListBoxHeader(Me.lbHEAD, Me.lbHist, "Modifier", "Owner", "When", "Tag", "Comment", "Sales", "id")
|
||||
|
||||
|
||||
' make it pretty
|
||||
'body.ZOrder (1)
|
||||
'lbHEAD.ZOrder (0)
|
||||
'lbHEAD.SpecialEffect = fmSpecialEffectFlat
|
||||
'lbHEAD.BackColor = RGB(200, 200, 200)
|
||||
'lbHEAD.Height = 10
|
||||
|
||||
' align header to body (should be done last!)
|
||||
'lbHEAD.width = lbHist.width
|
||||
'lbHEAD.Left = lbHist.Left
|
||||
'lbHEAD.Top = lbHist.Top - (lbHEAD.Height - 1)
|
||||
|
||||
End Sub
|
||||
|
||||
Sub delete_selected()
|
||||
|
||||
Dim logid As Integer
|
||||
Dim i As Integer
|
||||
Dim fail As Boolean
|
||||
@ -109,12 +56,11 @@ Sub delete_selected()
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
|
||||
For i = 0 To Me.lbHist.ListCount - 1
|
||||
If Me.lbHist.Selected(i) Then
|
||||
Call handler.undo_changes(x(i, 6), fail)
|
||||
Call handler.undo_changes(X(i, 6), fail)
|
||||
If fail Then
|
||||
MsgBox ("undo did not work")
|
||||
MsgBox ("Undo did not work.")
|
||||
Exit Sub
|
||||
End If
|
||||
End If
|
||||
@ -124,5 +70,4 @@ Sub delete_selected()
|
||||
|
||||
Me.lbHist.clear
|
||||
Me.Hide
|
||||
|
||||
End Sub
|
||||
|
BIN
VBA/changes.frx
BIN
VBA/changes.frx
Binary file not shown.
911
VBA/fpvt.frm
911
VBA/fpvt.frm
File diff suppressed because it is too large
Load Diff
BIN
VBA/fpvt.frx
BIN
VBA/fpvt.frx
Binary file not shown.
@ -98,7 +98,13 @@ Sub pg_main_workset(rep As String)
|
||||
Exit Sub
|
||||
End If
|
||||
Set json = JsonConverter.ParseJson(wr)
|
||||
ReDim res(json("x").Count, 33)
|
||||
|
||||
If IsNull(json("x")) Then
|
||||
MsgBox "No data found for " & rep & "."
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
ReDim res(json("x").Count, 34)
|
||||
|
||||
For i = 1 To UBound(res, 1)
|
||||
res(i, 0) = json("x")(i)("bill_cust_descr")
|
||||
@ -135,6 +141,7 @@ Sub pg_main_workset(rep As String)
|
||||
res(i, 31) = json("x")(i)("logid")
|
||||
res(i, 32) = json("x")(i)("tag")
|
||||
res(i, 33) = json("x")(i)("comment")
|
||||
res(i, 34) = json("x")(i)("pounds")
|
||||
Next i
|
||||
|
||||
res(0, 0) = "bill_cust_descr"
|
||||
@ -171,6 +178,7 @@ Sub pg_main_workset(rep As String)
|
||||
res(0, 31) = "logid"
|
||||
res(0, 32) = "tag"
|
||||
res(0, 33) = "comment"
|
||||
res(0, 34) = "pounds"
|
||||
|
||||
Set json = Nothing
|
||||
|
||||
@ -209,7 +217,7 @@ Function request_adjust(doc As String, ByRef fail As Boolean) As Object
|
||||
'json("stamp") = Format(Now, "yyyy-mm-dd hh:mm:ss")
|
||||
'doc = JsonConverter.ConvertToJson(doc)
|
||||
|
||||
server = shConfig.Cells(1, 2)
|
||||
server = shConfig.Range("server").Value
|
||||
|
||||
With req
|
||||
.Option(WinHttpRequestOption_SslErrorIgnoreFlags) = SslErrorFlag_Ignore_All
|
||||
@ -247,12 +255,12 @@ Function request_adjust(doc As String, ByRef fail As Boolean) As Object
|
||||
Set json = JsonConverter.ParseJson(wr)
|
||||
|
||||
If IsNull(json("x")) Then
|
||||
MsgBox ("no adjustment was made")
|
||||
MsgBox ("No adjustment was made.")
|
||||
fail = False
|
||||
Exit Function
|
||||
End If
|
||||
|
||||
ReDim res(json("x").Count - 1, 33)
|
||||
ReDim res(json("x").Count - 1, 34)
|
||||
|
||||
For i = 0 To UBound(res, 1)
|
||||
res(i, 0) = json("x")(i + 1)("bill_cust_descr")
|
||||
@ -289,6 +297,7 @@ Function request_adjust(doc As String, ByRef fail As Boolean) As Object
|
||||
res(i, 31) = json("x")(i + 1)("logid")
|
||||
res(i, 32) = json("x")(i + 1)("tag")
|
||||
res(i, 33) = json("x")(i + 1)("comment")
|
||||
res(i, 34) = json("x")(i + 1)("pounds")
|
||||
Next i
|
||||
|
||||
Set json = Nothing
|
||||
@ -322,41 +331,31 @@ End Function
|
||||
Sub load_config()
|
||||
|
||||
Dim i As Integer
|
||||
Dim j As Integer
|
||||
'----server to use---------------------------------------------------------
|
||||
handler.server = shConfig.Cells(1, 2)
|
||||
handler.server = shConfig.Range("server").Value
|
||||
'---basis-----------------------------------------------------------------
|
||||
ReDim handler.basis(100)
|
||||
i = 2
|
||||
j = 0
|
||||
Do While shConfig.Cells(2, i) <> ""
|
||||
handler.basis(j) = shConfig.Cells(2, i)
|
||||
j = j + 1
|
||||
i = i + 1
|
||||
Loop
|
||||
ReDim Preserve handler.basis(j - 1)
|
||||
With shConfig.ListObjects("BASIS")
|
||||
For i = 1 To .DataBodyRange.Rows.Count
|
||||
ReDim Preserve handler.basis(i - 1)
|
||||
handler.basis(i - 1) = .DataBodyRange(i, 1)
|
||||
Next
|
||||
End With
|
||||
'---baseline-----------------------------------------------------------------
|
||||
ReDim handler.baseline(100)
|
||||
i = 2
|
||||
j = 0
|
||||
Do While shConfig.Cells(3, i) <> ""
|
||||
handler.baseline(j) = shConfig.Cells(3, i)
|
||||
j = j + 1
|
||||
i = i + 1
|
||||
Loop
|
||||
ReDim Preserve handler.baseline(j - 1)
|
||||
With shConfig.ListObjects("BASELINE")
|
||||
For i = 1 To .DataBodyRange.Rows.Count
|
||||
ReDim Preserve handler.baseline(i - 1)
|
||||
handler.baseline(i - 1) = .DataBodyRange(i, 1)
|
||||
Next
|
||||
End With
|
||||
'---adjustments-----------------------------------------------------------------
|
||||
ReDim handler.adjust(100)
|
||||
i = 2
|
||||
j = 0
|
||||
Do While shConfig.Cells(4, i) <> ""
|
||||
handler.adjust(j) = shConfig.Cells(4, i)
|
||||
j = j + 1
|
||||
i = i + 1
|
||||
Loop
|
||||
ReDim Preserve handler.adjust(j - 1)
|
||||
With shConfig.ListObjects("ADJUST")
|
||||
For i = 1 To .DataBodyRange.Rows.Count
|
||||
ReDim Preserve handler.adjust(i - 1)
|
||||
handler.adjust(i - 1) = .DataBodyRange(i, 1)
|
||||
Next
|
||||
End With
|
||||
'---plan version--------------------------------------------------------------
|
||||
handler.plan = shConfig.Cells(9, 2)
|
||||
handler.plan = shConfig.Range("budget").Value
|
||||
|
||||
End Sub
|
||||
|
||||
@ -371,7 +370,7 @@ Sub month_tosheet(ByRef pkg() As Variant, ByRef basket() As Variant)
|
||||
Set j = JsonConverter.ParseJson("{""scenario"":" & scenario & "}")
|
||||
.Cells(1, 16) = JsonConverter.ConvertToJson(j)
|
||||
|
||||
For i = 0 To 12
|
||||
For i = 1 To 12
|
||||
'------------volume-------------------
|
||||
.Cells(i + 1, 1) = co_num(pkg(i, 1), 0)
|
||||
.Cells(i + 1, 2) = co_num(pkg(i, 2), 0)
|
||||
@ -456,11 +455,11 @@ Sub month_tosheet(ByRef pkg() As Variant, ByRef basket() As Variant)
|
||||
.Range("U1:AC100000").ClearContents
|
||||
Call Utils.SHTp_DumpVar(basket, .Name, 1, 21, False, False, True)
|
||||
Call Utils.SHTp_DumpVar(basket, .Name, 1, 26, False, False, True)
|
||||
shConfig.Cells(5, 2) = 0
|
||||
shConfig.Cells(6, 2) = 0
|
||||
shConfig.Cells(7, 2) = 0
|
||||
shConfig.Range("rebuild").Value = 0
|
||||
shConfig.Range("show_basket").Value = 0
|
||||
shConfig.Range("new_part").Value = 0
|
||||
|
||||
shMonthView.load_sheet
|
||||
shMonthView.LoadSheet
|
||||
|
||||
End With
|
||||
|
||||
@ -491,7 +490,7 @@ Function list_changes(doc As String, ByRef fail As Boolean) As Variant()
|
||||
Exit Function
|
||||
End If
|
||||
|
||||
server = shConfig.Cells(1, 2)
|
||||
server = shConfig.Range("server").Value
|
||||
|
||||
With req
|
||||
.Option(WinHttpRequestOption_SslErrorIgnoreFlags) = SslErrorFlag_Ignore_All
|
||||
@ -505,7 +504,7 @@ Function list_changes(doc As String, ByRef fail As Boolean) As Variant()
|
||||
Set json = JsonConverter.ParseJson(wr)
|
||||
|
||||
If IsNull(json("x")) Then
|
||||
MsgBox ("no history")
|
||||
MsgBox ("No history.")
|
||||
fail = True
|
||||
Exit Function
|
||||
End If
|
||||
@ -565,7 +564,7 @@ Function undo_changes(ByVal logid As Integer, ByRef fail As Boolean) As Variant(
|
||||
Next i
|
||||
|
||||
If j = 0 Then
|
||||
MsgBox ("current data set is not tracking changes, cannot isolate change locally")
|
||||
MsgBox ("Current data set is not tracking changes. Cannot isolate change locally.")
|
||||
fail = True
|
||||
Exit Function
|
||||
End If
|
||||
@ -604,7 +603,7 @@ Function get_swap_fit(doc As String, ByRef fail As Boolean) As Variant()
|
||||
Exit Function
|
||||
End If
|
||||
|
||||
server = shConfig.Cells(1, 2)
|
||||
server = shConfig.Range("server").Value
|
||||
|
||||
With req
|
||||
.Option(WinHttpRequestOption_SslErrorIgnoreFlags) = SslErrorFlag_Ignore_All
|
||||
@ -618,7 +617,7 @@ Function get_swap_fit(doc As String, ByRef fail As Boolean) As Variant()
|
||||
Set json = JsonConverter.ParseJson(wr)
|
||||
|
||||
If IsNull(json("x")) Then
|
||||
MsgBox ("no history")
|
||||
MsgBox ("No history.")
|
||||
fail = True
|
||||
Exit Function
|
||||
End If
|
||||
|
@ -1,10 +1,10 @@
|
||||
VERSION 5.00
|
||||
Begin {C62A69F0-16DC-11CE-9E98-00AA00574A4F} openf
|
||||
Caption = "Open a Forecast"
|
||||
ClientHeight = 2025
|
||||
ClientHeight = 1365
|
||||
ClientLeft = 120
|
||||
ClientTop = 465
|
||||
ClientWidth = 3825
|
||||
ClientWidth = 6825
|
||||
OleObjectBlob = "openf.frx":0000
|
||||
StartUpPosition = 1 'CenterOwner
|
||||
End
|
||||
@ -21,10 +21,10 @@ End Sub
|
||||
|
||||
Private Sub cbOK_Click()
|
||||
|
||||
Application.StatusBar = "Retrieving data for " & cbDSM.value & "....."
|
||||
Application.StatusBar = "Retrieving data for " & cbDSM.Value & "....."
|
||||
|
||||
openf.Caption = "retrieving data......"
|
||||
Call handler.pg_main_workset(cbDSM.value)
|
||||
openf.Caption = "Retrieving data......"
|
||||
Call handler.pg_main_workset(cbDSM.Value)
|
||||
shOrders.PivotTables("ptOrders").PivotCache.Refresh
|
||||
Application.StatusBar = False
|
||||
openf.Hide
|
||||
@ -33,11 +33,8 @@ End Sub
|
||||
|
||||
Private Sub UserForm_Activate()
|
||||
|
||||
'handler.server = "http://192.168.1.69:3000"
|
||||
handler.server = shConfig.Cells(1, 2)
|
||||
|
||||
openf.Caption = "Select a DSM"
|
||||
cbDSM.list = shSupportingData.ListObjects("DSM").DataBodyRange.value
|
||||
handler.server = shConfig.Range("server").Value
|
||||
cbDSM.list = shSupportingData.ListObjects("DSM").DataBodyRange.Value
|
||||
|
||||
End Sub
|
||||
|
||||
|
BIN
VBA/openf.frx
BIN
VBA/openf.frx
Binary file not shown.
29
VBA/part.frm
29
VBA/part.frm
@ -1,10 +1,10 @@
|
||||
VERSION 5.00
|
||||
Begin {C62A69F0-16DC-11CE-9E98-00AA00574A4F} part
|
||||
Caption = "Part Picker"
|
||||
ClientHeight = 1080
|
||||
ClientHeight = 1335
|
||||
ClientLeft = 120
|
||||
ClientTop = 465
|
||||
ClientWidth = 8100
|
||||
ClientWidth = 9285.001
|
||||
OleObjectBlob = "part.frx":0000
|
||||
StartUpPosition = 1 'CenterOwner
|
||||
End
|
||||
@ -13,34 +13,23 @@ Attribute VB_GlobalNameSpace = False
|
||||
Attribute VB_Creatable = False
|
||||
Attribute VB_PredeclaredId = True
|
||||
Attribute VB_Exposed = False
|
||||
|
||||
Public part As String
|
||||
Public bill As String
|
||||
Public ship As String
|
||||
Public useval As Boolean
|
||||
Option Explicit
|
||||
|
||||
Public useval As Boolean
|
||||
|
||||
Private Sub cbPart_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
|
||||
Private Sub cmdCancel_Click()
|
||||
useval = False
|
||||
Me.Hide
|
||||
End Sub
|
||||
|
||||
Select Case KeyCode
|
||||
Case 13
|
||||
Private Sub cmdOK_Click()
|
||||
useval = True
|
||||
Me.Hide
|
||||
Case 27
|
||||
useval = False
|
||||
Me.Hide
|
||||
End Select
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
Private Sub UserForm_Activate()
|
||||
|
||||
useval = False
|
||||
cbPart.list = shSupportingData.ListObjects("ITEM").DataBodyRange.value
|
||||
|
||||
cbPart.list = shSupportingData.ListObjects("ITEM").DataBodyRange.Value
|
||||
End Sub
|
||||
|
||||
|
||||
|
BIN
VBA/part.frx
BIN
VBA/part.frx
Binary file not shown.
@ -7,3 +7,25 @@ Attribute VB_GlobalNameSpace = False
|
||||
Attribute VB_Creatable = False
|
||||
Attribute VB_PredeclaredId = True
|
||||
Attribute VB_Exposed = True
|
||||
Option Explicit
|
||||
|
||||
Private Sub Worksheet_Change(ByVal Target As Range)
|
||||
If Intersect(Target, shConfig.Range("debug_mode")) Is Nothing Then Exit Sub
|
||||
|
||||
If shConfig.Range("debug_mode").Value Then
|
||||
shConfig.Visible = xlSheetVisible
|
||||
shData.Visible = xlSheetVisible
|
||||
shMonthView.Visible = xlSheetVisible
|
||||
shMonthUpdate.Visible = xlSheetVisible
|
||||
shSupportingData.Visible = xlSheetVisible
|
||||
shWalk.Visible = xlSheetVisible
|
||||
Else
|
||||
shConfig.Visible = xlSheetVeryHidden
|
||||
shData.Visible = xlSheetHidden
|
||||
shMonthView.Visible = xlSheetHidden
|
||||
shMonthUpdate.Visible = xlSheetVeryHidden
|
||||
shSupportingData.Visible = xlSheetVeryHidden
|
||||
shWalk.Visible = xlSheetVeryHidden
|
||||
End If
|
||||
End Sub
|
||||
|
||||
|
11
VBA/shHelp.cls
Normal file
11
VBA/shHelp.cls
Normal file
@ -0,0 +1,11 @@
|
||||
VERSION 1.0 CLASS
|
||||
BEGIN
|
||||
MultiUse = -1 'True
|
||||
END
|
||||
Attribute VB_Name = "shHelp"
|
||||
Attribute VB_GlobalNameSpace = False
|
||||
Attribute VB_Creatable = False
|
||||
Attribute VB_PredeclaredId = True
|
||||
Attribute VB_Exposed = True
|
||||
Option Explicit
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -7,9 +7,9 @@ Attribute VB_GlobalNameSpace = False
|
||||
Attribute VB_Creatable = False
|
||||
Attribute VB_PredeclaredId = True
|
||||
Attribute VB_Exposed = True
|
||||
' Option Explicit
|
||||
'Option Explicit
|
||||
'
|
||||
' Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
|
||||
'Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
|
||||
' Dim pt As PivotTable
|
||||
' Set pt = ActiveSheet.PivotTables("ptWalk")
|
||||
' Dim intersec As Range
|
||||
@ -63,9 +63,9 @@ Attribute VB_Exposed = True
|
||||
' Call handler.load_config
|
||||
' Call handler.load_fpvt
|
||||
'
|
||||
' End Sub
|
||||
'End Sub
|
||||
'
|
||||
' Function piv_pos(list As Object, target_pos As Long) As Long
|
||||
'Function piv_pos(list As Object, target_pos As Long) As Long
|
||||
'
|
||||
' Dim i As Long
|
||||
'
|
||||
@ -77,9 +77,9 @@ Attribute VB_Exposed = True
|
||||
' Next i
|
||||
' 'should not get to this point
|
||||
'
|
||||
' End Function
|
||||
'End Function
|
||||
'
|
||||
' Function piv_fld_index(field_name As String, ByRef pt As PivotTable) As Integer
|
||||
'Function piv_fld_index(field_name As String, ByRef pt As PivotTable) As Integer
|
||||
'
|
||||
' Dim i As Integer
|
||||
'
|
||||
@ -90,25 +90,25 @@ Attribute VB_Exposed = True
|
||||
' End If
|
||||
' Next i
|
||||
'
|
||||
' End Function
|
||||
'End Function
|
||||
'
|
||||
' Function escape_json(ByVal text As String) As String
|
||||
'Function escape_json(ByVal text As String) As String
|
||||
'
|
||||
' text = Replace(text, "'", "''")
|
||||
' text = Replace(text, """", "\""")
|
||||
' If text = "(blank)" Then text = ""
|
||||
' escape_json = text
|
||||
'
|
||||
' End Function
|
||||
'End Function
|
||||
'
|
||||
' Function escape_sql(ByVal text As String) As String
|
||||
'Function escape_sql(ByVal text As String) As String
|
||||
'
|
||||
' text = Replace(text, "'", "''")
|
||||
' text = Replace(text, """", """""")
|
||||
' If text = "(blank)" Then text = ""
|
||||
' escape_sql = text
|
||||
'
|
||||
' End Function
|
||||
'End Function
|
||||
'
|
||||
'
|
||||
|
||||
|
795
build/build_baseline_from_FAnalysis.sql
Normal file
795
build/build_baseline_from_FAnalysis.sql
Normal file
@ -0,0 +1,795 @@
|
||||
-- Connection: usmidsql01.FAnalysis
|
||||
/*
|
||||
|
||||
*******************************************************************************************************************************************
|
||||
** Phil Runninger, 4/27/2023 *************************************************************************************************************
|
||||
**
|
||||
** Here is how you use this script. This procedure is only temporary, as the entire
|
||||
** system will be rewritten for the 2025 season.
|
||||
**
|
||||
** 1. In SSMS...
|
||||
** a. Turn on the option: Query Results, Sql Server, Results to Grid, Include column headers....
|
||||
** b. Connect to usmidsql01.
|
||||
** c. Run this script in the FAnalysis database.
|
||||
** d. Right-click in the results grid, and choose Save Results As...
|
||||
** 2. In a proper text editor, aka Neovim, remove all instances of NULL from the exported file, leaving nothing between the commas.
|
||||
** 3. In DBeaver,
|
||||
** a. Log into usmidsap01
|
||||
** b. Navigate to the ubm.rlarp.osm_pool table
|
||||
** c. Right-click, and choose Import Data.
|
||||
** d. Follow the self-explanatory steps in the wizard. Make sure to choose the option to empty the table first.
|
||||
** e. Verify the import worked correctly.
|
||||
** f. Run the following statements to finish setting up the system.
|
||||
** DELETE FROM rlarp.osm_log WHERE id > 1;
|
||||
** ALTER SEQUENCE rlarp.osm_log_id_seq RESTART 1;
|
||||
**
|
||||
*******************************************************************************************************************************************
|
||||
*******************************************************************************************************************************************
|
||||
|
||||
|
||||
|
||||
Baseline Data New Method:
|
||||
|
||||
Forecasting on Orders Basis
|
||||
|
||||
1 -- Pull 2023 Sales & Volumes + 2023 Promised Sales & Volumes
|
||||
2 - Backout 2024 Open Orders --
|
||||
3 -- Sum 1 and 2, Group By ShiptoGroup, Partgroup
|
||||
4 - Pull 2019 Orders Group By ShipToGroup, Partgroup, OrderMonth
|
||||
5 - Map 3 (total) to 4 (by order month)
|
||||
ShipTo and Partgroup in both
|
||||
* Shipto and Partgroup does not exist in 2019 --> Subtract from 2023 Ship 90
|
||||
Exists in 2019, does not exists in 2023 -- > Ignore
|
||||
|
||||
On the Orders Worksheet
|
||||
Show 2019 Orders as Reference
|
||||
|
||||
Rollup - As part of process.
|
||||
|
||||
*/
|
||||
|
||||
----------------------------------------------------------------------
|
||||
--BASE DATA VALUES RECAST WITH Last Price Paid instead of Spot Price
|
||||
---------------------------------------------------------------------
|
||||
|
||||
SELECT * INTO #BASE_DATA
|
||||
FROM
|
||||
( SELECT
|
||||
[Bill-To] AS bill_cust_descr
|
||||
,[Bill-To Group] AS billto_group
|
||||
,[Ship-To] AS ship_cust_descr
|
||||
,[Ship-To Group] AS shipto_group
|
||||
,CASE WHEN [Quota Rep] LIKE '[0-9][0-9][0-9][0-9][0-9] -%' THEN LEFT([Quota Rep],5) ELSE NULL END AS [dsm]
|
||||
,CASE WHEN [Quota Rep] LIKE '[0-9][0-9][0-9][0-9][0-9] -%' THEN SUBSTRING(RTRIM([Quota Rep]), 9, LEN([Quota Rep])-8) ELSE LTRIM(RTRIM([Quota Rep])) END AS [quota_rep_descr]
|
||||
,[Director] AS [director]
|
||||
,[Segment] AS [segm]
|
||||
,CASE WHEN [Major Group] LIKE '610%' THEN 'Fiber' ELSE 'Plastic' END [substance]
|
||||
,[Channel] AS [chan]
|
||||
,[Channel Sub] AS [chansub]
|
||||
,[Channel - Retail] AS [chan_retail]
|
||||
,[Part Code] AS [part]
|
||||
,[Part Group Descr] AS [part_descr]
|
||||
,[Part Group] AS [part_group]
|
||||
,[Branding Flag] AS [branding]
|
||||
,LEFT([Major Group],5) + ' ' + [Major Group] AS [majg_descr]
|
||||
,LEFT([Minor Group],5) + ' ' + [Minor Group] AS [ming_descr]
|
||||
,LEFT([Major Sales Group],5) + ' ' + [Major Sales Group] AS [majs_descr]
|
||||
,LEFT([Minor Sales Group],5) + ' ' + [Minor Sales Group] AS [mins_descr]
|
||||
,[Order Date] AS [order_date]
|
||||
,[Order Season] AS [order_season]
|
||||
,[Order Month] AS [order_month]
|
||||
,[Ship Date] AS [ship_date]
|
||||
,[Ship Season] AS [ship_season]
|
||||
,[Ship Month] AS [ship_month]
|
||||
,[Request Date] AS [request_date]
|
||||
,[Request Season] AS [request_season]
|
||||
,[Request Month] AS [request_month]
|
||||
,[Promo Code] AS [promo]
|
||||
,[Financial Statement Line] as [fs_line]
|
||||
,[Inventory Currency] as [r_currency]
|
||||
,[Order Currency] as [c_currency]
|
||||
,PRICE.LPP_loc * BASE.Units AS [value_loc]
|
||||
,PRICE.LPP_USD * BASE.Units AS [value_usd]
|
||||
,[Standard Cost Local - Historic] AS [cost_loc]
|
||||
,[Std Cost USD - Historic] AS [cost_usd]
|
||||
,[Units] AS [units]
|
||||
,[Pounds] AS [pounds]
|
||||
,'b24' AS [version]
|
||||
,'copy' AS [iter]
|
||||
,1 AS [logid]
|
||||
,'baseline' AS [tag]
|
||||
,'don''t undo' AS [comment]
|
||||
,[Promise Month] AS [Promise Month]
|
||||
,[Data Source] AS [Data Source]
|
||||
,[Order Status] AS [Order Status]
|
||||
,[Promise Season] AS [Promise Season]
|
||||
FROM [FAnalysis].[RLARP].[osm_stack_pretty_wSTATUS] AS BASE
|
||||
LEFT OUTER JOIN
|
||||
(
|
||||
SELECT shipto_group, [part_descr], /*[Order Number], */ [price_loc] AS [LPP_loc], [price_USD] AS [LPP_USD]
|
||||
FROM
|
||||
( SELECT
|
||||
ROW_NUMBER() OVER (PARTITION BY [Ship-To Group], [Part Code Descr] ORDER BY [Order Date] DESC, [Order Number] DESC) AS LPP_RANK
|
||||
-- ,[Order Date] AS [Order Date]
|
||||
-- ,[Order Number] AS [Order Number]
|
||||
,[Ship-To Group] AS shipto_group
|
||||
,[Part Code Descr] AS [part_descr]
|
||||
-- ,[value local] AS [value_loc]
|
||||
-- ,[value usd] AS [value_usd]
|
||||
-- ,[Units] AS [units]
|
||||
,[Value Local] / NULLIF([Units],0) AS [price_loc]
|
||||
,[Value USD] / NULLIF([Units],0) AS [price_USD]
|
||||
FROM [FAnalysis].[RLARP].[osm_stack_pretty_wSTATUS]
|
||||
WHERE
|
||||
(
|
||||
([Data Source] = 'Actual' AND [Order Status] = 'Open - Current' AND [Promise Season] >= 2023) OR
|
||||
([Data Source] = 'Actual' AND [Ship Season] = 2023)
|
||||
) AND
|
||||
[Ship-To] IS NOT NULL AND
|
||||
[Ship-To Group] IS NOT NULL AND
|
||||
[Order Date] IS NOT NULL
|
||||
--ORDER BY [shipto_group], [part_descr], LPP_RANK ASC
|
||||
) AS LPP_RESULT
|
||||
WHERE LPP_RESULT.LPP_RANK = 1
|
||||
) PRICE
|
||||
ON BASE.[Ship-To Group] = PRICE.shipto_group AND
|
||||
BASE.[Part Code Descr] = PRICE.part_descr
|
||||
WHERE
|
||||
(
|
||||
(BASE.[Data Source] = 'Actual' AND BASE.[Order Status] = 'Open - Current' AND BASE.[Promise Season] >= 2023) OR
|
||||
(BASE.[Data Source] = 'Actual' AND BASE.[Ship Season] = 2023)
|
||||
) AND
|
||||
BASE.[Ship-To] IS NOT NULL AND
|
||||
BASE.[Ship-To Group] IS NOT NULL
|
||||
) AS A
|
||||
|
||||
CREATE CLUSTERED INDEX IDX_CBASE_DATA_STG ON #BASE_DATA(shipto_group)
|
||||
CREATE INDEX IDX_CFYBASE_DATA_PG ON #BASE_DATA(part_group)
|
||||
|
||||
/* Backout orders that already have been placed for FY2024 from the Order Forecast Baseline */
|
||||
|
||||
UPDATE #BASE_DATA SET
|
||||
[value_loc] = -1 * [value_loc]
|
||||
,[value_usd] = -1 * [value_usd]
|
||||
,[cost_loc] = -1 * [cost_loc]
|
||||
,[cost_usd] = -1 * [cost_usd]
|
||||
,[units] = -1 * [Units]
|
||||
,[pounds] = -1 * [Pounds]
|
||||
WHERE [Data Source] = 'Actual' AND [Order Status] = 'Open - Current' AND [Promise Season] > 2023
|
||||
|
||||
----------------------------------------------------------------------------------------------------
|
||||
--CREATE TEMP TABLES: * Shipto and Partgroup does not exist in 2019 --> Subtract from 2023 Ship 90
|
||||
--SELECT #BASE_DATA. FROM #BASE_DATA
|
||||
----------------------------------------------------------------------------------------------------
|
||||
|
||||
SELECT * INTO #FY2023 FROM
|
||||
( SELECT
|
||||
[shipto_group]
|
||||
,[part_group]
|
||||
,[ship_month]
|
||||
,[value_loc]
|
||||
,[value_usd]
|
||||
,[cost_loc]
|
||||
,[cost_usd]
|
||||
,[units]
|
||||
,[pounds]
|
||||
,[Promise Month]
|
||||
,CASE
|
||||
WHEN A.ship_month IS NULL THEN
|
||||
CASE
|
||||
WHEN CAST(LEFT(A.[Promise Month],2) AS INT) - 3 < 1 THEN CAST(LEFT(A.[Promise Month],2) AS INT) + 9
|
||||
ELSE CAST(LEFT(A.[Promise Month],2) AS INT) - 3
|
||||
END --2023 Promised, Not Shipped
|
||||
ELSE
|
||||
CASE
|
||||
WHEN CAST(LEFT(A.ship_month,2) AS INT) - 3 < 1 THEN CAST(LEFT(A.ship_month,2) AS INT) + 9
|
||||
ELSE CAST(LEFT(A.ship_month,2) AS INT) - 3
|
||||
END
|
||||
END AS order_month_idx
|
||||
FROM
|
||||
( SELECT
|
||||
shipto_group
|
||||
,[part_group]
|
||||
,[ship_month]
|
||||
,SUM([value_loc]) AS [value_loc]
|
||||
,SUM([value_usd]) AS [value_usd]
|
||||
,SUM([cost_loc]) AS [cost_loc]
|
||||
,SUM([cost_usd]) AS [cost_usd]
|
||||
,SUM([units]) AS [units]
|
||||
,SUM([pounds]) AS [pounds]
|
||||
,MAX([Promise Month]) AS [Promise Month]
|
||||
FROM #BASE_DATA
|
||||
WHERE
|
||||
(
|
||||
([Data Source] = 'Actual' AND [ship_season] = 2023) OR
|
||||
([Data Source] = 'Actual' AND [Order Status] = 'Open - Current' AND [Promise Season] = 2023)
|
||||
) AND
|
||||
[shipto_group] IS NOT NULL AND
|
||||
[part_group] <> ''
|
||||
GROUP BY [shipto_group], [part_group], [ship_month]
|
||||
) AS A
|
||||
) AS FY23
|
||||
|
||||
CREATE CLUSTERED INDEX IDX_CFY2023_STG ON #FY2023(shipto_group)
|
||||
CREATE INDEX IDX_CFY2023_PG ON #FY2023(part_group)
|
||||
|
||||
SELECT * INTO #FY2019 FROM
|
||||
( SELECT
|
||||
[Ship-To Group] AS shipto_group
|
||||
,[Part Group] AS [part_group]
|
||||
,MAX([Order Month]) AS [order_month]
|
||||
FROM [FAnalysis].[RLARP].[osm_stack_pretty_wSTATUS]
|
||||
WHERE
|
||||
[Data Source] = 'Actual' AND
|
||||
[Order Season] = 2019 AND
|
||||
[Ship-To Group] IS NOT NULL AND
|
||||
[part group] <> ''
|
||||
GROUP BY [Ship-To Group], [Part Group]
|
||||
) AS FY19
|
||||
|
||||
CREATE CLUSTERED INDEX IDX_CFY2019_STG ON #FY2019(shipto_group)
|
||||
CREATE INDEX IDX_CFY2019_PG ON #FY2019(part_group)
|
||||
|
||||
------------------------
|
||||
-- BEGIN MASTER QUERY
|
||||
-------------------------
|
||||
|
||||
SELECT
|
||||
CASE
|
||||
WHEN DETAIL.[ship_season] IS NULL THEN CAST(DETAIL.[promise_season] % 100 AS varchar) + LEFT(DETAIL.[promise_month], 2)
|
||||
ELSE CAST(DETAIL.[ship_season] % 100 AS varchar) + LEFT(DETAIL.[ship_month], 2)
|
||||
END AS [fspr]
|
||||
,NULL as [plnt]
|
||||
,DETAIL.[promo]
|
||||
,NULL as [terms]
|
||||
,DETAIL.bill_cust_descr
|
||||
,DETAIL.ship_cust_descr
|
||||
,DETAIL.[dsm]
|
||||
,DETAIL.[quota_rep_descr]
|
||||
,DETAIL.[director]
|
||||
,DETAIL.billto_group
|
||||
,DETAIL.shipto_group
|
||||
,DETAIL.[chan]
|
||||
,DETAIL.[chansub]
|
||||
,DETAIL.[chan_retail]
|
||||
,DETAIL.[part]
|
||||
,DETAIL.[part_descr]
|
||||
,DETAIL.[part_group]
|
||||
,DETAIL.[branding]
|
||||
,DETAIL.[majg_descr]
|
||||
,DETAIL.[ming_descr]
|
||||
,DETAIL.[majs_descr]
|
||||
,DETAIL.[mins_descr]
|
||||
,DETAIL.[segm]
|
||||
,DETAIL.[substance]
|
||||
,DETAIL.[fs_line]
|
||||
,DETAIL.[r_currency]
|
||||
,DETAIL.[value_usd]/nullif(DETAIL.[value_loc],0) as [r_rate]
|
||||
,DETAIL.[c_currency]
|
||||
,DETAIL.[cost_usd]/nullif(DETAIL.[cost_loc],0) as [c_rate]
|
||||
,ROUND(DETAIL.[Units] * MAPPED.Distribution_Factor,0) AS [units]
|
||||
,DETAIL.[value_loc] * MAPPED.Distribution_Factor AS [value_loc]
|
||||
,DETAIL.[value_usd] * MAPPED.Distribution_Factor AS [value_usd]
|
||||
,DETAIL.[cost_loc] * MAPPED.Distribution_Factor AS [cost_loc]
|
||||
,DETAIL.[cost_usd] * MAPPED.Distribution_Factor AS [cost_usd]
|
||||
,'CLOSED' as [calc_status]
|
||||
,'SHIPMENT' as [flag]
|
||||
,DETAIL.[order_date]
|
||||
,MAPPED.[order_month]
|
||||
,2024 AS [order_season]
|
||||
,DETAIL.[request_date]
|
||||
,DETAIL.[request_month]
|
||||
,DETAIL.[request_season]
|
||||
,DETAIL.[ship_date]
|
||||
,DETAIL.[ship_month]
|
||||
,DETAIL.[ship_season]
|
||||
,[version]
|
||||
,'copy' AS [iter] -- {'copy'--> baseline data, 'actuals' --> reference data}
|
||||
,[logid]
|
||||
,[tag]
|
||||
,[comment]
|
||||
,'build_pool' as [module]
|
||||
,DETAIL.[Pounds] * MAPPED.Distribution_Factor AS [pounds]
|
||||
FROM
|
||||
( SELECT
|
||||
FY23_SALES.shipto_group
|
||||
,FY23_SALES.part_group
|
||||
,FY19_ORDERS.order_month AS order_month
|
||||
,FY23_SALES.value_loc * FY19_ORDERS.Distribution_Factor AS value_loc
|
||||
,FY23_SALES.value_usd * FY19_ORDERS.Distribution_Factor AS value_usd
|
||||
,FY23_SALES.cost_loc * FY19_ORDERS.Distribution_Factor AS cost_loc
|
||||
,FY23_SALES.cost_usd * FY19_ORDERS.Distribution_Factor AS cost_usd
|
||||
,FY23_SALES.units * FY19_ORDERS.Distribution_Factor AS units
|
||||
,FY23_SALES.pounds * FY19_ORDERS.Distribution_Factor AS pounds
|
||||
,FY19_ORDERS.Distribution_Factor AS Distribution_Factor
|
||||
FROM
|
||||
( SELECT
|
||||
shipto_group
|
||||
,[part_group]
|
||||
,SUM([value_loc]) AS [value_loc]
|
||||
,SUM([value_usd]) AS [value_usd]
|
||||
,SUM([cost_loc]) AS [cost_loc]
|
||||
,SUM([cost_usd]) AS [cost_usd]
|
||||
,SUM([units]) AS [units]
|
||||
,SUM([pounds]) AS [pounds]
|
||||
FROM
|
||||
( SELECT /* SHIPPED IN 2023 */
|
||||
bill_cust_descr
|
||||
,billto_group
|
||||
,ship_cust_descr
|
||||
,[shipto_group]
|
||||
,[quota_rep_descr]
|
||||
,[director]
|
||||
,[segm]
|
||||
,[substance]
|
||||
,[chan]
|
||||
,[chansub]
|
||||
,[part_descr]
|
||||
,[part_group]
|
||||
,[branding]
|
||||
,[majg_descr]
|
||||
,[ming_descr]
|
||||
,[majs_descr]
|
||||
,[mins_descr]
|
||||
,[order_season]
|
||||
,[order_month]
|
||||
,[ship_date]
|
||||
,[ship_season]
|
||||
,[ship_month]
|
||||
,[request_season]
|
||||
,[request_month]
|
||||
,[promo]
|
||||
,[value_loc]
|
||||
,[value_usd]
|
||||
,[cost_loc]
|
||||
,[cost_usd]
|
||||
,[units]
|
||||
,[pounds]
|
||||
,[version]
|
||||
,[iter]
|
||||
,[logid]
|
||||
,[tag]
|
||||
,[comment]
|
||||
FROM #BASE_DATA
|
||||
WHERE [Data Source] = 'Actual' AND [ship_season] = 2023
|
||||
UNION ALL
|
||||
SELECT /* OPEN Promised 2023*/
|
||||
bill_cust_descr
|
||||
,billto_group
|
||||
,ship_cust_descr
|
||||
,shipto_group
|
||||
,[quota_rep_descr]
|
||||
,[director]
|
||||
,[segm]
|
||||
,[substance]
|
||||
,[chan]
|
||||
,[chansub]
|
||||
,[part_descr]
|
||||
,[part_group]
|
||||
,[branding]
|
||||
,[majg_descr]
|
||||
,[ming_descr]
|
||||
,[majs_descr]
|
||||
,[mins_descr]
|
||||
,[order_season]
|
||||
,[order_month]
|
||||
,[ship_date]
|
||||
,[ship_season]
|
||||
,[ship_month]
|
||||
,[request_season]
|
||||
,[request_month]
|
||||
,[promo]
|
||||
,[value_loc]
|
||||
,[value_usd]
|
||||
,[cost_loc]
|
||||
,[cost_usd]
|
||||
,[units]
|
||||
,[pounds]
|
||||
,[version]
|
||||
,[iter]
|
||||
,[logid]
|
||||
,[tag]
|
||||
,[comment]
|
||||
FROM #BASE_DATA
|
||||
WHERE [Data Source] = 'Actual' AND [Order Status] = 'Open - Current' AND [Promise Season] = 2023
|
||||
UNION ALL
|
||||
SELECT /* OPEN 2024 AND LATER */
|
||||
bill_cust_descr
|
||||
,billto_group
|
||||
,ship_cust_descr
|
||||
,shipto_group
|
||||
,[quota_rep_descr]
|
||||
,[director]
|
||||
,[segm]
|
||||
,[substance]
|
||||
,[chan]
|
||||
,[chansub]
|
||||
,[part_descr]
|
||||
,[part_group]
|
||||
,[branding]
|
||||
,[majg_descr]
|
||||
,[ming_descr]
|
||||
,[majs_descr]
|
||||
,[mins_descr]
|
||||
,[order_season]
|
||||
,[order_month]
|
||||
,[ship_date]
|
||||
,[ship_season]
|
||||
,[ship_month]
|
||||
,[request_season]
|
||||
,[request_month]
|
||||
,[promo]
|
||||
,[value_loc] AS [value_loc] /* These values are negative in #BASE_DATA to backout order that already have been placed for FY2024 */
|
||||
,[value_usd] AS [value_usd]
|
||||
,[cost_loc] AS [cost_loc]
|
||||
,[cost_usd] AS [cost_usd]
|
||||
,[Units] AS [units]
|
||||
,[Pounds] AS [pounds]
|
||||
,[version]
|
||||
,[iter]
|
||||
,[logid]
|
||||
,[tag]
|
||||
,[comment]
|
||||
FROM #BASE_DATA
|
||||
WHERE [Data Source] = 'Actual' AND [Order Status] = 'Open - Current' AND [Promise Season] > 2023
|
||||
) AS A
|
||||
WHERE part_group <>'' AND shipto_group IS NOT NULL
|
||||
GROUP BY A.shipto_group, A.part_group
|
||||
) AS FY23_SALES
|
||||
LEFT OUTER JOIN
|
||||
( SELECT * /* 4 - Pull 2019 Orders Group By ShipToGroup, Partgroup, OrderMonth Distribution */
|
||||
FROM
|
||||
( SELECT
|
||||
[shipto_group]
|
||||
,[part_group]
|
||||
,[order_month]
|
||||
,SUM([value_loc]) AS [value_loc]
|
||||
,SUM([value_usd]) AS [value_usd]
|
||||
,SUM([cost_loc]) AS [cost_loc]
|
||||
,SUM([cost_usd]) AS [cost_usd]
|
||||
,SUM([units]) AS [units]
|
||||
,SUM([pounds]) AS [pounds]
|
||||
,SUM([Distribution_Factor]) AS [Distribution_Factor]
|
||||
FROM
|
||||
( SELECT /* 2019 Orders*/
|
||||
CASE
|
||||
WHEN SUM([units]) OVER (Partition by [Ship-To Group], [Part Group]) <> 0 THEN [units] / SUM([units]) OVER (Partition by [Ship-To Group], [Part Group])
|
||||
ELSE NULL
|
||||
END AS [Distribution_Factor]
|
||||
,[Bill-To] AS bill_cust_descr
|
||||
,[Bill-To Group] AS billto_group
|
||||
,[Ship-To] AS ship_cust_descr
|
||||
,[Ship-To Group] AS shipto_group
|
||||
,CASE WHEN Right(Left([Quota Rep], 7), 1) = '-' THEN RIGHT(LTRIM(RTRIM([Quota Rep])), Len([Quota Rep]) - 7) ELSE LTRIM(RTRIM([Quota Rep])) END AS [quota_rep_descr]
|
||||
,[Director] AS [director]
|
||||
,[Segment] AS [segm]
|
||||
,CASE WHEN [Major Group] LIKE '610%' THEN 'Fiber' ELSE 'Plastic' END [substance]
|
||||
,[Channel] AS [chan]
|
||||
,[Channel Sub] AS [chansub]
|
||||
,[Part Group Descr] AS [part_descr]
|
||||
,[Part Group] AS [part_group]
|
||||
,[Branding Flag] AS [branding]
|
||||
,LEFT([Major Group],5) + ' ' + [Major Group] AS [majg_descr]
|
||||
,LEFT([Minor Group],5) + ' ' + [Minor Group] AS [ming_descr]
|
||||
,LEFT([Major Sales Group],5) + ' ' + [Major Sales Group] AS [majs_descr]
|
||||
,LEFT([Minor Sales Group],5) + ' ' + [Minor Sales Group] AS [mins_descr]
|
||||
,[Order Season] AS [order_season]
|
||||
,[Order Month] AS [order_month]
|
||||
,[Ship Season] AS [ship_season]
|
||||
,[Ship Month] AS [ship_month]
|
||||
,[Request Season] AS [request_season]
|
||||
,[Request Month] AS [request_month]
|
||||
,[Promo Code] AS [promo]
|
||||
,[value local] AS [value_loc]
|
||||
,[value usd] AS [value_usd]
|
||||
,[Standard Cost Local - Historic] AS [cost_loc]
|
||||
,[Std Cost USD - Historic] AS [cost_usd]
|
||||
,[Units] AS [units]
|
||||
,[Pounds] AS [pounds]
|
||||
,'b24' AS [version]
|
||||
,'copy' AS [iter]
|
||||
,1 AS [logid]
|
||||
,'baseline' AS [tag]
|
||||
,'don''t undo' AS [comment]
|
||||
FROM [FAnalysis].[RLARP].[osm_stack_pretty_wSTATUS]
|
||||
WHERE [Data Source] = 'Actual' AND [Order Season] = 2019
|
||||
) AS B
|
||||
GROUP BY B.shipto_group, B.part_group, B.order_month
|
||||
) AS C
|
||||
--ORDER BY shipto_group, part_group, order_month
|
||||
) AS FY19_ORDERS
|
||||
ON FY23_SALES.shipto_group = FY19_ORDERS.shipto_group AND FY23_SALES.part_group = FY19_ORDERS.part_group
|
||||
WHERE FY19_ORDERS.Order_month is NOT NULL
|
||||
--ORDER BY part_group ASC, order_month ASC
|
||||
UNION ALL
|
||||
SELECT
|
||||
C.shipto_group
|
||||
,C.part_group
|
||||
,D.order_month
|
||||
,C.value_loc AS value_loc
|
||||
,C.value_usd AS value_usd
|
||||
,C.cost_loc AS cost_loc
|
||||
,C.cost_usd AS cost_usd
|
||||
,C.units AS units
|
||||
,C.pounds AS pounds
|
||||
--,1 AS Distribution_Factor
|
||||
--,CASE WHEN SUM(C.[units]) OVER (Partition by [C.shipto_group], [C.part_group]) <> 0 THEN C.[units] / SUM(C.[units]) OVER (Partition by [C.shipto_group], [C.part_group]) ELSE NULL END AS [Distribution_Factor]
|
||||
,C.Distribution_Factor AS Distribution_Factor
|
||||
FROM
|
||||
( SELECT
|
||||
A.shipto_group
|
||||
,A.part_group
|
||||
,A.order_month_idx
|
||||
,A.value_loc AS value_loc
|
||||
,A.value_usd AS value_usd
|
||||
,A.cost_loc AS cost_loc
|
||||
,A.cost_usd AS cost_usd
|
||||
,A.units AS units
|
||||
,A.pounds AS pounds
|
||||
,CASE
|
||||
WHEN SUM(A.[units]) OVER (Partition by A.[shipto_group], A.[part_group]) <> 0 THEN A.[units] / SUM(A.[units]) OVER (Partition by A.[shipto_group], A.[part_group])
|
||||
ELSE NULL
|
||||
END AS [Distribution_Factor]
|
||||
FROM #FY2023 A
|
||||
LEFT OUTER JOIN #FY2019 B
|
||||
ON A.shipto_group = B.shipto_group AND A.part_group = B.part_group
|
||||
WHERE
|
||||
b.[order_month] IS NULL AND
|
||||
A.shipto_group IS NOT NULL
|
||||
) AS C
|
||||
INNER JOIN
|
||||
( SELECT DISTINCT CAST(Left([order_month],2) AS INT) AS [order_month_idx], [order_month]
|
||||
FROM #FY2019
|
||||
) AS D ON C.order_month_idx = D.Order_month_idx
|
||||
) AS MAPPED
|
||||
INNER JOIN
|
||||
( SELECT
|
||||
MAX([bill_cust_descr]) AS bill_cust_descr
|
||||
,MAX([billto_group]) AS billto_group
|
||||
,MAX([ship_cust_descr]) AS ship_cust_descr
|
||||
,shipto_group
|
||||
,MAX([dsm]) AS dsm
|
||||
,MAX([quota_rep_descr]) AS quota_rep_descr
|
||||
,MAX([director]) AS [director]
|
||||
,MAX([segm]) AS [segm]
|
||||
,MAX([substance]) AS [substance]
|
||||
,MAX([chan]) AS [chan]
|
||||
,MAX([chansub]) AS [chansub]
|
||||
,MAX([chan_retail]) AS [chan_retail]
|
||||
,MAX([part]) AS [part]
|
||||
,[part_descr]
|
||||
,[part_group]
|
||||
,MAX([branding]) AS [branding]
|
||||
,MAX([majg_descr]) AS [majg_descr]
|
||||
,MAX([ming_descr]) AS [ming_descr]
|
||||
,MAX([majs_descr]) AS [majs_descr]
|
||||
,MAX([mins_descr]) AS [mins_descr]
|
||||
,MAX([order_date]) AS [order_date]
|
||||
,MAX([order_season]) AS [order_season]
|
||||
,MAX([order_month]) AS [order_month]
|
||||
,MAX([ship_date]) AS [ship_date]
|
||||
,MAX([ship_season]) AS [ship_season]
|
||||
,MAX([ship_month]) AS [ship_month]
|
||||
,MAX([request_date]) AS [request_date]
|
||||
,MAX([request_season]) AS [request_season]
|
||||
,MAX([request_month]) AS [request_month]
|
||||
,MAX([promo]) AS [promo]
|
||||
,MAX([fs_line]) as [fs_line]
|
||||
,MAX([r_currency]) as [r_currency]
|
||||
,MAX([c_currency]) as [c_currency]
|
||||
,SUM([value_loc]) AS [value_loc]
|
||||
,SUM([value_usd]) AS [value_usd]
|
||||
,SUM([cost_loc]) AS [cost_loc]
|
||||
,SUM([cost_usd]) AS [cost_usd]
|
||||
,SUM([units]) AS [units]
|
||||
,SUM([pounds]) AS [pounds]
|
||||
,MAX([version]) AS [version]
|
||||
,MAX([iter]) AS [iter]
|
||||
,MAX([logid]) AS [logid]
|
||||
,MAX([tag]) AS [tag]
|
||||
,MAX([comment]) AS [comment]
|
||||
,MAX([Promise Month]) AS [promise_month]
|
||||
,MAX([Data Source]) AS [Data Source]
|
||||
,MAX([Order Status])AS [Order Status]
|
||||
,MAX([Promise Season]) AS [promise_season]
|
||||
FROM #BASE_DATA
|
||||
GROUP BY shipto_group, /*[part],*/ [part_descr], [part_group]
|
||||
) AS DETAIL
|
||||
ON MAPPED.shipto_group = DETAIL.shipto_group AND MAPPED.part_group = DETAIL.part_group
|
||||
-- ORDER BY shipto_group, part_group, order_season, order_month
|
||||
--
|
||||
UNION ALL
|
||||
--
|
||||
-- 2019 ORDERS & 2022 ORDERS for Reference --
|
||||
SELECT
|
||||
CASE
|
||||
WHEN [Ship Season] IS NULL THEN CAST([Promise Season] % 100 AS varchar) + LEFT([Promise Month], 2)
|
||||
ELSE CAST([Ship Season] % 100 AS varchar) + LEFT([Ship Month], 2)
|
||||
END AS [fspr]
|
||||
,NULL as [plnt]
|
||||
,[Promo Code] AS [promo]
|
||||
,NULL as [terms]
|
||||
,[Bill-To] AS bill_cust_descr
|
||||
,[Ship-To] AS ship_cust_descr
|
||||
,CASE WHEN [Quota Rep] LIKE '[0-9][0-9][0-9][0-9][0-9] -%' THEN LEFT([Quota Rep],5) ELSE NULL END AS [dsm]
|
||||
,CASE WHEN [Quota Rep] LIKE '[0-9][0-9][0-9][0-9][0-9] -%' THEN SUBSTRING(RTRIM([Quota Rep]), 9, LEN([Quota Rep])-8) ELSE LTRIM(RTRIM([Quota Rep])) END AS [quota_rep_descr]
|
||||
,[Director] AS [director]
|
||||
,[Bill-To Group] AS billto_group
|
||||
,[Ship-To Group] AS shipto_group
|
||||
,[Channel] AS [chan]
|
||||
,[Channel Sub] AS [chansub]
|
||||
,[Channel - Retail] AS [chan_retail]
|
||||
,[Part Code] AS [part]
|
||||
,[Part Group Descr] AS [part_descr]
|
||||
,[Part Group] AS [part_group]
|
||||
,[Branding Flag] AS [branding]
|
||||
,LEFT([Major Group],5) + ' ' + [Major Group] AS [majg_descr]
|
||||
,LEFT([Minor Group],5) + ' ' + [Minor Group] AS [ming_descr]
|
||||
,LEFT([Major Sales Group],5) + ' ' + [Major Sales Group] AS [majs_descr]
|
||||
,LEFT([Minor Sales Group],5) + ' ' + [Minor Sales Group] AS [mins_descr]
|
||||
,[Segment] AS [segm]
|
||||
,CASE WHEN [Major Group] LIKE '610%' THEN 'Fiber' ELSE 'Plastic' END [substance]
|
||||
,[Financial Statement Line] as [fs_line]
|
||||
,[Inventory Currency] as [r_currency]
|
||||
,[Value USD]/nullif([Value Local],0) as [r_rate]
|
||||
,[Order Currency] as [c_currency]
|
||||
,[Std Cost USD - Current]/nullif([Std Cost Local - Current],0) as [c_rate]
|
||||
,[Units] AS [units]
|
||||
,[value local] AS [value_loc]
|
||||
,[value usd] AS [value_usd]
|
||||
,[Standard Cost Local - Historic] AS [cost_loc]
|
||||
,[Std Cost USD - Historic] AS [cost_usd]
|
||||
,'CLOSED' as [calc_status]
|
||||
,'SHIPMENT' as [flag]
|
||||
,[Order Date] AS [order_date]
|
||||
,[Order Month] AS [order_month]
|
||||
,[Order Season] AS [order_season]
|
||||
,[Request Date] AS [request_date]
|
||||
,[Request Month] AS [request_month]
|
||||
,[Request Season] AS [request_season]
|
||||
,[Ship Date] AS [ship_date]
|
||||
,[Ship Month] AS [ship_month]
|
||||
,[Ship Season] AS [ship_season]
|
||||
,'b24' AS [version]
|
||||
,'actuals' AS [iter]
|
||||
,1 AS [logid]
|
||||
,'baseline' AS [tag]
|
||||
,'don''t undo' AS [comment]
|
||||
,'build_pool' as [module]
|
||||
,[Pounds] AS [pounds]
|
||||
FROM [FAnalysis].[RLARP].[osm_stack_pretty_wSTATUS]
|
||||
WHERE ([Data Source] = 'Actual' AND [Order Season] IN(2019,2022)) AND [Ship-To Group] IS NOT NULL AND [part group] <> '' --jps04/25/2023 Included 2022 Data for refernece per users request
|
||||
--
|
||||
UNION ALL
|
||||
--
|
||||
-- OPEN ORDERS GOING INTO THE BEGINNING OF 2024 SEASON --
|
||||
-- THESE WERE BACKED OUT OF THE 2024 BASELINE --
|
||||
SELECT
|
||||
CASE
|
||||
WHEN [Ship Season] IS NULL THEN CAST([Promise Season] % 100 AS varchar) + LEFT([Promise Month], 2)
|
||||
ELSE CAST([Ship Season] % 100 AS varchar) + LEFT([Ship Month], 2)
|
||||
END AS [fspr]
|
||||
,NULL as [plnt]
|
||||
,[Promo Code] AS [promo]
|
||||
,NULL as [terms]
|
||||
,[Bill-To] AS bill_cust_descr
|
||||
,[Ship-To] AS ship_cust_descr
|
||||
,CASE WHEN [Quota Rep] LIKE '[0-9][0-9][0-9][0-9][0-9] -%' THEN LEFT([Quota Rep],5) ELSE NULL END AS [dsm]
|
||||
,CASE WHEN [Quota Rep] LIKE '[0-9][0-9][0-9][0-9][0-9] -%' THEN SUBSTRING(RTRIM([Quota Rep]), 9, LEN([Quota Rep])-8) ELSE LTRIM(RTRIM([Quota Rep])) END AS [quota_rep_descr]
|
||||
,[Director] AS [director]
|
||||
,[Bill-To Group] AS billto_group
|
||||
,[Ship-To Group] AS shipto_group
|
||||
,[Channel] AS [chan]
|
||||
,[Channel Sub] AS [chansub]
|
||||
,[Channel - Retail] AS [chan_retail]
|
||||
,[Part Code] AS [part]
|
||||
,[Part Group Descr] AS [part_descr]
|
||||
,[Part Group] AS [part_group]
|
||||
,[Branding Flag] AS [branding]
|
||||
,LEFT([Major Group],5) + ' ' + [Major Group] AS [majg_descr]
|
||||
,LEFT([Minor Group],5) + ' ' + [Minor Group] AS [ming_descr]
|
||||
,LEFT([Major Sales Group],5) + ' ' + [Major Sales Group] AS [majs_descr]
|
||||
,LEFT([Minor Sales Group],5) + ' ' + [Minor Sales Group] AS [mins_descr]
|
||||
,[Segment] AS [segm]
|
||||
,CASE WHEN [Major Group] LIKE '610%' THEN 'Fiber' ELSE 'Plastic' END [substance]
|
||||
,[Financial Statement Line] as [fs_line]
|
||||
,[Inventory Currency] as [r_currency]
|
||||
,[Value USD]/nullif([Value Local],0) as [r_rate]
|
||||
,[Order Currency] as [c_currency]
|
||||
,[Std Cost USD - Current]/nullif([Std Cost Local - Current],0) as [c_rate]
|
||||
,[Units] AS [units]
|
||||
,[value local] AS [value_loc]
|
||||
,[value usd] AS [value_usd]
|
||||
,[Standard Cost Local - Historic] AS [cost_loc]
|
||||
,[Std Cost USD - Historic] AS [cost_usd]
|
||||
,'BACKORDER' as [calc_status]
|
||||
,'REMAINDER' as [flag]
|
||||
,[Order Date] AS [order_date]
|
||||
,[Order Month] AS [order_month]
|
||||
,'2024' AS [order_season] --jps04/25/2023 Changed order season to 2024 so these show up under 2024 in pivot table
|
||||
,[Request Date] AS [request_date]
|
||||
,[Request Month] AS [request_month]
|
||||
,[Request Season] AS [request_season]
|
||||
,[Ship Date] AS [ship_date]
|
||||
,[Ship Month] AS [ship_month]
|
||||
,[Ship Season] AS [ship_season]
|
||||
,'b24' AS [version]
|
||||
,'actuals' AS [iter]
|
||||
,1 AS [logid]
|
||||
,'open-orders' AS [tag] --jps04/25/2023 Change to 'Open-orders' to stinguish these records from the 2024 baseline records
|
||||
,'don''t undo' AS [comment]
|
||||
,'build_pool' as [module]
|
||||
,[Pounds] AS [pounds]
|
||||
FROM [FAnalysis].[RLARP].[osm_stack_pretty_wSTATUS]
|
||||
WHERE [Data Source] = 'Actual' AND [Order Status] = 'Open - Current' AND [Promise Season] > 2023
|
||||
|
||||
--- CLEANUP --
|
||||
DROP TABLE #FY2019
|
||||
DROP TABLE #FY2023
|
||||
DROP TABLE #BASE_DATA
|
||||
|
||||
/*
|
||||
/* OUTPUTS FOR DEBUG AND VALIDATION*/
|
||||
|
||||
-- Select * FROM #BASE_DATA
|
||||
-- ORDER BY shipto_group, part_group
|
||||
--
|
||||
-- Select * FROM #FY2019
|
||||
-- ORDER BY shipto_group, part_group
|
||||
--
|
||||
-- SELECT
|
||||
-- [shipto_group]
|
||||
-- ,[part_group]
|
||||
-- ,[order_month]
|
||||
-- ,SUM([value_loc]) AS [value_loc]
|
||||
-- ,SUM([value_usd]) AS [value_usd]
|
||||
-- ,SUM([cost_loc]) AS [cost_loc]
|
||||
-- ,SUM([cost_usd]) AS [cost_usd]
|
||||
-- ,SUM([units]) AS [units]
|
||||
-- ,SUM([pounds]) AS [pounds]
|
||||
-- ,SUM([Distribution_Factor]) AS [Distribution_Factor]
|
||||
-- FROM(
|
||||
-- Select /* 2019 Orders*/
|
||||
-- CASE WHEN SUM([units]) OVER (Partition by [Ship-To Group], [Part Group]) <> 0 THEN [units] / SUM([units]) OVER (Partition by [Ship-To Group], [Part Group]) ELSE NULL END AS [Distribution_Factor]
|
||||
-- ,[Bill-To] AS bill_cust_descr
|
||||
-- ,[Bill-To Group] AS billto_group
|
||||
-- ,[Ship-To] AS ship_cust_descr
|
||||
-- ,[Ship-To Group] AS shipto_group
|
||||
-- ,CASE WHEN Right(Left([Quota Rep], 7), 1) = '-' THEN RIGHT(LTRIM(RTRIM([Quota Rep])), Len([Quota Rep]) - 7) ELSE LTRIM(RTRIM([Quota Rep])) END AS [quota_rep_descr]
|
||||
-- ,[Director] AS [director]
|
||||
-- ,[Segment] AS [segm]
|
||||
-- ,CASE WHEN [Major Group] LIKE '610%' THEN 'Fiber' ELSE 'Plastic' END [substance]
|
||||
-- ,[Channel] AS [chan]
|
||||
-- ,[Channel Sub] AS [chansub]
|
||||
-- ,[Part Group Descr] AS [part_descr]
|
||||
-- ,[Part Group] AS [part_group]
|
||||
-- ,[Branding Flag] AS [branding]
|
||||
-- ,LEFT([Major Group],5) + ' ' + [Major Group] AS [majg_descr]
|
||||
-- ,LEFT([Minor Group],5) + ' ' + [Minor Group] AS [ming_descr]
|
||||
-- ,LEFT([Major Sales Group],5) + ' ' + [Major Sales Group] AS [majs_descr]
|
||||
-- ,LEFT([Minor Sales Group],5) + ' ' + [Minor Sales Group] AS [mins_descr]
|
||||
-- ,[Order Season] AS [order_season]
|
||||
-- ,[Order Month] AS [order_month]
|
||||
-- ,[Ship Season] AS [ship_season]
|
||||
-- ,[Ship Month] AS [ship_month]
|
||||
-- ,[Request Season] AS [request_season]
|
||||
-- ,[Request Month] AS [request_month]
|
||||
-- ,[Promo Code] AS [promo]
|
||||
-- ,[value local] AS [value_loc]
|
||||
-- ,[value usd] AS [value_usd]
|
||||
-- ,[Standard Cost Local - Historic] AS [cost_loc]
|
||||
-- ,[Std Cost USD - Historic] AS [cost_usd]
|
||||
-- ,[Units] AS [units]
|
||||
-- ,[Pounds] AS [pounds]
|
||||
-- ,'b24' AS [version]
|
||||
-- ,'actuals' AS [iter]
|
||||
-- ,1 AS [logid]
|
||||
-- ,'baseline' AS [tag]
|
||||
-- ,'don''t undo' AS [comment]
|
||||
-- FROM [FAnalysis].[RLARP].[osm_stack_pretty_wSTATUS]
|
||||
-- WHERE [Data Source] = 'Actual' AND [Order Season] = 2019
|
||||
-- ) AS B
|
||||
-- GROUP BY B.shipto_group, B.part_group, B.order_month
|
||||
-- ORDER BY shipto_group, part_group, order_month
|
||||
--
|
||||
*/
|
32
index.js
32
index.js
@ -77,7 +77,7 @@ server.get('/get_pool', bodyParser.json(), function(req, res) {
|
||||
var path = './route_sql/get_pool.sql';
|
||||
var callback = function(arg) {
|
||||
sql = arg;
|
||||
console.log(new Date().toISOString() + "-------------------------get pool:----------------------------");
|
||||
console.log(new Date().toISOString() + " GET (pool) file: " + path + "-._.".repeat(20));
|
||||
console.log(req.body.quota_rep);
|
||||
sql = sql.replace("rep_replace", req.body.quota_rep);
|
||||
console.log(sql);
|
||||
@ -124,7 +124,7 @@ server.get('/scenario_package', bodyParser.json(), function(req, res) {
|
||||
res.send("no body was sent");
|
||||
return;
|
||||
}
|
||||
console.log(new Date().toISOString() + "-------------------------get scenario:------------------------------")
|
||||
console.log(new Date().toISOString() + " GET (scenario package) file: " + path + "-._.".repeat(20))
|
||||
console.log(req.body);
|
||||
//parse the where clause into the main sql statement
|
||||
sql = sql.replace(new RegExp("where_clause", 'g'), w)
|
||||
@ -163,7 +163,7 @@ server.get('/swap_fit', bodyParser.json(), function(req, res) {
|
||||
res.send("no body was sent");
|
||||
return;
|
||||
}
|
||||
console.log(new Date().toISOString() + "-------------------------get swap fit:------------------------------")
|
||||
console.log(new Date().toISOString() + "get swap fit: " + path + "-._.".repeat(20))
|
||||
console.log(req.body);
|
||||
//parse the where clause into the main sql statement
|
||||
sql = sql.replace(new RegExp("where_clause", 'g'), w);
|
||||
@ -203,7 +203,7 @@ server.post('/swap', bodyParser.json(), function(req, res) {
|
||||
res.send("no body was sent");
|
||||
return;
|
||||
}
|
||||
console.log(new Date().toISOString() + "-------------------------post swap:------------------------------")
|
||||
console.log(new Date().toISOString() + "post swap: " + path + "-._.".repeat(20))
|
||||
console.log(req.body);
|
||||
//parse the where clause into the main sql statement
|
||||
sql = sql.replace(new RegExp("where_clause", 'g'), w);
|
||||
@ -246,7 +246,7 @@ server.post('/cust_swap', bodyParser.json(), function(req, res) {
|
||||
res.send("no body was sent");
|
||||
return;
|
||||
}
|
||||
console.log(new Date().toISOString() + "-------------------------cust swap:------------------------------")
|
||||
console.log(new Date().toISOString() + " POST (cust swap) file: " + path + "-._.".repeat(20))
|
||||
console.log(req.body);
|
||||
//parse the where clause into the main sql statement
|
||||
sql = sql.replace(new RegExp("where_clause", 'g'), w);
|
||||
@ -282,7 +282,7 @@ server.get('/list_changes', bodyParser.json(), function(req, res) {
|
||||
var callback = function(arg) {
|
||||
sql = arg;
|
||||
|
||||
console.log(new Date().toISOString() + "-------------------------list changes:------------------------------")
|
||||
console.log(new Date().toISOString() + "GET (list changes) file: " + path + "-._.".repeat(20))
|
||||
console.log(req.body);
|
||||
//parse the where clause into the main sql statement
|
||||
sql = sql.replace(new RegExp("replace_user", 'g'), req.body.scenario.quota_rep_descr)
|
||||
@ -313,7 +313,7 @@ server.get('/undo_change', bodyParser.json(), function(req, res) {
|
||||
var callback = function(arg) {
|
||||
sql = arg;
|
||||
|
||||
console.log(new Date().toISOString() + "-------------------------undo change:------------------------------")
|
||||
console.log(new Date().toISOString() + " GET (undo change) file: " + path + "-._.".repeat(20))
|
||||
console.log(req.body);
|
||||
//parse the where clause into the main sql statement
|
||||
sql = sql.replace(new RegExp("replace_id", 'g'), JSON.stringify(req.body.logid))
|
||||
@ -352,7 +352,7 @@ server.post('/addmonth_v', bodyParser.json(), function(req, res) {
|
||||
res.send("no body was sent");
|
||||
return;
|
||||
}
|
||||
console.log(new Date().toISOString() + "-----------------------------add month volume:---------------------------------");
|
||||
console.log(new Date().toISOString() + " POST (add month volume) file: " + path + "-._.".repeat(20));
|
||||
req.body.stamp = new Date().toISOString()
|
||||
console.log(req.body);
|
||||
//console.log(args);
|
||||
@ -386,7 +386,7 @@ server.post('/addmonth_vp', bodyParser.json(), function(req, res) {
|
||||
res.send("no body was sent");
|
||||
return;
|
||||
}
|
||||
console.log(new Date().toISOString() + "------------------add month volume and price:-------------------");
|
||||
console.log(new Date().toISOString() + " POST (add month volume and price) file: " + path + "-._.".repeat(20));
|
||||
req.body.stamp = new Date().toISOString()
|
||||
console.log(req.body);
|
||||
//console.log(args);
|
||||
@ -429,7 +429,7 @@ server.post('/scale_v', bodyParser.json(), function(req, res) {
|
||||
res.send("no body was sent");
|
||||
return;
|
||||
}
|
||||
console.log(new Date().toISOString() + "-----------------------scale volume:------------------------------");
|
||||
console.log(new Date().toISOString() + " POST (scale volume) file: " + path + "-._.".repeat(20));
|
||||
req.body.stamp = new Date().toISOString()
|
||||
console.log(req.body);
|
||||
//console.log(args);
|
||||
@ -470,7 +470,7 @@ server.post('/scale_p', bodyParser.json(), function(req, res) {
|
||||
res.send("no body was sent");
|
||||
return;
|
||||
}
|
||||
console.log(new Date().toISOString() + "--------------------scale price:-------------------");
|
||||
console.log(new Date().toISOString() + " POST (scale price) file: " + path + "-._.".repeat(20));
|
||||
req.body.stamp = new Date().toISOString()
|
||||
console.log(req.body);
|
||||
//console.log(args);
|
||||
@ -511,7 +511,7 @@ server.post('/scale_vp', bodyParser.json(), function(req, res) {
|
||||
res.send("no body was sent");
|
||||
return;
|
||||
}
|
||||
console.log(new Date().toISOString() + "--------------------scale volume & price:-------------------");
|
||||
console.log(new Date().toISOString() + " POST (scale volume & price) file: " + path + "-._.".repeat(20));
|
||||
req.body.stamp = new Date().toISOString()
|
||||
console.log(req.body);
|
||||
//console.log(args);
|
||||
@ -553,7 +553,7 @@ server.post('/scale_vp_sales', bodyParser.json(), function(req, res) {
|
||||
res.send("no body was sent");
|
||||
return;
|
||||
}
|
||||
console.log(new Date().toISOString() + "--------------------scale volume & price sales:-------------------");
|
||||
console.log(new Date().toISOString() + " POST (scale volume & price sales) file: " + path + "-._.".repeat(20));
|
||||
req.body.stamp = new Date().toISOString()
|
||||
console.log(req.body);
|
||||
//console.log(args);
|
||||
@ -595,7 +595,7 @@ server.post('/new_part', bodyParser.json(), function(req, res) {
|
||||
res.send("no body was sent");
|
||||
return;
|
||||
}
|
||||
console.log(new Date().toISOString() + "--------------------new part:-------------------");
|
||||
console.log(new Date().toISOString() + " POST (new part) file: " + path + "-._.".repeat(20));
|
||||
req.body.stamp = new Date().toISOString()
|
||||
console.log(req.body);
|
||||
//console.log(args);
|
||||
@ -639,7 +639,7 @@ server.post('/new_basket', bodyParser.json(), function(req, res) {
|
||||
res.send("no body was sent");
|
||||
return;
|
||||
}
|
||||
console.log(new Date().toISOString() + "--------------------new basket:-------------------");
|
||||
console.log(new Date().toISOString() + " POST (new basket) file: " + path + "-._.".repeat(20));
|
||||
req.body.stamp = new Date().toISOString()
|
||||
console.log(req.body);
|
||||
//console.log(args);
|
||||
@ -696,7 +696,7 @@ function build_where(req, c, w, d, args) {
|
||||
if (req.body.stamp) {
|
||||
w = w +
|
||||
`
|
||||
AND order_date >= least('` + req.body.stamp + "'::date,'2021-06-01')";
|
||||
AND order_date >= least('` + req.body.stamp + "'::date,'2022-06-01')";
|
||||
}
|
||||
return { c, w, d };
|
||||
}
|
||||
|
@ -224,6 +224,7 @@ SELECT
|
||||
,sum(coalesce(o.value_usd,0)) value_usd
|
||||
,sum(coalesce(o.cost_loc,0)) cost_loc
|
||||
,sum(coalesce(o.cost_usd,0)) cost_usd
|
||||
,sum(coalesce(o.pounds,0)) pounds
|
||||
,o.calc_status
|
||||
,o.flag
|
||||
FROM
|
||||
@ -338,6 +339,7 @@ SELECT
|
||||
,COALESCE(log.doc->>'tag','') "tag"
|
||||
,log.doc->>'message' "comment"
|
||||
,log.doc->>'type' module
|
||||
,round(b.pounds*s.factor*m.momix, 2) pounds
|
||||
FROM
|
||||
basemix b
|
||||
CROSS JOIN vscale s
|
||||
@ -428,6 +430,7 @@ SELECT
|
||||
,COALESCE(log.doc->>'tag','') "tag"
|
||||
,log.doc->>'message' "comment"
|
||||
,log.doc->>'type' module
|
||||
,0::numeric pounds
|
||||
FROM
|
||||
volume b
|
||||
CROSS JOIN pscale p
|
||||
@ -481,6 +484,7 @@ FROM
|
||||
,sum(cost_loc) cost_loc
|
||||
,sum(cost_usd) cost_usd
|
||||
,sum(units) units
|
||||
,sum(pounds) pounds
|
||||
FROM
|
||||
ins
|
||||
GROUP BY
|
||||
|
@ -36,6 +36,7 @@ SELECT
|
||||
,sum(cost_loc) cost_loc
|
||||
,sum(cost_usd) cost_usd
|
||||
,sum(units) units
|
||||
,sum(pounds) pounds
|
||||
,version
|
||||
,iter
|
||||
,logid
|
||||
|
@ -339,6 +339,7 @@ SELECT
|
||||
,COALESCE(log.doc->>'tag','') "tag"
|
||||
,log.doc->>'message' "comment"
|
||||
,log.doc->>'type' module
|
||||
,round(b.units * i.nwht * CASE i.nwun WHEN 'KG' THEN 2.2046 ELSE 1 END, 2) pounds
|
||||
FROM
|
||||
basemix b
|
||||
CROSS JOIN log
|
||||
@ -435,6 +436,7 @@ FROM
|
||||
,sum(cost_loc) cost_loc
|
||||
,sum(cost_usd) cost_usd
|
||||
,sum(units) units
|
||||
,sum(pounds) pounds
|
||||
FROM
|
||||
ins
|
||||
GROUP BY
|
||||
|
@ -36,6 +36,7 @@ target AS (select target_increment incr)
|
||||
,sum(coalesce(value_usd,0)) value_usd --0
|
||||
,sum(coalesce(cost_loc,0)) cost_loc --history part mix
|
||||
,sum(coalesce(cost_usd,0)) cost_usd
|
||||
,sum(coalesce(pounds,0)) pounds
|
||||
,calc_status --0
|
||||
,flag --0
|
||||
,order_date --history date mix
|
||||
@ -173,6 +174,7 @@ target AS (select target_increment incr)
|
||||
,COALESCE(log.doc->>'tag','') "tag"
|
||||
,log.doc->>'message' "comment"
|
||||
,log.doc->>'type' module
|
||||
,0::numeric pounds
|
||||
FROM
|
||||
basemix b
|
||||
CROSS JOIN scale s
|
||||
@ -227,6 +229,7 @@ target AS (select target_increment incr)
|
||||
,sum(cost_loc) cost_loc
|
||||
,sum(cost_usd) cost_usd
|
||||
,sum(units) units
|
||||
,sum(pounds) pounds
|
||||
FROM
|
||||
ins
|
||||
GROUP BY
|
||||
|
@ -72,6 +72,7 @@ target AS (select incr_qty qincr)
|
||||
,sum(coalesce(value_usd,0)) value_usd --0
|
||||
,sum(coalesce(cost_loc,0)) cost_loc --history part mix
|
||||
,sum(coalesce(cost_usd,0)) cost_usd
|
||||
,sum(coalesce(pounds,0)) pounds
|
||||
,calc_status --0
|
||||
,flag --0
|
||||
,order_date --history date mix
|
||||
@ -202,6 +203,7 @@ target AS (select incr_qty qincr)
|
||||
,COALESCE(log.doc->>'tag','') "tag"
|
||||
,log.doc->>'message' "comment"
|
||||
,log.doc->>'type' module
|
||||
,round(pounds*s.factor, 2) pounds
|
||||
FROM
|
||||
basemix b
|
||||
CROSS JOIN scale s
|
||||
@ -254,6 +256,7 @@ FROM
|
||||
,sum(cost_loc) cost_loc
|
||||
,sum(cost_usd) cost_usd
|
||||
,sum(units) units
|
||||
,sum(pounds) pounds
|
||||
FROM
|
||||
ins
|
||||
GROUP BY
|
||||
|
@ -72,6 +72,7 @@ target AS (select target_vol vincr, target_prc pincr)
|
||||
,sum(coalesce(value_usd,0)) value_usd --0
|
||||
,sum(coalesce(cost_loc,0)) cost_loc --history part mix
|
||||
,sum(coalesce(cost_usd,0)) cost_usd
|
||||
,sum(coalesce(pounds,0)) pounds
|
||||
,calc_status --0
|
||||
,flag --0
|
||||
,order_date --history date mix
|
||||
@ -201,6 +202,7 @@ target AS (select target_vol vincr, target_prc pincr)
|
||||
,COALESCE(log.doc->>'tag','') "tag"
|
||||
,log.doc->>'message' "comment"
|
||||
,log.doc->>'type' module
|
||||
,round(pounds*s.factor, 2) pounds
|
||||
FROM
|
||||
basemix b
|
||||
CROSS JOIN vscale s
|
||||
@ -282,6 +284,7 @@ FROM
|
||||
,COALESCE(log.doc->>'tag','') "tag"
|
||||
,log.doc->>'message' "comment"
|
||||
,log.doc->>'type' module
|
||||
,0::numeric pounds
|
||||
FROM
|
||||
volume b
|
||||
CROSS JOIN pscale s
|
||||
@ -336,6 +339,7 @@ FROM
|
||||
,sum(cost_loc) cost_loc
|
||||
,sum(cost_usd) cost_usd
|
||||
,sum(units) units
|
||||
,sum(pounds) pounds
|
||||
FROM
|
||||
ins
|
||||
GROUP BY
|
||||
|
@ -36,7 +36,6 @@ FROM
|
||||
rlarp.osm_pool
|
||||
WHERE
|
||||
where_clause
|
||||
--quota_rep_descr = 'MATTHEW STAAL'
|
||||
AND order_season IN (2023,2024)
|
||||
GROUP BY
|
||||
order_season
|
||||
|
Loading…
Reference in New Issue
Block a user