add functionality for new basket

This commit is contained in:
Trowbridge 2019-03-22 04:56:39 -04:00
parent 0be91dd6f8
commit d4daa4e460

View File

@ -27,6 +27,7 @@ Private orig As Range
Private basket_touch As Range
Private showbasket As Boolean
Private np As Object 'json dedicated to new part scenario
Private b() As Variant 'holds basket
Private Sub Worksheet_Change(ByVal target As Range)
@ -488,7 +489,7 @@ Sub build_json()
np("scenario")("version") = "b20"
Set np("scenario")("iter") = JsonConverter.ParseJson("[""copy""]")
np("source") = "adj"
np("type") = "new_part"
np("type") = "new_basket"
Set m = JsonConverter.ParseJson("{}")
End If
@ -546,6 +547,24 @@ Sub build_json()
If Me.newpart Then
Set np("months") = JsonConverter.ParseJson(JsonConverter.ConvertToJson(m))
np("newpart") = Worksheets("month").Range("B33").value
'np("basket") = x.json_from_table(b, "basket", False)
'get the basket from the sheet
b = Worksheets("_month").Range("U1").CurrentRegion.value
Set m = JsonConverter.ParseJson(x.json_from_table(b, "basket", False))
If UBound(b, 1) <= 2 Then
Set np("basket") = JsonConverter.ParseJson("[" & x.json_from_table(b, "basket", False) & "]")
Else
Set np("basket") = m("basket")
End If
End If
If Me.newpart Then
Sheets("_month").Range("P2:P13").ClearContents
Sheets("_month").Cells(2, 16) = JsonConverter.ConvertToJson(np)
Else
For i = 1 To 12
Sheets("_month").Cells(i + 1, 16) = JsonConverter.ConvertToJson(adjust(i))
Next i
End If
End Sub
@ -696,7 +715,6 @@ End Sub
Sub get_edit_basket()
Dim i As Long
Dim b() As Variant
Dim mix As Double
Dim touch_mix As Double
Dim untouched As Long
@ -754,7 +772,9 @@ Sub get_edit_basket()
Worksheets("_month").Range("U2:X5000").ClearContents
Call x.SHTp_DumpVar(b, "_month", 2, 21, False, False, True)
'orig.Select
If Me.newpart Then
Me.build_json
End If
@ -830,7 +850,6 @@ Sub new_part()
'set new part flag
Dim cust() As String
Dim b() As Variant
Dim i As Long
'---------build customer mix-------------------------------------------------------------------