From f9d5aaf78282bf7cea24359dfb3e0ad3e86a243a Mon Sep 17 00:00:00 2001 From: Trowbridge Date: Wed, 20 Mar 2019 01:43:18 -0400 Subject: [PATCH] number of updates for monthly --- fpvt.frm | 15 +++++-- fpvt.frx | Bin 19992 -> 19992 bytes handler.bas | 8 +++- months.cls | 111 +++++++++++++++++++++++++++++++++++++++++++++++----- 4 files changed, 120 insertions(+), 14 deletions(-) diff --git a/fpvt.frm b/fpvt.frm index 462a11e..6fb4aa8 100644 --- a/fpvt.frm +++ b/fpvt.frm @@ -4,7 +4,7 @@ Begin {C62A69F0-16DC-11CE-9E98-00AA00574A4F} fpvt ClientHeight = 7260 ClientLeft = 120 ClientTop = 465 - ClientWidth = 16140 + ClientWidth = 17475 OleObjectBlob = "fpvt.frx":0000 StartUpPosition = 1 'CenterOwner End @@ -101,6 +101,7 @@ End Sub Private Sub cbGoSheet_Click() Me.Hide + Worksheets("month").Visible = xlSheetVisible Sheets("month").Select End Sub @@ -328,8 +329,16 @@ Private Sub UserForm_Activate() fVol = bVol + pVol fVal = bVal + pVal - fPrc = fVal / fVol - pPrc = (pVal + bVal) / (bVol + pVol) - bVal / bVol + If fVol = 0 Then + fPrc = 0 + Else + fPrc = fVal / fVol + End If + If (bVol + pVol) = 0 Then + pPrc = 0 + Else + pPrc = (pVal + bVal) / (bVol + pVol) - bVal / bVol + End If Me.load_mbox_ann '---------------------------------------populate monthly------------------------------------------------------- diff --git a/fpvt.frx b/fpvt.frx index 65e763ba14946fb41a6c59df3ac97fc429d3abf1..e85ac680f6e3fd162c3c9dc90077c0e4068f214d 100644 GIT binary patch delta 1029 zcmZuwUr1A76#u?&%QjM%LTQ_Srpy01H=Wzv)XlU_U0Rl=_#imla@N?D=FBq5prE}~ zC(^_oda=Nu;)DJ|^fC(UAxH>&Py;FGDGDR#kDWVHXmsJ;bI$KO_nhEtv` zZLU)ga)4}J70&yq3PuIcux^%SgwxDRqp-x(%rC+Zc23#W=WEgsQkBFn$he&ON4QPl zmT!5joS0hTk;D*98qB^nwX`@-W0otEL$ZG%h@^z#5M^o{!Xv2<<)-Z?32|r%Ng!l= zZ!j441PIxRev23!@&`^475c5dpm!kHudVlcg8jbGEf`8Wld&{EAkfl8~=*GN}nZ7)AVKn#yl5B0^8~4*sirghFX$2`rbjY?drFr%nJ3fU>%E1W|Ah;QJMu%Z?H$A*r?)1EIE43NF{K$cUE!&apx3uhsJOx()_r!3%0ZgWOHfXSAL1nk#^Q^rJ+;#zM?gr>` x)% delta 1006 zcmZWo?MqW(6n~y)*K*{18HJ|X+7As`Y0kGT(-~r>7zkeHP-)(4>7XP*sRoNg z?FcIP2lOrDfnJE9FMTlkmJs$q4WuCGOJN1s%h}ST+x_yK^W*%^`JLbM+=V5&utfE~ zx_Cm)lE2@s`@TM&Q34sPo6S_g80*7ilch6h2)?sPEmpSG67nLB-_&q{l`7m7-z3CM zY%hf8cqCzj>bAP)!*d&JGX=h(ShLA)g+8t19IP>+;6TQkmUZr2!YYmYleN|{#pVCbJ64m4e^AuVWyfN zNmtDWZH5Zrk&Mr(-5_FA6@k{ILU_dVmQn>Sn)9f{@0gvG^#7=mGOkdDFyPaPN>DVocJeh?iUy52x5h5>V)xdYp5Hf2F~a}KOK6o~if z;C#s}atTOPNBNJED-?z*3Sg_aCDw4c;Sx}{6;{M#m~65lF%8yB!{|*RgbUDp7$5U2Z=XKXqrJn_KRJsKvS(J0{MW&S)}Q zvmG0~FX7-c^R&7S#?Zb4Y+t5hZ$<|gTz|}4_H "" + i = i - 1 + Loop + i = i + 1 + End If + + + Sheets("month").Cells(Target.row + i, 2) = build.cbPart.value + Sheets("month").Cells(Target.row + i, 6) = rev_cust(build.cbBill.value) + Sheets("month").Cells(Target.row + i, 12) = rev_cust(build.cbShip.value) + dumping = False + Set basket_touch = Selection + Call Me.get_edit_basket + Target.Select + + End If + + End If + +End Sub + Private Sub Worksheet_Change(ByVal Target As Range) @@ -100,6 +138,8 @@ Private Sub Worksheet_Change(ByVal Target As Range) If Not Intersect(Target, Range("L6:L17")) Is Nothing Then Call Me.mvp_set If Not Intersect(Target, Range("Q6:Q17")) Is Nothing Then Call Me.ms_adj If Not Intersect(Target, Range("R6:R17")) Is Nothing Then Call Me.ms_set + + If Not Intersect(Target, Range("B33:Q1000")) Is Nothing Then Set basket_touch = Target Call Me.get_edit_basket @@ -166,6 +206,8 @@ End Sub Sub ms_set() +On Error GoTo errh + Dim i As Integer Call Me.get_sheet Dim vp As String @@ -173,7 +215,7 @@ Sub ms_set() For i = 1 To 12 If sales(i, 5) = "" Then sales(i, 5) = 0 - If Round(sales(i, 5) - (sales(i, 2) + sales(i, 3)), 6) <> Round(sales(i, 4), 6) Then + If Round(sales(i, 5) - (sales(i, 2) + sales(i, 3)), 2) <> Round(sales(i, 4), 2) Then sales(i, 4) = sales(i, 5) - (sales(i, 2) + sales(i, 3)) Select Case vp Case "volume" @@ -213,6 +255,9 @@ Sub ms_set() Me.crunch_array Me.set_sheet + +errh: + If Err.Number <> 0 Then rollback = True End Sub @@ -282,7 +327,7 @@ Sub get_sheet() tprice = Range("H18:L18") tsales = Range("N18:R18") ReDim adjust(12) - Set basejson = JsonConverter.ParseJson("{""scenario"":" & Sheets("_month").Range("P1").FormulaR1C1 & "}") + Set basejson = JsonConverter.ParseJson(Sheets("_month").Range("P1").FormulaR1C1) End Sub @@ -455,6 +500,19 @@ End Sub Sub build_json(ByVal pos As Integer) + Dim i As Long + Dim j As Long + + ReDim handler.basis(100) + i = 2 + j = 0 + Do While Sheets("config").Cells(2, i) <> "" + handler.basis(j) = Sheets("config").Cells(2, i) + j = j + 1 + i = i + 1 + Loop + ReDim Preserve handler.basis(j - 1) + 'if something is changing If Round(units(pos, 4), 2) <> 0 Or (Round(price(pos, 4), 8) <> 0 And Round(units(pos, 5), 2) <> 0) Then Set adjust(pos) = JsonConverter.ParseJson(JsonConverter.ConvertToJson(basejson)) @@ -468,13 +526,17 @@ Sub build_json(ByVal pos As Integer) 'if the target price is the same as average and a month is being added adjust(pos)("type") = "addmonth_v" End If + adjust(pos)("month") = Worksheets("month").Cells(5 + pos, 1) adjust(pos)("qty") = units(pos, 4) adjust(pos)("amount") = sales(pos, 4) Else 'scale the existing volume(price) on the target month If Round(price(pos, 4), 8) <> 0 Then - 'if the target price is diferent from the average and a month is being added - adjust(pos)("type") = "scale_vp" + If Round(units(pos, 4), 2) <> 0 Then + adjust(pos)("type") = "scale_vp" + Else + adjust(pos)("type") = "scale_p" + End If Else 'if the target price is the same as average and a month is being added adjust(pos)("type") = "scale_v" @@ -482,6 +544,11 @@ Sub build_json(ByVal pos As Integer) adjust(pos)("qty") = units(pos, 4) adjust(pos)("amount") = sales(pos, 4) End If + adjust(pos)("stamp") = Format(DateTime.Now, "yyyy-MM-dd hh:mm:ss") + adjust(pos)("user") = Application.UserName + adjust(pos)("scenario")("version") = "b20" + adjust(pos)("scenario")("iter") = handler.basis + adjust(pos)("source") = "adj" End If End Sub @@ -515,14 +582,18 @@ Sub crunch_array() tprice(1, 5) = 0 End If 'adjust - tprice(1, 3) = (tsales(1, 2) + tsales(1, 3)) / (tunits(1, 2) + tunits(1, 3)) - tprice(1, 2) + If (tunits(1, 2) + tunits(1, 3)) = 0 Then + tprice(1, 3) = 0 + Else + tprice(1, 3) = (tsales(1, 2) + tsales(1, 3)) / (tunits(1, 2) + tunits(1, 3)) - tprice(1, 2) + End If 'current adjust tprice(1, 4) = tprice(1, 5) - (tprice(1, 2) + tprice(1, 3)) End Sub -Sub cancel() +Sub Cancel() Sheets("Orders").Select @@ -531,7 +602,11 @@ End Sub Sub reset() Call Me.load_sheet - + If showbasket Then + showbasket = False + Else + showbasket = True + End If End Sub @@ -654,9 +729,25 @@ Sub get_edit_basket() Worksheets("_month").Range("U2:X5000").ClearContents Call x.SHTp_DumpVar(b, "_month", 2, 21, False, False, True) + 'orig.Select End Sub + +Sub post_adjust() + + Dim i As Long + + For i = 2 To 13 + If Sheets("_month").Cells(i, 16) <> "" Then + Call handler.request_adjust(Sheets("_month").Cells(i, 16)) + End If + Next i + + Sheets("Orders").Select + Worksheets("month").Visible = xlHidden + +End Sub