-
Notifications
You must be signed in to change notification settings - Fork 2
/
TransactionAddressCollection.cls
166 lines (90 loc) · 3.79 KB
/
TransactionAddressCollection.cls
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
END
Attribute VB_Name = "TransactionAddressCollection"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Private aShipFrom As Address
Private aShipTo As Address
Private aPointOfOrderAcceptance As Address
Private aPointOfOrderOrigin As Address
Private aSingleLocation As Address
Property Get ShipFrom() As Address
Set ShipFrom = aShipFrom
End Property
Property Set ShipFrom(Address As Address)
If Not aSingleLocation Is Nothing Then
Err.Raise vbObjectError + 1000, Description:="ShipFrom cannot be set if SingleLocation is set."
Else
Set aShipFrom = Address
End If
End Property
Property Get ShipTo() As Address
Set ShipTo = aShipTo
End Property
Property Set ShipTo(Address As Address)
If Not aSingleLocation Is Nothing Then
Err.Raise vbObjectError + 1000, Description:="ShipTo cannot be set if SingleLocation is set."
Else
Set aShipTo = Address
End If
End Property
Property Get PointOfOrderAcceptance() As Address
Set PointOfOrderAcceptance = aPointOfOrderAcceptance
End Property
Property Set PointOfOrderAcceptance(Address As Address)
If Not aSingleLocation Is Nothing Then
Err.Raise vbObjectError + 1000, Description:="PointOfOrderAcceptance cannot be set if SingleLocation is set."
Else
Set aPointOfOrderAcceptance = Address
End If
End Property
Property Get PointOfOrderOrigin() As Address
Set PointOfOrderOrigin = aPointOfOrderOrigin
End Property
Property Set PointOfOrderOrigin(Address As Address)
If Not aSingleLocation Is Nothing Then
Err.Raise vbObjectError + 1000, Description:="PointOfOrderOrigin cannot be set if SingleLocation is set."
Else
Set aShipTo = Address
End If
End Property
Property Get SingleLocation() As Address
Set SingleLocation = aSingleLocation
End Property
Property Set SingleLocation(Address As Address)
If Not aShipFrom Is Nothing _
Or Not aShipTo Is Nothing _
Or Not aPointOfOrderAcceptance Is Nothing _
Or Not aPointOfOrderOrigin Is Nothing Then
Err.Raise vbObjectError + 1000, Description:="SingleLocation cannot be set if other types of addresses are set."
Else
Set aSingleLocation = Address
End If
End Property
Function ToJson() As Object
Dim addresses As Object
Set addresses = JsonConverter.ParseJson("{}")
If Not Me.ShipFrom Is Nothing Then
If Not Me.ShipTo Is Nothing Then
Set addresses("ShipFrom") = Me.ShipFrom.ToJson()
Set addresses("ShipTo") = Me.ShipTo.ToJson()
Else
Err.Raise vbObjectError + 1000, Description:="ShipFrom must have ShipTo set as well."
End If
If Not Me.PointOfOrderAcceptance Is Nothing Then
Set addresses("PointOfOrderAcceptance") = Me.PointOfOrderAcceptance.ToJson()
End If
If Not Me.PointOfOrderOrigin Is Nothing Then
Set addresses("PointOfOrderOrigin") = Me.PointOfOrderOrigin.ToJson()
End If
ElseIf Not Me.SingleLocation Is Nothing Then
Set addresses("SingleLocation") = Me.SingleLocation.ToJson()
ElseIf Not Me.ShipTo Is Nothing Then
Err.Raise vbObjectError + 1000, Description:="ShipFrom must be set if ShipTo is set."
End If
Set ToJson = addresses
End Function