-
Notifications
You must be signed in to change notification settings - Fork 2
/
TransactionRequest.cls
578 lines (304 loc) · 10.3 KB
/
TransactionRequest.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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
END
Attribute VB_Name = "TransactionRequest"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Private sCompanyCode As String
Private dTransactionDate As Date
Private sCode As String
Private sTransactionType As String
Private sCustomerCode As String
Private sSalespersonCode As String
Private tacAddresses As TransactionAddressCollection
Private aLines As Collection
Private sReferenceCode As String
Private cHashCode As Long
Private sReportingLocationCode As String
Private bCommit As Boolean
Private sBatchCode As String
Private sTaxOverrideType As String
Private cTaxOverrideAmount As Currency
Private dTaxOverrideDate As Date
Private sTaxOverrideReason As String
Private dTaxDate As Date
Private sCurrencyCode As String
Private sServiceMode As String
Private dPaymentDate As Date
Private cExchangeRate As Currency
Private dExchangeRateEffectiveDate As Date
Private sPosLaneCode As String
Private sBusinessIdentificationNo As String
Private bIsSellerImporterOfRecord As Boolean
Private sDescription As String
Private sEmail As String
Private sExemptionNo As String
Private sPurchaseOrderNo As String
Private cDiscount As Currency
Private sCustomerUsageType As String
Property Get CompanyCode() As String
CompanyCode = sCompanyCode
End Property
Property Let CompanyCode(CompanyCode As String)
sCompanyCode = CompanyCode
End Property
Property Get TransactionType() As String
TransactionType = sTransactionType
End Property
Property Let TransactionType(TransactionType As String)
sTransactionType = TransactionType
End Property
Property Get Code() As String
Code = sCode
End Property
Property Let Code(Code As String)
sCode = Code
End Property
Property Get TransactionDate() As Date
TransactionDate = dTransactionDate
End Property
Property Let TransactionDate(TransactionDate As Date)
dTransactionDate = TransactionDate
End Property
Property Get SalespersonCode() As String
SalespersonCode = sSalespersonCode
End Property
Property Let SalespersonCode(SalespersonCode As String)
sSalespersonCode = SalespersonCode
End Property
Property Get customerCode() As String
customerCode = sCustomerCode
End Property
Property Let customerCode(customerCode As String)
sCustomerCode = customerCode
End Property
Property Get CustomerUsageType() As String
CustomerUsageType = sCustomerUsageType
End Property
Property Let CustomerUsageType(CustomerUsageType As String)
sCustomerUsageType = CustomerUsageType
End Property
Property Get Discount() As Currency
Discount = cDiscount
End Property
Property Let Discount(Discount As Currency)
cDiscount = Discount
End Property
Property Get PurchaseOrderNo() As String
PurchaseOrderNo = sPurchaseOrderNo
End Property
Property Let PurchaseOrderNo(PurchaseOrderNo As String)
sPurchaseOrderNo = PurchaseOrderNo
End Property
Property Get ExemptionNo() As String
ExemptionNo = sExemptionNo
End Property
Property Let ExemptionNo(ExemptionNo As String)
sExemptionNo = ExemptionNo
End Property
Property Get addresses() As TransactionAddressCollection
addresses = tacAddresses
End Property
Property Set addresses(addresses As TransactionAddressCollection)
Set tacAddresses = addresses
End Property
Property Get Lines() As Collection
Set Lines = aLines
End Property
Property Set Lines(txLines As Collection)
Set aLines = txLines
End Property
Property Get ReferenceCode() As String
ReferenceCode = sReferenceCode
End Property
Property Let ReferenceCode(refCode As String)
sReferenceCode = refCode
End Property
Property Get HashCode() As Long
HashCode = cHashCode
End Property
Property Let HashCode(HashCode As Long)
cHashCode = HashCode
End Property
Property Get ReportingLocationCode() As String
ReportingLocationCode = sReportingLocationCode
End Property
Property Let ReportingLocationCode(ReportingLocationCode As String)
sReportingLocationCode = ReportingLocationCode
End Property
Property Get Commit() As Boolean
Commit = bCommit
End Property
Property Let Commit(Commit As Boolean)
bCommit = Commit
End Property
Property Get BatchCode() As String
BatchCode = sBatchCode
End Property
Property Let BatchCode(BatchCode As String)
sBatchCode = BatchCode
End Property
Property Get TaxOverrideType() As String
TaxOverrideType = sTaxOverrideType
End Property
Property Let TaxOverrideType(TaxOverrideType As String)
sTaxOverrideType = TaxOverrideType
End Property
Property Get TaxOverrideAmount() As Currency
TaxOverrideAmount = cTaxOverrideAmount
End Property
Property Let TaxOverrideAmount(TaxOverrideAmount As Currency)
cTaxOverrideAmount = TaxOverrideAmount
End Property
Property Get TaxOverrideDate() As Date
TaxOverrideDate = dTaxOverrideDate
End Property
Property Let TaxOverrideDate(TaxOverrideDate As Date)
dTaxOverrideDate = TaxOverrideDate
End Property
Property Get TaxOverrideReason() As String
TaxOverrideReason = sTaxOverrideReason
End Property
Property Let TaxOverrideReason(TaxOverrideReason As String)
sTaxOverrideReason = TaxOverrideReason
End Property
Property Get TaxDate() As Date
TaxDate = dTaxDate
End Property
Property Let TaxDate(TaxDate As Date)
dTaxDate = TaxDate
End Property
Property Get CurrencyCode() As String
CurrencyCode = sCurrencyCode
End Property
Property Let CurrencyCode(CurrencyCode As String)
sCurrencyCode = CurrencyCode
End Property
Property Get ServiceMode() As String
ServiceMode = sServiceMode
End Property
Property Let ServiceMode(ServiceMode As String)
sServiceMode = ServiceMode
End Property
Property Get PaymentDate() As Date
PaymentDate = dPaymentDate
End Property
Property Let PaymentDate(PaymentDate As Date)
dPaymentDate = PaymentDate
End Property
Property Get ExchangeRate() As Currency
ExchangeRate = cExchangeRate
End Property
Property Let ExchangeRate(ExchangeRate As Currency)
cExchangeRate = ExchangeRate
End Property
Property Get ExchangeRateEffectiveDate() As Date
ExchangeRateEffectiveDate = dExchangeRateEffectiveDate
End Property
Property Let ExchangeRateEffectiveDate(ExchangeRateEffectiveDate As Date)
dExchangeRateEffectiveDate = ExchangeRateEffectiveDate
End Property
Property Get PosLaneCode() As String
PosLaneCode = sPosLaneCode
End Property
Property Let PosLaneCode(PosLaneCode As String)
sPosLaneCode = PosLaneCode
End Property
Property Get BusinessIdentificationNo() As String
BusinessIdentificationNo = sBusinessIdentificationNo
End Property
Property Let BusinessIdentificationNo(BusinessIdentificationNo As String)
sBusinessIdentificationNo = BusinessIdentificationNo
End Property
Property Get IsSellerImporterOfRecord() As Boolean
IsSellerImporterOfRecord = bIsSellerImporterOfRecord
End Property
Property Let IsSellerImporterOfRecord(IsSellerImporterOfRecord As Boolean)
bIsSellerImporterOfRecord = IsSellerImporterOfRecord
End Property
Property Get Description() As String
Description = sDescription
End Property
Property Let Description(Description As String)
sDescription = Description
End Property
Property Get Email() As String
Email = sEmail
End Property
Property Let Email(Email As String)
sEmail = Email
End Property
Function ToJson() As Object
Dim Json As Object
Set Json = JsonConverter.ParseJson("{}")
If Me.CompanyCode = "" Then
Err.Raise vbObjectError + 1000, Description:="CompanyCode is required."
End If
Json("companyCode") = Me.CompanyCode
If Me.TransactionType = "" Then
Json("type") = "SalesOrder"
Else
Json("type") = Me.TransactionType
End If
If Me.Code = "" Then
Let Me.Code = Mid$(CreateObject("Scriptlet.TypeLib").GUID, 2, 36)
End If
Json("code") = Me.Code
If Me.customerCode = "" Then
Err.Raise vbObjectError + 1000, Description:="CustomerCode is required."
End If
If Me.TransactionDate = CDate(0) Then
Json("date") = Now
Else
Json("date") = Me.TransactionDate
End If
If Me.SalespersonCode <> "" Then
Json("salespersonCode") = Me.SalespersonCode
End If
If Me.customerCode <> "" Then
Json("customerCode") = Me.customerCode
End If
If Me.CustomerUsageType <> "" Then
Json("customerUsageType") = Me.CustomerUsageType
End If
If Me.Discount = 0 Then
Json("discount") = Me.Discount
End If
If Me.PurchaseOrderNo <> "" Then
Json("purchaseOrderNo") = Me.PurchaseOrderNo
End If
If Me.ExemptionNo <> "" Then
Json("exemptionNo") = Me.ExemptionNo
End If
Dim line As TaxLine
If tacAddresses Is Nothing Then
Dim noAddresses As Boolean
Let noAddresses = True
For Each line In Me.Lines
If Not line Is Nothing Then
If Not line.addresses Is Nothing Then
Let noAddresses = False
End If
End If
Next
If noAddresses Then
Err.Raise vbObjectError + 1000, Description:="An address is required at either the transaction or tax line level."
End If
Else
Set Json("addresses") = tacAddresses.ToJson()
End If
Dim taxLines As New Collection
For Each line In Me.Lines
If Not line Is Nothing Then
Dim lineJson As Object
Set lineJson = line.ToJson()
Debug.Print JsonConverter.ConvertToJson(lineJson)
taxLines.Add lineJson
End If
Next
Set Json("lines") = taxLines
Set ToJson = Json
End Function