Compare commits

...

3 Commits

Author SHA1 Message Date
Trowbridge
988f72996a accomodate tagging 2020-02-18 17:04:03 -05:00
pt
ce6461007a loop thorugh each month line to add the tag/comment to the doc 2020-02-18 02:56:37 -05:00
pt
501fa5f4e6 monthly comments and tags 2020-02-18 02:07:38 -05:00
6 changed files with 199 additions and 23 deletions

View File

@ -29,7 +29,7 @@ Private Sub cbUndo_Click()
For i = 0 To Me.lbHist.ListCount - 1 For i = 0 To Me.lbHist.ListCount - 1
If Me.lbHist.Selected(i) Then If Me.lbHist.Selected(i) Then
Call handler.undo_changes(x(i, 5), fail) Call handler.undo_changes(x(i, 6), fail)
If fail Then If fail Then
MsgBox ("undo did not work") MsgBox ("undo did not work")
Exit Sub Exit Sub

Binary file not shown.

120
fpvt.frm
View File

@ -72,6 +72,11 @@ Private Sub butAdjust_Click()
Exit Sub Exit Sub
End If End If
If cbTAG.text = "" Then
MsgBox ("no tag was selected")
Exit Sub
End If
Call handler.request_adjust(JsonConverter.ConvertToJson(adjust), fail) Call handler.request_adjust(JsonConverter.ConvertToJson(adjust), fail)
If fail Then If fail Then
MsgBox ("adjustment was not made due to error") MsgBox ("adjustment was not made due to error")
@ -79,6 +84,7 @@ Private Sub butAdjust_Click()
End If End If
Me.tbCOM = "" Me.tbCOM = ""
Me.cbTAG.text = ""
Me.Hide Me.Hide
@ -115,12 +121,26 @@ End Sub
Private Sub cbGoSheet_Click() Private Sub cbGoSheet_Click()
Worksheets("month").tbMCOM.text = ""
Worksheets("month").sbMPV.value = 0
Worksheets("month").sbMPP.value = 0
Me.Hide Me.Hide
Worksheets("month").Visible = xlSheetVisible Worksheets("month").Visible = xlSheetVisible
Sheets("month").Select Sheets("month").Select
End Sub End Sub
Private Sub cbTAG_Change()
If tbAPI.text = "" Then tbAPI.text = "{}"
Set adjust = JsonConverter.ParseJson(tbAPI.text)
adjust("tag") = cbTAG.value
tbAPI.text = JsonConverter.ConvertToJson(adjust)
End Sub
Private Sub Label64_Click() Private Sub Label64_Click()
End Sub End Sub
@ -180,6 +200,13 @@ Private Sub opEditPrice_Click()
tbFcVol.Enabled = True tbFcVol.Enabled = True
tbFcVol.BackColor = &H80000018 tbFcVol.BackColor = &H80000018
sbpv.Enabled = True
sbpp.Enabled = True
sbpd.Enabled = False
tbpv.Enabled = True
tbpp.Enabled = True
tbpd.Enabled = False
End Sub End Sub
Private Sub opEditSales_Click() Private Sub opEditSales_Click()
@ -196,6 +223,13 @@ Private Sub opEditSales_Click()
tbFcVol.Enabled = False tbFcVol.Enabled = False
tbFcVol.BackColor = &H80000005 tbFcVol.BackColor = &H80000005
sbpv.Enabled = False
sbpp.Enabled = False
sbpd.Enabled = True
tbpv.Enabled = False
tbpp.Enabled = False
tbpd.Enabled = True
End Sub End Sub
@ -260,6 +294,24 @@ Private Sub opPlugVol_Click()
calc_val calc_val
End Sub End Sub
Private Sub sbpd_Change()
tbpd.value = sbpd.value
End Sub
Private Sub sbpp_Change()
tbpp.value = sbpp.value
End Sub
Private Sub sbpv_Change()
tbpv.value = sbpv.value
End Sub
Private Sub tbCOM_Change() Private Sub tbCOM_Change()
If tbAPI.text = "" Then tbAPI.text = "{}" If tbAPI.text = "" Then tbAPI.text = "{}"
@ -277,8 +329,10 @@ Private Sub tbFcPrice_Change()
End Sub End Sub
Private Sub tbFcVal_Change() Private Sub tbFcVal_Change()
If load_tb Then Exit Sub If load_tb Then Exit Sub
If opEditSales Then calc_val If opEditSales Then calc_val
End Sub End Sub
Private Sub tbFcVol_Change() Private Sub tbFcVol_Change()
@ -297,25 +351,63 @@ Private Sub opmVol_Click()
End Sub End Sub
Private Sub tbmfPrice_Change() Private Sub tbmfPrice_Change()
If mline = 0 Then Exit Sub If mline = 0 Then Exit Sub
If clear_lb Or load_tb Then Exit Sub If clear_lb Or load_tb Then Exit Sub
set_Price = True set_Price = True
If opEditPriceM Then calc_mprice If opEditPriceM Then calc_mprice
set_Price = False set_Price = False
End Sub End Sub
Private Sub tbMFVal_Change() Private Sub tbMFVal_Change()
If mline = 0 Then Exit Sub If mline = 0 Then Exit Sub
If clear_lb Or load_tb Then Exit Sub If clear_lb Or load_tb Then Exit Sub
If opEditSalesM Then calc_mval If opEditSalesM Then calc_mval
End Sub End Sub
Private Sub tbmfVol_Change() Private Sub tbmfVol_Change()
If mline = 0 Then Exit Sub If mline = 0 Then Exit Sub
If clear_lb Or load_tb Then Exit Sub If clear_lb Or load_tb Then Exit Sub
If opEditPriceM Then calc_mprice If opEditPriceM Then calc_mprice
End Sub
Private Sub tbpd_Change()
If load_tb Then Exit Sub
If Not VBA.IsNumeric(tbpd.value) Then
tbpd = "0"
End If
tbFcVal = (bVal + pVal) * (1 + tbpd.value / 100)
End Sub
Private Sub tbpp_Change()
If load_tb Then Exit Sub
If Not VBA.IsNumeric(tbpd.value) Then
tbpd = "0"
End If
tbFcPrice = (bPrc + pPrc) * (1 + tbpp.value / 100)
Me.load_mbox_ann
End Sub
Private Sub tbpv_Change()
If load_tb Then Exit Sub
If Not VBA.IsNumeric(tbpv.value) Then
tbpd = "0"
End If
tbFcVol = (bVol + pVol) * (1 + tbpv.value / 100)
End Sub End Sub
Private Sub UserForm_Activate() Private Sub UserForm_Activate()
@ -324,6 +416,7 @@ Private Sub UserForm_Activate()
Dim j As Long Dim j As Long
Dim k As Long Dim k As Long
Dim ok As Boolean Dim ok As Boolean
Dim tags() As Variant
Me.Caption = "Forecast Adjust " & Worksheets("config").Cells(8, 2) Me.Caption = "Forecast Adjust " & Worksheets("config").Cells(8, 2)
Me.mp.Visible = False Me.mp.Visible = False
@ -472,6 +565,15 @@ Private Sub UserForm_Activate()
basket(i, 3) = sp("package")("basket")(i)("mix") basket(i, 3) = sp("package")("basket")(i)("mix")
Next i Next i
If Not IsNull(sp("package")("tags")) Then
ReDim tags(sp("package")("tags").Count - 1, 0)
For i = 1 To sp("package")("tags").Count
tags(i - 1, 0) = sp("package")("tags")(i)
Next i
cbTAG.list = tags
Sheets("month").cbMTAG.list = tags
End If
Call handler.month_tosheet(month, basket) Call handler.month_tosheet(month, basket)
Application.StatusBar = False Application.StatusBar = False
@ -561,19 +663,19 @@ Sub load_mbox()
tbMBaseVol = Format(bVolm, "#,###") tbMBaseVol = Format(bVolm, "#,###")
tbMBaseVal = Format(bValm, "#,###") tbMBaseVal = Format(bValm, "#,###")
tbMBasePrice = Format(bPrcm, "0.000") tbMBasePrice = Format(bPrcm, "0.00000")
tbMPAVol = Format(pVolm, "#,###") tbMPAVol = Format(pVolm, "#,###")
tbmPAVal = Format(pValm, "#,###") tbmPAVal = Format(pValm, "#,###")
tbMPAPrice = Format(pPrcm, "0.000") tbMPAPrice = Format(pPrcm, "0.00000")
tbMFVol = Format(fVolm, "#,###") tbMFVol = Format(fVolm, "#,###")
tbMFVal = Format(fValm, "#,###") tbMFVal = Format(fValm, "#,###")
If Not set_Price Then tbMFPrice = Format(fPrcm, "0.###") If Not set_Price Then tbMFPrice = Format(fPrcm, "0.#####")
tbMAVol = Format(aVolm, "#,###") tbMAVol = Format(aVolm, "#,###")
tbMAVal = Format(aValm, "#,###") tbMAVal = Format(aValm, "#,###")
tbMAPrice = Format(aPrcm, "0.000") tbMAPrice = Format(aPrcm, "0.00000")
load_tb = False load_tb = False
@ -585,19 +687,19 @@ Sub load_mbox_ann()
tbBaseVol = Format(bVol, "#,##0") tbBaseVol = Format(bVol, "#,##0")
tbBaseVal = Format(bVal, "#,##0") tbBaseVal = Format(bVal, "#,##0")
tbBasePrice = Format(bPrc, "0.000") tbBasePrice = Format(bPrc, "0.00000")
tbPadjVol = Format(pVol, "#,##0") tbPadjVol = Format(pVol, "#,##0")
tbPadjVal = Format(pVal, "#,##0") tbPadjVal = Format(pVal, "#,##0")
tbPadjPrice = Format(pPrc, "0.000") tbPadjPrice = Format(pPrc, "0.00000")
tbFcVol = Format(fVol, "#,##0") tbFcVol = Format(fVol, "#,##0")
tbFcVal = Format(fVal, "#,##0") tbFcVal = Format(fVal, "#,##0")
If Not set_Price Then tbFcPrice = Format(fPrc, "0.000") If Not set_Price Then tbFcPrice = Format(fPrc, "0.00000")
tbAdjVol = Format(aVol, "#,##0") tbAdjVol = Format(aVol, "#,##0")
tbAdjVal = Format(aVal, "#,##0") tbAdjVal = Format(aVal, "#,##0")
tbAdjPrice = Format(aPrc, "0.000") tbAdjPrice = Format(aPrc, "0.00000")
load_tb = False load_tb = False
@ -683,6 +785,7 @@ Sub calc_val()
adjust("user") = Application.UserName adjust("user") = Application.UserName
adjust("source") = "adj" adjust("source") = "adj"
adjust("message") = tbCOM.text adjust("message") = tbCOM.text
adjust("tag") = cbTAG.text
If opEditSales Then If opEditSales Then
If opPlugVol Then If opPlugVol Then
adjust("type") = "scale_v" adjust("type") = "scale_v"
@ -736,6 +839,7 @@ Sub calc_price()
adjust("user") = Application.UserName adjust("user") = Application.UserName
adjust("source") = "adj" adjust("source") = "adj"
adjust("message") = tbCOM.text adjust("message") = tbCOM.text
adjust("tag") = cbTAG.text
adjust("version") = handler.plan adjust("version") = handler.plan
If opEditSales Then If opEditSales Then

BIN
fpvt.frx

Binary file not shown.

View File

@ -137,8 +137,8 @@ Sub pg_main_workset(rep As String)
res(i, 28) = json("x")(i)("version") res(i, 28) = json("x")(i)("version")
res(i, 29) = json("x")(i)("iter") res(i, 29) = json("x")(i)("iter")
res(i, 30) = json("x")(i)("logid") res(i, 30) = json("x")(i)("logid")
res(i, 31) = json("x")(i)("comment") res(i, 31) = json("x")(i)("tag")
res(i, 32) = json("x")(i)("module") res(i, 32) = json("x")(i)("comment")
Next i Next i
res(0, 0) = "bill_cust_descr" res(0, 0) = "bill_cust_descr"
@ -172,8 +172,8 @@ Sub pg_main_workset(rep As String)
res(0, 28) = "version" res(0, 28) = "version"
res(0, 29) = "iter" res(0, 29) = "iter"
res(0, 30) = "logid" res(0, 30) = "logid"
res(0, 31) = "comment" res(0, 31) = "tag"
res(0, 32) = "module" res(0, 32) = "comment"
Set json = Nothing Set json = Nothing
@ -283,8 +283,8 @@ Function request_adjust(doc As String, ByRef fail As Boolean) As Object
res(i - 1, 28) = json("x")(i)("version") res(i - 1, 28) = json("x")(i)("version")
res(i - 1, 29) = json("x")(i)("iter") res(i - 1, 29) = json("x")(i)("iter")
res(i - 1, 30) = json("x")(i)("logid") res(i - 1, 30) = json("x")(i)("logid")
res(i - 1, 31) = json("x")(i)("comment") res(i - 1, 31) = json("x")(i)("tag")
res(i - 1, 32) = json("x")(i)("module") res(i - 1, 32) = json("x")(i)("comment")
Next i Next i
Set json = Nothing Set json = Nothing
@ -505,16 +505,17 @@ Function list_changes(doc As String, ByRef fail As Boolean) As Variant()
Exit Function Exit Function
End If End If
ReDim res(json("x").Count - 1, 6) ReDim res(json("x").Count - 1, 7)
For i = 0 To UBound(res, 1) For i = 0 To UBound(res, 1)
res(i, 0) = json("x")(i + 1)("user") res(i, 0) = json("x")(i + 1)("user")
res(i, 1) = json("x")(i + 1)("quota_rep_descr") res(i, 1) = json("x")(i + 1)("quota_rep_descr")
res(i, 2) = json("x")(i + 1)("stamp") res(i, 2) = json("x")(i + 1)("stamp")
res(i, 3) = json("x")(i + 1)("comment") res(i, 3) = json("x")(i + 1)("tag")
res(i, 4) = json("x")(i + 1)("sales") res(i, 4) = json("x")(i + 1)("comment")
res(i, 5) = json("x")(i + 1)("id") res(i, 5) = json("x")(i + 1)("sales")
res(i, 6) = json("x")(i + 1)("def") res(i, 6) = json("x")(i + 1)("id")
res(i, 7) = json("x")(i + 1)("def")
Next i Next i
list_changes = res list_changes = res

View File

@ -29,6 +29,66 @@ Private showbasket As Boolean
Private np As Object 'json dedicated to new part scenario Private np As Object 'json dedicated to new part scenario
Private b() As Variant 'holds basket Private b() As Variant 'holds basket
Private Sub cbMTAG_Change()
End Sub
Private Sub sbMPP_Change()
Dim m As Worksheet
Dim i As Long
Application.ScreenUpdating = False
dumping = True
Set m = Sheets("month")
m.Cells(19, 11) = sbMPP.value / 100
For i = 6 To 17
m.Cells(i, 11) = (m.Cells(i, 9)) * m.Cells(19, 11)
Next i
Me.mvp_adj
dumping = False
Application.ScreenUpdating = True
End Sub
Private Sub sbMPV_Change()
Dim m As Worksheet
Dim i As Long
Application.ScreenUpdating = False
dumping = True
Set m = Sheets("month")
m.Cells(19, 5) = sbMPV.value / 100
For i = 6 To 17
If m.Cells(i, 5) <> "" Then
m.Cells(i, 5) = (m.Cells(i, 3)) * m.Cells(19, 5)
End If
Next i
dumping = False
Call Me.mvp_adj
Application.ScreenUpdating = True
End Sub
Private Sub tbMCOM_Change()
End Sub
Private Sub Worksheet_Change(ByVal target As Range) Private Sub Worksheet_Change(ByVal target As Range)
If Not dumping Then If Not dumping Then
@ -513,7 +573,8 @@ Sub build_json()
adjust(pos)("type") = "addmonth_vp" adjust(pos)("type") = "addmonth_vp"
Else Else
'if the target price is the same as average and a month is being added 'if the target price is the same as average and a month is being added
adjust(pos)("type") = "addmonth_v" '--ignore above comment and always use add month_vp
adjust(pos)("type") = "addmonth_vp"
End If End If
adjust(pos)("month") = Worksheets("month").Cells(5 + pos, 1) adjust(pos)("month") = Worksheets("month").Cells(5 + pos, 1)
adjust(pos)("qty") = units(pos, 4) adjust(pos)("qty") = units(pos, 4)
@ -786,14 +847,24 @@ Sub post_adjust()
Dim i As Long Dim i As Long
Dim fail As Boolean Dim fail As Boolean
Dim adjust As Object
Dim jdoc As String
If Me.newpart Then If Me.newpart Then
Call handler.request_adjust(Sheets("_month").Cells(2, 16), fail) Set adjust = JsonConverter.ParseJson(Sheets("_month").Cells(2, 16))
adjust("message") = Me.tbMCOM.text
adjust("tag") = Me.cbMTAG.text
jdoc = JsonConverter.ConvertToJson(adjust)
Call handler.request_adjust(jdoc, fail)
If fail Then Exit Sub If fail Then Exit Sub
Else Else
For i = 2 To 13 For i = 2 To 13
If Sheets("_month").Cells(i, 16) <> "" Then If Sheets("_month").Cells(i, 16) <> "" Then
Call handler.request_adjust(Sheets("_month").Cells(i, 16), fail) Set adjust = JsonConverter.ParseJson(Sheets("_month").Cells(i, 16))
adjust("message") = Me.tbMCOM.text
adjust("tag") = Me.cbMTAG.text
jdoc = JsonConverter.ConvertToJson(adjust)
Call handler.request_adjust(jdoc, fail)
If fail Then Exit Sub If fail Then Exit Sub
End If End If
Next i Next i