@questwork/q-store-model 0.1.39 → 0.1.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.min.cjs +1230 -692
- package/dist/index.min.js +1237 -692
- package/dist/q-store-model.min.js +1230 -692
- package/eslint.config.js +3 -0
- package/package.json +4 -3
package/dist/index.min.cjs
CHANGED
|
@@ -50,6 +50,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
50
50
|
// EXPORTS
|
|
51
51
|
__webpack_require__.d(__webpack_exports__, {
|
|
52
52
|
Amount: () => (/* reexport */ Amount),
|
|
53
|
+
BillingAccount: () => (/* reexport */ BillingAccount),
|
|
54
|
+
BillingProject: () => (/* reexport */ BillingProject),
|
|
53
55
|
Cart: () => (/* reexport */ Cart),
|
|
54
56
|
CartItem: () => (/* reexport */ CartItem),
|
|
55
57
|
Category: () => (/* reexport */ Category),
|
|
@@ -70,13 +72,18 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
70
72
|
Merchandise: () => (/* reexport */ Merchandise),
|
|
71
73
|
Order: () => (/* reexport */ Order),
|
|
72
74
|
OrderLine: () => (/* reexport */ OrderLine),
|
|
75
|
+
PaymentCharge: () => (/* reexport */ PaymentCharge),
|
|
73
76
|
PaymentGateway: () => (/* reexport */ PaymentGateway),
|
|
77
|
+
PaymentItem: () => (/* reexport */ PaymentItem),
|
|
74
78
|
PaymentResult: () => (/* reexport */ PaymentResult),
|
|
75
79
|
Price: () => (/* reexport */ Price),
|
|
76
80
|
PriceStrategy: () => (/* reexport */ PriceStrategy),
|
|
77
81
|
Product: () => (/* reexport */ Product),
|
|
82
|
+
Receipt: () => (/* reexport */ Receipt),
|
|
83
|
+
ReceiptLine: () => (/* reexport */ ReceiptLine),
|
|
78
84
|
Status: () => (/* reexport */ Status),
|
|
79
85
|
StatusQStore: () => (/* reexport */ StatusQStore),
|
|
86
|
+
StatusQStoreInvoice: () => (/* reexport */ StatusQStoreInvoice),
|
|
80
87
|
StatusQStoreOrderLine: () => (/* reexport */ StatusQStoreOrderLine),
|
|
81
88
|
StoreItem: () => (/* reexport */ StoreItem),
|
|
82
89
|
Transaction: () => (/* reexport */ Transaction),
|
|
@@ -109,6 +116,8 @@ var models_namespaceObject = {};
|
|
|
109
116
|
__webpack_require__.r(models_namespaceObject);
|
|
110
117
|
__webpack_require__.d(models_namespaceObject, {
|
|
111
118
|
Amount: () => (Amount),
|
|
119
|
+
BillingAccount: () => (BillingAccount),
|
|
120
|
+
BillingProject: () => (BillingProject),
|
|
112
121
|
Cart: () => (Cart),
|
|
113
122
|
CartItem: () => (CartItem),
|
|
114
123
|
Category: () => (Category),
|
|
@@ -124,13 +133,18 @@ __webpack_require__.d(models_namespaceObject, {
|
|
|
124
133
|
Merchandise: () => (Merchandise),
|
|
125
134
|
Order: () => (Order),
|
|
126
135
|
OrderLine: () => (OrderLine),
|
|
136
|
+
PaymentCharge: () => (PaymentCharge),
|
|
127
137
|
PaymentGateway: () => (PaymentGateway),
|
|
138
|
+
PaymentItem: () => (PaymentItem),
|
|
128
139
|
PaymentResult: () => (PaymentResult),
|
|
129
140
|
Price: () => (Price),
|
|
130
141
|
PriceStrategy: () => (PriceStrategy),
|
|
131
142
|
Product: () => (Product),
|
|
143
|
+
Receipt: () => (Receipt),
|
|
144
|
+
ReceiptLine: () => (ReceiptLine),
|
|
132
145
|
Status: () => (Status),
|
|
133
146
|
StatusQStore: () => (StatusQStore),
|
|
147
|
+
StatusQStoreInvoice: () => (StatusQStoreInvoice),
|
|
134
148
|
StatusQStoreOrderLine: () => (StatusQStoreOrderLine),
|
|
135
149
|
StoreItem: () => (StoreItem),
|
|
136
150
|
Transaction: () => (Transaction),
|
|
@@ -185,7 +199,7 @@ class Amount {
|
|
|
185
199
|
|
|
186
200
|
// getters
|
|
187
201
|
get isValid() {
|
|
188
|
-
return typeof this.currencyCode === 'string' && !!this.currencyCode && typeof this.value === 'number'
|
|
202
|
+
return typeof this.currencyCode === 'string' && !!this.currencyCode && typeof this.value === 'number'
|
|
189
203
|
}
|
|
190
204
|
|
|
191
205
|
// instance methods
|
|
@@ -215,14 +229,150 @@ class Amount {
|
|
|
215
229
|
|
|
216
230
|
|
|
217
231
|
|
|
218
|
-
|
|
219
232
|
;// external "@questwork/q-utilities"
|
|
220
233
|
const q_utilities_namespaceObject = require("@questwork/q-utilities");
|
|
234
|
+
;// ./lib/models/billingAccount/billingAccount.js
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
const updateAllowedProps = [
|
|
238
|
+
'name',
|
|
239
|
+
]
|
|
240
|
+
|
|
241
|
+
class BillingAccount extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
242
|
+
constructor(options) {
|
|
243
|
+
options = options || {}
|
|
244
|
+
super(options)
|
|
245
|
+
|
|
246
|
+
const id = options._id || options.id
|
|
247
|
+
this.id = setId(id)
|
|
248
|
+
this._type = options._type || 'BillingAccount'
|
|
249
|
+
this.billingAccountCode = options.billingAccountCode
|
|
250
|
+
this.name = options.name
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
static dummyData() {
|
|
254
|
+
return {
|
|
255
|
+
tenantCode: 'tenantCode'
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
static get _classname() {
|
|
260
|
+
return 'BillingAccount'
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
static get _superclass() {
|
|
264
|
+
return 'BillingAccount'
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// get isValid() {
|
|
268
|
+
// return super.isValid
|
|
269
|
+
// }
|
|
270
|
+
|
|
271
|
+
update(obj) {
|
|
272
|
+
Object.keys(obj).forEach((key) => {
|
|
273
|
+
if (updateAllowedProps.includes(key)) {
|
|
274
|
+
this[key] = obj[key]
|
|
275
|
+
}
|
|
276
|
+
})
|
|
277
|
+
return super.update(obj)
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
// function setCode(options, key) {
|
|
282
|
+
// const copyOptions = options || {}
|
|
283
|
+
// if (copyOptions[key]) {
|
|
284
|
+
// return copyOptions[key]
|
|
285
|
+
// }
|
|
286
|
+
// return stringHelper.setCode()
|
|
287
|
+
// }
|
|
288
|
+
|
|
289
|
+
function setId(id) {
|
|
290
|
+
if (id && typeof id.toString === 'function') {
|
|
291
|
+
return id.toString()
|
|
292
|
+
}
|
|
293
|
+
return id
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
;// ./lib/models/billingAccount/index.js
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
;// ./lib/models/billingProject/billingProject.js
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
const billingProject_updateAllowedProps = [
|
|
307
|
+
'name',
|
|
308
|
+
]
|
|
309
|
+
|
|
310
|
+
class BillingProject extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
311
|
+
constructor(options) {
|
|
312
|
+
options = options || {}
|
|
313
|
+
super(options)
|
|
314
|
+
|
|
315
|
+
const id = options._id || options.id
|
|
316
|
+
this.id = billingProject_setId(id)
|
|
317
|
+
this._type = options._type || 'BillingProject'
|
|
318
|
+
this.billingProjectCode = options.billingProjectCode
|
|
319
|
+
this.name = options.name
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
static dummyData() {
|
|
323
|
+
return {
|
|
324
|
+
tenantCode: 'tenantCode'
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
static get _classname() {
|
|
329
|
+
return 'BillingProject'
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
static get _superclass() {
|
|
333
|
+
return 'BillingProject'
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
// get isValid() {
|
|
337
|
+
// return super.isValid
|
|
338
|
+
// }
|
|
339
|
+
|
|
340
|
+
update(obj) {
|
|
341
|
+
Object.keys(obj).forEach((key) => {
|
|
342
|
+
if (billingProject_updateAllowedProps.includes(key)) {
|
|
343
|
+
this[key] = obj[key]
|
|
344
|
+
}
|
|
345
|
+
})
|
|
346
|
+
return super.update(obj)
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
// function setCode(options, key) {
|
|
351
|
+
// const copyOptions = options || {}
|
|
352
|
+
// if (copyOptions[key]) {
|
|
353
|
+
// return copyOptions[key]
|
|
354
|
+
// }
|
|
355
|
+
// return stringHelper.setCode()
|
|
356
|
+
// }
|
|
357
|
+
|
|
358
|
+
function billingProject_setId(id) {
|
|
359
|
+
if (id && typeof id.toString === 'function') {
|
|
360
|
+
return id.toString()
|
|
361
|
+
}
|
|
362
|
+
return id
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
;// ./lib/models/billingProject/index.js
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
|
|
221
372
|
;// external "lodash"
|
|
222
373
|
const external_lodash_namespaceObject = require("lodash");
|
|
223
374
|
;// ./lib/models/itemOptionFillIn/itemOptionFillIn.js
|
|
224
|
-
|
|
225
|
-
const updateAllowedProps = [
|
|
375
|
+
const itemOptionFillIn_updateAllowedProps = [
|
|
226
376
|
'value'
|
|
227
377
|
]
|
|
228
378
|
|
|
@@ -291,7 +441,7 @@ class ItemOptionFillIn {
|
|
|
291
441
|
|
|
292
442
|
update(update) {
|
|
293
443
|
Object.keys(update).forEach((key) => {
|
|
294
|
-
if (
|
|
444
|
+
if (itemOptionFillIn_updateAllowedProps.includes(key)) {
|
|
295
445
|
this[key] = update[key]
|
|
296
446
|
}
|
|
297
447
|
})
|
|
@@ -430,7 +580,7 @@ function eleInArrayComparator(target, compare, prop) {
|
|
|
430
580
|
return false
|
|
431
581
|
}
|
|
432
582
|
if (!Array.isArray(target[prop]) && !Array.isArray(compare[prop])) {
|
|
433
|
-
throw new
|
|
583
|
+
throw new TypeError('This function can only compare array.')
|
|
434
584
|
}
|
|
435
585
|
return checkDuplicateHelper_lodash.intersection(target[prop], compare[prop]) > 0
|
|
436
586
|
}
|
|
@@ -440,7 +590,7 @@ function eleAllInArrayComparator(target, compare, prop) {
|
|
|
440
590
|
return false
|
|
441
591
|
}
|
|
442
592
|
if (!Array.isArray(target[prop]) && !Array.isArray(compare[prop])) {
|
|
443
|
-
throw new
|
|
593
|
+
throw new TypeError('This function can only compare array.')
|
|
444
594
|
}
|
|
445
595
|
return checkDuplicateHelper_lodash.intersection(target[prop], compare[prop]) === target[prop].length
|
|
446
596
|
}
|
|
@@ -450,11 +600,12 @@ function eleOrderInArrayComparator(target, compare, prop) {
|
|
|
450
600
|
return false
|
|
451
601
|
}
|
|
452
602
|
if (!Array.isArray(target[prop]) && !Array.isArray(compare[prop])) {
|
|
453
|
-
throw new
|
|
603
|
+
throw new TypeError('This function can only compare array.')
|
|
454
604
|
}
|
|
455
605
|
return target[prop].reduce((acc, item, index) => {
|
|
456
606
|
const res = item === compare[prop][index]
|
|
457
|
-
if (acc === null)
|
|
607
|
+
if (acc === null)
|
|
608
|
+
return res
|
|
458
609
|
return res && acc
|
|
459
610
|
}, null)
|
|
460
611
|
}
|
|
@@ -471,12 +622,14 @@ function objectInArrayComparator(target, compare, prop) {
|
|
|
471
622
|
return false
|
|
472
623
|
}
|
|
473
624
|
if (!Array.isArray(target[prop]) && !Array.isArray(compare[prop])) {
|
|
474
|
-
throw new
|
|
625
|
+
throw new TypeError('This function can only compare array.')
|
|
475
626
|
}
|
|
476
627
|
return target[prop].reduce((acc, item) => {
|
|
477
|
-
if (acc === true)
|
|
628
|
+
if (acc === true)
|
|
629
|
+
return acc
|
|
478
630
|
const res = item.isSameIn(compare[prop])
|
|
479
|
-
if (acc === null)
|
|
631
|
+
if (acc === null)
|
|
632
|
+
return res
|
|
480
633
|
return res || acc
|
|
481
634
|
}, null)
|
|
482
635
|
}
|
|
@@ -486,11 +639,12 @@ function objectAllInArrayComparator(target, compare, prop) {
|
|
|
486
639
|
return false
|
|
487
640
|
}
|
|
488
641
|
if (!Array.isArray(target[prop]) && !Array.isArray(compare[prop])) {
|
|
489
|
-
throw new
|
|
642
|
+
throw new TypeError('This function can only compare array.')
|
|
490
643
|
}
|
|
491
644
|
return target[prop].reduce((acc, item) => {
|
|
492
645
|
const res = item.isSameIn(compare[prop])
|
|
493
|
-
if (acc === null)
|
|
646
|
+
if (acc === null)
|
|
647
|
+
return res
|
|
494
648
|
return res && acc
|
|
495
649
|
}, null)
|
|
496
650
|
}
|
|
@@ -500,14 +654,15 @@ function objectOrderInArrayComparator(target, compare, prop) {
|
|
|
500
654
|
return false
|
|
501
655
|
}
|
|
502
656
|
if (!Array.isArray(target[prop]) && !Array.isArray(compare[prop])) {
|
|
503
|
-
throw new
|
|
657
|
+
throw new TypeError('This function can only compare array.')
|
|
504
658
|
}
|
|
505
659
|
if (target[prop].length !== compare[prop].length) {
|
|
506
660
|
return false
|
|
507
661
|
}
|
|
508
662
|
return target[prop].reduce((acc, item, index) => {
|
|
509
663
|
const res = item.isSame(compare[prop][index])
|
|
510
|
-
if (acc === null)
|
|
664
|
+
if (acc === null)
|
|
665
|
+
return res
|
|
511
666
|
return res && acc
|
|
512
667
|
}, null)
|
|
513
668
|
}
|
|
@@ -525,7 +680,6 @@ function _getBoolean(value1, value2, operation) {
|
|
|
525
680
|
|
|
526
681
|
|
|
527
682
|
;// ./lib/helpers/utilHelper/responseHelper.js
|
|
528
|
-
|
|
529
683
|
const LATEST_RESPONSE_OBJ_VERSION = '20200130'
|
|
530
684
|
|
|
531
685
|
const STANDARD_RESPONSE_OBJ_ARRAY = [
|
|
@@ -574,7 +728,8 @@ class ResponseHelper {
|
|
|
574
728
|
// private functions
|
|
575
729
|
|
|
576
730
|
function getStandardResponseObjByVersion(ver = LATEST_RESPONSE_OBJ_VERSION) {
|
|
577
|
-
if (!ver)
|
|
731
|
+
if (!ver)
|
|
732
|
+
return null
|
|
578
733
|
return STANDARD_RESPONSE_OBJ_ARRAY.find((obj) => (obj.version === ver))
|
|
579
734
|
}
|
|
580
735
|
|
|
@@ -582,18 +737,18 @@ function getStandardResponseObjByVersion(ver = LATEST_RESPONSE_OBJ_VERSION) {
|
|
|
582
737
|
|
|
583
738
|
function makeResponseHelper(options) {
|
|
584
739
|
const helper = new ResponseHelper(options)
|
|
585
|
-
if (!helper.isValid)
|
|
740
|
+
if (!helper.isValid)
|
|
741
|
+
throw new TypeError('Invalid options for responseHelper')
|
|
586
742
|
return helper
|
|
587
743
|
}
|
|
588
744
|
|
|
589
745
|
|
|
590
746
|
|
|
591
747
|
;// ./lib/helpers/utilHelper/setQuery.js
|
|
592
|
-
|
|
593
748
|
/**
|
|
594
749
|
* set up query with or without clientAppName
|
|
595
|
-
* @param {
|
|
596
|
-
* @returns {
|
|
750
|
+
* @param {object} ctx - koa context
|
|
751
|
+
* @returns {object} query
|
|
597
752
|
*/
|
|
598
753
|
function setQuery({ ctx, ids }) {
|
|
599
754
|
const { clientApp } = ctx.state
|
|
@@ -634,7 +789,6 @@ function setQuery({ ctx, ids }) {
|
|
|
634
789
|
|
|
635
790
|
|
|
636
791
|
|
|
637
|
-
|
|
638
792
|
;// ./lib/helpers/stringHelper/stringHelper.js
|
|
639
793
|
function baseXEncode(num, base = 34) {
|
|
640
794
|
const charset = getBaseCharset(base)
|
|
@@ -642,18 +796,18 @@ function baseXEncode(num, base = 34) {
|
|
|
642
796
|
}
|
|
643
797
|
|
|
644
798
|
function encode(int, charset) {
|
|
645
|
-
|
|
799
|
+
const byCode = charset.byCode
|
|
646
800
|
if (int === 0) {
|
|
647
|
-
|
|
801
|
+
return byCode[0]
|
|
648
802
|
}
|
|
649
803
|
|
|
650
|
-
|
|
651
|
-
|
|
804
|
+
let res = ''
|
|
805
|
+
const max = charset.length
|
|
652
806
|
while (int > 0) {
|
|
653
|
-
|
|
654
|
-
|
|
807
|
+
res = byCode[int % max] + res
|
|
808
|
+
int = Math.floor(int / max)
|
|
655
809
|
}
|
|
656
|
-
return res
|
|
810
|
+
return res
|
|
657
811
|
}
|
|
658
812
|
|
|
659
813
|
function getBaseCharset(base) {
|
|
@@ -665,16 +819,16 @@ function getBaseCharset(base) {
|
|
|
665
819
|
}
|
|
666
820
|
|
|
667
821
|
function indexCharset(str) {
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
822
|
+
const byCode = {}
|
|
823
|
+
const byChar = {}
|
|
824
|
+
const length = str.length
|
|
825
|
+
let i; let char
|
|
672
826
|
for (i = 0; i < length; i++) {
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
827
|
+
char = str[i]
|
|
828
|
+
byCode[i] = char
|
|
829
|
+
byChar[char] = i
|
|
676
830
|
}
|
|
677
|
-
return { byCode
|
|
831
|
+
return { byCode, byChar, length }
|
|
678
832
|
}
|
|
679
833
|
|
|
680
834
|
function randomString({ len = 16, pattern = 'a1' } = {}) {
|
|
@@ -696,7 +850,7 @@ function randomString({ len = 16, pattern = 'a1' } = {}) {
|
|
|
696
850
|
str += mark
|
|
697
851
|
}
|
|
698
852
|
const chars = [...str]
|
|
699
|
-
return [...Array(len)].map(i => {
|
|
853
|
+
return [...new Array(len)].map((i) => {
|
|
700
854
|
return chars[(Math.random() * chars.length) | 0]
|
|
701
855
|
}).join``
|
|
702
856
|
}
|
|
@@ -731,7 +885,6 @@ const stringHelper = {
|
|
|
731
885
|
|
|
732
886
|
|
|
733
887
|
|
|
734
|
-
|
|
735
888
|
;// ./lib/models/itemOption/itemOptionLocale.js
|
|
736
889
|
const itemOptionLocale_updateAllowedProps = [
|
|
737
890
|
'label',
|
|
@@ -1013,7 +1166,6 @@ class MerchandiseOption {
|
|
|
1013
1166
|
|
|
1014
1167
|
|
|
1015
1168
|
;// ./lib/models/qtyPerTransaction/qtyPerTransaction.js
|
|
1016
|
-
|
|
1017
1169
|
const qtyPerTransaction_updateAllowedProps = [
|
|
1018
1170
|
'min',
|
|
1019
1171
|
'max',
|
|
@@ -1071,7 +1223,6 @@ class QtyPerTransaction {
|
|
|
1071
1223
|
|
|
1072
1224
|
|
|
1073
1225
|
|
|
1074
|
-
|
|
1075
1226
|
const priceStrategy_updateAllowedProps = [
|
|
1076
1227
|
'active',
|
|
1077
1228
|
'amounts',
|
|
@@ -1291,7 +1442,7 @@ function matchAnd(key, value, payload) {
|
|
|
1291
1442
|
/**
|
|
1292
1443
|
* Check if a value matches a formula.
|
|
1293
1444
|
* @param {*} val - The value to check.
|
|
1294
|
-
* @param {
|
|
1445
|
+
* @param {object} [formula] - The formula object to check the value against.
|
|
1295
1446
|
* @returns {boolean} - Whether the value matches the formula.
|
|
1296
1447
|
*/
|
|
1297
1448
|
function _matcher(val, formula = {}, actions = [], match = true) {
|
|
@@ -1333,7 +1484,7 @@ function _match({ action, formulaValue, val }) {
|
|
|
1333
1484
|
}
|
|
1334
1485
|
return false
|
|
1335
1486
|
case '$includes':
|
|
1336
|
-
return val.includes(formulaValue)
|
|
1487
|
+
return val && val.includes(formulaValue)
|
|
1337
1488
|
case '$keyValue':
|
|
1338
1489
|
if (Array.isArray(val)) {
|
|
1339
1490
|
return (val.find((remark) => {
|
|
@@ -1442,8 +1593,6 @@ class Price {
|
|
|
1442
1593
|
// return prices.filter((price) => price.roleCodes.length === 0 || lodash.intersection(roleCodes, price.roleCodes).length > 0)
|
|
1443
1594
|
// }
|
|
1444
1595
|
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
1596
|
// getters
|
|
1448
1597
|
get isValid() {
|
|
1449
1598
|
return this.priceStrategies.length > 0
|
|
@@ -1585,7 +1734,7 @@ class Product extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
1585
1734
|
this._ItemOption = _ItemOption && (_ItemOption._superclass === ItemOption) ? _ItemOption : ItemOption
|
|
1586
1735
|
|
|
1587
1736
|
const id = options._id || options.id
|
|
1588
|
-
this.id =
|
|
1737
|
+
this.id = product_setId(id)
|
|
1589
1738
|
this._type = options._type || 'Product'
|
|
1590
1739
|
|
|
1591
1740
|
this.couponDetails = options.couponDetails
|
|
@@ -1682,6 +1831,16 @@ class Product extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
1682
1831
|
getCode() {
|
|
1683
1832
|
return this.productCode
|
|
1684
1833
|
}
|
|
1834
|
+
getPreservedData() {
|
|
1835
|
+
return {
|
|
1836
|
+
metadata: this.metadata,
|
|
1837
|
+
name: this.name,
|
|
1838
|
+
productCode: this.productCode,
|
|
1839
|
+
productGroupName: this.productGroupName,
|
|
1840
|
+
productType: this.productType,
|
|
1841
|
+
tenantCode: this.tenantCode,
|
|
1842
|
+
}
|
|
1843
|
+
}
|
|
1685
1844
|
getMetadataValueByKey(key) {
|
|
1686
1845
|
return q_utilities_namespaceObject.Metadata.getValueByKey(this.metadata || [], key)
|
|
1687
1846
|
}
|
|
@@ -1727,7 +1886,7 @@ class Product extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
1727
1886
|
}
|
|
1728
1887
|
}
|
|
1729
1888
|
|
|
1730
|
-
function
|
|
1889
|
+
function product_setId(id) {
|
|
1731
1890
|
if (id && typeof id.toString === 'function') {
|
|
1732
1891
|
return id.toString()
|
|
1733
1892
|
}
|
|
@@ -1748,33 +1907,11 @@ function _getDataByKey(key, data) {
|
|
|
1748
1907
|
|
|
1749
1908
|
|
|
1750
1909
|
|
|
1751
|
-
;// ./lib/models/product/productRepo.js
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
class ProductRepo extends q_utilities_namespaceObject.Repo {
|
|
1756
|
-
constructor(options = {}) {
|
|
1757
|
-
options = options || {}
|
|
1758
|
-
super(options)
|
|
1759
|
-
const { _Product } = options._constructor || {}
|
|
1760
|
-
this._Product = _Product && (_Product._superclass === Product._superclass) ? _Product : Product
|
|
1761
|
-
}
|
|
1762
|
-
static get _classname() {
|
|
1763
|
-
return 'ProductRepo'
|
|
1764
|
-
}
|
|
1765
|
-
init(options) {
|
|
1766
|
-
return this._Product.init(options)
|
|
1767
|
-
}
|
|
1768
|
-
}
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
1910
|
;// ./lib/models/product/index.js
|
|
1773
1911
|
|
|
1774
1912
|
|
|
1775
1913
|
|
|
1776
1914
|
|
|
1777
|
-
|
|
1778
1915
|
;// ./lib/models/merchandise/merchandise.js
|
|
1779
1916
|
|
|
1780
1917
|
|
|
@@ -1989,13 +2126,13 @@ class Merchandise extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
1989
2126
|
const _currencyCode = currency || this.defaultCurrency
|
|
1990
2127
|
const price = this.getPriceByTimeAndRoleCodes(dateTimestamp, roleCodes)
|
|
1991
2128
|
if (!price) {
|
|
1992
|
-
obj.errorMessages.push(
|
|
2129
|
+
obj.errorMessages.push('Can\'t get available price for you.')
|
|
1993
2130
|
return obj
|
|
1994
2131
|
}
|
|
1995
2132
|
obj.price = price
|
|
1996
2133
|
const priceStrategies = price.getStrategiesByCurrencyAndQty(_currencyCode, qty)
|
|
1997
2134
|
if (priceStrategies.length === 0) {
|
|
1998
|
-
obj.errorMessages.push(
|
|
2135
|
+
obj.errorMessages.push('Can\'t get available strategies from price.')
|
|
1999
2136
|
return obj
|
|
2000
2137
|
}
|
|
2001
2138
|
const { convertedPriceStrategies, maxQty } = priceStrategies.reduce((acc, priceStrategy) => {
|
|
@@ -2093,7 +2230,7 @@ class Merchandise extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
2093
2230
|
getCode() {
|
|
2094
2231
|
return this.merchandiseCode
|
|
2095
2232
|
}
|
|
2096
|
-
getCurrentAmount({ currencyCode, payload, ignoreRestriction =
|
|
2233
|
+
getCurrentAmount({ currencyCode, payload, ignoreRestriction = false }) {
|
|
2097
2234
|
if (!this.currentPrice) {
|
|
2098
2235
|
return null
|
|
2099
2236
|
}
|
|
@@ -2147,6 +2284,16 @@ class Merchandise extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
2147
2284
|
}
|
|
2148
2285
|
return null
|
|
2149
2286
|
}
|
|
2287
|
+
getPreservedData() {
|
|
2288
|
+
return {
|
|
2289
|
+
merchandiseCode: this.merchandiseCode,
|
|
2290
|
+
merchandiseType: this.merchandiseType,
|
|
2291
|
+
metadata: this.metadata,
|
|
2292
|
+
name: this.name,
|
|
2293
|
+
productCodes: this.productCodes,
|
|
2294
|
+
tenantCode: this.tenantCode,
|
|
2295
|
+
}
|
|
2296
|
+
}
|
|
2150
2297
|
getPrices() {
|
|
2151
2298
|
return this.prices ? this.prices : []
|
|
2152
2299
|
}
|
|
@@ -2244,34 +2391,11 @@ function merchandise_setId(id) {
|
|
|
2244
2391
|
|
|
2245
2392
|
|
|
2246
2393
|
|
|
2247
|
-
;// ./lib/models/merchandise/merchandiseRepo.js
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
class MerchandiseRepo extends q_utilities_namespaceObject.Repo {
|
|
2252
|
-
constructor(options = {}) {
|
|
2253
|
-
options = options || {}
|
|
2254
|
-
super(options)
|
|
2255
|
-
const { _Merchandise } = options._constructor || {}
|
|
2256
|
-
this._Merchandise = _Merchandise && (_Merchandise._superclass === Merchandise._superclass) ? _Merchandise : Merchandise
|
|
2257
|
-
}
|
|
2258
|
-
static get _classname() {
|
|
2259
|
-
return 'MerchandiseRepo'
|
|
2260
|
-
}
|
|
2261
|
-
init(options) {
|
|
2262
|
-
return this._Merchandise.init(options)
|
|
2263
|
-
}
|
|
2264
|
-
}
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
2394
|
;// ./lib/models/merchandise/index.js
|
|
2269
2395
|
|
|
2270
2396
|
|
|
2271
2397
|
|
|
2272
2398
|
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
2399
|
;// ./lib/models/cartItem/cartItem.js
|
|
2276
2400
|
|
|
2277
2401
|
|
|
@@ -2428,9 +2552,9 @@ function mergeDuplicateCartItems(cartItems, array = []) {
|
|
|
2428
2552
|
const { itemOptionFillIns } = item
|
|
2429
2553
|
const arr = external_lodash_namespaceObject.intersectionWith(itemOptionFillIns, cartItem.itemOptionFillIns, (obj1, obj2) => {
|
|
2430
2554
|
return obj1.target === obj2.target
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2555
|
+
&& obj1.targetCode === obj2.targetCode
|
|
2556
|
+
&& obj1.key === obj2.key
|
|
2557
|
+
&& external_lodash_namespaceObject.intersection(obj1.value, obj2.value).length === obj1.value.length
|
|
2434
2558
|
})
|
|
2435
2559
|
if (arr.length === itemOptionFillIns.length) {
|
|
2436
2560
|
acc.matched = item
|
|
@@ -2464,9 +2588,7 @@ function cartItem_setCode(options, key) {
|
|
|
2464
2588
|
|
|
2465
2589
|
|
|
2466
2590
|
|
|
2467
|
-
|
|
2468
2591
|
;// ./lib/models/status/status.js
|
|
2469
|
-
|
|
2470
2592
|
const notUpdateAllowedProps = [
|
|
2471
2593
|
'created',
|
|
2472
2594
|
]
|
|
@@ -2631,7 +2753,8 @@ class Status {
|
|
|
2631
2753
|
return keys.reduce((acc, key) => {
|
|
2632
2754
|
if (this[key]) {
|
|
2633
2755
|
acc.push({
|
|
2634
|
-
key,
|
|
2756
|
+
key,
|
|
2757
|
+
value: this[key]
|
|
2635
2758
|
})
|
|
2636
2759
|
}
|
|
2637
2760
|
return acc
|
|
@@ -2807,7 +2930,7 @@ class Cart extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
2807
2930
|
|
|
2808
2931
|
this._merchandises = options._merchandises
|
|
2809
2932
|
this._type = options._type || 'Cart'
|
|
2810
|
-
|
|
2933
|
+
|
|
2811
2934
|
this.cartCode = cart_setCode(options, 'cartCode')
|
|
2812
2935
|
this.cartItems = this._CartItem.initOnlyValidFromArray(options.cartItems)
|
|
2813
2936
|
this.status = this._Status.init(options.status)
|
|
@@ -3071,35 +3194,11 @@ function cart_setId(id) {
|
|
|
3071
3194
|
|
|
3072
3195
|
|
|
3073
3196
|
|
|
3074
|
-
;// ./lib/models/cart/cartRepo.js
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
class CartRepo extends q_utilities_namespaceObject.Repo {
|
|
3079
|
-
constructor(options = {}) {
|
|
3080
|
-
options = options || {}
|
|
3081
|
-
super(options)
|
|
3082
|
-
const { _Cart } = options._constructor || {}
|
|
3083
|
-
this._Cart = _Cart && (_Cart._superclass === Cart._superclass)
|
|
3084
|
-
? _Cart
|
|
3085
|
-
: Cart
|
|
3086
|
-
}
|
|
3087
|
-
static get _classname() {
|
|
3088
|
-
return 'CartRepo'
|
|
3089
|
-
}
|
|
3090
|
-
init(options) {
|
|
3091
|
-
return this._Cart.init(options)
|
|
3092
|
-
}
|
|
3093
|
-
}
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
3197
|
;// ./lib/models/cart/index.js
|
|
3098
3198
|
|
|
3099
3199
|
|
|
3100
3200
|
|
|
3101
3201
|
|
|
3102
|
-
|
|
3103
3202
|
;// ./lib/models/category/category.js
|
|
3104
3203
|
|
|
3105
3204
|
|
|
@@ -3155,7 +3254,7 @@ class Category extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
3155
3254
|
|
|
3156
3255
|
// getters
|
|
3157
3256
|
get isValid() {
|
|
3158
|
-
return super.isValid && !!this.name && this.max > this.
|
|
3257
|
+
return super.isValid && !!this.name && this.max > this.min
|
|
3159
3258
|
}
|
|
3160
3259
|
get products() {
|
|
3161
3260
|
return this._Product.initOnlyValidFromArray(this._products)
|
|
@@ -3189,36 +3288,11 @@ function category_setId(id) {
|
|
|
3189
3288
|
|
|
3190
3289
|
|
|
3191
3290
|
|
|
3192
|
-
;// ./lib/models/category/categoryRepo.js
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
class CategoryRepo extends q_utilities_namespaceObject.Repo {
|
|
3197
|
-
constructor(options = {}) {
|
|
3198
|
-
options = options || {}
|
|
3199
|
-
super(options)
|
|
3200
|
-
const { _Category } = options._constructor || {}
|
|
3201
|
-
this._Category = _Category && (_Category._superclass === Category._superclass)
|
|
3202
|
-
? _Category
|
|
3203
|
-
: Category
|
|
3204
|
-
}
|
|
3205
|
-
static get _classname() {
|
|
3206
|
-
return 'CategoryRepo'
|
|
3207
|
-
}
|
|
3208
|
-
init(options) {
|
|
3209
|
-
return this._Category.init(options)
|
|
3210
|
-
}
|
|
3211
|
-
}
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
3291
|
;// ./lib/models/category/index.js
|
|
3216
3292
|
|
|
3217
3293
|
|
|
3218
3294
|
|
|
3219
3295
|
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
3296
|
;// ./lib/models/creditNoteLine/creditNoteLine.js
|
|
3223
3297
|
|
|
3224
3298
|
|
|
@@ -3272,7 +3346,6 @@ class CreditNoteLine extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
3272
3346
|
return 'CreditNoteLine'
|
|
3273
3347
|
}
|
|
3274
3348
|
|
|
3275
|
-
|
|
3276
3349
|
// getters
|
|
3277
3350
|
get isValid() {
|
|
3278
3351
|
return super.isValid && !!this.creditNoteCode
|
|
@@ -3320,35 +3393,11 @@ function creditNoteLine_setId(id) {
|
|
|
3320
3393
|
|
|
3321
3394
|
|
|
3322
3395
|
|
|
3323
|
-
;// ./lib/models/creditNoteLine/creditNoteLineRepo.js
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
class CreditNoteLineRepo extends q_utilities_namespaceObject.Repo {
|
|
3328
|
-
constructor(options = {}) {
|
|
3329
|
-
options = options || {}
|
|
3330
|
-
super(options)
|
|
3331
|
-
const { _CreditNoteLine } = options._constructor || {}
|
|
3332
|
-
this._CreditNoteLine = _CreditNoteLine && (_CreditNoteLine._superclass === CreditNoteLine._superclass)
|
|
3333
|
-
? _CreditNoteLine
|
|
3334
|
-
: CreditNoteLine
|
|
3335
|
-
}
|
|
3336
|
-
static get _classname() {
|
|
3337
|
-
return 'CreditNoteLineRepo'
|
|
3338
|
-
}
|
|
3339
|
-
init(options) {
|
|
3340
|
-
return this._CreditNoteLine.init(options)
|
|
3341
|
-
}
|
|
3342
|
-
}
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
3396
|
;// ./lib/models/creditNoteLine/index.js
|
|
3347
3397
|
|
|
3348
3398
|
|
|
3349
3399
|
|
|
3350
3400
|
|
|
3351
|
-
|
|
3352
3401
|
;// ./lib/models/creditNote/creditNote.js
|
|
3353
3402
|
|
|
3354
3403
|
|
|
@@ -3356,7 +3405,6 @@ class CreditNoteLineRepo extends q_utilities_namespaceObject.Repo {
|
|
|
3356
3405
|
|
|
3357
3406
|
|
|
3358
3407
|
|
|
3359
|
-
|
|
3360
3408
|
const creditNote_updateAllowedProps = [
|
|
3361
3409
|
'description',
|
|
3362
3410
|
'status'
|
|
@@ -3506,7 +3554,6 @@ class CreditNoteRepo extends q_utilities_namespaceObject.Repo {
|
|
|
3506
3554
|
|
|
3507
3555
|
|
|
3508
3556
|
|
|
3509
|
-
|
|
3510
3557
|
const currency_updateAllowedProps = [
|
|
3511
3558
|
'description',
|
|
3512
3559
|
'name',
|
|
@@ -3585,36 +3632,11 @@ function currency_setId(id) {
|
|
|
3585
3632
|
|
|
3586
3633
|
|
|
3587
3634
|
|
|
3588
|
-
;// ./lib/models/currency/currencyRepo.js
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
class CurrencyRepo extends q_utilities_namespaceObject.Repo {
|
|
3593
|
-
constructor(options = {}) {
|
|
3594
|
-
options = options || {}
|
|
3595
|
-
super(options)
|
|
3596
|
-
const { _Currency } = options._constructor || {}
|
|
3597
|
-
this._Currency = _Currency && (_Currency._superclass === Currency._superclass)
|
|
3598
|
-
? _Currency
|
|
3599
|
-
: Currency
|
|
3600
|
-
}
|
|
3601
|
-
static get _classname() {
|
|
3602
|
-
return 'CurrencyRepo'
|
|
3603
|
-
}
|
|
3604
|
-
init(options) {
|
|
3605
|
-
return this._Currency.init(options)
|
|
3606
|
-
}
|
|
3607
|
-
}
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
|
|
3611
3635
|
;// ./lib/models/currency/index.js
|
|
3612
3636
|
|
|
3613
3637
|
|
|
3614
3638
|
|
|
3615
3639
|
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
3640
|
;// ./lib/helpers/getPurchaseOptionValue/getPurchaseOptionValue.js
|
|
3619
3641
|
function getPurchaseOptionValue(options) {
|
|
3620
3642
|
const {
|
|
@@ -3626,7 +3648,9 @@ function getPurchaseOptionValue(options) {
|
|
|
3626
3648
|
if (!key) {
|
|
3627
3649
|
return purchaseOptions.reduce((acc, purchaseOption) => {
|
|
3628
3650
|
const arr = _getOnePurchaseOptionValue({
|
|
3629
|
-
delimiter,
|
|
3651
|
+
delimiter,
|
|
3652
|
+
purchaseOption,
|
|
3653
|
+
tag
|
|
3630
3654
|
})
|
|
3631
3655
|
if (tag) {
|
|
3632
3656
|
acc.push(`<${tag}>${arr.join('')}</${tag}>`)
|
|
@@ -3643,7 +3667,9 @@ function getPurchaseOptionValue(options) {
|
|
|
3643
3667
|
return []
|
|
3644
3668
|
}
|
|
3645
3669
|
return _getOnePurchaseOptionValue({
|
|
3646
|
-
delimiter,
|
|
3670
|
+
delimiter,
|
|
3671
|
+
purchaseOption,
|
|
3672
|
+
tag
|
|
3647
3673
|
})
|
|
3648
3674
|
}
|
|
3649
3675
|
|
|
@@ -3683,6 +3709,784 @@ function _getOnePurchaseOptionValue({
|
|
|
3683
3709
|
|
|
3684
3710
|
|
|
3685
3711
|
|
|
3712
|
+
;// ./lib/models/paymentGateway/paymentGateway.js
|
|
3713
|
+
|
|
3714
|
+
|
|
3715
|
+
|
|
3716
|
+
|
|
3717
|
+
const paymentGateway_updateAllowedProps = [
|
|
3718
|
+
'label',
|
|
3719
|
+
'logoUrl',
|
|
3720
|
+
'name',
|
|
3721
|
+
'sandbox',
|
|
3722
|
+
'setting',
|
|
3723
|
+
'surchargeBillingAccountCode',
|
|
3724
|
+
'surchargeBillingProjectCode',
|
|
3725
|
+
'surcharges'
|
|
3726
|
+
]
|
|
3727
|
+
|
|
3728
|
+
class PaymentGateway extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
3729
|
+
constructor(options = {}) {
|
|
3730
|
+
options = options || {}
|
|
3731
|
+
super(options) // a paymentGateway may also store 'ADDITIONALFIELDS' and 'RESTRICTIONS into metadata
|
|
3732
|
+
|
|
3733
|
+
const { _Price } = options._constructor || {}
|
|
3734
|
+
this._Price = _Price && (_Price._superclass === Price._superclass) ? _Price : Price
|
|
3735
|
+
|
|
3736
|
+
const id = options._id || options.id
|
|
3737
|
+
this.id = paymentGateway_setId(id)
|
|
3738
|
+
this._type = options._type || 'PaymentGateway'
|
|
3739
|
+
|
|
3740
|
+
this.hasWebhook = options.hasWebhook || false
|
|
3741
|
+
this.label = options.label
|
|
3742
|
+
this.logoUrl = options.logoUrl
|
|
3743
|
+
this.name = options.name || ''
|
|
3744
|
+
this.paymentGatewayCode = paymentGateway_setCode(options, 'paymentGatewayCode')
|
|
3745
|
+
this.paymentGatewayType = options.paymentGatewayType || 'PaymentGateway'
|
|
3746
|
+
this.paymentResultType = options.paymentResultType || 'PaymentResult'
|
|
3747
|
+
this.sandbox = options.sandbox || false
|
|
3748
|
+
this.setting = options.setting || null
|
|
3749
|
+
|
|
3750
|
+
this.surchargeBillingAccountCode = options.surchargeBillingAccountCode
|
|
3751
|
+
this.surchargeBillingProjectCode = options.surchargeBillingProjectCode
|
|
3752
|
+
this.surcharges = this._Price.initOnlyValidFromArray(options.surcharges)
|
|
3753
|
+
}
|
|
3754
|
+
static dummyData() {
|
|
3755
|
+
return {
|
|
3756
|
+
name: 'name',
|
|
3757
|
+
tenantCode: 'tenantCode'
|
|
3758
|
+
}
|
|
3759
|
+
}
|
|
3760
|
+
static get _classname() {
|
|
3761
|
+
return 'PaymentGateway'
|
|
3762
|
+
}
|
|
3763
|
+
static get _superclass() {
|
|
3764
|
+
return 'PaymentGateway'
|
|
3765
|
+
}
|
|
3766
|
+
|
|
3767
|
+
// getters
|
|
3768
|
+
get isValid() {
|
|
3769
|
+
return super.isValid && !!this.name
|
|
3770
|
+
}
|
|
3771
|
+
|
|
3772
|
+
// instance methods
|
|
3773
|
+
async createPayment() {
|
|
3774
|
+
throw new Error(`${this._classname} subclass should implement createPayment`)
|
|
3775
|
+
}
|
|
3776
|
+
async getAppPayParams() {
|
|
3777
|
+
throw new Error(`${this._classname} subclass should implement getAppPayParams`)
|
|
3778
|
+
}
|
|
3779
|
+
getCode() {
|
|
3780
|
+
return this.paymentGatewayCode
|
|
3781
|
+
}
|
|
3782
|
+
async updatePayment() {
|
|
3783
|
+
throw new Error(`${this._classname} subclass should implement updatePayment`)
|
|
3784
|
+
}
|
|
3785
|
+
async query() {
|
|
3786
|
+
throw new Error(`${this._classname} subclass should implement query`)
|
|
3787
|
+
}
|
|
3788
|
+
async submit() {
|
|
3789
|
+
throw new Error(`${this._classname} subclass should implement submit`)
|
|
3790
|
+
}
|
|
3791
|
+
|
|
3792
|
+
setCompletedRelatedStatus(status) {
|
|
3793
|
+
throw new Error(`${this.name} subclass should implement setCompletedRelatedStatus`)
|
|
3794
|
+
}
|
|
3795
|
+
update(update) {
|
|
3796
|
+
Object.keys(update).forEach((key) => {
|
|
3797
|
+
if (paymentGateway_updateAllowedProps.includes(key)) {
|
|
3798
|
+
if (key === 'surcharges') {
|
|
3799
|
+
this[key] = this._Price.initOnlyValidFromArray(update[key])
|
|
3800
|
+
} else {
|
|
3801
|
+
this[key] = update[key]
|
|
3802
|
+
}
|
|
3803
|
+
}
|
|
3804
|
+
})
|
|
3805
|
+
return super.update(update)
|
|
3806
|
+
}
|
|
3807
|
+
}
|
|
3808
|
+
|
|
3809
|
+
function paymentGateway_setCode(options, key) {
|
|
3810
|
+
const copyOptions = options || {}
|
|
3811
|
+
if (copyOptions[key]) {
|
|
3812
|
+
return copyOptions[key]
|
|
3813
|
+
}
|
|
3814
|
+
return stringHelper.setCode()
|
|
3815
|
+
}
|
|
3816
|
+
|
|
3817
|
+
function paymentGateway_setId(id) {
|
|
3818
|
+
if (id && typeof id.toString === 'function') {
|
|
3819
|
+
return id.toString()
|
|
3820
|
+
}
|
|
3821
|
+
return id
|
|
3822
|
+
}
|
|
3823
|
+
|
|
3824
|
+
|
|
3825
|
+
|
|
3826
|
+
;// ./lib/models/paymentGateway/index.js
|
|
3827
|
+
|
|
3828
|
+
|
|
3829
|
+
|
|
3830
|
+
|
|
3831
|
+
;// ./lib/models/statusQStore/statusQStore.js
|
|
3832
|
+
|
|
3833
|
+
|
|
3834
|
+
const statusQStore_notUpdateAllowedProps = (/* unused pure expression or super */ null && ([
|
|
3835
|
+
]))
|
|
3836
|
+
|
|
3837
|
+
class StatusQStore extends q_utilities_namespaceObject.Status {
|
|
3838
|
+
constructor(options) {
|
|
3839
|
+
options = options || {}
|
|
3840
|
+
super(options)
|
|
3841
|
+
|
|
3842
|
+
this.cancelled = this._ActionRecord.init(options.cancelled)
|
|
3843
|
+
this.completed = this._ActionRecord.init(options.completed)
|
|
3844
|
+
this.confirmed = this._ActionRecord.init(options.confirmed)
|
|
3845
|
+
this.deleted = this._ActionRecord.init(options.deleted)
|
|
3846
|
+
this.terminated = this._ActionRecord.init(options.terminated)
|
|
3847
|
+
}
|
|
3848
|
+
|
|
3849
|
+
static get _classname() {
|
|
3850
|
+
return 'StatusQStore'
|
|
3851
|
+
}
|
|
3852
|
+
get _classname() {
|
|
3853
|
+
return 'StatusQStore'
|
|
3854
|
+
}
|
|
3855
|
+
get isCancelled() {
|
|
3856
|
+
return this.cancelled?.timestamp > 0
|
|
3857
|
+
}
|
|
3858
|
+
get isCompleted() {
|
|
3859
|
+
return this.completed?.timestamp > 0
|
|
3860
|
+
}
|
|
3861
|
+
get isConfirmed() {
|
|
3862
|
+
return this.confirmed?.timestamp > 0
|
|
3863
|
+
}
|
|
3864
|
+
get isDeleted() {
|
|
3865
|
+
return this.deleted?.timestamp > 0
|
|
3866
|
+
}
|
|
3867
|
+
get isTerminated() {
|
|
3868
|
+
return this.terminated?.timestamp > 0
|
|
3869
|
+
}
|
|
3870
|
+
get isValid() {
|
|
3871
|
+
return super.isValid
|
|
3872
|
+
}
|
|
3873
|
+
setCancelled(value, actorCode) {
|
|
3874
|
+
return this.setValue(value, actorCode, 'cancelled')
|
|
3875
|
+
}
|
|
3876
|
+
setCompleted(value, actorCode) {
|
|
3877
|
+
return this.setValue(value, actorCode, 'completed')
|
|
3878
|
+
}
|
|
3879
|
+
setConfirmed(value, actorCode) {
|
|
3880
|
+
return this.setValue(value, actorCode, 'confirmed')
|
|
3881
|
+
}
|
|
3882
|
+
setDeleted(value, actorCode) {
|
|
3883
|
+
return this.setValue(value, actorCode, 'deleted')
|
|
3884
|
+
}
|
|
3885
|
+
setTerminated(value, actorCode) {
|
|
3886
|
+
return this.setValue(value, actorCode, 'terminated')
|
|
3887
|
+
}
|
|
3888
|
+
// update(update) {
|
|
3889
|
+
// Object.keys(update).forEach((key) => {
|
|
3890
|
+
// if (!notUpdateAllowedProps.includes(key)) {
|
|
3891
|
+
// this[key] = this[key] instanceof this._ActionRecord ? this[key].update(update[key]) : this._ActionRecord.init(update[key])
|
|
3892
|
+
// }
|
|
3893
|
+
// })
|
|
3894
|
+
// return super.update(update)
|
|
3895
|
+
// }
|
|
3896
|
+
}
|
|
3897
|
+
|
|
3898
|
+
;// ./lib/models/statusQStore/statusQStoreInvoice.js
|
|
3899
|
+
|
|
3900
|
+
|
|
3901
|
+
// const notUpdateAllowedProps = [
|
|
3902
|
+
// ]
|
|
3903
|
+
|
|
3904
|
+
class StatusQStoreInvoice extends StatusQStore {
|
|
3905
|
+
constructor(options) {
|
|
3906
|
+
options = options || {}
|
|
3907
|
+
super(options)
|
|
3908
|
+
|
|
3909
|
+
this.closed = this._ActionRecord.init(options.closed)
|
|
3910
|
+
this.open = this._ActionRecord.init(options.open)
|
|
3911
|
+
}
|
|
3912
|
+
|
|
3913
|
+
static get _classname() {
|
|
3914
|
+
return 'StatusQStoreInvoice'
|
|
3915
|
+
}
|
|
3916
|
+
get _classname() {
|
|
3917
|
+
return 'StatusQStoreInvoice'
|
|
3918
|
+
}
|
|
3919
|
+
get isClosed() {
|
|
3920
|
+
return this.closed?.timestamp > Date.now()
|
|
3921
|
+
}
|
|
3922
|
+
get isOpen() {
|
|
3923
|
+
return this.open?.timestamp > Date.now()
|
|
3924
|
+
}
|
|
3925
|
+
get isValid() {
|
|
3926
|
+
return super.isValid
|
|
3927
|
+
}
|
|
3928
|
+
setClosed(value, actorCode) {
|
|
3929
|
+
return this.setValue(value, actorCode, 'closed')
|
|
3930
|
+
}
|
|
3931
|
+
setOpen(value, actorCode) {
|
|
3932
|
+
return this.setValue(value, actorCode, 'open')
|
|
3933
|
+
}
|
|
3934
|
+
}
|
|
3935
|
+
|
|
3936
|
+
;// ./lib/models/statusQStore/statusQStoreOrderLine.js
|
|
3937
|
+
|
|
3938
|
+
|
|
3939
|
+
const statusQStoreOrderLine_notUpdateAllowedProps = (/* unused pure expression or super */ null && ([
|
|
3940
|
+
]))
|
|
3941
|
+
|
|
3942
|
+
class StatusQStoreOrderLine extends StatusQStore {
|
|
3943
|
+
constructor(options) {
|
|
3944
|
+
options = options || {}
|
|
3945
|
+
super(options)
|
|
3946
|
+
|
|
3947
|
+
this.expired = this._ActionRecord.init(options.expired)
|
|
3948
|
+
this.invalid = this._ActionRecord.init(options.invalid)
|
|
3949
|
+
}
|
|
3950
|
+
|
|
3951
|
+
static get _classname() {
|
|
3952
|
+
return 'StatusQStoreOrderLine'
|
|
3953
|
+
}
|
|
3954
|
+
get _classname() {
|
|
3955
|
+
return 'StatusQStoreOrderLine'
|
|
3956
|
+
}
|
|
3957
|
+
get isExpired() {
|
|
3958
|
+
return this.expired?.timestamp > Date.now()
|
|
3959
|
+
}
|
|
3960
|
+
get isInvalid() {
|
|
3961
|
+
return this.invalid?.timestamp > Date.now()
|
|
3962
|
+
}
|
|
3963
|
+
get isValid() {
|
|
3964
|
+
return super.isValid
|
|
3965
|
+
}
|
|
3966
|
+
setExpired(value, actorCode) {
|
|
3967
|
+
return this.setValue(value, actorCode, 'expired')
|
|
3968
|
+
}
|
|
3969
|
+
setInvalid(value, actorCode) {
|
|
3970
|
+
return this.setValue(value, actorCode, 'invalid')
|
|
3971
|
+
}
|
|
3972
|
+
// update(update) {
|
|
3973
|
+
// Object.keys(update).forEach((key) => {
|
|
3974
|
+
// if (!notUpdateAllowedProps.includes(key)) {
|
|
3975
|
+
// this[key] = this[key] instanceof this._ActionRecord ? this[key].update(update[key]) : this._ActionRecord.init(update[key])
|
|
3976
|
+
// }
|
|
3977
|
+
// })
|
|
3978
|
+
// return super.update(update)
|
|
3979
|
+
// }
|
|
3980
|
+
}
|
|
3981
|
+
|
|
3982
|
+
;// ./lib/models/statusQStore/index.js
|
|
3983
|
+
|
|
3984
|
+
|
|
3985
|
+
|
|
3986
|
+
|
|
3987
|
+
|
|
3988
|
+
|
|
3989
|
+
;// ./lib/models/paymentCharge/paymentCharge.js
|
|
3990
|
+
|
|
3991
|
+
|
|
3992
|
+
|
|
3993
|
+
|
|
3994
|
+
|
|
3995
|
+
|
|
3996
|
+
const paymentCharge_updateAllowedProps = [
|
|
3997
|
+
'amount',
|
|
3998
|
+
]
|
|
3999
|
+
|
|
4000
|
+
class PaymentCharge extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
4001
|
+
constructor(options) {
|
|
4002
|
+
options = options || {}
|
|
4003
|
+
super(options)
|
|
4004
|
+
|
|
4005
|
+
const { _Amount, _PaymentGateway, _Receipt, _ReceiptLine } = options._constructor || {}
|
|
4006
|
+
this._Amount = _Amount && (_Amount._superclass === Amount._superclass) ? _Amount : Amount
|
|
4007
|
+
this._PaymentGateway = _PaymentGateway && (_PaymentGateway._superclass === PaymentGateway._superclass) ? _PaymentGateway : PaymentGateway
|
|
4008
|
+
this._Receipt = _Receipt && (_Receipt._superclass === Receipt._superclass) ? _Receipt : Receipt
|
|
4009
|
+
this._ReceiptLine = _ReceiptLine && (_ReceiptLine._superclass === ReceiptLine._superclass) ? _ReceiptLine : ReceiptLine
|
|
4010
|
+
|
|
4011
|
+
this._paymentGateway = options._paymentGateway
|
|
4012
|
+
this._receipt = options._receipt
|
|
4013
|
+
this._receiptLine = options._receiptLine
|
|
4014
|
+
|
|
4015
|
+
const id = options._id || options.id
|
|
4016
|
+
this.id = paymentCharge_setId(id)
|
|
4017
|
+
this._type = options._type || 'PaymentCharge'
|
|
4018
|
+
this.amount = this._Amount.init(options.amount)
|
|
4019
|
+
this.billingAccountCode = options.billingAccountCode
|
|
4020
|
+
this.billingProjectCode = options.billingProjectCode
|
|
4021
|
+
this.paymentGatewayCode = options.paymentGatewayCode
|
|
4022
|
+
this.paymentChargeCode = options.paymentChargeCode
|
|
4023
|
+
this.paymentChargeType = 'PaymentCharge'
|
|
4024
|
+
this.receiptCode = options.receiptCode
|
|
4025
|
+
this.receiptDate = options.receiptDate || (new Date()).valueOf()
|
|
4026
|
+
this.receiptLineCode = options.receiptLineCode
|
|
4027
|
+
// this.status = this._Status.init(options.status)
|
|
4028
|
+
}
|
|
4029
|
+
|
|
4030
|
+
static dummyData() {
|
|
4031
|
+
return {
|
|
4032
|
+
billingAccountCode: 'billingAccountCode',
|
|
4033
|
+
paymentGatewayCode: 'paymentGatewayCode',
|
|
4034
|
+
receiptCode: 'receiptCode',
|
|
4035
|
+
receiptLineCode: 'receiptLineCode',
|
|
4036
|
+
tenantCode: 'tenantCode'
|
|
4037
|
+
}
|
|
4038
|
+
}
|
|
4039
|
+
|
|
4040
|
+
static get _classname() {
|
|
4041
|
+
return 'PaymentCharge'
|
|
4042
|
+
}
|
|
4043
|
+
|
|
4044
|
+
static get _superclass() {
|
|
4045
|
+
return 'PaymentCharge'
|
|
4046
|
+
}
|
|
4047
|
+
|
|
4048
|
+
get isValid() {
|
|
4049
|
+
return super.isValid && !!this.billingAccountCode && !!this.paymentGatewayCode && !!this.receiptCode && !!this.receiptLineCode
|
|
4050
|
+
}
|
|
4051
|
+
|
|
4052
|
+
get paymentGateway() {
|
|
4053
|
+
return this._PaymentGateway.init(this._paymentGateway)
|
|
4054
|
+
}
|
|
4055
|
+
|
|
4056
|
+
get receipt() {
|
|
4057
|
+
return this._Receipt.init(this._receipt)
|
|
4058
|
+
}
|
|
4059
|
+
|
|
4060
|
+
get receiptLines() {
|
|
4061
|
+
return this._ReceiptLine.initOnlyValidFromArray(this._receiptLines || [])
|
|
4062
|
+
}
|
|
4063
|
+
|
|
4064
|
+
update(obj) {
|
|
4065
|
+
Object.keys(obj).forEach((key) => {
|
|
4066
|
+
if (paymentCharge_updateAllowedProps.includes(key)) {
|
|
4067
|
+
if (key === 'amount') {
|
|
4068
|
+
this[key] = this.amount instanceof this._Amount ? this.amount.update(obj[key]) : this._Amount.init(obj[key])
|
|
4069
|
+
} else {
|
|
4070
|
+
this[key] = obj[key]
|
|
4071
|
+
}
|
|
4072
|
+
}
|
|
4073
|
+
})
|
|
4074
|
+
return super.update(obj)
|
|
4075
|
+
}
|
|
4076
|
+
}
|
|
4077
|
+
|
|
4078
|
+
function paymentCharge_setId(id) {
|
|
4079
|
+
if (id && typeof id.toString === 'function') {
|
|
4080
|
+
return id.toString()
|
|
4081
|
+
}
|
|
4082
|
+
return id
|
|
4083
|
+
}
|
|
4084
|
+
|
|
4085
|
+
|
|
4086
|
+
|
|
4087
|
+
;// ./lib/models/paymentCharge/index.js
|
|
4088
|
+
|
|
4089
|
+
|
|
4090
|
+
|
|
4091
|
+
|
|
4092
|
+
;// ./lib/models/receiptLine/receiptLine.js
|
|
4093
|
+
|
|
4094
|
+
|
|
4095
|
+
|
|
4096
|
+
|
|
4097
|
+
|
|
4098
|
+
|
|
4099
|
+
|
|
4100
|
+
const receiptLine_updateAllowedProps = [
|
|
4101
|
+
'additionalData',
|
|
4102
|
+
'status',
|
|
4103
|
+
]
|
|
4104
|
+
|
|
4105
|
+
class ReceiptLine extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
4106
|
+
constructor(options) {
|
|
4107
|
+
options = options || {}
|
|
4108
|
+
super(options)
|
|
4109
|
+
|
|
4110
|
+
const { _Amount, _PaymentCharge, _PaymentItem, _Receipt, _Status } = options._constructor || {}
|
|
4111
|
+
this._Amount = _Amount && (_Amount._superclass === Amount._superclass) ? _Amount : Amount
|
|
4112
|
+
this._PaymentCharge = _PaymentCharge && (_PaymentCharge._superclass === PaymentCharge._superclass) ? _PaymentCharge : PaymentCharge
|
|
4113
|
+
this._PaymentItem = _PaymentItem && (_PaymentItem._superclass === PaymentItem._superclass) ? _PaymentItem : PaymentItem
|
|
4114
|
+
this._Receipt = _Receipt && (_Receipt._superclass === Receipt._superclass) ? _Receipt : Receipt
|
|
4115
|
+
this._Status = _Status && (_Status._superclass === StatusQStore._superclass) ? _Status : StatusQStore
|
|
4116
|
+
|
|
4117
|
+
this._paymentCharge = options._paymentCharge
|
|
4118
|
+
this._paymentItems = options._paymentItems
|
|
4119
|
+
this._receipt = options._receipt
|
|
4120
|
+
|
|
4121
|
+
const id = options._id || options.id
|
|
4122
|
+
this.id = receiptLine_setId(id)
|
|
4123
|
+
this._type = options._type || 'ReceiptLine'
|
|
4124
|
+
this.additionalData = q_utilities_namespaceObject.KeyValueObject.initOnlyValidFromArray(options.additionalData)
|
|
4125
|
+
this.amount = this._Amount.init(options.amount)
|
|
4126
|
+
this.paidAmount = this._Amount.init(options.paidAmount)
|
|
4127
|
+
this.paymentGatewayCode = options.paymentGatewayCode
|
|
4128
|
+
this.receiptCode = options.receiptCode
|
|
4129
|
+
this.receiptDate = options.receiptDate || (new Date()).valueOf()
|
|
4130
|
+
this.receiptLineCode = options.receiptLineCode
|
|
4131
|
+
this.receiptLineType = 'ReceiptLine'
|
|
4132
|
+
this.status = this._Status.init(options.status)
|
|
4133
|
+
this.surcharge = this._Amount.init(options.surcharge)
|
|
4134
|
+
}
|
|
4135
|
+
|
|
4136
|
+
static dummyData() {
|
|
4137
|
+
return {
|
|
4138
|
+
receiptCode: 'receiptCode',
|
|
4139
|
+
tenantCode: 'tenantCode'
|
|
4140
|
+
}
|
|
4141
|
+
}
|
|
4142
|
+
|
|
4143
|
+
static get _classname() {
|
|
4144
|
+
return 'ReceiptLine'
|
|
4145
|
+
}
|
|
4146
|
+
|
|
4147
|
+
static get _superclass() {
|
|
4148
|
+
return 'ReceiptLine'
|
|
4149
|
+
}
|
|
4150
|
+
|
|
4151
|
+
get isCancelled() {
|
|
4152
|
+
return this.status.isCancelled
|
|
4153
|
+
}
|
|
4154
|
+
|
|
4155
|
+
get isCompleted() {
|
|
4156
|
+
return this.status.isCompleted
|
|
4157
|
+
}
|
|
4158
|
+
|
|
4159
|
+
get isConfirmed() {
|
|
4160
|
+
return this.status.isConfirmed
|
|
4161
|
+
}
|
|
4162
|
+
|
|
4163
|
+
get isTerminated() {
|
|
4164
|
+
return this.status.isTerminated
|
|
4165
|
+
}
|
|
4166
|
+
|
|
4167
|
+
get isValid() {
|
|
4168
|
+
return super.isValid && !!this.receiptCode
|
|
4169
|
+
}
|
|
4170
|
+
|
|
4171
|
+
get paymentCharge() {
|
|
4172
|
+
return this._PaymentCharge.init(this._paymentCharge)
|
|
4173
|
+
}
|
|
4174
|
+
get paymentItems() {
|
|
4175
|
+
return this._PaymentItem.initOnlyValidFromArray(this._paymentItems)
|
|
4176
|
+
}
|
|
4177
|
+
get receipt() {
|
|
4178
|
+
return this._Receipt.init(this._receipt)
|
|
4179
|
+
}
|
|
4180
|
+
|
|
4181
|
+
getAmount() {
|
|
4182
|
+
return this.amount
|
|
4183
|
+
}
|
|
4184
|
+
|
|
4185
|
+
setCancelled(value, actorCode) {
|
|
4186
|
+
this.status.setCancelled(value, actorCode)
|
|
4187
|
+
return this.setModified()
|
|
4188
|
+
}
|
|
4189
|
+
|
|
4190
|
+
setCompleted(value, actorCode) {
|
|
4191
|
+
this.status.setCompleted(value, actorCode)
|
|
4192
|
+
return this.setModified()
|
|
4193
|
+
}
|
|
4194
|
+
setConfirmed(value, actorCode) {
|
|
4195
|
+
this.status.setProcessing(value, actorCode)
|
|
4196
|
+
return this.setModified()
|
|
4197
|
+
}
|
|
4198
|
+
|
|
4199
|
+
setTerminated(value, actorCode) {
|
|
4200
|
+
this.status.setTerminated(value, actorCode)
|
|
4201
|
+
return this.setModified()
|
|
4202
|
+
}
|
|
4203
|
+
|
|
4204
|
+
update(obj) {
|
|
4205
|
+
Object.keys(obj).forEach((key) => {
|
|
4206
|
+
if (receiptLine_updateAllowedProps.includes(key)) {
|
|
4207
|
+
if (key === 'additionalData') {
|
|
4208
|
+
this[key] = q_utilities_namespaceObject.KeyValueObject.initOnlyValidFromArray(obj[key])
|
|
4209
|
+
} else if (key === 'status') {
|
|
4210
|
+
this[key] = this[key] instanceof this._Status ? this[key].update(obj[key]) : this._Status.init(obj[key])
|
|
4211
|
+
} else {
|
|
4212
|
+
this[key] = obj[key]
|
|
4213
|
+
}
|
|
4214
|
+
}
|
|
4215
|
+
})
|
|
4216
|
+
return super.update(obj)
|
|
4217
|
+
}
|
|
4218
|
+
}
|
|
4219
|
+
|
|
4220
|
+
function receiptLine_setId(id) {
|
|
4221
|
+
if (id && typeof id.toString === 'function') {
|
|
4222
|
+
return id.toString()
|
|
4223
|
+
}
|
|
4224
|
+
return id
|
|
4225
|
+
}
|
|
4226
|
+
|
|
4227
|
+
|
|
4228
|
+
|
|
4229
|
+
;// ./lib/models/receiptLine/index.js
|
|
4230
|
+
|
|
4231
|
+
|
|
4232
|
+
|
|
4233
|
+
|
|
4234
|
+
;// ./lib/models/receipt/receipt.js
|
|
4235
|
+
|
|
4236
|
+
|
|
4237
|
+
|
|
4238
|
+
|
|
4239
|
+
|
|
4240
|
+
const receipt_updateAllowedProps = [
|
|
4241
|
+
'status',
|
|
4242
|
+
]
|
|
4243
|
+
|
|
4244
|
+
class Receipt extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
4245
|
+
constructor(options) {
|
|
4246
|
+
options = options || {}
|
|
4247
|
+
super(options)
|
|
4248
|
+
|
|
4249
|
+
const { _Amount, _ReceiptLine, _Status } = options._constructor || {}
|
|
4250
|
+
this._Amount = _Amount && (_Amount._superclass === Amount._superclass) ? _Amount : Amount
|
|
4251
|
+
this._ReceiptLine = _ReceiptLine && (_ReceiptLine._superclass === ReceiptLine._superclass) ? _ReceiptLine : ReceiptLine
|
|
4252
|
+
this._Status = _Status && (_Status._superclass === StatusQStore._superclass) ? _Status : StatusQStore
|
|
4253
|
+
|
|
4254
|
+
this._receiptLines = options._receiptLines
|
|
4255
|
+
|
|
4256
|
+
const id = options._id || options.id
|
|
4257
|
+
this.id = receipt_setId(id)
|
|
4258
|
+
this._type = options._type || 'Receipt'
|
|
4259
|
+
this.amount = this._Amount.init(options.amount)
|
|
4260
|
+
this.paidAmount = this._Amount.init(options.paidAmount)
|
|
4261
|
+
this.paymentGatewayCode = options.paymentGatewayCode
|
|
4262
|
+
this.receiptCode = options.receiptCode
|
|
4263
|
+
this.receiptDate = options.receiptDate || (new Date()).valueOf()
|
|
4264
|
+
this.receiptNumber = options.receiptNumber
|
|
4265
|
+
this.receiptType = 'Receipt'
|
|
4266
|
+
this.revisionNumber = options.revisionNumber || 1
|
|
4267
|
+
this.status = this._Status.init(options.status)
|
|
4268
|
+
this.surcharge = this._Amount.init(options.surcharge)
|
|
4269
|
+
}
|
|
4270
|
+
|
|
4271
|
+
static dummyData() {
|
|
4272
|
+
return {
|
|
4273
|
+
tenantCode: 'tenantCode'
|
|
4274
|
+
}
|
|
4275
|
+
}
|
|
4276
|
+
|
|
4277
|
+
static get _classname() {
|
|
4278
|
+
return 'Receipt'
|
|
4279
|
+
}
|
|
4280
|
+
|
|
4281
|
+
static get _superclass() {
|
|
4282
|
+
return 'Receipt'
|
|
4283
|
+
}
|
|
4284
|
+
|
|
4285
|
+
// get isValid() {
|
|
4286
|
+
// return super.isValid
|
|
4287
|
+
// }
|
|
4288
|
+
|
|
4289
|
+
get isCancelled() {
|
|
4290
|
+
return this.status.isCancelled
|
|
4291
|
+
}
|
|
4292
|
+
|
|
4293
|
+
get isCompleted() {
|
|
4294
|
+
return this.status.isCompleted
|
|
4295
|
+
}
|
|
4296
|
+
|
|
4297
|
+
get isConfirmed() {
|
|
4298
|
+
return this.status.isConfirmed
|
|
4299
|
+
}
|
|
4300
|
+
|
|
4301
|
+
get isTerminated() {
|
|
4302
|
+
return this.status.isTerminated
|
|
4303
|
+
}
|
|
4304
|
+
|
|
4305
|
+
get receiptLines() {
|
|
4306
|
+
return this._ReceiptLine.initOnlyValidFromArray(this._receiptLines || [])
|
|
4307
|
+
}
|
|
4308
|
+
|
|
4309
|
+
getAmount() {
|
|
4310
|
+
return this.amount
|
|
4311
|
+
}
|
|
4312
|
+
|
|
4313
|
+
getFullReceiptNumber(delimiter = '.') {
|
|
4314
|
+
return `${this.receiptNumber}${delimiter}${this.revisionNumber}`
|
|
4315
|
+
}
|
|
4316
|
+
|
|
4317
|
+
increaseRevisionNumber() {
|
|
4318
|
+
this.revisionNumber += 1
|
|
4319
|
+
return this
|
|
4320
|
+
}
|
|
4321
|
+
|
|
4322
|
+
setCancelled(value, actorCode) {
|
|
4323
|
+
this.status.setCancelled(value, actorCode)
|
|
4324
|
+
return this.setModified()
|
|
4325
|
+
}
|
|
4326
|
+
|
|
4327
|
+
setCompleted(value, actorCode) {
|
|
4328
|
+
this.status.setCompleted(value, actorCode)
|
|
4329
|
+
return this.setModified()
|
|
4330
|
+
}
|
|
4331
|
+
setConfirmed(value, actorCode) {
|
|
4332
|
+
this.status.setProcessing(value, actorCode)
|
|
4333
|
+
return this.setModified()
|
|
4334
|
+
}
|
|
4335
|
+
|
|
4336
|
+
setTerminated(value, actorCode) {
|
|
4337
|
+
this.status.setTerminated(value, actorCode)
|
|
4338
|
+
return this.setModified()
|
|
4339
|
+
}
|
|
4340
|
+
|
|
4341
|
+
update(obj) {
|
|
4342
|
+
Object.keys(obj).forEach((key) => {
|
|
4343
|
+
if (receipt_updateAllowedProps.includes(key)) {
|
|
4344
|
+
if (key === 'status') {
|
|
4345
|
+
this[key] = this.status instanceof this._Status ? this.status.update(obj[key]) : this._Status.init(obj[key])
|
|
4346
|
+
} else {
|
|
4347
|
+
this[key] = obj[key]
|
|
4348
|
+
}
|
|
4349
|
+
}
|
|
4350
|
+
})
|
|
4351
|
+
return super.update(obj)
|
|
4352
|
+
}
|
|
4353
|
+
}
|
|
4354
|
+
|
|
4355
|
+
function receipt_setId(id) {
|
|
4356
|
+
if (id && typeof id.toString === 'function') {
|
|
4357
|
+
return id.toString()
|
|
4358
|
+
}
|
|
4359
|
+
return id
|
|
4360
|
+
}
|
|
4361
|
+
|
|
4362
|
+
|
|
4363
|
+
|
|
4364
|
+
;// ./lib/models/receipt/index.js
|
|
4365
|
+
|
|
4366
|
+
|
|
4367
|
+
|
|
4368
|
+
|
|
4369
|
+
;// ./lib/models/paymentItem/paymentItem.js
|
|
4370
|
+
|
|
4371
|
+
|
|
4372
|
+
// import { StatusQStore } from '../statusQStore/index.js'
|
|
4373
|
+
|
|
4374
|
+
|
|
4375
|
+
|
|
4376
|
+
|
|
4377
|
+
|
|
4378
|
+
|
|
4379
|
+
const paymentItem_updateAllowedProps = [
|
|
4380
|
+
'amount',
|
|
4381
|
+
]
|
|
4382
|
+
|
|
4383
|
+
class PaymentItem extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
4384
|
+
constructor(options) {
|
|
4385
|
+
options = options || {}
|
|
4386
|
+
super(options)
|
|
4387
|
+
|
|
4388
|
+
const { _Amount, _Invoice, _InvoiceLine, _PaymentGateway, _Receipt, _ReceiptLine } = options._constructor || {}
|
|
4389
|
+
this._Amount = _Amount && (_Amount._superclass === Amount._superclass) ? _Amount : Amount
|
|
4390
|
+
this._Invoice = _Invoice && (_Invoice._superclass === Invoice._superclass) ? _Invoice : Invoice
|
|
4391
|
+
this._InvoiceLine = _InvoiceLine && (_InvoiceLine._superclass === InvoiceLine._superclass) ? _InvoiceLine : InvoiceLine
|
|
4392
|
+
this._PaymentGateway = _PaymentGateway && (_PaymentGateway._superclass === PaymentGateway._superclass) ? _PaymentGateway : PaymentGateway
|
|
4393
|
+
this._Receipt = _Receipt && (_Receipt._superclass === Receipt._superclass) ? _Receipt : Receipt
|
|
4394
|
+
this._ReceiptLine = _ReceiptLine && (_ReceiptLine._superclass === ReceiptLine._superclass) ? _ReceiptLine : ReceiptLine
|
|
4395
|
+
// this._Status = _Status && (_Status._superclass === StatusQStore._superclass) ? _Status : StatusQStore
|
|
4396
|
+
|
|
4397
|
+
this._invoice = options._invoice
|
|
4398
|
+
this._invoiceLines = options._invoiceLines
|
|
4399
|
+
this._paymentGateway = options._paymentGateway
|
|
4400
|
+
this._receipt = options._receipt
|
|
4401
|
+
this._receiptLine = options._receiptLine
|
|
4402
|
+
|
|
4403
|
+
const id = options._id || options.id
|
|
4404
|
+
this.id = paymentItem_setId(id)
|
|
4405
|
+
this._type = options._type || 'PaymentItem'
|
|
4406
|
+
this.amount = this._Amount.init(options.amount)
|
|
4407
|
+
this.invoiceCode = options.invoiceCode
|
|
4408
|
+
this.invoiceDate = options.invoiceDate || (new Date()).valueOf()
|
|
4409
|
+
this.invoiceLineCode = options.invoiceLineCode
|
|
4410
|
+
this.paymentGatewayCode = options.paymentGatewayCode
|
|
4411
|
+
this.paymentItemCode = options.paymentItemCode
|
|
4412
|
+
this.paymentItemType = 'PaymentItem'
|
|
4413
|
+
this.receiptCode = options.receiptCode
|
|
4414
|
+
this.receiptDate = options.receiptDate || (new Date()).valueOf()
|
|
4415
|
+
this.receiptLineCode = options.receiptLineCode
|
|
4416
|
+
// this.status = this._Status.init(options.status)
|
|
4417
|
+
}
|
|
4418
|
+
|
|
4419
|
+
static dummyData() {
|
|
4420
|
+
return {
|
|
4421
|
+
invoiceCode: 'invoiceCode',
|
|
4422
|
+
invoiceLineCode: 'invoiceLineCode',
|
|
4423
|
+
paymentGatewayCode: 'paymentGatewayCode',
|
|
4424
|
+
receiptCode: 'receiptCode',
|
|
4425
|
+
receiptLineCode: 'receiptLineCode',
|
|
4426
|
+
tenantCode: 'tenantCode'
|
|
4427
|
+
}
|
|
4428
|
+
}
|
|
4429
|
+
|
|
4430
|
+
static get _classname() {
|
|
4431
|
+
return 'PaymentItem'
|
|
4432
|
+
}
|
|
4433
|
+
|
|
4434
|
+
static get _superclass() {
|
|
4435
|
+
return 'PaymentItem'
|
|
4436
|
+
}
|
|
4437
|
+
|
|
4438
|
+
get invoice() {
|
|
4439
|
+
return this._Invoice.init(this._invoice)
|
|
4440
|
+
}
|
|
4441
|
+
|
|
4442
|
+
get invoiceLines() {
|
|
4443
|
+
return this._InvoiceLine.initOnlyValidFromArray(this._invoiceLines || [])
|
|
4444
|
+
}
|
|
4445
|
+
|
|
4446
|
+
get isValid() {
|
|
4447
|
+
return super.isValid && !!this.invoiceCode && !!this.invoiceLineCode && !!this.paymentGatewayCode && !!this.receiptCode && !!this.receiptLineCode
|
|
4448
|
+
}
|
|
4449
|
+
|
|
4450
|
+
get paymentGateway() {
|
|
4451
|
+
return this._PaymentGateway.init(this._paymentGateway)
|
|
4452
|
+
}
|
|
4453
|
+
|
|
4454
|
+
get receipt() {
|
|
4455
|
+
return this._Receipt.init(this._receipt)
|
|
4456
|
+
}
|
|
4457
|
+
|
|
4458
|
+
get receiptLines() {
|
|
4459
|
+
return this._ReceiptLine.initOnlyValidFromArray(this._receiptLines || [])
|
|
4460
|
+
}
|
|
4461
|
+
|
|
4462
|
+
update(obj) {
|
|
4463
|
+
Object.keys(obj).forEach((key) => {
|
|
4464
|
+
if (paymentItem_updateAllowedProps.includes(key)) {
|
|
4465
|
+
if (key === 'amount') {
|
|
4466
|
+
this[key] = this.amount instanceof this._Amount ? this.amount.update(obj[key]) : this._Amount.init(obj[key])
|
|
4467
|
+
} else {
|
|
4468
|
+
this[key] = obj[key]
|
|
4469
|
+
}
|
|
4470
|
+
}
|
|
4471
|
+
})
|
|
4472
|
+
return super.update(obj)
|
|
4473
|
+
}
|
|
4474
|
+
}
|
|
4475
|
+
|
|
4476
|
+
function paymentItem_setId(id) {
|
|
4477
|
+
if (id && typeof id.toString === 'function') {
|
|
4478
|
+
return id.toString()
|
|
4479
|
+
}
|
|
4480
|
+
return id
|
|
4481
|
+
}
|
|
4482
|
+
|
|
4483
|
+
|
|
4484
|
+
|
|
4485
|
+
;// ./lib/models/paymentItem/index.js
|
|
4486
|
+
|
|
4487
|
+
|
|
4488
|
+
|
|
4489
|
+
|
|
3686
4490
|
;// ./lib/models/invoiceLine/invoiceLine.js
|
|
3687
4491
|
|
|
3688
4492
|
|
|
@@ -3692,12 +4496,15 @@ function _getOnePurchaseOptionValue({
|
|
|
3692
4496
|
|
|
3693
4497
|
|
|
3694
4498
|
|
|
4499
|
+
|
|
3695
4500
|
const invoiceLine_updateAllowedProps = [
|
|
3696
4501
|
'amount',
|
|
3697
4502
|
'deduction',
|
|
3698
4503
|
'description',
|
|
3699
4504
|
'discount',
|
|
4505
|
+
'invoiceDate',
|
|
3700
4506
|
'note',
|
|
4507
|
+
'outstanding',
|
|
3701
4508
|
'purchaseOptions',
|
|
3702
4509
|
'qty',
|
|
3703
4510
|
'unitPrice'
|
|
@@ -3708,14 +4515,16 @@ class InvoiceLine extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
3708
4515
|
options = options || {}
|
|
3709
4516
|
super(options)
|
|
3710
4517
|
|
|
3711
|
-
const { _Amount, _Invoice, _Merchandise, _Status } = options._constructor || {}
|
|
4518
|
+
const { _Amount, _Invoice, _Merchandise, _PaymentItem, _Status } = options._constructor || {}
|
|
3712
4519
|
this._Amount = _Amount && (_Amount._superclass === Amount._superclass) ? _Amount : Amount
|
|
3713
4520
|
this._Invoice = _Invoice && (_Invoice._superclass === Invoice._superclass) ? _Invoice : Invoice
|
|
3714
4521
|
this._Merchandise = _Merchandise && (_Merchandise._superclass === Merchandise._superclass) ? _Merchandise : Merchandise
|
|
4522
|
+
this._PaymentItem = _PaymentItem && (_PaymentItem._superclass === PaymentItem._superclass) ? _PaymentItem : PaymentItem
|
|
3715
4523
|
this._Status = _Status && (_Status._superclass === Status._superclass) ? _Status : Status
|
|
3716
4524
|
|
|
3717
4525
|
this._invoice = options._invoice
|
|
3718
4526
|
this._merchandise = options._merchandise
|
|
4527
|
+
this._paymentItems = options._paymentItems
|
|
3719
4528
|
|
|
3720
4529
|
const id = options._id || options.id
|
|
3721
4530
|
this.id = invoiceLine_setId(id)
|
|
@@ -3725,10 +4534,12 @@ class InvoiceLine extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
3725
4534
|
this.description = options.description
|
|
3726
4535
|
this.discount = options.discount || 0
|
|
3727
4536
|
this.invoiceCode = options.invoiceCode
|
|
4537
|
+
this.invoiceDate = options.invoiceDate || (new Date()).valueOf()
|
|
3728
4538
|
this.invoiceLineCode = invoiceLine_setCode(options, 'invoiceLineCode')
|
|
3729
4539
|
this.invoiceLineType = options.invoiceLineType || 'InvoiceLine'
|
|
3730
4540
|
this.merchandiseCode = options.merchandiseCode
|
|
3731
4541
|
this.note = options.note
|
|
4542
|
+
this.outstanding = this._Amount.init(options.outstanding)
|
|
3732
4543
|
this.purchaseOptions = q_utilities_namespaceObject.KeyValueObject.initOnlyValidFromArray(options.purchaseOptions)
|
|
3733
4544
|
this.qty = options.qty || 1
|
|
3734
4545
|
this.status = this._Status.init(options.status)
|
|
@@ -3761,7 +4572,9 @@ class InvoiceLine extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
3761
4572
|
get merchandise() {
|
|
3762
4573
|
return this._Merchandise.init(this._merchandise)
|
|
3763
4574
|
}
|
|
3764
|
-
|
|
4575
|
+
get paymentItems() {
|
|
4576
|
+
return this._PaymentItem.initOnlyValidFromArray(this._paymentItems)
|
|
4577
|
+
}
|
|
3765
4578
|
get usedCoupons() {
|
|
3766
4579
|
const usedItemCoupons = q_utilities_namespaceObject.KeyValueObject.getValueByKey(this.remarks, 'USED_ITEM_COUPONS') || []
|
|
3767
4580
|
const usedTotalCoupons = q_utilities_namespaceObject.KeyValueObject.getValueByKey(this.remarks, 'USED_TOTAL_COUPONS') || []
|
|
@@ -3776,10 +4589,14 @@ class InvoiceLine extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
3776
4589
|
purchaseOptions: this.purchaseOptions
|
|
3777
4590
|
})
|
|
3778
4591
|
}
|
|
4592
|
+
setCompleted(timestamp, actorCode) {
|
|
4593
|
+
this.status.setCompleted(timestamp, actorCode)
|
|
4594
|
+
return this.setModified()
|
|
4595
|
+
}
|
|
3779
4596
|
update(update) {
|
|
3780
4597
|
Object.keys(update).forEach((key) => {
|
|
3781
4598
|
if (invoiceLine_updateAllowedProps.includes(key)) {
|
|
3782
|
-
if (key === 'amount' || key === 'unitPrice' || key === 'deduction') {
|
|
4599
|
+
if (key === 'amount' || key === 'unitPrice' || key === 'deduction' || key === 'outstanding') {
|
|
3783
4600
|
this[key] = this._Amount.init(update[key])
|
|
3784
4601
|
} else if (key === 'purchaseOptions') {
|
|
3785
4602
|
this[key] = q_utilities_namespaceObject.KeyValueObject.initOnlyValidFromArray(update[key])
|
|
@@ -3790,6 +4607,23 @@ class InvoiceLine extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
3790
4607
|
})
|
|
3791
4608
|
return super.update(update)
|
|
3792
4609
|
}
|
|
4610
|
+
updateOutstanding({ actorCode } = {}) {
|
|
4611
|
+
const paymentItems = this.paymentItems
|
|
4612
|
+
if (paymentItems.length === 0) {
|
|
4613
|
+
return this
|
|
4614
|
+
}
|
|
4615
|
+
const paid = paymentItems.reduce((acc, pi) => acc + (pi?.amount?.value || 0), 0)
|
|
4616
|
+
const value = this.amount.value - paid
|
|
4617
|
+
if (value <= 0) {
|
|
4618
|
+
this.setCompleted(Date.now(), actorCode)
|
|
4619
|
+
}
|
|
4620
|
+
return this.update({
|
|
4621
|
+
outstanding: {
|
|
4622
|
+
currencyCode: this.amount.currencyCode,
|
|
4623
|
+
value
|
|
4624
|
+
}
|
|
4625
|
+
})
|
|
4626
|
+
}
|
|
3793
4627
|
}
|
|
3794
4628
|
|
|
3795
4629
|
function invoiceLine_setCode(options, key) {
|
|
@@ -3809,36 +4643,12 @@ function invoiceLine_setId(id) {
|
|
|
3809
4643
|
|
|
3810
4644
|
|
|
3811
4645
|
|
|
3812
|
-
;// ./lib/models/invoiceLine/invoiceLineRepo.js
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
class InvoiceLineRepo extends q_utilities_namespaceObject.Repo {
|
|
3817
|
-
constructor(options = {}) {
|
|
3818
|
-
options = options || {}
|
|
3819
|
-
super(options)
|
|
3820
|
-
const { _InvoiceLine } = options._constructor || {}
|
|
3821
|
-
this._InvoiceLine = _InvoiceLine && (_InvoiceLine._superclass === InvoiceLine._superclass) ? _InvoiceLine : InvoiceLine
|
|
3822
|
-
}
|
|
3823
|
-
static get _classname() {
|
|
3824
|
-
return 'InvoiceLineRepo'
|
|
3825
|
-
}
|
|
3826
|
-
init(options) {
|
|
3827
|
-
return this._InvoiceLine.init(options)
|
|
3828
|
-
}
|
|
3829
|
-
}
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
4646
|
;// ./lib/models/invoiceLine/index.js
|
|
3834
4647
|
|
|
3835
4648
|
|
|
3836
4649
|
|
|
3837
4650
|
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
4651
|
;// ./lib/models/issuer/issuer.js
|
|
3841
|
-
|
|
3842
4652
|
class Issuer {
|
|
3843
4653
|
constructor(options = {}) {
|
|
3844
4654
|
options = options || {}
|
|
@@ -3900,6 +4710,7 @@ class Issuer {
|
|
|
3900
4710
|
|
|
3901
4711
|
|
|
3902
4712
|
|
|
4713
|
+
|
|
3903
4714
|
// import { Transaction } from '../transaction/index.js'
|
|
3904
4715
|
|
|
3905
4716
|
const walletItem_updateAllowedProps = [
|
|
@@ -3913,7 +4724,8 @@ class WalletItem extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
3913
4724
|
options = options || {}
|
|
3914
4725
|
super(options)
|
|
3915
4726
|
|
|
3916
|
-
const { _Product, _Status } = options._constructor || {}
|
|
4727
|
+
const { _Amount, _Product, _Status } = options._constructor || {}
|
|
4728
|
+
this._Amount = _Amount && (_Amount._superclass === Amount._superclass) ? _Amount : Amount
|
|
3917
4729
|
this._Product = _Product && (_Product._superclass === Product._superclass) ? _Product : Product
|
|
3918
4730
|
this._Status = _Status && (_Status._superclass === Status._superclass) ? _Status : Status
|
|
3919
4731
|
// this._Transaction = _Transaction && (_Transaction._superclass === Transaction._superclass) ? _Transaction : Transaction
|
|
@@ -4043,18 +4855,30 @@ class WalletItem extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
4043
4855
|
get displayPurchaseOptions() {
|
|
4044
4856
|
return this.purchaseOptions.length > 0
|
|
4045
4857
|
? this.purchaseOptions.reduce((acc, purchaseOption) => {
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
|
|
4858
|
+
const { value } = purchaseOption
|
|
4859
|
+
return acc += value.reduce((_acc, item) => {
|
|
4860
|
+
const { label, value } = item
|
|
4861
|
+
return _acc += `<div><span>${label}: </span><span>${value}</span></div>`
|
|
4862
|
+
}, '')
|
|
4050
4863
|
}, '')
|
|
4051
|
-
}, '')
|
|
4052
4864
|
: ''
|
|
4053
4865
|
}
|
|
4054
4866
|
|
|
4055
4867
|
get lastRefundRejectedDetail() {
|
|
4056
4868
|
return Array.isArray(this.refundRejectedHistory) && this.refundRejectedHistory.length > 0 ? this.refundRejectedHistory[this.refundRejectedHistory.length - 1] : null
|
|
4057
4869
|
}
|
|
4870
|
+
get paid() {
|
|
4871
|
+
if (!this._transaction) {
|
|
4872
|
+
return null
|
|
4873
|
+
}
|
|
4874
|
+
const { amount, meta } = this._transaction
|
|
4875
|
+
return {
|
|
4876
|
+
created: meta.created,
|
|
4877
|
+
currencyCode: amount.currencyCode,
|
|
4878
|
+
modified: meta.modified,
|
|
4879
|
+
value: amount.value
|
|
4880
|
+
}
|
|
4881
|
+
}
|
|
4058
4882
|
|
|
4059
4883
|
get product() {
|
|
4060
4884
|
return this._Product.init(this._product)
|
|
@@ -4290,33 +5114,11 @@ function walletItem_setCode(options, key) {
|
|
|
4290
5114
|
|
|
4291
5115
|
|
|
4292
5116
|
|
|
4293
|
-
;// ./lib/models/walletItem/walletItemRepo.js
|
|
4294
|
-
|
|
4295
|
-
|
|
4296
|
-
|
|
4297
|
-
class WalletItemRepo extends q_utilities_namespaceObject.Repo {
|
|
4298
|
-
constructor(options = {}) {
|
|
4299
|
-
options = options || {}
|
|
4300
|
-
super(options)
|
|
4301
|
-
const { _WalletItem } = options._constructor || {}
|
|
4302
|
-
this._WalletItem = _WalletItem && (_WalletItem._superclass === WalletItem._superclass) ? _WalletItem : WalletItem
|
|
4303
|
-
}
|
|
4304
|
-
static get _classname() {
|
|
4305
|
-
return 'WalletItemRepo'
|
|
4306
|
-
}
|
|
4307
|
-
init(options) {
|
|
4308
|
-
return this._WalletItem.init(options)
|
|
4309
|
-
}
|
|
4310
|
-
}
|
|
4311
|
-
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
5117
|
;// ./lib/models/walletItem/index.js
|
|
4315
5118
|
|
|
4316
5119
|
|
|
4317
5120
|
|
|
4318
5121
|
|
|
4319
|
-
|
|
4320
5122
|
;// ./lib/models/transaction/transaction.js
|
|
4321
5123
|
|
|
4322
5124
|
|
|
@@ -4641,34 +5443,11 @@ function transaction_setId(id) {
|
|
|
4641
5443
|
|
|
4642
5444
|
|
|
4643
5445
|
|
|
4644
|
-
;// ./lib/models/transaction/transactionRepo.js
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
|
|
4648
|
-
class TransactionRepo extends q_utilities_namespaceObject.Repo {
|
|
4649
|
-
constructor(options = {}) {
|
|
4650
|
-
options = options || {}
|
|
4651
|
-
super(options)
|
|
4652
|
-
const { _Transaction } = options._constructor || {}
|
|
4653
|
-
this._Transaction = _Transaction && (_Transaction._superclass === Transaction._superclass) ? _Transaction : Transaction
|
|
4654
|
-
}
|
|
4655
|
-
static get _classname() {
|
|
4656
|
-
return 'TransactionRepo'
|
|
4657
|
-
}
|
|
4658
|
-
init(options) {
|
|
4659
|
-
return this._Transaction.init(options)
|
|
4660
|
-
}
|
|
4661
|
-
}
|
|
4662
|
-
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
5446
|
;// ./lib/models/transaction/index.js
|
|
4666
5447
|
|
|
4667
5448
|
|
|
4668
5449
|
|
|
4669
5450
|
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
5451
|
;// ./lib/models/invoice/invoice.js
|
|
4673
5452
|
|
|
4674
5453
|
|
|
@@ -4680,10 +5459,12 @@ class TransactionRepo extends q_utilities_namespaceObject.Repo {
|
|
|
4680
5459
|
|
|
4681
5460
|
|
|
4682
5461
|
const invoice_updateAllowedProps = [
|
|
5462
|
+
'billToUserCode',
|
|
4683
5463
|
'checkoutDateTime',
|
|
4684
5464
|
'description',
|
|
4685
5465
|
'invoiceDate',
|
|
4686
5466
|
'issuer',
|
|
5467
|
+
'outstanding',
|
|
4687
5468
|
'revisionNumber',
|
|
4688
5469
|
'status'
|
|
4689
5470
|
]
|
|
@@ -4691,24 +5472,27 @@ const invoice_updateAllowedProps = [
|
|
|
4691
5472
|
class Invoice extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
4692
5473
|
constructor(options) {
|
|
4693
5474
|
options = options || {}
|
|
4694
|
-
super(options)
|
|
5475
|
+
super(options) // store the 'BUILDTOUSER' into invoice.metadata
|
|
4695
5476
|
|
|
4696
|
-
const { _Amount, _Cart, _InvoiceLine, _Issuer, _Status, _Transaction } = options._constructor || {}
|
|
5477
|
+
const { _Amount, _BillToUser, _Cart, _InvoiceLine, _Issuer, _Status, _Transaction } = options._constructor || {}
|
|
4697
5478
|
this._Amount = _Amount && (_Amount._superclass === Amount._superclass) ? _Amount : Amount
|
|
5479
|
+
this._BillToUser = _BillToUser
|
|
4698
5480
|
this._Cart = _Cart && (_Cart._superclass === Cart._superclass) ? _Cart : Cart
|
|
4699
5481
|
this._InvoiceLine = _InvoiceLine && (_InvoiceLine._superclass === InvoiceLine._superclass) ? _InvoiceLine : InvoiceLine
|
|
4700
5482
|
this._Issuer = _Issuer && (_Issuer._superclass === Issuer._superclass) ? _Issuer : Issuer
|
|
4701
5483
|
this._Status = _Status && (_Status._superclass === Status._superclass) ? _Status : Status
|
|
4702
5484
|
this._Transaction = _Transaction && (_Transaction._superclass === Transaction._superclass) ? _Transaction : Transaction
|
|
4703
5485
|
|
|
5486
|
+
this._billToUser = options._billToUser
|
|
4704
5487
|
this._cart = options._cart
|
|
4705
5488
|
this._invoiceLines = options._invoiceLines
|
|
4706
5489
|
this._transactions = options._transactions
|
|
4707
|
-
|
|
5490
|
+
|
|
4708
5491
|
const id = options._id || options.id
|
|
4709
5492
|
this.id = invoice_setId(id)
|
|
4710
5493
|
this._type = options._type || 'Invoice'
|
|
4711
5494
|
this.amount = this._Amount.init(options.amount)
|
|
5495
|
+
this.billToUserCode = options.billToUserCode // mainly for frontend populate
|
|
4712
5496
|
this.cartCode = options.cartCode
|
|
4713
5497
|
this.checkoutDateTime = options.checkoutDateTime || (new Date()).valueOf()
|
|
4714
5498
|
this.description = options.description
|
|
@@ -4717,6 +5501,7 @@ class Invoice extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
4717
5501
|
this.invoiceNumber = options.invoiceNumber
|
|
4718
5502
|
this.invoiceType = options.invoiceType || 'Invoice'
|
|
4719
5503
|
this.issuer = this._Issuer.init(options.issuer)
|
|
5504
|
+
this.outstanding = this._Amount.init(options.outstanding)
|
|
4720
5505
|
this.revisionNumber = options.revisionNumber || 1
|
|
4721
5506
|
this.status = this._Status.init(options.status)
|
|
4722
5507
|
}
|
|
@@ -4736,6 +5521,9 @@ class Invoice extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
4736
5521
|
get isValid() {
|
|
4737
5522
|
return super.isValid
|
|
4738
5523
|
}
|
|
5524
|
+
get billToUser() {
|
|
5525
|
+
return this._BillToUser && typeof this._BillToUser.init === 'function' ? this._BillToUser.init(this._billToUser) : this._billToUser
|
|
5526
|
+
}
|
|
4739
5527
|
get cart() {
|
|
4740
5528
|
return this._Cart.init(this._cart)
|
|
4741
5529
|
}
|
|
@@ -4827,6 +5615,14 @@ class Invoice extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
4827
5615
|
return this.status.setCancelled()
|
|
4828
5616
|
}
|
|
4829
5617
|
|
|
5618
|
+
setClosed(timestamp, actorCode) {
|
|
5619
|
+
if (typeof this.status.setClosed !== 'function') {
|
|
5620
|
+
return this
|
|
5621
|
+
}
|
|
5622
|
+
this.status.setClosed(timestamp, actorCode)
|
|
5623
|
+
return this.setModified()
|
|
5624
|
+
}
|
|
5625
|
+
|
|
4830
5626
|
setCheckoutDateTime(timestamp) {
|
|
4831
5627
|
if (typeof timestamp === 'number') {
|
|
4832
5628
|
this.checkoutDateTime = timestamp
|
|
@@ -4837,195 +5633,74 @@ class Invoice extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
4837
5633
|
this.status.setCompleted()
|
|
4838
5634
|
return this.setModified()
|
|
4839
5635
|
}
|
|
4840
|
-
|
|
4841
|
-
setWaived() {
|
|
4842
|
-
this.status.setWaived()
|
|
4843
|
-
return this.setModified()
|
|
4844
|
-
}
|
|
4845
|
-
|
|
4846
|
-
update(update) {
|
|
4847
|
-
Object.keys(update).forEach((key) => {
|
|
4848
|
-
if (invoice_updateAllowedProps.includes(key)) {
|
|
4849
|
-
if (key === 'amount') {
|
|
4850
|
-
this[key] = this._Amount.init(update[key])
|
|
4851
|
-
} else if (key === 'issuer') {
|
|
4852
|
-
this[key] = this._Issuer.init(update[key])
|
|
4853
|
-
} else if (key === 'status') {
|
|
4854
|
-
this[key] = this._Status.init(update[key])
|
|
4855
|
-
} else {
|
|
4856
|
-
this[key] = update[key]
|
|
4857
|
-
}
|
|
4858
|
-
}
|
|
4859
|
-
})
|
|
4860
|
-
return super.update(update)
|
|
4861
|
-
}
|
|
4862
|
-
}
|
|
4863
|
-
|
|
4864
|
-
function invoice_setCode(options, key) {
|
|
4865
|
-
const copyOptions = options || {}
|
|
4866
|
-
if (copyOptions[key]) {
|
|
4867
|
-
return copyOptions[key]
|
|
4868
|
-
}
|
|
4869
|
-
return stringHelper.setCode()
|
|
4870
|
-
}
|
|
4871
|
-
|
|
4872
|
-
function invoice_setId(id) {
|
|
4873
|
-
if (id && typeof id.toString === 'function') {
|
|
4874
|
-
return id.toString()
|
|
4875
|
-
}
|
|
4876
|
-
return id
|
|
4877
|
-
}
|
|
4878
|
-
|
|
4879
|
-
|
|
4880
|
-
|
|
4881
|
-
;// ./lib/models/invoice/invoiceRepo.js
|
|
4882
|
-
|
|
4883
|
-
|
|
4884
|
-
|
|
4885
|
-
class InvoiceRepo extends q_utilities_namespaceObject.Repo {
|
|
4886
|
-
constructor(options = {}) {
|
|
4887
|
-
options = options || {}
|
|
4888
|
-
super(options)
|
|
4889
|
-
const { _Invoice } = options._constructor || {}
|
|
4890
|
-
this._Invoice = _Invoice && (_Invoice._superclass === Invoice._superclass) ? _Invoice : Invoice
|
|
4891
|
-
}
|
|
4892
|
-
static get _classname() {
|
|
4893
|
-
return 'InvoiceRepo'
|
|
4894
|
-
}
|
|
4895
|
-
init(options) {
|
|
4896
|
-
return this._Invoice.init(options)
|
|
4897
|
-
}
|
|
4898
|
-
}
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
|
|
4902
|
-
;// ./lib/models/invoice/index.js
|
|
4903
|
-
|
|
4904
|
-
|
|
4905
|
-
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
|
|
4909
|
-
;// ./lib/models/keyValueObject/index.js
|
|
4910
|
-
|
|
4911
|
-
|
|
4912
|
-
;// ./lib/models/statusQStore/statusQStore.js
|
|
4913
|
-
|
|
4914
|
-
|
|
4915
|
-
const statusQStore_notUpdateAllowedProps = (/* unused pure expression or super */ null && ([
|
|
4916
|
-
]))
|
|
4917
|
-
|
|
4918
|
-
class StatusQStore extends q_utilities_namespaceObject.Status {
|
|
4919
|
-
constructor(options) {
|
|
4920
|
-
options = options || {}
|
|
4921
|
-
super(options)
|
|
4922
|
-
|
|
4923
|
-
this.cancelled = this._ActionRecord.init(options.cancelled)
|
|
4924
|
-
this.completed = this._ActionRecord.init(options.completed)
|
|
4925
|
-
this.confirmed = this._ActionRecord.init(options.confirmed)
|
|
4926
|
-
this.deleted = this._ActionRecord.init(options.deleted)
|
|
4927
|
-
this.terminated = this._ActionRecord.init(options.terminated)
|
|
4928
|
-
}
|
|
4929
|
-
|
|
4930
|
-
static get _classname() {
|
|
4931
|
-
return 'StatusQStore'
|
|
4932
|
-
}
|
|
4933
|
-
get _classname() {
|
|
4934
|
-
return 'StatusQStore'
|
|
4935
|
-
}
|
|
4936
|
-
get isCancelled() {
|
|
4937
|
-
return this.cancelled?.timestamp > 0
|
|
4938
|
-
}
|
|
4939
|
-
get isCompleted() {
|
|
4940
|
-
return this.completed?.timestamp > 0
|
|
4941
|
-
}
|
|
4942
|
-
get isConfirmed() {
|
|
4943
|
-
return this.confirmed?.timestamp > 0
|
|
4944
|
-
}
|
|
4945
|
-
get isDeleted() {
|
|
4946
|
-
return this.deleted?.timestamp > 0
|
|
4947
|
-
}
|
|
4948
|
-
get isTerminated() {
|
|
4949
|
-
return this.terminated?.timestamp > 0
|
|
4950
|
-
}
|
|
4951
|
-
get isValid() {
|
|
4952
|
-
return super.isValid
|
|
4953
|
-
}
|
|
4954
|
-
setCancelled(value, actorCode) {
|
|
4955
|
-
return this.setValue(value, actorCode, 'cancelled')
|
|
4956
|
-
}
|
|
4957
|
-
setCompleted(value, actorCode) {
|
|
4958
|
-
return this.setValue(value, actorCode, 'completed')
|
|
4959
|
-
}
|
|
4960
|
-
setConfirmed(value, actorCode) {
|
|
4961
|
-
return this.setValue(value, actorCode, 'confirmed')
|
|
4962
|
-
}
|
|
4963
|
-
setDeleted(value, actorCode) {
|
|
4964
|
-
return this.setValue(value, actorCode, 'deleted')
|
|
4965
|
-
}
|
|
4966
|
-
setTerminated(value, actorCode) {
|
|
4967
|
-
return this.setValue(value, actorCode, 'terminated')
|
|
4968
|
-
}
|
|
4969
|
-
// update(update) {
|
|
4970
|
-
// Object.keys(update).forEach((key) => {
|
|
4971
|
-
// if (!notUpdateAllowedProps.includes(key)) {
|
|
4972
|
-
// this[key] = this[key] instanceof this._ActionRecord ? this[key].update(update[key]) : this._ActionRecord.init(update[key])
|
|
4973
|
-
// }
|
|
4974
|
-
// })
|
|
4975
|
-
// return super.update(update)
|
|
4976
|
-
// }
|
|
4977
|
-
}
|
|
4978
|
-
|
|
4979
|
-
;// ./lib/models/statusQStore/statusQStoreOrderLine.js
|
|
4980
|
-
|
|
4981
|
-
|
|
4982
|
-
const statusQStoreOrderLine_notUpdateAllowedProps = (/* unused pure expression or super */ null && ([
|
|
4983
|
-
]))
|
|
4984
|
-
|
|
4985
|
-
class StatusQStoreOrderLine extends StatusQStore {
|
|
4986
|
-
constructor(options) {
|
|
4987
|
-
options = options || {}
|
|
4988
|
-
super(options)
|
|
4989
|
-
|
|
4990
|
-
this.expired = this._ActionRecord.init(options.expired)
|
|
4991
|
-
this.invalid = this._ActionRecord.init(options.invalid)
|
|
4992
|
-
}
|
|
4993
|
-
|
|
4994
|
-
static get _classname() {
|
|
4995
|
-
return 'StatusQStoreOrderLine'
|
|
4996
|
-
}
|
|
4997
|
-
get _classname() {
|
|
4998
|
-
return 'StatusQStoreOrderLine'
|
|
4999
|
-
}
|
|
5000
|
-
get isExpired() {
|
|
5001
|
-
return this.expired?.timestamp > Date.now()
|
|
5002
|
-
}
|
|
5003
|
-
get isInvalid() {
|
|
5004
|
-
return this.invalid?.timestamp > Date.now()
|
|
5636
|
+
|
|
5637
|
+
setWaived() {
|
|
5638
|
+
this.status.setWaived()
|
|
5639
|
+
return this.setModified()
|
|
5005
5640
|
}
|
|
5006
|
-
|
|
5007
|
-
|
|
5641
|
+
|
|
5642
|
+
update(update) {
|
|
5643
|
+
Object.keys(update).forEach((key) => {
|
|
5644
|
+
if (invoice_updateAllowedProps.includes(key)) {
|
|
5645
|
+
if (key === 'amount' || key === 'outstanding') {
|
|
5646
|
+
this[key] = this._Amount.init(update[key])
|
|
5647
|
+
} else if (key === 'issuer') {
|
|
5648
|
+
this[key] = this._Issuer.init(update[key])
|
|
5649
|
+
} else if (key === 'status') {
|
|
5650
|
+
this[key] = this._Status.init(update[key])
|
|
5651
|
+
} else {
|
|
5652
|
+
this[key] = update[key]
|
|
5653
|
+
}
|
|
5654
|
+
}
|
|
5655
|
+
})
|
|
5656
|
+
return super.update(update)
|
|
5008
5657
|
}
|
|
5009
|
-
|
|
5010
|
-
|
|
5658
|
+
|
|
5659
|
+
updateOutstanding({ actorCode } = {}) {
|
|
5660
|
+
const invoiceLines = this.invoiceLines
|
|
5661
|
+
if (invoiceLines.length === 0) {
|
|
5662
|
+
return this
|
|
5663
|
+
}
|
|
5664
|
+
const value = invoiceLines.reduce((acc, il) => {
|
|
5665
|
+
il.updateOutstanding({ actorCode })
|
|
5666
|
+
return acc + il?.outstanding?.value
|
|
5667
|
+
}, 0)
|
|
5668
|
+
if (value <= 0) {
|
|
5669
|
+
this.setClosed(Date.now(), actorCode)
|
|
5670
|
+
}
|
|
5671
|
+
this._invoiceLines = invoiceLines
|
|
5672
|
+
return this.update({
|
|
5673
|
+
outstanding: {
|
|
5674
|
+
currencyCode: this.getCurrencyCode(),
|
|
5675
|
+
value
|
|
5676
|
+
}
|
|
5677
|
+
})
|
|
5011
5678
|
}
|
|
5012
|
-
|
|
5013
|
-
|
|
5679
|
+
}
|
|
5680
|
+
|
|
5681
|
+
function invoice_setCode(options, key) {
|
|
5682
|
+
const copyOptions = options || {}
|
|
5683
|
+
if (copyOptions[key]) {
|
|
5684
|
+
return copyOptions[key]
|
|
5014
5685
|
}
|
|
5015
|
-
|
|
5016
|
-
|
|
5017
|
-
|
|
5018
|
-
|
|
5019
|
-
|
|
5020
|
-
|
|
5021
|
-
|
|
5022
|
-
|
|
5686
|
+
return stringHelper.setCode()
|
|
5687
|
+
}
|
|
5688
|
+
|
|
5689
|
+
function invoice_setId(id) {
|
|
5690
|
+
if (id && typeof id.toString === 'function') {
|
|
5691
|
+
return id.toString()
|
|
5692
|
+
}
|
|
5693
|
+
return id
|
|
5023
5694
|
}
|
|
5024
5695
|
|
|
5025
|
-
|
|
5696
|
+
|
|
5697
|
+
|
|
5698
|
+
;// ./lib/models/invoice/index.js
|
|
5699
|
+
|
|
5026
5700
|
|
|
5027
5701
|
|
|
5028
5702
|
|
|
5703
|
+
;// ./lib/models/keyValueObject/index.js
|
|
5029
5704
|
|
|
5030
5705
|
|
|
5031
5706
|
;// ./lib/models/orderLine/orderLine.js
|
|
@@ -5136,6 +5811,7 @@ class OrderLine extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
5136
5811
|
unitPrice: this.unitPrice,
|
|
5137
5812
|
deduction: this.deduction,
|
|
5138
5813
|
discount: this.discount,
|
|
5814
|
+
outstanding: this.amount,
|
|
5139
5815
|
qty: this.qty,
|
|
5140
5816
|
merchandiseCode: this.merchandiseCode,
|
|
5141
5817
|
metadata: this.metadata,
|
|
@@ -5152,6 +5828,14 @@ class OrderLine extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
5152
5828
|
return this.amount
|
|
5153
5829
|
}
|
|
5154
5830
|
|
|
5831
|
+
getPreservedData() {
|
|
5832
|
+
return {
|
|
5833
|
+
orderCode: this.orderCode,
|
|
5834
|
+
orderLineCode: this.orderLineCode,
|
|
5835
|
+
orderLineType: this.orderLineType,
|
|
5836
|
+
}
|
|
5837
|
+
}
|
|
5838
|
+
|
|
5155
5839
|
toCaculateAmountItem() {
|
|
5156
5840
|
return {
|
|
5157
5841
|
merchandiseCode: this.merchandiseCode,
|
|
@@ -5415,133 +6099,6 @@ function order_setId(id) {
|
|
|
5415
6099
|
|
|
5416
6100
|
|
|
5417
6101
|
|
|
5418
|
-
;// ./lib/models/paymentGateway/paymentGateway.js
|
|
5419
|
-
|
|
5420
|
-
|
|
5421
|
-
|
|
5422
|
-
const paymentGateway_updateAllowedProps = [
|
|
5423
|
-
'label',
|
|
5424
|
-
'logoUrl',
|
|
5425
|
-
'name',
|
|
5426
|
-
'sandbox',
|
|
5427
|
-
'setting'
|
|
5428
|
-
]
|
|
5429
|
-
|
|
5430
|
-
class PaymentGateway extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
5431
|
-
constructor(options = {}) {
|
|
5432
|
-
options = options || {}
|
|
5433
|
-
super(options)
|
|
5434
|
-
|
|
5435
|
-
const id = options._id || options.id
|
|
5436
|
-
this.id = paymentGateway_setId(id)
|
|
5437
|
-
this._type = options._type || 'PaymentGateway'
|
|
5438
|
-
|
|
5439
|
-
this.hasWebhook = options.hasWebhook || false
|
|
5440
|
-
this.label = options.label
|
|
5441
|
-
this.logoUrl = options.logoUrl
|
|
5442
|
-
this.name = options.name || ''
|
|
5443
|
-
this.paymentGatewayCode = paymentGateway_setCode(options, 'paymentGatewayCode')
|
|
5444
|
-
this.paymentGatewayType = options.paymentGatewayType || 'PaymentGateway'
|
|
5445
|
-
this.paymentResultType = options.paymentResultType || 'PaymentResult'
|
|
5446
|
-
this.sandbox = options.sandbox || false
|
|
5447
|
-
this.setting = options.setting || null
|
|
5448
|
-
}
|
|
5449
|
-
static dummyData() {
|
|
5450
|
-
return {
|
|
5451
|
-
name: 'name',
|
|
5452
|
-
tenantCode: 'tenantCode'
|
|
5453
|
-
}
|
|
5454
|
-
}
|
|
5455
|
-
static get _classname() {
|
|
5456
|
-
return 'PaymentGateway'
|
|
5457
|
-
}
|
|
5458
|
-
static get _superclass() {
|
|
5459
|
-
return 'PaymentGateway'
|
|
5460
|
-
}
|
|
5461
|
-
|
|
5462
|
-
// getters
|
|
5463
|
-
get isValid() {
|
|
5464
|
-
return super.isValid && !!this.name
|
|
5465
|
-
}
|
|
5466
|
-
|
|
5467
|
-
// instance methods
|
|
5468
|
-
async createPayment() {
|
|
5469
|
-
throw new Error(`${this._classname} subclass should implement createPayment`)
|
|
5470
|
-
}
|
|
5471
|
-
async getAppPayParams() {
|
|
5472
|
-
throw new Error(`${this._classname} subclass should implement getAppPayParams`)
|
|
5473
|
-
}
|
|
5474
|
-
getCode() {
|
|
5475
|
-
return this.paymentGatewayCode
|
|
5476
|
-
}
|
|
5477
|
-
async updatePayment() {
|
|
5478
|
-
throw new Error(`${this._classname} subclass should implement updatePayment`)
|
|
5479
|
-
}
|
|
5480
|
-
async query() {
|
|
5481
|
-
throw new Error(`${this._classname} subclass should implement query`)
|
|
5482
|
-
}
|
|
5483
|
-
async submit() {
|
|
5484
|
-
throw new Error(`${this._classname} subclass should implement submit`)
|
|
5485
|
-
}
|
|
5486
|
-
|
|
5487
|
-
setCompletedRelatedStatus(status) {
|
|
5488
|
-
throw new Error(`${this.name} subclass should implement setCompletedRelatedStatus`)
|
|
5489
|
-
}
|
|
5490
|
-
update(update) {
|
|
5491
|
-
Object.keys(update).forEach((key) => {
|
|
5492
|
-
if (paymentGateway_updateAllowedProps.includes(key)) {
|
|
5493
|
-
this[key] = update[key]
|
|
5494
|
-
}
|
|
5495
|
-
})
|
|
5496
|
-
return super.update(update)
|
|
5497
|
-
}
|
|
5498
|
-
}
|
|
5499
|
-
|
|
5500
|
-
function paymentGateway_setCode(options, key) {
|
|
5501
|
-
const copyOptions = options || {}
|
|
5502
|
-
if (copyOptions[key]) {
|
|
5503
|
-
return copyOptions[key]
|
|
5504
|
-
}
|
|
5505
|
-
return stringHelper.setCode()
|
|
5506
|
-
}
|
|
5507
|
-
|
|
5508
|
-
function paymentGateway_setId(id) {
|
|
5509
|
-
if (id && typeof id.toString === 'function') {
|
|
5510
|
-
return id.toString()
|
|
5511
|
-
}
|
|
5512
|
-
return id
|
|
5513
|
-
}
|
|
5514
|
-
|
|
5515
|
-
|
|
5516
|
-
|
|
5517
|
-
;// ./lib/models/paymentGateway/paymentGatewayRepo.js
|
|
5518
|
-
|
|
5519
|
-
|
|
5520
|
-
|
|
5521
|
-
class PaymentGatewayRepo extends q_utilities_namespaceObject.Repo {
|
|
5522
|
-
constructor(options = {}) {
|
|
5523
|
-
options = options || {}
|
|
5524
|
-
super(options)
|
|
5525
|
-
const { _PaymentGateway } = options._constructor || {}
|
|
5526
|
-
this._PaymentGateway = _PaymentGateway && (_PaymentGateway._superclass === PaymentGateway._superclass) ? _PaymentGateway : PaymentGateway
|
|
5527
|
-
}
|
|
5528
|
-
static get _classname() {
|
|
5529
|
-
return 'PaymentGatewayRepo'
|
|
5530
|
-
}
|
|
5531
|
-
init(options) {
|
|
5532
|
-
return this._PaymentGateway.init(options)
|
|
5533
|
-
}
|
|
5534
|
-
}
|
|
5535
|
-
|
|
5536
|
-
|
|
5537
|
-
|
|
5538
|
-
;// ./lib/models/paymentGateway/index.js
|
|
5539
|
-
|
|
5540
|
-
|
|
5541
|
-
|
|
5542
|
-
|
|
5543
|
-
|
|
5544
|
-
|
|
5545
6102
|
;// ./lib/models/paymentResult/paymentResult.js
|
|
5546
6103
|
|
|
5547
6104
|
|
|
@@ -5717,40 +6274,16 @@ function paymentResult_setId(id) {
|
|
|
5717
6274
|
|
|
5718
6275
|
|
|
5719
6276
|
|
|
5720
|
-
;// ./lib/models/paymentResult/paymentResultRepo.js
|
|
5721
|
-
|
|
5722
|
-
|
|
5723
|
-
|
|
5724
|
-
class PaymentResultRepo extends q_utilities_namespaceObject.Repo {
|
|
5725
|
-
constructor(options = {}) {
|
|
5726
|
-
options = options || {}
|
|
5727
|
-
super(options)
|
|
5728
|
-
const { _PaymentResult } = options._constructor || {}
|
|
5729
|
-
this._PaymentResult = _PaymentResult && (_PaymentResult._superclass === PaymentResult._superclass) ? _PaymentResult : PaymentResult
|
|
5730
|
-
}
|
|
5731
|
-
static get _classname() {
|
|
5732
|
-
return 'PaymentResultRepo'
|
|
5733
|
-
}
|
|
5734
|
-
init(options) {
|
|
5735
|
-
return this._PaymentResult.init(options)
|
|
5736
|
-
}
|
|
5737
|
-
}
|
|
5738
|
-
|
|
5739
|
-
|
|
5740
|
-
|
|
5741
6277
|
;// ./lib/models/paymentResult/index.js
|
|
5742
6278
|
|
|
5743
6279
|
|
|
5744
6280
|
|
|
5745
6281
|
|
|
5746
|
-
|
|
5747
|
-
|
|
5748
6282
|
;// ./lib/models/status/index.js
|
|
5749
6283
|
|
|
5750
6284
|
|
|
5751
6285
|
|
|
5752
6286
|
|
|
5753
|
-
|
|
5754
6287
|
;// ./lib/models/storeItem/storeItem.js
|
|
5755
6288
|
|
|
5756
6289
|
|
|
@@ -5911,7 +6444,7 @@ class StoreItem {
|
|
|
5911
6444
|
if (storeItem_updateAllowedProps.includes(key)) {
|
|
5912
6445
|
if (key === 'metadata') {
|
|
5913
6446
|
this[key] = q_utilities_namespaceObject.Metadata.initOnlyValidFromArray(update[key])
|
|
5914
|
-
} else
|
|
6447
|
+
} else if (key === 'productOptions') {
|
|
5915
6448
|
this[key] = this._ItemOption.initOnlyValidFromArray(update[key])
|
|
5916
6449
|
} else if (key === 'remarks') {
|
|
5917
6450
|
this[key] = q_utilities_namespaceObject.KeyValueObject.initOnlyValidFromArray(update[key])
|
|
@@ -5976,8 +6509,13 @@ function storeItem_getDataByKey(key, data) {
|
|
|
5976
6509
|
|
|
5977
6510
|
|
|
5978
6511
|
|
|
5979
|
-
;// ./lib/helpers/corHelper/chain.js
|
|
5980
6512
|
|
|
6513
|
+
|
|
6514
|
+
|
|
6515
|
+
|
|
6516
|
+
|
|
6517
|
+
|
|
6518
|
+
;// ./lib/helpers/corHelper/chain.js
|
|
5981
6519
|
class Chain {
|
|
5982
6520
|
constructor(options = {}) {
|
|
5983
6521
|
options = options || {}
|
|
@@ -6097,7 +6635,7 @@ function calculateByCoupon({ coupon, price, currencyCode }) {
|
|
|
6097
6635
|
}
|
|
6098
6636
|
const { type, item } = couponDetails
|
|
6099
6637
|
if (item) {
|
|
6100
|
-
switch(type) {
|
|
6638
|
+
switch (type) {
|
|
6101
6639
|
case ('Deduction'): {
|
|
6102
6640
|
return _caculateByDeduction({ price, couponDetails, currencyCode })
|
|
6103
6641
|
}
|
|
@@ -6122,7 +6660,6 @@ function _caculateByPercentage({ price, couponDetails }) {
|
|
|
6122
6660
|
|
|
6123
6661
|
|
|
6124
6662
|
|
|
6125
|
-
|
|
6126
6663
|
;// ./lib/helpers/calculateByCoupon/index.js
|
|
6127
6664
|
|
|
6128
6665
|
|
|
@@ -6169,7 +6706,12 @@ class ChainCategoryLimit extends Chain {
|
|
|
6169
6706
|
function groupCategory(categories = [], walletItems = []) {
|
|
6170
6707
|
return categories.reduce((acc, category) => {
|
|
6171
6708
|
const {
|
|
6172
|
-
categoryCode,
|
|
6709
|
+
categoryCode,
|
|
6710
|
+
codes,
|
|
6711
|
+
name,
|
|
6712
|
+
max,
|
|
6713
|
+
min,
|
|
6714
|
+
productCodes = [],
|
|
6173
6715
|
} = category
|
|
6174
6716
|
const filtered = walletItems.filter((w) => {
|
|
6175
6717
|
if (w.status.cancelled !== null) {
|
|
@@ -6424,7 +6966,7 @@ function getEntitlements(entitlements, productCodes, qty) {
|
|
|
6424
6966
|
if (entitlements.length === 0) {
|
|
6425
6967
|
return { waived: 0, entitlementsRemarkValue: [] }
|
|
6426
6968
|
}
|
|
6427
|
-
const groupedProductCodes = Array.from(
|
|
6969
|
+
const groupedProductCodes = Array.from({ length: qty }).map(() => [...productCodes])
|
|
6428
6970
|
// const copyEntitlements = JSON.parse(JSON.stringify(entitlements))
|
|
6429
6971
|
const { waived, entitlementsRemarkValue } = groupedProductCodes.reduce((acc, arr) => {
|
|
6430
6972
|
if (acc.continue === false) {
|
|
@@ -6483,7 +7025,6 @@ function getStrategiesByRestrictions(prices, line, user) {
|
|
|
6483
7025
|
return priceStrategies
|
|
6484
7026
|
}
|
|
6485
7027
|
|
|
6486
|
-
|
|
6487
7028
|
// function useCoupons(lines, currencyCode) {
|
|
6488
7029
|
// lines.forEach((line) => {
|
|
6489
7030
|
|
|
@@ -6507,7 +7048,7 @@ class ChainGetPriceForGroup extends Chain {
|
|
|
6507
7048
|
|
|
6508
7049
|
async handleRequest(chainTarget) {
|
|
6509
7050
|
try {
|
|
6510
|
-
const { lines
|
|
7051
|
+
const { lines } = chainTarget
|
|
6511
7052
|
const entitlements = external_lodash_namespaceObject.cloneDeep(this.entitlements)
|
|
6512
7053
|
|
|
6513
7054
|
lines.forEach((line) => {
|
|
@@ -6560,10 +7101,10 @@ function ChainGetPriceForGroup_cutEntitlements(lines, entitlements = [], currenc
|
|
|
6560
7101
|
const subTotal = Amount.init({ value, currencyCode })
|
|
6561
7102
|
const discountValue = (price.value * restQty) - subTotal.value + (price.value * waived)
|
|
6562
7103
|
const discount = Amount.init({ value: discountValue, currencyCode })
|
|
6563
|
-
let remarks = KeyValueObject.initOnlyValidFromArray([...(updatedItem.remarks || [])])
|
|
6564
|
-
remarks = KeyValueObject.updateOrInsertRecord(remarks, 'entitlements', entitlementsRemarkValue)
|
|
6565
|
-
let metadata = Metadata.initOnlyValidFromArray([...(updatedItem.metadata || [])])
|
|
6566
|
-
metadata = Metadata.updateOrInsertRecord(metadata, 'entitlements', entitlementsRemarkValue)
|
|
7104
|
+
let remarks = q_utilities_namespaceObject.KeyValueObject.initOnlyValidFromArray([...(updatedItem.remarks || [])])
|
|
7105
|
+
remarks = q_utilities_namespaceObject.KeyValueObject.updateOrInsertRecord(remarks, 'entitlements', entitlementsRemarkValue)
|
|
7106
|
+
let metadata = q_utilities_namespaceObject.Metadata.initOnlyValidFromArray([...(updatedItem.metadata || [])])
|
|
7107
|
+
metadata = q_utilities_namespaceObject.Metadata.updateOrInsertRecord(metadata, 'entitlements', entitlementsRemarkValue)
|
|
6567
7108
|
const obj = {
|
|
6568
7109
|
merchandiseCode,
|
|
6569
7110
|
price,
|
|
@@ -6642,7 +7183,7 @@ function ChainGetPriceForGroup_getEntitlements(entitlements, productCodes, qty)
|
|
|
6642
7183
|
if (entitlements.length === 0) {
|
|
6643
7184
|
return { waived: 0, entitlementsRemarkValue: [] }
|
|
6644
7185
|
}
|
|
6645
|
-
const groupedProductCodes = Array.from(
|
|
7186
|
+
const groupedProductCodes = Array.from({ length: qty }).map(() => [...productCodes])
|
|
6646
7187
|
// const copyEntitlements = JSON.parse(JSON.stringify(entitlements))
|
|
6647
7188
|
const { waived, entitlementsRemarkValue } = groupedProductCodes.reduce((acc, arr) => {
|
|
6648
7189
|
if (acc.continue === false) {
|
|
@@ -6813,7 +7354,7 @@ function _calculate({ line, currency }) {
|
|
|
6813
7354
|
|
|
6814
7355
|
function _findPriceAdjustmentValue(dataArray) {
|
|
6815
7356
|
for (const obj of dataArray) {
|
|
6816
|
-
const priceAdjustment = obj.value?.find(item => item.key === 'priceAdjustment')
|
|
7357
|
+
const priceAdjustment = obj.value?.find((item) => item.key === 'priceAdjustment')
|
|
6817
7358
|
if (priceAdjustment) {
|
|
6818
7359
|
return Number(priceAdjustment.value)
|
|
6819
7360
|
}
|
|
@@ -6823,7 +7364,6 @@ function _findPriceAdjustmentValue(dataArray) {
|
|
|
6823
7364
|
|
|
6824
7365
|
|
|
6825
7366
|
|
|
6826
|
-
|
|
6827
7367
|
;// ./lib/eventManager/chains/chainProductLimit.js
|
|
6828
7368
|
|
|
6829
7369
|
|
|
@@ -7041,7 +7581,7 @@ class ChainRelatedCoupons extends Chain {
|
|
|
7041
7581
|
})
|
|
7042
7582
|
// for total ptice coupon
|
|
7043
7583
|
_calculateAmountByTotalCoupons({ lines, currencyCode: this.currency.code, relatedTotalCoupons })
|
|
7044
|
-
_autoUsedTotalCoupons({ lines, autoUseCoupon: this.autoUseCoupon, currencyCode: this.currency.code, relatedTotalCoupons})
|
|
7584
|
+
_autoUsedTotalCoupons({ lines, autoUseCoupon: this.autoUseCoupon, currencyCode: this.currency.code, relatedTotalCoupons })
|
|
7045
7585
|
await this.next(chainTarget)
|
|
7046
7586
|
} catch (err) {
|
|
7047
7587
|
chainTarget.addException('handle related coupons fail', err.message)
|
|
@@ -7050,17 +7590,15 @@ class ChainRelatedCoupons extends Chain {
|
|
|
7050
7590
|
}
|
|
7051
7591
|
}
|
|
7052
7592
|
|
|
7053
|
-
|
|
7054
7593
|
function _autoUsedTotalCoupons({ lines, autoUseCoupon, currencyCode, relatedTotalCoupons }) {
|
|
7055
7594
|
if (autoUseCoupon) {
|
|
7056
|
-
|
|
7057
|
-
|
|
7058
|
-
|
|
7059
|
-
|
|
7595
|
+
relatedTotalCoupons.forEach((item) => {
|
|
7596
|
+
const obj = _autoUsedTotalCoupon(item, lines, currencyCode)
|
|
7597
|
+
Object.assign(item, obj)
|
|
7598
|
+
})
|
|
7060
7599
|
}
|
|
7061
7600
|
}
|
|
7062
7601
|
|
|
7063
|
-
|
|
7064
7602
|
function _autoUsedTotalCoupon(item, lines, currencyCode) {
|
|
7065
7603
|
const { availableCoupons, usedCoupons, product } = item
|
|
7066
7604
|
if (availableCoupons.length > 0) {
|
|
@@ -7101,7 +7639,7 @@ function _calculateAmountByTotalCoupons({ lines, currencyCode, relatedTotalCoupo
|
|
|
7101
7639
|
_calculateAmountByOneTotalCoupon({ lines, currencyCode, coupon })
|
|
7102
7640
|
})
|
|
7103
7641
|
})
|
|
7104
|
-
}
|
|
7642
|
+
}
|
|
7105
7643
|
|
|
7106
7644
|
function _calculateAmountByOneTotalCoupon({ lines, currencyCode, coupon }) {
|
|
7107
7645
|
const availableLines = lines.filter((line) => (coupon.isApplicableCoupon(line.merchandise)))
|
|
@@ -7114,7 +7652,7 @@ function _calculateAmountByOneTotalCoupon({ lines, currencyCode, coupon }) {
|
|
|
7114
7652
|
if (couponDetails) {
|
|
7115
7653
|
const { type, total } = couponDetails
|
|
7116
7654
|
const { value } = couponDetails
|
|
7117
|
-
switch(type) {
|
|
7655
|
+
switch (type) {
|
|
7118
7656
|
case ('Deduction'): {
|
|
7119
7657
|
const _discount = q_utilities_namespaceObject.KeyValueObject.foundValueByKey(value, currencyCode)
|
|
7120
7658
|
availableLines.forEach((line) => {
|
|
@@ -7126,7 +7664,7 @@ function _calculateAmountByOneTotalCoupon({ lines, currencyCode, coupon }) {
|
|
|
7126
7664
|
_usedCoupons.push(walletItemCode)
|
|
7127
7665
|
const obj = {
|
|
7128
7666
|
discount: Amount.init({ value: discountValue, currencyCode }),
|
|
7129
|
-
remarks: q_utilities_namespaceObject.KeyValueObject.insertOrUpdateRecord(remarks, 'USED_TOTAL_COUPONS', _usedCoupons
|
|
7667
|
+
remarks: q_utilities_namespaceObject.KeyValueObject.insertOrUpdateRecord(remarks, 'USED_TOTAL_COUPONS', _usedCoupons),
|
|
7130
7668
|
subTotal: Amount.init({ value: subTotalValue, currencyCode })
|
|
7131
7669
|
}
|
|
7132
7670
|
Object.assign(updatedItem, obj)
|
|
@@ -7144,7 +7682,7 @@ function _calculateAmountByOneTotalCoupon({ lines, currencyCode, coupon }) {
|
|
|
7144
7682
|
_usedCoupons.push(walletItemCode)
|
|
7145
7683
|
const obj = {
|
|
7146
7684
|
discount: Amount.init({ value: discountValue, currencyCode }),
|
|
7147
|
-
remarks: q_utilities_namespaceObject.KeyValueObject.insertOrUpdateRecord(remarks, 'USED_TOTAL_COUPONS', _usedCoupons
|
|
7685
|
+
remarks: q_utilities_namespaceObject.KeyValueObject.insertOrUpdateRecord(remarks, 'USED_TOTAL_COUPONS', _usedCoupons),
|
|
7148
7686
|
subTotal: Amount.init({ value: subTotalValue, currencyCode })
|
|
7149
7687
|
}
|
|
7150
7688
|
Object.assign(updatedItem, obj)
|
|
@@ -7152,11 +7690,10 @@ function _calculateAmountByOneTotalCoupon({ lines, currencyCode, coupon }) {
|
|
|
7152
7690
|
break
|
|
7153
7691
|
}
|
|
7154
7692
|
default: {
|
|
7155
|
-
|
|
7693
|
+
|
|
7156
7694
|
}
|
|
7157
7695
|
}
|
|
7158
7696
|
}
|
|
7159
|
-
|
|
7160
7697
|
}
|
|
7161
7698
|
|
|
7162
7699
|
function _calculateAmountByOneItemCoupon({ updatedItem, coupon, currencyCode }) {
|
|
@@ -7173,12 +7710,11 @@ function _calculateAmountByOneItemCoupon({ updatedItem, coupon, currencyCode })
|
|
|
7173
7710
|
return {
|
|
7174
7711
|
...updatedItem,
|
|
7175
7712
|
discount: Amount.init({ value: discountValue, currencyCode }),
|
|
7176
|
-
remarks: q_utilities_namespaceObject.KeyValueObject.insertOrUpdateRecord(remarks, 'USED_ITEM_COUPONS', _usedCoupons
|
|
7713
|
+
remarks: q_utilities_namespaceObject.KeyValueObject.insertOrUpdateRecord(remarks, 'USED_ITEM_COUPONS', _usedCoupons),
|
|
7177
7714
|
subTotal: Amount.init({ value: subTotalValue, currencyCode })
|
|
7178
7715
|
}
|
|
7179
7716
|
}
|
|
7180
7717
|
|
|
7181
|
-
|
|
7182
7718
|
function _getAvailableItemCoupons(line) {
|
|
7183
7719
|
const { relatedCoupons = [] } = line
|
|
7184
7720
|
line.relatedCoupons = relatedCoupons.map((c) => ({
|
|
@@ -7190,7 +7726,7 @@ function _getAvailableItemCoupons(line) {
|
|
|
7190
7726
|
function _getRelatedItemCoupons(cartItemLine, couponWalletItems, autoUseCoupon, currencyCode) {
|
|
7191
7727
|
const { merchandise, usedCoupons = {}, updatedItem = {} } = cartItemLine
|
|
7192
7728
|
const relatedWalletItems = couponWalletItems.filter(
|
|
7193
|
-
item => item.isApplicableCoupon(merchandise) && item.isItemCoupon
|
|
7729
|
+
(item) => item.isApplicableCoupon(merchandise) && item.isItemCoupon
|
|
7194
7730
|
)
|
|
7195
7731
|
// .sort((a, b) => (
|
|
7196
7732
|
// b.couponDetails.value - a.couponDetails.value
|
|
@@ -7203,7 +7739,7 @@ function _getRelatedItemCoupons(cartItemLine, couponWalletItems, autoUseCoupon,
|
|
|
7203
7739
|
exist = {
|
|
7204
7740
|
coupons: [],
|
|
7205
7741
|
product: w.product,
|
|
7206
|
-
productCode
|
|
7742
|
+
productCode,
|
|
7207
7743
|
usedQty: (usedCoupons[productCode] || []).length
|
|
7208
7744
|
}
|
|
7209
7745
|
acc.push(exist)
|
|
@@ -7225,7 +7761,6 @@ function _getRelatedItemCoupons(cartItemLine, couponWalletItems, autoUseCoupon,
|
|
|
7225
7761
|
}, [])
|
|
7226
7762
|
}
|
|
7227
7763
|
|
|
7228
|
-
|
|
7229
7764
|
function _updateRelatedItemCoupons(line, couponWalletItems, autoUseCoupon, currencyCode) {
|
|
7230
7765
|
if (couponWalletItems.length > 0) {
|
|
7231
7766
|
line.relatedCoupons = _getRelatedItemCoupons(line, couponWalletItems, autoUseCoupon, currencyCode)
|
|
@@ -7234,9 +7769,6 @@ function _updateRelatedItemCoupons(line, couponWalletItems, autoUseCoupon, curre
|
|
|
7234
7769
|
|
|
7235
7770
|
|
|
7236
7771
|
|
|
7237
|
-
|
|
7238
|
-
|
|
7239
|
-
|
|
7240
7772
|
;// ./lib/eventManager/chains/index.js
|
|
7241
7773
|
|
|
7242
7774
|
|
|
@@ -7252,7 +7784,6 @@ function _updateRelatedItemCoupons(line, couponWalletItems, autoUseCoupon, curre
|
|
|
7252
7784
|
|
|
7253
7785
|
|
|
7254
7786
|
;// ./lib/helpers/corHelper/chainException.js
|
|
7255
|
-
|
|
7256
7787
|
class ChainException {
|
|
7257
7788
|
constructor() {
|
|
7258
7789
|
this.result = {}
|
|
@@ -7381,7 +7912,6 @@ class ChainTargetCalculateAmount extends ChainTarget {
|
|
|
7381
7912
|
|
|
7382
7913
|
;// ./lib/helpers/corHelper/chainManager.js
|
|
7383
7914
|
|
|
7384
|
-
|
|
7385
7915
|
// import { ChainResult } from './chainResult.js'
|
|
7386
7916
|
// import { makeChainsFactory } from './helpers.js'
|
|
7387
7917
|
|
|
@@ -7538,7 +8068,10 @@ function _calculateAmountChainsFactory(payload) {
|
|
|
7538
8068
|
new ChainMerchandiseLimit(),
|
|
7539
8069
|
new ChainProductLimit({ products }),
|
|
7540
8070
|
new ChainGetPrice({
|
|
7541
|
-
currency,
|
|
8071
|
+
currency,
|
|
8072
|
+
dateTime,
|
|
8073
|
+
entitlements,
|
|
8074
|
+
merchandises
|
|
7542
8075
|
}),
|
|
7543
8076
|
new ChainRelatedCoupons({ currency, autoUseCoupon, walletItems }),
|
|
7544
8077
|
new ChainPriceAdjustment({ currency }),
|
|
@@ -7558,7 +8091,10 @@ function _calculateAmountChainsFactoryforGroup(payload) {
|
|
|
7558
8091
|
new ChainMerchandiseLimit(),
|
|
7559
8092
|
new ChainProductLimit({ products }),
|
|
7560
8093
|
new ChainGetPriceForGroup({
|
|
7561
|
-
currency,
|
|
8094
|
+
currency,
|
|
8095
|
+
dateTime,
|
|
8096
|
+
entitlements,
|
|
8097
|
+
merchandises
|
|
7562
8098
|
}),
|
|
7563
8099
|
]
|
|
7564
8100
|
}
|
|
@@ -7701,9 +8237,9 @@ function getRolesChangesRelatedCouponsHelper({ newRoles, originalRoles }) {
|
|
|
7701
8237
|
...Object.keys(couponFromOriginalRoles)
|
|
7702
8238
|
])
|
|
7703
8239
|
return Array.from(allKeys).reduce((acc, key) => {
|
|
7704
|
-
const newValue = couponFromNewRoles[key] || 0
|
|
7705
|
-
const originalValue = couponFromOriginalRoles[key] || 0
|
|
7706
|
-
const delta = newValue - originalValue
|
|
8240
|
+
const newValue = couponFromNewRoles[key] || 0
|
|
8241
|
+
const originalValue = couponFromOriginalRoles[key] || 0
|
|
8242
|
+
const delta = newValue - originalValue
|
|
7707
8243
|
if (delta !== 0) {
|
|
7708
8244
|
acc.push({
|
|
7709
8245
|
key,
|
|
@@ -7712,13 +8248,12 @@ function getRolesChangesRelatedCouponsHelper({ newRoles, originalRoles }) {
|
|
|
7712
8248
|
newValue,
|
|
7713
8249
|
originalValue
|
|
7714
8250
|
}
|
|
7715
|
-
})
|
|
8251
|
+
})
|
|
7716
8252
|
}
|
|
7717
8253
|
return acc
|
|
7718
8254
|
}, [])
|
|
7719
8255
|
}
|
|
7720
8256
|
|
|
7721
|
-
|
|
7722
8257
|
function _getCouponsByRoles(roles) {
|
|
7723
8258
|
return roles.reduce((acc, role) => {
|
|
7724
8259
|
const couponCodes = role.getCouponCodes()
|
|
@@ -7769,19 +8304,18 @@ class CouponManager {
|
|
|
7769
8304
|
return getRolesChangesRelatedCouponsHelper({ newRoles: this.newRoles, originalRoles: this.originalRoles })
|
|
7770
8305
|
}
|
|
7771
8306
|
|
|
7772
|
-
|
|
7773
8307
|
get couponItemList() {
|
|
7774
8308
|
return this.couponProducts.map((p) => {
|
|
7775
8309
|
const relatedWalletItems = this.walletItems.filter(
|
|
7776
|
-
item => item.productCode === p.productCode
|
|
8310
|
+
(item) => item.productCode === p.productCode
|
|
7777
8311
|
)
|
|
7778
8312
|
|
|
7779
|
-
const usedCoupons = relatedWalletItems.filter(item => item.isUsed)
|
|
8313
|
+
const usedCoupons = relatedWalletItems.filter((item) => item.isUsed)
|
|
7780
8314
|
usedCoupons.forEach((c) => {
|
|
7781
8315
|
c.useForWalletItems = this.walletItems.filter((item) => (c.useFor || []).includes(item.walletItemCode)) // useFor
|
|
7782
8316
|
})
|
|
7783
8317
|
|
|
7784
|
-
const availableCoupons = relatedWalletItems.filter(item => !item.isAvailableCoupon)
|
|
8318
|
+
const availableCoupons = relatedWalletItems.filter((item) => !item.isAvailableCoupon)
|
|
7785
8319
|
|
|
7786
8320
|
const roleBase = q_utilities_namespaceObject.KeyValueObject.foundValueByKey(this.roleRelatedCoupons, p.productCode) || {}
|
|
7787
8321
|
|
|
@@ -7799,19 +8333,17 @@ class CouponManager {
|
|
|
7799
8333
|
qty,
|
|
7800
8334
|
roleBase,
|
|
7801
8335
|
remarks
|
|
7802
|
-
}
|
|
8336
|
+
}
|
|
7803
8337
|
})
|
|
7804
8338
|
}
|
|
7805
8339
|
|
|
7806
8340
|
setNewRoles() {
|
|
7807
8341
|
this.newRoles = newRoles
|
|
7808
8342
|
}
|
|
7809
|
-
|
|
7810
8343
|
}
|
|
7811
8344
|
|
|
7812
8345
|
|
|
7813
8346
|
|
|
7814
|
-
|
|
7815
8347
|
function _handler({ product, remainingQuota, availableCoupons, roleBase }) {
|
|
7816
8348
|
const { delta = 0 } = roleBase
|
|
7817
8349
|
const { maxPerWallet } = product
|
|
@@ -7852,7 +8384,7 @@ class Handler {
|
|
|
7852
8384
|
|
|
7853
8385
|
|
|
7854
8386
|
class HandlerMinutes extends Handler {
|
|
7855
|
-
process(dateFormat) {
|
|
8387
|
+
process(dateFormat) {
|
|
7856
8388
|
const mthIdx = this.date.getMinutes()
|
|
7857
8389
|
dateFormat = dateFormat.replace('mm', zeroPadding(mthIdx)) // 23-03-10 17:mm
|
|
7858
8390
|
return dateFormat
|
|
@@ -7861,7 +8393,7 @@ class HandlerMinutes extends Handler {
|
|
|
7861
8393
|
|
|
7862
8394
|
function zeroPadding(num) {
|
|
7863
8395
|
if (typeof num !== 'number') {
|
|
7864
|
-
throw new
|
|
8396
|
+
throw new TypeError('Parameter must be of number')
|
|
7865
8397
|
}
|
|
7866
8398
|
return num < 10 ? `0${num}` : `${num}`
|
|
7867
8399
|
}
|
|
@@ -7872,7 +8404,7 @@ function zeroPadding(num) {
|
|
|
7872
8404
|
|
|
7873
8405
|
|
|
7874
8406
|
class HandlerHours extends Handler {
|
|
7875
|
-
process(dateFormat) {
|
|
8407
|
+
process(dateFormat) {
|
|
7876
8408
|
const hthIdx = this.date.getHours()
|
|
7877
8409
|
dateFormat = dateFormat.replace('HH', handlerHours_zeroPadding(hthIdx)) // 23-03-10 HH
|
|
7878
8410
|
return dateFormat
|
|
@@ -7881,7 +8413,7 @@ class HandlerHours extends Handler {
|
|
|
7881
8413
|
|
|
7882
8414
|
function handlerHours_zeroPadding(num) {
|
|
7883
8415
|
if (typeof num !== 'number') {
|
|
7884
|
-
throw new
|
|
8416
|
+
throw new TypeError('Parameter must be of number')
|
|
7885
8417
|
}
|
|
7886
8418
|
return num < 10 ? `0${num}` : `${num}`
|
|
7887
8419
|
}
|
|
@@ -7892,7 +8424,7 @@ function handlerHours_zeroPadding(num) {
|
|
|
7892
8424
|
|
|
7893
8425
|
|
|
7894
8426
|
class HandlerDate extends Handler {
|
|
7895
|
-
process(dateFormat) {
|
|
8427
|
+
process(dateFormat) {
|
|
7896
8428
|
const dthIdx = this.date.getDate()
|
|
7897
8429
|
dateFormat = dateFormat.replace('dd', handlerDate_zeroPadding(dthIdx)) // 23-03-dd
|
|
7898
8430
|
return dateFormat
|
|
@@ -7901,7 +8433,7 @@ class HandlerDate extends Handler {
|
|
|
7901
8433
|
|
|
7902
8434
|
function handlerDate_zeroPadding(num) {
|
|
7903
8435
|
if (typeof num !== 'number') {
|
|
7904
|
-
throw new
|
|
8436
|
+
throw new TypeError('Parameter must be of number')
|
|
7905
8437
|
}
|
|
7906
8438
|
return num < 10 ? `0${num}` : `${num}`
|
|
7907
8439
|
}
|
|
@@ -7923,7 +8455,7 @@ class HandlerMonth extends Handler {
|
|
|
7923
8455
|
|
|
7924
8456
|
function handlerMonth_zeroPadding(num) {
|
|
7925
8457
|
if (typeof num !== 'number') {
|
|
7926
|
-
throw new
|
|
8458
|
+
throw new TypeError('Parameter must be of number')
|
|
7927
8459
|
}
|
|
7928
8460
|
return num < 10 ? `0${num}` : `${num}`
|
|
7929
8461
|
}
|
|
@@ -7993,7 +8525,6 @@ function convert(date, dateFormat) {
|
|
|
7993
8525
|
|
|
7994
8526
|
|
|
7995
8527
|
|
|
7996
|
-
|
|
7997
8528
|
;// ./lib/helpers/ordersList/orderList.js
|
|
7998
8529
|
|
|
7999
8530
|
|
|
@@ -8060,7 +8591,6 @@ function actionBuilder(row, header, qRow) {
|
|
|
8060
8591
|
onClick: orderList_self.onOrderListAction('waived')
|
|
8061
8592
|
})
|
|
8062
8593
|
}
|
|
8063
|
-
|
|
8064
8594
|
}
|
|
8065
8595
|
actions.push({
|
|
8066
8596
|
css: {
|
|
@@ -8086,11 +8616,13 @@ function qListArr(originMerchandises, originInvoices) {
|
|
|
8086
8616
|
}
|
|
8087
8617
|
return {
|
|
8088
8618
|
...acc,
|
|
8089
|
-
amount: i.amount && i.amount.value
|
|
8090
|
-
|
|
8091
|
-
|
|
8092
|
-
|
|
8093
|
-
|
|
8619
|
+
amount: i.amount && i.amount.value
|
|
8620
|
+
? i.amount
|
|
8621
|
+
: {
|
|
8622
|
+
value: acc.amount.value + l.amount.value * l.qty,
|
|
8623
|
+
currencyCode: l.amount.currencyCode,
|
|
8624
|
+
default: acc.amount.default && l.amount.default
|
|
8625
|
+
},
|
|
8094
8626
|
}
|
|
8095
8627
|
}, {
|
|
8096
8628
|
amount: {
|
|
@@ -8120,7 +8652,8 @@ function qListArr(originMerchandises, originInvoices) {
|
|
|
8120
8652
|
|
|
8121
8653
|
function formatStatus(status) {
|
|
8122
8654
|
let newStatus = ''
|
|
8123
|
-
if (!(status instanceof Status))
|
|
8655
|
+
if (!(status instanceof Status))
|
|
8656
|
+
return newStatus
|
|
8124
8657
|
if (status.isCancelled) {
|
|
8125
8658
|
newStatus = 'cancelled'
|
|
8126
8659
|
return newStatus
|
|
@@ -8159,7 +8692,13 @@ function handlerHeaders(defaultHeaders) {
|
|
|
8159
8692
|
}
|
|
8160
8693
|
|
|
8161
8694
|
function handlerOrderList({
|
|
8162
|
-
component,
|
|
8695
|
+
component,
|
|
8696
|
+
config,
|
|
8697
|
+
merchandises,
|
|
8698
|
+
invoices,
|
|
8699
|
+
defaultHeaders,
|
|
8700
|
+
isAdmin,
|
|
8701
|
+
label = {}
|
|
8163
8702
|
}) {
|
|
8164
8703
|
orderList_self = component
|
|
8165
8704
|
_config = config
|
|
@@ -8183,7 +8722,6 @@ function handlerOrderList({
|
|
|
8183
8722
|
|
|
8184
8723
|
|
|
8185
8724
|
|
|
8186
|
-
|
|
8187
8725
|
;// ./lib/helpers/sortHelper/defaultSort.js
|
|
8188
8726
|
function defaultSort(arr, getKey) {
|
|
8189
8727
|
if (!getKey) {
|
|
@@ -8192,7 +8730,7 @@ function defaultSort(arr, getKey) {
|
|
|
8192
8730
|
let key = null
|
|
8193
8731
|
switch (typeof getKey) {
|
|
8194
8732
|
case 'function':
|
|
8195
|
-
arr.forEach(ele => { key = getKey(ele) })
|
|
8733
|
+
arr.forEach((ele) => { key = getKey(ele) })
|
|
8196
8734
|
if (key.length === 0) {
|
|
8197
8735
|
return arr
|
|
8198
8736
|
}
|
|
@@ -8211,9 +8749,9 @@ function defaultSort(arr, getKey) {
|
|
|
8211
8749
|
|
|
8212
8750
|
;// ./lib/helpers/sortHelper/isAllEqual.js
|
|
8213
8751
|
function isAllEqual({ arr = [], key }) {
|
|
8214
|
-
const [
|
|
8752
|
+
const [firstElem] = arr
|
|
8215
8753
|
const compareValue = firstElem[key]
|
|
8216
|
-
return arr.every(a => a[key] === compareValue)
|
|
8754
|
+
return arr.every((a) => a[key] === compareValue)
|
|
8217
8755
|
}
|
|
8218
8756
|
|
|
8219
8757
|
|
|
@@ -8238,7 +8776,6 @@ function isDescendingOrder({ arr = [], key }) {
|
|
|
8238
8776
|
|
|
8239
8777
|
|
|
8240
8778
|
|
|
8241
|
-
|
|
8242
8779
|
;// ./lib/helpers/index.js
|
|
8243
8780
|
|
|
8244
8781
|
|
|
@@ -8253,6 +8790,7 @@ function isDescendingOrder({ arr = [], key }) {
|
|
|
8253
8790
|
|
|
8254
8791
|
;// ./lib/index.js
|
|
8255
8792
|
|
|
8793
|
+
|
|
8256
8794
|
const models = models_namespaceObject
|
|
8257
8795
|
|
|
8258
8796
|
|