@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
|
@@ -88,6 +88,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
88
88
|
// EXPORTS
|
|
89
89
|
__webpack_require__.d(__webpack_exports__, {
|
|
90
90
|
Amount: () => (/* reexport */ Amount),
|
|
91
|
+
BillingAccount: () => (/* reexport */ BillingAccount),
|
|
92
|
+
BillingProject: () => (/* reexport */ BillingProject),
|
|
91
93
|
Cart: () => (/* reexport */ Cart),
|
|
92
94
|
CartItem: () => (/* reexport */ CartItem),
|
|
93
95
|
Category: () => (/* reexport */ Category),
|
|
@@ -108,13 +110,18 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
108
110
|
Merchandise: () => (/* reexport */ Merchandise),
|
|
109
111
|
Order: () => (/* reexport */ Order),
|
|
110
112
|
OrderLine: () => (/* reexport */ OrderLine),
|
|
113
|
+
PaymentCharge: () => (/* reexport */ PaymentCharge),
|
|
111
114
|
PaymentGateway: () => (/* reexport */ PaymentGateway),
|
|
115
|
+
PaymentItem: () => (/* reexport */ PaymentItem),
|
|
112
116
|
PaymentResult: () => (/* reexport */ PaymentResult),
|
|
113
117
|
Price: () => (/* reexport */ Price),
|
|
114
118
|
PriceStrategy: () => (/* reexport */ PriceStrategy),
|
|
115
119
|
Product: () => (/* reexport */ Product),
|
|
120
|
+
Receipt: () => (/* reexport */ Receipt),
|
|
121
|
+
ReceiptLine: () => (/* reexport */ ReceiptLine),
|
|
116
122
|
Status: () => (/* reexport */ Status),
|
|
117
123
|
StatusQStore: () => (/* reexport */ StatusQStore),
|
|
124
|
+
StatusQStoreInvoice: () => (/* reexport */ StatusQStoreInvoice),
|
|
118
125
|
StatusQStoreOrderLine: () => (/* reexport */ StatusQStoreOrderLine),
|
|
119
126
|
StoreItem: () => (/* reexport */ StoreItem),
|
|
120
127
|
Transaction: () => (/* reexport */ Transaction),
|
|
@@ -147,6 +154,8 @@ var models_namespaceObject = {};
|
|
|
147
154
|
__webpack_require__.r(models_namespaceObject);
|
|
148
155
|
__webpack_require__.d(models_namespaceObject, {
|
|
149
156
|
Amount: () => (Amount),
|
|
157
|
+
BillingAccount: () => (BillingAccount),
|
|
158
|
+
BillingProject: () => (BillingProject),
|
|
150
159
|
Cart: () => (Cart),
|
|
151
160
|
CartItem: () => (CartItem),
|
|
152
161
|
Category: () => (Category),
|
|
@@ -162,13 +171,18 @@ __webpack_require__.d(models_namespaceObject, {
|
|
|
162
171
|
Merchandise: () => (Merchandise),
|
|
163
172
|
Order: () => (Order),
|
|
164
173
|
OrderLine: () => (OrderLine),
|
|
174
|
+
PaymentCharge: () => (PaymentCharge),
|
|
165
175
|
PaymentGateway: () => (PaymentGateway),
|
|
176
|
+
PaymentItem: () => (PaymentItem),
|
|
166
177
|
PaymentResult: () => (PaymentResult),
|
|
167
178
|
Price: () => (Price),
|
|
168
179
|
PriceStrategy: () => (PriceStrategy),
|
|
169
180
|
Product: () => (Product),
|
|
181
|
+
Receipt: () => (Receipt),
|
|
182
|
+
ReceiptLine: () => (ReceiptLine),
|
|
170
183
|
Status: () => (Status),
|
|
171
184
|
StatusQStore: () => (StatusQStore),
|
|
185
|
+
StatusQStoreInvoice: () => (StatusQStoreInvoice),
|
|
172
186
|
StatusQStoreOrderLine: () => (StatusQStoreOrderLine),
|
|
173
187
|
StoreItem: () => (StoreItem),
|
|
174
188
|
Transaction: () => (Transaction),
|
|
@@ -223,7 +237,7 @@ class Amount {
|
|
|
223
237
|
|
|
224
238
|
// getters
|
|
225
239
|
get isValid() {
|
|
226
|
-
return typeof this.currencyCode === 'string' && !!this.currencyCode && typeof this.value === 'number'
|
|
240
|
+
return typeof this.currencyCode === 'string' && !!this.currencyCode && typeof this.value === 'number'
|
|
227
241
|
}
|
|
228
242
|
|
|
229
243
|
// instance methods
|
|
@@ -253,14 +267,150 @@ class Amount {
|
|
|
253
267
|
|
|
254
268
|
|
|
255
269
|
|
|
256
|
-
|
|
257
270
|
// EXTERNAL MODULE: external "@questwork/q-utilities"
|
|
258
271
|
var q_utilities_ = __webpack_require__(898);
|
|
272
|
+
;// ./lib/models/billingAccount/billingAccount.js
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
const updateAllowedProps = [
|
|
276
|
+
'name',
|
|
277
|
+
]
|
|
278
|
+
|
|
279
|
+
class BillingAccount extends q_utilities_.TenantAwareEntity {
|
|
280
|
+
constructor(options) {
|
|
281
|
+
options = options || {}
|
|
282
|
+
super(options)
|
|
283
|
+
|
|
284
|
+
const id = options._id || options.id
|
|
285
|
+
this.id = setId(id)
|
|
286
|
+
this._type = options._type || 'BillingAccount'
|
|
287
|
+
this.billingAccountCode = options.billingAccountCode
|
|
288
|
+
this.name = options.name
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
static dummyData() {
|
|
292
|
+
return {
|
|
293
|
+
tenantCode: 'tenantCode'
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
static get _classname() {
|
|
298
|
+
return 'BillingAccount'
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
static get _superclass() {
|
|
302
|
+
return 'BillingAccount'
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// get isValid() {
|
|
306
|
+
// return super.isValid
|
|
307
|
+
// }
|
|
308
|
+
|
|
309
|
+
update(obj) {
|
|
310
|
+
Object.keys(obj).forEach((key) => {
|
|
311
|
+
if (updateAllowedProps.includes(key)) {
|
|
312
|
+
this[key] = obj[key]
|
|
313
|
+
}
|
|
314
|
+
})
|
|
315
|
+
return super.update(obj)
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
// function setCode(options, key) {
|
|
320
|
+
// const copyOptions = options || {}
|
|
321
|
+
// if (copyOptions[key]) {
|
|
322
|
+
// return copyOptions[key]
|
|
323
|
+
// }
|
|
324
|
+
// return stringHelper.setCode()
|
|
325
|
+
// }
|
|
326
|
+
|
|
327
|
+
function setId(id) {
|
|
328
|
+
if (id && typeof id.toString === 'function') {
|
|
329
|
+
return id.toString()
|
|
330
|
+
}
|
|
331
|
+
return id
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
;// ./lib/models/billingAccount/index.js
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
;// ./lib/models/billingProject/billingProject.js
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
const billingProject_updateAllowedProps = [
|
|
345
|
+
'name',
|
|
346
|
+
]
|
|
347
|
+
|
|
348
|
+
class BillingProject extends q_utilities_.TenantAwareEntity {
|
|
349
|
+
constructor(options) {
|
|
350
|
+
options = options || {}
|
|
351
|
+
super(options)
|
|
352
|
+
|
|
353
|
+
const id = options._id || options.id
|
|
354
|
+
this.id = billingProject_setId(id)
|
|
355
|
+
this._type = options._type || 'BillingProject'
|
|
356
|
+
this.billingProjectCode = options.billingProjectCode
|
|
357
|
+
this.name = options.name
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
static dummyData() {
|
|
361
|
+
return {
|
|
362
|
+
tenantCode: 'tenantCode'
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
static get _classname() {
|
|
367
|
+
return 'BillingProject'
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
static get _superclass() {
|
|
371
|
+
return 'BillingProject'
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
// get isValid() {
|
|
375
|
+
// return super.isValid
|
|
376
|
+
// }
|
|
377
|
+
|
|
378
|
+
update(obj) {
|
|
379
|
+
Object.keys(obj).forEach((key) => {
|
|
380
|
+
if (billingProject_updateAllowedProps.includes(key)) {
|
|
381
|
+
this[key] = obj[key]
|
|
382
|
+
}
|
|
383
|
+
})
|
|
384
|
+
return super.update(obj)
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
// function setCode(options, key) {
|
|
389
|
+
// const copyOptions = options || {}
|
|
390
|
+
// if (copyOptions[key]) {
|
|
391
|
+
// return copyOptions[key]
|
|
392
|
+
// }
|
|
393
|
+
// return stringHelper.setCode()
|
|
394
|
+
// }
|
|
395
|
+
|
|
396
|
+
function billingProject_setId(id) {
|
|
397
|
+
if (id && typeof id.toString === 'function') {
|
|
398
|
+
return id.toString()
|
|
399
|
+
}
|
|
400
|
+
return id
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
|
|
404
|
+
|
|
405
|
+
;// ./lib/models/billingProject/index.js
|
|
406
|
+
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
|
|
259
410
|
// EXTERNAL MODULE: external "lodash"
|
|
260
411
|
var external_lodash_ = __webpack_require__(773);
|
|
261
412
|
;// ./lib/models/itemOptionFillIn/itemOptionFillIn.js
|
|
262
|
-
|
|
263
|
-
const updateAllowedProps = [
|
|
413
|
+
const itemOptionFillIn_updateAllowedProps = [
|
|
264
414
|
'value'
|
|
265
415
|
]
|
|
266
416
|
|
|
@@ -329,7 +479,7 @@ class ItemOptionFillIn {
|
|
|
329
479
|
|
|
330
480
|
update(update) {
|
|
331
481
|
Object.keys(update).forEach((key) => {
|
|
332
|
-
if (
|
|
482
|
+
if (itemOptionFillIn_updateAllowedProps.includes(key)) {
|
|
333
483
|
this[key] = update[key]
|
|
334
484
|
}
|
|
335
485
|
})
|
|
@@ -468,7 +618,7 @@ function eleInArrayComparator(target, compare, prop) {
|
|
|
468
618
|
return false
|
|
469
619
|
}
|
|
470
620
|
if (!Array.isArray(target[prop]) && !Array.isArray(compare[prop])) {
|
|
471
|
-
throw new
|
|
621
|
+
throw new TypeError('This function can only compare array.')
|
|
472
622
|
}
|
|
473
623
|
return checkDuplicateHelper_lodash.intersection(target[prop], compare[prop]) > 0
|
|
474
624
|
}
|
|
@@ -478,7 +628,7 @@ function eleAllInArrayComparator(target, compare, prop) {
|
|
|
478
628
|
return false
|
|
479
629
|
}
|
|
480
630
|
if (!Array.isArray(target[prop]) && !Array.isArray(compare[prop])) {
|
|
481
|
-
throw new
|
|
631
|
+
throw new TypeError('This function can only compare array.')
|
|
482
632
|
}
|
|
483
633
|
return checkDuplicateHelper_lodash.intersection(target[prop], compare[prop]) === target[prop].length
|
|
484
634
|
}
|
|
@@ -488,11 +638,12 @@ function eleOrderInArrayComparator(target, compare, prop) {
|
|
|
488
638
|
return false
|
|
489
639
|
}
|
|
490
640
|
if (!Array.isArray(target[prop]) && !Array.isArray(compare[prop])) {
|
|
491
|
-
throw new
|
|
641
|
+
throw new TypeError('This function can only compare array.')
|
|
492
642
|
}
|
|
493
643
|
return target[prop].reduce((acc, item, index) => {
|
|
494
644
|
const res = item === compare[prop][index]
|
|
495
|
-
if (acc === null)
|
|
645
|
+
if (acc === null)
|
|
646
|
+
return res
|
|
496
647
|
return res && acc
|
|
497
648
|
}, null)
|
|
498
649
|
}
|
|
@@ -509,12 +660,14 @@ function objectInArrayComparator(target, compare, prop) {
|
|
|
509
660
|
return false
|
|
510
661
|
}
|
|
511
662
|
if (!Array.isArray(target[prop]) && !Array.isArray(compare[prop])) {
|
|
512
|
-
throw new
|
|
663
|
+
throw new TypeError('This function can only compare array.')
|
|
513
664
|
}
|
|
514
665
|
return target[prop].reduce((acc, item) => {
|
|
515
|
-
if (acc === true)
|
|
666
|
+
if (acc === true)
|
|
667
|
+
return acc
|
|
516
668
|
const res = item.isSameIn(compare[prop])
|
|
517
|
-
if (acc === null)
|
|
669
|
+
if (acc === null)
|
|
670
|
+
return res
|
|
518
671
|
return res || acc
|
|
519
672
|
}, null)
|
|
520
673
|
}
|
|
@@ -524,11 +677,12 @@ function objectAllInArrayComparator(target, compare, prop) {
|
|
|
524
677
|
return false
|
|
525
678
|
}
|
|
526
679
|
if (!Array.isArray(target[prop]) && !Array.isArray(compare[prop])) {
|
|
527
|
-
throw new
|
|
680
|
+
throw new TypeError('This function can only compare array.')
|
|
528
681
|
}
|
|
529
682
|
return target[prop].reduce((acc, item) => {
|
|
530
683
|
const res = item.isSameIn(compare[prop])
|
|
531
|
-
if (acc === null)
|
|
684
|
+
if (acc === null)
|
|
685
|
+
return res
|
|
532
686
|
return res && acc
|
|
533
687
|
}, null)
|
|
534
688
|
}
|
|
@@ -538,14 +692,15 @@ function objectOrderInArrayComparator(target, compare, prop) {
|
|
|
538
692
|
return false
|
|
539
693
|
}
|
|
540
694
|
if (!Array.isArray(target[prop]) && !Array.isArray(compare[prop])) {
|
|
541
|
-
throw new
|
|
695
|
+
throw new TypeError('This function can only compare array.')
|
|
542
696
|
}
|
|
543
697
|
if (target[prop].length !== compare[prop].length) {
|
|
544
698
|
return false
|
|
545
699
|
}
|
|
546
700
|
return target[prop].reduce((acc, item, index) => {
|
|
547
701
|
const res = item.isSame(compare[prop][index])
|
|
548
|
-
if (acc === null)
|
|
702
|
+
if (acc === null)
|
|
703
|
+
return res
|
|
549
704
|
return res && acc
|
|
550
705
|
}, null)
|
|
551
706
|
}
|
|
@@ -563,7 +718,6 @@ function _getBoolean(value1, value2, operation) {
|
|
|
563
718
|
|
|
564
719
|
|
|
565
720
|
;// ./lib/helpers/utilHelper/responseHelper.js
|
|
566
|
-
|
|
567
721
|
const LATEST_RESPONSE_OBJ_VERSION = '20200130'
|
|
568
722
|
|
|
569
723
|
const STANDARD_RESPONSE_OBJ_ARRAY = [
|
|
@@ -612,7 +766,8 @@ class ResponseHelper {
|
|
|
612
766
|
// private functions
|
|
613
767
|
|
|
614
768
|
function getStandardResponseObjByVersion(ver = LATEST_RESPONSE_OBJ_VERSION) {
|
|
615
|
-
if (!ver)
|
|
769
|
+
if (!ver)
|
|
770
|
+
return null
|
|
616
771
|
return STANDARD_RESPONSE_OBJ_ARRAY.find((obj) => (obj.version === ver))
|
|
617
772
|
}
|
|
618
773
|
|
|
@@ -620,18 +775,18 @@ function getStandardResponseObjByVersion(ver = LATEST_RESPONSE_OBJ_VERSION) {
|
|
|
620
775
|
|
|
621
776
|
function makeResponseHelper(options) {
|
|
622
777
|
const helper = new ResponseHelper(options)
|
|
623
|
-
if (!helper.isValid)
|
|
778
|
+
if (!helper.isValid)
|
|
779
|
+
throw new TypeError('Invalid options for responseHelper')
|
|
624
780
|
return helper
|
|
625
781
|
}
|
|
626
782
|
|
|
627
783
|
|
|
628
784
|
|
|
629
785
|
;// ./lib/helpers/utilHelper/setQuery.js
|
|
630
|
-
|
|
631
786
|
/**
|
|
632
787
|
* set up query with or without clientAppName
|
|
633
|
-
* @param {
|
|
634
|
-
* @returns {
|
|
788
|
+
* @param {object} ctx - koa context
|
|
789
|
+
* @returns {object} query
|
|
635
790
|
*/
|
|
636
791
|
function setQuery({ ctx, ids }) {
|
|
637
792
|
const { clientApp } = ctx.state
|
|
@@ -672,7 +827,6 @@ function setQuery({ ctx, ids }) {
|
|
|
672
827
|
|
|
673
828
|
|
|
674
829
|
|
|
675
|
-
|
|
676
830
|
;// ./lib/helpers/stringHelper/stringHelper.js
|
|
677
831
|
function baseXEncode(num, base = 34) {
|
|
678
832
|
const charset = getBaseCharset(base)
|
|
@@ -680,18 +834,18 @@ function baseXEncode(num, base = 34) {
|
|
|
680
834
|
}
|
|
681
835
|
|
|
682
836
|
function encode(int, charset) {
|
|
683
|
-
|
|
837
|
+
const byCode = charset.byCode
|
|
684
838
|
if (int === 0) {
|
|
685
|
-
|
|
839
|
+
return byCode[0]
|
|
686
840
|
}
|
|
687
841
|
|
|
688
|
-
|
|
689
|
-
|
|
842
|
+
let res = ''
|
|
843
|
+
const max = charset.length
|
|
690
844
|
while (int > 0) {
|
|
691
|
-
|
|
692
|
-
|
|
845
|
+
res = byCode[int % max] + res
|
|
846
|
+
int = Math.floor(int / max)
|
|
693
847
|
}
|
|
694
|
-
return res
|
|
848
|
+
return res
|
|
695
849
|
}
|
|
696
850
|
|
|
697
851
|
function getBaseCharset(base) {
|
|
@@ -703,16 +857,16 @@ function getBaseCharset(base) {
|
|
|
703
857
|
}
|
|
704
858
|
|
|
705
859
|
function indexCharset(str) {
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
860
|
+
const byCode = {}
|
|
861
|
+
const byChar = {}
|
|
862
|
+
const length = str.length
|
|
863
|
+
let i; let char
|
|
710
864
|
for (i = 0; i < length; i++) {
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
865
|
+
char = str[i]
|
|
866
|
+
byCode[i] = char
|
|
867
|
+
byChar[char] = i
|
|
714
868
|
}
|
|
715
|
-
return { byCode
|
|
869
|
+
return { byCode, byChar, length }
|
|
716
870
|
}
|
|
717
871
|
|
|
718
872
|
function randomString({ len = 16, pattern = 'a1' } = {}) {
|
|
@@ -734,7 +888,7 @@ function randomString({ len = 16, pattern = 'a1' } = {}) {
|
|
|
734
888
|
str += mark
|
|
735
889
|
}
|
|
736
890
|
const chars = [...str]
|
|
737
|
-
return [...Array(len)].map(i => {
|
|
891
|
+
return [...new Array(len)].map((i) => {
|
|
738
892
|
return chars[(Math.random() * chars.length) | 0]
|
|
739
893
|
}).join``
|
|
740
894
|
}
|
|
@@ -769,7 +923,6 @@ const stringHelper = {
|
|
|
769
923
|
|
|
770
924
|
|
|
771
925
|
|
|
772
|
-
|
|
773
926
|
;// ./lib/models/itemOption/itemOptionLocale.js
|
|
774
927
|
const itemOptionLocale_updateAllowedProps = [
|
|
775
928
|
'label',
|
|
@@ -1051,7 +1204,6 @@ class MerchandiseOption {
|
|
|
1051
1204
|
|
|
1052
1205
|
|
|
1053
1206
|
;// ./lib/models/qtyPerTransaction/qtyPerTransaction.js
|
|
1054
|
-
|
|
1055
1207
|
const qtyPerTransaction_updateAllowedProps = [
|
|
1056
1208
|
'min',
|
|
1057
1209
|
'max',
|
|
@@ -1109,7 +1261,6 @@ class QtyPerTransaction {
|
|
|
1109
1261
|
|
|
1110
1262
|
|
|
1111
1263
|
|
|
1112
|
-
|
|
1113
1264
|
const priceStrategy_updateAllowedProps = [
|
|
1114
1265
|
'active',
|
|
1115
1266
|
'amounts',
|
|
@@ -1329,7 +1480,7 @@ function matchAnd(key, value, payload) {
|
|
|
1329
1480
|
/**
|
|
1330
1481
|
* Check if a value matches a formula.
|
|
1331
1482
|
* @param {*} val - The value to check.
|
|
1332
|
-
* @param {
|
|
1483
|
+
* @param {object} [formula] - The formula object to check the value against.
|
|
1333
1484
|
* @returns {boolean} - Whether the value matches the formula.
|
|
1334
1485
|
*/
|
|
1335
1486
|
function _matcher(val, formula = {}, actions = [], match = true) {
|
|
@@ -1371,7 +1522,7 @@ function _match({ action, formulaValue, val }) {
|
|
|
1371
1522
|
}
|
|
1372
1523
|
return false
|
|
1373
1524
|
case '$includes':
|
|
1374
|
-
return val.includes(formulaValue)
|
|
1525
|
+
return val && val.includes(formulaValue)
|
|
1375
1526
|
case '$keyValue':
|
|
1376
1527
|
if (Array.isArray(val)) {
|
|
1377
1528
|
return (val.find((remark) => {
|
|
@@ -1480,8 +1631,6 @@ class Price {
|
|
|
1480
1631
|
// return prices.filter((price) => price.roleCodes.length === 0 || lodash.intersection(roleCodes, price.roleCodes).length > 0)
|
|
1481
1632
|
// }
|
|
1482
1633
|
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
1634
|
// getters
|
|
1486
1635
|
get isValid() {
|
|
1487
1636
|
return this.priceStrategies.length > 0
|
|
@@ -1623,7 +1772,7 @@ class Product extends q_utilities_.TenantAwareEntity {
|
|
|
1623
1772
|
this._ItemOption = _ItemOption && (_ItemOption._superclass === ItemOption) ? _ItemOption : ItemOption
|
|
1624
1773
|
|
|
1625
1774
|
const id = options._id || options.id
|
|
1626
|
-
this.id =
|
|
1775
|
+
this.id = product_setId(id)
|
|
1627
1776
|
this._type = options._type || 'Product'
|
|
1628
1777
|
|
|
1629
1778
|
this.couponDetails = options.couponDetails
|
|
@@ -1720,6 +1869,16 @@ class Product extends q_utilities_.TenantAwareEntity {
|
|
|
1720
1869
|
getCode() {
|
|
1721
1870
|
return this.productCode
|
|
1722
1871
|
}
|
|
1872
|
+
getPreservedData() {
|
|
1873
|
+
return {
|
|
1874
|
+
metadata: this.metadata,
|
|
1875
|
+
name: this.name,
|
|
1876
|
+
productCode: this.productCode,
|
|
1877
|
+
productGroupName: this.productGroupName,
|
|
1878
|
+
productType: this.productType,
|
|
1879
|
+
tenantCode: this.tenantCode,
|
|
1880
|
+
}
|
|
1881
|
+
}
|
|
1723
1882
|
getMetadataValueByKey(key) {
|
|
1724
1883
|
return q_utilities_.Metadata.getValueByKey(this.metadata || [], key)
|
|
1725
1884
|
}
|
|
@@ -1765,7 +1924,7 @@ class Product extends q_utilities_.TenantAwareEntity {
|
|
|
1765
1924
|
}
|
|
1766
1925
|
}
|
|
1767
1926
|
|
|
1768
|
-
function
|
|
1927
|
+
function product_setId(id) {
|
|
1769
1928
|
if (id && typeof id.toString === 'function') {
|
|
1770
1929
|
return id.toString()
|
|
1771
1930
|
}
|
|
@@ -1786,33 +1945,11 @@ function _getDataByKey(key, data) {
|
|
|
1786
1945
|
|
|
1787
1946
|
|
|
1788
1947
|
|
|
1789
|
-
;// ./lib/models/product/productRepo.js
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
class ProductRepo extends q_utilities_.Repo {
|
|
1794
|
-
constructor(options = {}) {
|
|
1795
|
-
options = options || {}
|
|
1796
|
-
super(options)
|
|
1797
|
-
const { _Product } = options._constructor || {}
|
|
1798
|
-
this._Product = _Product && (_Product._superclass === Product._superclass) ? _Product : Product
|
|
1799
|
-
}
|
|
1800
|
-
static get _classname() {
|
|
1801
|
-
return 'ProductRepo'
|
|
1802
|
-
}
|
|
1803
|
-
init(options) {
|
|
1804
|
-
return this._Product.init(options)
|
|
1805
|
-
}
|
|
1806
|
-
}
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
1948
|
;// ./lib/models/product/index.js
|
|
1811
1949
|
|
|
1812
1950
|
|
|
1813
1951
|
|
|
1814
1952
|
|
|
1815
|
-
|
|
1816
1953
|
;// ./lib/models/merchandise/merchandise.js
|
|
1817
1954
|
|
|
1818
1955
|
|
|
@@ -2027,13 +2164,13 @@ class Merchandise extends q_utilities_.TenantAwareEntity {
|
|
|
2027
2164
|
const _currencyCode = currency || this.defaultCurrency
|
|
2028
2165
|
const price = this.getPriceByTimeAndRoleCodes(dateTimestamp, roleCodes)
|
|
2029
2166
|
if (!price) {
|
|
2030
|
-
obj.errorMessages.push(
|
|
2167
|
+
obj.errorMessages.push('Can\'t get available price for you.')
|
|
2031
2168
|
return obj
|
|
2032
2169
|
}
|
|
2033
2170
|
obj.price = price
|
|
2034
2171
|
const priceStrategies = price.getStrategiesByCurrencyAndQty(_currencyCode, qty)
|
|
2035
2172
|
if (priceStrategies.length === 0) {
|
|
2036
|
-
obj.errorMessages.push(
|
|
2173
|
+
obj.errorMessages.push('Can\'t get available strategies from price.')
|
|
2037
2174
|
return obj
|
|
2038
2175
|
}
|
|
2039
2176
|
const { convertedPriceStrategies, maxQty } = priceStrategies.reduce((acc, priceStrategy) => {
|
|
@@ -2131,7 +2268,7 @@ class Merchandise extends q_utilities_.TenantAwareEntity {
|
|
|
2131
2268
|
getCode() {
|
|
2132
2269
|
return this.merchandiseCode
|
|
2133
2270
|
}
|
|
2134
|
-
getCurrentAmount({ currencyCode, payload, ignoreRestriction =
|
|
2271
|
+
getCurrentAmount({ currencyCode, payload, ignoreRestriction = false }) {
|
|
2135
2272
|
if (!this.currentPrice) {
|
|
2136
2273
|
return null
|
|
2137
2274
|
}
|
|
@@ -2185,6 +2322,16 @@ class Merchandise extends q_utilities_.TenantAwareEntity {
|
|
|
2185
2322
|
}
|
|
2186
2323
|
return null
|
|
2187
2324
|
}
|
|
2325
|
+
getPreservedData() {
|
|
2326
|
+
return {
|
|
2327
|
+
merchandiseCode: this.merchandiseCode,
|
|
2328
|
+
merchandiseType: this.merchandiseType,
|
|
2329
|
+
metadata: this.metadata,
|
|
2330
|
+
name: this.name,
|
|
2331
|
+
productCodes: this.productCodes,
|
|
2332
|
+
tenantCode: this.tenantCode,
|
|
2333
|
+
}
|
|
2334
|
+
}
|
|
2188
2335
|
getPrices() {
|
|
2189
2336
|
return this.prices ? this.prices : []
|
|
2190
2337
|
}
|
|
@@ -2282,34 +2429,11 @@ function merchandise_setId(id) {
|
|
|
2282
2429
|
|
|
2283
2430
|
|
|
2284
2431
|
|
|
2285
|
-
;// ./lib/models/merchandise/merchandiseRepo.js
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
class MerchandiseRepo extends q_utilities_.Repo {
|
|
2290
|
-
constructor(options = {}) {
|
|
2291
|
-
options = options || {}
|
|
2292
|
-
super(options)
|
|
2293
|
-
const { _Merchandise } = options._constructor || {}
|
|
2294
|
-
this._Merchandise = _Merchandise && (_Merchandise._superclass === Merchandise._superclass) ? _Merchandise : Merchandise
|
|
2295
|
-
}
|
|
2296
|
-
static get _classname() {
|
|
2297
|
-
return 'MerchandiseRepo'
|
|
2298
|
-
}
|
|
2299
|
-
init(options) {
|
|
2300
|
-
return this._Merchandise.init(options)
|
|
2301
|
-
}
|
|
2302
|
-
}
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
2432
|
;// ./lib/models/merchandise/index.js
|
|
2307
2433
|
|
|
2308
2434
|
|
|
2309
2435
|
|
|
2310
2436
|
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
2437
|
;// ./lib/models/cartItem/cartItem.js
|
|
2314
2438
|
|
|
2315
2439
|
|
|
@@ -2466,9 +2590,9 @@ function mergeDuplicateCartItems(cartItems, array = []) {
|
|
|
2466
2590
|
const { itemOptionFillIns } = item
|
|
2467
2591
|
const arr = external_lodash_.intersectionWith(itemOptionFillIns, cartItem.itemOptionFillIns, (obj1, obj2) => {
|
|
2468
2592
|
return obj1.target === obj2.target
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2593
|
+
&& obj1.targetCode === obj2.targetCode
|
|
2594
|
+
&& obj1.key === obj2.key
|
|
2595
|
+
&& external_lodash_.intersection(obj1.value, obj2.value).length === obj1.value.length
|
|
2472
2596
|
})
|
|
2473
2597
|
if (arr.length === itemOptionFillIns.length) {
|
|
2474
2598
|
acc.matched = item
|
|
@@ -2502,9 +2626,7 @@ function cartItem_setCode(options, key) {
|
|
|
2502
2626
|
|
|
2503
2627
|
|
|
2504
2628
|
|
|
2505
|
-
|
|
2506
2629
|
;// ./lib/models/status/status.js
|
|
2507
|
-
|
|
2508
2630
|
const notUpdateAllowedProps = [
|
|
2509
2631
|
'created',
|
|
2510
2632
|
]
|
|
@@ -2669,7 +2791,8 @@ class Status {
|
|
|
2669
2791
|
return keys.reduce((acc, key) => {
|
|
2670
2792
|
if (this[key]) {
|
|
2671
2793
|
acc.push({
|
|
2672
|
-
key,
|
|
2794
|
+
key,
|
|
2795
|
+
value: this[key]
|
|
2673
2796
|
})
|
|
2674
2797
|
}
|
|
2675
2798
|
return acc
|
|
@@ -2845,7 +2968,7 @@ class Cart extends q_utilities_.TenantAwareEntity {
|
|
|
2845
2968
|
|
|
2846
2969
|
this._merchandises = options._merchandises
|
|
2847
2970
|
this._type = options._type || 'Cart'
|
|
2848
|
-
|
|
2971
|
+
|
|
2849
2972
|
this.cartCode = cart_setCode(options, 'cartCode')
|
|
2850
2973
|
this.cartItems = this._CartItem.initOnlyValidFromArray(options.cartItems)
|
|
2851
2974
|
this.status = this._Status.init(options.status)
|
|
@@ -3109,35 +3232,11 @@ function cart_setId(id) {
|
|
|
3109
3232
|
|
|
3110
3233
|
|
|
3111
3234
|
|
|
3112
|
-
;// ./lib/models/cart/cartRepo.js
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
class CartRepo extends q_utilities_.Repo {
|
|
3117
|
-
constructor(options = {}) {
|
|
3118
|
-
options = options || {}
|
|
3119
|
-
super(options)
|
|
3120
|
-
const { _Cart } = options._constructor || {}
|
|
3121
|
-
this._Cart = _Cart && (_Cart._superclass === Cart._superclass)
|
|
3122
|
-
? _Cart
|
|
3123
|
-
: Cart
|
|
3124
|
-
}
|
|
3125
|
-
static get _classname() {
|
|
3126
|
-
return 'CartRepo'
|
|
3127
|
-
}
|
|
3128
|
-
init(options) {
|
|
3129
|
-
return this._Cart.init(options)
|
|
3130
|
-
}
|
|
3131
|
-
}
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
3235
|
;// ./lib/models/cart/index.js
|
|
3136
3236
|
|
|
3137
3237
|
|
|
3138
3238
|
|
|
3139
3239
|
|
|
3140
|
-
|
|
3141
3240
|
;// ./lib/models/category/category.js
|
|
3142
3241
|
|
|
3143
3242
|
|
|
@@ -3193,7 +3292,7 @@ class Category extends q_utilities_.TenantAwareEntity {
|
|
|
3193
3292
|
|
|
3194
3293
|
// getters
|
|
3195
3294
|
get isValid() {
|
|
3196
|
-
return super.isValid && !!this.name && this.max > this.
|
|
3295
|
+
return super.isValid && !!this.name && this.max > this.min
|
|
3197
3296
|
}
|
|
3198
3297
|
get products() {
|
|
3199
3298
|
return this._Product.initOnlyValidFromArray(this._products)
|
|
@@ -3227,36 +3326,11 @@ function category_setId(id) {
|
|
|
3227
3326
|
|
|
3228
3327
|
|
|
3229
3328
|
|
|
3230
|
-
;// ./lib/models/category/categoryRepo.js
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
class CategoryRepo extends q_utilities_.Repo {
|
|
3235
|
-
constructor(options = {}) {
|
|
3236
|
-
options = options || {}
|
|
3237
|
-
super(options)
|
|
3238
|
-
const { _Category } = options._constructor || {}
|
|
3239
|
-
this._Category = _Category && (_Category._superclass === Category._superclass)
|
|
3240
|
-
? _Category
|
|
3241
|
-
: Category
|
|
3242
|
-
}
|
|
3243
|
-
static get _classname() {
|
|
3244
|
-
return 'CategoryRepo'
|
|
3245
|
-
}
|
|
3246
|
-
init(options) {
|
|
3247
|
-
return this._Category.init(options)
|
|
3248
|
-
}
|
|
3249
|
-
}
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
3329
|
;// ./lib/models/category/index.js
|
|
3254
3330
|
|
|
3255
3331
|
|
|
3256
3332
|
|
|
3257
3333
|
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
3334
|
;// ./lib/models/creditNoteLine/creditNoteLine.js
|
|
3261
3335
|
|
|
3262
3336
|
|
|
@@ -3310,7 +3384,6 @@ class CreditNoteLine extends q_utilities_.TenantAwareEntity {
|
|
|
3310
3384
|
return 'CreditNoteLine'
|
|
3311
3385
|
}
|
|
3312
3386
|
|
|
3313
|
-
|
|
3314
3387
|
// getters
|
|
3315
3388
|
get isValid() {
|
|
3316
3389
|
return super.isValid && !!this.creditNoteCode
|
|
@@ -3358,35 +3431,11 @@ function creditNoteLine_setId(id) {
|
|
|
3358
3431
|
|
|
3359
3432
|
|
|
3360
3433
|
|
|
3361
|
-
;// ./lib/models/creditNoteLine/creditNoteLineRepo.js
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
class CreditNoteLineRepo extends q_utilities_.Repo {
|
|
3366
|
-
constructor(options = {}) {
|
|
3367
|
-
options = options || {}
|
|
3368
|
-
super(options)
|
|
3369
|
-
const { _CreditNoteLine } = options._constructor || {}
|
|
3370
|
-
this._CreditNoteLine = _CreditNoteLine && (_CreditNoteLine._superclass === CreditNoteLine._superclass)
|
|
3371
|
-
? _CreditNoteLine
|
|
3372
|
-
: CreditNoteLine
|
|
3373
|
-
}
|
|
3374
|
-
static get _classname() {
|
|
3375
|
-
return 'CreditNoteLineRepo'
|
|
3376
|
-
}
|
|
3377
|
-
init(options) {
|
|
3378
|
-
return this._CreditNoteLine.init(options)
|
|
3379
|
-
}
|
|
3380
|
-
}
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
3434
|
;// ./lib/models/creditNoteLine/index.js
|
|
3385
3435
|
|
|
3386
3436
|
|
|
3387
3437
|
|
|
3388
3438
|
|
|
3389
|
-
|
|
3390
3439
|
;// ./lib/models/creditNote/creditNote.js
|
|
3391
3440
|
|
|
3392
3441
|
|
|
@@ -3394,7 +3443,6 @@ class CreditNoteLineRepo extends q_utilities_.Repo {
|
|
|
3394
3443
|
|
|
3395
3444
|
|
|
3396
3445
|
|
|
3397
|
-
|
|
3398
3446
|
const creditNote_updateAllowedProps = [
|
|
3399
3447
|
'description',
|
|
3400
3448
|
'status'
|
|
@@ -3544,7 +3592,6 @@ class CreditNoteRepo extends q_utilities_.Repo {
|
|
|
3544
3592
|
|
|
3545
3593
|
|
|
3546
3594
|
|
|
3547
|
-
|
|
3548
3595
|
const currency_updateAllowedProps = [
|
|
3549
3596
|
'description',
|
|
3550
3597
|
'name',
|
|
@@ -3623,36 +3670,11 @@ function currency_setId(id) {
|
|
|
3623
3670
|
|
|
3624
3671
|
|
|
3625
3672
|
|
|
3626
|
-
;// ./lib/models/currency/currencyRepo.js
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
class CurrencyRepo extends q_utilities_.Repo {
|
|
3631
|
-
constructor(options = {}) {
|
|
3632
|
-
options = options || {}
|
|
3633
|
-
super(options)
|
|
3634
|
-
const { _Currency } = options._constructor || {}
|
|
3635
|
-
this._Currency = _Currency && (_Currency._superclass === Currency._superclass)
|
|
3636
|
-
? _Currency
|
|
3637
|
-
: Currency
|
|
3638
|
-
}
|
|
3639
|
-
static get _classname() {
|
|
3640
|
-
return 'CurrencyRepo'
|
|
3641
|
-
}
|
|
3642
|
-
init(options) {
|
|
3643
|
-
return this._Currency.init(options)
|
|
3644
|
-
}
|
|
3645
|
-
}
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
3673
|
;// ./lib/models/currency/index.js
|
|
3650
3674
|
|
|
3651
3675
|
|
|
3652
3676
|
|
|
3653
3677
|
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
3678
|
;// ./lib/helpers/getPurchaseOptionValue/getPurchaseOptionValue.js
|
|
3657
3679
|
function getPurchaseOptionValue(options) {
|
|
3658
3680
|
const {
|
|
@@ -3664,7 +3686,9 @@ function getPurchaseOptionValue(options) {
|
|
|
3664
3686
|
if (!key) {
|
|
3665
3687
|
return purchaseOptions.reduce((acc, purchaseOption) => {
|
|
3666
3688
|
const arr = _getOnePurchaseOptionValue({
|
|
3667
|
-
delimiter,
|
|
3689
|
+
delimiter,
|
|
3690
|
+
purchaseOption,
|
|
3691
|
+
tag
|
|
3668
3692
|
})
|
|
3669
3693
|
if (tag) {
|
|
3670
3694
|
acc.push(`<${tag}>${arr.join('')}</${tag}>`)
|
|
@@ -3681,7 +3705,9 @@ function getPurchaseOptionValue(options) {
|
|
|
3681
3705
|
return []
|
|
3682
3706
|
}
|
|
3683
3707
|
return _getOnePurchaseOptionValue({
|
|
3684
|
-
delimiter,
|
|
3708
|
+
delimiter,
|
|
3709
|
+
purchaseOption,
|
|
3710
|
+
tag
|
|
3685
3711
|
})
|
|
3686
3712
|
}
|
|
3687
3713
|
|
|
@@ -3721,6 +3747,784 @@ function _getOnePurchaseOptionValue({
|
|
|
3721
3747
|
|
|
3722
3748
|
|
|
3723
3749
|
|
|
3750
|
+
;// ./lib/models/paymentGateway/paymentGateway.js
|
|
3751
|
+
|
|
3752
|
+
|
|
3753
|
+
|
|
3754
|
+
|
|
3755
|
+
const paymentGateway_updateAllowedProps = [
|
|
3756
|
+
'label',
|
|
3757
|
+
'logoUrl',
|
|
3758
|
+
'name',
|
|
3759
|
+
'sandbox',
|
|
3760
|
+
'setting',
|
|
3761
|
+
'surchargeBillingAccountCode',
|
|
3762
|
+
'surchargeBillingProjectCode',
|
|
3763
|
+
'surcharges'
|
|
3764
|
+
]
|
|
3765
|
+
|
|
3766
|
+
class PaymentGateway extends q_utilities_.TenantAwareEntity {
|
|
3767
|
+
constructor(options = {}) {
|
|
3768
|
+
options = options || {}
|
|
3769
|
+
super(options) // a paymentGateway may also store 'ADDITIONALFIELDS' and 'RESTRICTIONS into metadata
|
|
3770
|
+
|
|
3771
|
+
const { _Price } = options._constructor || {}
|
|
3772
|
+
this._Price = _Price && (_Price._superclass === Price._superclass) ? _Price : Price
|
|
3773
|
+
|
|
3774
|
+
const id = options._id || options.id
|
|
3775
|
+
this.id = paymentGateway_setId(id)
|
|
3776
|
+
this._type = options._type || 'PaymentGateway'
|
|
3777
|
+
|
|
3778
|
+
this.hasWebhook = options.hasWebhook || false
|
|
3779
|
+
this.label = options.label
|
|
3780
|
+
this.logoUrl = options.logoUrl
|
|
3781
|
+
this.name = options.name || ''
|
|
3782
|
+
this.paymentGatewayCode = paymentGateway_setCode(options, 'paymentGatewayCode')
|
|
3783
|
+
this.paymentGatewayType = options.paymentGatewayType || 'PaymentGateway'
|
|
3784
|
+
this.paymentResultType = options.paymentResultType || 'PaymentResult'
|
|
3785
|
+
this.sandbox = options.sandbox || false
|
|
3786
|
+
this.setting = options.setting || null
|
|
3787
|
+
|
|
3788
|
+
this.surchargeBillingAccountCode = options.surchargeBillingAccountCode
|
|
3789
|
+
this.surchargeBillingProjectCode = options.surchargeBillingProjectCode
|
|
3790
|
+
this.surcharges = this._Price.initOnlyValidFromArray(options.surcharges)
|
|
3791
|
+
}
|
|
3792
|
+
static dummyData() {
|
|
3793
|
+
return {
|
|
3794
|
+
name: 'name',
|
|
3795
|
+
tenantCode: 'tenantCode'
|
|
3796
|
+
}
|
|
3797
|
+
}
|
|
3798
|
+
static get _classname() {
|
|
3799
|
+
return 'PaymentGateway'
|
|
3800
|
+
}
|
|
3801
|
+
static get _superclass() {
|
|
3802
|
+
return 'PaymentGateway'
|
|
3803
|
+
}
|
|
3804
|
+
|
|
3805
|
+
// getters
|
|
3806
|
+
get isValid() {
|
|
3807
|
+
return super.isValid && !!this.name
|
|
3808
|
+
}
|
|
3809
|
+
|
|
3810
|
+
// instance methods
|
|
3811
|
+
async createPayment() {
|
|
3812
|
+
throw new Error(`${this._classname} subclass should implement createPayment`)
|
|
3813
|
+
}
|
|
3814
|
+
async getAppPayParams() {
|
|
3815
|
+
throw new Error(`${this._classname} subclass should implement getAppPayParams`)
|
|
3816
|
+
}
|
|
3817
|
+
getCode() {
|
|
3818
|
+
return this.paymentGatewayCode
|
|
3819
|
+
}
|
|
3820
|
+
async updatePayment() {
|
|
3821
|
+
throw new Error(`${this._classname} subclass should implement updatePayment`)
|
|
3822
|
+
}
|
|
3823
|
+
async query() {
|
|
3824
|
+
throw new Error(`${this._classname} subclass should implement query`)
|
|
3825
|
+
}
|
|
3826
|
+
async submit() {
|
|
3827
|
+
throw new Error(`${this._classname} subclass should implement submit`)
|
|
3828
|
+
}
|
|
3829
|
+
|
|
3830
|
+
setCompletedRelatedStatus(status) {
|
|
3831
|
+
throw new Error(`${this.name} subclass should implement setCompletedRelatedStatus`)
|
|
3832
|
+
}
|
|
3833
|
+
update(update) {
|
|
3834
|
+
Object.keys(update).forEach((key) => {
|
|
3835
|
+
if (paymentGateway_updateAllowedProps.includes(key)) {
|
|
3836
|
+
if (key === 'surcharges') {
|
|
3837
|
+
this[key] = this._Price.initOnlyValidFromArray(update[key])
|
|
3838
|
+
} else {
|
|
3839
|
+
this[key] = update[key]
|
|
3840
|
+
}
|
|
3841
|
+
}
|
|
3842
|
+
})
|
|
3843
|
+
return super.update(update)
|
|
3844
|
+
}
|
|
3845
|
+
}
|
|
3846
|
+
|
|
3847
|
+
function paymentGateway_setCode(options, key) {
|
|
3848
|
+
const copyOptions = options || {}
|
|
3849
|
+
if (copyOptions[key]) {
|
|
3850
|
+
return copyOptions[key]
|
|
3851
|
+
}
|
|
3852
|
+
return stringHelper.setCode()
|
|
3853
|
+
}
|
|
3854
|
+
|
|
3855
|
+
function paymentGateway_setId(id) {
|
|
3856
|
+
if (id && typeof id.toString === 'function') {
|
|
3857
|
+
return id.toString()
|
|
3858
|
+
}
|
|
3859
|
+
return id
|
|
3860
|
+
}
|
|
3861
|
+
|
|
3862
|
+
|
|
3863
|
+
|
|
3864
|
+
;// ./lib/models/paymentGateway/index.js
|
|
3865
|
+
|
|
3866
|
+
|
|
3867
|
+
|
|
3868
|
+
|
|
3869
|
+
;// ./lib/models/statusQStore/statusQStore.js
|
|
3870
|
+
|
|
3871
|
+
|
|
3872
|
+
const statusQStore_notUpdateAllowedProps = (/* unused pure expression or super */ null && ([
|
|
3873
|
+
]))
|
|
3874
|
+
|
|
3875
|
+
class StatusQStore extends q_utilities_.Status {
|
|
3876
|
+
constructor(options) {
|
|
3877
|
+
options = options || {}
|
|
3878
|
+
super(options)
|
|
3879
|
+
|
|
3880
|
+
this.cancelled = this._ActionRecord.init(options.cancelled)
|
|
3881
|
+
this.completed = this._ActionRecord.init(options.completed)
|
|
3882
|
+
this.confirmed = this._ActionRecord.init(options.confirmed)
|
|
3883
|
+
this.deleted = this._ActionRecord.init(options.deleted)
|
|
3884
|
+
this.terminated = this._ActionRecord.init(options.terminated)
|
|
3885
|
+
}
|
|
3886
|
+
|
|
3887
|
+
static get _classname() {
|
|
3888
|
+
return 'StatusQStore'
|
|
3889
|
+
}
|
|
3890
|
+
get _classname() {
|
|
3891
|
+
return 'StatusQStore'
|
|
3892
|
+
}
|
|
3893
|
+
get isCancelled() {
|
|
3894
|
+
return this.cancelled?.timestamp > 0
|
|
3895
|
+
}
|
|
3896
|
+
get isCompleted() {
|
|
3897
|
+
return this.completed?.timestamp > 0
|
|
3898
|
+
}
|
|
3899
|
+
get isConfirmed() {
|
|
3900
|
+
return this.confirmed?.timestamp > 0
|
|
3901
|
+
}
|
|
3902
|
+
get isDeleted() {
|
|
3903
|
+
return this.deleted?.timestamp > 0
|
|
3904
|
+
}
|
|
3905
|
+
get isTerminated() {
|
|
3906
|
+
return this.terminated?.timestamp > 0
|
|
3907
|
+
}
|
|
3908
|
+
get isValid() {
|
|
3909
|
+
return super.isValid
|
|
3910
|
+
}
|
|
3911
|
+
setCancelled(value, actorCode) {
|
|
3912
|
+
return this.setValue(value, actorCode, 'cancelled')
|
|
3913
|
+
}
|
|
3914
|
+
setCompleted(value, actorCode) {
|
|
3915
|
+
return this.setValue(value, actorCode, 'completed')
|
|
3916
|
+
}
|
|
3917
|
+
setConfirmed(value, actorCode) {
|
|
3918
|
+
return this.setValue(value, actorCode, 'confirmed')
|
|
3919
|
+
}
|
|
3920
|
+
setDeleted(value, actorCode) {
|
|
3921
|
+
return this.setValue(value, actorCode, 'deleted')
|
|
3922
|
+
}
|
|
3923
|
+
setTerminated(value, actorCode) {
|
|
3924
|
+
return this.setValue(value, actorCode, 'terminated')
|
|
3925
|
+
}
|
|
3926
|
+
// update(update) {
|
|
3927
|
+
// Object.keys(update).forEach((key) => {
|
|
3928
|
+
// if (!notUpdateAllowedProps.includes(key)) {
|
|
3929
|
+
// this[key] = this[key] instanceof this._ActionRecord ? this[key].update(update[key]) : this._ActionRecord.init(update[key])
|
|
3930
|
+
// }
|
|
3931
|
+
// })
|
|
3932
|
+
// return super.update(update)
|
|
3933
|
+
// }
|
|
3934
|
+
}
|
|
3935
|
+
|
|
3936
|
+
;// ./lib/models/statusQStore/statusQStoreInvoice.js
|
|
3937
|
+
|
|
3938
|
+
|
|
3939
|
+
// const notUpdateAllowedProps = [
|
|
3940
|
+
// ]
|
|
3941
|
+
|
|
3942
|
+
class StatusQStoreInvoice extends StatusQStore {
|
|
3943
|
+
constructor(options) {
|
|
3944
|
+
options = options || {}
|
|
3945
|
+
super(options)
|
|
3946
|
+
|
|
3947
|
+
this.closed = this._ActionRecord.init(options.closed)
|
|
3948
|
+
this.open = this._ActionRecord.init(options.open)
|
|
3949
|
+
}
|
|
3950
|
+
|
|
3951
|
+
static get _classname() {
|
|
3952
|
+
return 'StatusQStoreInvoice'
|
|
3953
|
+
}
|
|
3954
|
+
get _classname() {
|
|
3955
|
+
return 'StatusQStoreInvoice'
|
|
3956
|
+
}
|
|
3957
|
+
get isClosed() {
|
|
3958
|
+
return this.closed?.timestamp > Date.now()
|
|
3959
|
+
}
|
|
3960
|
+
get isOpen() {
|
|
3961
|
+
return this.open?.timestamp > Date.now()
|
|
3962
|
+
}
|
|
3963
|
+
get isValid() {
|
|
3964
|
+
return super.isValid
|
|
3965
|
+
}
|
|
3966
|
+
setClosed(value, actorCode) {
|
|
3967
|
+
return this.setValue(value, actorCode, 'closed')
|
|
3968
|
+
}
|
|
3969
|
+
setOpen(value, actorCode) {
|
|
3970
|
+
return this.setValue(value, actorCode, 'open')
|
|
3971
|
+
}
|
|
3972
|
+
}
|
|
3973
|
+
|
|
3974
|
+
;// ./lib/models/statusQStore/statusQStoreOrderLine.js
|
|
3975
|
+
|
|
3976
|
+
|
|
3977
|
+
const statusQStoreOrderLine_notUpdateAllowedProps = (/* unused pure expression or super */ null && ([
|
|
3978
|
+
]))
|
|
3979
|
+
|
|
3980
|
+
class StatusQStoreOrderLine extends StatusQStore {
|
|
3981
|
+
constructor(options) {
|
|
3982
|
+
options = options || {}
|
|
3983
|
+
super(options)
|
|
3984
|
+
|
|
3985
|
+
this.expired = this._ActionRecord.init(options.expired)
|
|
3986
|
+
this.invalid = this._ActionRecord.init(options.invalid)
|
|
3987
|
+
}
|
|
3988
|
+
|
|
3989
|
+
static get _classname() {
|
|
3990
|
+
return 'StatusQStoreOrderLine'
|
|
3991
|
+
}
|
|
3992
|
+
get _classname() {
|
|
3993
|
+
return 'StatusQStoreOrderLine'
|
|
3994
|
+
}
|
|
3995
|
+
get isExpired() {
|
|
3996
|
+
return this.expired?.timestamp > Date.now()
|
|
3997
|
+
}
|
|
3998
|
+
get isInvalid() {
|
|
3999
|
+
return this.invalid?.timestamp > Date.now()
|
|
4000
|
+
}
|
|
4001
|
+
get isValid() {
|
|
4002
|
+
return super.isValid
|
|
4003
|
+
}
|
|
4004
|
+
setExpired(value, actorCode) {
|
|
4005
|
+
return this.setValue(value, actorCode, 'expired')
|
|
4006
|
+
}
|
|
4007
|
+
setInvalid(value, actorCode) {
|
|
4008
|
+
return this.setValue(value, actorCode, 'invalid')
|
|
4009
|
+
}
|
|
4010
|
+
// update(update) {
|
|
4011
|
+
// Object.keys(update).forEach((key) => {
|
|
4012
|
+
// if (!notUpdateAllowedProps.includes(key)) {
|
|
4013
|
+
// this[key] = this[key] instanceof this._ActionRecord ? this[key].update(update[key]) : this._ActionRecord.init(update[key])
|
|
4014
|
+
// }
|
|
4015
|
+
// })
|
|
4016
|
+
// return super.update(update)
|
|
4017
|
+
// }
|
|
4018
|
+
}
|
|
4019
|
+
|
|
4020
|
+
;// ./lib/models/statusQStore/index.js
|
|
4021
|
+
|
|
4022
|
+
|
|
4023
|
+
|
|
4024
|
+
|
|
4025
|
+
|
|
4026
|
+
|
|
4027
|
+
;// ./lib/models/paymentCharge/paymentCharge.js
|
|
4028
|
+
|
|
4029
|
+
|
|
4030
|
+
|
|
4031
|
+
|
|
4032
|
+
|
|
4033
|
+
|
|
4034
|
+
const paymentCharge_updateAllowedProps = [
|
|
4035
|
+
'amount',
|
|
4036
|
+
]
|
|
4037
|
+
|
|
4038
|
+
class PaymentCharge extends q_utilities_.TenantAwareEntity {
|
|
4039
|
+
constructor(options) {
|
|
4040
|
+
options = options || {}
|
|
4041
|
+
super(options)
|
|
4042
|
+
|
|
4043
|
+
const { _Amount, _PaymentGateway, _Receipt, _ReceiptLine } = options._constructor || {}
|
|
4044
|
+
this._Amount = _Amount && (_Amount._superclass === Amount._superclass) ? _Amount : Amount
|
|
4045
|
+
this._PaymentGateway = _PaymentGateway && (_PaymentGateway._superclass === PaymentGateway._superclass) ? _PaymentGateway : PaymentGateway
|
|
4046
|
+
this._Receipt = _Receipt && (_Receipt._superclass === Receipt._superclass) ? _Receipt : Receipt
|
|
4047
|
+
this._ReceiptLine = _ReceiptLine && (_ReceiptLine._superclass === ReceiptLine._superclass) ? _ReceiptLine : ReceiptLine
|
|
4048
|
+
|
|
4049
|
+
this._paymentGateway = options._paymentGateway
|
|
4050
|
+
this._receipt = options._receipt
|
|
4051
|
+
this._receiptLine = options._receiptLine
|
|
4052
|
+
|
|
4053
|
+
const id = options._id || options.id
|
|
4054
|
+
this.id = paymentCharge_setId(id)
|
|
4055
|
+
this._type = options._type || 'PaymentCharge'
|
|
4056
|
+
this.amount = this._Amount.init(options.amount)
|
|
4057
|
+
this.billingAccountCode = options.billingAccountCode
|
|
4058
|
+
this.billingProjectCode = options.billingProjectCode
|
|
4059
|
+
this.paymentGatewayCode = options.paymentGatewayCode
|
|
4060
|
+
this.paymentChargeCode = options.paymentChargeCode
|
|
4061
|
+
this.paymentChargeType = 'PaymentCharge'
|
|
4062
|
+
this.receiptCode = options.receiptCode
|
|
4063
|
+
this.receiptDate = options.receiptDate || (new Date()).valueOf()
|
|
4064
|
+
this.receiptLineCode = options.receiptLineCode
|
|
4065
|
+
// this.status = this._Status.init(options.status)
|
|
4066
|
+
}
|
|
4067
|
+
|
|
4068
|
+
static dummyData() {
|
|
4069
|
+
return {
|
|
4070
|
+
billingAccountCode: 'billingAccountCode',
|
|
4071
|
+
paymentGatewayCode: 'paymentGatewayCode',
|
|
4072
|
+
receiptCode: 'receiptCode',
|
|
4073
|
+
receiptLineCode: 'receiptLineCode',
|
|
4074
|
+
tenantCode: 'tenantCode'
|
|
4075
|
+
}
|
|
4076
|
+
}
|
|
4077
|
+
|
|
4078
|
+
static get _classname() {
|
|
4079
|
+
return 'PaymentCharge'
|
|
4080
|
+
}
|
|
4081
|
+
|
|
4082
|
+
static get _superclass() {
|
|
4083
|
+
return 'PaymentCharge'
|
|
4084
|
+
}
|
|
4085
|
+
|
|
4086
|
+
get isValid() {
|
|
4087
|
+
return super.isValid && !!this.billingAccountCode && !!this.paymentGatewayCode && !!this.receiptCode && !!this.receiptLineCode
|
|
4088
|
+
}
|
|
4089
|
+
|
|
4090
|
+
get paymentGateway() {
|
|
4091
|
+
return this._PaymentGateway.init(this._paymentGateway)
|
|
4092
|
+
}
|
|
4093
|
+
|
|
4094
|
+
get receipt() {
|
|
4095
|
+
return this._Receipt.init(this._receipt)
|
|
4096
|
+
}
|
|
4097
|
+
|
|
4098
|
+
get receiptLines() {
|
|
4099
|
+
return this._ReceiptLine.initOnlyValidFromArray(this._receiptLines || [])
|
|
4100
|
+
}
|
|
4101
|
+
|
|
4102
|
+
update(obj) {
|
|
4103
|
+
Object.keys(obj).forEach((key) => {
|
|
4104
|
+
if (paymentCharge_updateAllowedProps.includes(key)) {
|
|
4105
|
+
if (key === 'amount') {
|
|
4106
|
+
this[key] = this.amount instanceof this._Amount ? this.amount.update(obj[key]) : this._Amount.init(obj[key])
|
|
4107
|
+
} else {
|
|
4108
|
+
this[key] = obj[key]
|
|
4109
|
+
}
|
|
4110
|
+
}
|
|
4111
|
+
})
|
|
4112
|
+
return super.update(obj)
|
|
4113
|
+
}
|
|
4114
|
+
}
|
|
4115
|
+
|
|
4116
|
+
function paymentCharge_setId(id) {
|
|
4117
|
+
if (id && typeof id.toString === 'function') {
|
|
4118
|
+
return id.toString()
|
|
4119
|
+
}
|
|
4120
|
+
return id
|
|
4121
|
+
}
|
|
4122
|
+
|
|
4123
|
+
|
|
4124
|
+
|
|
4125
|
+
;// ./lib/models/paymentCharge/index.js
|
|
4126
|
+
|
|
4127
|
+
|
|
4128
|
+
|
|
4129
|
+
|
|
4130
|
+
;// ./lib/models/receiptLine/receiptLine.js
|
|
4131
|
+
|
|
4132
|
+
|
|
4133
|
+
|
|
4134
|
+
|
|
4135
|
+
|
|
4136
|
+
|
|
4137
|
+
|
|
4138
|
+
const receiptLine_updateAllowedProps = [
|
|
4139
|
+
'additionalData',
|
|
4140
|
+
'status',
|
|
4141
|
+
]
|
|
4142
|
+
|
|
4143
|
+
class ReceiptLine extends q_utilities_.TenantAwareEntity {
|
|
4144
|
+
constructor(options) {
|
|
4145
|
+
options = options || {}
|
|
4146
|
+
super(options)
|
|
4147
|
+
|
|
4148
|
+
const { _Amount, _PaymentCharge, _PaymentItem, _Receipt, _Status } = options._constructor || {}
|
|
4149
|
+
this._Amount = _Amount && (_Amount._superclass === Amount._superclass) ? _Amount : Amount
|
|
4150
|
+
this._PaymentCharge = _PaymentCharge && (_PaymentCharge._superclass === PaymentCharge._superclass) ? _PaymentCharge : PaymentCharge
|
|
4151
|
+
this._PaymentItem = _PaymentItem && (_PaymentItem._superclass === PaymentItem._superclass) ? _PaymentItem : PaymentItem
|
|
4152
|
+
this._Receipt = _Receipt && (_Receipt._superclass === Receipt._superclass) ? _Receipt : Receipt
|
|
4153
|
+
this._Status = _Status && (_Status._superclass === StatusQStore._superclass) ? _Status : StatusQStore
|
|
4154
|
+
|
|
4155
|
+
this._paymentCharge = options._paymentCharge
|
|
4156
|
+
this._paymentItems = options._paymentItems
|
|
4157
|
+
this._receipt = options._receipt
|
|
4158
|
+
|
|
4159
|
+
const id = options._id || options.id
|
|
4160
|
+
this.id = receiptLine_setId(id)
|
|
4161
|
+
this._type = options._type || 'ReceiptLine'
|
|
4162
|
+
this.additionalData = q_utilities_.KeyValueObject.initOnlyValidFromArray(options.additionalData)
|
|
4163
|
+
this.amount = this._Amount.init(options.amount)
|
|
4164
|
+
this.paidAmount = this._Amount.init(options.paidAmount)
|
|
4165
|
+
this.paymentGatewayCode = options.paymentGatewayCode
|
|
4166
|
+
this.receiptCode = options.receiptCode
|
|
4167
|
+
this.receiptDate = options.receiptDate || (new Date()).valueOf()
|
|
4168
|
+
this.receiptLineCode = options.receiptLineCode
|
|
4169
|
+
this.receiptLineType = 'ReceiptLine'
|
|
4170
|
+
this.status = this._Status.init(options.status)
|
|
4171
|
+
this.surcharge = this._Amount.init(options.surcharge)
|
|
4172
|
+
}
|
|
4173
|
+
|
|
4174
|
+
static dummyData() {
|
|
4175
|
+
return {
|
|
4176
|
+
receiptCode: 'receiptCode',
|
|
4177
|
+
tenantCode: 'tenantCode'
|
|
4178
|
+
}
|
|
4179
|
+
}
|
|
4180
|
+
|
|
4181
|
+
static get _classname() {
|
|
4182
|
+
return 'ReceiptLine'
|
|
4183
|
+
}
|
|
4184
|
+
|
|
4185
|
+
static get _superclass() {
|
|
4186
|
+
return 'ReceiptLine'
|
|
4187
|
+
}
|
|
4188
|
+
|
|
4189
|
+
get isCancelled() {
|
|
4190
|
+
return this.status.isCancelled
|
|
4191
|
+
}
|
|
4192
|
+
|
|
4193
|
+
get isCompleted() {
|
|
4194
|
+
return this.status.isCompleted
|
|
4195
|
+
}
|
|
4196
|
+
|
|
4197
|
+
get isConfirmed() {
|
|
4198
|
+
return this.status.isConfirmed
|
|
4199
|
+
}
|
|
4200
|
+
|
|
4201
|
+
get isTerminated() {
|
|
4202
|
+
return this.status.isTerminated
|
|
4203
|
+
}
|
|
4204
|
+
|
|
4205
|
+
get isValid() {
|
|
4206
|
+
return super.isValid && !!this.receiptCode
|
|
4207
|
+
}
|
|
4208
|
+
|
|
4209
|
+
get paymentCharge() {
|
|
4210
|
+
return this._PaymentCharge.init(this._paymentCharge)
|
|
4211
|
+
}
|
|
4212
|
+
get paymentItems() {
|
|
4213
|
+
return this._PaymentItem.initOnlyValidFromArray(this._paymentItems)
|
|
4214
|
+
}
|
|
4215
|
+
get receipt() {
|
|
4216
|
+
return this._Receipt.init(this._receipt)
|
|
4217
|
+
}
|
|
4218
|
+
|
|
4219
|
+
getAmount() {
|
|
4220
|
+
return this.amount
|
|
4221
|
+
}
|
|
4222
|
+
|
|
4223
|
+
setCancelled(value, actorCode) {
|
|
4224
|
+
this.status.setCancelled(value, actorCode)
|
|
4225
|
+
return this.setModified()
|
|
4226
|
+
}
|
|
4227
|
+
|
|
4228
|
+
setCompleted(value, actorCode) {
|
|
4229
|
+
this.status.setCompleted(value, actorCode)
|
|
4230
|
+
return this.setModified()
|
|
4231
|
+
}
|
|
4232
|
+
setConfirmed(value, actorCode) {
|
|
4233
|
+
this.status.setProcessing(value, actorCode)
|
|
4234
|
+
return this.setModified()
|
|
4235
|
+
}
|
|
4236
|
+
|
|
4237
|
+
setTerminated(value, actorCode) {
|
|
4238
|
+
this.status.setTerminated(value, actorCode)
|
|
4239
|
+
return this.setModified()
|
|
4240
|
+
}
|
|
4241
|
+
|
|
4242
|
+
update(obj) {
|
|
4243
|
+
Object.keys(obj).forEach((key) => {
|
|
4244
|
+
if (receiptLine_updateAllowedProps.includes(key)) {
|
|
4245
|
+
if (key === 'additionalData') {
|
|
4246
|
+
this[key] = q_utilities_.KeyValueObject.initOnlyValidFromArray(obj[key])
|
|
4247
|
+
} else if (key === 'status') {
|
|
4248
|
+
this[key] = this[key] instanceof this._Status ? this[key].update(obj[key]) : this._Status.init(obj[key])
|
|
4249
|
+
} else {
|
|
4250
|
+
this[key] = obj[key]
|
|
4251
|
+
}
|
|
4252
|
+
}
|
|
4253
|
+
})
|
|
4254
|
+
return super.update(obj)
|
|
4255
|
+
}
|
|
4256
|
+
}
|
|
4257
|
+
|
|
4258
|
+
function receiptLine_setId(id) {
|
|
4259
|
+
if (id && typeof id.toString === 'function') {
|
|
4260
|
+
return id.toString()
|
|
4261
|
+
}
|
|
4262
|
+
return id
|
|
4263
|
+
}
|
|
4264
|
+
|
|
4265
|
+
|
|
4266
|
+
|
|
4267
|
+
;// ./lib/models/receiptLine/index.js
|
|
4268
|
+
|
|
4269
|
+
|
|
4270
|
+
|
|
4271
|
+
|
|
4272
|
+
;// ./lib/models/receipt/receipt.js
|
|
4273
|
+
|
|
4274
|
+
|
|
4275
|
+
|
|
4276
|
+
|
|
4277
|
+
|
|
4278
|
+
const receipt_updateAllowedProps = [
|
|
4279
|
+
'status',
|
|
4280
|
+
]
|
|
4281
|
+
|
|
4282
|
+
class Receipt extends q_utilities_.TenantAwareEntity {
|
|
4283
|
+
constructor(options) {
|
|
4284
|
+
options = options || {}
|
|
4285
|
+
super(options)
|
|
4286
|
+
|
|
4287
|
+
const { _Amount, _ReceiptLine, _Status } = options._constructor || {}
|
|
4288
|
+
this._Amount = _Amount && (_Amount._superclass === Amount._superclass) ? _Amount : Amount
|
|
4289
|
+
this._ReceiptLine = _ReceiptLine && (_ReceiptLine._superclass === ReceiptLine._superclass) ? _ReceiptLine : ReceiptLine
|
|
4290
|
+
this._Status = _Status && (_Status._superclass === StatusQStore._superclass) ? _Status : StatusQStore
|
|
4291
|
+
|
|
4292
|
+
this._receiptLines = options._receiptLines
|
|
4293
|
+
|
|
4294
|
+
const id = options._id || options.id
|
|
4295
|
+
this.id = receipt_setId(id)
|
|
4296
|
+
this._type = options._type || 'Receipt'
|
|
4297
|
+
this.amount = this._Amount.init(options.amount)
|
|
4298
|
+
this.paidAmount = this._Amount.init(options.paidAmount)
|
|
4299
|
+
this.paymentGatewayCode = options.paymentGatewayCode
|
|
4300
|
+
this.receiptCode = options.receiptCode
|
|
4301
|
+
this.receiptDate = options.receiptDate || (new Date()).valueOf()
|
|
4302
|
+
this.receiptNumber = options.receiptNumber
|
|
4303
|
+
this.receiptType = 'Receipt'
|
|
4304
|
+
this.revisionNumber = options.revisionNumber || 1
|
|
4305
|
+
this.status = this._Status.init(options.status)
|
|
4306
|
+
this.surcharge = this._Amount.init(options.surcharge)
|
|
4307
|
+
}
|
|
4308
|
+
|
|
4309
|
+
static dummyData() {
|
|
4310
|
+
return {
|
|
4311
|
+
tenantCode: 'tenantCode'
|
|
4312
|
+
}
|
|
4313
|
+
}
|
|
4314
|
+
|
|
4315
|
+
static get _classname() {
|
|
4316
|
+
return 'Receipt'
|
|
4317
|
+
}
|
|
4318
|
+
|
|
4319
|
+
static get _superclass() {
|
|
4320
|
+
return 'Receipt'
|
|
4321
|
+
}
|
|
4322
|
+
|
|
4323
|
+
// get isValid() {
|
|
4324
|
+
// return super.isValid
|
|
4325
|
+
// }
|
|
4326
|
+
|
|
4327
|
+
get isCancelled() {
|
|
4328
|
+
return this.status.isCancelled
|
|
4329
|
+
}
|
|
4330
|
+
|
|
4331
|
+
get isCompleted() {
|
|
4332
|
+
return this.status.isCompleted
|
|
4333
|
+
}
|
|
4334
|
+
|
|
4335
|
+
get isConfirmed() {
|
|
4336
|
+
return this.status.isConfirmed
|
|
4337
|
+
}
|
|
4338
|
+
|
|
4339
|
+
get isTerminated() {
|
|
4340
|
+
return this.status.isTerminated
|
|
4341
|
+
}
|
|
4342
|
+
|
|
4343
|
+
get receiptLines() {
|
|
4344
|
+
return this._ReceiptLine.initOnlyValidFromArray(this._receiptLines || [])
|
|
4345
|
+
}
|
|
4346
|
+
|
|
4347
|
+
getAmount() {
|
|
4348
|
+
return this.amount
|
|
4349
|
+
}
|
|
4350
|
+
|
|
4351
|
+
getFullReceiptNumber(delimiter = '.') {
|
|
4352
|
+
return `${this.receiptNumber}${delimiter}${this.revisionNumber}`
|
|
4353
|
+
}
|
|
4354
|
+
|
|
4355
|
+
increaseRevisionNumber() {
|
|
4356
|
+
this.revisionNumber += 1
|
|
4357
|
+
return this
|
|
4358
|
+
}
|
|
4359
|
+
|
|
4360
|
+
setCancelled(value, actorCode) {
|
|
4361
|
+
this.status.setCancelled(value, actorCode)
|
|
4362
|
+
return this.setModified()
|
|
4363
|
+
}
|
|
4364
|
+
|
|
4365
|
+
setCompleted(value, actorCode) {
|
|
4366
|
+
this.status.setCompleted(value, actorCode)
|
|
4367
|
+
return this.setModified()
|
|
4368
|
+
}
|
|
4369
|
+
setConfirmed(value, actorCode) {
|
|
4370
|
+
this.status.setProcessing(value, actorCode)
|
|
4371
|
+
return this.setModified()
|
|
4372
|
+
}
|
|
4373
|
+
|
|
4374
|
+
setTerminated(value, actorCode) {
|
|
4375
|
+
this.status.setTerminated(value, actorCode)
|
|
4376
|
+
return this.setModified()
|
|
4377
|
+
}
|
|
4378
|
+
|
|
4379
|
+
update(obj) {
|
|
4380
|
+
Object.keys(obj).forEach((key) => {
|
|
4381
|
+
if (receipt_updateAllowedProps.includes(key)) {
|
|
4382
|
+
if (key === 'status') {
|
|
4383
|
+
this[key] = this.status instanceof this._Status ? this.status.update(obj[key]) : this._Status.init(obj[key])
|
|
4384
|
+
} else {
|
|
4385
|
+
this[key] = obj[key]
|
|
4386
|
+
}
|
|
4387
|
+
}
|
|
4388
|
+
})
|
|
4389
|
+
return super.update(obj)
|
|
4390
|
+
}
|
|
4391
|
+
}
|
|
4392
|
+
|
|
4393
|
+
function receipt_setId(id) {
|
|
4394
|
+
if (id && typeof id.toString === 'function') {
|
|
4395
|
+
return id.toString()
|
|
4396
|
+
}
|
|
4397
|
+
return id
|
|
4398
|
+
}
|
|
4399
|
+
|
|
4400
|
+
|
|
4401
|
+
|
|
4402
|
+
;// ./lib/models/receipt/index.js
|
|
4403
|
+
|
|
4404
|
+
|
|
4405
|
+
|
|
4406
|
+
|
|
4407
|
+
;// ./lib/models/paymentItem/paymentItem.js
|
|
4408
|
+
|
|
4409
|
+
|
|
4410
|
+
// import { StatusQStore } from '../statusQStore/index.js'
|
|
4411
|
+
|
|
4412
|
+
|
|
4413
|
+
|
|
4414
|
+
|
|
4415
|
+
|
|
4416
|
+
|
|
4417
|
+
const paymentItem_updateAllowedProps = [
|
|
4418
|
+
'amount',
|
|
4419
|
+
]
|
|
4420
|
+
|
|
4421
|
+
class PaymentItem extends q_utilities_.TenantAwareEntity {
|
|
4422
|
+
constructor(options) {
|
|
4423
|
+
options = options || {}
|
|
4424
|
+
super(options)
|
|
4425
|
+
|
|
4426
|
+
const { _Amount, _Invoice, _InvoiceLine, _PaymentGateway, _Receipt, _ReceiptLine } = options._constructor || {}
|
|
4427
|
+
this._Amount = _Amount && (_Amount._superclass === Amount._superclass) ? _Amount : Amount
|
|
4428
|
+
this._Invoice = _Invoice && (_Invoice._superclass === Invoice._superclass) ? _Invoice : Invoice
|
|
4429
|
+
this._InvoiceLine = _InvoiceLine && (_InvoiceLine._superclass === InvoiceLine._superclass) ? _InvoiceLine : InvoiceLine
|
|
4430
|
+
this._PaymentGateway = _PaymentGateway && (_PaymentGateway._superclass === PaymentGateway._superclass) ? _PaymentGateway : PaymentGateway
|
|
4431
|
+
this._Receipt = _Receipt && (_Receipt._superclass === Receipt._superclass) ? _Receipt : Receipt
|
|
4432
|
+
this._ReceiptLine = _ReceiptLine && (_ReceiptLine._superclass === ReceiptLine._superclass) ? _ReceiptLine : ReceiptLine
|
|
4433
|
+
// this._Status = _Status && (_Status._superclass === StatusQStore._superclass) ? _Status : StatusQStore
|
|
4434
|
+
|
|
4435
|
+
this._invoice = options._invoice
|
|
4436
|
+
this._invoiceLines = options._invoiceLines
|
|
4437
|
+
this._paymentGateway = options._paymentGateway
|
|
4438
|
+
this._receipt = options._receipt
|
|
4439
|
+
this._receiptLine = options._receiptLine
|
|
4440
|
+
|
|
4441
|
+
const id = options._id || options.id
|
|
4442
|
+
this.id = paymentItem_setId(id)
|
|
4443
|
+
this._type = options._type || 'PaymentItem'
|
|
4444
|
+
this.amount = this._Amount.init(options.amount)
|
|
4445
|
+
this.invoiceCode = options.invoiceCode
|
|
4446
|
+
this.invoiceDate = options.invoiceDate || (new Date()).valueOf()
|
|
4447
|
+
this.invoiceLineCode = options.invoiceLineCode
|
|
4448
|
+
this.paymentGatewayCode = options.paymentGatewayCode
|
|
4449
|
+
this.paymentItemCode = options.paymentItemCode
|
|
4450
|
+
this.paymentItemType = 'PaymentItem'
|
|
4451
|
+
this.receiptCode = options.receiptCode
|
|
4452
|
+
this.receiptDate = options.receiptDate || (new Date()).valueOf()
|
|
4453
|
+
this.receiptLineCode = options.receiptLineCode
|
|
4454
|
+
// this.status = this._Status.init(options.status)
|
|
4455
|
+
}
|
|
4456
|
+
|
|
4457
|
+
static dummyData() {
|
|
4458
|
+
return {
|
|
4459
|
+
invoiceCode: 'invoiceCode',
|
|
4460
|
+
invoiceLineCode: 'invoiceLineCode',
|
|
4461
|
+
paymentGatewayCode: 'paymentGatewayCode',
|
|
4462
|
+
receiptCode: 'receiptCode',
|
|
4463
|
+
receiptLineCode: 'receiptLineCode',
|
|
4464
|
+
tenantCode: 'tenantCode'
|
|
4465
|
+
}
|
|
4466
|
+
}
|
|
4467
|
+
|
|
4468
|
+
static get _classname() {
|
|
4469
|
+
return 'PaymentItem'
|
|
4470
|
+
}
|
|
4471
|
+
|
|
4472
|
+
static get _superclass() {
|
|
4473
|
+
return 'PaymentItem'
|
|
4474
|
+
}
|
|
4475
|
+
|
|
4476
|
+
get invoice() {
|
|
4477
|
+
return this._Invoice.init(this._invoice)
|
|
4478
|
+
}
|
|
4479
|
+
|
|
4480
|
+
get invoiceLines() {
|
|
4481
|
+
return this._InvoiceLine.initOnlyValidFromArray(this._invoiceLines || [])
|
|
4482
|
+
}
|
|
4483
|
+
|
|
4484
|
+
get isValid() {
|
|
4485
|
+
return super.isValid && !!this.invoiceCode && !!this.invoiceLineCode && !!this.paymentGatewayCode && !!this.receiptCode && !!this.receiptLineCode
|
|
4486
|
+
}
|
|
4487
|
+
|
|
4488
|
+
get paymentGateway() {
|
|
4489
|
+
return this._PaymentGateway.init(this._paymentGateway)
|
|
4490
|
+
}
|
|
4491
|
+
|
|
4492
|
+
get receipt() {
|
|
4493
|
+
return this._Receipt.init(this._receipt)
|
|
4494
|
+
}
|
|
4495
|
+
|
|
4496
|
+
get receiptLines() {
|
|
4497
|
+
return this._ReceiptLine.initOnlyValidFromArray(this._receiptLines || [])
|
|
4498
|
+
}
|
|
4499
|
+
|
|
4500
|
+
update(obj) {
|
|
4501
|
+
Object.keys(obj).forEach((key) => {
|
|
4502
|
+
if (paymentItem_updateAllowedProps.includes(key)) {
|
|
4503
|
+
if (key === 'amount') {
|
|
4504
|
+
this[key] = this.amount instanceof this._Amount ? this.amount.update(obj[key]) : this._Amount.init(obj[key])
|
|
4505
|
+
} else {
|
|
4506
|
+
this[key] = obj[key]
|
|
4507
|
+
}
|
|
4508
|
+
}
|
|
4509
|
+
})
|
|
4510
|
+
return super.update(obj)
|
|
4511
|
+
}
|
|
4512
|
+
}
|
|
4513
|
+
|
|
4514
|
+
function paymentItem_setId(id) {
|
|
4515
|
+
if (id && typeof id.toString === 'function') {
|
|
4516
|
+
return id.toString()
|
|
4517
|
+
}
|
|
4518
|
+
return id
|
|
4519
|
+
}
|
|
4520
|
+
|
|
4521
|
+
|
|
4522
|
+
|
|
4523
|
+
;// ./lib/models/paymentItem/index.js
|
|
4524
|
+
|
|
4525
|
+
|
|
4526
|
+
|
|
4527
|
+
|
|
3724
4528
|
;// ./lib/models/invoiceLine/invoiceLine.js
|
|
3725
4529
|
|
|
3726
4530
|
|
|
@@ -3730,12 +4534,15 @@ function _getOnePurchaseOptionValue({
|
|
|
3730
4534
|
|
|
3731
4535
|
|
|
3732
4536
|
|
|
4537
|
+
|
|
3733
4538
|
const invoiceLine_updateAllowedProps = [
|
|
3734
4539
|
'amount',
|
|
3735
4540
|
'deduction',
|
|
3736
4541
|
'description',
|
|
3737
4542
|
'discount',
|
|
4543
|
+
'invoiceDate',
|
|
3738
4544
|
'note',
|
|
4545
|
+
'outstanding',
|
|
3739
4546
|
'purchaseOptions',
|
|
3740
4547
|
'qty',
|
|
3741
4548
|
'unitPrice'
|
|
@@ -3746,14 +4553,16 @@ class InvoiceLine extends q_utilities_.TenantAwareEntity {
|
|
|
3746
4553
|
options = options || {}
|
|
3747
4554
|
super(options)
|
|
3748
4555
|
|
|
3749
|
-
const { _Amount, _Invoice, _Merchandise, _Status } = options._constructor || {}
|
|
4556
|
+
const { _Amount, _Invoice, _Merchandise, _PaymentItem, _Status } = options._constructor || {}
|
|
3750
4557
|
this._Amount = _Amount && (_Amount._superclass === Amount._superclass) ? _Amount : Amount
|
|
3751
4558
|
this._Invoice = _Invoice && (_Invoice._superclass === Invoice._superclass) ? _Invoice : Invoice
|
|
3752
4559
|
this._Merchandise = _Merchandise && (_Merchandise._superclass === Merchandise._superclass) ? _Merchandise : Merchandise
|
|
4560
|
+
this._PaymentItem = _PaymentItem && (_PaymentItem._superclass === PaymentItem._superclass) ? _PaymentItem : PaymentItem
|
|
3753
4561
|
this._Status = _Status && (_Status._superclass === Status._superclass) ? _Status : Status
|
|
3754
4562
|
|
|
3755
4563
|
this._invoice = options._invoice
|
|
3756
4564
|
this._merchandise = options._merchandise
|
|
4565
|
+
this._paymentItems = options._paymentItems
|
|
3757
4566
|
|
|
3758
4567
|
const id = options._id || options.id
|
|
3759
4568
|
this.id = invoiceLine_setId(id)
|
|
@@ -3763,10 +4572,12 @@ class InvoiceLine extends q_utilities_.TenantAwareEntity {
|
|
|
3763
4572
|
this.description = options.description
|
|
3764
4573
|
this.discount = options.discount || 0
|
|
3765
4574
|
this.invoiceCode = options.invoiceCode
|
|
4575
|
+
this.invoiceDate = options.invoiceDate || (new Date()).valueOf()
|
|
3766
4576
|
this.invoiceLineCode = invoiceLine_setCode(options, 'invoiceLineCode')
|
|
3767
4577
|
this.invoiceLineType = options.invoiceLineType || 'InvoiceLine'
|
|
3768
4578
|
this.merchandiseCode = options.merchandiseCode
|
|
3769
4579
|
this.note = options.note
|
|
4580
|
+
this.outstanding = this._Amount.init(options.outstanding)
|
|
3770
4581
|
this.purchaseOptions = q_utilities_.KeyValueObject.initOnlyValidFromArray(options.purchaseOptions)
|
|
3771
4582
|
this.qty = options.qty || 1
|
|
3772
4583
|
this.status = this._Status.init(options.status)
|
|
@@ -3799,7 +4610,9 @@ class InvoiceLine extends q_utilities_.TenantAwareEntity {
|
|
|
3799
4610
|
get merchandise() {
|
|
3800
4611
|
return this._Merchandise.init(this._merchandise)
|
|
3801
4612
|
}
|
|
3802
|
-
|
|
4613
|
+
get paymentItems() {
|
|
4614
|
+
return this._PaymentItem.initOnlyValidFromArray(this._paymentItems)
|
|
4615
|
+
}
|
|
3803
4616
|
get usedCoupons() {
|
|
3804
4617
|
const usedItemCoupons = q_utilities_.KeyValueObject.getValueByKey(this.remarks, 'USED_ITEM_COUPONS') || []
|
|
3805
4618
|
const usedTotalCoupons = q_utilities_.KeyValueObject.getValueByKey(this.remarks, 'USED_TOTAL_COUPONS') || []
|
|
@@ -3814,10 +4627,14 @@ class InvoiceLine extends q_utilities_.TenantAwareEntity {
|
|
|
3814
4627
|
purchaseOptions: this.purchaseOptions
|
|
3815
4628
|
})
|
|
3816
4629
|
}
|
|
4630
|
+
setCompleted(timestamp, actorCode) {
|
|
4631
|
+
this.status.setCompleted(timestamp, actorCode)
|
|
4632
|
+
return this.setModified()
|
|
4633
|
+
}
|
|
3817
4634
|
update(update) {
|
|
3818
4635
|
Object.keys(update).forEach((key) => {
|
|
3819
4636
|
if (invoiceLine_updateAllowedProps.includes(key)) {
|
|
3820
|
-
if (key === 'amount' || key === 'unitPrice' || key === 'deduction') {
|
|
4637
|
+
if (key === 'amount' || key === 'unitPrice' || key === 'deduction' || key === 'outstanding') {
|
|
3821
4638
|
this[key] = this._Amount.init(update[key])
|
|
3822
4639
|
} else if (key === 'purchaseOptions') {
|
|
3823
4640
|
this[key] = q_utilities_.KeyValueObject.initOnlyValidFromArray(update[key])
|
|
@@ -3828,6 +4645,23 @@ class InvoiceLine extends q_utilities_.TenantAwareEntity {
|
|
|
3828
4645
|
})
|
|
3829
4646
|
return super.update(update)
|
|
3830
4647
|
}
|
|
4648
|
+
updateOutstanding({ actorCode } = {}) {
|
|
4649
|
+
const paymentItems = this.paymentItems
|
|
4650
|
+
if (paymentItems.length === 0) {
|
|
4651
|
+
return this
|
|
4652
|
+
}
|
|
4653
|
+
const paid = paymentItems.reduce((acc, pi) => acc + (pi?.amount?.value || 0), 0)
|
|
4654
|
+
const value = this.amount.value - paid
|
|
4655
|
+
if (value <= 0) {
|
|
4656
|
+
this.setCompleted(Date.now(), actorCode)
|
|
4657
|
+
}
|
|
4658
|
+
return this.update({
|
|
4659
|
+
outstanding: {
|
|
4660
|
+
currencyCode: this.amount.currencyCode,
|
|
4661
|
+
value
|
|
4662
|
+
}
|
|
4663
|
+
})
|
|
4664
|
+
}
|
|
3831
4665
|
}
|
|
3832
4666
|
|
|
3833
4667
|
function invoiceLine_setCode(options, key) {
|
|
@@ -3847,36 +4681,12 @@ function invoiceLine_setId(id) {
|
|
|
3847
4681
|
|
|
3848
4682
|
|
|
3849
4683
|
|
|
3850
|
-
;// ./lib/models/invoiceLine/invoiceLineRepo.js
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
class InvoiceLineRepo extends q_utilities_.Repo {
|
|
3855
|
-
constructor(options = {}) {
|
|
3856
|
-
options = options || {}
|
|
3857
|
-
super(options)
|
|
3858
|
-
const { _InvoiceLine } = options._constructor || {}
|
|
3859
|
-
this._InvoiceLine = _InvoiceLine && (_InvoiceLine._superclass === InvoiceLine._superclass) ? _InvoiceLine : InvoiceLine
|
|
3860
|
-
}
|
|
3861
|
-
static get _classname() {
|
|
3862
|
-
return 'InvoiceLineRepo'
|
|
3863
|
-
}
|
|
3864
|
-
init(options) {
|
|
3865
|
-
return this._InvoiceLine.init(options)
|
|
3866
|
-
}
|
|
3867
|
-
}
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
4684
|
;// ./lib/models/invoiceLine/index.js
|
|
3872
4685
|
|
|
3873
4686
|
|
|
3874
4687
|
|
|
3875
4688
|
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
4689
|
;// ./lib/models/issuer/issuer.js
|
|
3879
|
-
|
|
3880
4690
|
class Issuer {
|
|
3881
4691
|
constructor(options = {}) {
|
|
3882
4692
|
options = options || {}
|
|
@@ -3938,6 +4748,7 @@ class Issuer {
|
|
|
3938
4748
|
|
|
3939
4749
|
|
|
3940
4750
|
|
|
4751
|
+
|
|
3941
4752
|
// import { Transaction } from '../transaction/index.js'
|
|
3942
4753
|
|
|
3943
4754
|
const walletItem_updateAllowedProps = [
|
|
@@ -3951,7 +4762,8 @@ class WalletItem extends q_utilities_.TenantAwareEntity {
|
|
|
3951
4762
|
options = options || {}
|
|
3952
4763
|
super(options)
|
|
3953
4764
|
|
|
3954
|
-
const { _Product, _Status } = options._constructor || {}
|
|
4765
|
+
const { _Amount, _Product, _Status } = options._constructor || {}
|
|
4766
|
+
this._Amount = _Amount && (_Amount._superclass === Amount._superclass) ? _Amount : Amount
|
|
3955
4767
|
this._Product = _Product && (_Product._superclass === Product._superclass) ? _Product : Product
|
|
3956
4768
|
this._Status = _Status && (_Status._superclass === Status._superclass) ? _Status : Status
|
|
3957
4769
|
// this._Transaction = _Transaction && (_Transaction._superclass === Transaction._superclass) ? _Transaction : Transaction
|
|
@@ -4081,18 +4893,30 @@ class WalletItem extends q_utilities_.TenantAwareEntity {
|
|
|
4081
4893
|
get displayPurchaseOptions() {
|
|
4082
4894
|
return this.purchaseOptions.length > 0
|
|
4083
4895
|
? this.purchaseOptions.reduce((acc, purchaseOption) => {
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
|
|
4087
|
-
|
|
4896
|
+
const { value } = purchaseOption
|
|
4897
|
+
return acc += value.reduce((_acc, item) => {
|
|
4898
|
+
const { label, value } = item
|
|
4899
|
+
return _acc += `<div><span>${label}: </span><span>${value}</span></div>`
|
|
4900
|
+
}, '')
|
|
4088
4901
|
}, '')
|
|
4089
|
-
}, '')
|
|
4090
4902
|
: ''
|
|
4091
4903
|
}
|
|
4092
4904
|
|
|
4093
4905
|
get lastRefundRejectedDetail() {
|
|
4094
4906
|
return Array.isArray(this.refundRejectedHistory) && this.refundRejectedHistory.length > 0 ? this.refundRejectedHistory[this.refundRejectedHistory.length - 1] : null
|
|
4095
4907
|
}
|
|
4908
|
+
get paid() {
|
|
4909
|
+
if (!this._transaction) {
|
|
4910
|
+
return null
|
|
4911
|
+
}
|
|
4912
|
+
const { amount, meta } = this._transaction
|
|
4913
|
+
return {
|
|
4914
|
+
created: meta.created,
|
|
4915
|
+
currencyCode: amount.currencyCode,
|
|
4916
|
+
modified: meta.modified,
|
|
4917
|
+
value: amount.value
|
|
4918
|
+
}
|
|
4919
|
+
}
|
|
4096
4920
|
|
|
4097
4921
|
get product() {
|
|
4098
4922
|
return this._Product.init(this._product)
|
|
@@ -4328,33 +5152,11 @@ function walletItem_setCode(options, key) {
|
|
|
4328
5152
|
|
|
4329
5153
|
|
|
4330
5154
|
|
|
4331
|
-
;// ./lib/models/walletItem/walletItemRepo.js
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
class WalletItemRepo extends q_utilities_.Repo {
|
|
4336
|
-
constructor(options = {}) {
|
|
4337
|
-
options = options || {}
|
|
4338
|
-
super(options)
|
|
4339
|
-
const { _WalletItem } = options._constructor || {}
|
|
4340
|
-
this._WalletItem = _WalletItem && (_WalletItem._superclass === WalletItem._superclass) ? _WalletItem : WalletItem
|
|
4341
|
-
}
|
|
4342
|
-
static get _classname() {
|
|
4343
|
-
return 'WalletItemRepo'
|
|
4344
|
-
}
|
|
4345
|
-
init(options) {
|
|
4346
|
-
return this._WalletItem.init(options)
|
|
4347
|
-
}
|
|
4348
|
-
}
|
|
4349
|
-
|
|
4350
|
-
|
|
4351
|
-
|
|
4352
5155
|
;// ./lib/models/walletItem/index.js
|
|
4353
5156
|
|
|
4354
5157
|
|
|
4355
5158
|
|
|
4356
5159
|
|
|
4357
|
-
|
|
4358
5160
|
;// ./lib/models/transaction/transaction.js
|
|
4359
5161
|
|
|
4360
5162
|
|
|
@@ -4679,34 +5481,11 @@ function transaction_setId(id) {
|
|
|
4679
5481
|
|
|
4680
5482
|
|
|
4681
5483
|
|
|
4682
|
-
;// ./lib/models/transaction/transactionRepo.js
|
|
4683
|
-
|
|
4684
|
-
|
|
4685
|
-
|
|
4686
|
-
class TransactionRepo extends q_utilities_.Repo {
|
|
4687
|
-
constructor(options = {}) {
|
|
4688
|
-
options = options || {}
|
|
4689
|
-
super(options)
|
|
4690
|
-
const { _Transaction } = options._constructor || {}
|
|
4691
|
-
this._Transaction = _Transaction && (_Transaction._superclass === Transaction._superclass) ? _Transaction : Transaction
|
|
4692
|
-
}
|
|
4693
|
-
static get _classname() {
|
|
4694
|
-
return 'TransactionRepo'
|
|
4695
|
-
}
|
|
4696
|
-
init(options) {
|
|
4697
|
-
return this._Transaction.init(options)
|
|
4698
|
-
}
|
|
4699
|
-
}
|
|
4700
|
-
|
|
4701
|
-
|
|
4702
|
-
|
|
4703
5484
|
;// ./lib/models/transaction/index.js
|
|
4704
5485
|
|
|
4705
5486
|
|
|
4706
5487
|
|
|
4707
5488
|
|
|
4708
|
-
|
|
4709
|
-
|
|
4710
5489
|
;// ./lib/models/invoice/invoice.js
|
|
4711
5490
|
|
|
4712
5491
|
|
|
@@ -4718,10 +5497,12 @@ class TransactionRepo extends q_utilities_.Repo {
|
|
|
4718
5497
|
|
|
4719
5498
|
|
|
4720
5499
|
const invoice_updateAllowedProps = [
|
|
5500
|
+
'billToUserCode',
|
|
4721
5501
|
'checkoutDateTime',
|
|
4722
5502
|
'description',
|
|
4723
5503
|
'invoiceDate',
|
|
4724
5504
|
'issuer',
|
|
5505
|
+
'outstanding',
|
|
4725
5506
|
'revisionNumber',
|
|
4726
5507
|
'status'
|
|
4727
5508
|
]
|
|
@@ -4729,24 +5510,27 @@ const invoice_updateAllowedProps = [
|
|
|
4729
5510
|
class Invoice extends q_utilities_.TenantAwareEntity {
|
|
4730
5511
|
constructor(options) {
|
|
4731
5512
|
options = options || {}
|
|
4732
|
-
super(options)
|
|
5513
|
+
super(options) // store the 'BUILDTOUSER' into invoice.metadata
|
|
4733
5514
|
|
|
4734
|
-
const { _Amount, _Cart, _InvoiceLine, _Issuer, _Status, _Transaction } = options._constructor || {}
|
|
5515
|
+
const { _Amount, _BillToUser, _Cart, _InvoiceLine, _Issuer, _Status, _Transaction } = options._constructor || {}
|
|
4735
5516
|
this._Amount = _Amount && (_Amount._superclass === Amount._superclass) ? _Amount : Amount
|
|
5517
|
+
this._BillToUser = _BillToUser
|
|
4736
5518
|
this._Cart = _Cart && (_Cart._superclass === Cart._superclass) ? _Cart : Cart
|
|
4737
5519
|
this._InvoiceLine = _InvoiceLine && (_InvoiceLine._superclass === InvoiceLine._superclass) ? _InvoiceLine : InvoiceLine
|
|
4738
5520
|
this._Issuer = _Issuer && (_Issuer._superclass === Issuer._superclass) ? _Issuer : Issuer
|
|
4739
5521
|
this._Status = _Status && (_Status._superclass === Status._superclass) ? _Status : Status
|
|
4740
5522
|
this._Transaction = _Transaction && (_Transaction._superclass === Transaction._superclass) ? _Transaction : Transaction
|
|
4741
5523
|
|
|
5524
|
+
this._billToUser = options._billToUser
|
|
4742
5525
|
this._cart = options._cart
|
|
4743
5526
|
this._invoiceLines = options._invoiceLines
|
|
4744
5527
|
this._transactions = options._transactions
|
|
4745
|
-
|
|
5528
|
+
|
|
4746
5529
|
const id = options._id || options.id
|
|
4747
5530
|
this.id = invoice_setId(id)
|
|
4748
5531
|
this._type = options._type || 'Invoice'
|
|
4749
5532
|
this.amount = this._Amount.init(options.amount)
|
|
5533
|
+
this.billToUserCode = options.billToUserCode // mainly for frontend populate
|
|
4750
5534
|
this.cartCode = options.cartCode
|
|
4751
5535
|
this.checkoutDateTime = options.checkoutDateTime || (new Date()).valueOf()
|
|
4752
5536
|
this.description = options.description
|
|
@@ -4755,6 +5539,7 @@ class Invoice extends q_utilities_.TenantAwareEntity {
|
|
|
4755
5539
|
this.invoiceNumber = options.invoiceNumber
|
|
4756
5540
|
this.invoiceType = options.invoiceType || 'Invoice'
|
|
4757
5541
|
this.issuer = this._Issuer.init(options.issuer)
|
|
5542
|
+
this.outstanding = this._Amount.init(options.outstanding)
|
|
4758
5543
|
this.revisionNumber = options.revisionNumber || 1
|
|
4759
5544
|
this.status = this._Status.init(options.status)
|
|
4760
5545
|
}
|
|
@@ -4774,6 +5559,9 @@ class Invoice extends q_utilities_.TenantAwareEntity {
|
|
|
4774
5559
|
get isValid() {
|
|
4775
5560
|
return super.isValid
|
|
4776
5561
|
}
|
|
5562
|
+
get billToUser() {
|
|
5563
|
+
return this._BillToUser && typeof this._BillToUser.init === 'function' ? this._BillToUser.init(this._billToUser) : this._billToUser
|
|
5564
|
+
}
|
|
4777
5565
|
get cart() {
|
|
4778
5566
|
return this._Cart.init(this._cart)
|
|
4779
5567
|
}
|
|
@@ -4865,6 +5653,14 @@ class Invoice extends q_utilities_.TenantAwareEntity {
|
|
|
4865
5653
|
return this.status.setCancelled()
|
|
4866
5654
|
}
|
|
4867
5655
|
|
|
5656
|
+
setClosed(timestamp, actorCode) {
|
|
5657
|
+
if (typeof this.status.setClosed !== 'function') {
|
|
5658
|
+
return this
|
|
5659
|
+
}
|
|
5660
|
+
this.status.setClosed(timestamp, actorCode)
|
|
5661
|
+
return this.setModified()
|
|
5662
|
+
}
|
|
5663
|
+
|
|
4868
5664
|
setCheckoutDateTime(timestamp) {
|
|
4869
5665
|
if (typeof timestamp === 'number') {
|
|
4870
5666
|
this.checkoutDateTime = timestamp
|
|
@@ -4875,195 +5671,74 @@ class Invoice extends q_utilities_.TenantAwareEntity {
|
|
|
4875
5671
|
this.status.setCompleted()
|
|
4876
5672
|
return this.setModified()
|
|
4877
5673
|
}
|
|
4878
|
-
|
|
4879
|
-
setWaived() {
|
|
4880
|
-
this.status.setWaived()
|
|
4881
|
-
return this.setModified()
|
|
4882
|
-
}
|
|
4883
|
-
|
|
4884
|
-
update(update) {
|
|
4885
|
-
Object.keys(update).forEach((key) => {
|
|
4886
|
-
if (invoice_updateAllowedProps.includes(key)) {
|
|
4887
|
-
if (key === 'amount') {
|
|
4888
|
-
this[key] = this._Amount.init(update[key])
|
|
4889
|
-
} else if (key === 'issuer') {
|
|
4890
|
-
this[key] = this._Issuer.init(update[key])
|
|
4891
|
-
} else if (key === 'status') {
|
|
4892
|
-
this[key] = this._Status.init(update[key])
|
|
4893
|
-
} else {
|
|
4894
|
-
this[key] = update[key]
|
|
4895
|
-
}
|
|
4896
|
-
}
|
|
4897
|
-
})
|
|
4898
|
-
return super.update(update)
|
|
4899
|
-
}
|
|
4900
|
-
}
|
|
4901
|
-
|
|
4902
|
-
function invoice_setCode(options, key) {
|
|
4903
|
-
const copyOptions = options || {}
|
|
4904
|
-
if (copyOptions[key]) {
|
|
4905
|
-
return copyOptions[key]
|
|
4906
|
-
}
|
|
4907
|
-
return stringHelper.setCode()
|
|
4908
|
-
}
|
|
4909
|
-
|
|
4910
|
-
function invoice_setId(id) {
|
|
4911
|
-
if (id && typeof id.toString === 'function') {
|
|
4912
|
-
return id.toString()
|
|
4913
|
-
}
|
|
4914
|
-
return id
|
|
4915
|
-
}
|
|
4916
|
-
|
|
4917
|
-
|
|
4918
|
-
|
|
4919
|
-
;// ./lib/models/invoice/invoiceRepo.js
|
|
4920
|
-
|
|
4921
|
-
|
|
4922
|
-
|
|
4923
|
-
class InvoiceRepo extends q_utilities_.Repo {
|
|
4924
|
-
constructor(options = {}) {
|
|
4925
|
-
options = options || {}
|
|
4926
|
-
super(options)
|
|
4927
|
-
const { _Invoice } = options._constructor || {}
|
|
4928
|
-
this._Invoice = _Invoice && (_Invoice._superclass === Invoice._superclass) ? _Invoice : Invoice
|
|
4929
|
-
}
|
|
4930
|
-
static get _classname() {
|
|
4931
|
-
return 'InvoiceRepo'
|
|
4932
|
-
}
|
|
4933
|
-
init(options) {
|
|
4934
|
-
return this._Invoice.init(options)
|
|
4935
|
-
}
|
|
4936
|
-
}
|
|
4937
|
-
|
|
4938
|
-
|
|
4939
|
-
|
|
4940
|
-
;// ./lib/models/invoice/index.js
|
|
4941
|
-
|
|
4942
|
-
|
|
4943
|
-
|
|
4944
|
-
|
|
4945
|
-
|
|
4946
|
-
|
|
4947
|
-
;// ./lib/models/keyValueObject/index.js
|
|
4948
|
-
|
|
4949
|
-
|
|
4950
|
-
;// ./lib/models/statusQStore/statusQStore.js
|
|
4951
|
-
|
|
4952
|
-
|
|
4953
|
-
const statusQStore_notUpdateAllowedProps = (/* unused pure expression or super */ null && ([
|
|
4954
|
-
]))
|
|
4955
|
-
|
|
4956
|
-
class StatusQStore extends q_utilities_.Status {
|
|
4957
|
-
constructor(options) {
|
|
4958
|
-
options = options || {}
|
|
4959
|
-
super(options)
|
|
4960
|
-
|
|
4961
|
-
this.cancelled = this._ActionRecord.init(options.cancelled)
|
|
4962
|
-
this.completed = this._ActionRecord.init(options.completed)
|
|
4963
|
-
this.confirmed = this._ActionRecord.init(options.confirmed)
|
|
4964
|
-
this.deleted = this._ActionRecord.init(options.deleted)
|
|
4965
|
-
this.terminated = this._ActionRecord.init(options.terminated)
|
|
4966
|
-
}
|
|
4967
|
-
|
|
4968
|
-
static get _classname() {
|
|
4969
|
-
return 'StatusQStore'
|
|
4970
|
-
}
|
|
4971
|
-
get _classname() {
|
|
4972
|
-
return 'StatusQStore'
|
|
4973
|
-
}
|
|
4974
|
-
get isCancelled() {
|
|
4975
|
-
return this.cancelled?.timestamp > 0
|
|
4976
|
-
}
|
|
4977
|
-
get isCompleted() {
|
|
4978
|
-
return this.completed?.timestamp > 0
|
|
4979
|
-
}
|
|
4980
|
-
get isConfirmed() {
|
|
4981
|
-
return this.confirmed?.timestamp > 0
|
|
4982
|
-
}
|
|
4983
|
-
get isDeleted() {
|
|
4984
|
-
return this.deleted?.timestamp > 0
|
|
4985
|
-
}
|
|
4986
|
-
get isTerminated() {
|
|
4987
|
-
return this.terminated?.timestamp > 0
|
|
4988
|
-
}
|
|
4989
|
-
get isValid() {
|
|
4990
|
-
return super.isValid
|
|
4991
|
-
}
|
|
4992
|
-
setCancelled(value, actorCode) {
|
|
4993
|
-
return this.setValue(value, actorCode, 'cancelled')
|
|
4994
|
-
}
|
|
4995
|
-
setCompleted(value, actorCode) {
|
|
4996
|
-
return this.setValue(value, actorCode, 'completed')
|
|
4997
|
-
}
|
|
4998
|
-
setConfirmed(value, actorCode) {
|
|
4999
|
-
return this.setValue(value, actorCode, 'confirmed')
|
|
5000
|
-
}
|
|
5001
|
-
setDeleted(value, actorCode) {
|
|
5002
|
-
return this.setValue(value, actorCode, 'deleted')
|
|
5003
|
-
}
|
|
5004
|
-
setTerminated(value, actorCode) {
|
|
5005
|
-
return this.setValue(value, actorCode, 'terminated')
|
|
5006
|
-
}
|
|
5007
|
-
// update(update) {
|
|
5008
|
-
// Object.keys(update).forEach((key) => {
|
|
5009
|
-
// if (!notUpdateAllowedProps.includes(key)) {
|
|
5010
|
-
// this[key] = this[key] instanceof this._ActionRecord ? this[key].update(update[key]) : this._ActionRecord.init(update[key])
|
|
5011
|
-
// }
|
|
5012
|
-
// })
|
|
5013
|
-
// return super.update(update)
|
|
5014
|
-
// }
|
|
5015
|
-
}
|
|
5016
|
-
|
|
5017
|
-
;// ./lib/models/statusQStore/statusQStoreOrderLine.js
|
|
5018
|
-
|
|
5019
|
-
|
|
5020
|
-
const statusQStoreOrderLine_notUpdateAllowedProps = (/* unused pure expression or super */ null && ([
|
|
5021
|
-
]))
|
|
5022
|
-
|
|
5023
|
-
class StatusQStoreOrderLine extends StatusQStore {
|
|
5024
|
-
constructor(options) {
|
|
5025
|
-
options = options || {}
|
|
5026
|
-
super(options)
|
|
5027
|
-
|
|
5028
|
-
this.expired = this._ActionRecord.init(options.expired)
|
|
5029
|
-
this.invalid = this._ActionRecord.init(options.invalid)
|
|
5030
|
-
}
|
|
5031
|
-
|
|
5032
|
-
static get _classname() {
|
|
5033
|
-
return 'StatusQStoreOrderLine'
|
|
5034
|
-
}
|
|
5035
|
-
get _classname() {
|
|
5036
|
-
return 'StatusQStoreOrderLine'
|
|
5037
|
-
}
|
|
5038
|
-
get isExpired() {
|
|
5039
|
-
return this.expired?.timestamp > Date.now()
|
|
5040
|
-
}
|
|
5041
|
-
get isInvalid() {
|
|
5042
|
-
return this.invalid?.timestamp > Date.now()
|
|
5674
|
+
|
|
5675
|
+
setWaived() {
|
|
5676
|
+
this.status.setWaived()
|
|
5677
|
+
return this.setModified()
|
|
5043
5678
|
}
|
|
5044
|
-
|
|
5045
|
-
|
|
5679
|
+
|
|
5680
|
+
update(update) {
|
|
5681
|
+
Object.keys(update).forEach((key) => {
|
|
5682
|
+
if (invoice_updateAllowedProps.includes(key)) {
|
|
5683
|
+
if (key === 'amount' || key === 'outstanding') {
|
|
5684
|
+
this[key] = this._Amount.init(update[key])
|
|
5685
|
+
} else if (key === 'issuer') {
|
|
5686
|
+
this[key] = this._Issuer.init(update[key])
|
|
5687
|
+
} else if (key === 'status') {
|
|
5688
|
+
this[key] = this._Status.init(update[key])
|
|
5689
|
+
} else {
|
|
5690
|
+
this[key] = update[key]
|
|
5691
|
+
}
|
|
5692
|
+
}
|
|
5693
|
+
})
|
|
5694
|
+
return super.update(update)
|
|
5046
5695
|
}
|
|
5047
|
-
|
|
5048
|
-
|
|
5696
|
+
|
|
5697
|
+
updateOutstanding({ actorCode } = {}) {
|
|
5698
|
+
const invoiceLines = this.invoiceLines
|
|
5699
|
+
if (invoiceLines.length === 0) {
|
|
5700
|
+
return this
|
|
5701
|
+
}
|
|
5702
|
+
const value = invoiceLines.reduce((acc, il) => {
|
|
5703
|
+
il.updateOutstanding({ actorCode })
|
|
5704
|
+
return acc + il?.outstanding?.value
|
|
5705
|
+
}, 0)
|
|
5706
|
+
if (value <= 0) {
|
|
5707
|
+
this.setClosed(Date.now(), actorCode)
|
|
5708
|
+
}
|
|
5709
|
+
this._invoiceLines = invoiceLines
|
|
5710
|
+
return this.update({
|
|
5711
|
+
outstanding: {
|
|
5712
|
+
currencyCode: this.getCurrencyCode(),
|
|
5713
|
+
value
|
|
5714
|
+
}
|
|
5715
|
+
})
|
|
5049
5716
|
}
|
|
5050
|
-
|
|
5051
|
-
|
|
5717
|
+
}
|
|
5718
|
+
|
|
5719
|
+
function invoice_setCode(options, key) {
|
|
5720
|
+
const copyOptions = options || {}
|
|
5721
|
+
if (copyOptions[key]) {
|
|
5722
|
+
return copyOptions[key]
|
|
5052
5723
|
}
|
|
5053
|
-
|
|
5054
|
-
|
|
5055
|
-
|
|
5056
|
-
|
|
5057
|
-
|
|
5058
|
-
|
|
5059
|
-
|
|
5060
|
-
|
|
5724
|
+
return stringHelper.setCode()
|
|
5725
|
+
}
|
|
5726
|
+
|
|
5727
|
+
function invoice_setId(id) {
|
|
5728
|
+
if (id && typeof id.toString === 'function') {
|
|
5729
|
+
return id.toString()
|
|
5730
|
+
}
|
|
5731
|
+
return id
|
|
5061
5732
|
}
|
|
5062
5733
|
|
|
5063
|
-
|
|
5734
|
+
|
|
5735
|
+
|
|
5736
|
+
;// ./lib/models/invoice/index.js
|
|
5737
|
+
|
|
5064
5738
|
|
|
5065
5739
|
|
|
5066
5740
|
|
|
5741
|
+
;// ./lib/models/keyValueObject/index.js
|
|
5067
5742
|
|
|
5068
5743
|
|
|
5069
5744
|
;// ./lib/models/orderLine/orderLine.js
|
|
@@ -5174,6 +5849,7 @@ class OrderLine extends q_utilities_.TenantAwareEntity {
|
|
|
5174
5849
|
unitPrice: this.unitPrice,
|
|
5175
5850
|
deduction: this.deduction,
|
|
5176
5851
|
discount: this.discount,
|
|
5852
|
+
outstanding: this.amount,
|
|
5177
5853
|
qty: this.qty,
|
|
5178
5854
|
merchandiseCode: this.merchandiseCode,
|
|
5179
5855
|
metadata: this.metadata,
|
|
@@ -5190,6 +5866,14 @@ class OrderLine extends q_utilities_.TenantAwareEntity {
|
|
|
5190
5866
|
return this.amount
|
|
5191
5867
|
}
|
|
5192
5868
|
|
|
5869
|
+
getPreservedData() {
|
|
5870
|
+
return {
|
|
5871
|
+
orderCode: this.orderCode,
|
|
5872
|
+
orderLineCode: this.orderLineCode,
|
|
5873
|
+
orderLineType: this.orderLineType,
|
|
5874
|
+
}
|
|
5875
|
+
}
|
|
5876
|
+
|
|
5193
5877
|
toCaculateAmountItem() {
|
|
5194
5878
|
return {
|
|
5195
5879
|
merchandiseCode: this.merchandiseCode,
|
|
@@ -5453,133 +6137,6 @@ function order_setId(id) {
|
|
|
5453
6137
|
|
|
5454
6138
|
|
|
5455
6139
|
|
|
5456
|
-
;// ./lib/models/paymentGateway/paymentGateway.js
|
|
5457
|
-
|
|
5458
|
-
|
|
5459
|
-
|
|
5460
|
-
const paymentGateway_updateAllowedProps = [
|
|
5461
|
-
'label',
|
|
5462
|
-
'logoUrl',
|
|
5463
|
-
'name',
|
|
5464
|
-
'sandbox',
|
|
5465
|
-
'setting'
|
|
5466
|
-
]
|
|
5467
|
-
|
|
5468
|
-
class PaymentGateway extends q_utilities_.TenantAwareEntity {
|
|
5469
|
-
constructor(options = {}) {
|
|
5470
|
-
options = options || {}
|
|
5471
|
-
super(options)
|
|
5472
|
-
|
|
5473
|
-
const id = options._id || options.id
|
|
5474
|
-
this.id = paymentGateway_setId(id)
|
|
5475
|
-
this._type = options._type || 'PaymentGateway'
|
|
5476
|
-
|
|
5477
|
-
this.hasWebhook = options.hasWebhook || false
|
|
5478
|
-
this.label = options.label
|
|
5479
|
-
this.logoUrl = options.logoUrl
|
|
5480
|
-
this.name = options.name || ''
|
|
5481
|
-
this.paymentGatewayCode = paymentGateway_setCode(options, 'paymentGatewayCode')
|
|
5482
|
-
this.paymentGatewayType = options.paymentGatewayType || 'PaymentGateway'
|
|
5483
|
-
this.paymentResultType = options.paymentResultType || 'PaymentResult'
|
|
5484
|
-
this.sandbox = options.sandbox || false
|
|
5485
|
-
this.setting = options.setting || null
|
|
5486
|
-
}
|
|
5487
|
-
static dummyData() {
|
|
5488
|
-
return {
|
|
5489
|
-
name: 'name',
|
|
5490
|
-
tenantCode: 'tenantCode'
|
|
5491
|
-
}
|
|
5492
|
-
}
|
|
5493
|
-
static get _classname() {
|
|
5494
|
-
return 'PaymentGateway'
|
|
5495
|
-
}
|
|
5496
|
-
static get _superclass() {
|
|
5497
|
-
return 'PaymentGateway'
|
|
5498
|
-
}
|
|
5499
|
-
|
|
5500
|
-
// getters
|
|
5501
|
-
get isValid() {
|
|
5502
|
-
return super.isValid && !!this.name
|
|
5503
|
-
}
|
|
5504
|
-
|
|
5505
|
-
// instance methods
|
|
5506
|
-
async createPayment() {
|
|
5507
|
-
throw new Error(`${this._classname} subclass should implement createPayment`)
|
|
5508
|
-
}
|
|
5509
|
-
async getAppPayParams() {
|
|
5510
|
-
throw new Error(`${this._classname} subclass should implement getAppPayParams`)
|
|
5511
|
-
}
|
|
5512
|
-
getCode() {
|
|
5513
|
-
return this.paymentGatewayCode
|
|
5514
|
-
}
|
|
5515
|
-
async updatePayment() {
|
|
5516
|
-
throw new Error(`${this._classname} subclass should implement updatePayment`)
|
|
5517
|
-
}
|
|
5518
|
-
async query() {
|
|
5519
|
-
throw new Error(`${this._classname} subclass should implement query`)
|
|
5520
|
-
}
|
|
5521
|
-
async submit() {
|
|
5522
|
-
throw new Error(`${this._classname} subclass should implement submit`)
|
|
5523
|
-
}
|
|
5524
|
-
|
|
5525
|
-
setCompletedRelatedStatus(status) {
|
|
5526
|
-
throw new Error(`${this.name} subclass should implement setCompletedRelatedStatus`)
|
|
5527
|
-
}
|
|
5528
|
-
update(update) {
|
|
5529
|
-
Object.keys(update).forEach((key) => {
|
|
5530
|
-
if (paymentGateway_updateAllowedProps.includes(key)) {
|
|
5531
|
-
this[key] = update[key]
|
|
5532
|
-
}
|
|
5533
|
-
})
|
|
5534
|
-
return super.update(update)
|
|
5535
|
-
}
|
|
5536
|
-
}
|
|
5537
|
-
|
|
5538
|
-
function paymentGateway_setCode(options, key) {
|
|
5539
|
-
const copyOptions = options || {}
|
|
5540
|
-
if (copyOptions[key]) {
|
|
5541
|
-
return copyOptions[key]
|
|
5542
|
-
}
|
|
5543
|
-
return stringHelper.setCode()
|
|
5544
|
-
}
|
|
5545
|
-
|
|
5546
|
-
function paymentGateway_setId(id) {
|
|
5547
|
-
if (id && typeof id.toString === 'function') {
|
|
5548
|
-
return id.toString()
|
|
5549
|
-
}
|
|
5550
|
-
return id
|
|
5551
|
-
}
|
|
5552
|
-
|
|
5553
|
-
|
|
5554
|
-
|
|
5555
|
-
;// ./lib/models/paymentGateway/paymentGatewayRepo.js
|
|
5556
|
-
|
|
5557
|
-
|
|
5558
|
-
|
|
5559
|
-
class PaymentGatewayRepo extends q_utilities_.Repo {
|
|
5560
|
-
constructor(options = {}) {
|
|
5561
|
-
options = options || {}
|
|
5562
|
-
super(options)
|
|
5563
|
-
const { _PaymentGateway } = options._constructor || {}
|
|
5564
|
-
this._PaymentGateway = _PaymentGateway && (_PaymentGateway._superclass === PaymentGateway._superclass) ? _PaymentGateway : PaymentGateway
|
|
5565
|
-
}
|
|
5566
|
-
static get _classname() {
|
|
5567
|
-
return 'PaymentGatewayRepo'
|
|
5568
|
-
}
|
|
5569
|
-
init(options) {
|
|
5570
|
-
return this._PaymentGateway.init(options)
|
|
5571
|
-
}
|
|
5572
|
-
}
|
|
5573
|
-
|
|
5574
|
-
|
|
5575
|
-
|
|
5576
|
-
;// ./lib/models/paymentGateway/index.js
|
|
5577
|
-
|
|
5578
|
-
|
|
5579
|
-
|
|
5580
|
-
|
|
5581
|
-
|
|
5582
|
-
|
|
5583
6140
|
;// ./lib/models/paymentResult/paymentResult.js
|
|
5584
6141
|
|
|
5585
6142
|
|
|
@@ -5755,40 +6312,16 @@ function paymentResult_setId(id) {
|
|
|
5755
6312
|
|
|
5756
6313
|
|
|
5757
6314
|
|
|
5758
|
-
;// ./lib/models/paymentResult/paymentResultRepo.js
|
|
5759
|
-
|
|
5760
|
-
|
|
5761
|
-
|
|
5762
|
-
class PaymentResultRepo extends q_utilities_.Repo {
|
|
5763
|
-
constructor(options = {}) {
|
|
5764
|
-
options = options || {}
|
|
5765
|
-
super(options)
|
|
5766
|
-
const { _PaymentResult } = options._constructor || {}
|
|
5767
|
-
this._PaymentResult = _PaymentResult && (_PaymentResult._superclass === PaymentResult._superclass) ? _PaymentResult : PaymentResult
|
|
5768
|
-
}
|
|
5769
|
-
static get _classname() {
|
|
5770
|
-
return 'PaymentResultRepo'
|
|
5771
|
-
}
|
|
5772
|
-
init(options) {
|
|
5773
|
-
return this._PaymentResult.init(options)
|
|
5774
|
-
}
|
|
5775
|
-
}
|
|
5776
|
-
|
|
5777
|
-
|
|
5778
|
-
|
|
5779
6315
|
;// ./lib/models/paymentResult/index.js
|
|
5780
6316
|
|
|
5781
6317
|
|
|
5782
6318
|
|
|
5783
6319
|
|
|
5784
|
-
|
|
5785
|
-
|
|
5786
6320
|
;// ./lib/models/status/index.js
|
|
5787
6321
|
|
|
5788
6322
|
|
|
5789
6323
|
|
|
5790
6324
|
|
|
5791
|
-
|
|
5792
6325
|
;// ./lib/models/storeItem/storeItem.js
|
|
5793
6326
|
|
|
5794
6327
|
|
|
@@ -5949,7 +6482,7 @@ class StoreItem {
|
|
|
5949
6482
|
if (storeItem_updateAllowedProps.includes(key)) {
|
|
5950
6483
|
if (key === 'metadata') {
|
|
5951
6484
|
this[key] = q_utilities_.Metadata.initOnlyValidFromArray(update[key])
|
|
5952
|
-
} else
|
|
6485
|
+
} else if (key === 'productOptions') {
|
|
5953
6486
|
this[key] = this._ItemOption.initOnlyValidFromArray(update[key])
|
|
5954
6487
|
} else if (key === 'remarks') {
|
|
5955
6488
|
this[key] = q_utilities_.KeyValueObject.initOnlyValidFromArray(update[key])
|
|
@@ -6014,8 +6547,13 @@ function storeItem_getDataByKey(key, data) {
|
|
|
6014
6547
|
|
|
6015
6548
|
|
|
6016
6549
|
|
|
6017
|
-
;// ./lib/helpers/corHelper/chain.js
|
|
6018
6550
|
|
|
6551
|
+
|
|
6552
|
+
|
|
6553
|
+
|
|
6554
|
+
|
|
6555
|
+
|
|
6556
|
+
;// ./lib/helpers/corHelper/chain.js
|
|
6019
6557
|
class Chain {
|
|
6020
6558
|
constructor(options = {}) {
|
|
6021
6559
|
options = options || {}
|
|
@@ -6135,7 +6673,7 @@ function calculateByCoupon({ coupon, price, currencyCode }) {
|
|
|
6135
6673
|
}
|
|
6136
6674
|
const { type, item } = couponDetails
|
|
6137
6675
|
if (item) {
|
|
6138
|
-
switch(type) {
|
|
6676
|
+
switch (type) {
|
|
6139
6677
|
case ('Deduction'): {
|
|
6140
6678
|
return _caculateByDeduction({ price, couponDetails, currencyCode })
|
|
6141
6679
|
}
|
|
@@ -6160,7 +6698,6 @@ function _caculateByPercentage({ price, couponDetails }) {
|
|
|
6160
6698
|
|
|
6161
6699
|
|
|
6162
6700
|
|
|
6163
|
-
|
|
6164
6701
|
;// ./lib/helpers/calculateByCoupon/index.js
|
|
6165
6702
|
|
|
6166
6703
|
|
|
@@ -6207,7 +6744,12 @@ class ChainCategoryLimit extends Chain {
|
|
|
6207
6744
|
function groupCategory(categories = [], walletItems = []) {
|
|
6208
6745
|
return categories.reduce((acc, category) => {
|
|
6209
6746
|
const {
|
|
6210
|
-
categoryCode,
|
|
6747
|
+
categoryCode,
|
|
6748
|
+
codes,
|
|
6749
|
+
name,
|
|
6750
|
+
max,
|
|
6751
|
+
min,
|
|
6752
|
+
productCodes = [],
|
|
6211
6753
|
} = category
|
|
6212
6754
|
const filtered = walletItems.filter((w) => {
|
|
6213
6755
|
if (w.status.cancelled !== null) {
|
|
@@ -6462,7 +7004,7 @@ function getEntitlements(entitlements, productCodes, qty) {
|
|
|
6462
7004
|
if (entitlements.length === 0) {
|
|
6463
7005
|
return { waived: 0, entitlementsRemarkValue: [] }
|
|
6464
7006
|
}
|
|
6465
|
-
const groupedProductCodes = Array.from(
|
|
7007
|
+
const groupedProductCodes = Array.from({ length: qty }).map(() => [...productCodes])
|
|
6466
7008
|
// const copyEntitlements = JSON.parse(JSON.stringify(entitlements))
|
|
6467
7009
|
const { waived, entitlementsRemarkValue } = groupedProductCodes.reduce((acc, arr) => {
|
|
6468
7010
|
if (acc.continue === false) {
|
|
@@ -6521,7 +7063,6 @@ function getStrategiesByRestrictions(prices, line, user) {
|
|
|
6521
7063
|
return priceStrategies
|
|
6522
7064
|
}
|
|
6523
7065
|
|
|
6524
|
-
|
|
6525
7066
|
// function useCoupons(lines, currencyCode) {
|
|
6526
7067
|
// lines.forEach((line) => {
|
|
6527
7068
|
|
|
@@ -6545,7 +7086,7 @@ class ChainGetPriceForGroup extends Chain {
|
|
|
6545
7086
|
|
|
6546
7087
|
async handleRequest(chainTarget) {
|
|
6547
7088
|
try {
|
|
6548
|
-
const { lines
|
|
7089
|
+
const { lines } = chainTarget
|
|
6549
7090
|
const entitlements = external_lodash_.cloneDeep(this.entitlements)
|
|
6550
7091
|
|
|
6551
7092
|
lines.forEach((line) => {
|
|
@@ -6598,10 +7139,10 @@ function ChainGetPriceForGroup_cutEntitlements(lines, entitlements = [], currenc
|
|
|
6598
7139
|
const subTotal = Amount.init({ value, currencyCode })
|
|
6599
7140
|
const discountValue = (price.value * restQty) - subTotal.value + (price.value * waived)
|
|
6600
7141
|
const discount = Amount.init({ value: discountValue, currencyCode })
|
|
6601
|
-
let remarks = KeyValueObject.initOnlyValidFromArray([...(updatedItem.remarks || [])])
|
|
6602
|
-
remarks = KeyValueObject.updateOrInsertRecord(remarks, 'entitlements', entitlementsRemarkValue)
|
|
6603
|
-
let metadata = Metadata.initOnlyValidFromArray([...(updatedItem.metadata || [])])
|
|
6604
|
-
metadata = Metadata.updateOrInsertRecord(metadata, 'entitlements', entitlementsRemarkValue)
|
|
7142
|
+
let remarks = q_utilities_.KeyValueObject.initOnlyValidFromArray([...(updatedItem.remarks || [])])
|
|
7143
|
+
remarks = q_utilities_.KeyValueObject.updateOrInsertRecord(remarks, 'entitlements', entitlementsRemarkValue)
|
|
7144
|
+
let metadata = q_utilities_.Metadata.initOnlyValidFromArray([...(updatedItem.metadata || [])])
|
|
7145
|
+
metadata = q_utilities_.Metadata.updateOrInsertRecord(metadata, 'entitlements', entitlementsRemarkValue)
|
|
6605
7146
|
const obj = {
|
|
6606
7147
|
merchandiseCode,
|
|
6607
7148
|
price,
|
|
@@ -6680,7 +7221,7 @@ function ChainGetPriceForGroup_getEntitlements(entitlements, productCodes, qty)
|
|
|
6680
7221
|
if (entitlements.length === 0) {
|
|
6681
7222
|
return { waived: 0, entitlementsRemarkValue: [] }
|
|
6682
7223
|
}
|
|
6683
|
-
const groupedProductCodes = Array.from(
|
|
7224
|
+
const groupedProductCodes = Array.from({ length: qty }).map(() => [...productCodes])
|
|
6684
7225
|
// const copyEntitlements = JSON.parse(JSON.stringify(entitlements))
|
|
6685
7226
|
const { waived, entitlementsRemarkValue } = groupedProductCodes.reduce((acc, arr) => {
|
|
6686
7227
|
if (acc.continue === false) {
|
|
@@ -6851,7 +7392,7 @@ function _calculate({ line, currency }) {
|
|
|
6851
7392
|
|
|
6852
7393
|
function _findPriceAdjustmentValue(dataArray) {
|
|
6853
7394
|
for (const obj of dataArray) {
|
|
6854
|
-
const priceAdjustment = obj.value?.find(item => item.key === 'priceAdjustment')
|
|
7395
|
+
const priceAdjustment = obj.value?.find((item) => item.key === 'priceAdjustment')
|
|
6855
7396
|
if (priceAdjustment) {
|
|
6856
7397
|
return Number(priceAdjustment.value)
|
|
6857
7398
|
}
|
|
@@ -6861,7 +7402,6 @@ function _findPriceAdjustmentValue(dataArray) {
|
|
|
6861
7402
|
|
|
6862
7403
|
|
|
6863
7404
|
|
|
6864
|
-
|
|
6865
7405
|
;// ./lib/eventManager/chains/chainProductLimit.js
|
|
6866
7406
|
|
|
6867
7407
|
|
|
@@ -7079,7 +7619,7 @@ class ChainRelatedCoupons extends Chain {
|
|
|
7079
7619
|
})
|
|
7080
7620
|
// for total ptice coupon
|
|
7081
7621
|
_calculateAmountByTotalCoupons({ lines, currencyCode: this.currency.code, relatedTotalCoupons })
|
|
7082
|
-
_autoUsedTotalCoupons({ lines, autoUseCoupon: this.autoUseCoupon, currencyCode: this.currency.code, relatedTotalCoupons})
|
|
7622
|
+
_autoUsedTotalCoupons({ lines, autoUseCoupon: this.autoUseCoupon, currencyCode: this.currency.code, relatedTotalCoupons })
|
|
7083
7623
|
await this.next(chainTarget)
|
|
7084
7624
|
} catch (err) {
|
|
7085
7625
|
chainTarget.addException('handle related coupons fail', err.message)
|
|
@@ -7088,17 +7628,15 @@ class ChainRelatedCoupons extends Chain {
|
|
|
7088
7628
|
}
|
|
7089
7629
|
}
|
|
7090
7630
|
|
|
7091
|
-
|
|
7092
7631
|
function _autoUsedTotalCoupons({ lines, autoUseCoupon, currencyCode, relatedTotalCoupons }) {
|
|
7093
7632
|
if (autoUseCoupon) {
|
|
7094
|
-
|
|
7095
|
-
|
|
7096
|
-
|
|
7097
|
-
|
|
7633
|
+
relatedTotalCoupons.forEach((item) => {
|
|
7634
|
+
const obj = _autoUsedTotalCoupon(item, lines, currencyCode)
|
|
7635
|
+
Object.assign(item, obj)
|
|
7636
|
+
})
|
|
7098
7637
|
}
|
|
7099
7638
|
}
|
|
7100
7639
|
|
|
7101
|
-
|
|
7102
7640
|
function _autoUsedTotalCoupon(item, lines, currencyCode) {
|
|
7103
7641
|
const { availableCoupons, usedCoupons, product } = item
|
|
7104
7642
|
if (availableCoupons.length > 0) {
|
|
@@ -7139,7 +7677,7 @@ function _calculateAmountByTotalCoupons({ lines, currencyCode, relatedTotalCoupo
|
|
|
7139
7677
|
_calculateAmountByOneTotalCoupon({ lines, currencyCode, coupon })
|
|
7140
7678
|
})
|
|
7141
7679
|
})
|
|
7142
|
-
}
|
|
7680
|
+
}
|
|
7143
7681
|
|
|
7144
7682
|
function _calculateAmountByOneTotalCoupon({ lines, currencyCode, coupon }) {
|
|
7145
7683
|
const availableLines = lines.filter((line) => (coupon.isApplicableCoupon(line.merchandise)))
|
|
@@ -7152,7 +7690,7 @@ function _calculateAmountByOneTotalCoupon({ lines, currencyCode, coupon }) {
|
|
|
7152
7690
|
if (couponDetails) {
|
|
7153
7691
|
const { type, total } = couponDetails
|
|
7154
7692
|
const { value } = couponDetails
|
|
7155
|
-
switch(type) {
|
|
7693
|
+
switch (type) {
|
|
7156
7694
|
case ('Deduction'): {
|
|
7157
7695
|
const _discount = q_utilities_.KeyValueObject.foundValueByKey(value, currencyCode)
|
|
7158
7696
|
availableLines.forEach((line) => {
|
|
@@ -7164,7 +7702,7 @@ function _calculateAmountByOneTotalCoupon({ lines, currencyCode, coupon }) {
|
|
|
7164
7702
|
_usedCoupons.push(walletItemCode)
|
|
7165
7703
|
const obj = {
|
|
7166
7704
|
discount: Amount.init({ value: discountValue, currencyCode }),
|
|
7167
|
-
remarks: q_utilities_.KeyValueObject.insertOrUpdateRecord(remarks, 'USED_TOTAL_COUPONS', _usedCoupons
|
|
7705
|
+
remarks: q_utilities_.KeyValueObject.insertOrUpdateRecord(remarks, 'USED_TOTAL_COUPONS', _usedCoupons),
|
|
7168
7706
|
subTotal: Amount.init({ value: subTotalValue, currencyCode })
|
|
7169
7707
|
}
|
|
7170
7708
|
Object.assign(updatedItem, obj)
|
|
@@ -7182,7 +7720,7 @@ function _calculateAmountByOneTotalCoupon({ lines, currencyCode, coupon }) {
|
|
|
7182
7720
|
_usedCoupons.push(walletItemCode)
|
|
7183
7721
|
const obj = {
|
|
7184
7722
|
discount: Amount.init({ value: discountValue, currencyCode }),
|
|
7185
|
-
remarks: q_utilities_.KeyValueObject.insertOrUpdateRecord(remarks, 'USED_TOTAL_COUPONS', _usedCoupons
|
|
7723
|
+
remarks: q_utilities_.KeyValueObject.insertOrUpdateRecord(remarks, 'USED_TOTAL_COUPONS', _usedCoupons),
|
|
7186
7724
|
subTotal: Amount.init({ value: subTotalValue, currencyCode })
|
|
7187
7725
|
}
|
|
7188
7726
|
Object.assign(updatedItem, obj)
|
|
@@ -7190,11 +7728,10 @@ function _calculateAmountByOneTotalCoupon({ lines, currencyCode, coupon }) {
|
|
|
7190
7728
|
break
|
|
7191
7729
|
}
|
|
7192
7730
|
default: {
|
|
7193
|
-
|
|
7731
|
+
|
|
7194
7732
|
}
|
|
7195
7733
|
}
|
|
7196
7734
|
}
|
|
7197
|
-
|
|
7198
7735
|
}
|
|
7199
7736
|
|
|
7200
7737
|
function _calculateAmountByOneItemCoupon({ updatedItem, coupon, currencyCode }) {
|
|
@@ -7211,12 +7748,11 @@ function _calculateAmountByOneItemCoupon({ updatedItem, coupon, currencyCode })
|
|
|
7211
7748
|
return {
|
|
7212
7749
|
...updatedItem,
|
|
7213
7750
|
discount: Amount.init({ value: discountValue, currencyCode }),
|
|
7214
|
-
remarks: q_utilities_.KeyValueObject.insertOrUpdateRecord(remarks, 'USED_ITEM_COUPONS', _usedCoupons
|
|
7751
|
+
remarks: q_utilities_.KeyValueObject.insertOrUpdateRecord(remarks, 'USED_ITEM_COUPONS', _usedCoupons),
|
|
7215
7752
|
subTotal: Amount.init({ value: subTotalValue, currencyCode })
|
|
7216
7753
|
}
|
|
7217
7754
|
}
|
|
7218
7755
|
|
|
7219
|
-
|
|
7220
7756
|
function _getAvailableItemCoupons(line) {
|
|
7221
7757
|
const { relatedCoupons = [] } = line
|
|
7222
7758
|
line.relatedCoupons = relatedCoupons.map((c) => ({
|
|
@@ -7228,7 +7764,7 @@ function _getAvailableItemCoupons(line) {
|
|
|
7228
7764
|
function _getRelatedItemCoupons(cartItemLine, couponWalletItems, autoUseCoupon, currencyCode) {
|
|
7229
7765
|
const { merchandise, usedCoupons = {}, updatedItem = {} } = cartItemLine
|
|
7230
7766
|
const relatedWalletItems = couponWalletItems.filter(
|
|
7231
|
-
item => item.isApplicableCoupon(merchandise) && item.isItemCoupon
|
|
7767
|
+
(item) => item.isApplicableCoupon(merchandise) && item.isItemCoupon
|
|
7232
7768
|
)
|
|
7233
7769
|
// .sort((a, b) => (
|
|
7234
7770
|
// b.couponDetails.value - a.couponDetails.value
|
|
@@ -7241,7 +7777,7 @@ function _getRelatedItemCoupons(cartItemLine, couponWalletItems, autoUseCoupon,
|
|
|
7241
7777
|
exist = {
|
|
7242
7778
|
coupons: [],
|
|
7243
7779
|
product: w.product,
|
|
7244
|
-
productCode
|
|
7780
|
+
productCode,
|
|
7245
7781
|
usedQty: (usedCoupons[productCode] || []).length
|
|
7246
7782
|
}
|
|
7247
7783
|
acc.push(exist)
|
|
@@ -7263,7 +7799,6 @@ function _getRelatedItemCoupons(cartItemLine, couponWalletItems, autoUseCoupon,
|
|
|
7263
7799
|
}, [])
|
|
7264
7800
|
}
|
|
7265
7801
|
|
|
7266
|
-
|
|
7267
7802
|
function _updateRelatedItemCoupons(line, couponWalletItems, autoUseCoupon, currencyCode) {
|
|
7268
7803
|
if (couponWalletItems.length > 0) {
|
|
7269
7804
|
line.relatedCoupons = _getRelatedItemCoupons(line, couponWalletItems, autoUseCoupon, currencyCode)
|
|
@@ -7272,9 +7807,6 @@ function _updateRelatedItemCoupons(line, couponWalletItems, autoUseCoupon, curre
|
|
|
7272
7807
|
|
|
7273
7808
|
|
|
7274
7809
|
|
|
7275
|
-
|
|
7276
|
-
|
|
7277
|
-
|
|
7278
7810
|
;// ./lib/eventManager/chains/index.js
|
|
7279
7811
|
|
|
7280
7812
|
|
|
@@ -7290,7 +7822,6 @@ function _updateRelatedItemCoupons(line, couponWalletItems, autoUseCoupon, curre
|
|
|
7290
7822
|
|
|
7291
7823
|
|
|
7292
7824
|
;// ./lib/helpers/corHelper/chainException.js
|
|
7293
|
-
|
|
7294
7825
|
class ChainException {
|
|
7295
7826
|
constructor() {
|
|
7296
7827
|
this.result = {}
|
|
@@ -7419,7 +7950,6 @@ class ChainTargetCalculateAmount extends ChainTarget {
|
|
|
7419
7950
|
|
|
7420
7951
|
;// ./lib/helpers/corHelper/chainManager.js
|
|
7421
7952
|
|
|
7422
|
-
|
|
7423
7953
|
// import { ChainResult } from './chainResult.js'
|
|
7424
7954
|
// import { makeChainsFactory } from './helpers.js'
|
|
7425
7955
|
|
|
@@ -7576,7 +8106,10 @@ function _calculateAmountChainsFactory(payload) {
|
|
|
7576
8106
|
new ChainMerchandiseLimit(),
|
|
7577
8107
|
new ChainProductLimit({ products }),
|
|
7578
8108
|
new ChainGetPrice({
|
|
7579
|
-
currency,
|
|
8109
|
+
currency,
|
|
8110
|
+
dateTime,
|
|
8111
|
+
entitlements,
|
|
8112
|
+
merchandises
|
|
7580
8113
|
}),
|
|
7581
8114
|
new ChainRelatedCoupons({ currency, autoUseCoupon, walletItems }),
|
|
7582
8115
|
new ChainPriceAdjustment({ currency }),
|
|
@@ -7596,7 +8129,10 @@ function _calculateAmountChainsFactoryforGroup(payload) {
|
|
|
7596
8129
|
new ChainMerchandiseLimit(),
|
|
7597
8130
|
new ChainProductLimit({ products }),
|
|
7598
8131
|
new ChainGetPriceForGroup({
|
|
7599
|
-
currency,
|
|
8132
|
+
currency,
|
|
8133
|
+
dateTime,
|
|
8134
|
+
entitlements,
|
|
8135
|
+
merchandises
|
|
7600
8136
|
}),
|
|
7601
8137
|
]
|
|
7602
8138
|
}
|
|
@@ -7739,9 +8275,9 @@ function getRolesChangesRelatedCouponsHelper({ newRoles, originalRoles }) {
|
|
|
7739
8275
|
...Object.keys(couponFromOriginalRoles)
|
|
7740
8276
|
])
|
|
7741
8277
|
return Array.from(allKeys).reduce((acc, key) => {
|
|
7742
|
-
const newValue = couponFromNewRoles[key] || 0
|
|
7743
|
-
const originalValue = couponFromOriginalRoles[key] || 0
|
|
7744
|
-
const delta = newValue - originalValue
|
|
8278
|
+
const newValue = couponFromNewRoles[key] || 0
|
|
8279
|
+
const originalValue = couponFromOriginalRoles[key] || 0
|
|
8280
|
+
const delta = newValue - originalValue
|
|
7745
8281
|
if (delta !== 0) {
|
|
7746
8282
|
acc.push({
|
|
7747
8283
|
key,
|
|
@@ -7750,13 +8286,12 @@ function getRolesChangesRelatedCouponsHelper({ newRoles, originalRoles }) {
|
|
|
7750
8286
|
newValue,
|
|
7751
8287
|
originalValue
|
|
7752
8288
|
}
|
|
7753
|
-
})
|
|
8289
|
+
})
|
|
7754
8290
|
}
|
|
7755
8291
|
return acc
|
|
7756
8292
|
}, [])
|
|
7757
8293
|
}
|
|
7758
8294
|
|
|
7759
|
-
|
|
7760
8295
|
function _getCouponsByRoles(roles) {
|
|
7761
8296
|
return roles.reduce((acc, role) => {
|
|
7762
8297
|
const couponCodes = role.getCouponCodes()
|
|
@@ -7807,19 +8342,18 @@ class CouponManager {
|
|
|
7807
8342
|
return getRolesChangesRelatedCouponsHelper({ newRoles: this.newRoles, originalRoles: this.originalRoles })
|
|
7808
8343
|
}
|
|
7809
8344
|
|
|
7810
|
-
|
|
7811
8345
|
get couponItemList() {
|
|
7812
8346
|
return this.couponProducts.map((p) => {
|
|
7813
8347
|
const relatedWalletItems = this.walletItems.filter(
|
|
7814
|
-
item => item.productCode === p.productCode
|
|
8348
|
+
(item) => item.productCode === p.productCode
|
|
7815
8349
|
)
|
|
7816
8350
|
|
|
7817
|
-
const usedCoupons = relatedWalletItems.filter(item => item.isUsed)
|
|
8351
|
+
const usedCoupons = relatedWalletItems.filter((item) => item.isUsed)
|
|
7818
8352
|
usedCoupons.forEach((c) => {
|
|
7819
8353
|
c.useForWalletItems = this.walletItems.filter((item) => (c.useFor || []).includes(item.walletItemCode)) // useFor
|
|
7820
8354
|
})
|
|
7821
8355
|
|
|
7822
|
-
const availableCoupons = relatedWalletItems.filter(item => !item.isAvailableCoupon)
|
|
8356
|
+
const availableCoupons = relatedWalletItems.filter((item) => !item.isAvailableCoupon)
|
|
7823
8357
|
|
|
7824
8358
|
const roleBase = q_utilities_.KeyValueObject.foundValueByKey(this.roleRelatedCoupons, p.productCode) || {}
|
|
7825
8359
|
|
|
@@ -7837,19 +8371,17 @@ class CouponManager {
|
|
|
7837
8371
|
qty,
|
|
7838
8372
|
roleBase,
|
|
7839
8373
|
remarks
|
|
7840
|
-
}
|
|
8374
|
+
}
|
|
7841
8375
|
})
|
|
7842
8376
|
}
|
|
7843
8377
|
|
|
7844
8378
|
setNewRoles() {
|
|
7845
8379
|
this.newRoles = newRoles
|
|
7846
8380
|
}
|
|
7847
|
-
|
|
7848
8381
|
}
|
|
7849
8382
|
|
|
7850
8383
|
|
|
7851
8384
|
|
|
7852
|
-
|
|
7853
8385
|
function _handler({ product, remainingQuota, availableCoupons, roleBase }) {
|
|
7854
8386
|
const { delta = 0 } = roleBase
|
|
7855
8387
|
const { maxPerWallet } = product
|
|
@@ -7890,7 +8422,7 @@ class Handler {
|
|
|
7890
8422
|
|
|
7891
8423
|
|
|
7892
8424
|
class HandlerMinutes extends Handler {
|
|
7893
|
-
process(dateFormat) {
|
|
8425
|
+
process(dateFormat) {
|
|
7894
8426
|
const mthIdx = this.date.getMinutes()
|
|
7895
8427
|
dateFormat = dateFormat.replace('mm', zeroPadding(mthIdx)) // 23-03-10 17:mm
|
|
7896
8428
|
return dateFormat
|
|
@@ -7899,7 +8431,7 @@ class HandlerMinutes extends Handler {
|
|
|
7899
8431
|
|
|
7900
8432
|
function zeroPadding(num) {
|
|
7901
8433
|
if (typeof num !== 'number') {
|
|
7902
|
-
throw new
|
|
8434
|
+
throw new TypeError('Parameter must be of number')
|
|
7903
8435
|
}
|
|
7904
8436
|
return num < 10 ? `0${num}` : `${num}`
|
|
7905
8437
|
}
|
|
@@ -7910,7 +8442,7 @@ function zeroPadding(num) {
|
|
|
7910
8442
|
|
|
7911
8443
|
|
|
7912
8444
|
class HandlerHours extends Handler {
|
|
7913
|
-
process(dateFormat) {
|
|
8445
|
+
process(dateFormat) {
|
|
7914
8446
|
const hthIdx = this.date.getHours()
|
|
7915
8447
|
dateFormat = dateFormat.replace('HH', handlerHours_zeroPadding(hthIdx)) // 23-03-10 HH
|
|
7916
8448
|
return dateFormat
|
|
@@ -7919,7 +8451,7 @@ class HandlerHours extends Handler {
|
|
|
7919
8451
|
|
|
7920
8452
|
function handlerHours_zeroPadding(num) {
|
|
7921
8453
|
if (typeof num !== 'number') {
|
|
7922
|
-
throw new
|
|
8454
|
+
throw new TypeError('Parameter must be of number')
|
|
7923
8455
|
}
|
|
7924
8456
|
return num < 10 ? `0${num}` : `${num}`
|
|
7925
8457
|
}
|
|
@@ -7930,7 +8462,7 @@ function handlerHours_zeroPadding(num) {
|
|
|
7930
8462
|
|
|
7931
8463
|
|
|
7932
8464
|
class HandlerDate extends Handler {
|
|
7933
|
-
process(dateFormat) {
|
|
8465
|
+
process(dateFormat) {
|
|
7934
8466
|
const dthIdx = this.date.getDate()
|
|
7935
8467
|
dateFormat = dateFormat.replace('dd', handlerDate_zeroPadding(dthIdx)) // 23-03-dd
|
|
7936
8468
|
return dateFormat
|
|
@@ -7939,7 +8471,7 @@ class HandlerDate extends Handler {
|
|
|
7939
8471
|
|
|
7940
8472
|
function handlerDate_zeroPadding(num) {
|
|
7941
8473
|
if (typeof num !== 'number') {
|
|
7942
|
-
throw new
|
|
8474
|
+
throw new TypeError('Parameter must be of number')
|
|
7943
8475
|
}
|
|
7944
8476
|
return num < 10 ? `0${num}` : `${num}`
|
|
7945
8477
|
}
|
|
@@ -7961,7 +8493,7 @@ class HandlerMonth extends Handler {
|
|
|
7961
8493
|
|
|
7962
8494
|
function handlerMonth_zeroPadding(num) {
|
|
7963
8495
|
if (typeof num !== 'number') {
|
|
7964
|
-
throw new
|
|
8496
|
+
throw new TypeError('Parameter must be of number')
|
|
7965
8497
|
}
|
|
7966
8498
|
return num < 10 ? `0${num}` : `${num}`
|
|
7967
8499
|
}
|
|
@@ -8031,7 +8563,6 @@ function convert(date, dateFormat) {
|
|
|
8031
8563
|
|
|
8032
8564
|
|
|
8033
8565
|
|
|
8034
|
-
|
|
8035
8566
|
;// ./lib/helpers/ordersList/orderList.js
|
|
8036
8567
|
|
|
8037
8568
|
|
|
@@ -8098,7 +8629,6 @@ function actionBuilder(row, header, qRow) {
|
|
|
8098
8629
|
onClick: orderList_self.onOrderListAction('waived')
|
|
8099
8630
|
})
|
|
8100
8631
|
}
|
|
8101
|
-
|
|
8102
8632
|
}
|
|
8103
8633
|
actions.push({
|
|
8104
8634
|
css: {
|
|
@@ -8124,11 +8654,13 @@ function qListArr(originMerchandises, originInvoices) {
|
|
|
8124
8654
|
}
|
|
8125
8655
|
return {
|
|
8126
8656
|
...acc,
|
|
8127
|
-
amount: i.amount && i.amount.value
|
|
8128
|
-
|
|
8129
|
-
|
|
8130
|
-
|
|
8131
|
-
|
|
8657
|
+
amount: i.amount && i.amount.value
|
|
8658
|
+
? i.amount
|
|
8659
|
+
: {
|
|
8660
|
+
value: acc.amount.value + l.amount.value * l.qty,
|
|
8661
|
+
currencyCode: l.amount.currencyCode,
|
|
8662
|
+
default: acc.amount.default && l.amount.default
|
|
8663
|
+
},
|
|
8132
8664
|
}
|
|
8133
8665
|
}, {
|
|
8134
8666
|
amount: {
|
|
@@ -8158,7 +8690,8 @@ function qListArr(originMerchandises, originInvoices) {
|
|
|
8158
8690
|
|
|
8159
8691
|
function formatStatus(status) {
|
|
8160
8692
|
let newStatus = ''
|
|
8161
|
-
if (!(status instanceof Status))
|
|
8693
|
+
if (!(status instanceof Status))
|
|
8694
|
+
return newStatus
|
|
8162
8695
|
if (status.isCancelled) {
|
|
8163
8696
|
newStatus = 'cancelled'
|
|
8164
8697
|
return newStatus
|
|
@@ -8197,7 +8730,13 @@ function handlerHeaders(defaultHeaders) {
|
|
|
8197
8730
|
}
|
|
8198
8731
|
|
|
8199
8732
|
function handlerOrderList({
|
|
8200
|
-
component,
|
|
8733
|
+
component,
|
|
8734
|
+
config,
|
|
8735
|
+
merchandises,
|
|
8736
|
+
invoices,
|
|
8737
|
+
defaultHeaders,
|
|
8738
|
+
isAdmin,
|
|
8739
|
+
label = {}
|
|
8201
8740
|
}) {
|
|
8202
8741
|
orderList_self = component
|
|
8203
8742
|
_config = config
|
|
@@ -8221,7 +8760,6 @@ function handlerOrderList({
|
|
|
8221
8760
|
|
|
8222
8761
|
|
|
8223
8762
|
|
|
8224
|
-
|
|
8225
8763
|
;// ./lib/helpers/sortHelper/defaultSort.js
|
|
8226
8764
|
function defaultSort(arr, getKey) {
|
|
8227
8765
|
if (!getKey) {
|
|
@@ -8230,7 +8768,7 @@ function defaultSort(arr, getKey) {
|
|
|
8230
8768
|
let key = null
|
|
8231
8769
|
switch (typeof getKey) {
|
|
8232
8770
|
case 'function':
|
|
8233
|
-
arr.forEach(ele => { key = getKey(ele) })
|
|
8771
|
+
arr.forEach((ele) => { key = getKey(ele) })
|
|
8234
8772
|
if (key.length === 0) {
|
|
8235
8773
|
return arr
|
|
8236
8774
|
}
|
|
@@ -8249,9 +8787,9 @@ function defaultSort(arr, getKey) {
|
|
|
8249
8787
|
|
|
8250
8788
|
;// ./lib/helpers/sortHelper/isAllEqual.js
|
|
8251
8789
|
function isAllEqual({ arr = [], key }) {
|
|
8252
|
-
const [
|
|
8790
|
+
const [firstElem] = arr
|
|
8253
8791
|
const compareValue = firstElem[key]
|
|
8254
|
-
return arr.every(a => a[key] === compareValue)
|
|
8792
|
+
return arr.every((a) => a[key] === compareValue)
|
|
8255
8793
|
}
|
|
8256
8794
|
|
|
8257
8795
|
|
|
@@ -8276,7 +8814,6 @@ function isDescendingOrder({ arr = [], key }) {
|
|
|
8276
8814
|
|
|
8277
8815
|
|
|
8278
8816
|
|
|
8279
|
-
|
|
8280
8817
|
;// ./lib/helpers/index.js
|
|
8281
8818
|
|
|
8282
8819
|
|
|
@@ -8291,6 +8828,7 @@ function isDescendingOrder({ arr = [], key }) {
|
|
|
8291
8828
|
|
|
8292
8829
|
;// ./lib/index.js
|
|
8293
8830
|
|
|
8831
|
+
|
|
8294
8832
|
const models = models_namespaceObject
|
|
8295
8833
|
|
|
8296
8834
|
|