@questwork/q-store-model 0.1.39 → 0.1.41
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 +1243 -692
- package/dist/index.min.js +1250 -692
- package/dist/q-store-model.min.js +1243 -692
- package/eslint.config.js +3 -0
- package/package.json +4 -3
package/dist/index.min.js
CHANGED
|
@@ -38,6 +38,8 @@ var __webpack_exports__ = {};
|
|
|
38
38
|
// EXPORTS
|
|
39
39
|
__webpack_require__.d(__webpack_exports__, {
|
|
40
40
|
J0: () => (/* reexport */ Amount),
|
|
41
|
+
XC: () => (/* reexport */ BillingAccount),
|
|
42
|
+
l8: () => (/* reexport */ BillingProject),
|
|
41
43
|
Z3: () => (/* reexport */ Cart),
|
|
42
44
|
m6: () => (/* reexport */ CartItem),
|
|
43
45
|
b7: () => (/* reexport */ Category),
|
|
@@ -58,13 +60,18 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
58
60
|
So: () => (/* reexport */ Merchandise),
|
|
59
61
|
pH: () => (/* reexport */ Order),
|
|
60
62
|
$x: () => (/* reexport */ OrderLine),
|
|
63
|
+
f7: () => (/* reexport */ PaymentCharge),
|
|
61
64
|
Zg: () => (/* reexport */ PaymentGateway),
|
|
65
|
+
MS: () => (/* reexport */ PaymentItem),
|
|
62
66
|
gp: () => (/* reexport */ PaymentResult),
|
|
63
67
|
gm: () => (/* reexport */ Price),
|
|
64
68
|
X0: () => (/* reexport */ PriceStrategy),
|
|
65
69
|
Yt: () => (/* reexport */ Product),
|
|
70
|
+
TA: () => (/* reexport */ Receipt),
|
|
71
|
+
Hx: () => (/* reexport */ ReceiptLine),
|
|
66
72
|
nW: () => (/* reexport */ Status),
|
|
67
73
|
TM: () => (/* reexport */ StatusQStore),
|
|
74
|
+
M: () => (/* reexport */ StatusQStoreInvoice),
|
|
68
75
|
Dy: () => (/* reexport */ StatusQStoreOrderLine),
|
|
69
76
|
vB: () => (/* reexport */ StoreItem),
|
|
70
77
|
ZX: () => (/* reexport */ Transaction),
|
|
@@ -97,6 +104,8 @@ var models_namespaceObject = {};
|
|
|
97
104
|
__webpack_require__.r(models_namespaceObject);
|
|
98
105
|
__webpack_require__.d(models_namespaceObject, {
|
|
99
106
|
Amount: () => (Amount),
|
|
107
|
+
BillingAccount: () => (BillingAccount),
|
|
108
|
+
BillingProject: () => (BillingProject),
|
|
100
109
|
Cart: () => (Cart),
|
|
101
110
|
CartItem: () => (CartItem),
|
|
102
111
|
Category: () => (Category),
|
|
@@ -112,13 +121,18 @@ __webpack_require__.d(models_namespaceObject, {
|
|
|
112
121
|
Merchandise: () => (Merchandise),
|
|
113
122
|
Order: () => (Order),
|
|
114
123
|
OrderLine: () => (OrderLine),
|
|
124
|
+
PaymentCharge: () => (PaymentCharge),
|
|
115
125
|
PaymentGateway: () => (PaymentGateway),
|
|
126
|
+
PaymentItem: () => (PaymentItem),
|
|
116
127
|
PaymentResult: () => (PaymentResult),
|
|
117
128
|
Price: () => (Price),
|
|
118
129
|
PriceStrategy: () => (PriceStrategy),
|
|
119
130
|
Product: () => (Product),
|
|
131
|
+
Receipt: () => (Receipt),
|
|
132
|
+
ReceiptLine: () => (ReceiptLine),
|
|
120
133
|
Status: () => (Status),
|
|
121
134
|
StatusQStore: () => (StatusQStore),
|
|
135
|
+
StatusQStoreInvoice: () => (StatusQStoreInvoice),
|
|
122
136
|
StatusQStoreOrderLine: () => (StatusQStoreOrderLine),
|
|
123
137
|
StoreItem: () => (StoreItem),
|
|
124
138
|
Transaction: () => (Transaction),
|
|
@@ -173,7 +187,7 @@ class Amount {
|
|
|
173
187
|
|
|
174
188
|
// getters
|
|
175
189
|
get isValid() {
|
|
176
|
-
return typeof this.currencyCode === 'string' && !!this.currencyCode && typeof this.value === 'number'
|
|
190
|
+
return typeof this.currencyCode === 'string' && !!this.currencyCode && typeof this.value === 'number'
|
|
177
191
|
}
|
|
178
192
|
|
|
179
193
|
// instance methods
|
|
@@ -203,13 +217,150 @@ class Amount {
|
|
|
203
217
|
|
|
204
218
|
|
|
205
219
|
|
|
206
|
-
|
|
207
220
|
;// external "@questwork/q-utilities"
|
|
208
221
|
var x = (y) => {
|
|
209
222
|
var x = {}; __webpack_require__.d(x, y); return x
|
|
210
223
|
}
|
|
211
224
|
var y = (x) => (() => (x))
|
|
212
225
|
const q_utilities_namespaceObject = x({ ["KeyValueObject"]: () => (__WEBPACK_EXTERNAL_MODULE__questwork_q_utilities_9fa93684__.KeyValueObject), ["Metadata"]: () => (__WEBPACK_EXTERNAL_MODULE__questwork_q_utilities_9fa93684__.Metadata), ["Repo"]: () => (__WEBPACK_EXTERNAL_MODULE__questwork_q_utilities_9fa93684__.Repo), ["Status"]: () => (__WEBPACK_EXTERNAL_MODULE__questwork_q_utilities_9fa93684__.Status), ["TenantAwareEntity"]: () => (__WEBPACK_EXTERNAL_MODULE__questwork_q_utilities_9fa93684__.TenantAwareEntity), ["formatDate"]: () => (__WEBPACK_EXTERNAL_MODULE__questwork_q_utilities_9fa93684__.formatDate), ["getValidation"]: () => (__WEBPACK_EXTERNAL_MODULE__questwork_q_utilities_9fa93684__.getValidation), ["getValueByKeys"]: () => (__WEBPACK_EXTERNAL_MODULE__questwork_q_utilities_9fa93684__.getValueByKeys) });
|
|
226
|
+
;// ./lib/models/billingAccount/billingAccount.js
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
const updateAllowedProps = [
|
|
230
|
+
'name',
|
|
231
|
+
]
|
|
232
|
+
|
|
233
|
+
class BillingAccount extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
234
|
+
constructor(options) {
|
|
235
|
+
options = options || {}
|
|
236
|
+
super(options)
|
|
237
|
+
|
|
238
|
+
const id = options._id || options.id
|
|
239
|
+
this.id = setId(id)
|
|
240
|
+
this._type = options._type || 'BillingAccount'
|
|
241
|
+
this.billingAccountCode = options.billingAccountCode
|
|
242
|
+
this.name = options.name
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
static dummyData() {
|
|
246
|
+
return {
|
|
247
|
+
tenantCode: 'tenantCode'
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
static get _classname() {
|
|
252
|
+
return 'BillingAccount'
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
static get _superclass() {
|
|
256
|
+
return 'BillingAccount'
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// get isValid() {
|
|
260
|
+
// return super.isValid
|
|
261
|
+
// }
|
|
262
|
+
|
|
263
|
+
update(obj) {
|
|
264
|
+
Object.keys(obj).forEach((key) => {
|
|
265
|
+
if (updateAllowedProps.includes(key)) {
|
|
266
|
+
this[key] = obj[key]
|
|
267
|
+
}
|
|
268
|
+
})
|
|
269
|
+
return super.update(obj)
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// function setCode(options, key) {
|
|
274
|
+
// const copyOptions = options || {}
|
|
275
|
+
// if (copyOptions[key]) {
|
|
276
|
+
// return copyOptions[key]
|
|
277
|
+
// }
|
|
278
|
+
// return stringHelper.setCode()
|
|
279
|
+
// }
|
|
280
|
+
|
|
281
|
+
function setId(id) {
|
|
282
|
+
if (id && typeof id.toString === 'function') {
|
|
283
|
+
return id.toString()
|
|
284
|
+
}
|
|
285
|
+
return id
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
;// ./lib/models/billingAccount/index.js
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
;// ./lib/models/billingProject/billingProject.js
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
const billingProject_updateAllowedProps = [
|
|
299
|
+
'name',
|
|
300
|
+
]
|
|
301
|
+
|
|
302
|
+
class BillingProject extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
303
|
+
constructor(options) {
|
|
304
|
+
options = options || {}
|
|
305
|
+
super(options)
|
|
306
|
+
|
|
307
|
+
const id = options._id || options.id
|
|
308
|
+
this.id = billingProject_setId(id)
|
|
309
|
+
this._type = options._type || 'BillingProject'
|
|
310
|
+
this.billingProjectCode = options.billingProjectCode
|
|
311
|
+
this.name = options.name
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
static dummyData() {
|
|
315
|
+
return {
|
|
316
|
+
tenantCode: 'tenantCode'
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
static get _classname() {
|
|
321
|
+
return 'BillingProject'
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
static get _superclass() {
|
|
325
|
+
return 'BillingProject'
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
// get isValid() {
|
|
329
|
+
// return super.isValid
|
|
330
|
+
// }
|
|
331
|
+
|
|
332
|
+
update(obj) {
|
|
333
|
+
Object.keys(obj).forEach((key) => {
|
|
334
|
+
if (billingProject_updateAllowedProps.includes(key)) {
|
|
335
|
+
this[key] = obj[key]
|
|
336
|
+
}
|
|
337
|
+
})
|
|
338
|
+
return super.update(obj)
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
// function setCode(options, key) {
|
|
343
|
+
// const copyOptions = options || {}
|
|
344
|
+
// if (copyOptions[key]) {
|
|
345
|
+
// return copyOptions[key]
|
|
346
|
+
// }
|
|
347
|
+
// return stringHelper.setCode()
|
|
348
|
+
// }
|
|
349
|
+
|
|
350
|
+
function billingProject_setId(id) {
|
|
351
|
+
if (id && typeof id.toString === 'function') {
|
|
352
|
+
return id.toString()
|
|
353
|
+
}
|
|
354
|
+
return id
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
;// ./lib/models/billingProject/index.js
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
|
|
213
364
|
;// external "lodash"
|
|
214
365
|
var external_lodash_x = (y) => {
|
|
215
366
|
var x = {}; __webpack_require__.d(x, y); return x
|
|
@@ -217,8 +368,7 @@ var external_lodash_x = (y) => {
|
|
|
217
368
|
var external_lodash_y = (x) => (() => (x))
|
|
218
369
|
const external_lodash_namespaceObject = external_lodash_x({ ["default"]: () => (__WEBPACK_EXTERNAL_MODULE_lodash__["default"]) });
|
|
219
370
|
;// ./lib/models/itemOptionFillIn/itemOptionFillIn.js
|
|
220
|
-
|
|
221
|
-
const updateAllowedProps = [
|
|
371
|
+
const itemOptionFillIn_updateAllowedProps = [
|
|
222
372
|
'value'
|
|
223
373
|
]
|
|
224
374
|
|
|
@@ -287,7 +437,7 @@ class ItemOptionFillIn {
|
|
|
287
437
|
|
|
288
438
|
update(update) {
|
|
289
439
|
Object.keys(update).forEach((key) => {
|
|
290
|
-
if (
|
|
440
|
+
if (itemOptionFillIn_updateAllowedProps.includes(key)) {
|
|
291
441
|
this[key] = update[key]
|
|
292
442
|
}
|
|
293
443
|
})
|
|
@@ -426,7 +576,7 @@ function eleInArrayComparator(target, compare, prop) {
|
|
|
426
576
|
return false
|
|
427
577
|
}
|
|
428
578
|
if (!Array.isArray(target[prop]) && !Array.isArray(compare[prop])) {
|
|
429
|
-
throw new
|
|
579
|
+
throw new TypeError('This function can only compare array.')
|
|
430
580
|
}
|
|
431
581
|
return checkDuplicateHelper_lodash.intersection(target[prop], compare[prop]) > 0
|
|
432
582
|
}
|
|
@@ -436,7 +586,7 @@ function eleAllInArrayComparator(target, compare, prop) {
|
|
|
436
586
|
return false
|
|
437
587
|
}
|
|
438
588
|
if (!Array.isArray(target[prop]) && !Array.isArray(compare[prop])) {
|
|
439
|
-
throw new
|
|
589
|
+
throw new TypeError('This function can only compare array.')
|
|
440
590
|
}
|
|
441
591
|
return checkDuplicateHelper_lodash.intersection(target[prop], compare[prop]) === target[prop].length
|
|
442
592
|
}
|
|
@@ -446,11 +596,12 @@ function eleOrderInArrayComparator(target, compare, prop) {
|
|
|
446
596
|
return false
|
|
447
597
|
}
|
|
448
598
|
if (!Array.isArray(target[prop]) && !Array.isArray(compare[prop])) {
|
|
449
|
-
throw new
|
|
599
|
+
throw new TypeError('This function can only compare array.')
|
|
450
600
|
}
|
|
451
601
|
return target[prop].reduce((acc, item, index) => {
|
|
452
602
|
const res = item === compare[prop][index]
|
|
453
|
-
if (acc === null)
|
|
603
|
+
if (acc === null)
|
|
604
|
+
return res
|
|
454
605
|
return res && acc
|
|
455
606
|
}, null)
|
|
456
607
|
}
|
|
@@ -467,12 +618,14 @@ function objectInArrayComparator(target, compare, prop) {
|
|
|
467
618
|
return false
|
|
468
619
|
}
|
|
469
620
|
if (!Array.isArray(target[prop]) && !Array.isArray(compare[prop])) {
|
|
470
|
-
throw new
|
|
621
|
+
throw new TypeError('This function can only compare array.')
|
|
471
622
|
}
|
|
472
623
|
return target[prop].reduce((acc, item) => {
|
|
473
|
-
if (acc === true)
|
|
624
|
+
if (acc === true)
|
|
625
|
+
return acc
|
|
474
626
|
const res = item.isSameIn(compare[prop])
|
|
475
|
-
if (acc === null)
|
|
627
|
+
if (acc === null)
|
|
628
|
+
return res
|
|
476
629
|
return res || acc
|
|
477
630
|
}, null)
|
|
478
631
|
}
|
|
@@ -482,11 +635,12 @@ function objectAllInArrayComparator(target, compare, prop) {
|
|
|
482
635
|
return false
|
|
483
636
|
}
|
|
484
637
|
if (!Array.isArray(target[prop]) && !Array.isArray(compare[prop])) {
|
|
485
|
-
throw new
|
|
638
|
+
throw new TypeError('This function can only compare array.')
|
|
486
639
|
}
|
|
487
640
|
return target[prop].reduce((acc, item) => {
|
|
488
641
|
const res = item.isSameIn(compare[prop])
|
|
489
|
-
if (acc === null)
|
|
642
|
+
if (acc === null)
|
|
643
|
+
return res
|
|
490
644
|
return res && acc
|
|
491
645
|
}, null)
|
|
492
646
|
}
|
|
@@ -496,14 +650,15 @@ function objectOrderInArrayComparator(target, compare, prop) {
|
|
|
496
650
|
return false
|
|
497
651
|
}
|
|
498
652
|
if (!Array.isArray(target[prop]) && !Array.isArray(compare[prop])) {
|
|
499
|
-
throw new
|
|
653
|
+
throw new TypeError('This function can only compare array.')
|
|
500
654
|
}
|
|
501
655
|
if (target[prop].length !== compare[prop].length) {
|
|
502
656
|
return false
|
|
503
657
|
}
|
|
504
658
|
return target[prop].reduce((acc, item, index) => {
|
|
505
659
|
const res = item.isSame(compare[prop][index])
|
|
506
|
-
if (acc === null)
|
|
660
|
+
if (acc === null)
|
|
661
|
+
return res
|
|
507
662
|
return res && acc
|
|
508
663
|
}, null)
|
|
509
664
|
}
|
|
@@ -521,7 +676,6 @@ function _getBoolean(value1, value2, operation) {
|
|
|
521
676
|
|
|
522
677
|
|
|
523
678
|
;// ./lib/helpers/utilHelper/responseHelper.js
|
|
524
|
-
|
|
525
679
|
const LATEST_RESPONSE_OBJ_VERSION = '20200130'
|
|
526
680
|
|
|
527
681
|
const STANDARD_RESPONSE_OBJ_ARRAY = [
|
|
@@ -570,7 +724,8 @@ class ResponseHelper {
|
|
|
570
724
|
// private functions
|
|
571
725
|
|
|
572
726
|
function getStandardResponseObjByVersion(ver = LATEST_RESPONSE_OBJ_VERSION) {
|
|
573
|
-
if (!ver)
|
|
727
|
+
if (!ver)
|
|
728
|
+
return null
|
|
574
729
|
return STANDARD_RESPONSE_OBJ_ARRAY.find((obj) => (obj.version === ver))
|
|
575
730
|
}
|
|
576
731
|
|
|
@@ -578,18 +733,18 @@ function getStandardResponseObjByVersion(ver = LATEST_RESPONSE_OBJ_VERSION) {
|
|
|
578
733
|
|
|
579
734
|
function makeResponseHelper(options) {
|
|
580
735
|
const helper = new ResponseHelper(options)
|
|
581
|
-
if (!helper.isValid)
|
|
736
|
+
if (!helper.isValid)
|
|
737
|
+
throw new TypeError('Invalid options for responseHelper')
|
|
582
738
|
return helper
|
|
583
739
|
}
|
|
584
740
|
|
|
585
741
|
|
|
586
742
|
|
|
587
743
|
;// ./lib/helpers/utilHelper/setQuery.js
|
|
588
|
-
|
|
589
744
|
/**
|
|
590
745
|
* set up query with or without clientAppName
|
|
591
|
-
* @param {
|
|
592
|
-
* @returns {
|
|
746
|
+
* @param {object} ctx - koa context
|
|
747
|
+
* @returns {object} query
|
|
593
748
|
*/
|
|
594
749
|
function setQuery({ ctx, ids }) {
|
|
595
750
|
const { clientApp } = ctx.state
|
|
@@ -630,7 +785,6 @@ function setQuery({ ctx, ids }) {
|
|
|
630
785
|
|
|
631
786
|
|
|
632
787
|
|
|
633
|
-
|
|
634
788
|
;// ./lib/helpers/stringHelper/stringHelper.js
|
|
635
789
|
function baseXEncode(num, base = 34) {
|
|
636
790
|
const charset = getBaseCharset(base)
|
|
@@ -638,18 +792,18 @@ function baseXEncode(num, base = 34) {
|
|
|
638
792
|
}
|
|
639
793
|
|
|
640
794
|
function encode(int, charset) {
|
|
641
|
-
|
|
795
|
+
const byCode = charset.byCode
|
|
642
796
|
if (int === 0) {
|
|
643
|
-
|
|
797
|
+
return byCode[0]
|
|
644
798
|
}
|
|
645
799
|
|
|
646
|
-
|
|
647
|
-
|
|
800
|
+
let res = ''
|
|
801
|
+
const max = charset.length
|
|
648
802
|
while (int > 0) {
|
|
649
|
-
|
|
650
|
-
|
|
803
|
+
res = byCode[int % max] + res
|
|
804
|
+
int = Math.floor(int / max)
|
|
651
805
|
}
|
|
652
|
-
return res
|
|
806
|
+
return res
|
|
653
807
|
}
|
|
654
808
|
|
|
655
809
|
function getBaseCharset(base) {
|
|
@@ -661,16 +815,16 @@ function getBaseCharset(base) {
|
|
|
661
815
|
}
|
|
662
816
|
|
|
663
817
|
function indexCharset(str) {
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
818
|
+
const byCode = {}
|
|
819
|
+
const byChar = {}
|
|
820
|
+
const length = str.length
|
|
821
|
+
let i; let char
|
|
668
822
|
for (i = 0; i < length; i++) {
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
823
|
+
char = str[i]
|
|
824
|
+
byCode[i] = char
|
|
825
|
+
byChar[char] = i
|
|
672
826
|
}
|
|
673
|
-
return { byCode
|
|
827
|
+
return { byCode, byChar, length }
|
|
674
828
|
}
|
|
675
829
|
|
|
676
830
|
function randomString({ len = 16, pattern = 'a1' } = {}) {
|
|
@@ -692,7 +846,7 @@ function randomString({ len = 16, pattern = 'a1' } = {}) {
|
|
|
692
846
|
str += mark
|
|
693
847
|
}
|
|
694
848
|
const chars = [...str]
|
|
695
|
-
return [...Array(len)].map(i => {
|
|
849
|
+
return [...new Array(len)].map((i) => {
|
|
696
850
|
return chars[(Math.random() * chars.length) | 0]
|
|
697
851
|
}).join``
|
|
698
852
|
}
|
|
@@ -727,7 +881,6 @@ const stringHelper = {
|
|
|
727
881
|
|
|
728
882
|
|
|
729
883
|
|
|
730
|
-
|
|
731
884
|
;// ./lib/models/itemOption/itemOptionLocale.js
|
|
732
885
|
const itemOptionLocale_updateAllowedProps = [
|
|
733
886
|
'label',
|
|
@@ -1009,7 +1162,6 @@ class MerchandiseOption {
|
|
|
1009
1162
|
|
|
1010
1163
|
|
|
1011
1164
|
;// ./lib/models/qtyPerTransaction/qtyPerTransaction.js
|
|
1012
|
-
|
|
1013
1165
|
const qtyPerTransaction_updateAllowedProps = [
|
|
1014
1166
|
'min',
|
|
1015
1167
|
'max',
|
|
@@ -1067,7 +1219,6 @@ class QtyPerTransaction {
|
|
|
1067
1219
|
|
|
1068
1220
|
|
|
1069
1221
|
|
|
1070
|
-
|
|
1071
1222
|
const priceStrategy_updateAllowedProps = [
|
|
1072
1223
|
'active',
|
|
1073
1224
|
'amounts',
|
|
@@ -1287,7 +1438,7 @@ function matchAnd(key, value, payload) {
|
|
|
1287
1438
|
/**
|
|
1288
1439
|
* Check if a value matches a formula.
|
|
1289
1440
|
* @param {*} val - The value to check.
|
|
1290
|
-
* @param {
|
|
1441
|
+
* @param {object} [formula] - The formula object to check the value against.
|
|
1291
1442
|
* @returns {boolean} - Whether the value matches the formula.
|
|
1292
1443
|
*/
|
|
1293
1444
|
function _matcher(val, formula = {}, actions = [], match = true) {
|
|
@@ -1329,7 +1480,7 @@ function _match({ action, formulaValue, val }) {
|
|
|
1329
1480
|
}
|
|
1330
1481
|
return false
|
|
1331
1482
|
case '$includes':
|
|
1332
|
-
return val.includes(formulaValue)
|
|
1483
|
+
return val && val.includes(formulaValue)
|
|
1333
1484
|
case '$keyValue':
|
|
1334
1485
|
if (Array.isArray(val)) {
|
|
1335
1486
|
return (val.find((remark) => {
|
|
@@ -1438,8 +1589,6 @@ class Price {
|
|
|
1438
1589
|
// return prices.filter((price) => price.roleCodes.length === 0 || lodash.intersection(roleCodes, price.roleCodes).length > 0)
|
|
1439
1590
|
// }
|
|
1440
1591
|
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
1592
|
// getters
|
|
1444
1593
|
get isValid() {
|
|
1445
1594
|
return this.priceStrategies.length > 0
|
|
@@ -1581,7 +1730,7 @@ class Product extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
1581
1730
|
this._ItemOption = _ItemOption && (_ItemOption._superclass === ItemOption) ? _ItemOption : ItemOption
|
|
1582
1731
|
|
|
1583
1732
|
const id = options._id || options.id
|
|
1584
|
-
this.id =
|
|
1733
|
+
this.id = product_setId(id)
|
|
1585
1734
|
this._type = options._type || 'Product'
|
|
1586
1735
|
|
|
1587
1736
|
this.couponDetails = options.couponDetails
|
|
@@ -1678,6 +1827,16 @@ class Product extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
1678
1827
|
getCode() {
|
|
1679
1828
|
return this.productCode
|
|
1680
1829
|
}
|
|
1830
|
+
getPreservedData() {
|
|
1831
|
+
return {
|
|
1832
|
+
metadata: this.metadata,
|
|
1833
|
+
name: this.name,
|
|
1834
|
+
productCode: this.productCode,
|
|
1835
|
+
productGroupName: this.productGroupName,
|
|
1836
|
+
productType: this.productType,
|
|
1837
|
+
tenantCode: this.tenantCode,
|
|
1838
|
+
}
|
|
1839
|
+
}
|
|
1681
1840
|
getMetadataValueByKey(key) {
|
|
1682
1841
|
return q_utilities_namespaceObject.Metadata.getValueByKey(this.metadata || [], key)
|
|
1683
1842
|
}
|
|
@@ -1723,7 +1882,7 @@ class Product extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
1723
1882
|
}
|
|
1724
1883
|
}
|
|
1725
1884
|
|
|
1726
|
-
function
|
|
1885
|
+
function product_setId(id) {
|
|
1727
1886
|
if (id && typeof id.toString === 'function') {
|
|
1728
1887
|
return id.toString()
|
|
1729
1888
|
}
|
|
@@ -1744,33 +1903,11 @@ function _getDataByKey(key, data) {
|
|
|
1744
1903
|
|
|
1745
1904
|
|
|
1746
1905
|
|
|
1747
|
-
;// ./lib/models/product/productRepo.js
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
class ProductRepo extends q_utilities_namespaceObject.Repo {
|
|
1752
|
-
constructor(options = {}) {
|
|
1753
|
-
options = options || {}
|
|
1754
|
-
super(options)
|
|
1755
|
-
const { _Product } = options._constructor || {}
|
|
1756
|
-
this._Product = _Product && (_Product._superclass === Product._superclass) ? _Product : Product
|
|
1757
|
-
}
|
|
1758
|
-
static get _classname() {
|
|
1759
|
-
return 'ProductRepo'
|
|
1760
|
-
}
|
|
1761
|
-
init(options) {
|
|
1762
|
-
return this._Product.init(options)
|
|
1763
|
-
}
|
|
1764
|
-
}
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
1906
|
;// ./lib/models/product/index.js
|
|
1769
1907
|
|
|
1770
1908
|
|
|
1771
1909
|
|
|
1772
1910
|
|
|
1773
|
-
|
|
1774
1911
|
;// ./lib/models/merchandise/merchandise.js
|
|
1775
1912
|
|
|
1776
1913
|
|
|
@@ -1985,13 +2122,13 @@ class Merchandise extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
1985
2122
|
const _currencyCode = currency || this.defaultCurrency
|
|
1986
2123
|
const price = this.getPriceByTimeAndRoleCodes(dateTimestamp, roleCodes)
|
|
1987
2124
|
if (!price) {
|
|
1988
|
-
obj.errorMessages.push(
|
|
2125
|
+
obj.errorMessages.push('Can\'t get available price for you.')
|
|
1989
2126
|
return obj
|
|
1990
2127
|
}
|
|
1991
2128
|
obj.price = price
|
|
1992
2129
|
const priceStrategies = price.getStrategiesByCurrencyAndQty(_currencyCode, qty)
|
|
1993
2130
|
if (priceStrategies.length === 0) {
|
|
1994
|
-
obj.errorMessages.push(
|
|
2131
|
+
obj.errorMessages.push('Can\'t get available strategies from price.')
|
|
1995
2132
|
return obj
|
|
1996
2133
|
}
|
|
1997
2134
|
const { convertedPriceStrategies, maxQty } = priceStrategies.reduce((acc, priceStrategy) => {
|
|
@@ -2089,7 +2226,7 @@ class Merchandise extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
2089
2226
|
getCode() {
|
|
2090
2227
|
return this.merchandiseCode
|
|
2091
2228
|
}
|
|
2092
|
-
getCurrentAmount({ currencyCode, payload, ignoreRestriction =
|
|
2229
|
+
getCurrentAmount({ currencyCode, payload, ignoreRestriction = false }) {
|
|
2093
2230
|
if (!this.currentPrice) {
|
|
2094
2231
|
return null
|
|
2095
2232
|
}
|
|
@@ -2143,6 +2280,16 @@ class Merchandise extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
2143
2280
|
}
|
|
2144
2281
|
return null
|
|
2145
2282
|
}
|
|
2283
|
+
getPreservedData() {
|
|
2284
|
+
return {
|
|
2285
|
+
merchandiseCode: this.merchandiseCode,
|
|
2286
|
+
merchandiseType: this.merchandiseType,
|
|
2287
|
+
metadata: this.metadata,
|
|
2288
|
+
name: this.name,
|
|
2289
|
+
productCodes: this.productCodes,
|
|
2290
|
+
tenantCode: this.tenantCode,
|
|
2291
|
+
}
|
|
2292
|
+
}
|
|
2146
2293
|
getPrices() {
|
|
2147
2294
|
return this.prices ? this.prices : []
|
|
2148
2295
|
}
|
|
@@ -2240,34 +2387,11 @@ function merchandise_setId(id) {
|
|
|
2240
2387
|
|
|
2241
2388
|
|
|
2242
2389
|
|
|
2243
|
-
;// ./lib/models/merchandise/merchandiseRepo.js
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
class MerchandiseRepo extends q_utilities_namespaceObject.Repo {
|
|
2248
|
-
constructor(options = {}) {
|
|
2249
|
-
options = options || {}
|
|
2250
|
-
super(options)
|
|
2251
|
-
const { _Merchandise } = options._constructor || {}
|
|
2252
|
-
this._Merchandise = _Merchandise && (_Merchandise._superclass === Merchandise._superclass) ? _Merchandise : Merchandise
|
|
2253
|
-
}
|
|
2254
|
-
static get _classname() {
|
|
2255
|
-
return 'MerchandiseRepo'
|
|
2256
|
-
}
|
|
2257
|
-
init(options) {
|
|
2258
|
-
return this._Merchandise.init(options)
|
|
2259
|
-
}
|
|
2260
|
-
}
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
2390
|
;// ./lib/models/merchandise/index.js
|
|
2265
2391
|
|
|
2266
2392
|
|
|
2267
2393
|
|
|
2268
2394
|
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
2395
|
;// ./lib/models/cartItem/cartItem.js
|
|
2272
2396
|
|
|
2273
2397
|
|
|
@@ -2424,9 +2548,9 @@ function mergeDuplicateCartItems(cartItems, array = []) {
|
|
|
2424
2548
|
const { itemOptionFillIns } = item
|
|
2425
2549
|
const arr = external_lodash_namespaceObject["default"].intersectionWith(itemOptionFillIns, cartItem.itemOptionFillIns, (obj1, obj2) => {
|
|
2426
2550
|
return obj1.target === obj2.target
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2551
|
+
&& obj1.targetCode === obj2.targetCode
|
|
2552
|
+
&& obj1.key === obj2.key
|
|
2553
|
+
&& external_lodash_namespaceObject["default"].intersection(obj1.value, obj2.value).length === obj1.value.length
|
|
2430
2554
|
})
|
|
2431
2555
|
if (arr.length === itemOptionFillIns.length) {
|
|
2432
2556
|
acc.matched = item
|
|
@@ -2460,9 +2584,7 @@ function cartItem_setCode(options, key) {
|
|
|
2460
2584
|
|
|
2461
2585
|
|
|
2462
2586
|
|
|
2463
|
-
|
|
2464
2587
|
;// ./lib/models/status/status.js
|
|
2465
|
-
|
|
2466
2588
|
const notUpdateAllowedProps = [
|
|
2467
2589
|
'created',
|
|
2468
2590
|
]
|
|
@@ -2627,7 +2749,8 @@ class Status {
|
|
|
2627
2749
|
return keys.reduce((acc, key) => {
|
|
2628
2750
|
if (this[key]) {
|
|
2629
2751
|
acc.push({
|
|
2630
|
-
key,
|
|
2752
|
+
key,
|
|
2753
|
+
value: this[key]
|
|
2631
2754
|
})
|
|
2632
2755
|
}
|
|
2633
2756
|
return acc
|
|
@@ -2803,7 +2926,7 @@ class Cart extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
2803
2926
|
|
|
2804
2927
|
this._merchandises = options._merchandises
|
|
2805
2928
|
this._type = options._type || 'Cart'
|
|
2806
|
-
|
|
2929
|
+
|
|
2807
2930
|
this.cartCode = cart_setCode(options, 'cartCode')
|
|
2808
2931
|
this.cartItems = this._CartItem.initOnlyValidFromArray(options.cartItems)
|
|
2809
2932
|
this.status = this._Status.init(options.status)
|
|
@@ -3067,35 +3190,11 @@ function cart_setId(id) {
|
|
|
3067
3190
|
|
|
3068
3191
|
|
|
3069
3192
|
|
|
3070
|
-
;// ./lib/models/cart/cartRepo.js
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
class CartRepo extends q_utilities_namespaceObject.Repo {
|
|
3075
|
-
constructor(options = {}) {
|
|
3076
|
-
options = options || {}
|
|
3077
|
-
super(options)
|
|
3078
|
-
const { _Cart } = options._constructor || {}
|
|
3079
|
-
this._Cart = _Cart && (_Cart._superclass === Cart._superclass)
|
|
3080
|
-
? _Cart
|
|
3081
|
-
: Cart
|
|
3082
|
-
}
|
|
3083
|
-
static get _classname() {
|
|
3084
|
-
return 'CartRepo'
|
|
3085
|
-
}
|
|
3086
|
-
init(options) {
|
|
3087
|
-
return this._Cart.init(options)
|
|
3088
|
-
}
|
|
3089
|
-
}
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
3193
|
;// ./lib/models/cart/index.js
|
|
3094
3194
|
|
|
3095
3195
|
|
|
3096
3196
|
|
|
3097
3197
|
|
|
3098
|
-
|
|
3099
3198
|
;// ./lib/models/category/category.js
|
|
3100
3199
|
|
|
3101
3200
|
|
|
@@ -3151,7 +3250,7 @@ class Category extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
3151
3250
|
|
|
3152
3251
|
// getters
|
|
3153
3252
|
get isValid() {
|
|
3154
|
-
return super.isValid && !!this.name && this.max > this.
|
|
3253
|
+
return super.isValid && !!this.name && this.max > this.min
|
|
3155
3254
|
}
|
|
3156
3255
|
get products() {
|
|
3157
3256
|
return this._Product.initOnlyValidFromArray(this._products)
|
|
@@ -3185,36 +3284,11 @@ function category_setId(id) {
|
|
|
3185
3284
|
|
|
3186
3285
|
|
|
3187
3286
|
|
|
3188
|
-
;// ./lib/models/category/categoryRepo.js
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
class CategoryRepo extends q_utilities_namespaceObject.Repo {
|
|
3193
|
-
constructor(options = {}) {
|
|
3194
|
-
options = options || {}
|
|
3195
|
-
super(options)
|
|
3196
|
-
const { _Category } = options._constructor || {}
|
|
3197
|
-
this._Category = _Category && (_Category._superclass === Category._superclass)
|
|
3198
|
-
? _Category
|
|
3199
|
-
: Category
|
|
3200
|
-
}
|
|
3201
|
-
static get _classname() {
|
|
3202
|
-
return 'CategoryRepo'
|
|
3203
|
-
}
|
|
3204
|
-
init(options) {
|
|
3205
|
-
return this._Category.init(options)
|
|
3206
|
-
}
|
|
3207
|
-
}
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
3287
|
;// ./lib/models/category/index.js
|
|
3212
3288
|
|
|
3213
3289
|
|
|
3214
3290
|
|
|
3215
3291
|
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
3292
|
;// ./lib/models/creditNoteLine/creditNoteLine.js
|
|
3219
3293
|
|
|
3220
3294
|
|
|
@@ -3268,7 +3342,6 @@ class CreditNoteLine extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
3268
3342
|
return 'CreditNoteLine'
|
|
3269
3343
|
}
|
|
3270
3344
|
|
|
3271
|
-
|
|
3272
3345
|
// getters
|
|
3273
3346
|
get isValid() {
|
|
3274
3347
|
return super.isValid && !!this.creditNoteCode
|
|
@@ -3316,35 +3389,11 @@ function creditNoteLine_setId(id) {
|
|
|
3316
3389
|
|
|
3317
3390
|
|
|
3318
3391
|
|
|
3319
|
-
;// ./lib/models/creditNoteLine/creditNoteLineRepo.js
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
class CreditNoteLineRepo extends q_utilities_namespaceObject.Repo {
|
|
3324
|
-
constructor(options = {}) {
|
|
3325
|
-
options = options || {}
|
|
3326
|
-
super(options)
|
|
3327
|
-
const { _CreditNoteLine } = options._constructor || {}
|
|
3328
|
-
this._CreditNoteLine = _CreditNoteLine && (_CreditNoteLine._superclass === CreditNoteLine._superclass)
|
|
3329
|
-
? _CreditNoteLine
|
|
3330
|
-
: CreditNoteLine
|
|
3331
|
-
}
|
|
3332
|
-
static get _classname() {
|
|
3333
|
-
return 'CreditNoteLineRepo'
|
|
3334
|
-
}
|
|
3335
|
-
init(options) {
|
|
3336
|
-
return this._CreditNoteLine.init(options)
|
|
3337
|
-
}
|
|
3338
|
-
}
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
3392
|
;// ./lib/models/creditNoteLine/index.js
|
|
3343
3393
|
|
|
3344
3394
|
|
|
3345
3395
|
|
|
3346
3396
|
|
|
3347
|
-
|
|
3348
3397
|
;// ./lib/models/creditNote/creditNote.js
|
|
3349
3398
|
|
|
3350
3399
|
|
|
@@ -3352,7 +3401,6 @@ class CreditNoteLineRepo extends q_utilities_namespaceObject.Repo {
|
|
|
3352
3401
|
|
|
3353
3402
|
|
|
3354
3403
|
|
|
3355
|
-
|
|
3356
3404
|
const creditNote_updateAllowedProps = [
|
|
3357
3405
|
'description',
|
|
3358
3406
|
'status'
|
|
@@ -3502,7 +3550,6 @@ class CreditNoteRepo extends q_utilities_namespaceObject.Repo {
|
|
|
3502
3550
|
|
|
3503
3551
|
|
|
3504
3552
|
|
|
3505
|
-
|
|
3506
3553
|
const currency_updateAllowedProps = [
|
|
3507
3554
|
'description',
|
|
3508
3555
|
'name',
|
|
@@ -3581,36 +3628,11 @@ function currency_setId(id) {
|
|
|
3581
3628
|
|
|
3582
3629
|
|
|
3583
3630
|
|
|
3584
|
-
;// ./lib/models/currency/currencyRepo.js
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
class CurrencyRepo extends q_utilities_namespaceObject.Repo {
|
|
3589
|
-
constructor(options = {}) {
|
|
3590
|
-
options = options || {}
|
|
3591
|
-
super(options)
|
|
3592
|
-
const { _Currency } = options._constructor || {}
|
|
3593
|
-
this._Currency = _Currency && (_Currency._superclass === Currency._superclass)
|
|
3594
|
-
? _Currency
|
|
3595
|
-
: Currency
|
|
3596
|
-
}
|
|
3597
|
-
static get _classname() {
|
|
3598
|
-
return 'CurrencyRepo'
|
|
3599
|
-
}
|
|
3600
|
-
init(options) {
|
|
3601
|
-
return this._Currency.init(options)
|
|
3602
|
-
}
|
|
3603
|
-
}
|
|
3604
|
-
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
3631
|
;// ./lib/models/currency/index.js
|
|
3608
3632
|
|
|
3609
3633
|
|
|
3610
3634
|
|
|
3611
3635
|
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
3636
|
;// ./lib/helpers/getPurchaseOptionValue/getPurchaseOptionValue.js
|
|
3615
3637
|
function getPurchaseOptionValue(options) {
|
|
3616
3638
|
const {
|
|
@@ -3622,7 +3644,9 @@ function getPurchaseOptionValue(options) {
|
|
|
3622
3644
|
if (!key) {
|
|
3623
3645
|
return purchaseOptions.reduce((acc, purchaseOption) => {
|
|
3624
3646
|
const arr = _getOnePurchaseOptionValue({
|
|
3625
|
-
delimiter,
|
|
3647
|
+
delimiter,
|
|
3648
|
+
purchaseOption,
|
|
3649
|
+
tag
|
|
3626
3650
|
})
|
|
3627
3651
|
if (tag) {
|
|
3628
3652
|
acc.push(`<${tag}>${arr.join('')}</${tag}>`)
|
|
@@ -3639,7 +3663,9 @@ function getPurchaseOptionValue(options) {
|
|
|
3639
3663
|
return []
|
|
3640
3664
|
}
|
|
3641
3665
|
return _getOnePurchaseOptionValue({
|
|
3642
|
-
delimiter,
|
|
3666
|
+
delimiter,
|
|
3667
|
+
purchaseOption,
|
|
3668
|
+
tag
|
|
3643
3669
|
})
|
|
3644
3670
|
}
|
|
3645
3671
|
|
|
@@ -3679,6 +3705,797 @@ function _getOnePurchaseOptionValue({
|
|
|
3679
3705
|
|
|
3680
3706
|
|
|
3681
3707
|
|
|
3708
|
+
;// ./lib/models/paymentGateway/paymentGateway.js
|
|
3709
|
+
|
|
3710
|
+
|
|
3711
|
+
|
|
3712
|
+
|
|
3713
|
+
const paymentGateway_updateAllowedProps = [
|
|
3714
|
+
'label',
|
|
3715
|
+
'logoUrl',
|
|
3716
|
+
'name',
|
|
3717
|
+
'sandbox',
|
|
3718
|
+
'setting',
|
|
3719
|
+
'surchargeBillingAccountCode',
|
|
3720
|
+
'surchargeBillingProjectCode',
|
|
3721
|
+
'surcharges'
|
|
3722
|
+
]
|
|
3723
|
+
|
|
3724
|
+
class PaymentGateway extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
3725
|
+
constructor(options = {}) {
|
|
3726
|
+
options = options || {}
|
|
3727
|
+
super(options) // a paymentGateway may also store 'ADDITIONALFIELDS' and 'RESTRICTIONS into metadata
|
|
3728
|
+
|
|
3729
|
+
const { _Price } = options._constructor || {}
|
|
3730
|
+
this._Price = _Price && (_Price._superclass === Price._superclass) ? _Price : Price
|
|
3731
|
+
|
|
3732
|
+
const id = options._id || options.id
|
|
3733
|
+
this.id = paymentGateway_setId(id)
|
|
3734
|
+
this._type = options._type || 'PaymentGateway'
|
|
3735
|
+
|
|
3736
|
+
this.hasWebhook = options.hasWebhook || false
|
|
3737
|
+
this.label = options.label
|
|
3738
|
+
this.logoUrl = options.logoUrl
|
|
3739
|
+
this.name = options.name || ''
|
|
3740
|
+
this.paymentGatewayCode = paymentGateway_setCode(options, 'paymentGatewayCode')
|
|
3741
|
+
this.paymentGatewayType = options.paymentGatewayType || 'PaymentGateway'
|
|
3742
|
+
this.paymentResultType = options.paymentResultType || 'PaymentResult'
|
|
3743
|
+
this.sandbox = options.sandbox || false
|
|
3744
|
+
this.setting = options.setting || null
|
|
3745
|
+
|
|
3746
|
+
this.surchargeBillingAccountCode = options.surchargeBillingAccountCode
|
|
3747
|
+
this.surchargeBillingProjectCode = options.surchargeBillingProjectCode
|
|
3748
|
+
this.surcharges = this._Price.initOnlyValidFromArray(options.surcharges)
|
|
3749
|
+
}
|
|
3750
|
+
static dummyData() {
|
|
3751
|
+
return {
|
|
3752
|
+
name: 'name',
|
|
3753
|
+
tenantCode: 'tenantCode'
|
|
3754
|
+
}
|
|
3755
|
+
}
|
|
3756
|
+
static get _classname() {
|
|
3757
|
+
return 'PaymentGateway'
|
|
3758
|
+
}
|
|
3759
|
+
static get _superclass() {
|
|
3760
|
+
return 'PaymentGateway'
|
|
3761
|
+
}
|
|
3762
|
+
|
|
3763
|
+
// getters
|
|
3764
|
+
get isValid() {
|
|
3765
|
+
return super.isValid && !!this.name
|
|
3766
|
+
}
|
|
3767
|
+
|
|
3768
|
+
// instance methods
|
|
3769
|
+
async createPayment() {
|
|
3770
|
+
throw new Error(`${this._classname} subclass should implement createPayment`)
|
|
3771
|
+
}
|
|
3772
|
+
async getAppPayParams() {
|
|
3773
|
+
throw new Error(`${this._classname} subclass should implement getAppPayParams`)
|
|
3774
|
+
}
|
|
3775
|
+
getCode() {
|
|
3776
|
+
return this.paymentGatewayCode
|
|
3777
|
+
}
|
|
3778
|
+
async updatePayment() {
|
|
3779
|
+
throw new Error(`${this._classname} subclass should implement updatePayment`)
|
|
3780
|
+
}
|
|
3781
|
+
async query() {
|
|
3782
|
+
throw new Error(`${this._classname} subclass should implement query`)
|
|
3783
|
+
}
|
|
3784
|
+
async submit() {
|
|
3785
|
+
throw new Error(`${this._classname} subclass should implement submit`)
|
|
3786
|
+
}
|
|
3787
|
+
|
|
3788
|
+
setCompletedRelatedStatus(status) {
|
|
3789
|
+
throw new Error(`${this.name} subclass should implement setCompletedRelatedStatus`)
|
|
3790
|
+
}
|
|
3791
|
+
update(update) {
|
|
3792
|
+
Object.keys(update).forEach((key) => {
|
|
3793
|
+
if (paymentGateway_updateAllowedProps.includes(key)) {
|
|
3794
|
+
if (key === 'surcharges') {
|
|
3795
|
+
this[key] = this._Price.initOnlyValidFromArray(update[key])
|
|
3796
|
+
} else {
|
|
3797
|
+
this[key] = update[key]
|
|
3798
|
+
}
|
|
3799
|
+
}
|
|
3800
|
+
})
|
|
3801
|
+
return super.update(update)
|
|
3802
|
+
}
|
|
3803
|
+
}
|
|
3804
|
+
|
|
3805
|
+
function paymentGateway_setCode(options, key) {
|
|
3806
|
+
const copyOptions = options || {}
|
|
3807
|
+
if (copyOptions[key]) {
|
|
3808
|
+
return copyOptions[key]
|
|
3809
|
+
}
|
|
3810
|
+
return stringHelper.setCode()
|
|
3811
|
+
}
|
|
3812
|
+
|
|
3813
|
+
function paymentGateway_setId(id) {
|
|
3814
|
+
if (id && typeof id.toString === 'function') {
|
|
3815
|
+
return id.toString()
|
|
3816
|
+
}
|
|
3817
|
+
return id
|
|
3818
|
+
}
|
|
3819
|
+
|
|
3820
|
+
|
|
3821
|
+
|
|
3822
|
+
;// ./lib/models/paymentGateway/index.js
|
|
3823
|
+
|
|
3824
|
+
|
|
3825
|
+
|
|
3826
|
+
|
|
3827
|
+
;// ./lib/models/statusQStore/statusQStore.js
|
|
3828
|
+
|
|
3829
|
+
|
|
3830
|
+
const statusQStore_notUpdateAllowedProps = (/* unused pure expression or super */ null && ([
|
|
3831
|
+
]))
|
|
3832
|
+
|
|
3833
|
+
class StatusQStore extends q_utilities_namespaceObject.Status {
|
|
3834
|
+
constructor(options) {
|
|
3835
|
+
options = options || {}
|
|
3836
|
+
super(options)
|
|
3837
|
+
|
|
3838
|
+
this.cancelled = this._ActionRecord.init(options.cancelled)
|
|
3839
|
+
this.completed = this._ActionRecord.init(options.completed)
|
|
3840
|
+
this.confirmed = this._ActionRecord.init(options.confirmed)
|
|
3841
|
+
this.deleted = this._ActionRecord.init(options.deleted)
|
|
3842
|
+
this.terminated = this._ActionRecord.init(options.terminated)
|
|
3843
|
+
}
|
|
3844
|
+
|
|
3845
|
+
static get _classname() {
|
|
3846
|
+
return 'StatusQStore'
|
|
3847
|
+
}
|
|
3848
|
+
get _classname() {
|
|
3849
|
+
return 'StatusQStore'
|
|
3850
|
+
}
|
|
3851
|
+
get isCancelled() {
|
|
3852
|
+
return this.cancelled?.timestamp > 0
|
|
3853
|
+
}
|
|
3854
|
+
get isCompleted() {
|
|
3855
|
+
return this.completed?.timestamp > 0
|
|
3856
|
+
}
|
|
3857
|
+
get isConfirmed() {
|
|
3858
|
+
return this.confirmed?.timestamp > 0
|
|
3859
|
+
}
|
|
3860
|
+
get isDeleted() {
|
|
3861
|
+
return this.deleted?.timestamp > 0
|
|
3862
|
+
}
|
|
3863
|
+
get isTerminated() {
|
|
3864
|
+
return this.terminated?.timestamp > 0
|
|
3865
|
+
}
|
|
3866
|
+
get isValid() {
|
|
3867
|
+
return super.isValid
|
|
3868
|
+
}
|
|
3869
|
+
setCancelled(value, actorCode) {
|
|
3870
|
+
return this.setValue(value, actorCode, 'cancelled')
|
|
3871
|
+
}
|
|
3872
|
+
setCompleted(value, actorCode) {
|
|
3873
|
+
return this.setValue(value, actorCode, 'completed')
|
|
3874
|
+
}
|
|
3875
|
+
setConfirmed(value, actorCode) {
|
|
3876
|
+
return this.setValue(value, actorCode, 'confirmed')
|
|
3877
|
+
}
|
|
3878
|
+
setDeleted(value, actorCode) {
|
|
3879
|
+
return this.setValue(value, actorCode, 'deleted')
|
|
3880
|
+
}
|
|
3881
|
+
setTerminated(value, actorCode) {
|
|
3882
|
+
return this.setValue(value, actorCode, 'terminated')
|
|
3883
|
+
}
|
|
3884
|
+
// update(update) {
|
|
3885
|
+
// Object.keys(update).forEach((key) => {
|
|
3886
|
+
// if (!notUpdateAllowedProps.includes(key)) {
|
|
3887
|
+
// this[key] = this[key] instanceof this._ActionRecord ? this[key].update(update[key]) : this._ActionRecord.init(update[key])
|
|
3888
|
+
// }
|
|
3889
|
+
// })
|
|
3890
|
+
// return super.update(update)
|
|
3891
|
+
// }
|
|
3892
|
+
}
|
|
3893
|
+
|
|
3894
|
+
;// ./lib/models/statusQStore/statusQStoreInvoice.js
|
|
3895
|
+
|
|
3896
|
+
|
|
3897
|
+
// const notUpdateAllowedProps = [
|
|
3898
|
+
// ]
|
|
3899
|
+
|
|
3900
|
+
class StatusQStoreInvoice extends StatusQStore {
|
|
3901
|
+
constructor(options) {
|
|
3902
|
+
options = options || {}
|
|
3903
|
+
super(options)
|
|
3904
|
+
|
|
3905
|
+
this.closed = this._ActionRecord.init(options.closed)
|
|
3906
|
+
this.open = this._ActionRecord.init(options.open)
|
|
3907
|
+
}
|
|
3908
|
+
|
|
3909
|
+
static get _classname() {
|
|
3910
|
+
return 'StatusQStoreInvoice'
|
|
3911
|
+
}
|
|
3912
|
+
get _classname() {
|
|
3913
|
+
return 'StatusQStoreInvoice'
|
|
3914
|
+
}
|
|
3915
|
+
get isClosed() {
|
|
3916
|
+
return this.closed?.timestamp > Date.now()
|
|
3917
|
+
}
|
|
3918
|
+
get isOpen() {
|
|
3919
|
+
return this.open?.timestamp > Date.now()
|
|
3920
|
+
}
|
|
3921
|
+
get isValid() {
|
|
3922
|
+
return super.isValid
|
|
3923
|
+
}
|
|
3924
|
+
setClosed(value, actorCode) {
|
|
3925
|
+
return this.setValue(value, actorCode, 'closed')
|
|
3926
|
+
}
|
|
3927
|
+
setOpen(value, actorCode) {
|
|
3928
|
+
return this.setValue(value, actorCode, 'open')
|
|
3929
|
+
}
|
|
3930
|
+
}
|
|
3931
|
+
|
|
3932
|
+
;// ./lib/models/statusQStore/statusQStoreOrderLine.js
|
|
3933
|
+
|
|
3934
|
+
|
|
3935
|
+
const statusQStoreOrderLine_notUpdateAllowedProps = (/* unused pure expression or super */ null && ([
|
|
3936
|
+
]))
|
|
3937
|
+
|
|
3938
|
+
class StatusQStoreOrderLine extends StatusQStore {
|
|
3939
|
+
constructor(options) {
|
|
3940
|
+
options = options || {}
|
|
3941
|
+
super(options)
|
|
3942
|
+
|
|
3943
|
+
this.expired = this._ActionRecord.init(options.expired)
|
|
3944
|
+
this.invalid = this._ActionRecord.init(options.invalid)
|
|
3945
|
+
}
|
|
3946
|
+
|
|
3947
|
+
static get _classname() {
|
|
3948
|
+
return 'StatusQStoreOrderLine'
|
|
3949
|
+
}
|
|
3950
|
+
get _classname() {
|
|
3951
|
+
return 'StatusQStoreOrderLine'
|
|
3952
|
+
}
|
|
3953
|
+
get isExpired() {
|
|
3954
|
+
return this.expired?.timestamp > Date.now()
|
|
3955
|
+
}
|
|
3956
|
+
get isInvalid() {
|
|
3957
|
+
return this.invalid?.timestamp > Date.now()
|
|
3958
|
+
}
|
|
3959
|
+
get isValid() {
|
|
3960
|
+
return super.isValid
|
|
3961
|
+
}
|
|
3962
|
+
setExpired(value, actorCode) {
|
|
3963
|
+
return this.setValue(value, actorCode, 'expired')
|
|
3964
|
+
}
|
|
3965
|
+
setInvalid(value, actorCode) {
|
|
3966
|
+
return this.setValue(value, actorCode, 'invalid')
|
|
3967
|
+
}
|
|
3968
|
+
// update(update) {
|
|
3969
|
+
// Object.keys(update).forEach((key) => {
|
|
3970
|
+
// if (!notUpdateAllowedProps.includes(key)) {
|
|
3971
|
+
// this[key] = this[key] instanceof this._ActionRecord ? this[key].update(update[key]) : this._ActionRecord.init(update[key])
|
|
3972
|
+
// }
|
|
3973
|
+
// })
|
|
3974
|
+
// return super.update(update)
|
|
3975
|
+
// }
|
|
3976
|
+
}
|
|
3977
|
+
|
|
3978
|
+
;// ./lib/models/statusQStore/index.js
|
|
3979
|
+
|
|
3980
|
+
|
|
3981
|
+
|
|
3982
|
+
|
|
3983
|
+
|
|
3984
|
+
|
|
3985
|
+
;// ./lib/models/paymentCharge/paymentCharge.js
|
|
3986
|
+
|
|
3987
|
+
|
|
3988
|
+
|
|
3989
|
+
|
|
3990
|
+
|
|
3991
|
+
|
|
3992
|
+
const paymentCharge_updateAllowedProps = [
|
|
3993
|
+
'amount',
|
|
3994
|
+
]
|
|
3995
|
+
|
|
3996
|
+
class PaymentCharge extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
3997
|
+
constructor(options) {
|
|
3998
|
+
options = options || {}
|
|
3999
|
+
super(options)
|
|
4000
|
+
|
|
4001
|
+
const { _Amount, _PaymentGateway, _Receipt, _ReceiptLine } = options._constructor || {}
|
|
4002
|
+
this._Amount = _Amount && (_Amount._superclass === Amount._superclass) ? _Amount : Amount
|
|
4003
|
+
this._PaymentGateway = _PaymentGateway && (_PaymentGateway._superclass === PaymentGateway._superclass) ? _PaymentGateway : PaymentGateway
|
|
4004
|
+
this._Receipt = _Receipt && (_Receipt._superclass === Receipt._superclass) ? _Receipt : Receipt
|
|
4005
|
+
this._ReceiptLine = _ReceiptLine && (_ReceiptLine._superclass === ReceiptLine._superclass) ? _ReceiptLine : ReceiptLine
|
|
4006
|
+
|
|
4007
|
+
this._paymentGateway = options._paymentGateway
|
|
4008
|
+
this._receipt = options._receipt
|
|
4009
|
+
this._receiptLine = options._receiptLine
|
|
4010
|
+
|
|
4011
|
+
const id = options._id || options.id
|
|
4012
|
+
this.id = paymentCharge_setId(id)
|
|
4013
|
+
this._type = options._type || 'PaymentCharge'
|
|
4014
|
+
this.amount = this._Amount.init(options.amount)
|
|
4015
|
+
this.billingAccountCode = options.billingAccountCode
|
|
4016
|
+
this.billingProjectCode = options.billingProjectCode
|
|
4017
|
+
this.paymentGatewayCode = options.paymentGatewayCode
|
|
4018
|
+
this.paymentChargeCode = options.paymentChargeCode
|
|
4019
|
+
this.paymentChargeType = 'PaymentCharge'
|
|
4020
|
+
this.receiptCode = options.receiptCode
|
|
4021
|
+
this.receiptDate = options.receiptDate || (new Date()).valueOf()
|
|
4022
|
+
this.receiptLineCode = options.receiptLineCode
|
|
4023
|
+
// this.status = this._Status.init(options.status)
|
|
4024
|
+
}
|
|
4025
|
+
|
|
4026
|
+
static dummyData() {
|
|
4027
|
+
return {
|
|
4028
|
+
billingAccountCode: 'billingAccountCode',
|
|
4029
|
+
paymentGatewayCode: 'paymentGatewayCode',
|
|
4030
|
+
receiptCode: 'receiptCode',
|
|
4031
|
+
receiptLineCode: 'receiptLineCode',
|
|
4032
|
+
tenantCode: 'tenantCode'
|
|
4033
|
+
}
|
|
4034
|
+
}
|
|
4035
|
+
|
|
4036
|
+
static get _classname() {
|
|
4037
|
+
return 'PaymentCharge'
|
|
4038
|
+
}
|
|
4039
|
+
|
|
4040
|
+
static get _superclass() {
|
|
4041
|
+
return 'PaymentCharge'
|
|
4042
|
+
}
|
|
4043
|
+
|
|
4044
|
+
get isValid() {
|
|
4045
|
+
return super.isValid && !!this.billingAccountCode && !!this.paymentGatewayCode && !!this.receiptCode && !!this.receiptLineCode
|
|
4046
|
+
}
|
|
4047
|
+
|
|
4048
|
+
get paymentGateway() {
|
|
4049
|
+
return this._PaymentGateway.init(this._paymentGateway)
|
|
4050
|
+
}
|
|
4051
|
+
|
|
4052
|
+
get receipt() {
|
|
4053
|
+
return this._Receipt.init(this._receipt)
|
|
4054
|
+
}
|
|
4055
|
+
|
|
4056
|
+
get receiptLines() {
|
|
4057
|
+
return this._ReceiptLine.initOnlyValidFromArray(this._receiptLines || [])
|
|
4058
|
+
}
|
|
4059
|
+
|
|
4060
|
+
update(obj) {
|
|
4061
|
+
Object.keys(obj).forEach((key) => {
|
|
4062
|
+
if (paymentCharge_updateAllowedProps.includes(key)) {
|
|
4063
|
+
if (key === 'amount') {
|
|
4064
|
+
this[key] = this.amount instanceof this._Amount ? this.amount.update(obj[key]) : this._Amount.init(obj[key])
|
|
4065
|
+
} else {
|
|
4066
|
+
this[key] = obj[key]
|
|
4067
|
+
}
|
|
4068
|
+
}
|
|
4069
|
+
})
|
|
4070
|
+
return super.update(obj)
|
|
4071
|
+
}
|
|
4072
|
+
}
|
|
4073
|
+
|
|
4074
|
+
function paymentCharge_setId(id) {
|
|
4075
|
+
if (id && typeof id.toString === 'function') {
|
|
4076
|
+
return id.toString()
|
|
4077
|
+
}
|
|
4078
|
+
return id
|
|
4079
|
+
}
|
|
4080
|
+
|
|
4081
|
+
|
|
4082
|
+
|
|
4083
|
+
;// ./lib/models/paymentCharge/index.js
|
|
4084
|
+
|
|
4085
|
+
|
|
4086
|
+
|
|
4087
|
+
|
|
4088
|
+
;// ./lib/models/receiptLine/receiptLine.js
|
|
4089
|
+
|
|
4090
|
+
|
|
4091
|
+
|
|
4092
|
+
|
|
4093
|
+
|
|
4094
|
+
|
|
4095
|
+
|
|
4096
|
+
const receiptLine_updateAllowedProps = [
|
|
4097
|
+
'additionalData',
|
|
4098
|
+
'amount',
|
|
4099
|
+
'paidAmount',
|
|
4100
|
+
'paymentGatewayCode',
|
|
4101
|
+
'receiptDate',
|
|
4102
|
+
'status',
|
|
4103
|
+
'surcharge'
|
|
4104
|
+
]
|
|
4105
|
+
|
|
4106
|
+
class ReceiptLine extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
4107
|
+
constructor(options) {
|
|
4108
|
+
options = options || {}
|
|
4109
|
+
super(options)
|
|
4110
|
+
|
|
4111
|
+
const { _Amount, _PaymentCharge, _PaymentItem, _Receipt, _Status } = options._constructor || {}
|
|
4112
|
+
this._Amount = _Amount && (_Amount._superclass === Amount._superclass) ? _Amount : Amount
|
|
4113
|
+
this._PaymentCharge = _PaymentCharge && (_PaymentCharge._superclass === PaymentCharge._superclass) ? _PaymentCharge : PaymentCharge
|
|
4114
|
+
this._PaymentItem = _PaymentItem && (_PaymentItem._superclass === PaymentItem._superclass) ? _PaymentItem : PaymentItem
|
|
4115
|
+
this._Receipt = _Receipt && (_Receipt._superclass === Receipt._superclass) ? _Receipt : Receipt
|
|
4116
|
+
this._Status = _Status && (_Status._superclass === StatusQStore._superclass) ? _Status : StatusQStore
|
|
4117
|
+
|
|
4118
|
+
this._paymentCharge = options._paymentCharge
|
|
4119
|
+
this._paymentItems = options._paymentItems
|
|
4120
|
+
this._receipt = options._receipt
|
|
4121
|
+
|
|
4122
|
+
const id = options._id || options.id
|
|
4123
|
+
this.id = receiptLine_setId(id)
|
|
4124
|
+
this._type = options._type || 'ReceiptLine'
|
|
4125
|
+
this.additionalData = q_utilities_namespaceObject.KeyValueObject.initOnlyValidFromArray(options.additionalData)
|
|
4126
|
+
this.amount = this._Amount.init(options.amount)
|
|
4127
|
+
this.paidAmount = this._Amount.init(options.paidAmount)
|
|
4128
|
+
this.paymentGatewayCode = options.paymentGatewayCode
|
|
4129
|
+
this.receiptCode = options.receiptCode
|
|
4130
|
+
this.receiptDate = options.receiptDate || (new Date()).valueOf()
|
|
4131
|
+
this.receiptLineCode = options.receiptLineCode
|
|
4132
|
+
this.receiptLineType = 'ReceiptLine'
|
|
4133
|
+
this.status = this._Status.init(options.status)
|
|
4134
|
+
this.surcharge = this._Amount.init(options.surcharge)
|
|
4135
|
+
}
|
|
4136
|
+
|
|
4137
|
+
static dummyData() {
|
|
4138
|
+
return {
|
|
4139
|
+
receiptCode: 'receiptCode',
|
|
4140
|
+
tenantCode: 'tenantCode'
|
|
4141
|
+
}
|
|
4142
|
+
}
|
|
4143
|
+
|
|
4144
|
+
static get _classname() {
|
|
4145
|
+
return 'ReceiptLine'
|
|
4146
|
+
}
|
|
4147
|
+
|
|
4148
|
+
static get _superclass() {
|
|
4149
|
+
return 'ReceiptLine'
|
|
4150
|
+
}
|
|
4151
|
+
|
|
4152
|
+
get isCancelled() {
|
|
4153
|
+
return this.status.isCancelled
|
|
4154
|
+
}
|
|
4155
|
+
|
|
4156
|
+
get isCompleted() {
|
|
4157
|
+
return this.status.isCompleted
|
|
4158
|
+
}
|
|
4159
|
+
|
|
4160
|
+
get isConfirmed() {
|
|
4161
|
+
return this.status.isConfirmed
|
|
4162
|
+
}
|
|
4163
|
+
|
|
4164
|
+
get isTerminated() {
|
|
4165
|
+
return this.status.isTerminated
|
|
4166
|
+
}
|
|
4167
|
+
|
|
4168
|
+
get isValid() {
|
|
4169
|
+
return super.isValid && !!this.receiptCode
|
|
4170
|
+
}
|
|
4171
|
+
|
|
4172
|
+
get paymentCharge() {
|
|
4173
|
+
return this._PaymentCharge.init(this._paymentCharge)
|
|
4174
|
+
}
|
|
4175
|
+
get paymentItems() {
|
|
4176
|
+
return this._PaymentItem.initOnlyValidFromArray(this._paymentItems)
|
|
4177
|
+
}
|
|
4178
|
+
get receipt() {
|
|
4179
|
+
return this._Receipt.init(this._receipt)
|
|
4180
|
+
}
|
|
4181
|
+
|
|
4182
|
+
getAmount() {
|
|
4183
|
+
return this.amount
|
|
4184
|
+
}
|
|
4185
|
+
|
|
4186
|
+
setCancelled(value, actorCode) {
|
|
4187
|
+
this.status.setCancelled(value, actorCode)
|
|
4188
|
+
return this.setModified()
|
|
4189
|
+
}
|
|
4190
|
+
|
|
4191
|
+
setCompleted(value, actorCode) {
|
|
4192
|
+
this.status.setCompleted(value, actorCode)
|
|
4193
|
+
return this.setModified()
|
|
4194
|
+
}
|
|
4195
|
+
setConfirmed(value, actorCode) {
|
|
4196
|
+
this.status.setProcessing(value, actorCode)
|
|
4197
|
+
return this.setModified()
|
|
4198
|
+
}
|
|
4199
|
+
|
|
4200
|
+
setTerminated(value, actorCode) {
|
|
4201
|
+
this.status.setTerminated(value, actorCode)
|
|
4202
|
+
return this.setModified()
|
|
4203
|
+
}
|
|
4204
|
+
|
|
4205
|
+
update(obj) {
|
|
4206
|
+
Object.keys(obj).forEach((key) => {
|
|
4207
|
+
if (receiptLine_updateAllowedProps.includes(key)) {
|
|
4208
|
+
if (key === 'additionalData') {
|
|
4209
|
+
this[key] = q_utilities_namespaceObject.KeyValueObject.initOnlyValidFromArray(obj[key])
|
|
4210
|
+
} else if (key === 'status') {
|
|
4211
|
+
this[key] = this[key] instanceof this._Status ? this[key].update(obj[key]) : this._Status.init(obj[key])
|
|
4212
|
+
} else if (key === 'amount' || key === 'paidAmount' || key === 'surcharge') {
|
|
4213
|
+
this[key] = this[key] instanceof this._Amount ? this[key].update(obj[key]) : this._Amount.init(obj[key])
|
|
4214
|
+
} else {
|
|
4215
|
+
this[key] = obj[key]
|
|
4216
|
+
}
|
|
4217
|
+
}
|
|
4218
|
+
})
|
|
4219
|
+
return super.update(obj)
|
|
4220
|
+
}
|
|
4221
|
+
}
|
|
4222
|
+
|
|
4223
|
+
function receiptLine_setId(id) {
|
|
4224
|
+
if (id && typeof id.toString === 'function') {
|
|
4225
|
+
return id.toString()
|
|
4226
|
+
}
|
|
4227
|
+
return id
|
|
4228
|
+
}
|
|
4229
|
+
|
|
4230
|
+
|
|
4231
|
+
|
|
4232
|
+
;// ./lib/models/receiptLine/index.js
|
|
4233
|
+
|
|
4234
|
+
|
|
4235
|
+
|
|
4236
|
+
|
|
4237
|
+
;// ./lib/models/receipt/receipt.js
|
|
4238
|
+
|
|
4239
|
+
|
|
4240
|
+
|
|
4241
|
+
|
|
4242
|
+
|
|
4243
|
+
const receipt_updateAllowedProps = [
|
|
4244
|
+
'amount',
|
|
4245
|
+
'paidAmount',
|
|
4246
|
+
'receiptDate',
|
|
4247
|
+
'revisionNumber',
|
|
4248
|
+
'status',
|
|
4249
|
+
'surcharge'
|
|
4250
|
+
]
|
|
4251
|
+
|
|
4252
|
+
class Receipt extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
4253
|
+
constructor(options) {
|
|
4254
|
+
options = options || {}
|
|
4255
|
+
super(options)
|
|
4256
|
+
|
|
4257
|
+
const { _Amount, _ReceiptLine, _Status } = options._constructor || {}
|
|
4258
|
+
this._Amount = _Amount && (_Amount._superclass === Amount._superclass) ? _Amount : Amount
|
|
4259
|
+
this._ReceiptLine = _ReceiptLine && (_ReceiptLine._superclass === ReceiptLine._superclass) ? _ReceiptLine : ReceiptLine
|
|
4260
|
+
this._Status = _Status && (_Status._superclass === StatusQStore._superclass) ? _Status : StatusQStore
|
|
4261
|
+
|
|
4262
|
+
this._receiptLines = options._receiptLines
|
|
4263
|
+
|
|
4264
|
+
const id = options._id || options.id
|
|
4265
|
+
this.id = receipt_setId(id)
|
|
4266
|
+
this._type = options._type || 'Receipt'
|
|
4267
|
+
this.amount = this._Amount.init(options.amount)
|
|
4268
|
+
this.paidAmount = this._Amount.init(options.paidAmount)
|
|
4269
|
+
this.receiptCode = options.receiptCode
|
|
4270
|
+
this.receiptDate = options.receiptDate || (new Date()).valueOf()
|
|
4271
|
+
this.receiptNumber = options.receiptNumber
|
|
4272
|
+
this.receiptType = 'Receipt'
|
|
4273
|
+
this.revisionNumber = options.revisionNumber || 1
|
|
4274
|
+
this.status = this._Status.init(options.status)
|
|
4275
|
+
this.surcharge = this._Amount.init(options.surcharge)
|
|
4276
|
+
}
|
|
4277
|
+
|
|
4278
|
+
static dummyData() {
|
|
4279
|
+
return {
|
|
4280
|
+
tenantCode: 'tenantCode'
|
|
4281
|
+
}
|
|
4282
|
+
}
|
|
4283
|
+
|
|
4284
|
+
static get _classname() {
|
|
4285
|
+
return 'Receipt'
|
|
4286
|
+
}
|
|
4287
|
+
|
|
4288
|
+
static get _superclass() {
|
|
4289
|
+
return 'Receipt'
|
|
4290
|
+
}
|
|
4291
|
+
|
|
4292
|
+
// get isValid() {
|
|
4293
|
+
// return super.isValid
|
|
4294
|
+
// }
|
|
4295
|
+
|
|
4296
|
+
get isCancelled() {
|
|
4297
|
+
return this.status.isCancelled
|
|
4298
|
+
}
|
|
4299
|
+
|
|
4300
|
+
get isCompleted() {
|
|
4301
|
+
return this.status.isCompleted
|
|
4302
|
+
}
|
|
4303
|
+
|
|
4304
|
+
get isConfirmed() {
|
|
4305
|
+
return this.status.isConfirmed
|
|
4306
|
+
}
|
|
4307
|
+
|
|
4308
|
+
get isTerminated() {
|
|
4309
|
+
return this.status.isTerminated
|
|
4310
|
+
}
|
|
4311
|
+
|
|
4312
|
+
get receiptLines() {
|
|
4313
|
+
return this._ReceiptLine.initOnlyValidFromArray(this._receiptLines || [])
|
|
4314
|
+
}
|
|
4315
|
+
|
|
4316
|
+
getAmount() {
|
|
4317
|
+
return this.amount
|
|
4318
|
+
}
|
|
4319
|
+
|
|
4320
|
+
getFullReceiptNumber(delimiter = '.') {
|
|
4321
|
+
return `${this.receiptNumber}${delimiter}${this.revisionNumber}`
|
|
4322
|
+
}
|
|
4323
|
+
|
|
4324
|
+
increaseRevisionNumber() {
|
|
4325
|
+
this.revisionNumber += 1
|
|
4326
|
+
return this
|
|
4327
|
+
}
|
|
4328
|
+
|
|
4329
|
+
setCancelled(value, actorCode) {
|
|
4330
|
+
this.status.setCancelled(value, actorCode)
|
|
4331
|
+
return this.setModified()
|
|
4332
|
+
}
|
|
4333
|
+
|
|
4334
|
+
setCompleted(value, actorCode) {
|
|
4335
|
+
this.status.setCompleted(value, actorCode)
|
|
4336
|
+
return this.setModified()
|
|
4337
|
+
}
|
|
4338
|
+
setConfirmed(value, actorCode) {
|
|
4339
|
+
this.status.setProcessing(value, actorCode)
|
|
4340
|
+
return this.setModified()
|
|
4341
|
+
}
|
|
4342
|
+
|
|
4343
|
+
setTerminated(value, actorCode) {
|
|
4344
|
+
this.status.setTerminated(value, actorCode)
|
|
4345
|
+
return this.setModified()
|
|
4346
|
+
}
|
|
4347
|
+
|
|
4348
|
+
update(obj) {
|
|
4349
|
+
Object.keys(obj).forEach((key) => {
|
|
4350
|
+
if (receipt_updateAllowedProps.includes(key)) {
|
|
4351
|
+
if (key === 'status') {
|
|
4352
|
+
this[key] = this.status instanceof this._Status ? this.status.update(obj[key]) : this._Status.init(obj[key])
|
|
4353
|
+
} else if (key === 'amount' || key === 'paidAmount' || key === 'surcharge') {
|
|
4354
|
+
this[key] = this[key] instanceof this._Amount ? this[key].update(obj[key]) : this._Amount.init(obj[key])
|
|
4355
|
+
} else {
|
|
4356
|
+
this[key] = obj[key]
|
|
4357
|
+
}
|
|
4358
|
+
}
|
|
4359
|
+
})
|
|
4360
|
+
return super.update(obj)
|
|
4361
|
+
}
|
|
4362
|
+
}
|
|
4363
|
+
|
|
4364
|
+
function receipt_setId(id) {
|
|
4365
|
+
if (id && typeof id.toString === 'function') {
|
|
4366
|
+
return id.toString()
|
|
4367
|
+
}
|
|
4368
|
+
return id
|
|
4369
|
+
}
|
|
4370
|
+
|
|
4371
|
+
|
|
4372
|
+
|
|
4373
|
+
;// ./lib/models/receipt/index.js
|
|
4374
|
+
|
|
4375
|
+
|
|
4376
|
+
|
|
4377
|
+
|
|
4378
|
+
;// ./lib/models/paymentItem/paymentItem.js
|
|
4379
|
+
|
|
4380
|
+
|
|
4381
|
+
// import { StatusQStore } from '../statusQStore/index.js'
|
|
4382
|
+
|
|
4383
|
+
|
|
4384
|
+
|
|
4385
|
+
|
|
4386
|
+
|
|
4387
|
+
|
|
4388
|
+
const paymentItem_updateAllowedProps = [
|
|
4389
|
+
'amount',
|
|
4390
|
+
]
|
|
4391
|
+
|
|
4392
|
+
class PaymentItem extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
4393
|
+
constructor(options) {
|
|
4394
|
+
options = options || {}
|
|
4395
|
+
super(options)
|
|
4396
|
+
|
|
4397
|
+
const { _Amount, _Invoice, _InvoiceLine, _PaymentGateway, _Receipt, _ReceiptLine } = options._constructor || {}
|
|
4398
|
+
this._Amount = _Amount && (_Amount._superclass === Amount._superclass) ? _Amount : Amount
|
|
4399
|
+
this._Invoice = _Invoice && (_Invoice._superclass === Invoice._superclass) ? _Invoice : Invoice
|
|
4400
|
+
this._InvoiceLine = _InvoiceLine && (_InvoiceLine._superclass === InvoiceLine._superclass) ? _InvoiceLine : InvoiceLine
|
|
4401
|
+
this._PaymentGateway = _PaymentGateway && (_PaymentGateway._superclass === PaymentGateway._superclass) ? _PaymentGateway : PaymentGateway
|
|
4402
|
+
this._Receipt = _Receipt && (_Receipt._superclass === Receipt._superclass) ? _Receipt : Receipt
|
|
4403
|
+
this._ReceiptLine = _ReceiptLine && (_ReceiptLine._superclass === ReceiptLine._superclass) ? _ReceiptLine : ReceiptLine
|
|
4404
|
+
// this._Status = _Status && (_Status._superclass === StatusQStore._superclass) ? _Status : StatusQStore
|
|
4405
|
+
|
|
4406
|
+
this._invoice = options._invoice
|
|
4407
|
+
this._invoiceLines = options._invoiceLines
|
|
4408
|
+
this._paymentGateway = options._paymentGateway
|
|
4409
|
+
this._receipt = options._receipt
|
|
4410
|
+
this._receiptLine = options._receiptLine
|
|
4411
|
+
|
|
4412
|
+
const id = options._id || options.id
|
|
4413
|
+
this.id = paymentItem_setId(id)
|
|
4414
|
+
this._type = options._type || 'PaymentItem'
|
|
4415
|
+
this.amount = this._Amount.init(options.amount)
|
|
4416
|
+
this.invoiceCode = options.invoiceCode
|
|
4417
|
+
this.invoiceDate = options.invoiceDate || (new Date()).valueOf()
|
|
4418
|
+
this.invoiceLineCode = options.invoiceLineCode
|
|
4419
|
+
this.paymentGatewayCode = options.paymentGatewayCode
|
|
4420
|
+
this.paymentItemCode = options.paymentItemCode
|
|
4421
|
+
this.paymentItemType = 'PaymentItem'
|
|
4422
|
+
this.receiptCode = options.receiptCode
|
|
4423
|
+
this.receiptDate = options.receiptDate || (new Date()).valueOf()
|
|
4424
|
+
this.receiptLineCode = options.receiptLineCode
|
|
4425
|
+
// this.status = this._Status.init(options.status)
|
|
4426
|
+
}
|
|
4427
|
+
|
|
4428
|
+
static dummyData() {
|
|
4429
|
+
return {
|
|
4430
|
+
invoiceCode: 'invoiceCode',
|
|
4431
|
+
invoiceLineCode: 'invoiceLineCode',
|
|
4432
|
+
paymentGatewayCode: 'paymentGatewayCode',
|
|
4433
|
+
receiptCode: 'receiptCode',
|
|
4434
|
+
receiptLineCode: 'receiptLineCode',
|
|
4435
|
+
tenantCode: 'tenantCode'
|
|
4436
|
+
}
|
|
4437
|
+
}
|
|
4438
|
+
|
|
4439
|
+
static get _classname() {
|
|
4440
|
+
return 'PaymentItem'
|
|
4441
|
+
}
|
|
4442
|
+
|
|
4443
|
+
static get _superclass() {
|
|
4444
|
+
return 'PaymentItem'
|
|
4445
|
+
}
|
|
4446
|
+
|
|
4447
|
+
get invoice() {
|
|
4448
|
+
return this._Invoice.init(this._invoice)
|
|
4449
|
+
}
|
|
4450
|
+
|
|
4451
|
+
get invoiceLines() {
|
|
4452
|
+
return this._InvoiceLine.initOnlyValidFromArray(this._invoiceLines || [])
|
|
4453
|
+
}
|
|
4454
|
+
|
|
4455
|
+
get isValid() {
|
|
4456
|
+
return super.isValid && !!this.invoiceCode && !!this.invoiceLineCode && !!this.paymentGatewayCode && !!this.receiptCode && !!this.receiptLineCode
|
|
4457
|
+
}
|
|
4458
|
+
|
|
4459
|
+
get paymentGateway() {
|
|
4460
|
+
return this._PaymentGateway.init(this._paymentGateway)
|
|
4461
|
+
}
|
|
4462
|
+
|
|
4463
|
+
get receipt() {
|
|
4464
|
+
return this._Receipt.init(this._receipt)
|
|
4465
|
+
}
|
|
4466
|
+
|
|
4467
|
+
get receiptLines() {
|
|
4468
|
+
return this._ReceiptLine.initOnlyValidFromArray(this._receiptLines || [])
|
|
4469
|
+
}
|
|
4470
|
+
|
|
4471
|
+
update(obj) {
|
|
4472
|
+
Object.keys(obj).forEach((key) => {
|
|
4473
|
+
if (paymentItem_updateAllowedProps.includes(key)) {
|
|
4474
|
+
if (key === 'amount') {
|
|
4475
|
+
this[key] = this.amount instanceof this._Amount ? this.amount.update(obj[key]) : this._Amount.init(obj[key])
|
|
4476
|
+
} else {
|
|
4477
|
+
this[key] = obj[key]
|
|
4478
|
+
}
|
|
4479
|
+
}
|
|
4480
|
+
})
|
|
4481
|
+
return super.update(obj)
|
|
4482
|
+
}
|
|
4483
|
+
}
|
|
4484
|
+
|
|
4485
|
+
function paymentItem_setId(id) {
|
|
4486
|
+
if (id && typeof id.toString === 'function') {
|
|
4487
|
+
return id.toString()
|
|
4488
|
+
}
|
|
4489
|
+
return id
|
|
4490
|
+
}
|
|
4491
|
+
|
|
4492
|
+
|
|
4493
|
+
|
|
4494
|
+
;// ./lib/models/paymentItem/index.js
|
|
4495
|
+
|
|
4496
|
+
|
|
4497
|
+
|
|
4498
|
+
|
|
3682
4499
|
;// ./lib/models/invoiceLine/invoiceLine.js
|
|
3683
4500
|
|
|
3684
4501
|
|
|
@@ -3688,12 +4505,15 @@ function _getOnePurchaseOptionValue({
|
|
|
3688
4505
|
|
|
3689
4506
|
|
|
3690
4507
|
|
|
4508
|
+
|
|
3691
4509
|
const invoiceLine_updateAllowedProps = [
|
|
3692
4510
|
'amount',
|
|
3693
4511
|
'deduction',
|
|
3694
4512
|
'description',
|
|
3695
4513
|
'discount',
|
|
4514
|
+
'invoiceDate',
|
|
3696
4515
|
'note',
|
|
4516
|
+
'outstanding',
|
|
3697
4517
|
'purchaseOptions',
|
|
3698
4518
|
'qty',
|
|
3699
4519
|
'unitPrice'
|
|
@@ -3704,14 +4524,16 @@ class InvoiceLine extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
3704
4524
|
options = options || {}
|
|
3705
4525
|
super(options)
|
|
3706
4526
|
|
|
3707
|
-
const { _Amount, _Invoice, _Merchandise, _Status } = options._constructor || {}
|
|
4527
|
+
const { _Amount, _Invoice, _Merchandise, _PaymentItem, _Status } = options._constructor || {}
|
|
3708
4528
|
this._Amount = _Amount && (_Amount._superclass === Amount._superclass) ? _Amount : Amount
|
|
3709
4529
|
this._Invoice = _Invoice && (_Invoice._superclass === Invoice._superclass) ? _Invoice : Invoice
|
|
3710
4530
|
this._Merchandise = _Merchandise && (_Merchandise._superclass === Merchandise._superclass) ? _Merchandise : Merchandise
|
|
4531
|
+
this._PaymentItem = _PaymentItem && (_PaymentItem._superclass === PaymentItem._superclass) ? _PaymentItem : PaymentItem
|
|
3711
4532
|
this._Status = _Status && (_Status._superclass === Status._superclass) ? _Status : Status
|
|
3712
4533
|
|
|
3713
4534
|
this._invoice = options._invoice
|
|
3714
4535
|
this._merchandise = options._merchandise
|
|
4536
|
+
this._paymentItems = options._paymentItems
|
|
3715
4537
|
|
|
3716
4538
|
const id = options._id || options.id
|
|
3717
4539
|
this.id = invoiceLine_setId(id)
|
|
@@ -3721,10 +4543,12 @@ class InvoiceLine extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
3721
4543
|
this.description = options.description
|
|
3722
4544
|
this.discount = options.discount || 0
|
|
3723
4545
|
this.invoiceCode = options.invoiceCode
|
|
4546
|
+
this.invoiceDate = options.invoiceDate || (new Date()).valueOf()
|
|
3724
4547
|
this.invoiceLineCode = invoiceLine_setCode(options, 'invoiceLineCode')
|
|
3725
4548
|
this.invoiceLineType = options.invoiceLineType || 'InvoiceLine'
|
|
3726
4549
|
this.merchandiseCode = options.merchandiseCode
|
|
3727
4550
|
this.note = options.note
|
|
4551
|
+
this.outstanding = this._Amount.init(options.outstanding)
|
|
3728
4552
|
this.purchaseOptions = q_utilities_namespaceObject.KeyValueObject.initOnlyValidFromArray(options.purchaseOptions)
|
|
3729
4553
|
this.qty = options.qty || 1
|
|
3730
4554
|
this.status = this._Status.init(options.status)
|
|
@@ -3757,7 +4581,9 @@ class InvoiceLine extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
3757
4581
|
get merchandise() {
|
|
3758
4582
|
return this._Merchandise.init(this._merchandise)
|
|
3759
4583
|
}
|
|
3760
|
-
|
|
4584
|
+
get paymentItems() {
|
|
4585
|
+
return this._PaymentItem.initOnlyValidFromArray(this._paymentItems)
|
|
4586
|
+
}
|
|
3761
4587
|
get usedCoupons() {
|
|
3762
4588
|
const usedItemCoupons = q_utilities_namespaceObject.KeyValueObject.getValueByKey(this.remarks, 'USED_ITEM_COUPONS') || []
|
|
3763
4589
|
const usedTotalCoupons = q_utilities_namespaceObject.KeyValueObject.getValueByKey(this.remarks, 'USED_TOTAL_COUPONS') || []
|
|
@@ -3772,10 +4598,14 @@ class InvoiceLine extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
3772
4598
|
purchaseOptions: this.purchaseOptions
|
|
3773
4599
|
})
|
|
3774
4600
|
}
|
|
4601
|
+
setCompleted(timestamp, actorCode) {
|
|
4602
|
+
this.status.setCompleted(timestamp, actorCode)
|
|
4603
|
+
return this.setModified()
|
|
4604
|
+
}
|
|
3775
4605
|
update(update) {
|
|
3776
4606
|
Object.keys(update).forEach((key) => {
|
|
3777
4607
|
if (invoiceLine_updateAllowedProps.includes(key)) {
|
|
3778
|
-
if (key === 'amount' || key === 'unitPrice' || key === 'deduction') {
|
|
4608
|
+
if (key === 'amount' || key === 'unitPrice' || key === 'deduction' || key === 'outstanding') {
|
|
3779
4609
|
this[key] = this._Amount.init(update[key])
|
|
3780
4610
|
} else if (key === 'purchaseOptions') {
|
|
3781
4611
|
this[key] = q_utilities_namespaceObject.KeyValueObject.initOnlyValidFromArray(update[key])
|
|
@@ -3786,6 +4616,23 @@ class InvoiceLine extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
3786
4616
|
})
|
|
3787
4617
|
return super.update(update)
|
|
3788
4618
|
}
|
|
4619
|
+
updateOutstanding({ actorCode } = {}) {
|
|
4620
|
+
const paymentItems = this.paymentItems
|
|
4621
|
+
if (paymentItems.length === 0) {
|
|
4622
|
+
return this
|
|
4623
|
+
}
|
|
4624
|
+
const paid = paymentItems.reduce((acc, pi) => acc + (pi?.amount?.value || 0), 0)
|
|
4625
|
+
const value = this.amount.value - paid
|
|
4626
|
+
if (value <= 0) {
|
|
4627
|
+
this.setCompleted(Date.now(), actorCode)
|
|
4628
|
+
}
|
|
4629
|
+
return this.update({
|
|
4630
|
+
outstanding: {
|
|
4631
|
+
currencyCode: this.amount.currencyCode,
|
|
4632
|
+
value
|
|
4633
|
+
}
|
|
4634
|
+
})
|
|
4635
|
+
}
|
|
3789
4636
|
}
|
|
3790
4637
|
|
|
3791
4638
|
function invoiceLine_setCode(options, key) {
|
|
@@ -3805,36 +4652,12 @@ function invoiceLine_setId(id) {
|
|
|
3805
4652
|
|
|
3806
4653
|
|
|
3807
4654
|
|
|
3808
|
-
;// ./lib/models/invoiceLine/invoiceLineRepo.js
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
class InvoiceLineRepo extends q_utilities_namespaceObject.Repo {
|
|
3813
|
-
constructor(options = {}) {
|
|
3814
|
-
options = options || {}
|
|
3815
|
-
super(options)
|
|
3816
|
-
const { _InvoiceLine } = options._constructor || {}
|
|
3817
|
-
this._InvoiceLine = _InvoiceLine && (_InvoiceLine._superclass === InvoiceLine._superclass) ? _InvoiceLine : InvoiceLine
|
|
3818
|
-
}
|
|
3819
|
-
static get _classname() {
|
|
3820
|
-
return 'InvoiceLineRepo'
|
|
3821
|
-
}
|
|
3822
|
-
init(options) {
|
|
3823
|
-
return this._InvoiceLine.init(options)
|
|
3824
|
-
}
|
|
3825
|
-
}
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
4655
|
;// ./lib/models/invoiceLine/index.js
|
|
3830
4656
|
|
|
3831
4657
|
|
|
3832
4658
|
|
|
3833
4659
|
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
4660
|
;// ./lib/models/issuer/issuer.js
|
|
3837
|
-
|
|
3838
4661
|
class Issuer {
|
|
3839
4662
|
constructor(options = {}) {
|
|
3840
4663
|
options = options || {}
|
|
@@ -3896,6 +4719,7 @@ class Issuer {
|
|
|
3896
4719
|
|
|
3897
4720
|
|
|
3898
4721
|
|
|
4722
|
+
|
|
3899
4723
|
// import { Transaction } from '../transaction/index.js'
|
|
3900
4724
|
|
|
3901
4725
|
const walletItem_updateAllowedProps = [
|
|
@@ -3909,7 +4733,8 @@ class WalletItem extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
3909
4733
|
options = options || {}
|
|
3910
4734
|
super(options)
|
|
3911
4735
|
|
|
3912
|
-
const { _Product, _Status } = options._constructor || {}
|
|
4736
|
+
const { _Amount, _Product, _Status } = options._constructor || {}
|
|
4737
|
+
this._Amount = _Amount && (_Amount._superclass === Amount._superclass) ? _Amount : Amount
|
|
3913
4738
|
this._Product = _Product && (_Product._superclass === Product._superclass) ? _Product : Product
|
|
3914
4739
|
this._Status = _Status && (_Status._superclass === Status._superclass) ? _Status : Status
|
|
3915
4740
|
// this._Transaction = _Transaction && (_Transaction._superclass === Transaction._superclass) ? _Transaction : Transaction
|
|
@@ -4039,18 +4864,30 @@ class WalletItem extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
4039
4864
|
get displayPurchaseOptions() {
|
|
4040
4865
|
return this.purchaseOptions.length > 0
|
|
4041
4866
|
? this.purchaseOptions.reduce((acc, purchaseOption) => {
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
|
|
4867
|
+
const { value } = purchaseOption
|
|
4868
|
+
return acc += value.reduce((_acc, item) => {
|
|
4869
|
+
const { label, value } = item
|
|
4870
|
+
return _acc += `<div><span>${label}: </span><span>${value}</span></div>`
|
|
4871
|
+
}, '')
|
|
4046
4872
|
}, '')
|
|
4047
|
-
}, '')
|
|
4048
4873
|
: ''
|
|
4049
4874
|
}
|
|
4050
4875
|
|
|
4051
4876
|
get lastRefundRejectedDetail() {
|
|
4052
4877
|
return Array.isArray(this.refundRejectedHistory) && this.refundRejectedHistory.length > 0 ? this.refundRejectedHistory[this.refundRejectedHistory.length - 1] : null
|
|
4053
4878
|
}
|
|
4879
|
+
get paid() {
|
|
4880
|
+
if (!this._transaction) {
|
|
4881
|
+
return null
|
|
4882
|
+
}
|
|
4883
|
+
const { amount, meta } = this._transaction
|
|
4884
|
+
return {
|
|
4885
|
+
created: meta.created,
|
|
4886
|
+
currencyCode: amount.currencyCode,
|
|
4887
|
+
modified: meta.modified,
|
|
4888
|
+
value: amount.value
|
|
4889
|
+
}
|
|
4890
|
+
}
|
|
4054
4891
|
|
|
4055
4892
|
get product() {
|
|
4056
4893
|
return this._Product.init(this._product)
|
|
@@ -4286,33 +5123,11 @@ function walletItem_setCode(options, key) {
|
|
|
4286
5123
|
|
|
4287
5124
|
|
|
4288
5125
|
|
|
4289
|
-
;// ./lib/models/walletItem/walletItemRepo.js
|
|
4290
|
-
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
class WalletItemRepo extends q_utilities_namespaceObject.Repo {
|
|
4294
|
-
constructor(options = {}) {
|
|
4295
|
-
options = options || {}
|
|
4296
|
-
super(options)
|
|
4297
|
-
const { _WalletItem } = options._constructor || {}
|
|
4298
|
-
this._WalletItem = _WalletItem && (_WalletItem._superclass === WalletItem._superclass) ? _WalletItem : WalletItem
|
|
4299
|
-
}
|
|
4300
|
-
static get _classname() {
|
|
4301
|
-
return 'WalletItemRepo'
|
|
4302
|
-
}
|
|
4303
|
-
init(options) {
|
|
4304
|
-
return this._WalletItem.init(options)
|
|
4305
|
-
}
|
|
4306
|
-
}
|
|
4307
|
-
|
|
4308
|
-
|
|
4309
|
-
|
|
4310
5126
|
;// ./lib/models/walletItem/index.js
|
|
4311
5127
|
|
|
4312
5128
|
|
|
4313
5129
|
|
|
4314
5130
|
|
|
4315
|
-
|
|
4316
5131
|
;// ./lib/models/transaction/transaction.js
|
|
4317
5132
|
|
|
4318
5133
|
|
|
@@ -4637,34 +5452,11 @@ function transaction_setId(id) {
|
|
|
4637
5452
|
|
|
4638
5453
|
|
|
4639
5454
|
|
|
4640
|
-
;// ./lib/models/transaction/transactionRepo.js
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
class TransactionRepo extends q_utilities_namespaceObject.Repo {
|
|
4645
|
-
constructor(options = {}) {
|
|
4646
|
-
options = options || {}
|
|
4647
|
-
super(options)
|
|
4648
|
-
const { _Transaction } = options._constructor || {}
|
|
4649
|
-
this._Transaction = _Transaction && (_Transaction._superclass === Transaction._superclass) ? _Transaction : Transaction
|
|
4650
|
-
}
|
|
4651
|
-
static get _classname() {
|
|
4652
|
-
return 'TransactionRepo'
|
|
4653
|
-
}
|
|
4654
|
-
init(options) {
|
|
4655
|
-
return this._Transaction.init(options)
|
|
4656
|
-
}
|
|
4657
|
-
}
|
|
4658
|
-
|
|
4659
|
-
|
|
4660
|
-
|
|
4661
5455
|
;// ./lib/models/transaction/index.js
|
|
4662
5456
|
|
|
4663
5457
|
|
|
4664
5458
|
|
|
4665
5459
|
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
5460
|
;// ./lib/models/invoice/invoice.js
|
|
4669
5461
|
|
|
4670
5462
|
|
|
@@ -4676,10 +5468,12 @@ class TransactionRepo extends q_utilities_namespaceObject.Repo {
|
|
|
4676
5468
|
|
|
4677
5469
|
|
|
4678
5470
|
const invoice_updateAllowedProps = [
|
|
5471
|
+
'billToUserCode',
|
|
4679
5472
|
'checkoutDateTime',
|
|
4680
5473
|
'description',
|
|
4681
5474
|
'invoiceDate',
|
|
4682
5475
|
'issuer',
|
|
5476
|
+
'outstanding',
|
|
4683
5477
|
'revisionNumber',
|
|
4684
5478
|
'status'
|
|
4685
5479
|
]
|
|
@@ -4687,24 +5481,27 @@ const invoice_updateAllowedProps = [
|
|
|
4687
5481
|
class Invoice extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
4688
5482
|
constructor(options) {
|
|
4689
5483
|
options = options || {}
|
|
4690
|
-
super(options)
|
|
5484
|
+
super(options) // store the 'BUILDTOUSER' into invoice.metadata
|
|
4691
5485
|
|
|
4692
|
-
const { _Amount, _Cart, _InvoiceLine, _Issuer, _Status, _Transaction } = options._constructor || {}
|
|
5486
|
+
const { _Amount, _BillToUser, _Cart, _InvoiceLine, _Issuer, _Status, _Transaction } = options._constructor || {}
|
|
4693
5487
|
this._Amount = _Amount && (_Amount._superclass === Amount._superclass) ? _Amount : Amount
|
|
5488
|
+
this._BillToUser = _BillToUser
|
|
4694
5489
|
this._Cart = _Cart && (_Cart._superclass === Cart._superclass) ? _Cart : Cart
|
|
4695
5490
|
this._InvoiceLine = _InvoiceLine && (_InvoiceLine._superclass === InvoiceLine._superclass) ? _InvoiceLine : InvoiceLine
|
|
4696
5491
|
this._Issuer = _Issuer && (_Issuer._superclass === Issuer._superclass) ? _Issuer : Issuer
|
|
4697
5492
|
this._Status = _Status && (_Status._superclass === Status._superclass) ? _Status : Status
|
|
4698
5493
|
this._Transaction = _Transaction && (_Transaction._superclass === Transaction._superclass) ? _Transaction : Transaction
|
|
4699
5494
|
|
|
5495
|
+
this._billToUser = options._billToUser
|
|
4700
5496
|
this._cart = options._cart
|
|
4701
5497
|
this._invoiceLines = options._invoiceLines
|
|
4702
5498
|
this._transactions = options._transactions
|
|
4703
|
-
|
|
5499
|
+
|
|
4704
5500
|
const id = options._id || options.id
|
|
4705
5501
|
this.id = invoice_setId(id)
|
|
4706
5502
|
this._type = options._type || 'Invoice'
|
|
4707
5503
|
this.amount = this._Amount.init(options.amount)
|
|
5504
|
+
this.billToUserCode = options.billToUserCode // mainly for frontend populate
|
|
4708
5505
|
this.cartCode = options.cartCode
|
|
4709
5506
|
this.checkoutDateTime = options.checkoutDateTime || (new Date()).valueOf()
|
|
4710
5507
|
this.description = options.description
|
|
@@ -4713,6 +5510,7 @@ class Invoice extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
4713
5510
|
this.invoiceNumber = options.invoiceNumber
|
|
4714
5511
|
this.invoiceType = options.invoiceType || 'Invoice'
|
|
4715
5512
|
this.issuer = this._Issuer.init(options.issuer)
|
|
5513
|
+
this.outstanding = this._Amount.init(options.outstanding)
|
|
4716
5514
|
this.revisionNumber = options.revisionNumber || 1
|
|
4717
5515
|
this.status = this._Status.init(options.status)
|
|
4718
5516
|
}
|
|
@@ -4732,6 +5530,9 @@ class Invoice extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
4732
5530
|
get isValid() {
|
|
4733
5531
|
return super.isValid
|
|
4734
5532
|
}
|
|
5533
|
+
get billToUser() {
|
|
5534
|
+
return this._BillToUser && typeof this._BillToUser.init === 'function' ? this._BillToUser.init(this._billToUser) : this._billToUser
|
|
5535
|
+
}
|
|
4735
5536
|
get cart() {
|
|
4736
5537
|
return this._Cart.init(this._cart)
|
|
4737
5538
|
}
|
|
@@ -4823,6 +5624,14 @@ class Invoice extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
4823
5624
|
return this.status.setCancelled()
|
|
4824
5625
|
}
|
|
4825
5626
|
|
|
5627
|
+
setClosed(timestamp, actorCode) {
|
|
5628
|
+
if (typeof this.status.setClosed !== 'function') {
|
|
5629
|
+
return this
|
|
5630
|
+
}
|
|
5631
|
+
this.status.setClosed(timestamp, actorCode)
|
|
5632
|
+
return this.setModified()
|
|
5633
|
+
}
|
|
5634
|
+
|
|
4826
5635
|
setCheckoutDateTime(timestamp) {
|
|
4827
5636
|
if (typeof timestamp === 'number') {
|
|
4828
5637
|
this.checkoutDateTime = timestamp
|
|
@@ -4833,196 +5642,75 @@ class Invoice extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
4833
5642
|
this.status.setCompleted()
|
|
4834
5643
|
return this.setModified()
|
|
4835
5644
|
}
|
|
4836
|
-
|
|
4837
|
-
setWaived() {
|
|
4838
|
-
this.status.setWaived()
|
|
4839
|
-
return this.setModified()
|
|
4840
|
-
}
|
|
4841
|
-
|
|
4842
|
-
update(update) {
|
|
4843
|
-
Object.keys(update).forEach((key) => {
|
|
4844
|
-
if (invoice_updateAllowedProps.includes(key)) {
|
|
4845
|
-
if (key === 'amount') {
|
|
4846
|
-
this[key] = this._Amount.init(update[key])
|
|
4847
|
-
} else if (key === 'issuer') {
|
|
4848
|
-
this[key] = this._Issuer.init(update[key])
|
|
4849
|
-
} else if (key === 'status') {
|
|
4850
|
-
this[key] = this._Status.init(update[key])
|
|
4851
|
-
} else {
|
|
4852
|
-
this[key] = update[key]
|
|
4853
|
-
}
|
|
4854
|
-
}
|
|
4855
|
-
})
|
|
4856
|
-
return super.update(update)
|
|
4857
|
-
}
|
|
4858
|
-
}
|
|
4859
|
-
|
|
4860
|
-
function invoice_setCode(options, key) {
|
|
4861
|
-
const copyOptions = options || {}
|
|
4862
|
-
if (copyOptions[key]) {
|
|
4863
|
-
return copyOptions[key]
|
|
4864
|
-
}
|
|
4865
|
-
return stringHelper.setCode()
|
|
4866
|
-
}
|
|
4867
|
-
|
|
4868
|
-
function invoice_setId(id) {
|
|
4869
|
-
if (id && typeof id.toString === 'function') {
|
|
4870
|
-
return id.toString()
|
|
4871
|
-
}
|
|
4872
|
-
return id
|
|
4873
|
-
}
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
|
|
4877
|
-
;// ./lib/models/invoice/invoiceRepo.js
|
|
4878
|
-
|
|
4879
|
-
|
|
4880
|
-
|
|
4881
|
-
class InvoiceRepo extends q_utilities_namespaceObject.Repo {
|
|
4882
|
-
constructor(options = {}) {
|
|
4883
|
-
options = options || {}
|
|
4884
|
-
super(options)
|
|
4885
|
-
const { _Invoice } = options._constructor || {}
|
|
4886
|
-
this._Invoice = _Invoice && (_Invoice._superclass === Invoice._superclass) ? _Invoice : Invoice
|
|
4887
|
-
}
|
|
4888
|
-
static get _classname() {
|
|
4889
|
-
return 'InvoiceRepo'
|
|
4890
|
-
}
|
|
4891
|
-
init(options) {
|
|
4892
|
-
return this._Invoice.init(options)
|
|
4893
|
-
}
|
|
4894
|
-
}
|
|
4895
|
-
|
|
4896
|
-
|
|
4897
|
-
|
|
4898
|
-
;// ./lib/models/invoice/index.js
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
|
|
4905
|
-
;// ./lib/models/keyValueObject/index.js
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
;// ./lib/models/statusQStore/statusQStore.js
|
|
4909
|
-
|
|
4910
|
-
|
|
4911
|
-
const statusQStore_notUpdateAllowedProps = (/* unused pure expression or super */ null && ([
|
|
4912
|
-
]))
|
|
4913
|
-
|
|
4914
|
-
class StatusQStore extends q_utilities_namespaceObject.Status {
|
|
4915
|
-
constructor(options) {
|
|
4916
|
-
options = options || {}
|
|
4917
|
-
super(options)
|
|
4918
|
-
|
|
4919
|
-
this.cancelled = this._ActionRecord.init(options.cancelled)
|
|
4920
|
-
this.completed = this._ActionRecord.init(options.completed)
|
|
4921
|
-
this.confirmed = this._ActionRecord.init(options.confirmed)
|
|
4922
|
-
this.deleted = this._ActionRecord.init(options.deleted)
|
|
4923
|
-
this.terminated = this._ActionRecord.init(options.terminated)
|
|
4924
|
-
}
|
|
4925
|
-
|
|
4926
|
-
static get _classname() {
|
|
4927
|
-
return 'StatusQStore'
|
|
4928
|
-
}
|
|
4929
|
-
get _classname() {
|
|
4930
|
-
return 'StatusQStore'
|
|
4931
|
-
}
|
|
4932
|
-
get isCancelled() {
|
|
4933
|
-
return this.cancelled?.timestamp > 0
|
|
4934
|
-
}
|
|
4935
|
-
get isCompleted() {
|
|
4936
|
-
return this.completed?.timestamp > 0
|
|
4937
|
-
}
|
|
4938
|
-
get isConfirmed() {
|
|
4939
|
-
return this.confirmed?.timestamp > 0
|
|
4940
|
-
}
|
|
4941
|
-
get isDeleted() {
|
|
4942
|
-
return this.deleted?.timestamp > 0
|
|
4943
|
-
}
|
|
4944
|
-
get isTerminated() {
|
|
4945
|
-
return this.terminated?.timestamp > 0
|
|
4946
|
-
}
|
|
4947
|
-
get isValid() {
|
|
4948
|
-
return super.isValid
|
|
4949
|
-
}
|
|
4950
|
-
setCancelled(value, actorCode) {
|
|
4951
|
-
return this.setValue(value, actorCode, 'cancelled')
|
|
4952
|
-
}
|
|
4953
|
-
setCompleted(value, actorCode) {
|
|
4954
|
-
return this.setValue(value, actorCode, 'completed')
|
|
4955
|
-
}
|
|
4956
|
-
setConfirmed(value, actorCode) {
|
|
4957
|
-
return this.setValue(value, actorCode, 'confirmed')
|
|
4958
|
-
}
|
|
4959
|
-
setDeleted(value, actorCode) {
|
|
4960
|
-
return this.setValue(value, actorCode, 'deleted')
|
|
4961
|
-
}
|
|
4962
|
-
setTerminated(value, actorCode) {
|
|
4963
|
-
return this.setValue(value, actorCode, 'terminated')
|
|
4964
|
-
}
|
|
4965
|
-
// update(update) {
|
|
4966
|
-
// Object.keys(update).forEach((key) => {
|
|
4967
|
-
// if (!notUpdateAllowedProps.includes(key)) {
|
|
4968
|
-
// this[key] = this[key] instanceof this._ActionRecord ? this[key].update(update[key]) : this._ActionRecord.init(update[key])
|
|
4969
|
-
// }
|
|
4970
|
-
// })
|
|
4971
|
-
// return super.update(update)
|
|
4972
|
-
// }
|
|
4973
|
-
}
|
|
4974
|
-
|
|
4975
|
-
;// ./lib/models/statusQStore/statusQStoreOrderLine.js
|
|
4976
|
-
|
|
4977
|
-
|
|
4978
|
-
const statusQStoreOrderLine_notUpdateAllowedProps = (/* unused pure expression or super */ null && ([
|
|
4979
|
-
]))
|
|
4980
|
-
|
|
4981
|
-
class StatusQStoreOrderLine extends StatusQStore {
|
|
4982
|
-
constructor(options) {
|
|
4983
|
-
options = options || {}
|
|
4984
|
-
super(options)
|
|
4985
|
-
|
|
4986
|
-
this.expired = this._ActionRecord.init(options.expired)
|
|
4987
|
-
this.invalid = this._ActionRecord.init(options.invalid)
|
|
4988
|
-
}
|
|
4989
|
-
|
|
4990
|
-
static get _classname() {
|
|
4991
|
-
return 'StatusQStoreOrderLine'
|
|
4992
|
-
}
|
|
4993
|
-
get _classname() {
|
|
4994
|
-
return 'StatusQStoreOrderLine'
|
|
4995
|
-
}
|
|
4996
|
-
get isExpired() {
|
|
4997
|
-
return this.expired?.timestamp > Date.now()
|
|
5645
|
+
|
|
5646
|
+
setWaived() {
|
|
5647
|
+
this.status.setWaived()
|
|
5648
|
+
return this.setModified()
|
|
4998
5649
|
}
|
|
4999
|
-
|
|
5000
|
-
|
|
5650
|
+
|
|
5651
|
+
update(update) {
|
|
5652
|
+
Object.keys(update).forEach((key) => {
|
|
5653
|
+
if (invoice_updateAllowedProps.includes(key)) {
|
|
5654
|
+
if (key === 'amount' || key === 'outstanding') {
|
|
5655
|
+
this[key] = this._Amount.init(update[key])
|
|
5656
|
+
} else if (key === 'issuer') {
|
|
5657
|
+
this[key] = this._Issuer.init(update[key])
|
|
5658
|
+
} else if (key === 'status') {
|
|
5659
|
+
this[key] = this._Status.init(update[key])
|
|
5660
|
+
} else {
|
|
5661
|
+
this[key] = update[key]
|
|
5662
|
+
}
|
|
5663
|
+
}
|
|
5664
|
+
})
|
|
5665
|
+
return super.update(update)
|
|
5001
5666
|
}
|
|
5002
|
-
|
|
5003
|
-
|
|
5667
|
+
|
|
5668
|
+
updateOutstanding({ actorCode } = {}) {
|
|
5669
|
+
const invoiceLines = this.invoiceLines
|
|
5670
|
+
if (invoiceLines.length === 0) {
|
|
5671
|
+
return this
|
|
5672
|
+
}
|
|
5673
|
+
const value = invoiceLines.reduce((acc, il) => {
|
|
5674
|
+
il.updateOutstanding({ actorCode })
|
|
5675
|
+
return acc + il?.outstanding?.value
|
|
5676
|
+
}, 0)
|
|
5677
|
+
if (value <= 0) {
|
|
5678
|
+
this.setClosed(Date.now(), actorCode)
|
|
5679
|
+
}
|
|
5680
|
+
this._invoiceLines = invoiceLines
|
|
5681
|
+
return this.update({
|
|
5682
|
+
outstanding: {
|
|
5683
|
+
currencyCode: this.getCurrencyCode(),
|
|
5684
|
+
value
|
|
5685
|
+
}
|
|
5686
|
+
})
|
|
5004
5687
|
}
|
|
5005
|
-
|
|
5006
|
-
|
|
5688
|
+
}
|
|
5689
|
+
|
|
5690
|
+
function invoice_setCode(options, key) {
|
|
5691
|
+
const copyOptions = options || {}
|
|
5692
|
+
if (copyOptions[key]) {
|
|
5693
|
+
return copyOptions[key]
|
|
5007
5694
|
}
|
|
5008
|
-
|
|
5009
|
-
|
|
5695
|
+
return stringHelper.setCode()
|
|
5696
|
+
}
|
|
5697
|
+
|
|
5698
|
+
function invoice_setId(id) {
|
|
5699
|
+
if (id && typeof id.toString === 'function') {
|
|
5700
|
+
return id.toString()
|
|
5010
5701
|
}
|
|
5011
|
-
|
|
5012
|
-
// Object.keys(update).forEach((key) => {
|
|
5013
|
-
// if (!notUpdateAllowedProps.includes(key)) {
|
|
5014
|
-
// this[key] = this[key] instanceof this._ActionRecord ? this[key].update(update[key]) : this._ActionRecord.init(update[key])
|
|
5015
|
-
// }
|
|
5016
|
-
// })
|
|
5017
|
-
// return super.update(update)
|
|
5018
|
-
// }
|
|
5702
|
+
return id
|
|
5019
5703
|
}
|
|
5020
5704
|
|
|
5021
|
-
|
|
5705
|
+
|
|
5706
|
+
|
|
5707
|
+
;// ./lib/models/invoice/index.js
|
|
5022
5708
|
|
|
5023
5709
|
|
|
5024
5710
|
|
|
5025
5711
|
|
|
5712
|
+
;// ./lib/models/keyValueObject/index.js
|
|
5713
|
+
|
|
5026
5714
|
|
|
5027
5715
|
;// ./lib/models/orderLine/orderLine.js
|
|
5028
5716
|
|
|
@@ -5132,6 +5820,7 @@ class OrderLine extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
5132
5820
|
unitPrice: this.unitPrice,
|
|
5133
5821
|
deduction: this.deduction,
|
|
5134
5822
|
discount: this.discount,
|
|
5823
|
+
outstanding: this.amount,
|
|
5135
5824
|
qty: this.qty,
|
|
5136
5825
|
merchandiseCode: this.merchandiseCode,
|
|
5137
5826
|
metadata: this.metadata,
|
|
@@ -5148,6 +5837,14 @@ class OrderLine extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
5148
5837
|
return this.amount
|
|
5149
5838
|
}
|
|
5150
5839
|
|
|
5840
|
+
getPreservedData() {
|
|
5841
|
+
return {
|
|
5842
|
+
orderCode: this.orderCode,
|
|
5843
|
+
orderLineCode: this.orderLineCode,
|
|
5844
|
+
orderLineType: this.orderLineType,
|
|
5845
|
+
}
|
|
5846
|
+
}
|
|
5847
|
+
|
|
5151
5848
|
toCaculateAmountItem() {
|
|
5152
5849
|
return {
|
|
5153
5850
|
merchandiseCode: this.merchandiseCode,
|
|
@@ -5411,133 +6108,6 @@ function order_setId(id) {
|
|
|
5411
6108
|
|
|
5412
6109
|
|
|
5413
6110
|
|
|
5414
|
-
;// ./lib/models/paymentGateway/paymentGateway.js
|
|
5415
|
-
|
|
5416
|
-
|
|
5417
|
-
|
|
5418
|
-
const paymentGateway_updateAllowedProps = [
|
|
5419
|
-
'label',
|
|
5420
|
-
'logoUrl',
|
|
5421
|
-
'name',
|
|
5422
|
-
'sandbox',
|
|
5423
|
-
'setting'
|
|
5424
|
-
]
|
|
5425
|
-
|
|
5426
|
-
class PaymentGateway extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
5427
|
-
constructor(options = {}) {
|
|
5428
|
-
options = options || {}
|
|
5429
|
-
super(options)
|
|
5430
|
-
|
|
5431
|
-
const id = options._id || options.id
|
|
5432
|
-
this.id = paymentGateway_setId(id)
|
|
5433
|
-
this._type = options._type || 'PaymentGateway'
|
|
5434
|
-
|
|
5435
|
-
this.hasWebhook = options.hasWebhook || false
|
|
5436
|
-
this.label = options.label
|
|
5437
|
-
this.logoUrl = options.logoUrl
|
|
5438
|
-
this.name = options.name || ''
|
|
5439
|
-
this.paymentGatewayCode = paymentGateway_setCode(options, 'paymentGatewayCode')
|
|
5440
|
-
this.paymentGatewayType = options.paymentGatewayType || 'PaymentGateway'
|
|
5441
|
-
this.paymentResultType = options.paymentResultType || 'PaymentResult'
|
|
5442
|
-
this.sandbox = options.sandbox || false
|
|
5443
|
-
this.setting = options.setting || null
|
|
5444
|
-
}
|
|
5445
|
-
static dummyData() {
|
|
5446
|
-
return {
|
|
5447
|
-
name: 'name',
|
|
5448
|
-
tenantCode: 'tenantCode'
|
|
5449
|
-
}
|
|
5450
|
-
}
|
|
5451
|
-
static get _classname() {
|
|
5452
|
-
return 'PaymentGateway'
|
|
5453
|
-
}
|
|
5454
|
-
static get _superclass() {
|
|
5455
|
-
return 'PaymentGateway'
|
|
5456
|
-
}
|
|
5457
|
-
|
|
5458
|
-
// getters
|
|
5459
|
-
get isValid() {
|
|
5460
|
-
return super.isValid && !!this.name
|
|
5461
|
-
}
|
|
5462
|
-
|
|
5463
|
-
// instance methods
|
|
5464
|
-
async createPayment() {
|
|
5465
|
-
throw new Error(`${this._classname} subclass should implement createPayment`)
|
|
5466
|
-
}
|
|
5467
|
-
async getAppPayParams() {
|
|
5468
|
-
throw new Error(`${this._classname} subclass should implement getAppPayParams`)
|
|
5469
|
-
}
|
|
5470
|
-
getCode() {
|
|
5471
|
-
return this.paymentGatewayCode
|
|
5472
|
-
}
|
|
5473
|
-
async updatePayment() {
|
|
5474
|
-
throw new Error(`${this._classname} subclass should implement updatePayment`)
|
|
5475
|
-
}
|
|
5476
|
-
async query() {
|
|
5477
|
-
throw new Error(`${this._classname} subclass should implement query`)
|
|
5478
|
-
}
|
|
5479
|
-
async submit() {
|
|
5480
|
-
throw new Error(`${this._classname} subclass should implement submit`)
|
|
5481
|
-
}
|
|
5482
|
-
|
|
5483
|
-
setCompletedRelatedStatus(status) {
|
|
5484
|
-
throw new Error(`${this.name} subclass should implement setCompletedRelatedStatus`)
|
|
5485
|
-
}
|
|
5486
|
-
update(update) {
|
|
5487
|
-
Object.keys(update).forEach((key) => {
|
|
5488
|
-
if (paymentGateway_updateAllowedProps.includes(key)) {
|
|
5489
|
-
this[key] = update[key]
|
|
5490
|
-
}
|
|
5491
|
-
})
|
|
5492
|
-
return super.update(update)
|
|
5493
|
-
}
|
|
5494
|
-
}
|
|
5495
|
-
|
|
5496
|
-
function paymentGateway_setCode(options, key) {
|
|
5497
|
-
const copyOptions = options || {}
|
|
5498
|
-
if (copyOptions[key]) {
|
|
5499
|
-
return copyOptions[key]
|
|
5500
|
-
}
|
|
5501
|
-
return stringHelper.setCode()
|
|
5502
|
-
}
|
|
5503
|
-
|
|
5504
|
-
function paymentGateway_setId(id) {
|
|
5505
|
-
if (id && typeof id.toString === 'function') {
|
|
5506
|
-
return id.toString()
|
|
5507
|
-
}
|
|
5508
|
-
return id
|
|
5509
|
-
}
|
|
5510
|
-
|
|
5511
|
-
|
|
5512
|
-
|
|
5513
|
-
;// ./lib/models/paymentGateway/paymentGatewayRepo.js
|
|
5514
|
-
|
|
5515
|
-
|
|
5516
|
-
|
|
5517
|
-
class PaymentGatewayRepo extends q_utilities_namespaceObject.Repo {
|
|
5518
|
-
constructor(options = {}) {
|
|
5519
|
-
options = options || {}
|
|
5520
|
-
super(options)
|
|
5521
|
-
const { _PaymentGateway } = options._constructor || {}
|
|
5522
|
-
this._PaymentGateway = _PaymentGateway && (_PaymentGateway._superclass === PaymentGateway._superclass) ? _PaymentGateway : PaymentGateway
|
|
5523
|
-
}
|
|
5524
|
-
static get _classname() {
|
|
5525
|
-
return 'PaymentGatewayRepo'
|
|
5526
|
-
}
|
|
5527
|
-
init(options) {
|
|
5528
|
-
return this._PaymentGateway.init(options)
|
|
5529
|
-
}
|
|
5530
|
-
}
|
|
5531
|
-
|
|
5532
|
-
|
|
5533
|
-
|
|
5534
|
-
;// ./lib/models/paymentGateway/index.js
|
|
5535
|
-
|
|
5536
|
-
|
|
5537
|
-
|
|
5538
|
-
|
|
5539
|
-
|
|
5540
|
-
|
|
5541
6111
|
;// ./lib/models/paymentResult/paymentResult.js
|
|
5542
6112
|
|
|
5543
6113
|
|
|
@@ -5713,40 +6283,16 @@ function paymentResult_setId(id) {
|
|
|
5713
6283
|
|
|
5714
6284
|
|
|
5715
6285
|
|
|
5716
|
-
;// ./lib/models/paymentResult/paymentResultRepo.js
|
|
5717
|
-
|
|
5718
|
-
|
|
5719
|
-
|
|
5720
|
-
class PaymentResultRepo extends q_utilities_namespaceObject.Repo {
|
|
5721
|
-
constructor(options = {}) {
|
|
5722
|
-
options = options || {}
|
|
5723
|
-
super(options)
|
|
5724
|
-
const { _PaymentResult } = options._constructor || {}
|
|
5725
|
-
this._PaymentResult = _PaymentResult && (_PaymentResult._superclass === PaymentResult._superclass) ? _PaymentResult : PaymentResult
|
|
5726
|
-
}
|
|
5727
|
-
static get _classname() {
|
|
5728
|
-
return 'PaymentResultRepo'
|
|
5729
|
-
}
|
|
5730
|
-
init(options) {
|
|
5731
|
-
return this._PaymentResult.init(options)
|
|
5732
|
-
}
|
|
5733
|
-
}
|
|
5734
|
-
|
|
5735
|
-
|
|
5736
|
-
|
|
5737
6286
|
;// ./lib/models/paymentResult/index.js
|
|
5738
6287
|
|
|
5739
6288
|
|
|
5740
6289
|
|
|
5741
6290
|
|
|
5742
|
-
|
|
5743
|
-
|
|
5744
6291
|
;// ./lib/models/status/index.js
|
|
5745
6292
|
|
|
5746
6293
|
|
|
5747
6294
|
|
|
5748
6295
|
|
|
5749
|
-
|
|
5750
6296
|
;// ./lib/models/storeItem/storeItem.js
|
|
5751
6297
|
|
|
5752
6298
|
|
|
@@ -5907,7 +6453,7 @@ class StoreItem {
|
|
|
5907
6453
|
if (storeItem_updateAllowedProps.includes(key)) {
|
|
5908
6454
|
if (key === 'metadata') {
|
|
5909
6455
|
this[key] = q_utilities_namespaceObject.Metadata.initOnlyValidFromArray(update[key])
|
|
5910
|
-
} else
|
|
6456
|
+
} else if (key === 'productOptions') {
|
|
5911
6457
|
this[key] = this._ItemOption.initOnlyValidFromArray(update[key])
|
|
5912
6458
|
} else if (key === 'remarks') {
|
|
5913
6459
|
this[key] = q_utilities_namespaceObject.KeyValueObject.initOnlyValidFromArray(update[key])
|
|
@@ -5972,8 +6518,13 @@ function storeItem_getDataByKey(key, data) {
|
|
|
5972
6518
|
|
|
5973
6519
|
|
|
5974
6520
|
|
|
5975
|
-
;// ./lib/helpers/corHelper/chain.js
|
|
5976
6521
|
|
|
6522
|
+
|
|
6523
|
+
|
|
6524
|
+
|
|
6525
|
+
|
|
6526
|
+
|
|
6527
|
+
;// ./lib/helpers/corHelper/chain.js
|
|
5977
6528
|
class Chain {
|
|
5978
6529
|
constructor(options = {}) {
|
|
5979
6530
|
options = options || {}
|
|
@@ -6093,7 +6644,7 @@ function calculateByCoupon({ coupon, price, currencyCode }) {
|
|
|
6093
6644
|
}
|
|
6094
6645
|
const { type, item } = couponDetails
|
|
6095
6646
|
if (item) {
|
|
6096
|
-
switch(type) {
|
|
6647
|
+
switch (type) {
|
|
6097
6648
|
case ('Deduction'): {
|
|
6098
6649
|
return _caculateByDeduction({ price, couponDetails, currencyCode })
|
|
6099
6650
|
}
|
|
@@ -6118,7 +6669,6 @@ function _caculateByPercentage({ price, couponDetails }) {
|
|
|
6118
6669
|
|
|
6119
6670
|
|
|
6120
6671
|
|
|
6121
|
-
|
|
6122
6672
|
;// ./lib/helpers/calculateByCoupon/index.js
|
|
6123
6673
|
|
|
6124
6674
|
|
|
@@ -6165,7 +6715,12 @@ class ChainCategoryLimit extends Chain {
|
|
|
6165
6715
|
function groupCategory(categories = [], walletItems = []) {
|
|
6166
6716
|
return categories.reduce((acc, category) => {
|
|
6167
6717
|
const {
|
|
6168
|
-
categoryCode,
|
|
6718
|
+
categoryCode,
|
|
6719
|
+
codes,
|
|
6720
|
+
name,
|
|
6721
|
+
max,
|
|
6722
|
+
min,
|
|
6723
|
+
productCodes = [],
|
|
6169
6724
|
} = category
|
|
6170
6725
|
const filtered = walletItems.filter((w) => {
|
|
6171
6726
|
if (w.status.cancelled !== null) {
|
|
@@ -6420,7 +6975,7 @@ function getEntitlements(entitlements, productCodes, qty) {
|
|
|
6420
6975
|
if (entitlements.length === 0) {
|
|
6421
6976
|
return { waived: 0, entitlementsRemarkValue: [] }
|
|
6422
6977
|
}
|
|
6423
|
-
const groupedProductCodes = Array.from(
|
|
6978
|
+
const groupedProductCodes = Array.from({ length: qty }).map(() => [...productCodes])
|
|
6424
6979
|
// const copyEntitlements = JSON.parse(JSON.stringify(entitlements))
|
|
6425
6980
|
const { waived, entitlementsRemarkValue } = groupedProductCodes.reduce((acc, arr) => {
|
|
6426
6981
|
if (acc.continue === false) {
|
|
@@ -6479,7 +7034,6 @@ function getStrategiesByRestrictions(prices, line, user) {
|
|
|
6479
7034
|
return priceStrategies
|
|
6480
7035
|
}
|
|
6481
7036
|
|
|
6482
|
-
|
|
6483
7037
|
// function useCoupons(lines, currencyCode) {
|
|
6484
7038
|
// lines.forEach((line) => {
|
|
6485
7039
|
|
|
@@ -6503,7 +7057,7 @@ class ChainGetPriceForGroup extends Chain {
|
|
|
6503
7057
|
|
|
6504
7058
|
async handleRequest(chainTarget) {
|
|
6505
7059
|
try {
|
|
6506
|
-
const { lines
|
|
7060
|
+
const { lines } = chainTarget
|
|
6507
7061
|
const entitlements = external_lodash_namespaceObject["default"].cloneDeep(this.entitlements)
|
|
6508
7062
|
|
|
6509
7063
|
lines.forEach((line) => {
|
|
@@ -6556,10 +7110,10 @@ function ChainGetPriceForGroup_cutEntitlements(lines, entitlements = [], currenc
|
|
|
6556
7110
|
const subTotal = Amount.init({ value, currencyCode })
|
|
6557
7111
|
const discountValue = (price.value * restQty) - subTotal.value + (price.value * waived)
|
|
6558
7112
|
const discount = Amount.init({ value: discountValue, currencyCode })
|
|
6559
|
-
let remarks = KeyValueObject.initOnlyValidFromArray([...(updatedItem.remarks || [])])
|
|
6560
|
-
remarks = KeyValueObject.updateOrInsertRecord(remarks, 'entitlements', entitlementsRemarkValue)
|
|
6561
|
-
let metadata = Metadata.initOnlyValidFromArray([...(updatedItem.metadata || [])])
|
|
6562
|
-
metadata = Metadata.updateOrInsertRecord(metadata, 'entitlements', entitlementsRemarkValue)
|
|
7113
|
+
let remarks = q_utilities_namespaceObject.KeyValueObject.initOnlyValidFromArray([...(updatedItem.remarks || [])])
|
|
7114
|
+
remarks = q_utilities_namespaceObject.KeyValueObject.updateOrInsertRecord(remarks, 'entitlements', entitlementsRemarkValue)
|
|
7115
|
+
let metadata = q_utilities_namespaceObject.Metadata.initOnlyValidFromArray([...(updatedItem.metadata || [])])
|
|
7116
|
+
metadata = q_utilities_namespaceObject.Metadata.updateOrInsertRecord(metadata, 'entitlements', entitlementsRemarkValue)
|
|
6563
7117
|
const obj = {
|
|
6564
7118
|
merchandiseCode,
|
|
6565
7119
|
price,
|
|
@@ -6638,7 +7192,7 @@ function ChainGetPriceForGroup_getEntitlements(entitlements, productCodes, qty)
|
|
|
6638
7192
|
if (entitlements.length === 0) {
|
|
6639
7193
|
return { waived: 0, entitlementsRemarkValue: [] }
|
|
6640
7194
|
}
|
|
6641
|
-
const groupedProductCodes = Array.from(
|
|
7195
|
+
const groupedProductCodes = Array.from({ length: qty }).map(() => [...productCodes])
|
|
6642
7196
|
// const copyEntitlements = JSON.parse(JSON.stringify(entitlements))
|
|
6643
7197
|
const { waived, entitlementsRemarkValue } = groupedProductCodes.reduce((acc, arr) => {
|
|
6644
7198
|
if (acc.continue === false) {
|
|
@@ -6809,7 +7363,7 @@ function _calculate({ line, currency }) {
|
|
|
6809
7363
|
|
|
6810
7364
|
function _findPriceAdjustmentValue(dataArray) {
|
|
6811
7365
|
for (const obj of dataArray) {
|
|
6812
|
-
const priceAdjustment = obj.value?.find(item => item.key === 'priceAdjustment')
|
|
7366
|
+
const priceAdjustment = obj.value?.find((item) => item.key === 'priceAdjustment')
|
|
6813
7367
|
if (priceAdjustment) {
|
|
6814
7368
|
return Number(priceAdjustment.value)
|
|
6815
7369
|
}
|
|
@@ -6819,7 +7373,6 @@ function _findPriceAdjustmentValue(dataArray) {
|
|
|
6819
7373
|
|
|
6820
7374
|
|
|
6821
7375
|
|
|
6822
|
-
|
|
6823
7376
|
;// ./lib/eventManager/chains/chainProductLimit.js
|
|
6824
7377
|
|
|
6825
7378
|
|
|
@@ -7037,7 +7590,7 @@ class ChainRelatedCoupons extends Chain {
|
|
|
7037
7590
|
})
|
|
7038
7591
|
// for total ptice coupon
|
|
7039
7592
|
_calculateAmountByTotalCoupons({ lines, currencyCode: this.currency.code, relatedTotalCoupons })
|
|
7040
|
-
_autoUsedTotalCoupons({ lines, autoUseCoupon: this.autoUseCoupon, currencyCode: this.currency.code, relatedTotalCoupons})
|
|
7593
|
+
_autoUsedTotalCoupons({ lines, autoUseCoupon: this.autoUseCoupon, currencyCode: this.currency.code, relatedTotalCoupons })
|
|
7041
7594
|
await this.next(chainTarget)
|
|
7042
7595
|
} catch (err) {
|
|
7043
7596
|
chainTarget.addException('handle related coupons fail', err.message)
|
|
@@ -7046,17 +7599,15 @@ class ChainRelatedCoupons extends Chain {
|
|
|
7046
7599
|
}
|
|
7047
7600
|
}
|
|
7048
7601
|
|
|
7049
|
-
|
|
7050
7602
|
function _autoUsedTotalCoupons({ lines, autoUseCoupon, currencyCode, relatedTotalCoupons }) {
|
|
7051
7603
|
if (autoUseCoupon) {
|
|
7052
|
-
|
|
7053
|
-
|
|
7054
|
-
|
|
7055
|
-
|
|
7604
|
+
relatedTotalCoupons.forEach((item) => {
|
|
7605
|
+
const obj = _autoUsedTotalCoupon(item, lines, currencyCode)
|
|
7606
|
+
Object.assign(item, obj)
|
|
7607
|
+
})
|
|
7056
7608
|
}
|
|
7057
7609
|
}
|
|
7058
7610
|
|
|
7059
|
-
|
|
7060
7611
|
function _autoUsedTotalCoupon(item, lines, currencyCode) {
|
|
7061
7612
|
const { availableCoupons, usedCoupons, product } = item
|
|
7062
7613
|
if (availableCoupons.length > 0) {
|
|
@@ -7097,7 +7648,7 @@ function _calculateAmountByTotalCoupons({ lines, currencyCode, relatedTotalCoupo
|
|
|
7097
7648
|
_calculateAmountByOneTotalCoupon({ lines, currencyCode, coupon })
|
|
7098
7649
|
})
|
|
7099
7650
|
})
|
|
7100
|
-
}
|
|
7651
|
+
}
|
|
7101
7652
|
|
|
7102
7653
|
function _calculateAmountByOneTotalCoupon({ lines, currencyCode, coupon }) {
|
|
7103
7654
|
const availableLines = lines.filter((line) => (coupon.isApplicableCoupon(line.merchandise)))
|
|
@@ -7110,7 +7661,7 @@ function _calculateAmountByOneTotalCoupon({ lines, currencyCode, coupon }) {
|
|
|
7110
7661
|
if (couponDetails) {
|
|
7111
7662
|
const { type, total } = couponDetails
|
|
7112
7663
|
const { value } = couponDetails
|
|
7113
|
-
switch(type) {
|
|
7664
|
+
switch (type) {
|
|
7114
7665
|
case ('Deduction'): {
|
|
7115
7666
|
const _discount = q_utilities_namespaceObject.KeyValueObject.foundValueByKey(value, currencyCode)
|
|
7116
7667
|
availableLines.forEach((line) => {
|
|
@@ -7122,7 +7673,7 @@ function _calculateAmountByOneTotalCoupon({ lines, currencyCode, coupon }) {
|
|
|
7122
7673
|
_usedCoupons.push(walletItemCode)
|
|
7123
7674
|
const obj = {
|
|
7124
7675
|
discount: Amount.init({ value: discountValue, currencyCode }),
|
|
7125
|
-
remarks: q_utilities_namespaceObject.KeyValueObject.insertOrUpdateRecord(remarks, 'USED_TOTAL_COUPONS', _usedCoupons
|
|
7676
|
+
remarks: q_utilities_namespaceObject.KeyValueObject.insertOrUpdateRecord(remarks, 'USED_TOTAL_COUPONS', _usedCoupons),
|
|
7126
7677
|
subTotal: Amount.init({ value: subTotalValue, currencyCode })
|
|
7127
7678
|
}
|
|
7128
7679
|
Object.assign(updatedItem, obj)
|
|
@@ -7140,7 +7691,7 @@ function _calculateAmountByOneTotalCoupon({ lines, currencyCode, coupon }) {
|
|
|
7140
7691
|
_usedCoupons.push(walletItemCode)
|
|
7141
7692
|
const obj = {
|
|
7142
7693
|
discount: Amount.init({ value: discountValue, currencyCode }),
|
|
7143
|
-
remarks: q_utilities_namespaceObject.KeyValueObject.insertOrUpdateRecord(remarks, 'USED_TOTAL_COUPONS', _usedCoupons
|
|
7694
|
+
remarks: q_utilities_namespaceObject.KeyValueObject.insertOrUpdateRecord(remarks, 'USED_TOTAL_COUPONS', _usedCoupons),
|
|
7144
7695
|
subTotal: Amount.init({ value: subTotalValue, currencyCode })
|
|
7145
7696
|
}
|
|
7146
7697
|
Object.assign(updatedItem, obj)
|
|
@@ -7148,11 +7699,10 @@ function _calculateAmountByOneTotalCoupon({ lines, currencyCode, coupon }) {
|
|
|
7148
7699
|
break
|
|
7149
7700
|
}
|
|
7150
7701
|
default: {
|
|
7151
|
-
|
|
7702
|
+
|
|
7152
7703
|
}
|
|
7153
7704
|
}
|
|
7154
7705
|
}
|
|
7155
|
-
|
|
7156
7706
|
}
|
|
7157
7707
|
|
|
7158
7708
|
function _calculateAmountByOneItemCoupon({ updatedItem, coupon, currencyCode }) {
|
|
@@ -7169,12 +7719,11 @@ function _calculateAmountByOneItemCoupon({ updatedItem, coupon, currencyCode })
|
|
|
7169
7719
|
return {
|
|
7170
7720
|
...updatedItem,
|
|
7171
7721
|
discount: Amount.init({ value: discountValue, currencyCode }),
|
|
7172
|
-
remarks: q_utilities_namespaceObject.KeyValueObject.insertOrUpdateRecord(remarks, 'USED_ITEM_COUPONS', _usedCoupons
|
|
7722
|
+
remarks: q_utilities_namespaceObject.KeyValueObject.insertOrUpdateRecord(remarks, 'USED_ITEM_COUPONS', _usedCoupons),
|
|
7173
7723
|
subTotal: Amount.init({ value: subTotalValue, currencyCode })
|
|
7174
7724
|
}
|
|
7175
7725
|
}
|
|
7176
7726
|
|
|
7177
|
-
|
|
7178
7727
|
function _getAvailableItemCoupons(line) {
|
|
7179
7728
|
const { relatedCoupons = [] } = line
|
|
7180
7729
|
line.relatedCoupons = relatedCoupons.map((c) => ({
|
|
@@ -7186,7 +7735,7 @@ function _getAvailableItemCoupons(line) {
|
|
|
7186
7735
|
function _getRelatedItemCoupons(cartItemLine, couponWalletItems, autoUseCoupon, currencyCode) {
|
|
7187
7736
|
const { merchandise, usedCoupons = {}, updatedItem = {} } = cartItemLine
|
|
7188
7737
|
const relatedWalletItems = couponWalletItems.filter(
|
|
7189
|
-
item => item.isApplicableCoupon(merchandise) && item.isItemCoupon
|
|
7738
|
+
(item) => item.isApplicableCoupon(merchandise) && item.isItemCoupon
|
|
7190
7739
|
)
|
|
7191
7740
|
// .sort((a, b) => (
|
|
7192
7741
|
// b.couponDetails.value - a.couponDetails.value
|
|
@@ -7199,7 +7748,7 @@ function _getRelatedItemCoupons(cartItemLine, couponWalletItems, autoUseCoupon,
|
|
|
7199
7748
|
exist = {
|
|
7200
7749
|
coupons: [],
|
|
7201
7750
|
product: w.product,
|
|
7202
|
-
productCode
|
|
7751
|
+
productCode,
|
|
7203
7752
|
usedQty: (usedCoupons[productCode] || []).length
|
|
7204
7753
|
}
|
|
7205
7754
|
acc.push(exist)
|
|
@@ -7221,7 +7770,6 @@ function _getRelatedItemCoupons(cartItemLine, couponWalletItems, autoUseCoupon,
|
|
|
7221
7770
|
}, [])
|
|
7222
7771
|
}
|
|
7223
7772
|
|
|
7224
|
-
|
|
7225
7773
|
function _updateRelatedItemCoupons(line, couponWalletItems, autoUseCoupon, currencyCode) {
|
|
7226
7774
|
if (couponWalletItems.length > 0) {
|
|
7227
7775
|
line.relatedCoupons = _getRelatedItemCoupons(line, couponWalletItems, autoUseCoupon, currencyCode)
|
|
@@ -7230,9 +7778,6 @@ function _updateRelatedItemCoupons(line, couponWalletItems, autoUseCoupon, curre
|
|
|
7230
7778
|
|
|
7231
7779
|
|
|
7232
7780
|
|
|
7233
|
-
|
|
7234
|
-
|
|
7235
|
-
|
|
7236
7781
|
;// ./lib/eventManager/chains/index.js
|
|
7237
7782
|
|
|
7238
7783
|
|
|
@@ -7248,7 +7793,6 @@ function _updateRelatedItemCoupons(line, couponWalletItems, autoUseCoupon, curre
|
|
|
7248
7793
|
|
|
7249
7794
|
|
|
7250
7795
|
;// ./lib/helpers/corHelper/chainException.js
|
|
7251
|
-
|
|
7252
7796
|
class ChainException {
|
|
7253
7797
|
constructor() {
|
|
7254
7798
|
this.result = {}
|
|
@@ -7377,7 +7921,6 @@ class ChainTargetCalculateAmount extends ChainTarget {
|
|
|
7377
7921
|
|
|
7378
7922
|
;// ./lib/helpers/corHelper/chainManager.js
|
|
7379
7923
|
|
|
7380
|
-
|
|
7381
7924
|
// import { ChainResult } from './chainResult.js'
|
|
7382
7925
|
// import { makeChainsFactory } from './helpers.js'
|
|
7383
7926
|
|
|
@@ -7534,7 +8077,10 @@ function _calculateAmountChainsFactory(payload) {
|
|
|
7534
8077
|
new ChainMerchandiseLimit(),
|
|
7535
8078
|
new ChainProductLimit({ products }),
|
|
7536
8079
|
new ChainGetPrice({
|
|
7537
|
-
currency,
|
|
8080
|
+
currency,
|
|
8081
|
+
dateTime,
|
|
8082
|
+
entitlements,
|
|
8083
|
+
merchandises
|
|
7538
8084
|
}),
|
|
7539
8085
|
new ChainRelatedCoupons({ currency, autoUseCoupon, walletItems }),
|
|
7540
8086
|
new ChainPriceAdjustment({ currency }),
|
|
@@ -7554,7 +8100,10 @@ function _calculateAmountChainsFactoryforGroup(payload) {
|
|
|
7554
8100
|
new ChainMerchandiseLimit(),
|
|
7555
8101
|
new ChainProductLimit({ products }),
|
|
7556
8102
|
new ChainGetPriceForGroup({
|
|
7557
|
-
currency,
|
|
8103
|
+
currency,
|
|
8104
|
+
dateTime,
|
|
8105
|
+
entitlements,
|
|
8106
|
+
merchandises
|
|
7558
8107
|
}),
|
|
7559
8108
|
]
|
|
7560
8109
|
}
|
|
@@ -7697,9 +8246,9 @@ function getRolesChangesRelatedCouponsHelper({ newRoles, originalRoles }) {
|
|
|
7697
8246
|
...Object.keys(couponFromOriginalRoles)
|
|
7698
8247
|
])
|
|
7699
8248
|
return Array.from(allKeys).reduce((acc, key) => {
|
|
7700
|
-
const newValue = couponFromNewRoles[key] || 0
|
|
7701
|
-
const originalValue = couponFromOriginalRoles[key] || 0
|
|
7702
|
-
const delta = newValue - originalValue
|
|
8249
|
+
const newValue = couponFromNewRoles[key] || 0
|
|
8250
|
+
const originalValue = couponFromOriginalRoles[key] || 0
|
|
8251
|
+
const delta = newValue - originalValue
|
|
7703
8252
|
if (delta !== 0) {
|
|
7704
8253
|
acc.push({
|
|
7705
8254
|
key,
|
|
@@ -7708,13 +8257,12 @@ function getRolesChangesRelatedCouponsHelper({ newRoles, originalRoles }) {
|
|
|
7708
8257
|
newValue,
|
|
7709
8258
|
originalValue
|
|
7710
8259
|
}
|
|
7711
|
-
})
|
|
8260
|
+
})
|
|
7712
8261
|
}
|
|
7713
8262
|
return acc
|
|
7714
8263
|
}, [])
|
|
7715
8264
|
}
|
|
7716
8265
|
|
|
7717
|
-
|
|
7718
8266
|
function _getCouponsByRoles(roles) {
|
|
7719
8267
|
return roles.reduce((acc, role) => {
|
|
7720
8268
|
const couponCodes = role.getCouponCodes()
|
|
@@ -7765,19 +8313,18 @@ class CouponManager {
|
|
|
7765
8313
|
return getRolesChangesRelatedCouponsHelper({ newRoles: this.newRoles, originalRoles: this.originalRoles })
|
|
7766
8314
|
}
|
|
7767
8315
|
|
|
7768
|
-
|
|
7769
8316
|
get couponItemList() {
|
|
7770
8317
|
return this.couponProducts.map((p) => {
|
|
7771
8318
|
const relatedWalletItems = this.walletItems.filter(
|
|
7772
|
-
item => item.productCode === p.productCode
|
|
8319
|
+
(item) => item.productCode === p.productCode
|
|
7773
8320
|
)
|
|
7774
8321
|
|
|
7775
|
-
const usedCoupons = relatedWalletItems.filter(item => item.isUsed)
|
|
8322
|
+
const usedCoupons = relatedWalletItems.filter((item) => item.isUsed)
|
|
7776
8323
|
usedCoupons.forEach((c) => {
|
|
7777
8324
|
c.useForWalletItems = this.walletItems.filter((item) => (c.useFor || []).includes(item.walletItemCode)) // useFor
|
|
7778
8325
|
})
|
|
7779
8326
|
|
|
7780
|
-
const availableCoupons = relatedWalletItems.filter(item => !item.isAvailableCoupon)
|
|
8327
|
+
const availableCoupons = relatedWalletItems.filter((item) => !item.isAvailableCoupon)
|
|
7781
8328
|
|
|
7782
8329
|
const roleBase = q_utilities_namespaceObject.KeyValueObject.foundValueByKey(this.roleRelatedCoupons, p.productCode) || {}
|
|
7783
8330
|
|
|
@@ -7795,19 +8342,17 @@ class CouponManager {
|
|
|
7795
8342
|
qty,
|
|
7796
8343
|
roleBase,
|
|
7797
8344
|
remarks
|
|
7798
|
-
}
|
|
8345
|
+
}
|
|
7799
8346
|
})
|
|
7800
8347
|
}
|
|
7801
8348
|
|
|
7802
8349
|
setNewRoles() {
|
|
7803
8350
|
this.newRoles = newRoles
|
|
7804
8351
|
}
|
|
7805
|
-
|
|
7806
8352
|
}
|
|
7807
8353
|
|
|
7808
8354
|
|
|
7809
8355
|
|
|
7810
|
-
|
|
7811
8356
|
function _handler({ product, remainingQuota, availableCoupons, roleBase }) {
|
|
7812
8357
|
const { delta = 0 } = roleBase
|
|
7813
8358
|
const { maxPerWallet } = product
|
|
@@ -7848,7 +8393,7 @@ class Handler {
|
|
|
7848
8393
|
|
|
7849
8394
|
|
|
7850
8395
|
class HandlerMinutes extends Handler {
|
|
7851
|
-
process(dateFormat) {
|
|
8396
|
+
process(dateFormat) {
|
|
7852
8397
|
const mthIdx = this.date.getMinutes()
|
|
7853
8398
|
dateFormat = dateFormat.replace('mm', zeroPadding(mthIdx)) // 23-03-10 17:mm
|
|
7854
8399
|
return dateFormat
|
|
@@ -7857,7 +8402,7 @@ class HandlerMinutes extends Handler {
|
|
|
7857
8402
|
|
|
7858
8403
|
function zeroPadding(num) {
|
|
7859
8404
|
if (typeof num !== 'number') {
|
|
7860
|
-
throw new
|
|
8405
|
+
throw new TypeError('Parameter must be of number')
|
|
7861
8406
|
}
|
|
7862
8407
|
return num < 10 ? `0${num}` : `${num}`
|
|
7863
8408
|
}
|
|
@@ -7868,7 +8413,7 @@ function zeroPadding(num) {
|
|
|
7868
8413
|
|
|
7869
8414
|
|
|
7870
8415
|
class HandlerHours extends Handler {
|
|
7871
|
-
process(dateFormat) {
|
|
8416
|
+
process(dateFormat) {
|
|
7872
8417
|
const hthIdx = this.date.getHours()
|
|
7873
8418
|
dateFormat = dateFormat.replace('HH', handlerHours_zeroPadding(hthIdx)) // 23-03-10 HH
|
|
7874
8419
|
return dateFormat
|
|
@@ -7877,7 +8422,7 @@ class HandlerHours extends Handler {
|
|
|
7877
8422
|
|
|
7878
8423
|
function handlerHours_zeroPadding(num) {
|
|
7879
8424
|
if (typeof num !== 'number') {
|
|
7880
|
-
throw new
|
|
8425
|
+
throw new TypeError('Parameter must be of number')
|
|
7881
8426
|
}
|
|
7882
8427
|
return num < 10 ? `0${num}` : `${num}`
|
|
7883
8428
|
}
|
|
@@ -7888,7 +8433,7 @@ function handlerHours_zeroPadding(num) {
|
|
|
7888
8433
|
|
|
7889
8434
|
|
|
7890
8435
|
class HandlerDate extends Handler {
|
|
7891
|
-
process(dateFormat) {
|
|
8436
|
+
process(dateFormat) {
|
|
7892
8437
|
const dthIdx = this.date.getDate()
|
|
7893
8438
|
dateFormat = dateFormat.replace('dd', handlerDate_zeroPadding(dthIdx)) // 23-03-dd
|
|
7894
8439
|
return dateFormat
|
|
@@ -7897,7 +8442,7 @@ class HandlerDate extends Handler {
|
|
|
7897
8442
|
|
|
7898
8443
|
function handlerDate_zeroPadding(num) {
|
|
7899
8444
|
if (typeof num !== 'number') {
|
|
7900
|
-
throw new
|
|
8445
|
+
throw new TypeError('Parameter must be of number')
|
|
7901
8446
|
}
|
|
7902
8447
|
return num < 10 ? `0${num}` : `${num}`
|
|
7903
8448
|
}
|
|
@@ -7919,7 +8464,7 @@ class HandlerMonth extends Handler {
|
|
|
7919
8464
|
|
|
7920
8465
|
function handlerMonth_zeroPadding(num) {
|
|
7921
8466
|
if (typeof num !== 'number') {
|
|
7922
|
-
throw new
|
|
8467
|
+
throw new TypeError('Parameter must be of number')
|
|
7923
8468
|
}
|
|
7924
8469
|
return num < 10 ? `0${num}` : `${num}`
|
|
7925
8470
|
}
|
|
@@ -7989,7 +8534,6 @@ function convert(date, dateFormat) {
|
|
|
7989
8534
|
|
|
7990
8535
|
|
|
7991
8536
|
|
|
7992
|
-
|
|
7993
8537
|
;// ./lib/helpers/ordersList/orderList.js
|
|
7994
8538
|
|
|
7995
8539
|
|
|
@@ -8056,7 +8600,6 @@ function actionBuilder(row, header, qRow) {
|
|
|
8056
8600
|
onClick: orderList_self.onOrderListAction('waived')
|
|
8057
8601
|
})
|
|
8058
8602
|
}
|
|
8059
|
-
|
|
8060
8603
|
}
|
|
8061
8604
|
actions.push({
|
|
8062
8605
|
css: {
|
|
@@ -8082,11 +8625,13 @@ function qListArr(originMerchandises, originInvoices) {
|
|
|
8082
8625
|
}
|
|
8083
8626
|
return {
|
|
8084
8627
|
...acc,
|
|
8085
|
-
amount: i.amount && i.amount.value
|
|
8086
|
-
|
|
8087
|
-
|
|
8088
|
-
|
|
8089
|
-
|
|
8628
|
+
amount: i.amount && i.amount.value
|
|
8629
|
+
? i.amount
|
|
8630
|
+
: {
|
|
8631
|
+
value: acc.amount.value + l.amount.value * l.qty,
|
|
8632
|
+
currencyCode: l.amount.currencyCode,
|
|
8633
|
+
default: acc.amount.default && l.amount.default
|
|
8634
|
+
},
|
|
8090
8635
|
}
|
|
8091
8636
|
}, {
|
|
8092
8637
|
amount: {
|
|
@@ -8116,7 +8661,8 @@ function qListArr(originMerchandises, originInvoices) {
|
|
|
8116
8661
|
|
|
8117
8662
|
function formatStatus(status) {
|
|
8118
8663
|
let newStatus = ''
|
|
8119
|
-
if (!(status instanceof Status))
|
|
8664
|
+
if (!(status instanceof Status))
|
|
8665
|
+
return newStatus
|
|
8120
8666
|
if (status.isCancelled) {
|
|
8121
8667
|
newStatus = 'cancelled'
|
|
8122
8668
|
return newStatus
|
|
@@ -8155,7 +8701,13 @@ function handlerHeaders(defaultHeaders) {
|
|
|
8155
8701
|
}
|
|
8156
8702
|
|
|
8157
8703
|
function handlerOrderList({
|
|
8158
|
-
component,
|
|
8704
|
+
component,
|
|
8705
|
+
config,
|
|
8706
|
+
merchandises,
|
|
8707
|
+
invoices,
|
|
8708
|
+
defaultHeaders,
|
|
8709
|
+
isAdmin,
|
|
8710
|
+
label = {}
|
|
8159
8711
|
}) {
|
|
8160
8712
|
orderList_self = component
|
|
8161
8713
|
_config = config
|
|
@@ -8179,7 +8731,6 @@ function handlerOrderList({
|
|
|
8179
8731
|
|
|
8180
8732
|
|
|
8181
8733
|
|
|
8182
|
-
|
|
8183
8734
|
;// ./lib/helpers/sortHelper/defaultSort.js
|
|
8184
8735
|
function defaultSort(arr, getKey) {
|
|
8185
8736
|
if (!getKey) {
|
|
@@ -8188,7 +8739,7 @@ function defaultSort(arr, getKey) {
|
|
|
8188
8739
|
let key = null
|
|
8189
8740
|
switch (typeof getKey) {
|
|
8190
8741
|
case 'function':
|
|
8191
|
-
arr.forEach(ele => { key = getKey(ele) })
|
|
8742
|
+
arr.forEach((ele) => { key = getKey(ele) })
|
|
8192
8743
|
if (key.length === 0) {
|
|
8193
8744
|
return arr
|
|
8194
8745
|
}
|
|
@@ -8207,9 +8758,9 @@ function defaultSort(arr, getKey) {
|
|
|
8207
8758
|
|
|
8208
8759
|
;// ./lib/helpers/sortHelper/isAllEqual.js
|
|
8209
8760
|
function isAllEqual({ arr = [], key }) {
|
|
8210
|
-
const [
|
|
8761
|
+
const [firstElem] = arr
|
|
8211
8762
|
const compareValue = firstElem[key]
|
|
8212
|
-
return arr.every(a => a[key] === compareValue)
|
|
8763
|
+
return arr.every((a) => a[key] === compareValue)
|
|
8213
8764
|
}
|
|
8214
8765
|
|
|
8215
8766
|
|
|
@@ -8234,7 +8785,6 @@ function isDescendingOrder({ arr = [], key }) {
|
|
|
8234
8785
|
|
|
8235
8786
|
|
|
8236
8787
|
|
|
8237
|
-
|
|
8238
8788
|
;// ./lib/helpers/index.js
|
|
8239
8789
|
|
|
8240
8790
|
|
|
@@ -8249,6 +8799,7 @@ function isDescendingOrder({ arr = [], key }) {
|
|
|
8249
8799
|
|
|
8250
8800
|
;// ./lib/index.js
|
|
8251
8801
|
|
|
8802
|
+
|
|
8252
8803
|
const models = models_namespaceObject
|
|
8253
8804
|
|
|
8254
8805
|
|
|
@@ -8258,6 +8809,8 @@ const models = models_namespaceObject
|
|
|
8258
8809
|
|
|
8259
8810
|
|
|
8260
8811
|
var __webpack_exports__Amount = __webpack_exports__.J0;
|
|
8812
|
+
var __webpack_exports__BillingAccount = __webpack_exports__.XC;
|
|
8813
|
+
var __webpack_exports__BillingProject = __webpack_exports__.l8;
|
|
8261
8814
|
var __webpack_exports__Cart = __webpack_exports__.Z3;
|
|
8262
8815
|
var __webpack_exports__CartItem = __webpack_exports__.m6;
|
|
8263
8816
|
var __webpack_exports__Category = __webpack_exports__.b7;
|
|
@@ -8278,13 +8831,18 @@ var __webpack_exports__KeyValueObject = __webpack_exports__.Yc;
|
|
|
8278
8831
|
var __webpack_exports__Merchandise = __webpack_exports__.So;
|
|
8279
8832
|
var __webpack_exports__Order = __webpack_exports__.pH;
|
|
8280
8833
|
var __webpack_exports__OrderLine = __webpack_exports__.$x;
|
|
8834
|
+
var __webpack_exports__PaymentCharge = __webpack_exports__.f7;
|
|
8281
8835
|
var __webpack_exports__PaymentGateway = __webpack_exports__.Zg;
|
|
8836
|
+
var __webpack_exports__PaymentItem = __webpack_exports__.MS;
|
|
8282
8837
|
var __webpack_exports__PaymentResult = __webpack_exports__.gp;
|
|
8283
8838
|
var __webpack_exports__Price = __webpack_exports__.gm;
|
|
8284
8839
|
var __webpack_exports__PriceStrategy = __webpack_exports__.X0;
|
|
8285
8840
|
var __webpack_exports__Product = __webpack_exports__.Yt;
|
|
8841
|
+
var __webpack_exports__Receipt = __webpack_exports__.TA;
|
|
8842
|
+
var __webpack_exports__ReceiptLine = __webpack_exports__.Hx;
|
|
8286
8843
|
var __webpack_exports__Status = __webpack_exports__.nW;
|
|
8287
8844
|
var __webpack_exports__StatusQStore = __webpack_exports__.TM;
|
|
8845
|
+
var __webpack_exports__StatusQStoreInvoice = __webpack_exports__.M;
|
|
8288
8846
|
var __webpack_exports__StatusQStoreOrderLine = __webpack_exports__.Dy;
|
|
8289
8847
|
var __webpack_exports__StoreItem = __webpack_exports__.vB;
|
|
8290
8848
|
var __webpack_exports__Transaction = __webpack_exports__.ZX;
|
|
@@ -8310,4 +8868,4 @@ var __webpack_exports__objectComparator = __webpack_exports__.aL;
|
|
|
8310
8868
|
var __webpack_exports__objectOrderInArrayComparator = __webpack_exports__.il;
|
|
8311
8869
|
var __webpack_exports__setQuery = __webpack_exports__.NY;
|
|
8312
8870
|
var __webpack_exports__stringHelper = __webpack_exports__.yO;
|
|
8313
|
-
export { __webpack_exports__Amount as Amount, __webpack_exports__Cart as Cart, __webpack_exports__CartItem as CartItem, __webpack_exports__Category as Category, __webpack_exports__Chain as Chain, __webpack_exports__ChainManager as ChainManager, __webpack_exports__ChainManagerFactory as ChainManagerFactory, __webpack_exports__ChainTarget as ChainTarget, __webpack_exports__CouponManager as CouponManager, __webpack_exports__CreditNote as CreditNote, __webpack_exports__CreditNoteLine as CreditNoteLine, __webpack_exports__CreditNoteRepo as CreditNoteRepo, __webpack_exports__Currency as Currency, __webpack_exports__Invoice as Invoice, __webpack_exports__InvoiceLine as InvoiceLine, __webpack_exports__ItemOption as ItemOption, __webpack_exports__ItemOptionLocale as ItemOptionLocale, __webpack_exports__KeyValueObject as KeyValueObject, __webpack_exports__Merchandise as Merchandise, __webpack_exports__Order as Order, __webpack_exports__OrderLine as OrderLine, __webpack_exports__PaymentGateway as PaymentGateway, __webpack_exports__PaymentResult as PaymentResult, __webpack_exports__Price as Price, __webpack_exports__PriceStrategy as PriceStrategy, __webpack_exports__Product as Product, __webpack_exports__Status as Status, __webpack_exports__StatusQStore as StatusQStore, __webpack_exports__StatusQStoreOrderLine as StatusQStoreOrderLine, __webpack_exports__StoreItem as StoreItem, __webpack_exports__Transaction as Transaction, __webpack_exports__WalletItem as WalletItem, __webpack_exports__adminSettle as adminSettle, __webpack_exports__calculateByCoupon as calculateByCoupon, __webpack_exports__calculator as calculator, __webpack_exports__checkDuplicate as checkDuplicate, __webpack_exports__convertTimestampToString as convertTimestampToString, __webpack_exports__defaultComparator as defaultComparator, __webpack_exports__defaultSort as defaultSort, __webpack_exports__eleInArrayComparator as eleInArrayComparator, __webpack_exports__firstLetterToLower as firstLetterToLower, __webpack_exports__getFakeClass as getFakeClass, __webpack_exports__getSubClass as getSubClass, __webpack_exports__handlerOrderList as handlerOrderList, __webpack_exports__isAllEqual as isAllEqual, __webpack_exports__isDescendingOrder as isDescendingOrder, __webpack_exports__makeResponseHelper as makeResponseHelper, __webpack_exports__models as models, __webpack_exports__objectAllInArrayComparator as objectAllInArrayComparator, __webpack_exports__objectComparator as objectComparator, __webpack_exports__objectOrderInArrayComparator as objectOrderInArrayComparator, __webpack_exports__setQuery as setQuery, __webpack_exports__stringHelper as stringHelper };
|
|
8871
|
+
export { __webpack_exports__Amount as Amount, __webpack_exports__BillingAccount as BillingAccount, __webpack_exports__BillingProject as BillingProject, __webpack_exports__Cart as Cart, __webpack_exports__CartItem as CartItem, __webpack_exports__Category as Category, __webpack_exports__Chain as Chain, __webpack_exports__ChainManager as ChainManager, __webpack_exports__ChainManagerFactory as ChainManagerFactory, __webpack_exports__ChainTarget as ChainTarget, __webpack_exports__CouponManager as CouponManager, __webpack_exports__CreditNote as CreditNote, __webpack_exports__CreditNoteLine as CreditNoteLine, __webpack_exports__CreditNoteRepo as CreditNoteRepo, __webpack_exports__Currency as Currency, __webpack_exports__Invoice as Invoice, __webpack_exports__InvoiceLine as InvoiceLine, __webpack_exports__ItemOption as ItemOption, __webpack_exports__ItemOptionLocale as ItemOptionLocale, __webpack_exports__KeyValueObject as KeyValueObject, __webpack_exports__Merchandise as Merchandise, __webpack_exports__Order as Order, __webpack_exports__OrderLine as OrderLine, __webpack_exports__PaymentCharge as PaymentCharge, __webpack_exports__PaymentGateway as PaymentGateway, __webpack_exports__PaymentItem as PaymentItem, __webpack_exports__PaymentResult as PaymentResult, __webpack_exports__Price as Price, __webpack_exports__PriceStrategy as PriceStrategy, __webpack_exports__Product as Product, __webpack_exports__Receipt as Receipt, __webpack_exports__ReceiptLine as ReceiptLine, __webpack_exports__Status as Status, __webpack_exports__StatusQStore as StatusQStore, __webpack_exports__StatusQStoreInvoice as StatusQStoreInvoice, __webpack_exports__StatusQStoreOrderLine as StatusQStoreOrderLine, __webpack_exports__StoreItem as StoreItem, __webpack_exports__Transaction as Transaction, __webpack_exports__WalletItem as WalletItem, __webpack_exports__adminSettle as adminSettle, __webpack_exports__calculateByCoupon as calculateByCoupon, __webpack_exports__calculator as calculator, __webpack_exports__checkDuplicate as checkDuplicate, __webpack_exports__convertTimestampToString as convertTimestampToString, __webpack_exports__defaultComparator as defaultComparator, __webpack_exports__defaultSort as defaultSort, __webpack_exports__eleInArrayComparator as eleInArrayComparator, __webpack_exports__firstLetterToLower as firstLetterToLower, __webpack_exports__getFakeClass as getFakeClass, __webpack_exports__getSubClass as getSubClass, __webpack_exports__handlerOrderList as handlerOrderList, __webpack_exports__isAllEqual as isAllEqual, __webpack_exports__isDescendingOrder as isDescendingOrder, __webpack_exports__makeResponseHelper as makeResponseHelper, __webpack_exports__models as models, __webpack_exports__objectAllInArrayComparator as objectAllInArrayComparator, __webpack_exports__objectComparator as objectComparator, __webpack_exports__objectOrderInArrayComparator as objectOrderInArrayComparator, __webpack_exports__setQuery as setQuery, __webpack_exports__stringHelper as stringHelper };
|