@questwork/q-store-model 0.1.39 → 0.1.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.min.cjs +1230 -692
- package/dist/index.min.js +1237 -692
- package/dist/q-store-model.min.js +1230 -692
- package/eslint.config.js +3 -0
- package/package.json +4 -3
package/dist/index.min.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,784 @@ 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
|
+
'status',
|
|
4099
|
+
]
|
|
4100
|
+
|
|
4101
|
+
class ReceiptLine extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
4102
|
+
constructor(options) {
|
|
4103
|
+
options = options || {}
|
|
4104
|
+
super(options)
|
|
4105
|
+
|
|
4106
|
+
const { _Amount, _PaymentCharge, _PaymentItem, _Receipt, _Status } = options._constructor || {}
|
|
4107
|
+
this._Amount = _Amount && (_Amount._superclass === Amount._superclass) ? _Amount : Amount
|
|
4108
|
+
this._PaymentCharge = _PaymentCharge && (_PaymentCharge._superclass === PaymentCharge._superclass) ? _PaymentCharge : PaymentCharge
|
|
4109
|
+
this._PaymentItem = _PaymentItem && (_PaymentItem._superclass === PaymentItem._superclass) ? _PaymentItem : PaymentItem
|
|
4110
|
+
this._Receipt = _Receipt && (_Receipt._superclass === Receipt._superclass) ? _Receipt : Receipt
|
|
4111
|
+
this._Status = _Status && (_Status._superclass === StatusQStore._superclass) ? _Status : StatusQStore
|
|
4112
|
+
|
|
4113
|
+
this._paymentCharge = options._paymentCharge
|
|
4114
|
+
this._paymentItems = options._paymentItems
|
|
4115
|
+
this._receipt = options._receipt
|
|
4116
|
+
|
|
4117
|
+
const id = options._id || options.id
|
|
4118
|
+
this.id = receiptLine_setId(id)
|
|
4119
|
+
this._type = options._type || 'ReceiptLine'
|
|
4120
|
+
this.additionalData = q_utilities_namespaceObject.KeyValueObject.initOnlyValidFromArray(options.additionalData)
|
|
4121
|
+
this.amount = this._Amount.init(options.amount)
|
|
4122
|
+
this.paidAmount = this._Amount.init(options.paidAmount)
|
|
4123
|
+
this.paymentGatewayCode = options.paymentGatewayCode
|
|
4124
|
+
this.receiptCode = options.receiptCode
|
|
4125
|
+
this.receiptDate = options.receiptDate || (new Date()).valueOf()
|
|
4126
|
+
this.receiptLineCode = options.receiptLineCode
|
|
4127
|
+
this.receiptLineType = 'ReceiptLine'
|
|
4128
|
+
this.status = this._Status.init(options.status)
|
|
4129
|
+
this.surcharge = this._Amount.init(options.surcharge)
|
|
4130
|
+
}
|
|
4131
|
+
|
|
4132
|
+
static dummyData() {
|
|
4133
|
+
return {
|
|
4134
|
+
receiptCode: 'receiptCode',
|
|
4135
|
+
tenantCode: 'tenantCode'
|
|
4136
|
+
}
|
|
4137
|
+
}
|
|
4138
|
+
|
|
4139
|
+
static get _classname() {
|
|
4140
|
+
return 'ReceiptLine'
|
|
4141
|
+
}
|
|
4142
|
+
|
|
4143
|
+
static get _superclass() {
|
|
4144
|
+
return 'ReceiptLine'
|
|
4145
|
+
}
|
|
4146
|
+
|
|
4147
|
+
get isCancelled() {
|
|
4148
|
+
return this.status.isCancelled
|
|
4149
|
+
}
|
|
4150
|
+
|
|
4151
|
+
get isCompleted() {
|
|
4152
|
+
return this.status.isCompleted
|
|
4153
|
+
}
|
|
4154
|
+
|
|
4155
|
+
get isConfirmed() {
|
|
4156
|
+
return this.status.isConfirmed
|
|
4157
|
+
}
|
|
4158
|
+
|
|
4159
|
+
get isTerminated() {
|
|
4160
|
+
return this.status.isTerminated
|
|
4161
|
+
}
|
|
4162
|
+
|
|
4163
|
+
get isValid() {
|
|
4164
|
+
return super.isValid && !!this.receiptCode
|
|
4165
|
+
}
|
|
4166
|
+
|
|
4167
|
+
get paymentCharge() {
|
|
4168
|
+
return this._PaymentCharge.init(this._paymentCharge)
|
|
4169
|
+
}
|
|
4170
|
+
get paymentItems() {
|
|
4171
|
+
return this._PaymentItem.initOnlyValidFromArray(this._paymentItems)
|
|
4172
|
+
}
|
|
4173
|
+
get receipt() {
|
|
4174
|
+
return this._Receipt.init(this._receipt)
|
|
4175
|
+
}
|
|
4176
|
+
|
|
4177
|
+
getAmount() {
|
|
4178
|
+
return this.amount
|
|
4179
|
+
}
|
|
4180
|
+
|
|
4181
|
+
setCancelled(value, actorCode) {
|
|
4182
|
+
this.status.setCancelled(value, actorCode)
|
|
4183
|
+
return this.setModified()
|
|
4184
|
+
}
|
|
4185
|
+
|
|
4186
|
+
setCompleted(value, actorCode) {
|
|
4187
|
+
this.status.setCompleted(value, actorCode)
|
|
4188
|
+
return this.setModified()
|
|
4189
|
+
}
|
|
4190
|
+
setConfirmed(value, actorCode) {
|
|
4191
|
+
this.status.setProcessing(value, actorCode)
|
|
4192
|
+
return this.setModified()
|
|
4193
|
+
}
|
|
4194
|
+
|
|
4195
|
+
setTerminated(value, actorCode) {
|
|
4196
|
+
this.status.setTerminated(value, actorCode)
|
|
4197
|
+
return this.setModified()
|
|
4198
|
+
}
|
|
4199
|
+
|
|
4200
|
+
update(obj) {
|
|
4201
|
+
Object.keys(obj).forEach((key) => {
|
|
4202
|
+
if (receiptLine_updateAllowedProps.includes(key)) {
|
|
4203
|
+
if (key === 'additionalData') {
|
|
4204
|
+
this[key] = q_utilities_namespaceObject.KeyValueObject.initOnlyValidFromArray(obj[key])
|
|
4205
|
+
} else if (key === 'status') {
|
|
4206
|
+
this[key] = this[key] instanceof this._Status ? this[key].update(obj[key]) : this._Status.init(obj[key])
|
|
4207
|
+
} else {
|
|
4208
|
+
this[key] = obj[key]
|
|
4209
|
+
}
|
|
4210
|
+
}
|
|
4211
|
+
})
|
|
4212
|
+
return super.update(obj)
|
|
4213
|
+
}
|
|
4214
|
+
}
|
|
4215
|
+
|
|
4216
|
+
function receiptLine_setId(id) {
|
|
4217
|
+
if (id && typeof id.toString === 'function') {
|
|
4218
|
+
return id.toString()
|
|
4219
|
+
}
|
|
4220
|
+
return id
|
|
4221
|
+
}
|
|
4222
|
+
|
|
4223
|
+
|
|
4224
|
+
|
|
4225
|
+
;// ./lib/models/receiptLine/index.js
|
|
4226
|
+
|
|
4227
|
+
|
|
4228
|
+
|
|
4229
|
+
|
|
4230
|
+
;// ./lib/models/receipt/receipt.js
|
|
4231
|
+
|
|
4232
|
+
|
|
4233
|
+
|
|
4234
|
+
|
|
4235
|
+
|
|
4236
|
+
const receipt_updateAllowedProps = [
|
|
4237
|
+
'status',
|
|
4238
|
+
]
|
|
4239
|
+
|
|
4240
|
+
class Receipt extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
4241
|
+
constructor(options) {
|
|
4242
|
+
options = options || {}
|
|
4243
|
+
super(options)
|
|
4244
|
+
|
|
4245
|
+
const { _Amount, _ReceiptLine, _Status } = options._constructor || {}
|
|
4246
|
+
this._Amount = _Amount && (_Amount._superclass === Amount._superclass) ? _Amount : Amount
|
|
4247
|
+
this._ReceiptLine = _ReceiptLine && (_ReceiptLine._superclass === ReceiptLine._superclass) ? _ReceiptLine : ReceiptLine
|
|
4248
|
+
this._Status = _Status && (_Status._superclass === StatusQStore._superclass) ? _Status : StatusQStore
|
|
4249
|
+
|
|
4250
|
+
this._receiptLines = options._receiptLines
|
|
4251
|
+
|
|
4252
|
+
const id = options._id || options.id
|
|
4253
|
+
this.id = receipt_setId(id)
|
|
4254
|
+
this._type = options._type || 'Receipt'
|
|
4255
|
+
this.amount = this._Amount.init(options.amount)
|
|
4256
|
+
this.paidAmount = this._Amount.init(options.paidAmount)
|
|
4257
|
+
this.paymentGatewayCode = options.paymentGatewayCode
|
|
4258
|
+
this.receiptCode = options.receiptCode
|
|
4259
|
+
this.receiptDate = options.receiptDate || (new Date()).valueOf()
|
|
4260
|
+
this.receiptNumber = options.receiptNumber
|
|
4261
|
+
this.receiptType = 'Receipt'
|
|
4262
|
+
this.revisionNumber = options.revisionNumber || 1
|
|
4263
|
+
this.status = this._Status.init(options.status)
|
|
4264
|
+
this.surcharge = this._Amount.init(options.surcharge)
|
|
4265
|
+
}
|
|
4266
|
+
|
|
4267
|
+
static dummyData() {
|
|
4268
|
+
return {
|
|
4269
|
+
tenantCode: 'tenantCode'
|
|
4270
|
+
}
|
|
4271
|
+
}
|
|
4272
|
+
|
|
4273
|
+
static get _classname() {
|
|
4274
|
+
return 'Receipt'
|
|
4275
|
+
}
|
|
4276
|
+
|
|
4277
|
+
static get _superclass() {
|
|
4278
|
+
return 'Receipt'
|
|
4279
|
+
}
|
|
4280
|
+
|
|
4281
|
+
// get isValid() {
|
|
4282
|
+
// return super.isValid
|
|
4283
|
+
// }
|
|
4284
|
+
|
|
4285
|
+
get isCancelled() {
|
|
4286
|
+
return this.status.isCancelled
|
|
4287
|
+
}
|
|
4288
|
+
|
|
4289
|
+
get isCompleted() {
|
|
4290
|
+
return this.status.isCompleted
|
|
4291
|
+
}
|
|
4292
|
+
|
|
4293
|
+
get isConfirmed() {
|
|
4294
|
+
return this.status.isConfirmed
|
|
4295
|
+
}
|
|
4296
|
+
|
|
4297
|
+
get isTerminated() {
|
|
4298
|
+
return this.status.isTerminated
|
|
4299
|
+
}
|
|
4300
|
+
|
|
4301
|
+
get receiptLines() {
|
|
4302
|
+
return this._ReceiptLine.initOnlyValidFromArray(this._receiptLines || [])
|
|
4303
|
+
}
|
|
4304
|
+
|
|
4305
|
+
getAmount() {
|
|
4306
|
+
return this.amount
|
|
4307
|
+
}
|
|
4308
|
+
|
|
4309
|
+
getFullReceiptNumber(delimiter = '.') {
|
|
4310
|
+
return `${this.receiptNumber}${delimiter}${this.revisionNumber}`
|
|
4311
|
+
}
|
|
4312
|
+
|
|
4313
|
+
increaseRevisionNumber() {
|
|
4314
|
+
this.revisionNumber += 1
|
|
4315
|
+
return this
|
|
4316
|
+
}
|
|
4317
|
+
|
|
4318
|
+
setCancelled(value, actorCode) {
|
|
4319
|
+
this.status.setCancelled(value, actorCode)
|
|
4320
|
+
return this.setModified()
|
|
4321
|
+
}
|
|
4322
|
+
|
|
4323
|
+
setCompleted(value, actorCode) {
|
|
4324
|
+
this.status.setCompleted(value, actorCode)
|
|
4325
|
+
return this.setModified()
|
|
4326
|
+
}
|
|
4327
|
+
setConfirmed(value, actorCode) {
|
|
4328
|
+
this.status.setProcessing(value, actorCode)
|
|
4329
|
+
return this.setModified()
|
|
4330
|
+
}
|
|
4331
|
+
|
|
4332
|
+
setTerminated(value, actorCode) {
|
|
4333
|
+
this.status.setTerminated(value, actorCode)
|
|
4334
|
+
return this.setModified()
|
|
4335
|
+
}
|
|
4336
|
+
|
|
4337
|
+
update(obj) {
|
|
4338
|
+
Object.keys(obj).forEach((key) => {
|
|
4339
|
+
if (receipt_updateAllowedProps.includes(key)) {
|
|
4340
|
+
if (key === 'status') {
|
|
4341
|
+
this[key] = this.status instanceof this._Status ? this.status.update(obj[key]) : this._Status.init(obj[key])
|
|
4342
|
+
} else {
|
|
4343
|
+
this[key] = obj[key]
|
|
4344
|
+
}
|
|
4345
|
+
}
|
|
4346
|
+
})
|
|
4347
|
+
return super.update(obj)
|
|
4348
|
+
}
|
|
4349
|
+
}
|
|
4350
|
+
|
|
4351
|
+
function receipt_setId(id) {
|
|
4352
|
+
if (id && typeof id.toString === 'function') {
|
|
4353
|
+
return id.toString()
|
|
4354
|
+
}
|
|
4355
|
+
return id
|
|
4356
|
+
}
|
|
4357
|
+
|
|
4358
|
+
|
|
4359
|
+
|
|
4360
|
+
;// ./lib/models/receipt/index.js
|
|
4361
|
+
|
|
4362
|
+
|
|
4363
|
+
|
|
4364
|
+
|
|
4365
|
+
;// ./lib/models/paymentItem/paymentItem.js
|
|
4366
|
+
|
|
4367
|
+
|
|
4368
|
+
// import { StatusQStore } from '../statusQStore/index.js'
|
|
4369
|
+
|
|
4370
|
+
|
|
4371
|
+
|
|
4372
|
+
|
|
4373
|
+
|
|
4374
|
+
|
|
4375
|
+
const paymentItem_updateAllowedProps = [
|
|
4376
|
+
'amount',
|
|
4377
|
+
]
|
|
4378
|
+
|
|
4379
|
+
class PaymentItem extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
4380
|
+
constructor(options) {
|
|
4381
|
+
options = options || {}
|
|
4382
|
+
super(options)
|
|
4383
|
+
|
|
4384
|
+
const { _Amount, _Invoice, _InvoiceLine, _PaymentGateway, _Receipt, _ReceiptLine } = options._constructor || {}
|
|
4385
|
+
this._Amount = _Amount && (_Amount._superclass === Amount._superclass) ? _Amount : Amount
|
|
4386
|
+
this._Invoice = _Invoice && (_Invoice._superclass === Invoice._superclass) ? _Invoice : Invoice
|
|
4387
|
+
this._InvoiceLine = _InvoiceLine && (_InvoiceLine._superclass === InvoiceLine._superclass) ? _InvoiceLine : InvoiceLine
|
|
4388
|
+
this._PaymentGateway = _PaymentGateway && (_PaymentGateway._superclass === PaymentGateway._superclass) ? _PaymentGateway : PaymentGateway
|
|
4389
|
+
this._Receipt = _Receipt && (_Receipt._superclass === Receipt._superclass) ? _Receipt : Receipt
|
|
4390
|
+
this._ReceiptLine = _ReceiptLine && (_ReceiptLine._superclass === ReceiptLine._superclass) ? _ReceiptLine : ReceiptLine
|
|
4391
|
+
// this._Status = _Status && (_Status._superclass === StatusQStore._superclass) ? _Status : StatusQStore
|
|
4392
|
+
|
|
4393
|
+
this._invoice = options._invoice
|
|
4394
|
+
this._invoiceLines = options._invoiceLines
|
|
4395
|
+
this._paymentGateway = options._paymentGateway
|
|
4396
|
+
this._receipt = options._receipt
|
|
4397
|
+
this._receiptLine = options._receiptLine
|
|
4398
|
+
|
|
4399
|
+
const id = options._id || options.id
|
|
4400
|
+
this.id = paymentItem_setId(id)
|
|
4401
|
+
this._type = options._type || 'PaymentItem'
|
|
4402
|
+
this.amount = this._Amount.init(options.amount)
|
|
4403
|
+
this.invoiceCode = options.invoiceCode
|
|
4404
|
+
this.invoiceDate = options.invoiceDate || (new Date()).valueOf()
|
|
4405
|
+
this.invoiceLineCode = options.invoiceLineCode
|
|
4406
|
+
this.paymentGatewayCode = options.paymentGatewayCode
|
|
4407
|
+
this.paymentItemCode = options.paymentItemCode
|
|
4408
|
+
this.paymentItemType = 'PaymentItem'
|
|
4409
|
+
this.receiptCode = options.receiptCode
|
|
4410
|
+
this.receiptDate = options.receiptDate || (new Date()).valueOf()
|
|
4411
|
+
this.receiptLineCode = options.receiptLineCode
|
|
4412
|
+
// this.status = this._Status.init(options.status)
|
|
4413
|
+
}
|
|
4414
|
+
|
|
4415
|
+
static dummyData() {
|
|
4416
|
+
return {
|
|
4417
|
+
invoiceCode: 'invoiceCode',
|
|
4418
|
+
invoiceLineCode: 'invoiceLineCode',
|
|
4419
|
+
paymentGatewayCode: 'paymentGatewayCode',
|
|
4420
|
+
receiptCode: 'receiptCode',
|
|
4421
|
+
receiptLineCode: 'receiptLineCode',
|
|
4422
|
+
tenantCode: 'tenantCode'
|
|
4423
|
+
}
|
|
4424
|
+
}
|
|
4425
|
+
|
|
4426
|
+
static get _classname() {
|
|
4427
|
+
return 'PaymentItem'
|
|
4428
|
+
}
|
|
4429
|
+
|
|
4430
|
+
static get _superclass() {
|
|
4431
|
+
return 'PaymentItem'
|
|
4432
|
+
}
|
|
4433
|
+
|
|
4434
|
+
get invoice() {
|
|
4435
|
+
return this._Invoice.init(this._invoice)
|
|
4436
|
+
}
|
|
4437
|
+
|
|
4438
|
+
get invoiceLines() {
|
|
4439
|
+
return this._InvoiceLine.initOnlyValidFromArray(this._invoiceLines || [])
|
|
4440
|
+
}
|
|
4441
|
+
|
|
4442
|
+
get isValid() {
|
|
4443
|
+
return super.isValid && !!this.invoiceCode && !!this.invoiceLineCode && !!this.paymentGatewayCode && !!this.receiptCode && !!this.receiptLineCode
|
|
4444
|
+
}
|
|
4445
|
+
|
|
4446
|
+
get paymentGateway() {
|
|
4447
|
+
return this._PaymentGateway.init(this._paymentGateway)
|
|
4448
|
+
}
|
|
4449
|
+
|
|
4450
|
+
get receipt() {
|
|
4451
|
+
return this._Receipt.init(this._receipt)
|
|
4452
|
+
}
|
|
4453
|
+
|
|
4454
|
+
get receiptLines() {
|
|
4455
|
+
return this._ReceiptLine.initOnlyValidFromArray(this._receiptLines || [])
|
|
4456
|
+
}
|
|
4457
|
+
|
|
4458
|
+
update(obj) {
|
|
4459
|
+
Object.keys(obj).forEach((key) => {
|
|
4460
|
+
if (paymentItem_updateAllowedProps.includes(key)) {
|
|
4461
|
+
if (key === 'amount') {
|
|
4462
|
+
this[key] = this.amount instanceof this._Amount ? this.amount.update(obj[key]) : this._Amount.init(obj[key])
|
|
4463
|
+
} else {
|
|
4464
|
+
this[key] = obj[key]
|
|
4465
|
+
}
|
|
4466
|
+
}
|
|
4467
|
+
})
|
|
4468
|
+
return super.update(obj)
|
|
4469
|
+
}
|
|
4470
|
+
}
|
|
4471
|
+
|
|
4472
|
+
function paymentItem_setId(id) {
|
|
4473
|
+
if (id && typeof id.toString === 'function') {
|
|
4474
|
+
return id.toString()
|
|
4475
|
+
}
|
|
4476
|
+
return id
|
|
4477
|
+
}
|
|
4478
|
+
|
|
4479
|
+
|
|
4480
|
+
|
|
4481
|
+
;// ./lib/models/paymentItem/index.js
|
|
4482
|
+
|
|
4483
|
+
|
|
4484
|
+
|
|
4485
|
+
|
|
3682
4486
|
;// ./lib/models/invoiceLine/invoiceLine.js
|
|
3683
4487
|
|
|
3684
4488
|
|
|
@@ -3688,12 +4492,15 @@ function _getOnePurchaseOptionValue({
|
|
|
3688
4492
|
|
|
3689
4493
|
|
|
3690
4494
|
|
|
4495
|
+
|
|
3691
4496
|
const invoiceLine_updateAllowedProps = [
|
|
3692
4497
|
'amount',
|
|
3693
4498
|
'deduction',
|
|
3694
4499
|
'description',
|
|
3695
4500
|
'discount',
|
|
4501
|
+
'invoiceDate',
|
|
3696
4502
|
'note',
|
|
4503
|
+
'outstanding',
|
|
3697
4504
|
'purchaseOptions',
|
|
3698
4505
|
'qty',
|
|
3699
4506
|
'unitPrice'
|
|
@@ -3704,14 +4511,16 @@ class InvoiceLine extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
3704
4511
|
options = options || {}
|
|
3705
4512
|
super(options)
|
|
3706
4513
|
|
|
3707
|
-
const { _Amount, _Invoice, _Merchandise, _Status } = options._constructor || {}
|
|
4514
|
+
const { _Amount, _Invoice, _Merchandise, _PaymentItem, _Status } = options._constructor || {}
|
|
3708
4515
|
this._Amount = _Amount && (_Amount._superclass === Amount._superclass) ? _Amount : Amount
|
|
3709
4516
|
this._Invoice = _Invoice && (_Invoice._superclass === Invoice._superclass) ? _Invoice : Invoice
|
|
3710
4517
|
this._Merchandise = _Merchandise && (_Merchandise._superclass === Merchandise._superclass) ? _Merchandise : Merchandise
|
|
4518
|
+
this._PaymentItem = _PaymentItem && (_PaymentItem._superclass === PaymentItem._superclass) ? _PaymentItem : PaymentItem
|
|
3711
4519
|
this._Status = _Status && (_Status._superclass === Status._superclass) ? _Status : Status
|
|
3712
4520
|
|
|
3713
4521
|
this._invoice = options._invoice
|
|
3714
4522
|
this._merchandise = options._merchandise
|
|
4523
|
+
this._paymentItems = options._paymentItems
|
|
3715
4524
|
|
|
3716
4525
|
const id = options._id || options.id
|
|
3717
4526
|
this.id = invoiceLine_setId(id)
|
|
@@ -3721,10 +4530,12 @@ class InvoiceLine extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
3721
4530
|
this.description = options.description
|
|
3722
4531
|
this.discount = options.discount || 0
|
|
3723
4532
|
this.invoiceCode = options.invoiceCode
|
|
4533
|
+
this.invoiceDate = options.invoiceDate || (new Date()).valueOf()
|
|
3724
4534
|
this.invoiceLineCode = invoiceLine_setCode(options, 'invoiceLineCode')
|
|
3725
4535
|
this.invoiceLineType = options.invoiceLineType || 'InvoiceLine'
|
|
3726
4536
|
this.merchandiseCode = options.merchandiseCode
|
|
3727
4537
|
this.note = options.note
|
|
4538
|
+
this.outstanding = this._Amount.init(options.outstanding)
|
|
3728
4539
|
this.purchaseOptions = q_utilities_namespaceObject.KeyValueObject.initOnlyValidFromArray(options.purchaseOptions)
|
|
3729
4540
|
this.qty = options.qty || 1
|
|
3730
4541
|
this.status = this._Status.init(options.status)
|
|
@@ -3757,7 +4568,9 @@ class InvoiceLine extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
3757
4568
|
get merchandise() {
|
|
3758
4569
|
return this._Merchandise.init(this._merchandise)
|
|
3759
4570
|
}
|
|
3760
|
-
|
|
4571
|
+
get paymentItems() {
|
|
4572
|
+
return this._PaymentItem.initOnlyValidFromArray(this._paymentItems)
|
|
4573
|
+
}
|
|
3761
4574
|
get usedCoupons() {
|
|
3762
4575
|
const usedItemCoupons = q_utilities_namespaceObject.KeyValueObject.getValueByKey(this.remarks, 'USED_ITEM_COUPONS') || []
|
|
3763
4576
|
const usedTotalCoupons = q_utilities_namespaceObject.KeyValueObject.getValueByKey(this.remarks, 'USED_TOTAL_COUPONS') || []
|
|
@@ -3772,10 +4585,14 @@ class InvoiceLine extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
3772
4585
|
purchaseOptions: this.purchaseOptions
|
|
3773
4586
|
})
|
|
3774
4587
|
}
|
|
4588
|
+
setCompleted(timestamp, actorCode) {
|
|
4589
|
+
this.status.setCompleted(timestamp, actorCode)
|
|
4590
|
+
return this.setModified()
|
|
4591
|
+
}
|
|
3775
4592
|
update(update) {
|
|
3776
4593
|
Object.keys(update).forEach((key) => {
|
|
3777
4594
|
if (invoiceLine_updateAllowedProps.includes(key)) {
|
|
3778
|
-
if (key === 'amount' || key === 'unitPrice' || key === 'deduction') {
|
|
4595
|
+
if (key === 'amount' || key === 'unitPrice' || key === 'deduction' || key === 'outstanding') {
|
|
3779
4596
|
this[key] = this._Amount.init(update[key])
|
|
3780
4597
|
} else if (key === 'purchaseOptions') {
|
|
3781
4598
|
this[key] = q_utilities_namespaceObject.KeyValueObject.initOnlyValidFromArray(update[key])
|
|
@@ -3786,6 +4603,23 @@ class InvoiceLine extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
3786
4603
|
})
|
|
3787
4604
|
return super.update(update)
|
|
3788
4605
|
}
|
|
4606
|
+
updateOutstanding({ actorCode } = {}) {
|
|
4607
|
+
const paymentItems = this.paymentItems
|
|
4608
|
+
if (paymentItems.length === 0) {
|
|
4609
|
+
return this
|
|
4610
|
+
}
|
|
4611
|
+
const paid = paymentItems.reduce((acc, pi) => acc + (pi?.amount?.value || 0), 0)
|
|
4612
|
+
const value = this.amount.value - paid
|
|
4613
|
+
if (value <= 0) {
|
|
4614
|
+
this.setCompleted(Date.now(), actorCode)
|
|
4615
|
+
}
|
|
4616
|
+
return this.update({
|
|
4617
|
+
outstanding: {
|
|
4618
|
+
currencyCode: this.amount.currencyCode,
|
|
4619
|
+
value
|
|
4620
|
+
}
|
|
4621
|
+
})
|
|
4622
|
+
}
|
|
3789
4623
|
}
|
|
3790
4624
|
|
|
3791
4625
|
function invoiceLine_setCode(options, key) {
|
|
@@ -3805,36 +4639,12 @@ function invoiceLine_setId(id) {
|
|
|
3805
4639
|
|
|
3806
4640
|
|
|
3807
4641
|
|
|
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
4642
|
;// ./lib/models/invoiceLine/index.js
|
|
3830
4643
|
|
|
3831
4644
|
|
|
3832
4645
|
|
|
3833
4646
|
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
4647
|
;// ./lib/models/issuer/issuer.js
|
|
3837
|
-
|
|
3838
4648
|
class Issuer {
|
|
3839
4649
|
constructor(options = {}) {
|
|
3840
4650
|
options = options || {}
|
|
@@ -3896,6 +4706,7 @@ class Issuer {
|
|
|
3896
4706
|
|
|
3897
4707
|
|
|
3898
4708
|
|
|
4709
|
+
|
|
3899
4710
|
// import { Transaction } from '../transaction/index.js'
|
|
3900
4711
|
|
|
3901
4712
|
const walletItem_updateAllowedProps = [
|
|
@@ -3909,7 +4720,8 @@ class WalletItem extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
3909
4720
|
options = options || {}
|
|
3910
4721
|
super(options)
|
|
3911
4722
|
|
|
3912
|
-
const { _Product, _Status } = options._constructor || {}
|
|
4723
|
+
const { _Amount, _Product, _Status } = options._constructor || {}
|
|
4724
|
+
this._Amount = _Amount && (_Amount._superclass === Amount._superclass) ? _Amount : Amount
|
|
3913
4725
|
this._Product = _Product && (_Product._superclass === Product._superclass) ? _Product : Product
|
|
3914
4726
|
this._Status = _Status && (_Status._superclass === Status._superclass) ? _Status : Status
|
|
3915
4727
|
// this._Transaction = _Transaction && (_Transaction._superclass === Transaction._superclass) ? _Transaction : Transaction
|
|
@@ -4039,18 +4851,30 @@ class WalletItem extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
4039
4851
|
get displayPurchaseOptions() {
|
|
4040
4852
|
return this.purchaseOptions.length > 0
|
|
4041
4853
|
? this.purchaseOptions.reduce((acc, purchaseOption) => {
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
|
|
4854
|
+
const { value } = purchaseOption
|
|
4855
|
+
return acc += value.reduce((_acc, item) => {
|
|
4856
|
+
const { label, value } = item
|
|
4857
|
+
return _acc += `<div><span>${label}: </span><span>${value}</span></div>`
|
|
4858
|
+
}, '')
|
|
4046
4859
|
}, '')
|
|
4047
|
-
}, '')
|
|
4048
4860
|
: ''
|
|
4049
4861
|
}
|
|
4050
4862
|
|
|
4051
4863
|
get lastRefundRejectedDetail() {
|
|
4052
4864
|
return Array.isArray(this.refundRejectedHistory) && this.refundRejectedHistory.length > 0 ? this.refundRejectedHistory[this.refundRejectedHistory.length - 1] : null
|
|
4053
4865
|
}
|
|
4866
|
+
get paid() {
|
|
4867
|
+
if (!this._transaction) {
|
|
4868
|
+
return null
|
|
4869
|
+
}
|
|
4870
|
+
const { amount, meta } = this._transaction
|
|
4871
|
+
return {
|
|
4872
|
+
created: meta.created,
|
|
4873
|
+
currencyCode: amount.currencyCode,
|
|
4874
|
+
modified: meta.modified,
|
|
4875
|
+
value: amount.value
|
|
4876
|
+
}
|
|
4877
|
+
}
|
|
4054
4878
|
|
|
4055
4879
|
get product() {
|
|
4056
4880
|
return this._Product.init(this._product)
|
|
@@ -4286,33 +5110,11 @@ function walletItem_setCode(options, key) {
|
|
|
4286
5110
|
|
|
4287
5111
|
|
|
4288
5112
|
|
|
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
5113
|
;// ./lib/models/walletItem/index.js
|
|
4311
5114
|
|
|
4312
5115
|
|
|
4313
5116
|
|
|
4314
5117
|
|
|
4315
|
-
|
|
4316
5118
|
;// ./lib/models/transaction/transaction.js
|
|
4317
5119
|
|
|
4318
5120
|
|
|
@@ -4637,34 +5439,11 @@ function transaction_setId(id) {
|
|
|
4637
5439
|
|
|
4638
5440
|
|
|
4639
5441
|
|
|
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
5442
|
;// ./lib/models/transaction/index.js
|
|
4662
5443
|
|
|
4663
5444
|
|
|
4664
5445
|
|
|
4665
5446
|
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
5447
|
;// ./lib/models/invoice/invoice.js
|
|
4669
5448
|
|
|
4670
5449
|
|
|
@@ -4676,10 +5455,12 @@ class TransactionRepo extends q_utilities_namespaceObject.Repo {
|
|
|
4676
5455
|
|
|
4677
5456
|
|
|
4678
5457
|
const invoice_updateAllowedProps = [
|
|
5458
|
+
'billToUserCode',
|
|
4679
5459
|
'checkoutDateTime',
|
|
4680
5460
|
'description',
|
|
4681
5461
|
'invoiceDate',
|
|
4682
5462
|
'issuer',
|
|
5463
|
+
'outstanding',
|
|
4683
5464
|
'revisionNumber',
|
|
4684
5465
|
'status'
|
|
4685
5466
|
]
|
|
@@ -4687,24 +5468,27 @@ const invoice_updateAllowedProps = [
|
|
|
4687
5468
|
class Invoice extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
4688
5469
|
constructor(options) {
|
|
4689
5470
|
options = options || {}
|
|
4690
|
-
super(options)
|
|
5471
|
+
super(options) // store the 'BUILDTOUSER' into invoice.metadata
|
|
4691
5472
|
|
|
4692
|
-
const { _Amount, _Cart, _InvoiceLine, _Issuer, _Status, _Transaction } = options._constructor || {}
|
|
5473
|
+
const { _Amount, _BillToUser, _Cart, _InvoiceLine, _Issuer, _Status, _Transaction } = options._constructor || {}
|
|
4693
5474
|
this._Amount = _Amount && (_Amount._superclass === Amount._superclass) ? _Amount : Amount
|
|
5475
|
+
this._BillToUser = _BillToUser
|
|
4694
5476
|
this._Cart = _Cart && (_Cart._superclass === Cart._superclass) ? _Cart : Cart
|
|
4695
5477
|
this._InvoiceLine = _InvoiceLine && (_InvoiceLine._superclass === InvoiceLine._superclass) ? _InvoiceLine : InvoiceLine
|
|
4696
5478
|
this._Issuer = _Issuer && (_Issuer._superclass === Issuer._superclass) ? _Issuer : Issuer
|
|
4697
5479
|
this._Status = _Status && (_Status._superclass === Status._superclass) ? _Status : Status
|
|
4698
5480
|
this._Transaction = _Transaction && (_Transaction._superclass === Transaction._superclass) ? _Transaction : Transaction
|
|
4699
5481
|
|
|
5482
|
+
this._billToUser = options._billToUser
|
|
4700
5483
|
this._cart = options._cart
|
|
4701
5484
|
this._invoiceLines = options._invoiceLines
|
|
4702
5485
|
this._transactions = options._transactions
|
|
4703
|
-
|
|
5486
|
+
|
|
4704
5487
|
const id = options._id || options.id
|
|
4705
5488
|
this.id = invoice_setId(id)
|
|
4706
5489
|
this._type = options._type || 'Invoice'
|
|
4707
5490
|
this.amount = this._Amount.init(options.amount)
|
|
5491
|
+
this.billToUserCode = options.billToUserCode // mainly for frontend populate
|
|
4708
5492
|
this.cartCode = options.cartCode
|
|
4709
5493
|
this.checkoutDateTime = options.checkoutDateTime || (new Date()).valueOf()
|
|
4710
5494
|
this.description = options.description
|
|
@@ -4713,6 +5497,7 @@ class Invoice extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
4713
5497
|
this.invoiceNumber = options.invoiceNumber
|
|
4714
5498
|
this.invoiceType = options.invoiceType || 'Invoice'
|
|
4715
5499
|
this.issuer = this._Issuer.init(options.issuer)
|
|
5500
|
+
this.outstanding = this._Amount.init(options.outstanding)
|
|
4716
5501
|
this.revisionNumber = options.revisionNumber || 1
|
|
4717
5502
|
this.status = this._Status.init(options.status)
|
|
4718
5503
|
}
|
|
@@ -4732,6 +5517,9 @@ class Invoice extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
4732
5517
|
get isValid() {
|
|
4733
5518
|
return super.isValid
|
|
4734
5519
|
}
|
|
5520
|
+
get billToUser() {
|
|
5521
|
+
return this._BillToUser && typeof this._BillToUser.init === 'function' ? this._BillToUser.init(this._billToUser) : this._billToUser
|
|
5522
|
+
}
|
|
4735
5523
|
get cart() {
|
|
4736
5524
|
return this._Cart.init(this._cart)
|
|
4737
5525
|
}
|
|
@@ -4823,6 +5611,14 @@ class Invoice extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
4823
5611
|
return this.status.setCancelled()
|
|
4824
5612
|
}
|
|
4825
5613
|
|
|
5614
|
+
setClosed(timestamp, actorCode) {
|
|
5615
|
+
if (typeof this.status.setClosed !== 'function') {
|
|
5616
|
+
return this
|
|
5617
|
+
}
|
|
5618
|
+
this.status.setClosed(timestamp, actorCode)
|
|
5619
|
+
return this.setModified()
|
|
5620
|
+
}
|
|
5621
|
+
|
|
4826
5622
|
setCheckoutDateTime(timestamp) {
|
|
4827
5623
|
if (typeof timestamp === 'number') {
|
|
4828
5624
|
this.checkoutDateTime = timestamp
|
|
@@ -4833,196 +5629,75 @@ class Invoice extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
4833
5629
|
this.status.setCompleted()
|
|
4834
5630
|
return this.setModified()
|
|
4835
5631
|
}
|
|
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()
|
|
5632
|
+
|
|
5633
|
+
setWaived() {
|
|
5634
|
+
this.status.setWaived()
|
|
5635
|
+
return this.setModified()
|
|
4998
5636
|
}
|
|
4999
|
-
|
|
5000
|
-
|
|
5637
|
+
|
|
5638
|
+
update(update) {
|
|
5639
|
+
Object.keys(update).forEach((key) => {
|
|
5640
|
+
if (invoice_updateAllowedProps.includes(key)) {
|
|
5641
|
+
if (key === 'amount' || key === 'outstanding') {
|
|
5642
|
+
this[key] = this._Amount.init(update[key])
|
|
5643
|
+
} else if (key === 'issuer') {
|
|
5644
|
+
this[key] = this._Issuer.init(update[key])
|
|
5645
|
+
} else if (key === 'status') {
|
|
5646
|
+
this[key] = this._Status.init(update[key])
|
|
5647
|
+
} else {
|
|
5648
|
+
this[key] = update[key]
|
|
5649
|
+
}
|
|
5650
|
+
}
|
|
5651
|
+
})
|
|
5652
|
+
return super.update(update)
|
|
5001
5653
|
}
|
|
5002
|
-
|
|
5003
|
-
|
|
5654
|
+
|
|
5655
|
+
updateOutstanding({ actorCode } = {}) {
|
|
5656
|
+
const invoiceLines = this.invoiceLines
|
|
5657
|
+
if (invoiceLines.length === 0) {
|
|
5658
|
+
return this
|
|
5659
|
+
}
|
|
5660
|
+
const value = invoiceLines.reduce((acc, il) => {
|
|
5661
|
+
il.updateOutstanding({ actorCode })
|
|
5662
|
+
return acc + il?.outstanding?.value
|
|
5663
|
+
}, 0)
|
|
5664
|
+
if (value <= 0) {
|
|
5665
|
+
this.setClosed(Date.now(), actorCode)
|
|
5666
|
+
}
|
|
5667
|
+
this._invoiceLines = invoiceLines
|
|
5668
|
+
return this.update({
|
|
5669
|
+
outstanding: {
|
|
5670
|
+
currencyCode: this.getCurrencyCode(),
|
|
5671
|
+
value
|
|
5672
|
+
}
|
|
5673
|
+
})
|
|
5004
5674
|
}
|
|
5005
|
-
|
|
5006
|
-
|
|
5675
|
+
}
|
|
5676
|
+
|
|
5677
|
+
function invoice_setCode(options, key) {
|
|
5678
|
+
const copyOptions = options || {}
|
|
5679
|
+
if (copyOptions[key]) {
|
|
5680
|
+
return copyOptions[key]
|
|
5007
5681
|
}
|
|
5008
|
-
|
|
5009
|
-
|
|
5682
|
+
return stringHelper.setCode()
|
|
5683
|
+
}
|
|
5684
|
+
|
|
5685
|
+
function invoice_setId(id) {
|
|
5686
|
+
if (id && typeof id.toString === 'function') {
|
|
5687
|
+
return id.toString()
|
|
5010
5688
|
}
|
|
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
|
-
// }
|
|
5689
|
+
return id
|
|
5019
5690
|
}
|
|
5020
5691
|
|
|
5021
|
-
|
|
5692
|
+
|
|
5693
|
+
|
|
5694
|
+
;// ./lib/models/invoice/index.js
|
|
5022
5695
|
|
|
5023
5696
|
|
|
5024
5697
|
|
|
5025
5698
|
|
|
5699
|
+
;// ./lib/models/keyValueObject/index.js
|
|
5700
|
+
|
|
5026
5701
|
|
|
5027
5702
|
;// ./lib/models/orderLine/orderLine.js
|
|
5028
5703
|
|
|
@@ -5132,6 +5807,7 @@ class OrderLine extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
5132
5807
|
unitPrice: this.unitPrice,
|
|
5133
5808
|
deduction: this.deduction,
|
|
5134
5809
|
discount: this.discount,
|
|
5810
|
+
outstanding: this.amount,
|
|
5135
5811
|
qty: this.qty,
|
|
5136
5812
|
merchandiseCode: this.merchandiseCode,
|
|
5137
5813
|
metadata: this.metadata,
|
|
@@ -5148,6 +5824,14 @@ class OrderLine extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
5148
5824
|
return this.amount
|
|
5149
5825
|
}
|
|
5150
5826
|
|
|
5827
|
+
getPreservedData() {
|
|
5828
|
+
return {
|
|
5829
|
+
orderCode: this.orderCode,
|
|
5830
|
+
orderLineCode: this.orderLineCode,
|
|
5831
|
+
orderLineType: this.orderLineType,
|
|
5832
|
+
}
|
|
5833
|
+
}
|
|
5834
|
+
|
|
5151
5835
|
toCaculateAmountItem() {
|
|
5152
5836
|
return {
|
|
5153
5837
|
merchandiseCode: this.merchandiseCode,
|
|
@@ -5411,133 +6095,6 @@ function order_setId(id) {
|
|
|
5411
6095
|
|
|
5412
6096
|
|
|
5413
6097
|
|
|
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
6098
|
;// ./lib/models/paymentResult/paymentResult.js
|
|
5542
6099
|
|
|
5543
6100
|
|
|
@@ -5713,40 +6270,16 @@ function paymentResult_setId(id) {
|
|
|
5713
6270
|
|
|
5714
6271
|
|
|
5715
6272
|
|
|
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
6273
|
;// ./lib/models/paymentResult/index.js
|
|
5738
6274
|
|
|
5739
6275
|
|
|
5740
6276
|
|
|
5741
6277
|
|
|
5742
|
-
|
|
5743
|
-
|
|
5744
6278
|
;// ./lib/models/status/index.js
|
|
5745
6279
|
|
|
5746
6280
|
|
|
5747
6281
|
|
|
5748
6282
|
|
|
5749
|
-
|
|
5750
6283
|
;// ./lib/models/storeItem/storeItem.js
|
|
5751
6284
|
|
|
5752
6285
|
|
|
@@ -5907,7 +6440,7 @@ class StoreItem {
|
|
|
5907
6440
|
if (storeItem_updateAllowedProps.includes(key)) {
|
|
5908
6441
|
if (key === 'metadata') {
|
|
5909
6442
|
this[key] = q_utilities_namespaceObject.Metadata.initOnlyValidFromArray(update[key])
|
|
5910
|
-
} else
|
|
6443
|
+
} else if (key === 'productOptions') {
|
|
5911
6444
|
this[key] = this._ItemOption.initOnlyValidFromArray(update[key])
|
|
5912
6445
|
} else if (key === 'remarks') {
|
|
5913
6446
|
this[key] = q_utilities_namespaceObject.KeyValueObject.initOnlyValidFromArray(update[key])
|
|
@@ -5972,8 +6505,13 @@ function storeItem_getDataByKey(key, data) {
|
|
|
5972
6505
|
|
|
5973
6506
|
|
|
5974
6507
|
|
|
5975
|
-
;// ./lib/helpers/corHelper/chain.js
|
|
5976
6508
|
|
|
6509
|
+
|
|
6510
|
+
|
|
6511
|
+
|
|
6512
|
+
|
|
6513
|
+
|
|
6514
|
+
;// ./lib/helpers/corHelper/chain.js
|
|
5977
6515
|
class Chain {
|
|
5978
6516
|
constructor(options = {}) {
|
|
5979
6517
|
options = options || {}
|
|
@@ -6093,7 +6631,7 @@ function calculateByCoupon({ coupon, price, currencyCode }) {
|
|
|
6093
6631
|
}
|
|
6094
6632
|
const { type, item } = couponDetails
|
|
6095
6633
|
if (item) {
|
|
6096
|
-
switch(type) {
|
|
6634
|
+
switch (type) {
|
|
6097
6635
|
case ('Deduction'): {
|
|
6098
6636
|
return _caculateByDeduction({ price, couponDetails, currencyCode })
|
|
6099
6637
|
}
|
|
@@ -6118,7 +6656,6 @@ function _caculateByPercentage({ price, couponDetails }) {
|
|
|
6118
6656
|
|
|
6119
6657
|
|
|
6120
6658
|
|
|
6121
|
-
|
|
6122
6659
|
;// ./lib/helpers/calculateByCoupon/index.js
|
|
6123
6660
|
|
|
6124
6661
|
|
|
@@ -6165,7 +6702,12 @@ class ChainCategoryLimit extends Chain {
|
|
|
6165
6702
|
function groupCategory(categories = [], walletItems = []) {
|
|
6166
6703
|
return categories.reduce((acc, category) => {
|
|
6167
6704
|
const {
|
|
6168
|
-
categoryCode,
|
|
6705
|
+
categoryCode,
|
|
6706
|
+
codes,
|
|
6707
|
+
name,
|
|
6708
|
+
max,
|
|
6709
|
+
min,
|
|
6710
|
+
productCodes = [],
|
|
6169
6711
|
} = category
|
|
6170
6712
|
const filtered = walletItems.filter((w) => {
|
|
6171
6713
|
if (w.status.cancelled !== null) {
|
|
@@ -6420,7 +6962,7 @@ function getEntitlements(entitlements, productCodes, qty) {
|
|
|
6420
6962
|
if (entitlements.length === 0) {
|
|
6421
6963
|
return { waived: 0, entitlementsRemarkValue: [] }
|
|
6422
6964
|
}
|
|
6423
|
-
const groupedProductCodes = Array.from(
|
|
6965
|
+
const groupedProductCodes = Array.from({ length: qty }).map(() => [...productCodes])
|
|
6424
6966
|
// const copyEntitlements = JSON.parse(JSON.stringify(entitlements))
|
|
6425
6967
|
const { waived, entitlementsRemarkValue } = groupedProductCodes.reduce((acc, arr) => {
|
|
6426
6968
|
if (acc.continue === false) {
|
|
@@ -6479,7 +7021,6 @@ function getStrategiesByRestrictions(prices, line, user) {
|
|
|
6479
7021
|
return priceStrategies
|
|
6480
7022
|
}
|
|
6481
7023
|
|
|
6482
|
-
|
|
6483
7024
|
// function useCoupons(lines, currencyCode) {
|
|
6484
7025
|
// lines.forEach((line) => {
|
|
6485
7026
|
|
|
@@ -6503,7 +7044,7 @@ class ChainGetPriceForGroup extends Chain {
|
|
|
6503
7044
|
|
|
6504
7045
|
async handleRequest(chainTarget) {
|
|
6505
7046
|
try {
|
|
6506
|
-
const { lines
|
|
7047
|
+
const { lines } = chainTarget
|
|
6507
7048
|
const entitlements = external_lodash_namespaceObject["default"].cloneDeep(this.entitlements)
|
|
6508
7049
|
|
|
6509
7050
|
lines.forEach((line) => {
|
|
@@ -6556,10 +7097,10 @@ function ChainGetPriceForGroup_cutEntitlements(lines, entitlements = [], currenc
|
|
|
6556
7097
|
const subTotal = Amount.init({ value, currencyCode })
|
|
6557
7098
|
const discountValue = (price.value * restQty) - subTotal.value + (price.value * waived)
|
|
6558
7099
|
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)
|
|
7100
|
+
let remarks = q_utilities_namespaceObject.KeyValueObject.initOnlyValidFromArray([...(updatedItem.remarks || [])])
|
|
7101
|
+
remarks = q_utilities_namespaceObject.KeyValueObject.updateOrInsertRecord(remarks, 'entitlements', entitlementsRemarkValue)
|
|
7102
|
+
let metadata = q_utilities_namespaceObject.Metadata.initOnlyValidFromArray([...(updatedItem.metadata || [])])
|
|
7103
|
+
metadata = q_utilities_namespaceObject.Metadata.updateOrInsertRecord(metadata, 'entitlements', entitlementsRemarkValue)
|
|
6563
7104
|
const obj = {
|
|
6564
7105
|
merchandiseCode,
|
|
6565
7106
|
price,
|
|
@@ -6638,7 +7179,7 @@ function ChainGetPriceForGroup_getEntitlements(entitlements, productCodes, qty)
|
|
|
6638
7179
|
if (entitlements.length === 0) {
|
|
6639
7180
|
return { waived: 0, entitlementsRemarkValue: [] }
|
|
6640
7181
|
}
|
|
6641
|
-
const groupedProductCodes = Array.from(
|
|
7182
|
+
const groupedProductCodes = Array.from({ length: qty }).map(() => [...productCodes])
|
|
6642
7183
|
// const copyEntitlements = JSON.parse(JSON.stringify(entitlements))
|
|
6643
7184
|
const { waived, entitlementsRemarkValue } = groupedProductCodes.reduce((acc, arr) => {
|
|
6644
7185
|
if (acc.continue === false) {
|
|
@@ -6809,7 +7350,7 @@ function _calculate({ line, currency }) {
|
|
|
6809
7350
|
|
|
6810
7351
|
function _findPriceAdjustmentValue(dataArray) {
|
|
6811
7352
|
for (const obj of dataArray) {
|
|
6812
|
-
const priceAdjustment = obj.value?.find(item => item.key === 'priceAdjustment')
|
|
7353
|
+
const priceAdjustment = obj.value?.find((item) => item.key === 'priceAdjustment')
|
|
6813
7354
|
if (priceAdjustment) {
|
|
6814
7355
|
return Number(priceAdjustment.value)
|
|
6815
7356
|
}
|
|
@@ -6819,7 +7360,6 @@ function _findPriceAdjustmentValue(dataArray) {
|
|
|
6819
7360
|
|
|
6820
7361
|
|
|
6821
7362
|
|
|
6822
|
-
|
|
6823
7363
|
;// ./lib/eventManager/chains/chainProductLimit.js
|
|
6824
7364
|
|
|
6825
7365
|
|
|
@@ -7037,7 +7577,7 @@ class ChainRelatedCoupons extends Chain {
|
|
|
7037
7577
|
})
|
|
7038
7578
|
// for total ptice coupon
|
|
7039
7579
|
_calculateAmountByTotalCoupons({ lines, currencyCode: this.currency.code, relatedTotalCoupons })
|
|
7040
|
-
_autoUsedTotalCoupons({ lines, autoUseCoupon: this.autoUseCoupon, currencyCode: this.currency.code, relatedTotalCoupons})
|
|
7580
|
+
_autoUsedTotalCoupons({ lines, autoUseCoupon: this.autoUseCoupon, currencyCode: this.currency.code, relatedTotalCoupons })
|
|
7041
7581
|
await this.next(chainTarget)
|
|
7042
7582
|
} catch (err) {
|
|
7043
7583
|
chainTarget.addException('handle related coupons fail', err.message)
|
|
@@ -7046,17 +7586,15 @@ class ChainRelatedCoupons extends Chain {
|
|
|
7046
7586
|
}
|
|
7047
7587
|
}
|
|
7048
7588
|
|
|
7049
|
-
|
|
7050
7589
|
function _autoUsedTotalCoupons({ lines, autoUseCoupon, currencyCode, relatedTotalCoupons }) {
|
|
7051
7590
|
if (autoUseCoupon) {
|
|
7052
|
-
|
|
7053
|
-
|
|
7054
|
-
|
|
7055
|
-
|
|
7591
|
+
relatedTotalCoupons.forEach((item) => {
|
|
7592
|
+
const obj = _autoUsedTotalCoupon(item, lines, currencyCode)
|
|
7593
|
+
Object.assign(item, obj)
|
|
7594
|
+
})
|
|
7056
7595
|
}
|
|
7057
7596
|
}
|
|
7058
7597
|
|
|
7059
|
-
|
|
7060
7598
|
function _autoUsedTotalCoupon(item, lines, currencyCode) {
|
|
7061
7599
|
const { availableCoupons, usedCoupons, product } = item
|
|
7062
7600
|
if (availableCoupons.length > 0) {
|
|
@@ -7097,7 +7635,7 @@ function _calculateAmountByTotalCoupons({ lines, currencyCode, relatedTotalCoupo
|
|
|
7097
7635
|
_calculateAmountByOneTotalCoupon({ lines, currencyCode, coupon })
|
|
7098
7636
|
})
|
|
7099
7637
|
})
|
|
7100
|
-
}
|
|
7638
|
+
}
|
|
7101
7639
|
|
|
7102
7640
|
function _calculateAmountByOneTotalCoupon({ lines, currencyCode, coupon }) {
|
|
7103
7641
|
const availableLines = lines.filter((line) => (coupon.isApplicableCoupon(line.merchandise)))
|
|
@@ -7110,7 +7648,7 @@ function _calculateAmountByOneTotalCoupon({ lines, currencyCode, coupon }) {
|
|
|
7110
7648
|
if (couponDetails) {
|
|
7111
7649
|
const { type, total } = couponDetails
|
|
7112
7650
|
const { value } = couponDetails
|
|
7113
|
-
switch(type) {
|
|
7651
|
+
switch (type) {
|
|
7114
7652
|
case ('Deduction'): {
|
|
7115
7653
|
const _discount = q_utilities_namespaceObject.KeyValueObject.foundValueByKey(value, currencyCode)
|
|
7116
7654
|
availableLines.forEach((line) => {
|
|
@@ -7122,7 +7660,7 @@ function _calculateAmountByOneTotalCoupon({ lines, currencyCode, coupon }) {
|
|
|
7122
7660
|
_usedCoupons.push(walletItemCode)
|
|
7123
7661
|
const obj = {
|
|
7124
7662
|
discount: Amount.init({ value: discountValue, currencyCode }),
|
|
7125
|
-
remarks: q_utilities_namespaceObject.KeyValueObject.insertOrUpdateRecord(remarks, 'USED_TOTAL_COUPONS', _usedCoupons
|
|
7663
|
+
remarks: q_utilities_namespaceObject.KeyValueObject.insertOrUpdateRecord(remarks, 'USED_TOTAL_COUPONS', _usedCoupons),
|
|
7126
7664
|
subTotal: Amount.init({ value: subTotalValue, currencyCode })
|
|
7127
7665
|
}
|
|
7128
7666
|
Object.assign(updatedItem, obj)
|
|
@@ -7140,7 +7678,7 @@ function _calculateAmountByOneTotalCoupon({ lines, currencyCode, coupon }) {
|
|
|
7140
7678
|
_usedCoupons.push(walletItemCode)
|
|
7141
7679
|
const obj = {
|
|
7142
7680
|
discount: Amount.init({ value: discountValue, currencyCode }),
|
|
7143
|
-
remarks: q_utilities_namespaceObject.KeyValueObject.insertOrUpdateRecord(remarks, 'USED_TOTAL_COUPONS', _usedCoupons
|
|
7681
|
+
remarks: q_utilities_namespaceObject.KeyValueObject.insertOrUpdateRecord(remarks, 'USED_TOTAL_COUPONS', _usedCoupons),
|
|
7144
7682
|
subTotal: Amount.init({ value: subTotalValue, currencyCode })
|
|
7145
7683
|
}
|
|
7146
7684
|
Object.assign(updatedItem, obj)
|
|
@@ -7148,11 +7686,10 @@ function _calculateAmountByOneTotalCoupon({ lines, currencyCode, coupon }) {
|
|
|
7148
7686
|
break
|
|
7149
7687
|
}
|
|
7150
7688
|
default: {
|
|
7151
|
-
|
|
7689
|
+
|
|
7152
7690
|
}
|
|
7153
7691
|
}
|
|
7154
7692
|
}
|
|
7155
|
-
|
|
7156
7693
|
}
|
|
7157
7694
|
|
|
7158
7695
|
function _calculateAmountByOneItemCoupon({ updatedItem, coupon, currencyCode }) {
|
|
@@ -7169,12 +7706,11 @@ function _calculateAmountByOneItemCoupon({ updatedItem, coupon, currencyCode })
|
|
|
7169
7706
|
return {
|
|
7170
7707
|
...updatedItem,
|
|
7171
7708
|
discount: Amount.init({ value: discountValue, currencyCode }),
|
|
7172
|
-
remarks: q_utilities_namespaceObject.KeyValueObject.insertOrUpdateRecord(remarks, 'USED_ITEM_COUPONS', _usedCoupons
|
|
7709
|
+
remarks: q_utilities_namespaceObject.KeyValueObject.insertOrUpdateRecord(remarks, 'USED_ITEM_COUPONS', _usedCoupons),
|
|
7173
7710
|
subTotal: Amount.init({ value: subTotalValue, currencyCode })
|
|
7174
7711
|
}
|
|
7175
7712
|
}
|
|
7176
7713
|
|
|
7177
|
-
|
|
7178
7714
|
function _getAvailableItemCoupons(line) {
|
|
7179
7715
|
const { relatedCoupons = [] } = line
|
|
7180
7716
|
line.relatedCoupons = relatedCoupons.map((c) => ({
|
|
@@ -7186,7 +7722,7 @@ function _getAvailableItemCoupons(line) {
|
|
|
7186
7722
|
function _getRelatedItemCoupons(cartItemLine, couponWalletItems, autoUseCoupon, currencyCode) {
|
|
7187
7723
|
const { merchandise, usedCoupons = {}, updatedItem = {} } = cartItemLine
|
|
7188
7724
|
const relatedWalletItems = couponWalletItems.filter(
|
|
7189
|
-
item => item.isApplicableCoupon(merchandise) && item.isItemCoupon
|
|
7725
|
+
(item) => item.isApplicableCoupon(merchandise) && item.isItemCoupon
|
|
7190
7726
|
)
|
|
7191
7727
|
// .sort((a, b) => (
|
|
7192
7728
|
// b.couponDetails.value - a.couponDetails.value
|
|
@@ -7199,7 +7735,7 @@ function _getRelatedItemCoupons(cartItemLine, couponWalletItems, autoUseCoupon,
|
|
|
7199
7735
|
exist = {
|
|
7200
7736
|
coupons: [],
|
|
7201
7737
|
product: w.product,
|
|
7202
|
-
productCode
|
|
7738
|
+
productCode,
|
|
7203
7739
|
usedQty: (usedCoupons[productCode] || []).length
|
|
7204
7740
|
}
|
|
7205
7741
|
acc.push(exist)
|
|
@@ -7221,7 +7757,6 @@ function _getRelatedItemCoupons(cartItemLine, couponWalletItems, autoUseCoupon,
|
|
|
7221
7757
|
}, [])
|
|
7222
7758
|
}
|
|
7223
7759
|
|
|
7224
|
-
|
|
7225
7760
|
function _updateRelatedItemCoupons(line, couponWalletItems, autoUseCoupon, currencyCode) {
|
|
7226
7761
|
if (couponWalletItems.length > 0) {
|
|
7227
7762
|
line.relatedCoupons = _getRelatedItemCoupons(line, couponWalletItems, autoUseCoupon, currencyCode)
|
|
@@ -7230,9 +7765,6 @@ function _updateRelatedItemCoupons(line, couponWalletItems, autoUseCoupon, curre
|
|
|
7230
7765
|
|
|
7231
7766
|
|
|
7232
7767
|
|
|
7233
|
-
|
|
7234
|
-
|
|
7235
|
-
|
|
7236
7768
|
;// ./lib/eventManager/chains/index.js
|
|
7237
7769
|
|
|
7238
7770
|
|
|
@@ -7248,7 +7780,6 @@ function _updateRelatedItemCoupons(line, couponWalletItems, autoUseCoupon, curre
|
|
|
7248
7780
|
|
|
7249
7781
|
|
|
7250
7782
|
;// ./lib/helpers/corHelper/chainException.js
|
|
7251
|
-
|
|
7252
7783
|
class ChainException {
|
|
7253
7784
|
constructor() {
|
|
7254
7785
|
this.result = {}
|
|
@@ -7377,7 +7908,6 @@ class ChainTargetCalculateAmount extends ChainTarget {
|
|
|
7377
7908
|
|
|
7378
7909
|
;// ./lib/helpers/corHelper/chainManager.js
|
|
7379
7910
|
|
|
7380
|
-
|
|
7381
7911
|
// import { ChainResult } from './chainResult.js'
|
|
7382
7912
|
// import { makeChainsFactory } from './helpers.js'
|
|
7383
7913
|
|
|
@@ -7534,7 +8064,10 @@ function _calculateAmountChainsFactory(payload) {
|
|
|
7534
8064
|
new ChainMerchandiseLimit(),
|
|
7535
8065
|
new ChainProductLimit({ products }),
|
|
7536
8066
|
new ChainGetPrice({
|
|
7537
|
-
currency,
|
|
8067
|
+
currency,
|
|
8068
|
+
dateTime,
|
|
8069
|
+
entitlements,
|
|
8070
|
+
merchandises
|
|
7538
8071
|
}),
|
|
7539
8072
|
new ChainRelatedCoupons({ currency, autoUseCoupon, walletItems }),
|
|
7540
8073
|
new ChainPriceAdjustment({ currency }),
|
|
@@ -7554,7 +8087,10 @@ function _calculateAmountChainsFactoryforGroup(payload) {
|
|
|
7554
8087
|
new ChainMerchandiseLimit(),
|
|
7555
8088
|
new ChainProductLimit({ products }),
|
|
7556
8089
|
new ChainGetPriceForGroup({
|
|
7557
|
-
currency,
|
|
8090
|
+
currency,
|
|
8091
|
+
dateTime,
|
|
8092
|
+
entitlements,
|
|
8093
|
+
merchandises
|
|
7558
8094
|
}),
|
|
7559
8095
|
]
|
|
7560
8096
|
}
|
|
@@ -7697,9 +8233,9 @@ function getRolesChangesRelatedCouponsHelper({ newRoles, originalRoles }) {
|
|
|
7697
8233
|
...Object.keys(couponFromOriginalRoles)
|
|
7698
8234
|
])
|
|
7699
8235
|
return Array.from(allKeys).reduce((acc, key) => {
|
|
7700
|
-
const newValue = couponFromNewRoles[key] || 0
|
|
7701
|
-
const originalValue = couponFromOriginalRoles[key] || 0
|
|
7702
|
-
const delta = newValue - originalValue
|
|
8236
|
+
const newValue = couponFromNewRoles[key] || 0
|
|
8237
|
+
const originalValue = couponFromOriginalRoles[key] || 0
|
|
8238
|
+
const delta = newValue - originalValue
|
|
7703
8239
|
if (delta !== 0) {
|
|
7704
8240
|
acc.push({
|
|
7705
8241
|
key,
|
|
@@ -7708,13 +8244,12 @@ function getRolesChangesRelatedCouponsHelper({ newRoles, originalRoles }) {
|
|
|
7708
8244
|
newValue,
|
|
7709
8245
|
originalValue
|
|
7710
8246
|
}
|
|
7711
|
-
})
|
|
8247
|
+
})
|
|
7712
8248
|
}
|
|
7713
8249
|
return acc
|
|
7714
8250
|
}, [])
|
|
7715
8251
|
}
|
|
7716
8252
|
|
|
7717
|
-
|
|
7718
8253
|
function _getCouponsByRoles(roles) {
|
|
7719
8254
|
return roles.reduce((acc, role) => {
|
|
7720
8255
|
const couponCodes = role.getCouponCodes()
|
|
@@ -7765,19 +8300,18 @@ class CouponManager {
|
|
|
7765
8300
|
return getRolesChangesRelatedCouponsHelper({ newRoles: this.newRoles, originalRoles: this.originalRoles })
|
|
7766
8301
|
}
|
|
7767
8302
|
|
|
7768
|
-
|
|
7769
8303
|
get couponItemList() {
|
|
7770
8304
|
return this.couponProducts.map((p) => {
|
|
7771
8305
|
const relatedWalletItems = this.walletItems.filter(
|
|
7772
|
-
item => item.productCode === p.productCode
|
|
8306
|
+
(item) => item.productCode === p.productCode
|
|
7773
8307
|
)
|
|
7774
8308
|
|
|
7775
|
-
const usedCoupons = relatedWalletItems.filter(item => item.isUsed)
|
|
8309
|
+
const usedCoupons = relatedWalletItems.filter((item) => item.isUsed)
|
|
7776
8310
|
usedCoupons.forEach((c) => {
|
|
7777
8311
|
c.useForWalletItems = this.walletItems.filter((item) => (c.useFor || []).includes(item.walletItemCode)) // useFor
|
|
7778
8312
|
})
|
|
7779
8313
|
|
|
7780
|
-
const availableCoupons = relatedWalletItems.filter(item => !item.isAvailableCoupon)
|
|
8314
|
+
const availableCoupons = relatedWalletItems.filter((item) => !item.isAvailableCoupon)
|
|
7781
8315
|
|
|
7782
8316
|
const roleBase = q_utilities_namespaceObject.KeyValueObject.foundValueByKey(this.roleRelatedCoupons, p.productCode) || {}
|
|
7783
8317
|
|
|
@@ -7795,19 +8329,17 @@ class CouponManager {
|
|
|
7795
8329
|
qty,
|
|
7796
8330
|
roleBase,
|
|
7797
8331
|
remarks
|
|
7798
|
-
}
|
|
8332
|
+
}
|
|
7799
8333
|
})
|
|
7800
8334
|
}
|
|
7801
8335
|
|
|
7802
8336
|
setNewRoles() {
|
|
7803
8337
|
this.newRoles = newRoles
|
|
7804
8338
|
}
|
|
7805
|
-
|
|
7806
8339
|
}
|
|
7807
8340
|
|
|
7808
8341
|
|
|
7809
8342
|
|
|
7810
|
-
|
|
7811
8343
|
function _handler({ product, remainingQuota, availableCoupons, roleBase }) {
|
|
7812
8344
|
const { delta = 0 } = roleBase
|
|
7813
8345
|
const { maxPerWallet } = product
|
|
@@ -7848,7 +8380,7 @@ class Handler {
|
|
|
7848
8380
|
|
|
7849
8381
|
|
|
7850
8382
|
class HandlerMinutes extends Handler {
|
|
7851
|
-
process(dateFormat) {
|
|
8383
|
+
process(dateFormat) {
|
|
7852
8384
|
const mthIdx = this.date.getMinutes()
|
|
7853
8385
|
dateFormat = dateFormat.replace('mm', zeroPadding(mthIdx)) // 23-03-10 17:mm
|
|
7854
8386
|
return dateFormat
|
|
@@ -7857,7 +8389,7 @@ class HandlerMinutes extends Handler {
|
|
|
7857
8389
|
|
|
7858
8390
|
function zeroPadding(num) {
|
|
7859
8391
|
if (typeof num !== 'number') {
|
|
7860
|
-
throw new
|
|
8392
|
+
throw new TypeError('Parameter must be of number')
|
|
7861
8393
|
}
|
|
7862
8394
|
return num < 10 ? `0${num}` : `${num}`
|
|
7863
8395
|
}
|
|
@@ -7868,7 +8400,7 @@ function zeroPadding(num) {
|
|
|
7868
8400
|
|
|
7869
8401
|
|
|
7870
8402
|
class HandlerHours extends Handler {
|
|
7871
|
-
process(dateFormat) {
|
|
8403
|
+
process(dateFormat) {
|
|
7872
8404
|
const hthIdx = this.date.getHours()
|
|
7873
8405
|
dateFormat = dateFormat.replace('HH', handlerHours_zeroPadding(hthIdx)) // 23-03-10 HH
|
|
7874
8406
|
return dateFormat
|
|
@@ -7877,7 +8409,7 @@ class HandlerHours extends Handler {
|
|
|
7877
8409
|
|
|
7878
8410
|
function handlerHours_zeroPadding(num) {
|
|
7879
8411
|
if (typeof num !== 'number') {
|
|
7880
|
-
throw new
|
|
8412
|
+
throw new TypeError('Parameter must be of number')
|
|
7881
8413
|
}
|
|
7882
8414
|
return num < 10 ? `0${num}` : `${num}`
|
|
7883
8415
|
}
|
|
@@ -7888,7 +8420,7 @@ function handlerHours_zeroPadding(num) {
|
|
|
7888
8420
|
|
|
7889
8421
|
|
|
7890
8422
|
class HandlerDate extends Handler {
|
|
7891
|
-
process(dateFormat) {
|
|
8423
|
+
process(dateFormat) {
|
|
7892
8424
|
const dthIdx = this.date.getDate()
|
|
7893
8425
|
dateFormat = dateFormat.replace('dd', handlerDate_zeroPadding(dthIdx)) // 23-03-dd
|
|
7894
8426
|
return dateFormat
|
|
@@ -7897,7 +8429,7 @@ class HandlerDate extends Handler {
|
|
|
7897
8429
|
|
|
7898
8430
|
function handlerDate_zeroPadding(num) {
|
|
7899
8431
|
if (typeof num !== 'number') {
|
|
7900
|
-
throw new
|
|
8432
|
+
throw new TypeError('Parameter must be of number')
|
|
7901
8433
|
}
|
|
7902
8434
|
return num < 10 ? `0${num}` : `${num}`
|
|
7903
8435
|
}
|
|
@@ -7919,7 +8451,7 @@ class HandlerMonth extends Handler {
|
|
|
7919
8451
|
|
|
7920
8452
|
function handlerMonth_zeroPadding(num) {
|
|
7921
8453
|
if (typeof num !== 'number') {
|
|
7922
|
-
throw new
|
|
8454
|
+
throw new TypeError('Parameter must be of number')
|
|
7923
8455
|
}
|
|
7924
8456
|
return num < 10 ? `0${num}` : `${num}`
|
|
7925
8457
|
}
|
|
@@ -7989,7 +8521,6 @@ function convert(date, dateFormat) {
|
|
|
7989
8521
|
|
|
7990
8522
|
|
|
7991
8523
|
|
|
7992
|
-
|
|
7993
8524
|
;// ./lib/helpers/ordersList/orderList.js
|
|
7994
8525
|
|
|
7995
8526
|
|
|
@@ -8056,7 +8587,6 @@ function actionBuilder(row, header, qRow) {
|
|
|
8056
8587
|
onClick: orderList_self.onOrderListAction('waived')
|
|
8057
8588
|
})
|
|
8058
8589
|
}
|
|
8059
|
-
|
|
8060
8590
|
}
|
|
8061
8591
|
actions.push({
|
|
8062
8592
|
css: {
|
|
@@ -8082,11 +8612,13 @@ function qListArr(originMerchandises, originInvoices) {
|
|
|
8082
8612
|
}
|
|
8083
8613
|
return {
|
|
8084
8614
|
...acc,
|
|
8085
|
-
amount: i.amount && i.amount.value
|
|
8086
|
-
|
|
8087
|
-
|
|
8088
|
-
|
|
8089
|
-
|
|
8615
|
+
amount: i.amount && i.amount.value
|
|
8616
|
+
? i.amount
|
|
8617
|
+
: {
|
|
8618
|
+
value: acc.amount.value + l.amount.value * l.qty,
|
|
8619
|
+
currencyCode: l.amount.currencyCode,
|
|
8620
|
+
default: acc.amount.default && l.amount.default
|
|
8621
|
+
},
|
|
8090
8622
|
}
|
|
8091
8623
|
}, {
|
|
8092
8624
|
amount: {
|
|
@@ -8116,7 +8648,8 @@ function qListArr(originMerchandises, originInvoices) {
|
|
|
8116
8648
|
|
|
8117
8649
|
function formatStatus(status) {
|
|
8118
8650
|
let newStatus = ''
|
|
8119
|
-
if (!(status instanceof Status))
|
|
8651
|
+
if (!(status instanceof Status))
|
|
8652
|
+
return newStatus
|
|
8120
8653
|
if (status.isCancelled) {
|
|
8121
8654
|
newStatus = 'cancelled'
|
|
8122
8655
|
return newStatus
|
|
@@ -8155,7 +8688,13 @@ function handlerHeaders(defaultHeaders) {
|
|
|
8155
8688
|
}
|
|
8156
8689
|
|
|
8157
8690
|
function handlerOrderList({
|
|
8158
|
-
component,
|
|
8691
|
+
component,
|
|
8692
|
+
config,
|
|
8693
|
+
merchandises,
|
|
8694
|
+
invoices,
|
|
8695
|
+
defaultHeaders,
|
|
8696
|
+
isAdmin,
|
|
8697
|
+
label = {}
|
|
8159
8698
|
}) {
|
|
8160
8699
|
orderList_self = component
|
|
8161
8700
|
_config = config
|
|
@@ -8179,7 +8718,6 @@ function handlerOrderList({
|
|
|
8179
8718
|
|
|
8180
8719
|
|
|
8181
8720
|
|
|
8182
|
-
|
|
8183
8721
|
;// ./lib/helpers/sortHelper/defaultSort.js
|
|
8184
8722
|
function defaultSort(arr, getKey) {
|
|
8185
8723
|
if (!getKey) {
|
|
@@ -8188,7 +8726,7 @@ function defaultSort(arr, getKey) {
|
|
|
8188
8726
|
let key = null
|
|
8189
8727
|
switch (typeof getKey) {
|
|
8190
8728
|
case 'function':
|
|
8191
|
-
arr.forEach(ele => { key = getKey(ele) })
|
|
8729
|
+
arr.forEach((ele) => { key = getKey(ele) })
|
|
8192
8730
|
if (key.length === 0) {
|
|
8193
8731
|
return arr
|
|
8194
8732
|
}
|
|
@@ -8207,9 +8745,9 @@ function defaultSort(arr, getKey) {
|
|
|
8207
8745
|
|
|
8208
8746
|
;// ./lib/helpers/sortHelper/isAllEqual.js
|
|
8209
8747
|
function isAllEqual({ arr = [], key }) {
|
|
8210
|
-
const [
|
|
8748
|
+
const [firstElem] = arr
|
|
8211
8749
|
const compareValue = firstElem[key]
|
|
8212
|
-
return arr.every(a => a[key] === compareValue)
|
|
8750
|
+
return arr.every((a) => a[key] === compareValue)
|
|
8213
8751
|
}
|
|
8214
8752
|
|
|
8215
8753
|
|
|
@@ -8234,7 +8772,6 @@ function isDescendingOrder({ arr = [], key }) {
|
|
|
8234
8772
|
|
|
8235
8773
|
|
|
8236
8774
|
|
|
8237
|
-
|
|
8238
8775
|
;// ./lib/helpers/index.js
|
|
8239
8776
|
|
|
8240
8777
|
|
|
@@ -8249,6 +8786,7 @@ function isDescendingOrder({ arr = [], key }) {
|
|
|
8249
8786
|
|
|
8250
8787
|
;// ./lib/index.js
|
|
8251
8788
|
|
|
8789
|
+
|
|
8252
8790
|
const models = models_namespaceObject
|
|
8253
8791
|
|
|
8254
8792
|
|
|
@@ -8258,6 +8796,8 @@ const models = models_namespaceObject
|
|
|
8258
8796
|
|
|
8259
8797
|
|
|
8260
8798
|
var __webpack_exports__Amount = __webpack_exports__.J0;
|
|
8799
|
+
var __webpack_exports__BillingAccount = __webpack_exports__.XC;
|
|
8800
|
+
var __webpack_exports__BillingProject = __webpack_exports__.l8;
|
|
8261
8801
|
var __webpack_exports__Cart = __webpack_exports__.Z3;
|
|
8262
8802
|
var __webpack_exports__CartItem = __webpack_exports__.m6;
|
|
8263
8803
|
var __webpack_exports__Category = __webpack_exports__.b7;
|
|
@@ -8278,13 +8818,18 @@ var __webpack_exports__KeyValueObject = __webpack_exports__.Yc;
|
|
|
8278
8818
|
var __webpack_exports__Merchandise = __webpack_exports__.So;
|
|
8279
8819
|
var __webpack_exports__Order = __webpack_exports__.pH;
|
|
8280
8820
|
var __webpack_exports__OrderLine = __webpack_exports__.$x;
|
|
8821
|
+
var __webpack_exports__PaymentCharge = __webpack_exports__.f7;
|
|
8281
8822
|
var __webpack_exports__PaymentGateway = __webpack_exports__.Zg;
|
|
8823
|
+
var __webpack_exports__PaymentItem = __webpack_exports__.MS;
|
|
8282
8824
|
var __webpack_exports__PaymentResult = __webpack_exports__.gp;
|
|
8283
8825
|
var __webpack_exports__Price = __webpack_exports__.gm;
|
|
8284
8826
|
var __webpack_exports__PriceStrategy = __webpack_exports__.X0;
|
|
8285
8827
|
var __webpack_exports__Product = __webpack_exports__.Yt;
|
|
8828
|
+
var __webpack_exports__Receipt = __webpack_exports__.TA;
|
|
8829
|
+
var __webpack_exports__ReceiptLine = __webpack_exports__.Hx;
|
|
8286
8830
|
var __webpack_exports__Status = __webpack_exports__.nW;
|
|
8287
8831
|
var __webpack_exports__StatusQStore = __webpack_exports__.TM;
|
|
8832
|
+
var __webpack_exports__StatusQStoreInvoice = __webpack_exports__.M;
|
|
8288
8833
|
var __webpack_exports__StatusQStoreOrderLine = __webpack_exports__.Dy;
|
|
8289
8834
|
var __webpack_exports__StoreItem = __webpack_exports__.vB;
|
|
8290
8835
|
var __webpack_exports__Transaction = __webpack_exports__.ZX;
|
|
@@ -8310,4 +8855,4 @@ var __webpack_exports__objectComparator = __webpack_exports__.aL;
|
|
|
8310
8855
|
var __webpack_exports__objectOrderInArrayComparator = __webpack_exports__.il;
|
|
8311
8856
|
var __webpack_exports__setQuery = __webpack_exports__.NY;
|
|
8312
8857
|
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 };
|
|
8858
|
+
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 };
|