@questwork/q-store-model 0.1.44 → 0.2.1
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/q-store-model.cjs +2 -2
- package/dist/q-store-model.esm.js +1588 -1162
- package/dist/q-store-model.iife.js +2 -2
- package/dist/q-store-model.umd.js +2 -2
- package/dist/v2/evaluation/acquisition.d.ts +48 -0
- package/dist/v2/evaluation/effectiveRules.d.ts +7 -0
- package/dist/v2/evaluation/index.d.ts +4 -0
- package/dist/v2/evaluation/ruleEvaluators.d.ts +48 -0
- package/dist/v2/evaluation/shared.d.ts +28 -0
- package/dist/v2/index.d.ts +11 -0
- package/dist/v2/internal/StoreContract.d.ts +10 -0
- package/dist/v2/internal/StoreContractValidationError.d.ts +9 -0
- package/dist/v2/internal/StoreEntity.d.ts +12 -0
- package/dist/v2/internal/validation.d.ts +12 -0
- package/dist/v2/models/AcquisitionSnapshot.d.ts +5 -0
- package/dist/v2/models/Category.d.ts +5 -0
- package/dist/v2/models/Currency.d.ts +5 -0
- package/dist/v2/models/EligibilityFact.d.ts +4 -0
- package/dist/v2/models/Merchandise.d.ts +5 -0
- package/dist/v2/models/MerchandiseComponent.d.ts +4 -0
- package/dist/v2/models/PriceEvaluationContext.d.ts +4 -0
- package/dist/v2/models/PriceMatchCriteria.d.ts +4 -0
- package/dist/v2/models/PriceRow.d.ts +4 -0
- package/dist/v2/models/PriceSchedule.d.ts +5 -0
- package/dist/v2/models/PriceScheduleRef.d.ts +4 -0
- package/dist/v2/models/Product.d.ts +5 -0
- package/dist/v2/models/PublishedRule.d.ts +5 -0
- package/dist/v2/models/PublishedRuleRef.d.ts +4 -0
- package/dist/v2/models/RefundPolicy.d.ts +5 -0
- package/dist/v2/models/RefundPolicyRef.d.ts +4 -0
- package/dist/v2/models/RequirementPlan.d.ts +4 -0
- package/dist/v2/models/SalesPeriod.d.ts +5 -0
- package/dist/v2/models/SalesPeriodRef.d.ts +4 -0
- package/dist/v2/models/Variant.d.ts +5 -0
- package/dist/v2/models/VariantRef.d.ts +4 -0
- package/dist/v2/models/WalletItem.d.ts +5 -0
- package/dist/v2/models/index.d.ts +24 -0
- package/dist/v2/models/ruleDetails/EligibilityRuleDetails.d.ts +4 -0
- package/dist/v2/models/ruleDetails/InventoryRuleDetails.d.ts +4 -0
- package/dist/v2/models/ruleDetails/PrerequisiteRuleDetails.d.ts +4 -0
- package/dist/v2/models/ruleDetails/QuantityRuleDetails.d.ts +4 -0
- package/dist/v2/models/ruleDetails/RefundRuleDetails.d.ts +4 -0
- package/dist/v2/models/ruleDetails/RequirementDefinition.d.ts +4 -0
- package/dist/v2/models/ruleDetails/RequirementFieldDefinition.d.ts +4 -0
- package/dist/v2/models/ruleDetails/RequirementRuleDetails.d.ts +4 -0
- package/dist/v2/models/ruleDetails/index.d.ts +1 -0
- package/dist/v2/models/ruleDetails/shared.d.ts +8 -0
- package/dist/v2/q-store-model-v2.cjs +2 -0
- package/dist/v2/q-store-model-v2.esm.js +1855 -0
- package/dist/v2/ruleVocabulary.d.ts +75 -0
- package/package.json +14 -6
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { KeyValueObject as p, Metadata as _, TenantAwareEntity as
|
|
2
|
-
import { KeyValueObject as
|
|
3
|
-
import
|
|
4
|
-
class
|
|
1
|
+
import { KeyValueObject as p, Metadata as _, TenantAwareEntity as v, getValidation as wt, getValueByKeys as It, Status as Kt, convertTimestampToString as Yt, formatDate as _t, Repo as kt } from "@questwork/q-utilities";
|
|
2
|
+
import { KeyValueObject as Cr } from "@questwork/q-utilities";
|
|
3
|
+
import $ from "lodash";
|
|
4
|
+
class h {
|
|
5
5
|
constructor(t = {}) {
|
|
6
6
|
t = t || {}, this.currencyCode = t.currencyCode || t.currency, this.value = t.value, this.default = t.default || 0;
|
|
7
7
|
}
|
|
@@ -31,10 +31,10 @@ class m {
|
|
|
31
31
|
return "Amount";
|
|
32
32
|
}
|
|
33
33
|
static getAmountsByCurrency(t, e) {
|
|
34
|
-
return t.filter((
|
|
34
|
+
return t.filter((i) => i.currencyCode === e);
|
|
35
35
|
}
|
|
36
36
|
static getAmountsByCurrencyCode(t, e) {
|
|
37
|
-
return t.filter((
|
|
37
|
+
return t.filter((i) => i.currencyCode === e);
|
|
38
38
|
}
|
|
39
39
|
// getters
|
|
40
40
|
get isValid() {
|
|
@@ -53,53 +53,53 @@ class m {
|
|
|
53
53
|
}), this;
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
-
function
|
|
57
|
-
return
|
|
56
|
+
function Y(s, t) {
|
|
57
|
+
return Jt(t).map((r) => r.reduce((n, a) => {
|
|
58
58
|
if (n.qty === 0)
|
|
59
59
|
return n;
|
|
60
60
|
let u;
|
|
61
|
-
a.recursing ? u =
|
|
61
|
+
a.recursing ? u = St : u = zt;
|
|
62
62
|
const c = u(a, s);
|
|
63
63
|
return n.value += c.value, n.qty = c.qty, n.priceStrategy = c.priceStrategy, n;
|
|
64
64
|
}, { priceStrategy: null, value: 0, qty: s }));
|
|
65
65
|
}
|
|
66
|
-
function
|
|
66
|
+
function zt(s, t) {
|
|
67
67
|
const e = s;
|
|
68
68
|
if (t < e.min)
|
|
69
69
|
return { value: 0, qty: t };
|
|
70
|
-
const
|
|
70
|
+
const i = s.max === null ? t : Math.min(s.max, t);
|
|
71
71
|
return {
|
|
72
72
|
priceStrategy: e.priceStrategy,
|
|
73
|
-
value:
|
|
73
|
+
value: Rt(s, i),
|
|
74
74
|
qty: s.max === null || s.max >= t ? 0 : t - s.max
|
|
75
75
|
};
|
|
76
76
|
}
|
|
77
|
-
function
|
|
78
|
-
const
|
|
79
|
-
if (t <
|
|
77
|
+
function St(s, t, e = 0, i = 0) {
|
|
78
|
+
const r = s;
|
|
79
|
+
if (t < r.min)
|
|
80
80
|
return { amount: 0, qty: t };
|
|
81
|
-
const n =
|
|
81
|
+
const n = Rt(s, s.min), a = t - s.min;
|
|
82
82
|
return a === 0 || s.max !== null && s.max - a < s.min ? {
|
|
83
|
-
priceStrategy:
|
|
84
|
-
value:
|
|
83
|
+
priceStrategy: r.priceStrategy,
|
|
84
|
+
value: i + i,
|
|
85
85
|
qty: a
|
|
86
|
-
} :
|
|
86
|
+
} : St(s, a, e + s.min, i + n);
|
|
87
87
|
}
|
|
88
|
-
function
|
|
88
|
+
function Rt(s, t) {
|
|
89
89
|
const e = s.value * t * (1 - s.discount) - s.deduction;
|
|
90
90
|
return e < 0 ? 0 : e;
|
|
91
91
|
}
|
|
92
|
-
function
|
|
92
|
+
function Jt(s = []) {
|
|
93
93
|
const t = [], e = [];
|
|
94
|
-
function r
|
|
94
|
+
function i(r) {
|
|
95
95
|
let n, a;
|
|
96
|
-
for (n = 0; n <
|
|
97
|
-
a =
|
|
96
|
+
for (n = 0; n < r.length; n++)
|
|
97
|
+
a = r.splice(n, 1)[0], e.push(a), r.length === 0 && t.push(e.slice()), i(r), r.splice(n, 0, a), e.pop();
|
|
98
98
|
return t;
|
|
99
99
|
}
|
|
100
|
-
return
|
|
100
|
+
return i(s);
|
|
101
101
|
}
|
|
102
|
-
class
|
|
102
|
+
class S {
|
|
103
103
|
constructor(t = {}) {
|
|
104
104
|
t = t || {}, this.options = t;
|
|
105
105
|
}
|
|
@@ -167,25 +167,25 @@ class b {
|
|
|
167
167
|
return this.successor = t, this;
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
|
-
class
|
|
170
|
+
class Vt {
|
|
171
171
|
constructor(t) {
|
|
172
172
|
t = t || {}, this.exitOnErr = t.exitOnErr || !1, this.runAllChains = typeof t.runAllChains < "u" ? !!t.runAllChains : !0, this.chains = t.chains || [], this.chainTarget = t.chainTarget;
|
|
173
173
|
}
|
|
174
174
|
appendChains(t) {
|
|
175
175
|
return t.forEach((e) => {
|
|
176
176
|
e.setChainManager(this);
|
|
177
|
-
const
|
|
178
|
-
|
|
177
|
+
const i = this.chains.length;
|
|
178
|
+
i > 0 && t[i - 1].setSuccessor(e), this.chains.push(e);
|
|
179
179
|
}), this;
|
|
180
180
|
}
|
|
181
181
|
addException(t, e) {
|
|
182
182
|
if (typeof e > "u")
|
|
183
183
|
return this.exceptionHandler.setProp(t), this;
|
|
184
|
-
const
|
|
185
|
-
return Array.isArray(
|
|
184
|
+
const i = this.exceptionHandler.getResult(t);
|
|
185
|
+
return Array.isArray(i) ? this.exceptionHandler.setProp({ [t]: i.concat(e) }) : this.exceptionHandler.setProp({ [t]: Array.isArray(e) ? e : [e] }), this;
|
|
186
186
|
}
|
|
187
187
|
createChains({ chains: t = [] } = {}) {
|
|
188
|
-
if (t.find((e) => !(e instanceof
|
|
188
|
+
if (t.find((e) => !(e instanceof S)))
|
|
189
189
|
throw new Error("every chain must be an instance of Chain");
|
|
190
190
|
return this.appendChains(t);
|
|
191
191
|
}
|
|
@@ -205,7 +205,7 @@ class It {
|
|
|
205
205
|
return this.exceptionHandler.clear(), this.resultHandler.clear(), this;
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
|
-
class
|
|
208
|
+
class Xt {
|
|
209
209
|
constructor() {
|
|
210
210
|
this.result = {};
|
|
211
211
|
}
|
|
@@ -230,15 +230,15 @@ class Gt {
|
|
|
230
230
|
return typeof this.result[t] < "u" && delete this.result[t], this;
|
|
231
231
|
}
|
|
232
232
|
}
|
|
233
|
-
class
|
|
233
|
+
class Dt {
|
|
234
234
|
constructor(t) {
|
|
235
|
-
t = t || {}, this.exceptionHandler = t.exceptionHandler || new
|
|
235
|
+
t = t || {}, this.exceptionHandler = t.exceptionHandler || new Xt();
|
|
236
236
|
}
|
|
237
237
|
addException(t, e) {
|
|
238
238
|
if (typeof e > "u")
|
|
239
239
|
return this.exceptionHandler.setProp(t), this;
|
|
240
|
-
const
|
|
241
|
-
return Array.isArray(
|
|
240
|
+
const i = this.exceptionHandler.getResult(t), r = e instanceof Error ? e.message : e;
|
|
241
|
+
return Array.isArray(i) ? this.exceptionHandler.setProp({ [t]: i.concat(r) }) : this.exceptionHandler.setProp({ [t]: Array.isArray(r) ? r : [r] }), this;
|
|
242
242
|
}
|
|
243
243
|
getException() {
|
|
244
244
|
return this.exceptionHandler.getResult();
|
|
@@ -259,343 +259,351 @@ class wt {
|
|
|
259
259
|
return t !== "exceptionHandler" && typeof this[t] < "u" && delete this[t], this;
|
|
260
260
|
}
|
|
261
261
|
}
|
|
262
|
-
function
|
|
263
|
-
const { couponDetails:
|
|
264
|
-
if (!
|
|
262
|
+
function Et({ coupon: s, price: t, currencyCode: e }) {
|
|
263
|
+
const { couponDetails: i } = s;
|
|
264
|
+
if (!i)
|
|
265
265
|
return 0;
|
|
266
|
-
const { type:
|
|
266
|
+
const { type: r, item: n } = i;
|
|
267
267
|
if (n)
|
|
268
|
-
switch (
|
|
268
|
+
switch (r) {
|
|
269
269
|
case "Deduction":
|
|
270
|
-
return
|
|
270
|
+
return Zt({ price: t, couponDetails: i, currencyCode: e });
|
|
271
271
|
case "Percentage":
|
|
272
|
-
return
|
|
272
|
+
return te({ price: t, couponDetails: i });
|
|
273
273
|
default:
|
|
274
274
|
return 0;
|
|
275
275
|
}
|
|
276
276
|
}
|
|
277
|
-
function
|
|
278
|
-
const { value:
|
|
279
|
-
return p.foundValueByKey(
|
|
277
|
+
function Zt({ price: s, couponDetails: t, currencyCode: e }) {
|
|
278
|
+
const { value: i } = t;
|
|
279
|
+
return p.foundValueByKey(i, e);
|
|
280
280
|
}
|
|
281
|
-
function
|
|
281
|
+
function te({ price: s, couponDetails: t }) {
|
|
282
282
|
const { value: e } = t;
|
|
283
283
|
return s.value * (e / 100);
|
|
284
284
|
}
|
|
285
|
-
class
|
|
285
|
+
class ee extends S {
|
|
286
286
|
constructor(t = {}) {
|
|
287
287
|
super(t), this.groupCategory = t.groupCategory, this.categories = t.categories, this.walletItems = t.walletItems;
|
|
288
288
|
}
|
|
289
289
|
async handleRequest(t) {
|
|
290
290
|
try {
|
|
291
|
-
const { lines: e, users:
|
|
291
|
+
const { lines: e, users: i } = t, r = se(this.categories, this.walletItems);
|
|
292
292
|
e.forEach((n) => {
|
|
293
|
-
|
|
293
|
+
ie(n, r);
|
|
294
294
|
}), await this.next(t);
|
|
295
295
|
} catch (e) {
|
|
296
296
|
t.addException("calculate categories limit fail", e.message), this.exitChain();
|
|
297
297
|
}
|
|
298
298
|
}
|
|
299
299
|
}
|
|
300
|
-
function
|
|
301
|
-
return s.reduce((e,
|
|
300
|
+
function se(s = [], t = []) {
|
|
301
|
+
return s.reduce((e, i) => {
|
|
302
302
|
const {
|
|
303
|
-
categoryCode:
|
|
303
|
+
categoryCode: r,
|
|
304
304
|
codes: n,
|
|
305
305
|
name: a,
|
|
306
306
|
max: u,
|
|
307
307
|
min: c,
|
|
308
|
-
productCodes:
|
|
309
|
-
} =
|
|
308
|
+
productCodes: o = []
|
|
309
|
+
} = i, l = t.filter((d) => ne(d) && o.includes(d.productCode));
|
|
310
310
|
return e.push({
|
|
311
|
-
categoryCode:
|
|
311
|
+
categoryCode: r,
|
|
312
312
|
codes: n,
|
|
313
313
|
max: u,
|
|
314
314
|
min: c,
|
|
315
315
|
name: a,
|
|
316
|
-
owned:
|
|
317
|
-
productCodes:
|
|
316
|
+
owned: l.length,
|
|
317
|
+
productCodes: o,
|
|
318
318
|
used: 0
|
|
319
319
|
}), e;
|
|
320
320
|
}, []);
|
|
321
321
|
}
|
|
322
|
-
function
|
|
323
|
-
const { productsQty: e, updatedItem:
|
|
324
|
-
Object.keys(e).forEach((
|
|
325
|
-
const n = t.find((a) => a.productCodes.includes(
|
|
322
|
+
function ie(s, t) {
|
|
323
|
+
const { productsQty: e, updatedItem: i } = s;
|
|
324
|
+
Object.keys(e).forEach((r) => {
|
|
325
|
+
const n = t.find((a) => a.productCodes.includes(r) && a.codes.includes(i.merchandiseCode));
|
|
326
326
|
if (n) {
|
|
327
327
|
const a = n.max - (n.used + n.owned);
|
|
328
328
|
if (a === 0)
|
|
329
|
-
|
|
329
|
+
i.qty = 0, s.disabled = !0;
|
|
330
330
|
else {
|
|
331
|
-
e[
|
|
332
|
-
const c =
|
|
331
|
+
e[r] * i.qty > a && (i.qty = 0, s.errors.push(`You have exceeded the maximum number of category "${n.name}".`));
|
|
332
|
+
const c = re(i, a, e[r]);
|
|
333
333
|
n.used += c;
|
|
334
334
|
}
|
|
335
335
|
}
|
|
336
336
|
});
|
|
337
337
|
}
|
|
338
|
-
function
|
|
339
|
-
let
|
|
340
|
-
const
|
|
341
|
-
return t -
|
|
338
|
+
function re(s, t, e) {
|
|
339
|
+
let i;
|
|
340
|
+
const r = e * s.qty;
|
|
341
|
+
return t - r >= 0 ? i = r : (s.qty = t, i = t), i;
|
|
342
|
+
}
|
|
343
|
+
function ne(s) {
|
|
344
|
+
if (!s)
|
|
345
|
+
return !1;
|
|
346
|
+
if (typeof s.isInWallet < "u")
|
|
347
|
+
return s.isInWallet;
|
|
348
|
+
const t = s.status || {};
|
|
349
|
+
return !t.cancelled && !t.rejected && !t.refunded && !t.refundRequested;
|
|
342
350
|
}
|
|
343
|
-
class
|
|
351
|
+
class ae extends S {
|
|
344
352
|
constructor(t = {}) {
|
|
345
353
|
super(t), this.currency = t.currency, this.dateTime = t.dateTime, this.entitlements = t.entitlements || [], this.merchandises = t.merchandises;
|
|
346
354
|
}
|
|
347
355
|
async handleRequest(t) {
|
|
348
356
|
try {
|
|
349
|
-
const { lines: e, user: r } = t,
|
|
350
|
-
e.forEach((
|
|
351
|
-
const
|
|
352
|
-
Object.assign(
|
|
353
|
-
}),
|
|
357
|
+
const { lines: e, registration: i, user: r } = t, n = $.cloneDeep(this.entitlements);
|
|
358
|
+
e.forEach((a) => {
|
|
359
|
+
const u = de(a, this.dateTime), c = he(u, a, { registration: i, user: r }), o = ce(this.currency.code, c, a), l = oe(o, this.currency.code, a);
|
|
360
|
+
Object.assign(a.updatedItem, l || {});
|
|
361
|
+
}), ue(e, n, this.currency.code), await this.next(t);
|
|
354
362
|
} catch (e) {
|
|
355
363
|
t.addException("get price fail", e.message), this.exitChain();
|
|
356
364
|
}
|
|
357
365
|
}
|
|
358
366
|
}
|
|
359
|
-
function
|
|
360
|
-
Array.from(s).sort((
|
|
361
|
-
const { merchandise: n, updatedItem: a } =
|
|
362
|
-
let y =
|
|
363
|
-
y.length === 0 && (a.qty = 0,
|
|
367
|
+
function ue(s, t = [], e) {
|
|
368
|
+
Array.from(s).sort((r, n) => n.updatedItem.price && r.updatedItem.price ? n.updatedItem.price.value - r.updatedItem.price.value : 1).forEach((r) => {
|
|
369
|
+
const { merchandise: n, updatedItem: a } = r, { priceStrategies: u = [], qty: c } = a, { merchandiseCode: o, productCodes: l } = n, { waived: d, entitlementsRemarkValue: m } = le(t, l, c), g = u.map((L) => L.toCalculatorRule({ currencyCode: e })), f = c - d;
|
|
370
|
+
let y = Y(f, g);
|
|
371
|
+
y.length === 0 && (a.qty = 0, r.disabled = !0, r.errors.push("No available price.")), y = (y || []).sort((L, it) => L.value - it.value);
|
|
364
372
|
const [C = {}] = y;
|
|
365
|
-
C.qty > 0 &&
|
|
366
|
-
const { priceStrategy:
|
|
367
|
-
let
|
|
368
|
-
|
|
369
|
-
let
|
|
370
|
-
|
|
371
|
-
const
|
|
372
|
-
merchandiseCode:
|
|
373
|
-
price:
|
|
374
|
-
discount:
|
|
375
|
-
subTotal:
|
|
373
|
+
C.qty > 0 && r.errors.push("Exceed maximum quantity per transaction."), C.qty < 0 && r.errors.push("No available price.");
|
|
374
|
+
const { priceStrategy: A, value: P } = C, w = A || u[0], I = h.init(w ? w.getAmountByCurrencyCode(e) : null), U = h.init({ value: P, currencyCode: e }), tt = (I ? I.value : 0) * f - (U ? U.value : 0) + (I ? I.value : 0) * d, et = h.init({ value: tt, currencyCode: e });
|
|
375
|
+
let F = p.initOnlyValidFromArray([...a.remarks || []]);
|
|
376
|
+
F = p.updateOrInsertRecord(F, "entitlements", m);
|
|
377
|
+
let x = _.initOnlyValidFromArray([...a.metadata || []]);
|
|
378
|
+
x = _.updateOrInsertRecord(x, "entitlements", m);
|
|
379
|
+
const st = {
|
|
380
|
+
merchandiseCode: o,
|
|
381
|
+
price: I,
|
|
382
|
+
discount: et,
|
|
383
|
+
subTotal: U,
|
|
376
384
|
qty: c,
|
|
377
|
-
waived:
|
|
385
|
+
waived: d,
|
|
378
386
|
// remarks: [{ key: 'entitlements', value: entitlementsRemarkValue }],
|
|
379
|
-
remarks:
|
|
380
|
-
metadata:
|
|
387
|
+
remarks: F,
|
|
388
|
+
metadata: x,
|
|
381
389
|
priceStrategies: u,
|
|
382
|
-
priceStrategy:
|
|
390
|
+
priceStrategy: w
|
|
383
391
|
};
|
|
384
|
-
Object.assign(
|
|
392
|
+
Object.assign(r.updatedItem, st);
|
|
385
393
|
});
|
|
386
394
|
}
|
|
387
|
-
function
|
|
395
|
+
function ce(s, t, e) {
|
|
388
396
|
if (t.length === 0)
|
|
389
397
|
return [];
|
|
390
|
-
const { updatedItem:
|
|
391
|
-
return
|
|
398
|
+
const { updatedItem: i } = e, r = t.filter((n) => n.hasCurrencyCode(s));
|
|
399
|
+
return r.length === 0 && (i.qty = 0, e.disabled = !0, e.errors.push(`Not support currency "${s}".`)), r;
|
|
392
400
|
}
|
|
393
|
-
function
|
|
401
|
+
function oe(s, t, e) {
|
|
394
402
|
if (s.length === 0)
|
|
395
403
|
return null;
|
|
396
|
-
const { merchandise:
|
|
397
|
-
let c =
|
|
404
|
+
const { merchandise: i, updatedItem: r } = e, { qty: n } = r, { merchandiseCode: a } = i, u = s.map((A) => A.toCalculatorRule({ currencyCode: t }));
|
|
405
|
+
let c = Y(n, u);
|
|
398
406
|
if (c.length === 0)
|
|
399
|
-
return
|
|
400
|
-
c = c.sort((
|
|
401
|
-
const [
|
|
402
|
-
if (
|
|
407
|
+
return r.qty = 0, e.disabled = !0, e.errors.push("No available price."), null;
|
|
408
|
+
c = c.sort((A, P) => A.value - P.value);
|
|
409
|
+
const [o = {}] = c;
|
|
410
|
+
if (o.qty > 0)
|
|
403
411
|
return e.errors.push("Exceed maximum quantity per transaction."), null;
|
|
404
|
-
if (
|
|
412
|
+
if (o.qty < 0)
|
|
405
413
|
return e.errors.push("No available price."), null;
|
|
406
|
-
const { priceStrategy:
|
|
414
|
+
const { priceStrategy: l, value: d } = o, m = l || s[0], g = h.init(m.getAmountByCurrencyCode(t)), f = h.init({ value: d, currencyCode: t }), y = g.value * n - f.value, C = h.init({ value: y, currencyCode: t });
|
|
407
415
|
return {
|
|
408
416
|
merchandiseCode: a,
|
|
409
417
|
// remarks: [],
|
|
410
|
-
price:
|
|
418
|
+
price: g,
|
|
411
419
|
discount: C,
|
|
412
|
-
subTotal:
|
|
420
|
+
subTotal: f,
|
|
413
421
|
qty: n,
|
|
414
422
|
// waived,
|
|
415
423
|
priceStrategies: s,
|
|
416
|
-
priceStrategy:
|
|
424
|
+
priceStrategy: m
|
|
417
425
|
};
|
|
418
426
|
}
|
|
419
|
-
function
|
|
427
|
+
function le(s, t, e) {
|
|
420
428
|
if (s.length === 0)
|
|
421
429
|
return { waived: 0, entitlementsRemarkValue: [] };
|
|
422
|
-
const
|
|
430
|
+
const i = Array.from({ length: e }).map(() => [...t]), { waived: r, entitlementsRemarkValue: n } = i.reduce((a, u) => {
|
|
423
431
|
if (a.continue === !1)
|
|
424
432
|
return a;
|
|
425
|
-
const { entitlementKeyValues: c } = u.reduce((
|
|
426
|
-
const
|
|
427
|
-
if (
|
|
428
|
-
const [
|
|
429
|
-
|
|
433
|
+
const { entitlementKeyValues: c } = u.reduce((o, l) => {
|
|
434
|
+
const d = s.findIndex((m) => (m.value || []).includes(l));
|
|
435
|
+
if (d !== -1) {
|
|
436
|
+
const [m] = s.splice(d, 1);
|
|
437
|
+
o.cutEntitlements.push(m), o.entitlementKeyValues.push({ key: l, value: m.key });
|
|
430
438
|
}
|
|
431
|
-
return
|
|
439
|
+
return o;
|
|
432
440
|
}, { cutEntitlements: [], entitlementKeyValues: [] });
|
|
433
441
|
return u.length !== c.length ? a.continue = !1 : (a.waived += 1, a.entitlementsRemarkValue.push(...c)), a;
|
|
434
442
|
}, { continue: !0, waived: 0, entitlementsRemarkValue: [] });
|
|
435
|
-
return { waived:
|
|
443
|
+
return { waived: r, entitlementsRemarkValue: n };
|
|
436
444
|
}
|
|
437
|
-
function
|
|
438
|
-
const { merchandise: e, updatedItem:
|
|
439
|
-
return
|
|
440
|
-
}
|
|
441
|
-
function
|
|
442
|
-
const { updatedItem:
|
|
443
|
-
let
|
|
444
|
-
return s.length !== 0 && (
|
|
445
|
-
const u = a.getStrategiesByRestrictions(
|
|
445
|
+
function de(s, t) {
|
|
446
|
+
const { merchandise: e, updatedItem: i } = s, r = e.getPricesByTime(t);
|
|
447
|
+
return r.length === 0 && (i.qty = 0, s.disabled = !0, s.errors.push("Currently not available for sale.")), r.sort((n, a) => n.dateBegin - a.dateBegin);
|
|
448
|
+
}
|
|
449
|
+
function he(s, t, e) {
|
|
450
|
+
const { updatedItem: i } = t;
|
|
451
|
+
let r = [];
|
|
452
|
+
return s.length !== 0 && (r = s.reduce((n, a) => {
|
|
453
|
+
const u = a.getStrategiesByRestrictions(e);
|
|
446
454
|
return n.concat(u);
|
|
447
|
-
}, [])),
|
|
455
|
+
}, [])), r.length === 0 && (i.qty = 0, t.available = !1, t.errors.push("You are not entitled to this item.")), r;
|
|
448
456
|
}
|
|
449
|
-
class
|
|
457
|
+
class me extends S {
|
|
450
458
|
constructor(t = {}) {
|
|
451
459
|
super(t), this.currency = t.currency, this.dateTime = t.dateTime, this.entitlements = t.entitlements || [], this.merchandises = t.merchandises;
|
|
452
460
|
}
|
|
453
461
|
async handleRequest(t) {
|
|
454
462
|
try {
|
|
455
|
-
const { lines: e } = t,
|
|
456
|
-
e.forEach((
|
|
457
|
-
const n =
|
|
458
|
-
Object.assign(
|
|
459
|
-
}),
|
|
463
|
+
const { lines: e } = t, i = $.cloneDeep(this.entitlements);
|
|
464
|
+
e.forEach((r) => {
|
|
465
|
+
const n = Ce(r, this.dateTime), a = _e(n), u = ge(this.currency.code, a, r), c = fe(u, this.currency.code, r);
|
|
466
|
+
Object.assign(r.updatedItem, c || {});
|
|
467
|
+
}), pe(e, i, this.currency.code), await this.next(t);
|
|
460
468
|
} catch (e) {
|
|
461
469
|
t.addException("get price fail", e.message), this.exitChain();
|
|
462
470
|
}
|
|
463
471
|
}
|
|
464
472
|
}
|
|
465
|
-
function
|
|
466
|
-
Array.from(s).sort((
|
|
467
|
-
const { merchandise: n, updatedItem: a } =
|
|
468
|
-
|
|
469
|
-
const
|
|
470
|
-
let y =
|
|
471
|
-
y.length === 0 && (a.qty = 0,
|
|
473
|
+
function pe(s, t = [], e) {
|
|
474
|
+
Array.from(s).sort((r, n) => n.updatedItem.price.value - r.updatedItem.price.value).forEach((r) => {
|
|
475
|
+
const { merchandise: n, updatedItem: a } = r, { priceStrategies: u, qty: c } = a, { merchandiseCode: o, productCodes: l } = n, { waived: d, entitlementsRemarkValue: m } = ye(t, l, c), g = u.map((L) => L.toCalculatorRule({ currencyCode: e }));
|
|
476
|
+
Tt({ rules: g, max: 9999 });
|
|
477
|
+
const f = c - d;
|
|
478
|
+
let y = Y(f, g);
|
|
479
|
+
y.length === 0 && (a.qty = 0, r.disabled = !0, r.errors.push("No available price.")), y = y.sort((L, it) => L.value - it.value);
|
|
472
480
|
const [C = {}] = y;
|
|
473
|
-
C.qty > 0 &&
|
|
474
|
-
const { priceStrategy:
|
|
475
|
-
let
|
|
476
|
-
|
|
477
|
-
let
|
|
478
|
-
|
|
479
|
-
const
|
|
480
|
-
merchandiseCode:
|
|
481
|
-
price:
|
|
482
|
-
discount:
|
|
483
|
-
subTotal:
|
|
481
|
+
C.qty > 0 && r.errors.push("Exceed maximum quantity per transaction."), C.qty < 0 && r.errors.push("No available price.");
|
|
482
|
+
const { priceStrategy: A, value: P } = C, w = A || u[0], I = h.init(w.getAmountByCurrencyCode(e)), U = h.init({ value: P, currencyCode: e }), tt = I.value * f - U.value + I.value * d, et = h.init({ value: tt, currencyCode: e });
|
|
483
|
+
let F = p.initOnlyValidFromArray([...a.remarks || []]);
|
|
484
|
+
F = p.updateOrInsertRecord(F, "entitlements", m);
|
|
485
|
+
let x = _.initOnlyValidFromArray([...a.metadata || []]);
|
|
486
|
+
x = _.updateOrInsertRecord(x, "entitlements", m);
|
|
487
|
+
const st = {
|
|
488
|
+
merchandiseCode: o,
|
|
489
|
+
price: I,
|
|
490
|
+
discount: et,
|
|
491
|
+
subTotal: U,
|
|
484
492
|
qty: c,
|
|
485
|
-
waived:
|
|
493
|
+
waived: d,
|
|
486
494
|
// remarks: [{ key: 'entitlements', value: entitlementsRemarkValue }],
|
|
487
|
-
remarks:
|
|
488
|
-
metadata:
|
|
495
|
+
remarks: F,
|
|
496
|
+
metadata: x,
|
|
489
497
|
priceStrategies: u,
|
|
490
|
-
priceStrategy:
|
|
498
|
+
priceStrategy: w
|
|
491
499
|
};
|
|
492
|
-
Object.assign(
|
|
500
|
+
Object.assign(r.updatedItem, st);
|
|
493
501
|
});
|
|
494
502
|
}
|
|
495
|
-
function
|
|
503
|
+
function ge(s, t, e) {
|
|
496
504
|
if (t.length === 0)
|
|
497
505
|
return [];
|
|
498
|
-
const { updatedItem:
|
|
499
|
-
return
|
|
506
|
+
const { updatedItem: i } = e, r = t.filter((n) => n.hasCurrencyCode(s));
|
|
507
|
+
return r.length === 0 && (i.qty = 0, e.disabled = !0, e.errors.push(`Not support currency "${s}".`)), r;
|
|
500
508
|
}
|
|
501
|
-
function
|
|
509
|
+
function fe(s, t, e) {
|
|
502
510
|
if (s.length === 0)
|
|
503
511
|
return null;
|
|
504
|
-
const { merchandise:
|
|
505
|
-
|
|
506
|
-
let c =
|
|
512
|
+
const { merchandise: i, updatedItem: r } = e, { qty: n } = r, { merchandiseCode: a } = i, u = s.map((A) => A.toCalculatorRule({ currencyCode: t }));
|
|
513
|
+
Tt({ rules: u, max: 9999 });
|
|
514
|
+
let c = Y(n, u);
|
|
507
515
|
if (c.length === 0)
|
|
508
|
-
return
|
|
509
|
-
c = c.sort((
|
|
510
|
-
const [
|
|
511
|
-
if (
|
|
516
|
+
return r.qty = 0, e.disabled = !0, e.errors.push("No available price."), null;
|
|
517
|
+
c = c.sort((A, P) => A.value - P.value);
|
|
518
|
+
const [o = {}] = c;
|
|
519
|
+
if (o.qty > 0)
|
|
512
520
|
return e.errors.push("Exceed maximum quantity per transaction."), null;
|
|
513
|
-
if (
|
|
521
|
+
if (o.qty < 0)
|
|
514
522
|
return e.errors.push("No available price."), null;
|
|
515
|
-
const { priceStrategy:
|
|
523
|
+
const { priceStrategy: l, value: d } = o, m = l || s[0], g = h.init(m.getAmountByCurrencyCode(t)), f = h.init({ value: d, currencyCode: t }), y = g.value * n - f.value, C = h.init({ value: y, currencyCode: t });
|
|
516
524
|
return {
|
|
517
525
|
merchandiseCode: a,
|
|
518
526
|
// remarks: [],
|
|
519
|
-
price:
|
|
527
|
+
price: g,
|
|
520
528
|
discount: C,
|
|
521
|
-
subTotal:
|
|
529
|
+
subTotal: f,
|
|
522
530
|
qty: n,
|
|
523
531
|
// waived,
|
|
524
532
|
priceStrategies: s,
|
|
525
|
-
priceStrategy:
|
|
533
|
+
priceStrategy: m
|
|
526
534
|
};
|
|
527
535
|
}
|
|
528
|
-
function
|
|
536
|
+
function ye(s, t, e) {
|
|
529
537
|
if (s.length === 0)
|
|
530
538
|
return { waived: 0, entitlementsRemarkValue: [] };
|
|
531
|
-
const
|
|
539
|
+
const i = Array.from({ length: e }).map(() => [...t]), { waived: r, entitlementsRemarkValue: n } = i.reduce((a, u) => {
|
|
532
540
|
if (a.continue === !1)
|
|
533
541
|
return a;
|
|
534
|
-
const { entitlementKeyValues: c } = u.reduce((
|
|
535
|
-
const
|
|
536
|
-
if (
|
|
537
|
-
const [
|
|
538
|
-
|
|
542
|
+
const { entitlementKeyValues: c } = u.reduce((o, l) => {
|
|
543
|
+
const d = s.findIndex((m) => (m.value || []).includes(l));
|
|
544
|
+
if (d !== -1) {
|
|
545
|
+
const [m] = s.splice(d, 1);
|
|
546
|
+
o.cutEntitlements.push(m), o.entitlementKeyValues.push({ key: l, value: m.key });
|
|
539
547
|
}
|
|
540
|
-
return
|
|
548
|
+
return o;
|
|
541
549
|
}, { cutEntitlements: [], entitlementKeyValues: [] });
|
|
542
550
|
return u.length !== c.length ? a.continue = !1 : (a.waived += 1, a.entitlementsRemarkValue.push(...c)), a;
|
|
543
551
|
}, { continue: !0, waived: 0, entitlementsRemarkValue: [] });
|
|
544
|
-
return { waived:
|
|
552
|
+
return { waived: r, entitlementsRemarkValue: n };
|
|
545
553
|
}
|
|
546
|
-
function
|
|
547
|
-
const { merchandise: e, updatedItem:
|
|
548
|
-
return
|
|
554
|
+
function Ce(s, t) {
|
|
555
|
+
const { merchandise: e, updatedItem: i } = s, r = e.getPricesByTime(t);
|
|
556
|
+
return r.length === 0 && (i.qty = 0, s.disabled = !0, s.errors.push("Currently not available for sale.")), r.sort((n, a) => n.dateBegin - a.dateBegin);
|
|
549
557
|
}
|
|
550
|
-
function
|
|
551
|
-
return s.length === 0 ? [] : s.reduce((e,
|
|
552
|
-
const
|
|
553
|
-
return e.concat(
|
|
558
|
+
function _e(s) {
|
|
559
|
+
return s.length === 0 ? [] : s.reduce((e, i) => {
|
|
560
|
+
const r = i.priceStrategies;
|
|
561
|
+
return e.concat(r);
|
|
554
562
|
}, []);
|
|
555
563
|
}
|
|
556
|
-
function
|
|
564
|
+
function Tt({ rules: s, max: t }) {
|
|
557
565
|
return s.forEach((e) => {
|
|
558
|
-
const
|
|
559
|
-
|
|
566
|
+
const i = e;
|
|
567
|
+
i.max = t;
|
|
560
568
|
}), s;
|
|
561
569
|
}
|
|
562
|
-
class
|
|
570
|
+
class Ft extends S {
|
|
563
571
|
constructor(t = {}) {
|
|
564
572
|
super(t);
|
|
565
573
|
}
|
|
566
574
|
async handleRequest(t) {
|
|
567
575
|
try {
|
|
568
576
|
const { lines: e } = t;
|
|
569
|
-
e.forEach((
|
|
570
|
-
const { item:
|
|
571
|
-
|
|
572
|
-
...
|
|
577
|
+
e.forEach((i) => {
|
|
578
|
+
const { item: r = {} } = i;
|
|
579
|
+
i.updatedItem = {
|
|
580
|
+
...r,
|
|
573
581
|
waived: 0,
|
|
574
|
-
remarks: p.initOnlyValidFromArray(
|
|
575
|
-
metadata: _.initOnlyValidFromArray(
|
|
576
|
-
price:
|
|
577
|
-
discount:
|
|
578
|
-
subTotal:
|
|
582
|
+
remarks: p.initOnlyValidFromArray(r.remarks),
|
|
583
|
+
metadata: _.initOnlyValidFromArray(r.metadata),
|
|
584
|
+
price: h.init(r.price),
|
|
585
|
+
discount: h.init(r.discount),
|
|
586
|
+
subTotal: h.init(r.subTotal),
|
|
579
587
|
priceStrategy: null
|
|
580
588
|
// purchaseOptions: [],
|
|
581
|
-
},
|
|
589
|
+
}, i.available = !0, i.disabled = !1, i.errors = [], i.messages = [], i.validated = !0;
|
|
582
590
|
}), await this.next(t);
|
|
583
591
|
} catch (e) {
|
|
584
592
|
t.addException("init lines fail", e.message), this.exitChain();
|
|
585
593
|
}
|
|
586
594
|
}
|
|
587
595
|
}
|
|
588
|
-
class
|
|
596
|
+
class xt extends S {
|
|
589
597
|
constructor(t = {}) {
|
|
590
598
|
super(t);
|
|
591
599
|
}
|
|
592
600
|
async handleRequest(t) {
|
|
593
601
|
try {
|
|
594
|
-
const { lines: e, users:
|
|
595
|
-
e.forEach((
|
|
596
|
-
const { updatedItem: n, merchandise: a } =
|
|
602
|
+
const { lines: e, users: i } = t;
|
|
603
|
+
e.forEach((r) => {
|
|
604
|
+
const { updatedItem: n, merchandise: a } = r, u = a.getStock();
|
|
597
605
|
if (u === 0)
|
|
598
|
-
|
|
606
|
+
r.disabled = !0, r.errors.push("Full.");
|
|
599
607
|
else {
|
|
600
608
|
const { qty: c } = n;
|
|
601
609
|
n.qty = c > u ? u : c;
|
|
@@ -606,65 +614,65 @@ class Rt extends b {
|
|
|
606
614
|
}
|
|
607
615
|
}
|
|
608
616
|
}
|
|
609
|
-
class
|
|
617
|
+
class Ae extends S {
|
|
610
618
|
constructor(t = {}) {
|
|
611
619
|
super(t), this.currency = t.currency;
|
|
612
620
|
}
|
|
613
621
|
async handleRequest(t) {
|
|
614
622
|
try {
|
|
615
623
|
const { lines: e } = t;
|
|
616
|
-
e.forEach((
|
|
617
|
-
|
|
624
|
+
e.forEach((i) => {
|
|
625
|
+
ve({ line: i, currency: this.currency });
|
|
618
626
|
}), await this.next(t);
|
|
619
627
|
} catch (e) {
|
|
620
628
|
t.addException("handle related coupons fail", e.message), this.exitChain();
|
|
621
629
|
}
|
|
622
630
|
}
|
|
623
631
|
}
|
|
624
|
-
function
|
|
625
|
-
const { updatedItem: e } = s, { price:
|
|
632
|
+
function ve({ line: s, currency: t }) {
|
|
633
|
+
const { updatedItem: e } = s, { price: i, qty: r, discount: n, purchaseOptions: a, remarks: u, subTotal: c } = e;
|
|
626
634
|
if (a.length === 0 || e.qty === 0)
|
|
627
635
|
return;
|
|
628
|
-
const
|
|
629
|
-
if (!
|
|
636
|
+
const o = Oe(a);
|
|
637
|
+
if (!o)
|
|
630
638
|
return;
|
|
631
|
-
const
|
|
632
|
-
subTotal:
|
|
639
|
+
const l = c.value + o * (t.factor || 1), d = {
|
|
640
|
+
subTotal: h.init({ value: l, currencyCode: t.code })
|
|
633
641
|
};
|
|
634
|
-
Object.assign(e,
|
|
642
|
+
Object.assign(e, d);
|
|
635
643
|
}
|
|
636
|
-
function
|
|
644
|
+
function Oe(s) {
|
|
637
645
|
var t;
|
|
638
646
|
for (const e of s) {
|
|
639
|
-
const
|
|
640
|
-
if (
|
|
641
|
-
return Number(
|
|
647
|
+
const i = (t = e.value) == null ? void 0 : t.find((r) => r.key === "priceAdjustment");
|
|
648
|
+
if (i)
|
|
649
|
+
return Number(i.value);
|
|
642
650
|
}
|
|
643
651
|
return null;
|
|
644
652
|
}
|
|
645
|
-
class
|
|
653
|
+
class Lt extends S {
|
|
646
654
|
constructor(t = {}) {
|
|
647
655
|
super(t), this.products = t.products || [];
|
|
648
656
|
}
|
|
649
657
|
async handleRequest(t) {
|
|
650
658
|
try {
|
|
651
|
-
const { lines: e, users:
|
|
659
|
+
const { lines: e, users: i } = t, r = Pe(this.products);
|
|
652
660
|
e.forEach((n) => {
|
|
653
|
-
const { merchandise: a, productsQty: u, updatedItem: c } = n, { qty:
|
|
654
|
-
Object.keys(u).forEach((
|
|
655
|
-
const
|
|
656
|
-
if (!
|
|
657
|
-
throw new Error(`Invalid merchandise "${a.name}": no productCode "${
|
|
658
|
-
const { name:
|
|
661
|
+
const { merchandise: a, productsQty: u, updatedItem: c } = n, { qty: o } = c;
|
|
662
|
+
Object.keys(u).forEach((l) => {
|
|
663
|
+
const d = u[l], m = r[l];
|
|
664
|
+
if (!m)
|
|
665
|
+
throw new Error(`Invalid merchandise "${a.name}": no productCode "${l}"`);
|
|
666
|
+
const { name: g, stock: f, used: y } = m, C = f - y;
|
|
659
667
|
if (C === 0)
|
|
660
668
|
c.qty = 0;
|
|
661
669
|
else {
|
|
662
|
-
const
|
|
663
|
-
if (C -
|
|
664
|
-
|
|
670
|
+
const A = d * o;
|
|
671
|
+
if (C - A > 0)
|
|
672
|
+
m.used += A;
|
|
665
673
|
else {
|
|
666
|
-
const
|
|
667
|
-
|
|
674
|
+
const w = Math.floor(C / d);
|
|
675
|
+
w === 0 ? (c.qty = 0, n.disabled = !0, n.errors.push(`"${g}" does not have enough stock`)) : (m.used += w * d, c.qty = Math.min(c.qty, w));
|
|
668
676
|
}
|
|
669
677
|
}
|
|
670
678
|
});
|
|
@@ -674,35 +682,35 @@ class Et extends b {
|
|
|
674
682
|
}
|
|
675
683
|
}
|
|
676
684
|
}
|
|
677
|
-
function
|
|
685
|
+
function Pe(s) {
|
|
678
686
|
return s.reduce((t, e) => {
|
|
679
|
-
const { productCode:
|
|
680
|
-
return t[
|
|
681
|
-
name:
|
|
687
|
+
const { productCode: i, name: r, stock: n } = e;
|
|
688
|
+
return t[i] = {
|
|
689
|
+
name: r,
|
|
682
690
|
stock: n,
|
|
683
691
|
used: 0
|
|
684
692
|
}, t;
|
|
685
693
|
}, {});
|
|
686
694
|
}
|
|
687
|
-
class
|
|
695
|
+
class be extends S {
|
|
688
696
|
constructor(t = {}) {
|
|
689
697
|
super(t), this.products = t.products || [], this.walletItems = t.walletItems || [];
|
|
690
698
|
}
|
|
691
699
|
async handleRequest(t) {
|
|
692
700
|
try {
|
|
693
|
-
const { lines: e, users:
|
|
694
|
-
const { merchandise:
|
|
695
|
-
return
|
|
696
|
-
}, []), a = [...new Set(n.concat(
|
|
701
|
+
const { lines: e, users: i } = t, r = this.walletItems.filter(we).map((u) => u.productCode), n = e.reduce((u, c) => {
|
|
702
|
+
const { merchandise: o, updatedItem: l } = c;
|
|
703
|
+
return l.qty > 0 ? u.concat(o.productCodes) : u;
|
|
704
|
+
}, []), a = [...new Set(n.concat(r))];
|
|
697
705
|
e.forEach((u) => {
|
|
698
|
-
const { item: c, updatedItem:
|
|
699
|
-
this.products.filter((
|
|
700
|
-
const
|
|
701
|
-
|
|
702
|
-
const [y = []] = p.getValuesByKey(
|
|
706
|
+
const { item: c, updatedItem: o, merchandise: l } = u, { productCodes: d } = l;
|
|
707
|
+
this.products.filter((g) => d.includes(g.productCode)).forEach((g) => {
|
|
708
|
+
const f = r.reduce((P, w) => w === g.productCode ? P + 1 : P, 0);
|
|
709
|
+
g.maxPerWallet > f || (u.disabled = !0);
|
|
710
|
+
const [y = []] = p.getValuesByKey(g.remarks, "restrictions"), [C = []] = p.getValuesByKey(y, "requiredProductCodes");
|
|
703
711
|
if (C.length === 0)
|
|
704
712
|
return;
|
|
705
|
-
C.some((
|
|
713
|
+
C.some((P) => a.includes(P)) || (u.disabled = !0, o.qty = 0);
|
|
706
714
|
});
|
|
707
715
|
}), await this.next(t);
|
|
708
716
|
} catch (e) {
|
|
@@ -710,22 +718,30 @@ class ye extends b {
|
|
|
710
718
|
}
|
|
711
719
|
}
|
|
712
720
|
}
|
|
713
|
-
|
|
721
|
+
function we(s) {
|
|
722
|
+
if (!s)
|
|
723
|
+
return !1;
|
|
724
|
+
if (typeof s.isInWallet < "u")
|
|
725
|
+
return s.isInWallet;
|
|
726
|
+
const t = s.status || {};
|
|
727
|
+
return !t.cancelled && !t.rejected && !t.refunded && !t.refundRequested;
|
|
728
|
+
}
|
|
729
|
+
class Ie extends S {
|
|
714
730
|
constructor(t = {}) {
|
|
715
731
|
super(t);
|
|
716
732
|
}
|
|
717
733
|
async handleRequest(t) {
|
|
718
734
|
try {
|
|
719
|
-
const { lines: e, users:
|
|
720
|
-
e.forEach((
|
|
721
|
-
const { updatedItem: n } =
|
|
735
|
+
const { lines: e, users: i } = t;
|
|
736
|
+
e.forEach((r) => {
|
|
737
|
+
const { updatedItem: n } = r, { purchaseOptions: a = [] } = n;
|
|
722
738
|
if (a.length === 0 || n.qty === 0)
|
|
723
739
|
return;
|
|
724
740
|
let u = !1, c = !1;
|
|
725
|
-
a.forEach((
|
|
726
|
-
(
|
|
727
|
-
const { required:
|
|
728
|
-
|
|
741
|
+
a.forEach((o) => {
|
|
742
|
+
(o.value || []).forEach((l) => {
|
|
743
|
+
const { required: d, validated: m, value: g } = l;
|
|
744
|
+
d && !g && !u && (u = !0, r.validated = !1, r.errors.push("Please fill in the option(s).")), m && !c && (c = !0, r.errors.push("Invalid option(s)."));
|
|
729
745
|
});
|
|
730
746
|
});
|
|
731
747
|
}), await this.next(t);
|
|
@@ -734,146 +750,153 @@ class Ce extends b {
|
|
|
734
750
|
}
|
|
735
751
|
}
|
|
736
752
|
}
|
|
737
|
-
class
|
|
753
|
+
class Se extends S {
|
|
738
754
|
constructor(t = {}) {
|
|
739
755
|
super(t), this.autoUseCoupon = t.autoUseCoupon || !1, this.currency = t.currency, this.walletItems = t.walletItems;
|
|
740
756
|
}
|
|
741
757
|
async handleRequest(t) {
|
|
742
758
|
try {
|
|
743
|
-
const { lines: e, relatedTotalCoupons:
|
|
759
|
+
const { lines: e, relatedTotalCoupons: i = [], users: r } = t, n = this.walletItems.filter((a) => a.isCoupon);
|
|
744
760
|
e.forEach((a) => {
|
|
745
|
-
|
|
761
|
+
Ve({ line: a, currencyCode: this.currency.code }), Fe(a, n, this.autoUseCoupon, this.currency.code);
|
|
746
762
|
}), e.forEach((a) => {
|
|
747
|
-
|
|
748
|
-
}),
|
|
763
|
+
Ee(a);
|
|
764
|
+
}), De({ lines: e, currencyCode: this.currency.code, relatedTotalCoupons: i }), Re({ lines: e, autoUseCoupon: this.autoUseCoupon, currencyCode: this.currency.code, relatedTotalCoupons: i }), await this.next(t);
|
|
749
765
|
} catch (e) {
|
|
750
766
|
t.addException("handle related coupons fail", e.message), this.exitChain();
|
|
751
767
|
}
|
|
752
768
|
}
|
|
753
769
|
}
|
|
754
|
-
function
|
|
755
|
-
t &&
|
|
756
|
-
const n =
|
|
757
|
-
Object.assign(
|
|
770
|
+
function Re({ lines: s, autoUseCoupon: t, currencyCode: e, relatedTotalCoupons: i }) {
|
|
771
|
+
t && i.forEach((r) => {
|
|
772
|
+
const n = Bt(r, s, e);
|
|
773
|
+
Object.assign(r, n);
|
|
758
774
|
});
|
|
759
775
|
}
|
|
760
|
-
function
|
|
761
|
-
const { availableCoupons:
|
|
762
|
-
if (
|
|
763
|
-
const { updatedItem:
|
|
764
|
-
return
|
|
776
|
+
function Bt(s, t, e) {
|
|
777
|
+
const { availableCoupons: i, usedCoupons: r, product: n } = s;
|
|
778
|
+
if (i.length > 0 && t.filter((c) => n.isApplicableCoupon(c.merchandise)).reduce((c, o) => {
|
|
779
|
+
const { updatedItem: l = {} } = o, { subTotal: d = {} } = l;
|
|
780
|
+
return d && d.value && (c += d.value), c;
|
|
765
781
|
}, 0) > 0) {
|
|
766
|
-
const [c] =
|
|
767
|
-
return c.setOnHold(),
|
|
782
|
+
const [c] = i.splice(0, 1);
|
|
783
|
+
return c.setOnHold(), r.push(c), Mt({ lines: t, currencyCode: e, coupon: c }), Bt(s, t, e);
|
|
768
784
|
}
|
|
769
785
|
return s;
|
|
770
786
|
}
|
|
771
|
-
function
|
|
772
|
-
const { usedCoupons: e = {}, updatedItem:
|
|
773
|
-
Object.keys(e).forEach((
|
|
774
|
-
e[
|
|
775
|
-
const a =
|
|
776
|
-
Object.assign(
|
|
787
|
+
function Ve({ line: s, currencyCode: t }) {
|
|
788
|
+
const { usedCoupons: e = {}, updatedItem: i } = s;
|
|
789
|
+
Object.keys(e).forEach((r) => {
|
|
790
|
+
Ct(e[r]).forEach((n) => {
|
|
791
|
+
const a = $t({ updatedItem: i, coupon: n, currencyCode: t });
|
|
792
|
+
Object.assign(i, a);
|
|
777
793
|
});
|
|
778
794
|
});
|
|
779
795
|
}
|
|
780
|
-
function
|
|
781
|
-
e.forEach((
|
|
782
|
-
const { usedCoupons:
|
|
783
|
-
|
|
784
|
-
|
|
796
|
+
function De({ lines: s, currencyCode: t, relatedTotalCoupons: e }) {
|
|
797
|
+
e.forEach((i) => {
|
|
798
|
+
const { usedCoupons: r } = i;
|
|
799
|
+
Ct(r).forEach((n) => {
|
|
800
|
+
Mt({ lines: s, currencyCode: t, coupon: n });
|
|
785
801
|
});
|
|
786
802
|
});
|
|
787
803
|
}
|
|
788
|
-
function
|
|
789
|
-
const
|
|
790
|
-
const { price:
|
|
791
|
-
return u +=
|
|
804
|
+
function Mt({ lines: s, currencyCode: t, coupon: e }) {
|
|
805
|
+
const i = s.filter((u) => e.isApplicableCoupon(u.merchandise)), r = i.reduce((u, c) => {
|
|
806
|
+
const { price: o = {}, qty: l } = c.updatedItem || {};
|
|
807
|
+
return u += o.value * l;
|
|
792
808
|
}, 0), { couponDetails: n, walletItemCode: a } = e;
|
|
793
809
|
if (n) {
|
|
794
|
-
const { type: u, total: c } = n, { value:
|
|
810
|
+
const { type: u, total: c } = n, { value: o } = n;
|
|
795
811
|
switch (u) {
|
|
796
812
|
case "Deduction": {
|
|
797
|
-
const
|
|
798
|
-
|
|
799
|
-
const { updatedItem:
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
remarks: p.insertOrUpdateRecord(C, "USED_TOTAL_COUPONS", S),
|
|
804
|
-
subTotal: m.init({ value: P, currencyCode: t })
|
|
813
|
+
const l = p.foundValueByKey(o, t);
|
|
814
|
+
i.forEach((d) => {
|
|
815
|
+
const { updatedItem: m } = d, { price: g, qty: f, discount: y, remarks: C, subTotal: A } = m, P = l * (g.value * f / r) + y.value, w = A.value > l ? A.value - l : 0, I = {
|
|
816
|
+
discount: h.init({ value: P, currencyCode: t }),
|
|
817
|
+
remarks: rt(C, "USED_TOTAL_COUPONS", a),
|
|
818
|
+
subTotal: h.init({ value: w, currencyCode: t })
|
|
805
819
|
};
|
|
806
|
-
Object.assign(
|
|
820
|
+
Object.assign(m, I);
|
|
807
821
|
});
|
|
808
822
|
break;
|
|
809
823
|
}
|
|
810
824
|
case "Percentage": {
|
|
811
|
-
|
|
812
|
-
const { updatedItem:
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
remarks: p.insertOrUpdateRecord(y, "USED_TOTAL_COUPONS", S),
|
|
817
|
-
subTotal: m.init({ value: P, currencyCode: t })
|
|
825
|
+
i.forEach((l) => {
|
|
826
|
+
const { updatedItem: d } = l, { price: m, qty: g, discount: f, remarks: y, subTotal: C } = d, A = m.value * (o / 100) * g, P = A + f.value, w = C.value > A ? C.value - A : 0, I = {
|
|
827
|
+
discount: h.init({ value: P, currencyCode: t }),
|
|
828
|
+
remarks: rt(y, "USED_TOTAL_COUPONS", a),
|
|
829
|
+
subTotal: h.init({ value: w, currencyCode: t })
|
|
818
830
|
};
|
|
819
|
-
Object.assign(
|
|
831
|
+
Object.assign(d, I);
|
|
820
832
|
});
|
|
821
833
|
break;
|
|
822
834
|
}
|
|
823
835
|
}
|
|
824
836
|
}
|
|
825
837
|
}
|
|
826
|
-
function
|
|
827
|
-
const { couponDetails:
|
|
828
|
-
if (!
|
|
838
|
+
function $t({ updatedItem: s, coupon: t, currencyCode: e }) {
|
|
839
|
+
const { couponDetails: i, walletItemCode: r } = t;
|
|
840
|
+
if (!i)
|
|
829
841
|
return s;
|
|
830
|
-
const { price: n, qty: a, discount: u, remarks: c, subTotal:
|
|
831
|
-
return
|
|
842
|
+
const { price: n, qty: a, discount: u, remarks: c, subTotal: o } = s, l = Et({ coupon: t, price: n, currencyCode: e }), d = l + u.value, m = o.value > l ? o.value - l : 0;
|
|
843
|
+
return {
|
|
832
844
|
...s,
|
|
833
|
-
discount:
|
|
834
|
-
remarks:
|
|
835
|
-
subTotal:
|
|
845
|
+
discount: h.init({ value: d, currencyCode: e }),
|
|
846
|
+
remarks: rt(c, "USED_ITEM_COUPONS", r),
|
|
847
|
+
subTotal: h.init({ value: m, currencyCode: e })
|
|
836
848
|
};
|
|
837
849
|
}
|
|
838
|
-
function
|
|
850
|
+
function Ct(s = []) {
|
|
851
|
+
const t = [];
|
|
852
|
+
return s.filter((e) => {
|
|
853
|
+
const { walletItemCode: i } = e || {};
|
|
854
|
+
return !i || t.includes(i) ? !1 : (t.push(i), !0);
|
|
855
|
+
});
|
|
856
|
+
}
|
|
857
|
+
function rt(s, t, e) {
|
|
858
|
+
const i = p.foundValueByKey(s, t) || [], r = [.../* @__PURE__ */ new Set([...i, e])];
|
|
859
|
+
return p.insertOrUpdateRecord(s, t, r);
|
|
860
|
+
}
|
|
861
|
+
function Ee(s) {
|
|
839
862
|
const { relatedCoupons: t = [] } = s;
|
|
840
863
|
s.relatedCoupons = t.map((e) => ({
|
|
841
864
|
...e,
|
|
842
|
-
availableCoupons: e.coupons.filter((
|
|
865
|
+
availableCoupons: e.coupons.filter((i) => !i.isOnHold)
|
|
843
866
|
}));
|
|
844
867
|
}
|
|
845
|
-
function
|
|
846
|
-
const { merchandise:
|
|
868
|
+
function Te(s, t, e, i) {
|
|
869
|
+
const { merchandise: r, usedCoupons: n = {}, updatedItem: a = {} } = s;
|
|
847
870
|
return t.filter(
|
|
848
|
-
(c) => c.isApplicableCoupon(
|
|
849
|
-
).reduce((c,
|
|
850
|
-
const
|
|
851
|
-
let
|
|
852
|
-
const
|
|
853
|
-
|
|
871
|
+
(c) => c.isApplicableCoupon(r) && c.isItemCoupon
|
|
872
|
+
).reduce((c, o) => {
|
|
873
|
+
const l = o.product.productCode;
|
|
874
|
+
let d = c.find((y) => y.productCode === l);
|
|
875
|
+
const m = o.isOnHold;
|
|
876
|
+
d || (d = {
|
|
854
877
|
coupons: [],
|
|
855
|
-
product:
|
|
856
|
-
productCode:
|
|
857
|
-
usedQty: (n[
|
|
858
|
-
}, c.push(
|
|
859
|
-
const { qty:
|
|
860
|
-
if (e && !
|
|
861
|
-
|
|
862
|
-
...n[
|
|
863
|
-
|
|
878
|
+
product: o.product,
|
|
879
|
+
productCode: l,
|
|
880
|
+
usedQty: Ct(n[l]).length
|
|
881
|
+
}, c.push(d)), d.coupons.push(o);
|
|
882
|
+
const { qty: g, subTotal: f } = a;
|
|
883
|
+
if (e && !m && d.usedQty < g && f.value > 0) {
|
|
884
|
+
o.setOnHold(), n[l] = [
|
|
885
|
+
...n[l] || [],
|
|
886
|
+
o
|
|
864
887
|
];
|
|
865
|
-
const y =
|
|
866
|
-
Object.assign(a, y),
|
|
888
|
+
const y = $t({ updatedItem: a, currencyCode: i, coupon: o });
|
|
889
|
+
Object.assign(a, y), d.usedQty = n[l].length;
|
|
867
890
|
}
|
|
868
891
|
return c;
|
|
869
892
|
}, []);
|
|
870
893
|
}
|
|
871
|
-
function
|
|
872
|
-
t.length > 0 && (s.relatedCoupons =
|
|
894
|
+
function Fe(s, t, e, i) {
|
|
895
|
+
t.length > 0 && (s.relatedCoupons = Te(s, t, e, i));
|
|
873
896
|
}
|
|
874
|
-
class
|
|
897
|
+
class xe extends Dt {
|
|
875
898
|
constructor(t = {}) {
|
|
876
|
-
super(t), this.lines = t.lines, this.relatedTotalCoupons = t.relatedTotalCoupons, this.user = t.user;
|
|
899
|
+
super(t), this.lines = t.lines, this.relatedTotalCoupons = t.relatedTotalCoupons, this.registration = t.registration, this.user = t.user;
|
|
877
900
|
}
|
|
878
901
|
getResult() {
|
|
879
902
|
return {
|
|
@@ -882,33 +905,39 @@ class Se extends wt {
|
|
|
882
905
|
};
|
|
883
906
|
}
|
|
884
907
|
}
|
|
885
|
-
class
|
|
886
|
-
static getChainManager({ payload: t = {}, serviceAppName: e, type:
|
|
887
|
-
let
|
|
888
|
-
switch (
|
|
908
|
+
class qt {
|
|
909
|
+
static getChainManager({ payload: t = {}, serviceAppName: e, type: i } = {}) {
|
|
910
|
+
let r = [];
|
|
911
|
+
switch (i) {
|
|
889
912
|
case "CALCULATE_AMOUNT":
|
|
890
|
-
return
|
|
913
|
+
return r = Le(t), this.calculateAmount({ chains: r, payload: t, serviceAppName: e });
|
|
891
914
|
case "CALCULATE_AMOUNT_FOR_GROUP":
|
|
892
|
-
return
|
|
915
|
+
return r = Be(t), this.calculateAmount({ chains: r, payload: t, serviceAppName: e });
|
|
893
916
|
default:
|
|
894
917
|
throw new Error("invalid type");
|
|
895
918
|
}
|
|
896
919
|
}
|
|
897
|
-
static calculateAmount({ chains: t = [], payload: e = {}, serviceAppName:
|
|
920
|
+
static calculateAmount({ chains: t = [], payload: e = {}, serviceAppName: i }) {
|
|
898
921
|
const {
|
|
899
|
-
lines:
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
922
|
+
lines: r,
|
|
923
|
+
registration: n,
|
|
924
|
+
relatedTotalCoupons: a,
|
|
925
|
+
user: u
|
|
926
|
+
} = e, c = new xe({
|
|
927
|
+
lines: r,
|
|
928
|
+
registration: n || u,
|
|
929
|
+
relatedTotalCoupons: a,
|
|
930
|
+
user: u || {}
|
|
931
|
+
}), o = new Vt({ chainTarget: c });
|
|
932
|
+
return o.createChains({ chains: t }), o;
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
function Le(s) {
|
|
907
936
|
const {
|
|
908
937
|
autoUseCoupon: t,
|
|
909
938
|
categories: e,
|
|
910
|
-
currency:
|
|
911
|
-
dateTime:
|
|
939
|
+
currency: i,
|
|
940
|
+
dateTime: r,
|
|
912
941
|
entitlements: n,
|
|
913
942
|
// groupCategory,
|
|
914
943
|
merchandises: a,
|
|
@@ -916,95 +945,95 @@ function be(s) {
|
|
|
916
945
|
walletItems: c
|
|
917
946
|
} = s;
|
|
918
947
|
return [
|
|
919
|
-
new
|
|
920
|
-
new
|
|
948
|
+
new Ft(),
|
|
949
|
+
new ee({
|
|
921
950
|
// groupCategory,
|
|
922
951
|
categories: e,
|
|
923
952
|
walletItems: c
|
|
924
953
|
}),
|
|
925
|
-
new
|
|
926
|
-
new
|
|
927
|
-
new
|
|
928
|
-
new
|
|
929
|
-
new
|
|
930
|
-
currency:
|
|
931
|
-
dateTime:
|
|
954
|
+
new be({ products: u, walletItems: c }),
|
|
955
|
+
new Ie(),
|
|
956
|
+
new xt(),
|
|
957
|
+
new Lt({ products: u }),
|
|
958
|
+
new ae({
|
|
959
|
+
currency: i,
|
|
960
|
+
dateTime: r,
|
|
932
961
|
entitlements: n,
|
|
933
962
|
merchandises: a
|
|
934
963
|
}),
|
|
935
|
-
new
|
|
936
|
-
new
|
|
964
|
+
new Se({ currency: i, autoUseCoupon: t, walletItems: c }),
|
|
965
|
+
new Ae({ currency: i })
|
|
937
966
|
];
|
|
938
967
|
}
|
|
939
|
-
function
|
|
968
|
+
function Be(s) {
|
|
940
969
|
const {
|
|
941
970
|
currency: t,
|
|
942
971
|
dateTime: e,
|
|
943
|
-
entitlements:
|
|
944
|
-
merchandises:
|
|
972
|
+
entitlements: i,
|
|
973
|
+
merchandises: r,
|
|
945
974
|
products: n
|
|
946
975
|
} = s;
|
|
947
976
|
return [
|
|
948
|
-
new
|
|
949
|
-
new
|
|
950
|
-
new
|
|
951
|
-
new
|
|
977
|
+
new Ft(),
|
|
978
|
+
new xt(),
|
|
979
|
+
new Lt({ products: n }),
|
|
980
|
+
new me({
|
|
952
981
|
currency: t,
|
|
953
982
|
dateTime: e,
|
|
954
|
-
entitlements:
|
|
955
|
-
merchandises:
|
|
983
|
+
entitlements: i,
|
|
984
|
+
merchandises: r
|
|
956
985
|
})
|
|
957
986
|
];
|
|
958
987
|
}
|
|
959
|
-
const
|
|
988
|
+
const Me = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
960
989
|
__proto__: null,
|
|
961
|
-
ChainManagerFactory:
|
|
990
|
+
ChainManagerFactory: qt
|
|
962
991
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
963
|
-
function
|
|
992
|
+
function $e({ adminSettleFormData: s = {}, component: t, eventRegistration: e, invoice: i, payeeName: r, payeeAddress: n, payeeCountry: a, cb: u }) {
|
|
964
993
|
const c = e || t.registration;
|
|
965
|
-
t.invoice =
|
|
966
|
-
...
|
|
994
|
+
t.invoice = i, t.adminSettleFormData = {
|
|
995
|
+
...i,
|
|
967
996
|
...s,
|
|
968
997
|
email: c && c.getEmail() || "",
|
|
969
|
-
payeeName:
|
|
998
|
+
payeeName: r,
|
|
970
999
|
payeeAddress: n,
|
|
971
1000
|
payeeCountry: a,
|
|
972
1001
|
paidDate: (/* @__PURE__ */ new Date()).valueOf(),
|
|
973
|
-
totalAmount:
|
|
1002
|
+
totalAmount: qe(i)
|
|
974
1003
|
}, u();
|
|
975
1004
|
}
|
|
976
|
-
function
|
|
1005
|
+
function qe(s) {
|
|
977
1006
|
if (!s.amount)
|
|
978
1007
|
return "";
|
|
979
1008
|
const { amount: t } = s;
|
|
980
1009
|
return `${t.currencyCode} ${(t.value / 100).toFixed(2)}`;
|
|
981
1010
|
}
|
|
982
|
-
async function
|
|
983
|
-
const { currency: t, merchandises: e = [], lines:
|
|
984
|
-
lines:
|
|
1011
|
+
async function Ne(s) {
|
|
1012
|
+
const { currency: t, merchandises: e = [], lines: i, products: r, user: n } = s, a = {
|
|
1013
|
+
lines: i,
|
|
985
1014
|
merchandises: e,
|
|
986
|
-
products:
|
|
1015
|
+
products: r,
|
|
987
1016
|
currency: t,
|
|
988
1017
|
dateTime: Date.now(),
|
|
989
1018
|
categories: [],
|
|
990
1019
|
entitlements: [],
|
|
991
1020
|
walletItems: [],
|
|
992
1021
|
user: {}
|
|
993
|
-
}, u =
|
|
1022
|
+
}, u = qt.getChainManager({ payload: a, type: "CALCULATE_AMOUNT" });
|
|
994
1023
|
await u.handleRequest();
|
|
995
|
-
const { data: c = {}, err:
|
|
996
|
-
if (
|
|
997
|
-
throw
|
|
998
|
-
if ((c.lines || []).find((
|
|
1024
|
+
const { data: c = {}, err: o } = u.getResult();
|
|
1025
|
+
if (o)
|
|
1026
|
+
throw o;
|
|
1027
|
+
if ((c.lines || []).find((m) => Array.isArray(m.errors) && m.errors.length > 0))
|
|
999
1028
|
throw new Error("has invalid line");
|
|
1000
|
-
return { data: c, err:
|
|
1029
|
+
return { data: c, err: o };
|
|
1001
1030
|
}
|
|
1002
|
-
function
|
|
1031
|
+
function Nt(s) {
|
|
1003
1032
|
return s.charAt(0).toLowerCase() + s.slice(1);
|
|
1004
1033
|
}
|
|
1005
|
-
function
|
|
1006
|
-
const t = s.name, e = `${
|
|
1007
|
-
class
|
|
1034
|
+
function je(s) {
|
|
1035
|
+
const t = s.name, e = `${Nt(t)}Type`;
|
|
1036
|
+
class i extends s {
|
|
1008
1037
|
constructor(n) {
|
|
1009
1038
|
const a = n || {};
|
|
1010
1039
|
super(a), this[e] = a[e] || `${t}Event`;
|
|
@@ -1013,7 +1042,7 @@ function xe(s) {
|
|
|
1013
1042
|
return super.isValid;
|
|
1014
1043
|
}
|
|
1015
1044
|
static init(n) {
|
|
1016
|
-
const a = new
|
|
1045
|
+
const a = new i(n);
|
|
1017
1046
|
return a.isValid ? a : null;
|
|
1018
1047
|
}
|
|
1019
1048
|
static dummyData() {
|
|
@@ -1023,13 +1052,13 @@ function xe(s) {
|
|
|
1023
1052
|
};
|
|
1024
1053
|
}
|
|
1025
1054
|
}
|
|
1026
|
-
return
|
|
1055
|
+
return i;
|
|
1027
1056
|
}
|
|
1028
|
-
function
|
|
1057
|
+
function Ue() {
|
|
1029
1058
|
class s {
|
|
1030
1059
|
constructor(e) {
|
|
1031
|
-
const
|
|
1032
|
-
this._type = "Fake", this.fakeCode =
|
|
1060
|
+
const i = e || {};
|
|
1061
|
+
this._type = "Fake", this.fakeCode = i.fakeCode, this.fakeType = i.fakeType || "Fake";
|
|
1033
1062
|
}
|
|
1034
1063
|
static dummyData() {
|
|
1035
1064
|
return {
|
|
@@ -1037,8 +1066,8 @@ function Le() {
|
|
|
1037
1066
|
};
|
|
1038
1067
|
}
|
|
1039
1068
|
static init(e) {
|
|
1040
|
-
const
|
|
1041
|
-
return
|
|
1069
|
+
const i = new s(e);
|
|
1070
|
+
return i.isValid ? i : null;
|
|
1042
1071
|
}
|
|
1043
1072
|
get isValid() {
|
|
1044
1073
|
return !!this.fakeCode;
|
|
@@ -1046,88 +1075,88 @@ function Le() {
|
|
|
1046
1075
|
}
|
|
1047
1076
|
return s;
|
|
1048
1077
|
}
|
|
1049
|
-
class
|
|
1078
|
+
class Ge {
|
|
1050
1079
|
constructor(t = {}) {
|
|
1051
|
-
var e,
|
|
1052
|
-
this.mapping = (e = t.rule) == null ? void 0 : e.mapping, this.makeWalletItemHandler = t.makeWalletItemHandler, this.tiers = (
|
|
1080
|
+
var e, i;
|
|
1081
|
+
this.mapping = (e = t.rule) == null ? void 0 : e.mapping, this.makeWalletItemHandler = t.makeWalletItemHandler, this.tiers = (i = t.rule) == null ? void 0 : i.tiers;
|
|
1053
1082
|
}
|
|
1054
1083
|
get complimentaryCategories() {
|
|
1055
1084
|
return this.mapping.map((t) => t.key);
|
|
1056
1085
|
}
|
|
1057
1086
|
get countableCategories() {
|
|
1058
|
-
const t = this.mapping.reduce((e,
|
|
1059
|
-
const { value:
|
|
1060
|
-
return Array.isArray(
|
|
1087
|
+
const t = this.mapping.reduce((e, i) => {
|
|
1088
|
+
const { value: r } = i;
|
|
1089
|
+
return Array.isArray(r) && r.forEach((n) => e.add(n)), e;
|
|
1061
1090
|
}, /* @__PURE__ */ new Set());
|
|
1062
1091
|
return Array.from(t);
|
|
1063
1092
|
}
|
|
1064
1093
|
process({ walletItems: t }) {
|
|
1065
|
-
const { complimentaryWalletItems: e, countableWalletItems:
|
|
1094
|
+
const { complimentaryWalletItems: e, countableWalletItems: i } = Qe({
|
|
1066
1095
|
complimentaryCategories: this.complimentaryCategories,
|
|
1067
1096
|
countableCategories: this.countableCategories,
|
|
1068
1097
|
walletItems: t
|
|
1069
|
-
}),
|
|
1098
|
+
}), r = We({
|
|
1070
1099
|
tiers: this.tiers,
|
|
1071
|
-
total:
|
|
1072
|
-
}), { toBeAssignedItems: n, entitlements: a } =
|
|
1100
|
+
total: i.length
|
|
1101
|
+
}), { toBeAssignedItems: n, entitlements: a } = He({ complimentaryWalletItems: e, tier: r, countableWalletItems: i, mapping: this.mapping });
|
|
1073
1102
|
return {
|
|
1074
1103
|
walletItems: this.makeWalletItemHandler(n),
|
|
1075
1104
|
entitlements: a,
|
|
1076
|
-
tier:
|
|
1105
|
+
tier: r
|
|
1077
1106
|
};
|
|
1078
1107
|
}
|
|
1079
1108
|
}
|
|
1080
|
-
function
|
|
1081
|
-
const { numOfComplimentaryItem:
|
|
1082
|
-
const { productCode:
|
|
1083
|
-
return
|
|
1109
|
+
function He({ complimentaryWalletItems: s, tier: t, countableWalletItems: e, mapping: i }) {
|
|
1110
|
+
const { numOfComplimentaryItem: r } = t, n = r - s.length, a = e.map((o) => o.productCode), u = s.reduce((o, l) => {
|
|
1111
|
+
const { productCode: d } = l, m = o.get(d) || 0;
|
|
1112
|
+
return o.set(d, m + 1), o;
|
|
1084
1113
|
}, /* @__PURE__ */ new Map()), c = [];
|
|
1085
1114
|
if (n > 0) {
|
|
1086
|
-
const
|
|
1087
|
-
const { value:
|
|
1088
|
-
return
|
|
1089
|
-
}).key,
|
|
1090
|
-
u.set(
|
|
1091
|
-
productCode:
|
|
1115
|
+
const l = i.find((m) => {
|
|
1116
|
+
const { value: g } = m;
|
|
1117
|
+
return g.find((f) => a.includes(f));
|
|
1118
|
+
}).key, d = u.get(l) || 0;
|
|
1119
|
+
u.set(l, d + n), c.push({
|
|
1120
|
+
productCode: l,
|
|
1092
1121
|
qty: n
|
|
1093
1122
|
});
|
|
1094
1123
|
}
|
|
1095
1124
|
return {
|
|
1096
1125
|
toBeAssignedItems: c,
|
|
1097
|
-
entitlements: Array.from(u, ([
|
|
1126
|
+
entitlements: Array.from(u, ([o, l]) => ({ productCode: o, qty: l }))
|
|
1098
1127
|
};
|
|
1099
1128
|
}
|
|
1100
|
-
function
|
|
1129
|
+
function We({
|
|
1101
1130
|
tiers: s,
|
|
1102
1131
|
total: t
|
|
1103
1132
|
}) {
|
|
1104
|
-
const e = [...s].sort((
|
|
1105
|
-
let
|
|
1106
|
-
return e.forEach((
|
|
1107
|
-
t >=
|
|
1108
|
-
}),
|
|
1133
|
+
const e = [...s].sort((r, n) => r.gte - n.gte);
|
|
1134
|
+
let i = e[0];
|
|
1135
|
+
return e.forEach((r) => {
|
|
1136
|
+
t >= r.gte && (i = r);
|
|
1137
|
+
}), i;
|
|
1109
1138
|
}
|
|
1110
|
-
function
|
|
1139
|
+
function Qe({
|
|
1111
1140
|
complimentaryCategories: s,
|
|
1112
1141
|
countableCategories: t,
|
|
1113
1142
|
walletItems: e
|
|
1114
1143
|
}) {
|
|
1115
|
-
return e.reduce((
|
|
1116
|
-
const { productCode: n } =
|
|
1117
|
-
return s.includes(n) &&
|
|
1144
|
+
return e.reduce((i, r) => {
|
|
1145
|
+
const { productCode: n } = r;
|
|
1146
|
+
return s.includes(n) && i.complimentaryWalletItems.push(r), t.includes(n) && i.countableWalletItems.push(r), i;
|
|
1118
1147
|
}, {
|
|
1119
1148
|
complimentaryWalletItems: [],
|
|
1120
1149
|
countableWalletItems: []
|
|
1121
1150
|
});
|
|
1122
1151
|
}
|
|
1123
|
-
class
|
|
1152
|
+
class Ke {
|
|
1124
1153
|
constructor(t) {
|
|
1125
1154
|
this.makeWalletItemHandler = t.makeWalletItemHandler, this.rule = t.rule, this.type = t.type, this.handler = this.getHandler();
|
|
1126
1155
|
}
|
|
1127
1156
|
getHandler() {
|
|
1128
1157
|
switch (this.type) {
|
|
1129
1158
|
case "TIER_MAPPING":
|
|
1130
|
-
return new
|
|
1159
|
+
return new Ge({
|
|
1131
1160
|
rule: this.rule,
|
|
1132
1161
|
makeWalletItemHandler: this.makeWalletItemHandler
|
|
1133
1162
|
});
|
|
@@ -1137,30 +1166,30 @@ class Be {
|
|
|
1137
1166
|
return this.handler.process({ walletItems: t });
|
|
1138
1167
|
}
|
|
1139
1168
|
}
|
|
1140
|
-
function
|
|
1141
|
-
const e =
|
|
1169
|
+
function Ye({ newRoles: s, originalRoles: t }) {
|
|
1170
|
+
const e = At(s), i = At(t), r = /* @__PURE__ */ new Set([
|
|
1142
1171
|
...Object.keys(e),
|
|
1143
|
-
...Object.keys(
|
|
1172
|
+
...Object.keys(i)
|
|
1144
1173
|
]);
|
|
1145
|
-
return Array.from(
|
|
1146
|
-
const u = e[a] || 0, c =
|
|
1147
|
-
return
|
|
1174
|
+
return Array.from(r).reduce((n, a) => {
|
|
1175
|
+
const u = e[a] || 0, c = i[a] || 0, o = u - c;
|
|
1176
|
+
return o !== 0 && n.push({
|
|
1148
1177
|
key: a,
|
|
1149
1178
|
value: {
|
|
1150
|
-
delta:
|
|
1179
|
+
delta: o,
|
|
1151
1180
|
newValue: u,
|
|
1152
1181
|
originalValue: c
|
|
1153
1182
|
}
|
|
1154
1183
|
}), n;
|
|
1155
1184
|
}, []);
|
|
1156
1185
|
}
|
|
1157
|
-
function
|
|
1158
|
-
return s.reduce((t, e) => (e.getCouponCodes().forEach((
|
|
1159
|
-
const { key: n, value: a } =
|
|
1186
|
+
function At(s) {
|
|
1187
|
+
return s.reduce((t, e) => (e.getCouponCodes().forEach((r) => {
|
|
1188
|
+
const { key: n, value: a } = r;
|
|
1160
1189
|
t[n] = t[n] ? t[n] + a : a;
|
|
1161
1190
|
}), t), {});
|
|
1162
1191
|
}
|
|
1163
|
-
class
|
|
1192
|
+
class ke {
|
|
1164
1193
|
constructor(t) {
|
|
1165
1194
|
this.products = t.products || [], this.walletItems = t.walletItems || [], this.originalRoles = t.originalRoles || [], this.newRoles = t.newRoles || [];
|
|
1166
1195
|
}
|
|
@@ -1180,22 +1209,22 @@ class Ue {
|
|
|
1180
1209
|
return this.walletItems.filter((t) => t.isCoupon);
|
|
1181
1210
|
}
|
|
1182
1211
|
get roleRelatedCoupons() {
|
|
1183
|
-
return
|
|
1212
|
+
return Ye({ newRoles: this.newRoles, originalRoles: this.originalRoles });
|
|
1184
1213
|
}
|
|
1185
1214
|
get couponItemList() {
|
|
1186
1215
|
return this.couponProducts.map((t) => {
|
|
1187
1216
|
const e = this.walletItems.filter(
|
|
1188
|
-
(
|
|
1189
|
-
),
|
|
1190
|
-
|
|
1191
|
-
|
|
1217
|
+
(o) => o.productCode === t.productCode
|
|
1218
|
+
), i = e.filter((o) => o.isUsed);
|
|
1219
|
+
i.forEach((o) => {
|
|
1220
|
+
o.useForWalletItems = this.walletItems.filter((l) => (o.useFor || []).includes(l.walletItemCode));
|
|
1192
1221
|
});
|
|
1193
|
-
const
|
|
1222
|
+
const r = e.filter((o) => !o.isAvailableCoupon), n = p.foundValueByKey(this.roleRelatedCoupons, t.productCode) || {}, a = t.maxPerWallet - (i.length + r.length), { qty: u, remarks: c } = ze({ product: t, availableCoupons: r, roleBase: n, remainingQuota: a });
|
|
1194
1223
|
return {
|
|
1195
1224
|
product: t,
|
|
1196
|
-
usedCoupons:
|
|
1197
|
-
availableCoupons:
|
|
1198
|
-
alreadyHave:
|
|
1225
|
+
usedCoupons: i,
|
|
1226
|
+
availableCoupons: r,
|
|
1227
|
+
alreadyHave: i.length + r.length,
|
|
1199
1228
|
maxLimit: t.maxPerWallet,
|
|
1200
1229
|
remainingQuota: a,
|
|
1201
1230
|
qty: u,
|
|
@@ -1208,19 +1237,19 @@ class Ue {
|
|
|
1208
1237
|
this.newRoles = t;
|
|
1209
1238
|
}
|
|
1210
1239
|
}
|
|
1211
|
-
function
|
|
1212
|
-
const { delta:
|
|
1213
|
-
let a =
|
|
1240
|
+
function ze({ product: s, remainingQuota: t, availableCoupons: e, roleBase: i }) {
|
|
1241
|
+
const { delta: r = 0 } = i, { maxPerWallet: n } = s;
|
|
1242
|
+
let a = r;
|
|
1214
1243
|
const u = [];
|
|
1215
|
-
return
|
|
1244
|
+
return r > 0 && n && r > t && (a = 0, u.push(`max ${n}`)), r < 0 && n && e.length < r && (a = e.length, u.push(`only ${e.length} could be cancelled`)), {
|
|
1216
1245
|
qty: a,
|
|
1217
1246
|
remarks: u
|
|
1218
1247
|
};
|
|
1219
1248
|
}
|
|
1220
|
-
const
|
|
1249
|
+
const Je = [
|
|
1221
1250
|
"value"
|
|
1222
1251
|
];
|
|
1223
|
-
class
|
|
1252
|
+
class Q {
|
|
1224
1253
|
constructor(t = {}) {
|
|
1225
1254
|
t = t || {}, this.target = t.target, this.targetCode = t.targetCode, this.key = t.key, this.value = t.value || [];
|
|
1226
1255
|
}
|
|
@@ -1249,10 +1278,10 @@ class H {
|
|
|
1249
1278
|
static get _superclass() {
|
|
1250
1279
|
return "ItemOptionFillIn";
|
|
1251
1280
|
}
|
|
1252
|
-
static getItemOptionFillInsByTarget({ itemOptionFillIns: t = [], target: e, targetCode:
|
|
1281
|
+
static getItemOptionFillInsByTarget({ itemOptionFillIns: t = [], target: e, targetCode: i }) {
|
|
1253
1282
|
if (!e)
|
|
1254
1283
|
throw new Error("no target");
|
|
1255
|
-
return
|
|
1284
|
+
return i ? t.filter((r) => r.target === e && r.targetCode === i) : t.filter((r) => r.target === e);
|
|
1256
1285
|
}
|
|
1257
1286
|
get isValid() {
|
|
1258
1287
|
return !!this.target && !!this.targetCode && !!this.key;
|
|
@@ -1265,67 +1294,67 @@ class H {
|
|
|
1265
1294
|
}
|
|
1266
1295
|
update(t) {
|
|
1267
1296
|
return Object.keys(t).forEach((e) => {
|
|
1268
|
-
|
|
1297
|
+
Je.includes(e) && (this[e] = t[e]);
|
|
1269
1298
|
}), this;
|
|
1270
1299
|
}
|
|
1271
1300
|
}
|
|
1272
|
-
function
|
|
1301
|
+
function jt(s, t, e) {
|
|
1273
1302
|
e = e || {};
|
|
1274
|
-
let
|
|
1275
|
-
if (e.operation && e.props && (
|
|
1276
|
-
const { prop: a, compareFn: u } = n, c = typeof u == "function" ? u(s, t, a) :
|
|
1277
|
-
return
|
|
1303
|
+
let i;
|
|
1304
|
+
if (e.operation && e.props && (i = e.props.reduce((r, n) => {
|
|
1305
|
+
const { prop: a, compareFn: u } = n, c = typeof u == "function" ? u(s, t, a) : Ut(s, t, a);
|
|
1306
|
+
return r === null ? c : vt(c, r, e.operation);
|
|
1278
1307
|
}, null), e.subOperation && e.subOperation.operation)) {
|
|
1279
|
-
const
|
|
1280
|
-
|
|
1308
|
+
const r = jt(s, t, e.subOperation);
|
|
1309
|
+
i = vt(r, i, e.operation);
|
|
1281
1310
|
}
|
|
1282
|
-
return
|
|
1311
|
+
return i;
|
|
1283
1312
|
}
|
|
1284
|
-
function
|
|
1313
|
+
function Ut(s, t, e) {
|
|
1285
1314
|
return s[e] === null || s[e] === void 0 ? !1 : s[e] === t[e];
|
|
1286
1315
|
}
|
|
1287
|
-
function
|
|
1316
|
+
function Xe(s, t, e) {
|
|
1288
1317
|
if (s[e] === null || s[e] === void 0)
|
|
1289
1318
|
return !1;
|
|
1290
1319
|
if (!Array.isArray(s[e]) && !Array.isArray(t[e]))
|
|
1291
1320
|
throw new TypeError("This function can only compare array.");
|
|
1292
|
-
return
|
|
1321
|
+
return ss(s[e], t[e]) > 0;
|
|
1293
1322
|
}
|
|
1294
|
-
function
|
|
1323
|
+
function Ze(s, t, e) {
|
|
1295
1324
|
return s[e] === null || s[e] === void 0 ? !1 : s[e].isSame(t[e]);
|
|
1296
1325
|
}
|
|
1297
|
-
function
|
|
1326
|
+
function ts(s, t, e) {
|
|
1298
1327
|
if (s[e] === null || s[e] === void 0)
|
|
1299
1328
|
return !1;
|
|
1300
1329
|
if (!Array.isArray(s[e]) && !Array.isArray(t[e]))
|
|
1301
1330
|
throw new TypeError("This function can only compare array.");
|
|
1302
|
-
return s[e].reduce((
|
|
1303
|
-
const n =
|
|
1304
|
-
return
|
|
1331
|
+
return s[e].reduce((i, r) => {
|
|
1332
|
+
const n = r.isSameIn(t[e]);
|
|
1333
|
+
return i === null ? n : n && i;
|
|
1305
1334
|
}, null);
|
|
1306
1335
|
}
|
|
1307
|
-
function
|
|
1336
|
+
function es(s, t, e) {
|
|
1308
1337
|
if (s[e] === null || s[e] === void 0)
|
|
1309
1338
|
return !1;
|
|
1310
1339
|
if (!Array.isArray(s[e]) && !Array.isArray(t[e]))
|
|
1311
1340
|
throw new TypeError("This function can only compare array.");
|
|
1312
|
-
return s[e].length !== t[e].length ? !1 : s[e].reduce((
|
|
1313
|
-
const a =
|
|
1314
|
-
return
|
|
1341
|
+
return s[e].length !== t[e].length ? !1 : s[e].reduce((i, r, n) => {
|
|
1342
|
+
const a = r.isSame(t[e][n]);
|
|
1343
|
+
return i === null ? a : a && i;
|
|
1315
1344
|
}, null);
|
|
1316
1345
|
}
|
|
1317
|
-
function
|
|
1346
|
+
function vt(s, t, e) {
|
|
1318
1347
|
if (e.toLowerCase() === "or")
|
|
1319
1348
|
return s || t;
|
|
1320
1349
|
if (e.toLowerCase() === "and")
|
|
1321
1350
|
return s && t;
|
|
1322
1351
|
throw new Error("The operation does not conform to the specification.");
|
|
1323
1352
|
}
|
|
1324
|
-
function
|
|
1353
|
+
function ss(s, t) {
|
|
1325
1354
|
const e = new Set(t);
|
|
1326
|
-
return s.filter((
|
|
1355
|
+
return s.filter((i) => e.has(i));
|
|
1327
1356
|
}
|
|
1328
|
-
const
|
|
1357
|
+
const is = "20200130", rs = [
|
|
1329
1358
|
{
|
|
1330
1359
|
data: [],
|
|
1331
1360
|
err: null,
|
|
@@ -1335,9 +1364,9 @@ const Ye = "20200130", Je = [
|
|
|
1335
1364
|
version: "20200130"
|
|
1336
1365
|
}
|
|
1337
1366
|
];
|
|
1338
|
-
class
|
|
1367
|
+
class ns {
|
|
1339
1368
|
constructor(t = {}) {
|
|
1340
|
-
this.standardResponseObj =
|
|
1369
|
+
this.standardResponseObj = as(t.responseVer);
|
|
1341
1370
|
}
|
|
1342
1371
|
// getters
|
|
1343
1372
|
get isValid() {
|
|
@@ -1345,97 +1374,97 @@ class ze {
|
|
|
1345
1374
|
}
|
|
1346
1375
|
// instance methods
|
|
1347
1376
|
standardizeResponse(t = {}) {
|
|
1348
|
-
let e,
|
|
1349
|
-
return t.message && (e = t.message), t.err && (
|
|
1377
|
+
let e, i;
|
|
1378
|
+
return t.message && (e = t.message), t.err && (i = {
|
|
1350
1379
|
hasError: !0,
|
|
1351
1380
|
message: t.err.message || t.err
|
|
1352
1381
|
}), {
|
|
1353
1382
|
...this.standardResponseObj,
|
|
1354
1383
|
...t,
|
|
1355
|
-
err:
|
|
1384
|
+
err: i,
|
|
1356
1385
|
message: e
|
|
1357
1386
|
};
|
|
1358
1387
|
}
|
|
1359
1388
|
}
|
|
1360
|
-
function
|
|
1361
|
-
return s ?
|
|
1389
|
+
function as(s = is) {
|
|
1390
|
+
return s ? rs.find((t) => t.version === s) : null;
|
|
1362
1391
|
}
|
|
1363
|
-
function
|
|
1364
|
-
const t = new
|
|
1392
|
+
function us(s) {
|
|
1393
|
+
const t = new ns(s);
|
|
1365
1394
|
if (!t.isValid)
|
|
1366
1395
|
throw new TypeError("Invalid options for responseHelper");
|
|
1367
1396
|
return t;
|
|
1368
1397
|
}
|
|
1369
|
-
function
|
|
1370
|
-
const { clientApp: e } = s.state, { query:
|
|
1398
|
+
function cs({ ctx: s, ids: t }) {
|
|
1399
|
+
const { clientApp: e } = s.state, { query: i } = s.request, { id: r } = s.params;
|
|
1371
1400
|
if (s.isAuthenticated() && !e)
|
|
1372
1401
|
return {
|
|
1373
|
-
id:
|
|
1402
|
+
id: r,
|
|
1374
1403
|
ids: t,
|
|
1375
|
-
...
|
|
1404
|
+
...i
|
|
1376
1405
|
};
|
|
1377
1406
|
const n = e ? e.name : null;
|
|
1378
1407
|
return !n || n === "com.questwork.questwork-admin" ? {
|
|
1379
|
-
id:
|
|
1408
|
+
id: r,
|
|
1380
1409
|
ids: t,
|
|
1381
|
-
...
|
|
1410
|
+
...i
|
|
1382
1411
|
} : {
|
|
1383
|
-
id:
|
|
1412
|
+
id: r,
|
|
1384
1413
|
ids: t,
|
|
1385
|
-
...
|
|
1414
|
+
...i,
|
|
1386
1415
|
clientAppName: n
|
|
1387
1416
|
};
|
|
1388
1417
|
}
|
|
1389
|
-
function
|
|
1390
|
-
const e =
|
|
1391
|
-
return
|
|
1418
|
+
function os(s, t = 34) {
|
|
1419
|
+
const e = ds(t);
|
|
1420
|
+
return ls(s, e);
|
|
1392
1421
|
}
|
|
1393
|
-
function
|
|
1422
|
+
function ls(s, t) {
|
|
1394
1423
|
const e = t.byCode;
|
|
1395
1424
|
if (s === 0)
|
|
1396
1425
|
return e[0];
|
|
1397
|
-
let
|
|
1398
|
-
const
|
|
1426
|
+
let i = "";
|
|
1427
|
+
const r = t.length;
|
|
1399
1428
|
for (; s > 0; )
|
|
1400
|
-
|
|
1401
|
-
return
|
|
1429
|
+
i = e[s % r] + i, s = Math.floor(s / r);
|
|
1430
|
+
return i;
|
|
1402
1431
|
}
|
|
1403
|
-
function
|
|
1432
|
+
function ds(s) {
|
|
1404
1433
|
let t = "9876543210ABCDEFGHJKLMNPQRSTUVWXYZ";
|
|
1405
|
-
return s === 58 && (t = "9876543210ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz"),
|
|
1434
|
+
return s === 58 && (t = "9876543210ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz"), hs(t);
|
|
1406
1435
|
}
|
|
1407
|
-
function
|
|
1408
|
-
const t = {}, e = {},
|
|
1409
|
-
let
|
|
1410
|
-
for (
|
|
1411
|
-
n = s[
|
|
1412
|
-
return { byCode: t, byChar: e, length:
|
|
1436
|
+
function hs(s) {
|
|
1437
|
+
const t = {}, e = {}, i = s.length;
|
|
1438
|
+
let r, n;
|
|
1439
|
+
for (r = 0; r < i; r++)
|
|
1440
|
+
n = s[r], t[r] = n, e[n] = r;
|
|
1441
|
+
return { byCode: t, byChar: e, length: i };
|
|
1413
1442
|
}
|
|
1414
|
-
function
|
|
1415
|
-
const e = "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
|
|
1443
|
+
function ms({ len: s = 16, pattern: t = "a1" } = {}) {
|
|
1444
|
+
const e = "ABCDEFGHIJKLMNOPQRSTUVWXYZ", i = "abcdefghijklmnopqrstuvwxyz", r = "1234567890", n = "~!@#$%^&*_+-=";
|
|
1416
1445
|
let a = "";
|
|
1417
|
-
t.includes("A") && (a += e), t.includes("a") && (a +=
|
|
1446
|
+
t.includes("A") && (a += e), t.includes("a") && (a += i), t.includes("1") && (a += r), t.includes("#") && (a += n);
|
|
1418
1447
|
const u = [...a];
|
|
1419
1448
|
return [...new Array(s)].map((c) => u[Math.random() * u.length | 0]).join``;
|
|
1420
1449
|
}
|
|
1421
|
-
function
|
|
1450
|
+
function ps(s) {
|
|
1422
1451
|
return typeof s != "string" && (s = s.toString()), s.split("").reverse().join("");
|
|
1423
1452
|
}
|
|
1424
|
-
function
|
|
1425
|
-
const t = (/* @__PURE__ */ new Date()).valueOf(), e =
|
|
1453
|
+
function gs(s = 34) {
|
|
1454
|
+
const t = (/* @__PURE__ */ new Date()).valueOf(), e = ms({
|
|
1426
1455
|
len: 8,
|
|
1427
1456
|
pattern: "1"
|
|
1428
|
-
}),
|
|
1429
|
-
return
|
|
1457
|
+
}), i = ps(`${t}${e}`);
|
|
1458
|
+
return os(i, s);
|
|
1430
1459
|
}
|
|
1431
|
-
const
|
|
1432
|
-
setCode:
|
|
1433
|
-
},
|
|
1460
|
+
const O = {
|
|
1461
|
+
setCode: gs
|
|
1462
|
+
}, fs = [
|
|
1434
1463
|
"label",
|
|
1435
1464
|
"locale",
|
|
1436
1465
|
"value"
|
|
1437
1466
|
];
|
|
1438
|
-
class
|
|
1467
|
+
class nt {
|
|
1439
1468
|
constructor(t = {}) {
|
|
1440
1469
|
t = t || {}, this.locale = t.locale, this.label = t.label, this.value = t.value || "";
|
|
1441
1470
|
}
|
|
@@ -1467,11 +1496,11 @@ class st {
|
|
|
1467
1496
|
}
|
|
1468
1497
|
update(t) {
|
|
1469
1498
|
return Object.keys(t).forEach((e) => {
|
|
1470
|
-
|
|
1499
|
+
fs.includes(e) && (this[e] = t[e]);
|
|
1471
1500
|
}), this;
|
|
1472
1501
|
}
|
|
1473
1502
|
}
|
|
1474
|
-
const
|
|
1503
|
+
const ys = [
|
|
1475
1504
|
"description",
|
|
1476
1505
|
"key",
|
|
1477
1506
|
"label",
|
|
@@ -1479,11 +1508,11 @@ const ds = [
|
|
|
1479
1508
|
"value",
|
|
1480
1509
|
"locales"
|
|
1481
1510
|
];
|
|
1482
|
-
class
|
|
1511
|
+
class T {
|
|
1483
1512
|
constructor(t = {}) {
|
|
1484
1513
|
t = t || {};
|
|
1485
1514
|
const { _ItemOptionLocale: e } = t._constructor || {};
|
|
1486
|
-
this._ItemOptionLocale = e && e._superclass ===
|
|
1515
|
+
this._ItemOptionLocale = e && e._superclass === nt._superclass ? e : nt, this.approved = t.approved || !1, this.description = t.description, this.itemOptionCode = Cs(t, "itemOptionCode"), this.itemOptionType = t.itemOptionType || "ItemOption", this.key = t.key, this.label = t.label, this.layout = t.layout, this.required = t.required || !1, this.type = t.type, this.value = t.value || "", this.locales = this._ItemOptionLocale.initOnlyValidFromArray(t.locales);
|
|
1487
1516
|
}
|
|
1488
1517
|
static dummyData() {
|
|
1489
1518
|
return {
|
|
@@ -1530,15 +1559,15 @@ class D {
|
|
|
1530
1559
|
}
|
|
1531
1560
|
update(t) {
|
|
1532
1561
|
return Object.keys(t).forEach((e) => {
|
|
1533
|
-
|
|
1562
|
+
ys.includes(e) && (e === "locales" ? this[e] = this._ItemOptionLocale.initOnlyValidFromArray(t[e]) : this[e] = t[e]);
|
|
1534
1563
|
}), this;
|
|
1535
1564
|
}
|
|
1536
1565
|
}
|
|
1537
|
-
function
|
|
1566
|
+
function Cs(s, t) {
|
|
1538
1567
|
const e = s || {};
|
|
1539
|
-
return e[t] ? e[t] :
|
|
1568
|
+
return e[t] ? e[t] : O.setCode();
|
|
1540
1569
|
}
|
|
1541
|
-
class
|
|
1570
|
+
class G {
|
|
1542
1571
|
constructor(t = {}) {
|
|
1543
1572
|
t = t || {}, this.description = t.description, this.header = t.header, this.key = t.key, this.type = t.type;
|
|
1544
1573
|
}
|
|
@@ -1570,11 +1599,11 @@ class j {
|
|
|
1570
1599
|
}
|
|
1571
1600
|
static convertToFormData(t = []) {
|
|
1572
1601
|
const e = {};
|
|
1573
|
-
return t.map((
|
|
1574
|
-
let
|
|
1575
|
-
|
|
1576
|
-
n.default && (e[
|
|
1577
|
-
}),
|
|
1602
|
+
return t.map((i) => {
|
|
1603
|
+
let r = !1;
|
|
1604
|
+
i.values.map((n) => {
|
|
1605
|
+
n.default && (e[i.key] = n.value, r = !0);
|
|
1606
|
+
}), r || (e[i.key] = "");
|
|
1578
1607
|
}), e;
|
|
1579
1608
|
}
|
|
1580
1609
|
static convertToInputs(t = []) {
|
|
@@ -1587,15 +1616,15 @@ class j {
|
|
|
1587
1616
|
}
|
|
1588
1617
|
static convertToPurchaseOptions(t = []) {
|
|
1589
1618
|
const e = [];
|
|
1590
|
-
return t.map((
|
|
1591
|
-
let
|
|
1592
|
-
|
|
1619
|
+
return t.map((i) => {
|
|
1620
|
+
let r = !1;
|
|
1621
|
+
i.values.map((n) => {
|
|
1593
1622
|
n.default && (e.push({
|
|
1594
|
-
key:
|
|
1623
|
+
key: i.key,
|
|
1595
1624
|
value: n.value
|
|
1596
|
-
}),
|
|
1597
|
-
}),
|
|
1598
|
-
key:
|
|
1625
|
+
}), r = !0);
|
|
1626
|
+
}), r || e.push({
|
|
1627
|
+
key: i.key,
|
|
1599
1628
|
value: ""
|
|
1600
1629
|
});
|
|
1601
1630
|
}), e;
|
|
@@ -1609,11 +1638,100 @@ class j {
|
|
|
1609
1638
|
});
|
|
1610
1639
|
}
|
|
1611
1640
|
}
|
|
1612
|
-
const
|
|
1641
|
+
const _s = [
|
|
1642
|
+
"allocatedAmount",
|
|
1643
|
+
"productCode"
|
|
1644
|
+
];
|
|
1645
|
+
class H {
|
|
1646
|
+
constructor(t = {}) {
|
|
1647
|
+
t = t || {};
|
|
1648
|
+
const { _Amount: e } = t._constructor || {};
|
|
1649
|
+
this._Amount = e && e._superclass === h._superclass ? e : h, this.allocatedAmount = this._Amount.init(t.allocatedAmount), this.productCode = t.productCode;
|
|
1650
|
+
}
|
|
1651
|
+
static dummyData() {
|
|
1652
|
+
return {
|
|
1653
|
+
allocatedAmount: h.dummyData(),
|
|
1654
|
+
productCode: "productCode"
|
|
1655
|
+
};
|
|
1656
|
+
}
|
|
1657
|
+
static init(t = {}) {
|
|
1658
|
+
if (t instanceof this)
|
|
1659
|
+
return t;
|
|
1660
|
+
const e = new this(t);
|
|
1661
|
+
return e.isValid ? e : null;
|
|
1662
|
+
}
|
|
1663
|
+
static initFromArray(t = []) {
|
|
1664
|
+
return Array.isArray(t) ? t.map((e) => this.init(e)) : [];
|
|
1665
|
+
}
|
|
1666
|
+
static initOnlyValidFromArray(t = []) {
|
|
1667
|
+
return this.initFromArray(t).filter((e) => e);
|
|
1668
|
+
}
|
|
1669
|
+
static get _classname() {
|
|
1670
|
+
return "AccountAllocation";
|
|
1671
|
+
}
|
|
1672
|
+
static get _superclass() {
|
|
1673
|
+
return "AccountAllocation";
|
|
1674
|
+
}
|
|
1675
|
+
get isValid() {
|
|
1676
|
+
return !!this.productCode && !!this.allocatedAmount && !!this.allocatedAmount.currencyCode && typeof this.allocatedAmount.value == "number";
|
|
1677
|
+
}
|
|
1678
|
+
update(t) {
|
|
1679
|
+
return Object.keys(t).forEach((e) => {
|
|
1680
|
+
_s.includes(e) && (e === "allocatedAmount" ? this[e] = this._Amount.init(t[e]) : this[e] = t[e]);
|
|
1681
|
+
}), this;
|
|
1682
|
+
}
|
|
1683
|
+
}
|
|
1684
|
+
const As = [
|
|
1685
|
+
"accountAllocations",
|
|
1686
|
+
"currencyCode"
|
|
1687
|
+
];
|
|
1688
|
+
class at {
|
|
1689
|
+
constructor(t = {}) {
|
|
1690
|
+
t = t || {};
|
|
1691
|
+
const { _AccountAllocation: e } = t._constructor || {};
|
|
1692
|
+
this._AccountAllocation = e && e._superclass === H._superclass ? e : H, this.accountAllocations = this._AccountAllocation.initOnlyValidFromArray(t.accountAllocations), this.currencyCode = t.currencyCode;
|
|
1693
|
+
}
|
|
1694
|
+
static dummyData() {
|
|
1695
|
+
return {
|
|
1696
|
+
accountAllocations: [H.dummyData()],
|
|
1697
|
+
currencyCode: "USD"
|
|
1698
|
+
};
|
|
1699
|
+
}
|
|
1700
|
+
static init(t = {}) {
|
|
1701
|
+
if (t instanceof this)
|
|
1702
|
+
return t;
|
|
1703
|
+
const e = new this(t);
|
|
1704
|
+
return e.isValid ? e : null;
|
|
1705
|
+
}
|
|
1706
|
+
static initFromArray(t = []) {
|
|
1707
|
+
return Array.isArray(t) ? t.map((e) => this.init(e)) : [];
|
|
1708
|
+
}
|
|
1709
|
+
static initOnlyValidFromArray(t = []) {
|
|
1710
|
+
return this.initFromArray(t).filter((e) => e);
|
|
1711
|
+
}
|
|
1712
|
+
static get _classname() {
|
|
1713
|
+
return "AccountAllocationGroup";
|
|
1714
|
+
}
|
|
1715
|
+
static get _superclass() {
|
|
1716
|
+
return "AccountAllocationGroup";
|
|
1717
|
+
}
|
|
1718
|
+
get isValid() {
|
|
1719
|
+
return !!this.currencyCode && this.accountAllocations.length > 0 && this.accountAllocations.every((t) => {
|
|
1720
|
+
var e;
|
|
1721
|
+
return ((e = t.allocatedAmount) == null ? void 0 : e.currencyCode) === this.currencyCode;
|
|
1722
|
+
});
|
|
1723
|
+
}
|
|
1724
|
+
update(t) {
|
|
1725
|
+
return Object.keys(t).forEach((e) => {
|
|
1726
|
+
As.includes(e) && (e === "accountAllocations" ? this[e] = this._AccountAllocation.initOnlyValidFromArray(t[e]) : this[e] = t[e]);
|
|
1727
|
+
}), this;
|
|
1728
|
+
}
|
|
1729
|
+
}
|
|
1730
|
+
const vs = [
|
|
1613
1731
|
"min",
|
|
1614
1732
|
"max"
|
|
1615
1733
|
];
|
|
1616
|
-
class
|
|
1734
|
+
class Ot {
|
|
1617
1735
|
constructor(t = {}) {
|
|
1618
1736
|
t = t || {}, this.max = t.max === null || t.max > 0 ? t.max : 1, this.min = t.min === null || t.min >= 0 ? t.min : 0;
|
|
1619
1737
|
}
|
|
@@ -1640,11 +1758,101 @@ class gt {
|
|
|
1640
1758
|
}
|
|
1641
1759
|
update(t) {
|
|
1642
1760
|
return Object.keys(t).forEach((e) => {
|
|
1643
|
-
|
|
1761
|
+
vs.includes(e) && (this[e] = t[e]);
|
|
1762
|
+
}), this;
|
|
1763
|
+
}
|
|
1764
|
+
}
|
|
1765
|
+
const Os = [
|
|
1766
|
+
"productCode",
|
|
1767
|
+
"unitAllocatedAmount"
|
|
1768
|
+
];
|
|
1769
|
+
class W {
|
|
1770
|
+
constructor(t = {}) {
|
|
1771
|
+
t = t || {};
|
|
1772
|
+
const { _Amount: e } = t._constructor || {};
|
|
1773
|
+
this._Amount = e && e._superclass === h._superclass ? e : h, this.productCode = t.productCode, this.unitAllocatedAmount = this._Amount.init(t.unitAllocatedAmount);
|
|
1774
|
+
}
|
|
1775
|
+
static dummyData() {
|
|
1776
|
+
return {
|
|
1777
|
+
productCode: "productCode",
|
|
1778
|
+
unitAllocatedAmount: h.dummyData()
|
|
1779
|
+
};
|
|
1780
|
+
}
|
|
1781
|
+
static init(t = {}) {
|
|
1782
|
+
if (t instanceof this)
|
|
1783
|
+
return t;
|
|
1784
|
+
const e = new this(t);
|
|
1785
|
+
return e.isValid ? e : null;
|
|
1786
|
+
}
|
|
1787
|
+
static initFromArray(t = []) {
|
|
1788
|
+
return Array.isArray(t) ? t.map((e) => this.init(e)) : [];
|
|
1789
|
+
}
|
|
1790
|
+
static initOnlyValidFromArray(t = []) {
|
|
1791
|
+
return this.initFromArray(t).filter((e) => e);
|
|
1792
|
+
}
|
|
1793
|
+
static get _classname() {
|
|
1794
|
+
return "RefundAccountAllocation";
|
|
1795
|
+
}
|
|
1796
|
+
static get _superclass() {
|
|
1797
|
+
return "RefundAccountAllocation";
|
|
1798
|
+
}
|
|
1799
|
+
get isValid() {
|
|
1800
|
+
return !!this.productCode && !!this.unitAllocatedAmount && !!this.unitAllocatedAmount.currencyCode && typeof this.unitAllocatedAmount.value == "number";
|
|
1801
|
+
}
|
|
1802
|
+
update(t) {
|
|
1803
|
+
return Object.keys(t).forEach((e) => {
|
|
1804
|
+
Os.includes(e) && (e === "unitAllocatedAmount" ? this[e] = this._Amount.init(t[e]) : this[e] = t[e]);
|
|
1805
|
+
}), this;
|
|
1806
|
+
}
|
|
1807
|
+
}
|
|
1808
|
+
const Ps = [
|
|
1809
|
+
"currencyCode",
|
|
1810
|
+
"refundAccountAllocations"
|
|
1811
|
+
];
|
|
1812
|
+
class ut {
|
|
1813
|
+
constructor(t = {}) {
|
|
1814
|
+
t = t || {};
|
|
1815
|
+
const { _RefundAccountAllocation: e } = t._constructor || {};
|
|
1816
|
+
this._RefundAccountAllocation = e && e._superclass === W._superclass ? e : W, this.currencyCode = t.currencyCode, this.refundAccountAllocations = this._RefundAccountAllocation.initOnlyValidFromArray(t.refundAccountAllocations);
|
|
1817
|
+
}
|
|
1818
|
+
static dummyData() {
|
|
1819
|
+
return {
|
|
1820
|
+
currencyCode: "USD",
|
|
1821
|
+
refundAccountAllocations: [W.dummyData()]
|
|
1822
|
+
};
|
|
1823
|
+
}
|
|
1824
|
+
static init(t = {}) {
|
|
1825
|
+
if (t instanceof this)
|
|
1826
|
+
return t;
|
|
1827
|
+
const e = new this(t);
|
|
1828
|
+
return e.isValid ? e : null;
|
|
1829
|
+
}
|
|
1830
|
+
static initFromArray(t = []) {
|
|
1831
|
+
return Array.isArray(t) ? t.map((e) => this.init(e)) : [];
|
|
1832
|
+
}
|
|
1833
|
+
static initOnlyValidFromArray(t = []) {
|
|
1834
|
+
return this.initFromArray(t).filter((e) => e);
|
|
1835
|
+
}
|
|
1836
|
+
static get _classname() {
|
|
1837
|
+
return "RefundAccountAllocationGroup";
|
|
1838
|
+
}
|
|
1839
|
+
static get _superclass() {
|
|
1840
|
+
return "RefundAccountAllocationGroup";
|
|
1841
|
+
}
|
|
1842
|
+
get isValid() {
|
|
1843
|
+
return !!this.currencyCode && this.refundAccountAllocations.length > 0 && this.refundAccountAllocations.every((t) => {
|
|
1844
|
+
var e;
|
|
1845
|
+
return ((e = t.unitAllocatedAmount) == null ? void 0 : e.currencyCode) === this.currencyCode;
|
|
1846
|
+
});
|
|
1847
|
+
}
|
|
1848
|
+
update(t) {
|
|
1849
|
+
return Object.keys(t).forEach((e) => {
|
|
1850
|
+
Ps.includes(e) && (e === "refundAccountAllocations" ? this[e] = this._RefundAccountAllocation.initOnlyValidFromArray(t[e]) : this[e] = t[e]);
|
|
1644
1851
|
}), this;
|
|
1645
1852
|
}
|
|
1646
1853
|
}
|
|
1647
|
-
const
|
|
1854
|
+
const bs = [
|
|
1855
|
+
"accountAllocationGroups",
|
|
1648
1856
|
"active",
|
|
1649
1857
|
"amounts",
|
|
1650
1858
|
"deductions",
|
|
@@ -1652,18 +1860,19 @@ const hs = [
|
|
|
1652
1860
|
"metadata",
|
|
1653
1861
|
"name",
|
|
1654
1862
|
"qtyPerTransaction",
|
|
1863
|
+
"refundAccountAllocationGroups",
|
|
1655
1864
|
"remarks"
|
|
1656
1865
|
];
|
|
1657
|
-
class
|
|
1866
|
+
class X {
|
|
1658
1867
|
constructor(t = {}) {
|
|
1659
1868
|
t = t || {};
|
|
1660
|
-
const {
|
|
1661
|
-
this.
|
|
1869
|
+
const { _AccountAllocationGroup: e, _Amount: i, _QtyPerTransaction: r, _RefundAccountAllocationGroup: n } = t._constructor || {};
|
|
1870
|
+
this._AccountAllocationGroup = e && e._superclass === at._superclass ? e : at, this._Amount = i && i._superclass === h._superclass ? i : h, this._QtyPerTransaction = r && r._superclass === Ot._superclass ? r : Ot, this._RefundAccountAllocationGroup = n && n._superclass === ut._superclass ? n : ut, this.accountAllocationGroups = this._AccountAllocationGroup.initOnlyValidFromArray(t.accountAllocationGroups), this.active = typeof t.active < "u" ? !!t.active : !0, this.amounts = this._Amount.initOnlyValidFromArray(t.amounts), this.deductions = this._Amount.initOnlyValidFromArray(t.deductions), this.discount = t.discount || 0, this.metadata = _.initOnlyValidFromArray(t.metadata), this.name = t.name, this.qtyPerTransaction = this._QtyPerTransaction.init(t.qtyPerTransaction), this.priceStrategyType = t.priceStrategyType || "PriceStrategy", this.refundAccountAllocationGroups = this._RefundAccountAllocationGroup.initOnlyValidFromArray(t.refundAccountAllocationGroups), this.remarks = p.initOnlyValidFromArray(t.remarks);
|
|
1662
1871
|
}
|
|
1663
1872
|
// class method
|
|
1664
1873
|
static dummyData() {
|
|
1665
1874
|
return {
|
|
1666
|
-
amounts: [
|
|
1875
|
+
amounts: [h.dummyData()],
|
|
1667
1876
|
name: "name"
|
|
1668
1877
|
};
|
|
1669
1878
|
}
|
|
@@ -1711,10 +1920,10 @@ class J {
|
|
|
1711
1920
|
// return this.priceStrategyType === priceStrategyType
|
|
1712
1921
|
// }
|
|
1713
1922
|
getAmount({ currencyCode: t, qty: e }) {
|
|
1714
|
-
const
|
|
1715
|
-
if (
|
|
1716
|
-
const { value:
|
|
1717
|
-
return
|
|
1923
|
+
const i = this.getAmountByCurrencyCode(t);
|
|
1924
|
+
if (i) {
|
|
1925
|
+
const { value: r } = i;
|
|
1926
|
+
return r * e;
|
|
1718
1927
|
}
|
|
1719
1928
|
return null;
|
|
1720
1929
|
}
|
|
@@ -1739,9 +1948,9 @@ class J {
|
|
|
1739
1948
|
return !(this.qtyPerTransaction.min > e || this._Amount.getAmountsByCurrencyCode(this.amounts, t).length === 0);
|
|
1740
1949
|
}
|
|
1741
1950
|
isMatchedRestrictions(t = {}) {
|
|
1742
|
-
return this.restrictions.length === 0 ? !0 : this.restrictions.reduce((
|
|
1743
|
-
const { key: n, value: a = {} } =
|
|
1744
|
-
return
|
|
1951
|
+
return this.restrictions.length === 0 ? !0 : this.restrictions.reduce((i, r) => {
|
|
1952
|
+
const { key: n, value: a = {} } = r;
|
|
1953
|
+
return i = i || ws(n, a, t), i;
|
|
1745
1954
|
}, !1) || !1;
|
|
1746
1955
|
}
|
|
1747
1956
|
isQtyValid(t) {
|
|
@@ -1750,14 +1959,14 @@ class J {
|
|
|
1750
1959
|
setRemarks(t) {
|
|
1751
1960
|
return Array.isArray(t) && (this.remarks = p.initFromArray(t)), this;
|
|
1752
1961
|
}
|
|
1753
|
-
toCalculatorRule({ currencyCode: t
|
|
1754
|
-
const
|
|
1962
|
+
toCalculatorRule({ currencyCode: t }) {
|
|
1963
|
+
const e = this.getAmountByCurrencyCode(t);
|
|
1755
1964
|
return {
|
|
1756
1965
|
deduction: 0,
|
|
1757
1966
|
discount: 0,
|
|
1758
1967
|
min: this.qtyPerTransaction.min,
|
|
1759
1968
|
max: this.qtyPerTransaction.max,
|
|
1760
|
-
value:
|
|
1969
|
+
value: e.value || e.default,
|
|
1761
1970
|
recursing: !1,
|
|
1762
1971
|
recursingStartQty: null,
|
|
1763
1972
|
priceStrategy: this
|
|
@@ -1765,30 +1974,30 @@ class J {
|
|
|
1765
1974
|
}
|
|
1766
1975
|
update(t) {
|
|
1767
1976
|
return Object.keys(t).forEach((e) => {
|
|
1768
|
-
|
|
1977
|
+
bs.includes(e) && (e === "amounts" || e === "deductions" ? this[e] = this._Amount.initOnlyValidFromArray(t[e]) : e === "qtyPerTransaction" ? this[e] = this._QtyPerTransaction.init(t[e]) : e === "accountAllocationGroups" ? this[e] = this._AccountAllocationGroup.initOnlyValidFromArray(t[e]) : e === "refundAccountAllocationGroups" ? this[e] = this._RefundAccountAllocationGroup.initOnlyValidFromArray(t[e]) : this[e] = t[e]);
|
|
1769
1978
|
}), this;
|
|
1770
1979
|
}
|
|
1771
1980
|
}
|
|
1772
|
-
function
|
|
1773
|
-
return Object.keys(t).reduce((
|
|
1774
|
-
const n =
|
|
1775
|
-
return
|
|
1981
|
+
function ws(s, t, e) {
|
|
1982
|
+
return Object.keys(t).reduce((i, r) => {
|
|
1983
|
+
const n = $.get(e[s], r), a = Object.keys(t[r]);
|
|
1984
|
+
return i = i && Gt(n, t[r], a, !0), i;
|
|
1776
1985
|
}, !0);
|
|
1777
1986
|
}
|
|
1778
|
-
function
|
|
1779
|
-
if (!
|
|
1780
|
-
return
|
|
1781
|
-
const
|
|
1782
|
-
return
|
|
1987
|
+
function Gt(s, t = {}, e = [], i = !0) {
|
|
1988
|
+
if (!i || e.length === 0)
|
|
1989
|
+
return i;
|
|
1990
|
+
const r = e.shift(), n = t[r];
|
|
1991
|
+
return i = Is({ action: r, formulaValue: n, val: s }), Gt(s, t, e, i);
|
|
1783
1992
|
}
|
|
1784
|
-
function
|
|
1993
|
+
function Is({ action: s, formulaValue: t, val: e }) {
|
|
1785
1994
|
switch (s) {
|
|
1786
1995
|
case "elemMatch":
|
|
1787
1996
|
case "$elemMatch":
|
|
1788
|
-
return (e || []).some((
|
|
1997
|
+
return (e || []).some((i) => Object.keys(t).filter((r) => Object.prototype.hasOwnProperty.call(i, r) && i[r] === t[r]).length > 0);
|
|
1789
1998
|
case "eq":
|
|
1790
1999
|
case "$eq":
|
|
1791
|
-
return
|
|
2000
|
+
return $.isEqual(e, t);
|
|
1792
2001
|
case "gt":
|
|
1793
2002
|
case "$gt":
|
|
1794
2003
|
return e > t;
|
|
@@ -1796,13 +2005,13 @@ function ps({ action: s, formulaValue: t, val: e }) {
|
|
|
1796
2005
|
case "$gte":
|
|
1797
2006
|
return e >= t;
|
|
1798
2007
|
case "$in":
|
|
1799
|
-
return Array.isArray(e) ? !!e.find((
|
|
2008
|
+
return Array.isArray(e) ? !!e.find((i) => t.includes(i)) : typeof e != "object" ? !!t.includes(e) : !1;
|
|
1800
2009
|
case "$nin":
|
|
1801
|
-
return Array.isArray(e) ? !e.some((
|
|
2010
|
+
return Array.isArray(e) ? !e.some((i) => t.includes(i)) : typeof e != "object" ? !t.includes(e) : !0;
|
|
1802
2011
|
case "$includes":
|
|
1803
2012
|
return e && e.includes(t);
|
|
1804
2013
|
case "$keyValue":
|
|
1805
|
-
return Array.isArray(e) ? e.find((
|
|
2014
|
+
return Array.isArray(e) ? e.find((i) => t.key === i.key && t.values.includes(i.value)) !== void 0 : e.key ? t.key === e.key && t.values.includes(e.value) : !1;
|
|
1806
2015
|
case "lt":
|
|
1807
2016
|
case "$lt":
|
|
1808
2017
|
return e < t;
|
|
@@ -1816,18 +2025,18 @@ function ps({ action: s, formulaValue: t, val: e }) {
|
|
|
1816
2025
|
return !0;
|
|
1817
2026
|
}
|
|
1818
2027
|
}
|
|
1819
|
-
const
|
|
2028
|
+
const Ss = [
|
|
1820
2029
|
"dateBegin",
|
|
1821
2030
|
"dateEnd",
|
|
1822
2031
|
"name",
|
|
1823
2032
|
"priceStrategies"
|
|
1824
2033
|
// 'roleCodes'
|
|
1825
2034
|
];
|
|
1826
|
-
class
|
|
2035
|
+
class V {
|
|
1827
2036
|
constructor(t) {
|
|
1828
2037
|
t = t || {};
|
|
1829
2038
|
const { _PriceStrategy: e } = t._constructor || {};
|
|
1830
|
-
this._PriceStrategy = e && e._superclass ===
|
|
2039
|
+
this._PriceStrategy = e && e._superclass === X._superclass ? e : X, this.created = t.created || (/* @__PURE__ */ new Date()).valueOf(), this.dateBegin = t.dateBegin || (/* @__PURE__ */ new Date()).valueOf(), this.dateEnd = t.dateEnd || null, this.modified = t.modified || (/* @__PURE__ */ new Date()).valueOf(), this.name = t.name || "", this.priceStrategies = this._PriceStrategy.initOnlyValidFromArray(t.priceStrategies), this.remarks = p.initOnlyValidFromArray(t.remarks);
|
|
1831
2040
|
}
|
|
1832
2041
|
// class method
|
|
1833
2042
|
// static getPricingsByCurrency(pricings, currency) {
|
|
@@ -1840,7 +2049,7 @@ class R {
|
|
|
1840
2049
|
name: "Standard",
|
|
1841
2050
|
dateBegin: (/* @__PURE__ */ new Date()).valueOf(),
|
|
1842
2051
|
dateEnd: (/* @__PURE__ */ new Date()).valueOf() + 1,
|
|
1843
|
-
priceStrategies: [
|
|
2052
|
+
priceStrategies: [X.dummyData()]
|
|
1844
2053
|
};
|
|
1845
2054
|
}
|
|
1846
2055
|
static init(t = {}) {
|
|
@@ -1862,7 +2071,7 @@ class R {
|
|
|
1862
2071
|
return "Price";
|
|
1863
2072
|
}
|
|
1864
2073
|
static getPricesByTime(t = [], e) {
|
|
1865
|
-
return t.filter((
|
|
2074
|
+
return t.filter((r) => r.isAvailableByDate(e));
|
|
1866
2075
|
}
|
|
1867
2076
|
// static getPricesByRoleCodes(prices = [], roleCodes = []) {
|
|
1868
2077
|
// if (roleCodes.length === 0) {
|
|
@@ -1889,21 +2098,21 @@ class R {
|
|
|
1889
2098
|
return this.priceStrategies.filter((e) => e.isMatchedRestrictions(t));
|
|
1890
2099
|
}
|
|
1891
2100
|
getStrategiesByCurrencyAndQty(t, e) {
|
|
1892
|
-
let
|
|
1893
|
-
return
|
|
2101
|
+
let i = this.getStrategiesByCurrencyCode(t, this.priceStrategies);
|
|
2102
|
+
return i = this.getStrategiesByQty(e, i), i;
|
|
1894
2103
|
}
|
|
1895
2104
|
getStrategiesByCurrencyCode(t, e) {
|
|
1896
|
-
return (e || this.priceStrategies).reduce((
|
|
2105
|
+
return (e || this.priceStrategies).reduce((r, n) => (n.hasCurrencyCode(t) && n.deductionHasCurrencyCode(t) && r.push(n), r), []);
|
|
1897
2106
|
}
|
|
1898
2107
|
getStrategiesByQty(t, e) {
|
|
1899
|
-
return (e || this.priceStrategies).reduce((
|
|
2108
|
+
return (e || this.priceStrategies).reduce((r, n) => (n.isQtyValid(t) && r.push(n), r), []);
|
|
1900
2109
|
}
|
|
1901
2110
|
isAvailableByDate(t) {
|
|
1902
2111
|
const e = t || (/* @__PURE__ */ new Date()).valueOf();
|
|
1903
2112
|
return e >= this.dateBegin && (e < this.dateEnd || this.dateEnd === null);
|
|
1904
2113
|
}
|
|
1905
2114
|
hasCurrencyCodeWithQty(t, e) {
|
|
1906
|
-
return this.priceStrategies.reduce((
|
|
2115
|
+
return this.priceStrategies.reduce((i, r) => (i = r.hasCurrencyCodeWithQty(t, e) ? !0 : i, i), !1);
|
|
1907
2116
|
}
|
|
1908
2117
|
// isMatchCurrency(currency) {
|
|
1909
2118
|
// return this.amount.currency === currency
|
|
@@ -1932,11 +2141,11 @@ class R {
|
|
|
1932
2141
|
}
|
|
1933
2142
|
update(t) {
|
|
1934
2143
|
return Object.keys(t).forEach((e) => {
|
|
1935
|
-
|
|
2144
|
+
Ss.includes(e) && (e === "remarks" ? this[e] = p.initOnlyValidFromArray(t[e]) : e === "priceStrategies" ? this[e] = this._PriceStrategy.initOnlyValidFromArray(t[e]) : this[e] = t[e]);
|
|
1936
2145
|
}), this.setModified();
|
|
1937
2146
|
}
|
|
1938
2147
|
}
|
|
1939
|
-
const
|
|
2148
|
+
const Rs = [
|
|
1940
2149
|
"couponDetails",
|
|
1941
2150
|
"description",
|
|
1942
2151
|
"entitlements",
|
|
@@ -1956,13 +2165,13 @@ const gs = [
|
|
|
1956
2165
|
"requiredProductCode",
|
|
1957
2166
|
"stock"
|
|
1958
2167
|
];
|
|
1959
|
-
class
|
|
2168
|
+
class D extends v {
|
|
1960
2169
|
constructor(t = {}) {
|
|
1961
2170
|
t = t || {}, super(t);
|
|
1962
2171
|
const { _ItemOption: e } = t._constructor || {};
|
|
1963
|
-
this._ItemOption = e && e._superclass ===
|
|
1964
|
-
const
|
|
1965
|
-
this.id =
|
|
2172
|
+
this._ItemOption = e && e._superclass === T ? e : T;
|
|
2173
|
+
const i = t._id || t.id;
|
|
2174
|
+
this.id = Vs(i), this._type = t._type || "Product", this.couponDetails = t.couponDetails, this.description = t.description || "", this.entitlements = t.entitlements, this.intangible = t.intangible || !1, this.limitPercentage = t.limitPercentage || 100, this.lineOptions = this._ItemOption.initOnlyValidFromArray(t.lineOptions), this.maxPerWallet = t.maxPerWallet || 1, this.name = t.name || "", this.originalStock = t.originalStock || 0, this.printable = t.printable || !1, this.printLayoutCodes = t.printLayoutCodes || [], this.printLayoutMappingCodes = t.printLayoutMappingCodes || [], this.productCategories = t.productCategories || [], this.productCode = Ds(t, "productCode"), this.productGroupName = typeof t.productGroupName < "u" ? t.productGroupName.toUpperCase() : t.productGroupName || "DEFAULT", this.productOptions = this._ItemOption.initOnlyValidFromArray(t.productOptions), this.productType = t.productType || "Product", this.requiredProductCode = t.requiredProductCode, this.stock = t.stock || 0;
|
|
1966
2175
|
}
|
|
1967
2176
|
// class method
|
|
1968
2177
|
static dummyData() {
|
|
@@ -2014,9 +2223,9 @@ class B extends O {
|
|
|
2014
2223
|
return this.maxPerWallet >= t;
|
|
2015
2224
|
}
|
|
2016
2225
|
checkProductItemOptions(t = []) {
|
|
2017
|
-
return
|
|
2018
|
-
const n =
|
|
2019
|
-
return a ? (a.isValidFillInValue(
|
|
2226
|
+
return Q.getItemOptionFillInsByTarget({ itemOptionFillIns: t, target: "Product", targetCode: this.productCode }).reduce((i, r) => {
|
|
2227
|
+
const n = r.getKey(), a = this.getProductOptionByKey(n);
|
|
2228
|
+
return a ? (a.isValidFillInValue(r.getValue()) || i.errMsgs.push(`the product(${this.productCode}) option's(${n}) fillInValue is invalid`), i) : (i.errMsgs.push(`options of the product(${this.productCode}) does not contain key: "${n}"`), i);
|
|
2020
2229
|
}, { errMsgs: [] });
|
|
2021
2230
|
}
|
|
2022
2231
|
getCode() {
|
|
@@ -2050,28 +2259,63 @@ class B extends O {
|
|
|
2050
2259
|
}
|
|
2051
2260
|
isQualified(t) {
|
|
2052
2261
|
const e = this.getMetadataValueByKey("RULES") || [];
|
|
2053
|
-
return e.length === 0 ? !0 : e.reduce((
|
|
2262
|
+
return e.length === 0 ? !0 : e.reduce((i, r) => i || wt(r, t, Es, p), !1);
|
|
2054
2263
|
}
|
|
2055
2264
|
isTicket() {
|
|
2056
2265
|
return !1;
|
|
2057
2266
|
}
|
|
2058
2267
|
update(t) {
|
|
2059
2268
|
return Object.keys(t).forEach((e) => {
|
|
2060
|
-
|
|
2269
|
+
Rs.includes(e) && (e === "productOptions" || e === "lineOptions" ? this[e] = this._ItemOption.initOnlyValidFromArray(t[e]) : this[e] = t[e]);
|
|
2061
2270
|
}), super.update(t);
|
|
2062
2271
|
}
|
|
2063
2272
|
}
|
|
2064
|
-
function
|
|
2273
|
+
function Vs(s) {
|
|
2065
2274
|
return s && typeof s.toString == "function" ? s.toString() : s;
|
|
2066
2275
|
}
|
|
2067
|
-
function
|
|
2276
|
+
function Ds(s, t) {
|
|
2068
2277
|
const e = s || {};
|
|
2069
|
-
return e[t] ? e[t] :
|
|
2278
|
+
return e[t] ? e[t] : O.setCode();
|
|
2070
2279
|
}
|
|
2071
|
-
function
|
|
2072
|
-
return
|
|
2280
|
+
function Es(s, t) {
|
|
2281
|
+
return It(s.split("."), t);
|
|
2073
2282
|
}
|
|
2074
|
-
const
|
|
2283
|
+
const Ts = [
|
|
2284
|
+
"billingAccountCode",
|
|
2285
|
+
"billingProjectCode"
|
|
2286
|
+
];
|
|
2287
|
+
class Fs extends D {
|
|
2288
|
+
constructor(t = {}) {
|
|
2289
|
+
t = t || {}, super(t), this.billingAccountCode = t.billingAccountCode, this.billingProjectCode = t.billingProjectCode, this.productType = "ProductBilling";
|
|
2290
|
+
}
|
|
2291
|
+
static dummyData() {
|
|
2292
|
+
return {
|
|
2293
|
+
...D.dummyData(),
|
|
2294
|
+
billingAccountCode: "billingAccountCode",
|
|
2295
|
+
billingProjectCode: "billingProjectCode",
|
|
2296
|
+
productType: "ProductBilling"
|
|
2297
|
+
};
|
|
2298
|
+
}
|
|
2299
|
+
static get _classname() {
|
|
2300
|
+
return "ProductBilling";
|
|
2301
|
+
}
|
|
2302
|
+
get isValid() {
|
|
2303
|
+
return super.isValid && !!this.billingAccountCode && !!this.billingProjectCode;
|
|
2304
|
+
}
|
|
2305
|
+
getPreservedData() {
|
|
2306
|
+
return {
|
|
2307
|
+
...super.getPreservedData(),
|
|
2308
|
+
billingAccountCode: this.billingAccountCode,
|
|
2309
|
+
billingProjectCode: this.billingProjectCode
|
|
2310
|
+
};
|
|
2311
|
+
}
|
|
2312
|
+
update(t) {
|
|
2313
|
+
return Object.keys(t).forEach((e) => {
|
|
2314
|
+
Ts.includes(e) && (this[e] = t[e]);
|
|
2315
|
+
}), super.update(t);
|
|
2316
|
+
}
|
|
2317
|
+
}
|
|
2318
|
+
const xs = [
|
|
2075
2319
|
"allowEditQty",
|
|
2076
2320
|
"allowEditUnitPrice",
|
|
2077
2321
|
"defaultCurrency",
|
|
@@ -2091,13 +2335,13 @@ const vs = [
|
|
|
2091
2335
|
"stock",
|
|
2092
2336
|
"visibleBy"
|
|
2093
2337
|
];
|
|
2094
|
-
class
|
|
2338
|
+
class R extends v {
|
|
2095
2339
|
constructor(t = {}) {
|
|
2096
2340
|
t = t || {}, super(t);
|
|
2097
|
-
const { _ItemOption: e, _ItemOptionFillIn:
|
|
2098
|
-
this._ItemOption = e && e._superclass ===
|
|
2341
|
+
const { _ItemOption: e, _ItemOptionFillIn: i, _MerchandiseOption: r, _Price: n, _Product: a } = t._constructor || {};
|
|
2342
|
+
this._ItemOption = e && e._superclass === T._superclass ? e : T, this._ItemOptionFillIn = i && i._superclass === Q._superclass ? i : Q, this._MerchandiseOption = r && r._superclass === G._superclass ? r : G, this._Price = n && n._superclass === V._superclass ? n : V, this._Product = a && a._superclass === D._superclass ? a : D, this._products = t._products || [], this._type = t._type || "Merchandise";
|
|
2099
2343
|
const u = t._id || t.id;
|
|
2100
|
-
this.id =
|
|
2344
|
+
this.id = Ms(u), this.allowEditQty = t.allowEditQty || !1, this.allowEditUnitPrice = t.allowEditUnitPrice || !1, this.defaultCurrency = t.defaultCurrency || "HKD", this.description = t.description, this.free = t.free || !1, this.intangible = t.intangible || !1, this.max = t.max || 1, this.merchandiseCategoryCodes = t.merchandiseCategoryCodes || [], this.merchandiseCode = Bs(t, "merchandiseCode"), this.merchandiseOptions = Ls(this, t), this.merchandiseType = t.merchandiseType || "Merchandise", this.name = t.name || "", this.prices = this._Price.initOnlyValidFromArray(t.prices), this.productCodes = t.productCodes || [], this.priority = t.priority || 100, this.sku = t.sku || "", this.stock = t.stock || 0, this.targets = t.targets || [];
|
|
2101
2345
|
}
|
|
2102
2346
|
// Class Mehtods
|
|
2103
2347
|
static dummyData() {
|
|
@@ -2106,13 +2350,13 @@ class V extends O {
|
|
|
2106
2350
|
sku: "20190430",
|
|
2107
2351
|
productCodes: ["123456"],
|
|
2108
2352
|
// merchandiseOptions: [MerchandiseOption.dummyData()],
|
|
2109
|
-
merchandiseOptions: [
|
|
2353
|
+
merchandiseOptions: [T.init({
|
|
2110
2354
|
itemOptionType: "ItemOptionText",
|
|
2111
2355
|
type: "TextInput",
|
|
2112
2356
|
key: "firstName",
|
|
2113
2357
|
label: "First Name"
|
|
2114
2358
|
})],
|
|
2115
|
-
prices: [
|
|
2359
|
+
prices: [V.dummyData()],
|
|
2116
2360
|
stock: 100,
|
|
2117
2361
|
tenantCode: "85223977000"
|
|
2118
2362
|
};
|
|
@@ -2133,7 +2377,7 @@ class V extends O {
|
|
|
2133
2377
|
get currentPrice() {
|
|
2134
2378
|
if (this.free)
|
|
2135
2379
|
return null;
|
|
2136
|
-
const t = Date.now(), e = this.prices.filter((
|
|
2380
|
+
const t = Date.now(), e = this.prices.filter((i) => i.isAvailableByDate(t));
|
|
2137
2381
|
if (e.length === 1)
|
|
2138
2382
|
return e[0];
|
|
2139
2383
|
if (e.length === 0)
|
|
@@ -2190,103 +2434,103 @@ class V extends O {
|
|
|
2190
2434
|
return this.stock >= t;
|
|
2191
2435
|
}
|
|
2192
2436
|
checkMerchandiseItemOptions(t = []) {
|
|
2193
|
-
return this._ItemOptionFillIn.getItemOptionFillInsByTarget({ itemOptionFillIns: t, target: "Merchandise", targetCode: this.merchandiseCode }).reduce((
|
|
2194
|
-
const n =
|
|
2195
|
-
return a ? (a.isValidFillInValue(
|
|
2437
|
+
return this._ItemOptionFillIn.getItemOptionFillInsByTarget({ itemOptionFillIns: t, target: "Merchandise", targetCode: this.merchandiseCode }).reduce((i, r) => {
|
|
2438
|
+
const n = r.getKey(), a = this.getMerchandiseOptionByKey(n);
|
|
2439
|
+
return a ? (a.isValidFillInValue(r.getValue()) || i.errMsgs.push(`the merchandise(${this.merchandiseCode}) option's(${n}) fillInValue is invalid`), i) : (i.errMsgs.push(`options of the merchandise(${this.merchandiseCode}) does not contain key: "${n}"`), i);
|
|
2196
2440
|
}, { errMsgs: [] });
|
|
2197
2441
|
}
|
|
2198
2442
|
checkProductsItemOptions(t = []) {
|
|
2199
|
-
return this.getProducts().reduce((e,
|
|
2200
|
-
const { errMsgs:
|
|
2201
|
-
return e.errMsgs.push(...
|
|
2443
|
+
return this.getProducts().reduce((e, i) => {
|
|
2444
|
+
const { errMsgs: r } = i.checkProductItemOptions(t);
|
|
2445
|
+
return e.errMsgs.push(...r), e;
|
|
2202
2446
|
}, { errMsgs: [] });
|
|
2203
2447
|
}
|
|
2204
2448
|
convertMerchandiseOptionsToFormData() {
|
|
2205
|
-
return
|
|
2449
|
+
return G.convertToFormData(this.merchandiseOptions);
|
|
2206
2450
|
}
|
|
2207
2451
|
convertMerchandiseOptionsToInputs() {
|
|
2208
|
-
return
|
|
2452
|
+
return G.convertToInputs(this.merchandiseOptions);
|
|
2209
2453
|
}
|
|
2210
2454
|
convertMerchandiseOptionsToPurchaseOptions() {
|
|
2211
|
-
return
|
|
2455
|
+
return G.convertToPurchaseOptions(this.merchandiseOptions);
|
|
2212
2456
|
}
|
|
2213
|
-
getAmountFromPrice({ cartItems: t, currency: e, dateTimestamp:
|
|
2457
|
+
getAmountFromPrice({ cartItems: t, currency: e, dateTimestamp: i = Date.now(), qty: r, roleCodes: n }) {
|
|
2214
2458
|
const a = {
|
|
2215
2459
|
cartItems: t,
|
|
2216
2460
|
errorMessages: [],
|
|
2217
2461
|
merchandise: this,
|
|
2218
2462
|
price: null,
|
|
2219
|
-
qty:
|
|
2463
|
+
qty: r,
|
|
2220
2464
|
value: null
|
|
2221
|
-
}, u = e || this.defaultCurrency, c = this.getPriceByTimeAndRoleCodes(
|
|
2465
|
+
}, u = e || this.defaultCurrency, c = this.getPriceByTimeAndRoleCodes(i, n);
|
|
2222
2466
|
if (!c)
|
|
2223
2467
|
return a.errorMessages.push("Can't get available price for you."), a;
|
|
2224
2468
|
a.price = c;
|
|
2225
|
-
const
|
|
2226
|
-
if (
|
|
2469
|
+
const o = c.getStrategiesByCurrencyAndQty(u, r);
|
|
2470
|
+
if (o.length === 0)
|
|
2227
2471
|
return a.errorMessages.push("Can't get available strategies from price."), a;
|
|
2228
|
-
const { convertedPriceStrategies:
|
|
2229
|
-
const C = y.toCalculatorRule({ currency: u, qty:
|
|
2230
|
-
return
|
|
2472
|
+
const { convertedPriceStrategies: l, maxQty: d } = o.reduce((f, y) => {
|
|
2473
|
+
const C = y.toCalculatorRule({ currency: u, qty: r });
|
|
2474
|
+
return f.convertedPriceStrategies.push(C), C.max === null && (f.maxQty = null), C.max !== null && f.maxQty !== null && (f.maxQty += C.max), f;
|
|
2231
2475
|
}, { convertedPriceStrategies: [], maxQty: 0 });
|
|
2232
|
-
if (
|
|
2233
|
-
return a.errorMessages.push(`Currently you can only purchase a maximum of ${
|
|
2234
|
-
let
|
|
2235
|
-
if (
|
|
2476
|
+
if (d !== null && d < r)
|
|
2477
|
+
return a.errorMessages.push(`Currently you can only purchase a maximum of ${d} pieces of this merchandise.`), a;
|
|
2478
|
+
let m = Y(r, l);
|
|
2479
|
+
if (m.length === 0)
|
|
2236
2480
|
return a.errorMessages.push("No amount"), a;
|
|
2237
|
-
|
|
2238
|
-
const [
|
|
2239
|
-
return
|
|
2481
|
+
m = m.sort((f, y) => f.value - y.value);
|
|
2482
|
+
const [g] = m;
|
|
2483
|
+
return g.qty > 0 ? (a.errorMessages.push("Exceed maximum quantity per transaction."), a) : g.qty < 0 ? (a.errorMessages.push("No amount."), a) : (a.value = g.value, a);
|
|
2240
2484
|
}
|
|
2241
|
-
getAvailableInfo({ cartItems: t, currency: e, dateTimestamp:
|
|
2485
|
+
getAvailableInfo({ cartItems: t, currency: e, dateTimestamp: i = Date.now(), roleCodes: r } = {}) {
|
|
2242
2486
|
const n = {
|
|
2243
2487
|
available: !1,
|
|
2244
2488
|
unavailableMessages: [],
|
|
2245
2489
|
merchandise: this,
|
|
2246
2490
|
cartItemInfos: [],
|
|
2247
2491
|
cartItems: t,
|
|
2248
|
-
qty: t.reduce((
|
|
2492
|
+
qty: t.reduce((l, d) => l + d.getQty(), 0)
|
|
2249
2493
|
};
|
|
2250
2494
|
this.stock < n.qty && n.unavailableMessages.push(`The quantity(${n.qty}) you selected is less than the stock(${this.stock}).`), this.isActive || n.unavailableMessages.push("Inactive."), this.isDeleted && n.unavailableMessages.push("Deleted.");
|
|
2251
|
-
const a = this.getPriceByTimeAndRoleCodes(
|
|
2495
|
+
const a = this.getPriceByTimeAndRoleCodes(i, r);
|
|
2252
2496
|
a || n.unavailableMessages.push("No available price for you in this time."), n.price = a;
|
|
2253
2497
|
const u = e || this.defaultCurrency;
|
|
2254
2498
|
a.getStrategiesByCurrencyAndQty(u, n.qty).length === 0 && n.unavailableMessages.push(`The price not support currency '${u}'.`);
|
|
2255
|
-
const { cartItemInfos: c, hasProblem:
|
|
2256
|
-
return n.cartItemInfos = c,
|
|
2499
|
+
const { cartItemInfos: c, hasProblem: o } = this.getItemOptionInfos(t);
|
|
2500
|
+
return n.cartItemInfos = c, o && n.unavailableMessages.push("Cart item has problem, please check."), n.unavailableMessages.length === 0 && (n.available = !0), n;
|
|
2257
2501
|
}
|
|
2258
2502
|
getBeginAndEndDates() {
|
|
2259
2503
|
const t = {
|
|
2260
2504
|
dateBegin: null,
|
|
2261
2505
|
dateEnd: null
|
|
2262
2506
|
};
|
|
2263
|
-
return this.prices.reduce((e,
|
|
2507
|
+
return this.prices.reduce((e, i) => ((!e.dateBegin || i.dateBegin > e.dateBegin) && (e.dateBegin = i.dateBegin), (!e.dateEnd || i.dateEnd <= e.dateEnd) && (e.dateEnd = i.dateEnd), e), t);
|
|
2264
2508
|
}
|
|
2265
2509
|
getCode() {
|
|
2266
2510
|
return this.merchandiseCode;
|
|
2267
2511
|
}
|
|
2268
|
-
getCurrentAmount({ currencyCode: t, payload: e, ignoreRestriction:
|
|
2512
|
+
getCurrentAmount({ currencyCode: t, payload: e, ignoreRestriction: i = !1 }) {
|
|
2269
2513
|
if (!this.currentPrice)
|
|
2270
2514
|
return null;
|
|
2271
|
-
let
|
|
2272
|
-
return
|
|
2515
|
+
let r = i ? this.currentPrice.priceStrategies : this.currentPrice.getStrategiesByRestrictions(e);
|
|
2516
|
+
return r = this.currentPrice.getStrategiesByCurrencyCode(t, r), r.length === 0 ? null : r[0].getAmountByCurrencyCode(t);
|
|
2273
2517
|
}
|
|
2274
2518
|
getCurrentPrice(t) {
|
|
2275
|
-
const e = t || Date.now(),
|
|
2276
|
-
return
|
|
2519
|
+
const e = t || Date.now(), i = this.getPricesByTime(e);
|
|
2520
|
+
return i.length === 1 ? i[0] : null;
|
|
2277
2521
|
}
|
|
2278
2522
|
getCurrentPriceByRoleCodes(t) {
|
|
2279
2523
|
const e = Date.now();
|
|
2280
|
-
let
|
|
2281
|
-
return
|
|
2524
|
+
let i = this.getPricesByTime(e);
|
|
2525
|
+
return i = V.getPricesByRoleCodes(i, t), i.length === 1 ? i[0] : null;
|
|
2282
2526
|
}
|
|
2283
2527
|
getItemOptionInfos(t = []) {
|
|
2284
|
-
return t.reduce((e,
|
|
2285
|
-
const
|
|
2528
|
+
return t.reduce((e, i) => {
|
|
2529
|
+
const r = i.getItemOptionFillIns(), n = {
|
|
2286
2530
|
available: !0,
|
|
2287
|
-
cartItem:
|
|
2531
|
+
cartItem: i,
|
|
2288
2532
|
unavailableMessages: []
|
|
2289
|
-
}, a = this.checkMerchandiseItemOptions(
|
|
2533
|
+
}, a = this.checkMerchandiseItemOptions(r), { errMsgs: u } = this.checkProductsItemOptions(r);
|
|
2290
2534
|
return n.unavailableMessages.push(...a.errMsgs), n.unavailableMessages.push(...u), n.available = !(n.unavailableMessages.length > 0), e.hasProblem = n.available ? e.hasProblem : !0, e.cartItemInfos.push(n), e;
|
|
2291
2535
|
}, { cartItemInfos: [], hasProblem: !1 });
|
|
2292
2536
|
}
|
|
@@ -2318,11 +2562,11 @@ class V extends O {
|
|
|
2318
2562
|
}
|
|
2319
2563
|
getPricesByTime(t) {
|
|
2320
2564
|
const e = t || Date.now();
|
|
2321
|
-
return
|
|
2565
|
+
return V.getPricesByTime(this.prices, e);
|
|
2322
2566
|
}
|
|
2323
2567
|
getPriceByTimeAndRoleCodes(t, e) {
|
|
2324
|
-
let
|
|
2325
|
-
return
|
|
2568
|
+
let i = this.getPricesByTime(t);
|
|
2569
|
+
return i = V.getPricesByRoleCodes(i, e), i.length === 1 ? i[0] : null;
|
|
2326
2570
|
}
|
|
2327
2571
|
getProducts() {
|
|
2328
2572
|
return this.products || [];
|
|
@@ -2331,7 +2575,7 @@ class V extends O {
|
|
|
2331
2575
|
return this.products.map((e) => e.getMetadataValueByKey(t)).filter((e) => e);
|
|
2332
2576
|
}
|
|
2333
2577
|
getProductsQty(t = 1) {
|
|
2334
|
-
return this.productCodes.reduce((e,
|
|
2578
|
+
return this.productCodes.reduce((e, i) => (e[i] ? e[i] += 1 * t : e[i] = 1 * t, e), {});
|
|
2335
2579
|
}
|
|
2336
2580
|
getRemarksByKey(t) {
|
|
2337
2581
|
return p.getValuesByKey(this.remarks, t);
|
|
@@ -2340,45 +2584,121 @@ class V extends O {
|
|
|
2340
2584
|
return this.stock || 0;
|
|
2341
2585
|
}
|
|
2342
2586
|
getSummary(t) {
|
|
2343
|
-
|
|
2587
|
+
const e = this.getCurrentAmount(t);
|
|
2588
|
+
return e ? {
|
|
2344
2589
|
...this.summary,
|
|
2345
|
-
currentAmount:
|
|
2346
|
-
};
|
|
2590
|
+
currentAmount: e
|
|
2591
|
+
} : null;
|
|
2347
2592
|
}
|
|
2348
2593
|
reachLimit(t) {
|
|
2349
2594
|
return this.max < t;
|
|
2350
2595
|
}
|
|
2351
2596
|
setPrices(t) {
|
|
2352
|
-
return Array.isArray(t) && (this.prices =
|
|
2597
|
+
return Array.isArray(t) && (this.prices = this._Price.initOnlyValidFromArray(t)), this.setModified();
|
|
2353
2598
|
}
|
|
2354
2599
|
update(t) {
|
|
2355
2600
|
return Object.keys(t).forEach((e) => {
|
|
2356
|
-
|
|
2601
|
+
xs.includes(e) && (e === "merchandiseOptions" && this.tenantCode ? this[e] = this._ItemOption.initOnlyValidFromArray(t[e]) : e === "merchandiseOptions" && this.tenantCode ? this[e] = G.initOnlyValidFromArray(t[e]) : e === "prices" ? this[e] = this._Price.initOnlyValidFromArray(t[e]) : this[e] = t[e]);
|
|
2357
2602
|
}), super.update(t);
|
|
2358
2603
|
}
|
|
2359
2604
|
}
|
|
2360
|
-
function
|
|
2605
|
+
function Ls(s, t) {
|
|
2361
2606
|
return t.tenantCode ? s._ItemOption.initOnlyValidFromArray(t.merchandiseOptions) : s._MerchandiseOption.initOnlyValidFromArray(t.merchandiseOptions);
|
|
2362
2607
|
}
|
|
2363
|
-
function
|
|
2608
|
+
function Bs(s, t) {
|
|
2364
2609
|
const e = s || {};
|
|
2365
|
-
return e[t] ? e[t] :
|
|
2610
|
+
return e[t] ? e[t] : O.setCode();
|
|
2366
2611
|
}
|
|
2367
|
-
function
|
|
2612
|
+
function Ms(s) {
|
|
2368
2613
|
return s && typeof s.toString == "function" ? s.toString() : s;
|
|
2369
2614
|
}
|
|
2370
|
-
const
|
|
2615
|
+
const $s = [
|
|
2616
|
+
"billingAccountCode",
|
|
2617
|
+
"billingProjectCode",
|
|
2618
|
+
"bussinessUnits",
|
|
2619
|
+
"orderExpiryMs",
|
|
2620
|
+
"orderInvalidMs",
|
|
2621
|
+
"unsupportedPaymentGatewayCodes"
|
|
2622
|
+
];
|
|
2623
|
+
class qs extends R {
|
|
2624
|
+
constructor(t = {}) {
|
|
2625
|
+
t = t || {}, super(t);
|
|
2626
|
+
const { _BillingAccount: e, _BillingProject: i } = t._constructor || {};
|
|
2627
|
+
this._BillingAccount = e, this._BillingProject = i, this._billingAccount = t._billingAccount, this._billingProject = t._billingProject, this.billingAccountCode = t.billingAccountCode, this.billingProjectCode = t.billingProjectCode, this.bussinessUnits = t.bussinessUnits || [], this.merchandiseType = "MerchandiseBilling", this.orderExpiryMs = t.orderExpiryMs || null, this.orderInvalidMs = t.orderInvalidMs || null, this.unsupportedPaymentGatewayCodes = t.unsupportedPaymentGatewayCodes || [];
|
|
2628
|
+
}
|
|
2629
|
+
static get _classname() {
|
|
2630
|
+
return "MerchandiseBilling";
|
|
2631
|
+
}
|
|
2632
|
+
get billingAccount() {
|
|
2633
|
+
return this._BillingAccount && typeof this._BillingAccount.init == "function" ? this._BillingAccount.init(this._billingAccount) : this._billingAccount;
|
|
2634
|
+
}
|
|
2635
|
+
get billingProject() {
|
|
2636
|
+
return this._BillingProject && typeof this._BillingProject.init == "function" ? this._BillingProject.init(this._billingProject) : this._billingProject;
|
|
2637
|
+
}
|
|
2638
|
+
get isValid() {
|
|
2639
|
+
return super.isValid && !!this.billingProjectCode && this.hasValidBillingProducts && this.hasValidAccountAllocations && this.hasValidRefundAccountAllocations;
|
|
2640
|
+
}
|
|
2641
|
+
get hasValidBillingProducts() {
|
|
2642
|
+
return this.products.length === 0 ? !0 : this.products.every((t) => !!t.billingAccountCode && !!t.billingProjectCode);
|
|
2643
|
+
}
|
|
2644
|
+
get hasValidAccountAllocations() {
|
|
2645
|
+
return this.prices.length === 0 ? !1 : this.prices.every((t) => t.priceStrategies.every((e) => this.hasValidAccountAllocationsByStrategy(e)));
|
|
2646
|
+
}
|
|
2647
|
+
get hasValidRefundAccountAllocations() {
|
|
2648
|
+
return this.prices.every((t) => t.priceStrategies.every((e) => this.hasValidRefundAccountAllocationsByStrategy(e)));
|
|
2649
|
+
}
|
|
2650
|
+
getPreservedData() {
|
|
2651
|
+
return {
|
|
2652
|
+
...super.getPreservedData(),
|
|
2653
|
+
billingAccountCode: this.billingAccountCode,
|
|
2654
|
+
billingProjectCode: this.billingProjectCode,
|
|
2655
|
+
bussinessUnits: this.bussinessUnits,
|
|
2656
|
+
orderExpiryMs: this.orderExpiryMs,
|
|
2657
|
+
orderInvalidMs: this.orderInvalidMs,
|
|
2658
|
+
unsupportedPaymentGatewayCodes: this.unsupportedPaymentGatewayCodes
|
|
2659
|
+
};
|
|
2660
|
+
}
|
|
2661
|
+
hasValidAccountAllocationsByStrategy(t) {
|
|
2662
|
+
const { accountAllocationGroups: e = [], amounts: i = [] } = t, r = i.map((n) => n.currencyCode);
|
|
2663
|
+
return e.length === 0 || this.hasDuplicateCurrencies(e) || !e.every((n) => r.includes(n.currencyCode)) ? !1 : i.every((n) => {
|
|
2664
|
+
const { currencyCode: a, value: u } = n, c = e.find((l) => l.currencyCode === a);
|
|
2665
|
+
return c ? c.accountAllocations.reduce((l, d) => !d || !this.productCodes.includes(d.productCode) ? Number.NaN : l + d.allocatedAmount.value, 0) === u : !1;
|
|
2666
|
+
});
|
|
2667
|
+
}
|
|
2668
|
+
hasValidRefundAccountAllocationsByStrategy(t) {
|
|
2669
|
+
const { amounts: e = [], refundAccountAllocationGroups: i = [] } = t;
|
|
2670
|
+
if (i.length === 0)
|
|
2671
|
+
return !0;
|
|
2672
|
+
if (this.hasDuplicateCurrencies(i))
|
|
2673
|
+
return !1;
|
|
2674
|
+
const r = e.map((n) => n.currencyCode);
|
|
2675
|
+
return i.every((n) => !!n && r.includes(n.currencyCode) && n.refundAccountAllocations.every((a) => {
|
|
2676
|
+
var u, c;
|
|
2677
|
+
return !!a && this.productCodes.includes(a.productCode) && ((u = a.unitAllocatedAmount) == null ? void 0 : u.currencyCode) === n.currencyCode && typeof ((c = a.unitAllocatedAmount) == null ? void 0 : c.value) == "number";
|
|
2678
|
+
}));
|
|
2679
|
+
}
|
|
2680
|
+
hasDuplicateCurrencies(t = []) {
|
|
2681
|
+
const e = t.map((i) => i.currencyCode);
|
|
2682
|
+
return new Set(e).size !== e.length;
|
|
2683
|
+
}
|
|
2684
|
+
update(t) {
|
|
2685
|
+
return Object.keys(t).forEach((e) => {
|
|
2686
|
+
$s.includes(e) && (this[e] = t[e]);
|
|
2687
|
+
}), super.update(t);
|
|
2688
|
+
}
|
|
2689
|
+
}
|
|
2690
|
+
const Ns = [
|
|
2371
2691
|
"paidAmount",
|
|
2372
2692
|
"purchaseOptions",
|
|
2373
2693
|
"qty",
|
|
2374
2694
|
"itemOptionFillIns",
|
|
2375
2695
|
"remarks"
|
|
2376
2696
|
];
|
|
2377
|
-
class
|
|
2697
|
+
class Z {
|
|
2378
2698
|
constructor(t = {}) {
|
|
2379
2699
|
t = t || {};
|
|
2380
|
-
const { _Amount: e, _ItemOptionFillIn:
|
|
2381
|
-
this._Amount = e && e._superclass ===
|
|
2700
|
+
const { _Amount: e, _ItemOptionFillIn: i, _Merchandise: r } = t._constructor || {};
|
|
2701
|
+
this._Amount = e && e._superclass === h._superclass ? e : h, this._ItemOptionFillIn = i && i._superclass === Q._superclass ? i : Q, this._Merchandise = r && r._superclass === R._superclass ? r : R, this._merchandise = t._merchandise, this.cartItemCode = js(t, "cartItemCode"), this.created = t.created || (/* @__PURE__ */ new Date()).valueOf(), this.discount = this._Amount.init(t.discount), this.itemOptionFillIns = this._ItemOptionFillIn.initOnlyValidFromArray(t.itemOptionFillIns), this.merchandiseCode = t.merchandiseCode, this.metadata = _.initOnlyValidFromArray(t.metadata), this.price = this._Amount.init(t.price), this.purchaseOptions = p.initOnlyValidFromArray(t.purchaseOptions), this.qty = t.qty, this.remarks = p.initOnlyValidFromArray(t.remarks), this.subTotal = this._Amount.init(t.subTotal), this.waived = t.waived || 0;
|
|
2382
2702
|
}
|
|
2383
2703
|
// Class Methods
|
|
2384
2704
|
static dummyData() {
|
|
@@ -2406,10 +2726,10 @@ class z {
|
|
|
2406
2726
|
return "CartItem";
|
|
2407
2727
|
}
|
|
2408
2728
|
static getByMerchandiseCode(t = [], e) {
|
|
2409
|
-
return t.filter((
|
|
2729
|
+
return t.filter((i) => i.merchandiseCode === e);
|
|
2410
2730
|
}
|
|
2411
2731
|
static mergeDuplicateCartItems(t) {
|
|
2412
|
-
return
|
|
2732
|
+
return Ht(t);
|
|
2413
2733
|
}
|
|
2414
2734
|
get isValid() {
|
|
2415
2735
|
return !!this.merchandiseCode && this.qty > 0;
|
|
@@ -2460,30 +2780,30 @@ class z {
|
|
|
2460
2780
|
}
|
|
2461
2781
|
update(t) {
|
|
2462
2782
|
return Object.keys(t).forEach((e) => {
|
|
2463
|
-
|
|
2783
|
+
Ns.includes(e) && (e === "discount" || e === "price" || e === "subTotal" ? this[e] = this._Amount.init(t[e]) : e === "itemOptionFillIns" ? this[e] = this._ItemOptionFillIn.initOnlyValidFromArray(t[e]) : e === "metadata" ? this[e] = _.initOnlyValidFromArray(t[e]) : e === "purchaseOptions" || e === "remarks" ? this[e] = p.initOnlyValidFromArray(t[e]) : this[e] = t[e]);
|
|
2464
2784
|
}), this;
|
|
2465
2785
|
}
|
|
2466
2786
|
}
|
|
2467
|
-
function
|
|
2468
|
-
const e = s.shift(), { matched:
|
|
2469
|
-
if (
|
|
2470
|
-
return
|
|
2787
|
+
function Ht(s, t = []) {
|
|
2788
|
+
const e = s.shift(), { matched: i } = s.reduce((r, n) => {
|
|
2789
|
+
if (r.matched)
|
|
2790
|
+
return r;
|
|
2471
2791
|
if (e.merchandiseCode === n.merchandiseCode && e.itemOptionFillIns.length === n.itemOptionFillIns.length) {
|
|
2472
2792
|
const { itemOptionFillIns: a } = n;
|
|
2473
|
-
|
|
2793
|
+
$.intersectionWith(a, e.itemOptionFillIns, (c, o) => c.target === o.target && c.targetCode === o.targetCode && c.key === o.key && $.intersection(c.value, o.value).length === c.value.length).length === a.length && (r.matched = n);
|
|
2474
2794
|
}
|
|
2475
|
-
return
|
|
2795
|
+
return r;
|
|
2476
2796
|
}, { matched: null });
|
|
2477
|
-
return
|
|
2797
|
+
return i ? i.qty += e.qty : t.push(e), s.length === 0 ? t : Ht(s, t);
|
|
2478
2798
|
}
|
|
2479
|
-
function
|
|
2799
|
+
function js(s, t) {
|
|
2480
2800
|
const e = s || {};
|
|
2481
|
-
return e[t] ? e[t] :
|
|
2801
|
+
return e[t] ? e[t] : O.setCode();
|
|
2482
2802
|
}
|
|
2483
|
-
const
|
|
2803
|
+
const Us = [
|
|
2484
2804
|
"created"
|
|
2485
2805
|
];
|
|
2486
|
-
class
|
|
2806
|
+
class b {
|
|
2487
2807
|
constructor(t) {
|
|
2488
2808
|
t = t || {}, this.absent = t.absent || null, this.assigned = t.assigned || null, this.cancelled = t.cancelled || null, this.completed = t.completed || null, this.confirmed = t.confirmed || null, this.created = t.created || (/* @__PURE__ */ new Date()).valueOf(), this.delivered = t.delivered || null, this.expired = t.expired || null, this.failed = t.failed || null, this.onHold = t.onHold || null, this.processing = t.processing || null, this.paid = t.paid || null, this.payLater = t.payLater || null, this.pending = t.pending, this.redeemed = t.redeemed || null, this.refunded = t.refunded || null, this.refundRequested = t.refundRequested || null, this.rejected = t.rejected || null, this.shared = t.shared || null, this.submitted = t.submitted || null, this.terminated = t.terminated || null, this.used = t.used || null, this.waived = t.waived || null;
|
|
2489
2809
|
}
|
|
@@ -2595,10 +2915,10 @@ class I {
|
|
|
2595
2915
|
return this.statusList.length === 0 ? null : this.statusList[this.statusList.length - 1];
|
|
2596
2916
|
}
|
|
2597
2917
|
get statusList() {
|
|
2598
|
-
return Object.keys(this).reduce((e,
|
|
2599
|
-
key:
|
|
2600
|
-
value: this[
|
|
2601
|
-
}), e), []).sort((e,
|
|
2918
|
+
return Object.keys(this).reduce((e, i) => (this[i] && e.push({
|
|
2919
|
+
key: i,
|
|
2920
|
+
value: this[i]
|
|
2921
|
+
}), e), []).sort((e, i) => e.value > i.value ? 1 : -1);
|
|
2602
2922
|
}
|
|
2603
2923
|
// instance methods
|
|
2604
2924
|
allowCancel() {
|
|
@@ -2701,23 +3021,23 @@ class I {
|
|
|
2701
3021
|
}
|
|
2702
3022
|
update(t) {
|
|
2703
3023
|
return Object.keys(t).forEach((e) => {
|
|
2704
|
-
|
|
3024
|
+
Us.includes(e) || (this[e] = t[e]);
|
|
2705
3025
|
}), this;
|
|
2706
3026
|
}
|
|
2707
3027
|
}
|
|
2708
|
-
const
|
|
2709
|
-
class
|
|
3028
|
+
const Gs = [];
|
|
3029
|
+
class ct extends v {
|
|
2710
3030
|
constructor(t = {}) {
|
|
2711
3031
|
t = t || {}, super(t);
|
|
2712
|
-
const { _CartItem: e, _Merchandise:
|
|
2713
|
-
this._CartItem = e && e._superclass ===
|
|
3032
|
+
const { _CartItem: e, _Merchandise: i, _Status: r } = t._constructor || {};
|
|
3033
|
+
this._CartItem = e && e._superclass === Z._superclass ? e : Z, this._Merchandise = i && i._superclass === R._superclass ? i : R, this._Status = r && r._superclass === b._superclass ? r : b;
|
|
2714
3034
|
const n = t._id || t.id;
|
|
2715
|
-
this.id =
|
|
3035
|
+
this.id = Ws(n), this._merchandises = t._merchandises, this._type = t._type || "Cart", this.cartCode = Hs(t, "cartCode"), this.cartItems = this._CartItem.initOnlyValidFromArray(t.cartItems), this.status = this._Status.init(t.status);
|
|
2716
3036
|
}
|
|
2717
3037
|
// Class Methods
|
|
2718
3038
|
static dummyData() {
|
|
2719
3039
|
return {
|
|
2720
|
-
cartItems: [
|
|
3040
|
+
cartItems: [Z.dummyData()],
|
|
2721
3041
|
tenantCode: "tenantCode"
|
|
2722
3042
|
};
|
|
2723
3043
|
}
|
|
@@ -2739,34 +3059,34 @@ class rt extends O {
|
|
|
2739
3059
|
}
|
|
2740
3060
|
get merchandisesSummary() {
|
|
2741
3061
|
return this.merchandises.reduce((t, e) => {
|
|
2742
|
-
const
|
|
2743
|
-
return
|
|
3062
|
+
const i = t.find((r) => r.merchandiseCode === e.merchandiseCode);
|
|
3063
|
+
return i ? i.qty += 1 : t.push({
|
|
2744
3064
|
...e.summary,
|
|
2745
3065
|
qty: 1
|
|
2746
3066
|
}), t;
|
|
2747
3067
|
}, []);
|
|
2748
3068
|
}
|
|
2749
3069
|
// instance methods
|
|
2750
|
-
checkoutAvailable({ ownedWalletItems: t, selectCartItems: e, isCoordinator:
|
|
3070
|
+
checkoutAvailable({ ownedWalletItems: t, selectCartItems: e, isCoordinator: i = !1 }) {
|
|
2751
3071
|
try {
|
|
2752
|
-
return
|
|
2753
|
-
} catch (
|
|
2754
|
-
throw
|
|
3072
|
+
return i ? this.checkHasStock({ selectCartItems: e }) : this.checkHasStock({ selectCartItems: e }) && !this.checkWalletItemReachLimit({ ownedWalletItems: t, selectCartItems: e }) && !this.checkMerchandiseReachLimit({ selectCartItems: e });
|
|
3073
|
+
} catch (r) {
|
|
3074
|
+
throw r;
|
|
2755
3075
|
}
|
|
2756
3076
|
}
|
|
2757
3077
|
checkHasStock({ selectCartItems: t }) {
|
|
2758
3078
|
try {
|
|
2759
3079
|
return t.forEach((e) => {
|
|
2760
|
-
const { qty:
|
|
3080
|
+
const { qty: i } = e;
|
|
2761
3081
|
if (this.merchandises && this.merchandises.length === 0)
|
|
2762
3082
|
throw new Error("not have merchandises array object");
|
|
2763
|
-
const [
|
|
3083
|
+
const [r] = this.merchandises.filter((a) => a.merchandiseCode === e.merchandiseCode), { products: n } = r;
|
|
2764
3084
|
if (n && n.length === 0)
|
|
2765
3085
|
throw new Error("merchandise not have products array object");
|
|
2766
|
-
if (!
|
|
3086
|
+
if (!r.checkHasStock(i))
|
|
2767
3087
|
throw new Error("merchandise not enough stock");
|
|
2768
3088
|
n.forEach((a) => {
|
|
2769
|
-
if (!a.hasStock(
|
|
3089
|
+
if (!a.hasStock(i))
|
|
2770
3090
|
throw new Error("product not enough stock");
|
|
2771
3091
|
});
|
|
2772
3092
|
}), !0;
|
|
@@ -2776,25 +3096,25 @@ class rt extends O {
|
|
|
2776
3096
|
}
|
|
2777
3097
|
checkWalletItemReachLimit({ ownedWalletItems: t, selectCartItems: e }) {
|
|
2778
3098
|
try {
|
|
2779
|
-
return e.forEach((
|
|
2780
|
-
const { qty:
|
|
3099
|
+
return e.forEach((i) => {
|
|
3100
|
+
const { qty: r } = i, [n] = this.merchandises.filter((u) => u.merchandiseCode === i.merchandiseCode), { products: a } = n;
|
|
2781
3101
|
if (a && a.length === 0)
|
|
2782
3102
|
throw new Error("merchandise not have products array object");
|
|
2783
3103
|
a.forEach((u) => {
|
|
2784
|
-
const
|
|
2785
|
-
if (!u.ableToHave(
|
|
3104
|
+
const o = t.filter((l) => l.productCode === u.productCode).length || 0;
|
|
3105
|
+
if (!u.ableToHave(o + r))
|
|
2786
3106
|
throw new Error("walletItem reach limit");
|
|
2787
3107
|
});
|
|
2788
3108
|
}), !1;
|
|
2789
|
-
} catch (
|
|
2790
|
-
throw
|
|
3109
|
+
} catch (i) {
|
|
3110
|
+
throw i;
|
|
2791
3111
|
}
|
|
2792
3112
|
}
|
|
2793
3113
|
checkMerchandiseReachLimit({ selectCartItems: t }) {
|
|
2794
3114
|
try {
|
|
2795
3115
|
return t.forEach((e) => {
|
|
2796
|
-
const { qty:
|
|
2797
|
-
if (
|
|
3116
|
+
const { qty: i } = e, [r] = this.merchandises.filter((n) => n.merchandiseCode === e.merchandiseCode);
|
|
3117
|
+
if (i > r.max)
|
|
2798
3118
|
throw new Error("merchandise reach limit");
|
|
2799
3119
|
}), !1;
|
|
2800
3120
|
} catch (e) {
|
|
@@ -2822,14 +3142,14 @@ class rt extends O {
|
|
|
2822
3142
|
getCurrencyCode() {
|
|
2823
3143
|
return this.cartItems.length > 0 ? this.cartItems[0].getCurrencyCode() : null;
|
|
2824
3144
|
}
|
|
2825
|
-
getMerchandiseAvailableInfos({ cartItems: t, currency: e, roleCodes:
|
|
3145
|
+
getMerchandiseAvailableInfos({ cartItems: t, currency: e, roleCodes: i }) {
|
|
2826
3146
|
if (this.cartItems.length > 0 && this.merchandises.length === 0)
|
|
2827
3147
|
throw new Error("No merchandises");
|
|
2828
|
-
const
|
|
2829
|
-
if (t = t ||
|
|
3148
|
+
const r = this;
|
|
3149
|
+
if (t = t || r.cartItems, t = this._CartItem.initOnlyValidFromArray(t), t.length === 0)
|
|
2830
3150
|
throw new Error("No cartItems");
|
|
2831
|
-
return
|
|
2832
|
-
const u = this._CartItem.getByMerchandiseCode(t, a.merchandiseCode), c = a.getAvailableInfo({ cartItems: u, currency: e, roleCodes:
|
|
3151
|
+
return r.merchandises.reduce((n, a) => {
|
|
3152
|
+
const u = this._CartItem.getByMerchandiseCode(t, a.merchandiseCode), c = a.getAvailableInfo({ cartItems: u, currency: e, roleCodes: i });
|
|
2833
3153
|
return n.push(c), n;
|
|
2834
3154
|
}, []);
|
|
2835
3155
|
}
|
|
@@ -2868,87 +3188,82 @@ class rt extends O {
|
|
|
2868
3188
|
updateAvailable({ isCoordinator: t, selectCartItems: e }) {
|
|
2869
3189
|
try {
|
|
2870
3190
|
return t ? this.checkHasStock({ selectCartItems: e }) : this.checkHasStock({ selectCartItems: e }) && !this.checkMerchandiseReachLimit({ selectCartItems: e });
|
|
2871
|
-
} catch (
|
|
2872
|
-
throw
|
|
3191
|
+
} catch (i) {
|
|
3192
|
+
throw i;
|
|
2873
3193
|
}
|
|
2874
3194
|
}
|
|
2875
3195
|
update(t) {
|
|
2876
3196
|
return Object.keys(t).forEach((e) => {
|
|
2877
|
-
|
|
3197
|
+
Gs.includes(e) && (this[e] = t[e]);
|
|
2878
3198
|
}), super.update(t);
|
|
2879
3199
|
}
|
|
2880
3200
|
updateStock() {
|
|
2881
3201
|
if (this.cartItems.length === 0)
|
|
2882
3202
|
throw new Error("No cartItems");
|
|
2883
3203
|
let t = [], e = [];
|
|
2884
|
-
return this.cartItems.forEach((
|
|
2885
|
-
const { merchandiseCode:
|
|
2886
|
-
c.forEach((
|
|
2887
|
-
const
|
|
2888
|
-
|
|
3204
|
+
return this.cartItems.forEach((i) => {
|
|
3205
|
+
const { merchandiseCode: r, qty: n } = i, [a] = this.merchandises.filter((o) => o.merchandiseCode === r), u = a.stock - n, { products: c } = a;
|
|
3206
|
+
c.forEach((o) => {
|
|
3207
|
+
const l = o.stock - i.qty;
|
|
3208
|
+
o.updateProduct({ stock: l });
|
|
2889
3209
|
}), t = t.concat(c), a.update({ stock: u }), e = e.concat(a);
|
|
2890
3210
|
}), { newProducts: t, newMerchandises: e };
|
|
2891
3211
|
}
|
|
2892
3212
|
}
|
|
2893
|
-
function
|
|
3213
|
+
function Hs(s, t) {
|
|
2894
3214
|
const e = s || {};
|
|
2895
|
-
return e[t] ? e[t] :
|
|
3215
|
+
return e[t] ? e[t] : O.setCode();
|
|
2896
3216
|
}
|
|
2897
|
-
function
|
|
3217
|
+
function Ws(s) {
|
|
2898
3218
|
return s && typeof s.toString == "function" ? s.toString() : s;
|
|
2899
3219
|
}
|
|
2900
|
-
function
|
|
3220
|
+
function Wt(s) {
|
|
2901
3221
|
const {
|
|
2902
3222
|
delimiter: t = ": ",
|
|
2903
3223
|
key: e,
|
|
2904
|
-
purchaseOptions:
|
|
2905
|
-
tag:
|
|
3224
|
+
purchaseOptions: i,
|
|
3225
|
+
tag: r = "div"
|
|
2906
3226
|
} = s || {};
|
|
2907
3227
|
if (!e)
|
|
2908
|
-
return
|
|
2909
|
-
const c =
|
|
3228
|
+
return i.reduce((a, u) => {
|
|
3229
|
+
const c = Pt({
|
|
2910
3230
|
delimiter: t,
|
|
2911
3231
|
purchaseOption: u,
|
|
2912
|
-
tag:
|
|
3232
|
+
tag: r
|
|
2913
3233
|
});
|
|
2914
|
-
return
|
|
3234
|
+
return r ? a.push(`<${r}>${c.join("")}</${r}>`) : a.push(`${c.join("; ")}`), a;
|
|
2915
3235
|
}, []);
|
|
2916
|
-
const n = (
|
|
2917
|
-
return n ?
|
|
3236
|
+
const n = (i || []).find((a) => !!e && a.key === e);
|
|
3237
|
+
return n ? Pt({
|
|
2918
3238
|
delimiter: t,
|
|
2919
3239
|
purchaseOption: n,
|
|
2920
|
-
tag:
|
|
3240
|
+
tag: r
|
|
2921
3241
|
}) : [];
|
|
2922
3242
|
}
|
|
2923
|
-
function
|
|
3243
|
+
function Pt({
|
|
2924
3244
|
delimiter: s = ": ",
|
|
2925
3245
|
purchaseOption: t,
|
|
2926
3246
|
tag: e = "div"
|
|
2927
3247
|
}) {
|
|
2928
|
-
return (t.value || []).reduce((
|
|
2929
|
-
const { label: n, value: a = {} } =
|
|
2930
|
-
return Array.isArray(a) ? e ?
|
|
2931
|
-
e ?
|
|
2932
|
-
}) : e ?
|
|
3248
|
+
return (t.value || []).reduce((i, r) => {
|
|
3249
|
+
const { label: n, value: a = {} } = r || {}, u = n ?? "";
|
|
3250
|
+
return Array.isArray(a) ? e ? i.push(`<${e}>${u}${s}${a.join(s)}</${e}>`) : i.push(`${u}${s}${a.join(s)}`) : typeof a == "object" ? Object.keys(a).map((c) => {
|
|
3251
|
+
e ? i.push(`<${e}>${c}${s}${a[c]}</${e}>`) : i.push(`${c}${s}${a[c]}`);
|
|
3252
|
+
}) : e ? i.push(`<${e}>${u}${s}${a}</${e}>`) : i.push(`${u}${s}${a}`), i;
|
|
2933
3253
|
}, []);
|
|
2934
3254
|
}
|
|
2935
|
-
const
|
|
3255
|
+
const Qs = [
|
|
2936
3256
|
"label",
|
|
2937
3257
|
"logoUrl",
|
|
2938
3258
|
"name",
|
|
2939
3259
|
"sandbox",
|
|
2940
|
-
"setting"
|
|
2941
|
-
"surchargeBillingAccountCode",
|
|
2942
|
-
"surchargeBillingProjectCode",
|
|
2943
|
-
"surcharges"
|
|
3260
|
+
"setting"
|
|
2944
3261
|
];
|
|
2945
|
-
class
|
|
3262
|
+
class q extends v {
|
|
2946
3263
|
constructor(t = {}) {
|
|
2947
3264
|
t = t || {}, super(t);
|
|
2948
|
-
const
|
|
2949
|
-
this.
|
|
2950
|
-
const r = t._id || t.id;
|
|
2951
|
-
this.id = Ds(r), this._type = t._type || "PaymentGateway", this.hasWebhook = t.hasWebhook || !1, this.label = t.label, this.logoUrl = t.logoUrl, this.name = t.name || "", this.paymentGatewayCode = Ts(t, "paymentGatewayCode"), this.paymentGatewayType = t.paymentGatewayType || "PaymentGateway", this.paymentResultType = t.paymentResultType || "PaymentResult", this.sandbox = t.sandbox || !1, this.setting = t.setting || null, this.surchargeBillingAccountCode = t.surchargeBillingAccountCode, this.surchargeBillingProjectCode = t.surchargeBillingProjectCode, this.surcharges = this._Price.initOnlyValidFromArray(t.surcharges);
|
|
3265
|
+
const e = t._id || t.id;
|
|
3266
|
+
this.id = Ys(e), this._type = t._type || "PaymentGateway", this.hasWebhook = t.hasWebhook || !1, this.label = t.label, this.logoUrl = t.logoUrl, this.name = t.name || "", this.paymentGatewayCode = Ks(t, "paymentGatewayCode"), this.paymentGatewayType = t.paymentGatewayType || "PaymentGateway", this.paymentResultType = t.paymentResultType || "PaymentResult", this.sandbox = t.sandbox || !1, this.setting = t.setting || null;
|
|
2952
3267
|
}
|
|
2953
3268
|
static dummyData() {
|
|
2954
3269
|
return {
|
|
@@ -2990,18 +3305,60 @@ class G extends O {
|
|
|
2990
3305
|
}
|
|
2991
3306
|
update(t) {
|
|
2992
3307
|
return Object.keys(t).forEach((e) => {
|
|
2993
|
-
|
|
3308
|
+
Qs.includes(e) && (this[e] = t[e]);
|
|
2994
3309
|
}), super.update(t);
|
|
2995
3310
|
}
|
|
2996
3311
|
}
|
|
2997
|
-
function
|
|
3312
|
+
function Ks(s, t) {
|
|
2998
3313
|
const e = s || {};
|
|
2999
|
-
return e[t] ? e[t] :
|
|
3314
|
+
return e[t] ? e[t] : O.setCode();
|
|
3000
3315
|
}
|
|
3001
|
-
function
|
|
3316
|
+
function Ys(s) {
|
|
3002
3317
|
return s && typeof s.toString == "function" ? s.toString() : s;
|
|
3003
3318
|
}
|
|
3004
|
-
|
|
3319
|
+
const ks = [
|
|
3320
|
+
"clearingBillingAccountCode",
|
|
3321
|
+
"settlementDebitBillingAccountCode",
|
|
3322
|
+
"settlementFeeBillingAccountCode",
|
|
3323
|
+
"settlementFeeBillingProjectCode",
|
|
3324
|
+
"settlementFeeRate",
|
|
3325
|
+
"surchargeBillingAccountCode",
|
|
3326
|
+
"surchargeBillingProjectCode",
|
|
3327
|
+
"surchargeClearingBillingAccountCode",
|
|
3328
|
+
"surcharges"
|
|
3329
|
+
];
|
|
3330
|
+
class zs extends q {
|
|
3331
|
+
constructor(t = {}) {
|
|
3332
|
+
t = t || {}, super(t);
|
|
3333
|
+
const { _Price: e } = t._constructor || {};
|
|
3334
|
+
this._Price = e && e._superclass === V._superclass ? e : V, this.paymentGatewayType = "PaymentGatewayBilling", this.clearingBillingAccountCode = t.clearingBillingAccountCode, this.surchargeClearingBillingAccountCode = t.surchargeClearingBillingAccountCode, this.settlementDebitBillingAccountCode = t.settlementDebitBillingAccountCode, this.settlementFeeRate = t.settlementFeeRate || 0, this.settlementFeeBillingAccountCode = t.settlementFeeBillingAccountCode, this.settlementFeeBillingProjectCode = t.settlementFeeBillingProjectCode, this.surchargeBillingAccountCode = t.surchargeBillingAccountCode, this.surchargeBillingProjectCode = t.surchargeBillingProjectCode, this.surcharges = this._Price.initOnlyValidFromArray(t.surcharges);
|
|
3335
|
+
}
|
|
3336
|
+
static dummyData() {
|
|
3337
|
+
return {
|
|
3338
|
+
...q.dummyData(),
|
|
3339
|
+
paymentGatewayType: "PaymentGatewayBilling",
|
|
3340
|
+
settlementDebitBillingAccountCode: "settlementDebitBillingAccountCode"
|
|
3341
|
+
};
|
|
3342
|
+
}
|
|
3343
|
+
static get _classname() {
|
|
3344
|
+
return "PaymentGatewayBilling";
|
|
3345
|
+
}
|
|
3346
|
+
get hasSurcharge() {
|
|
3347
|
+
return this.surcharges.length > 0;
|
|
3348
|
+
}
|
|
3349
|
+
get isDeferred() {
|
|
3350
|
+
return !!this.clearingBillingAccountCode;
|
|
3351
|
+
}
|
|
3352
|
+
get isValid() {
|
|
3353
|
+
return super.isValid && !!this.settlementDebitBillingAccountCode && (!this.hasSurcharge || !!this.surchargeBillingAccountCode && !!this.surchargeBillingProjectCode);
|
|
3354
|
+
}
|
|
3355
|
+
update(t = {}) {
|
|
3356
|
+
return Object.keys(t).forEach((e) => {
|
|
3357
|
+
ks.includes(e) && (e === "surcharges" ? this[e] = this._Price.initOnlyValidFromArray(t[e]) : this[e] = t[e]);
|
|
3358
|
+
}), super.update(t);
|
|
3359
|
+
}
|
|
3360
|
+
}
|
|
3361
|
+
class E extends Kt {
|
|
3005
3362
|
constructor(t) {
|
|
3006
3363
|
t = t || {}, super(t), this.cancelled = this._ActionRecord.init(t.cancelled), this.completed = this._ActionRecord.init(t.completed), this.confirmed = this._ActionRecord.init(t.confirmed), this.deleted = this._ActionRecord.init(t.deleted), this.terminated = this._ActionRecord.init(t.terminated);
|
|
3007
3364
|
}
|
|
@@ -3058,7 +3415,7 @@ class T extends Ut {
|
|
|
3058
3415
|
// return super.update(update)
|
|
3059
3416
|
// }
|
|
3060
3417
|
}
|
|
3061
|
-
class
|
|
3418
|
+
class Js extends E {
|
|
3062
3419
|
constructor(t) {
|
|
3063
3420
|
t = t || {}, super(t), this.closed = this._ActionRecord.init(t.closed), this.open = this._ActionRecord.init(t.open), this.revised = this._ActionRecord.init(t.revised), this.void = this._ActionRecord.init(t.void);
|
|
3064
3421
|
}
|
|
@@ -3100,7 +3457,7 @@ class xs extends T {
|
|
|
3100
3457
|
return this.setValue(t, e, "void");
|
|
3101
3458
|
}
|
|
3102
3459
|
}
|
|
3103
|
-
class
|
|
3460
|
+
class Xs extends E {
|
|
3104
3461
|
constructor(t) {
|
|
3105
3462
|
t = t || {}, super(t), this.closed = this._ActionRecord.init(t.closed), this.open = this._ActionRecord.init(t.open), this.revised = this._ActionRecord.init(t.revised), this.void = this._ActionRecord.init(t.void);
|
|
3106
3463
|
}
|
|
@@ -3142,7 +3499,7 @@ class Ls extends T {
|
|
|
3142
3499
|
return this.setValue(t, e, "void");
|
|
3143
3500
|
}
|
|
3144
3501
|
}
|
|
3145
|
-
class
|
|
3502
|
+
class ot extends E {
|
|
3146
3503
|
constructor(t) {
|
|
3147
3504
|
t = t || {}, super(t), this.closed = this._ActionRecord.init(t.closed), this.expired = this._ActionRecord.init(t.expired), this.invalid = this._ActionRecord.init(t.invalid), this.open = this._ActionRecord.init(t.open);
|
|
3148
3505
|
}
|
|
@@ -3184,7 +3541,7 @@ class it extends T {
|
|
|
3184
3541
|
return this.setValue(t, e, "open");
|
|
3185
3542
|
}
|
|
3186
3543
|
}
|
|
3187
|
-
class
|
|
3544
|
+
class lt extends E {
|
|
3188
3545
|
constructor(t) {
|
|
3189
3546
|
t = t || {}, super(t), this.closed = this._ActionRecord.init(t.closed), this.expired = this._ActionRecord.init(t.expired), this.fulfilled = this._ActionRecord.init(t.fulfilled), this.invalid = this._ActionRecord.init(t.invalid), this.open = this._ActionRecord.init(t.open);
|
|
3190
3547
|
}
|
|
@@ -3244,16 +3601,16 @@ class nt extends T {
|
|
|
3244
3601
|
// return super.update(update)
|
|
3245
3602
|
// }
|
|
3246
3603
|
}
|
|
3247
|
-
const
|
|
3604
|
+
const Zs = [
|
|
3248
3605
|
"amount"
|
|
3249
3606
|
];
|
|
3250
|
-
class
|
|
3607
|
+
class dt extends v {
|
|
3251
3608
|
constructor(t) {
|
|
3252
3609
|
t = t || {}, super(t);
|
|
3253
|
-
const { _Amount: e, _PaymentGateway:
|
|
3254
|
-
this._Amount = e && e._superclass ===
|
|
3610
|
+
const { _Amount: e, _PaymentGateway: i, _Receipt: r, _ReceiptLine: n } = t._constructor || {};
|
|
3611
|
+
this._Amount = e && e._superclass === h._superclass ? e : h, this._PaymentGateway = i && i._superclass === q._superclass ? i : q, this._Receipt = r && r._superclass === j._superclass ? r : j, this._ReceiptLine = n && n._superclass === N._superclass ? n : N, this._paymentGateway = t._paymentGateway, this._receipt = t._receipt, this._receiptLine = t._receiptLine;
|
|
3255
3612
|
const a = t._id || t.id;
|
|
3256
|
-
this.id =
|
|
3613
|
+
this.id = ti(a), this._type = t._type || "PaymentCharge", this.amount = this._Amount.init(t.amount), this.billingAccountCode = t.billingAccountCode, this.billingProjectCode = t.billingProjectCode, this.paymentGatewayCode = t.paymentGatewayCode, this.paymentChargeCode = t.paymentChargeCode, this.paymentChargeType = "PaymentCharge", this.receiptCode = t.receiptCode, this.receiptDate = t.receiptDate || (/* @__PURE__ */ new Date()).valueOf(), this.receiptLineCode = t.receiptLineCode;
|
|
3257
3614
|
}
|
|
3258
3615
|
static dummyData() {
|
|
3259
3616
|
return {
|
|
@@ -3284,14 +3641,14 @@ class at extends O {
|
|
|
3284
3641
|
}
|
|
3285
3642
|
update(t) {
|
|
3286
3643
|
return Object.keys(t).forEach((e) => {
|
|
3287
|
-
|
|
3644
|
+
Zs.includes(e) && (e === "amount" ? this[e] = this.amount instanceof this._Amount ? this.amount.update(t[e]) : this._Amount.init(t[e]) : this[e] = t[e]);
|
|
3288
3645
|
}), super.update(t);
|
|
3289
3646
|
}
|
|
3290
3647
|
}
|
|
3291
|
-
function
|
|
3648
|
+
function ti(s) {
|
|
3292
3649
|
return s && typeof s.toString == "function" ? s.toString() : s;
|
|
3293
3650
|
}
|
|
3294
|
-
const
|
|
3651
|
+
const ei = [
|
|
3295
3652
|
"additionalData",
|
|
3296
3653
|
"amount",
|
|
3297
3654
|
"paidAmount",
|
|
@@ -3300,13 +3657,13 @@ const $s = [
|
|
|
3300
3657
|
"status",
|
|
3301
3658
|
"surcharge"
|
|
3302
3659
|
];
|
|
3303
|
-
class N extends
|
|
3660
|
+
class N extends v {
|
|
3304
3661
|
constructor(t) {
|
|
3305
3662
|
t = t || {}, super(t);
|
|
3306
|
-
const { _Amount: e, _PaymentCharge:
|
|
3307
|
-
this._Amount = e && e._superclass ===
|
|
3663
|
+
const { _Amount: e, _PaymentCharge: i, _PaymentItem: r, _Receipt: n, _Status: a } = t._constructor || {};
|
|
3664
|
+
this._Amount = e && e._superclass === h._superclass ? e : h, this._PaymentCharge = i && i._superclass === dt._superclass ? i : dt, this._PaymentItem = r && r._superclass === k._superclass ? r : k, this._Receipt = n && n._superclass === j._superclass ? n : j, this._Status = a && a._superclass === E._superclass ? a : E, this._paymentCharge = t._paymentCharge, this._paymentItems = t._paymentItems, this._receipt = t._receipt;
|
|
3308
3665
|
const u = t._id || t.id;
|
|
3309
|
-
this.id =
|
|
3666
|
+
this.id = si(u), this._type = t._type || "ReceiptLine", this.additionalData = p.initOnlyValidFromArray(t.additionalData), this.amount = this._Amount.init(t.amount), this.paidAmount = this._Amount.init(t.paidAmount), this.paymentGatewayCode = t.paymentGatewayCode, this.receiptCode = t.receiptCode, this.receiptDate = t.receiptDate || (/* @__PURE__ */ new Date()).valueOf(), this.receiptLineCode = t.receiptLineCode, this.receiptLineType = "ReceiptLine", this.status = this._Status.init(t.status), this.surcharge = this._Amount.init(t.surcharge);
|
|
3310
3667
|
}
|
|
3311
3668
|
static dummyData() {
|
|
3312
3669
|
return {
|
|
@@ -3361,14 +3718,14 @@ class N extends O {
|
|
|
3361
3718
|
}
|
|
3362
3719
|
update(t) {
|
|
3363
3720
|
return Object.keys(t).forEach((e) => {
|
|
3364
|
-
|
|
3721
|
+
ei.includes(e) && (e === "additionalData" ? this[e] = p.initOnlyValidFromArray(t[e]) : e === "status" ? this[e] = this[e] instanceof this._Status ? this[e].update(t[e]) : this._Status.init(t[e]) : e === "amount" || e === "paidAmount" || e === "surcharge" ? this[e] = this[e] instanceof this._Amount ? this[e].update(t[e]) : this._Amount.init(t[e]) : this[e] = t[e]);
|
|
3365
3722
|
}), super.update(t);
|
|
3366
3723
|
}
|
|
3367
3724
|
}
|
|
3368
|
-
function
|
|
3725
|
+
function si(s) {
|
|
3369
3726
|
return s && typeof s.toString == "function" ? s.toString() : s;
|
|
3370
3727
|
}
|
|
3371
|
-
const
|
|
3728
|
+
const ii = [
|
|
3372
3729
|
"amount",
|
|
3373
3730
|
"paidAmount",
|
|
3374
3731
|
"receiptDate",
|
|
@@ -3376,13 +3733,13 @@ const Bs = [
|
|
|
3376
3733
|
"status",
|
|
3377
3734
|
"surcharge"
|
|
3378
3735
|
];
|
|
3379
|
-
class
|
|
3736
|
+
class j extends v {
|
|
3380
3737
|
constructor(t) {
|
|
3381
3738
|
t = t || {}, super(t);
|
|
3382
|
-
const { _Amount: e, _ReceiptLine:
|
|
3383
|
-
this._Amount = e && e._superclass ===
|
|
3739
|
+
const { _Amount: e, _ReceiptLine: i, _Status: r } = t._constructor || {};
|
|
3740
|
+
this._Amount = e && e._superclass === h._superclass ? e : h, this._ReceiptLine = i && i._superclass === N._superclass ? i : N, this._Status = r && r._superclass === E._superclass ? r : E, this._receiptLines = t._receiptLines;
|
|
3384
3741
|
const n = t._id || t.id;
|
|
3385
|
-
this.id =
|
|
3742
|
+
this.id = ri(n), this._type = t._type || "Receipt", this.amount = this._Amount.init(t.amount), this.paidAmount = this._Amount.init(t.paidAmount), this.receiptCode = t.receiptCode, this.receiptDate = t.receiptDate || (/* @__PURE__ */ new Date()).valueOf(), this.receiptNumber = t.receiptNumber, this.receiptType = "Receipt", this.revisionNumber = t.revisionNumber || 1, this.status = this._Status.init(t.status), this.surcharge = this._Amount.init(t.surcharge);
|
|
3386
3743
|
}
|
|
3387
3744
|
static dummyData() {
|
|
3388
3745
|
return {
|
|
@@ -3436,23 +3793,23 @@ class U extends O {
|
|
|
3436
3793
|
}
|
|
3437
3794
|
update(t) {
|
|
3438
3795
|
return Object.keys(t).forEach((e) => {
|
|
3439
|
-
|
|
3796
|
+
ii.includes(e) && (e === "status" ? this[e] = this.status instanceof this._Status ? this.status.update(t[e]) : this._Status.init(t[e]) : e === "amount" || e === "paidAmount" || e === "surcharge" ? this[e] = this[e] instanceof this._Amount ? this[e].update(t[e]) : this._Amount.init(t[e]) : this[e] = t[e]);
|
|
3440
3797
|
}), super.update(t);
|
|
3441
3798
|
}
|
|
3442
3799
|
}
|
|
3443
|
-
function
|
|
3800
|
+
function ri(s) {
|
|
3444
3801
|
return s && typeof s.toString == "function" ? s.toString() : s;
|
|
3445
3802
|
}
|
|
3446
|
-
const
|
|
3803
|
+
const ni = [
|
|
3447
3804
|
"amount"
|
|
3448
3805
|
];
|
|
3449
|
-
class
|
|
3806
|
+
class k extends v {
|
|
3450
3807
|
constructor(t) {
|
|
3451
3808
|
t = t || {}, super(t);
|
|
3452
|
-
const { _Amount: e, _Invoice:
|
|
3453
|
-
this._Amount = e && e._superclass ===
|
|
3809
|
+
const { _Amount: e, _Invoice: i, _InvoiceLine: r, _PaymentGateway: n, _Receipt: a, _ReceiptLine: u } = t._constructor || {};
|
|
3810
|
+
this._Amount = e && e._superclass === h._superclass ? e : h, this._Invoice = i && i._superclass === K._superclass ? i : K, this._InvoiceLine = r && r._superclass === z._superclass ? r : z, this._PaymentGateway = n && n._superclass === q._superclass ? n : q, this._Receipt = a && a._superclass === j._superclass ? a : j, this._ReceiptLine = u && u._superclass === N._superclass ? u : N, this._invoice = t._invoice, this._invoiceLines = t._invoiceLines, this._paymentGateway = t._paymentGateway, this._receipt = t._receipt, this._receiptLine = t._receiptLine;
|
|
3454
3811
|
const c = t._id || t.id;
|
|
3455
|
-
this.id =
|
|
3812
|
+
this.id = ai(c), this._type = t._type || "PaymentItem", this.amount = this._Amount.init(t.amount), this.invoiceCode = t.invoiceCode, this.invoiceDate = t.invoiceDate || (/* @__PURE__ */ new Date()).valueOf(), this.invoiceLineCode = t.invoiceLineCode, this.paymentGatewayCode = t.paymentGatewayCode, this.paymentItemCode = t.paymentItemCode, this.paymentItemType = "PaymentItem", this.receiptCode = t.receiptCode, this.receiptDate = t.receiptDate || (/* @__PURE__ */ new Date()).valueOf(), this.receiptLineCode = t.receiptLineCode;
|
|
3456
3813
|
}
|
|
3457
3814
|
static dummyData() {
|
|
3458
3815
|
return {
|
|
@@ -3490,14 +3847,15 @@ class K extends O {
|
|
|
3490
3847
|
}
|
|
3491
3848
|
update(t) {
|
|
3492
3849
|
return Object.keys(t).forEach((e) => {
|
|
3493
|
-
|
|
3850
|
+
ni.includes(e) && (e === "amount" ? this[e] = this.amount instanceof this._Amount ? this.amount.update(t[e]) : this._Amount.init(t[e]) : this[e] = t[e]);
|
|
3494
3851
|
}), super.update(t);
|
|
3495
3852
|
}
|
|
3496
3853
|
}
|
|
3497
|
-
function
|
|
3854
|
+
function ai(s) {
|
|
3498
3855
|
return s && typeof s.toString == "function" ? s.toString() : s;
|
|
3499
3856
|
}
|
|
3500
|
-
const
|
|
3857
|
+
const ui = [
|
|
3858
|
+
"accountAllocations",
|
|
3501
3859
|
"amount",
|
|
3502
3860
|
"deduction",
|
|
3503
3861
|
"description",
|
|
@@ -3507,20 +3865,21 @@ const Hs = [
|
|
|
3507
3865
|
"outstanding",
|
|
3508
3866
|
"purchaseOptions",
|
|
3509
3867
|
"qty",
|
|
3868
|
+
"refundAccountAllocations",
|
|
3510
3869
|
"unitPrice"
|
|
3511
3870
|
];
|
|
3512
|
-
class
|
|
3871
|
+
class z extends v {
|
|
3513
3872
|
constructor(t = {}) {
|
|
3514
3873
|
t = t || {}, super(t);
|
|
3515
|
-
const {
|
|
3516
|
-
this.
|
|
3517
|
-
const
|
|
3518
|
-
this.id =
|
|
3874
|
+
const { _AccountAllocation: e, _Amount: i, _Invoice: r, _Merchandise: n, _PaymentItem: a, _RefundAccountAllocation: u, _Status: c } = t._constructor || {};
|
|
3875
|
+
this._AccountAllocation = e && e._superclass === H._superclass ? e : H, this._Amount = i && i._superclass === h._superclass ? i : h, this._Invoice = r && r._superclass === K._superclass ? r : K, this._Merchandise = n && n._superclass === R._superclass ? n : R, this._PaymentItem = a && a._superclass === k._superclass ? a : k, this._RefundAccountAllocation = u && u._superclass === W._superclass ? u : W, this._Status = c && c._superclass === b._superclass ? c : b, this._invoice = t._invoice, this._merchandise = t._merchandise, this._paymentItems = t._paymentItems;
|
|
3876
|
+
const o = t._id || t.id;
|
|
3877
|
+
this.id = oi(o), this._type = t._type || "InvoiceLine", this.accountAllocations = this._AccountAllocation.initOnlyValidFromArray(t.accountAllocations), this.amount = this._Amount.init(t.amount), this.deduction = this._Amount.init(t.deduction), this.description = t.description, this.discount = t.discount || 0, this.invoiceCode = t.invoiceCode, this.invoiceDate = t.invoiceDate, this.invoiceLineCode = ci(t, "invoiceLineCode"), this.invoiceLineType = t.invoiceLineType || "InvoiceLine", this.merchandiseCode = t.merchandiseCode, this.note = t.note, this.outstanding = this._Amount.init(t.outstanding), this.purchaseOptions = p.initOnlyValidFromArray(t.purchaseOptions), this.qty = t.qty || 1, this.refundAccountAllocations = this._RefundAccountAllocation.initOnlyValidFromArray(t.refundAccountAllocations), this.status = this._Status.init(t.status), this.unitPrice = this._Amount.init(t.unitPrice), this.waived = t.waived || 0;
|
|
3519
3878
|
}
|
|
3520
3879
|
// Class Methods
|
|
3521
3880
|
static dummyData() {
|
|
3522
3881
|
return {
|
|
3523
|
-
amount:
|
|
3882
|
+
amount: h.dummyData(),
|
|
3524
3883
|
invoiceCode: "invoiceCode",
|
|
3525
3884
|
tenantCode: "tenantCode"
|
|
3526
3885
|
};
|
|
@@ -3569,9 +3928,9 @@ class k extends O {
|
|
|
3569
3928
|
};
|
|
3570
3929
|
}
|
|
3571
3930
|
getPurchaseOptionValue(t) {
|
|
3572
|
-
const {
|
|
3573
|
-
return
|
|
3574
|
-
key:
|
|
3931
|
+
const { key: e } = t || {};
|
|
3932
|
+
return Wt({
|
|
3933
|
+
key: e,
|
|
3575
3934
|
purchaseOptions: this.purchaseOptions
|
|
3576
3935
|
});
|
|
3577
3936
|
}
|
|
@@ -3592,7 +3951,7 @@ class k extends O {
|
|
|
3592
3951
|
}
|
|
3593
3952
|
update(t) {
|
|
3594
3953
|
return Object.keys(t).forEach((e) => {
|
|
3595
|
-
|
|
3954
|
+
ui.includes(e) && (e === "amount" || e === "unitPrice" || e === "deduction" || e === "outstanding" ? this[e] = this._Amount.init(t[e]) : e === "accountAllocations" ? this[e] = this._AccountAllocation.initOnlyValidFromArray(t[e]) : e === "purchaseOptions" ? this[e] = p.initOnlyValidFromArray(t[e]) : e === "refundAccountAllocations" ? this[e] = this._RefundAccountAllocation.initOnlyValidFromArray(t[e]) : this[e] = t[e]);
|
|
3596
3955
|
}), super.update(t);
|
|
3597
3956
|
}
|
|
3598
3957
|
updateOutstanding({ actorCode: t } = {}) {
|
|
@@ -3602,26 +3961,26 @@ class k extends O {
|
|
|
3602
3961
|
return this;
|
|
3603
3962
|
if (((n = this.outstanding) == null ? void 0 : n.value) <= 0)
|
|
3604
3963
|
return this;
|
|
3605
|
-
const
|
|
3964
|
+
const i = e.reduce((a, u) => {
|
|
3606
3965
|
var c;
|
|
3607
3966
|
return a + (((c = u == null ? void 0 : u.amount) == null ? void 0 : c.value) || 0);
|
|
3608
|
-
}, 0),
|
|
3609
|
-
return
|
|
3967
|
+
}, 0), r = this.amount.value - i;
|
|
3968
|
+
return r <= 0 && this.setClosed(Date.now(), t), this.update({
|
|
3610
3969
|
outstanding: {
|
|
3611
3970
|
currencyCode: this.amount.currencyCode,
|
|
3612
|
-
value:
|
|
3971
|
+
value: r
|
|
3613
3972
|
}
|
|
3614
3973
|
});
|
|
3615
3974
|
}
|
|
3616
3975
|
}
|
|
3617
|
-
function
|
|
3976
|
+
function ci(s, t) {
|
|
3618
3977
|
const e = s || {};
|
|
3619
|
-
return e[t] ? e[t] :
|
|
3978
|
+
return e[t] ? e[t] : O.setCode();
|
|
3620
3979
|
}
|
|
3621
|
-
function
|
|
3980
|
+
function oi(s) {
|
|
3622
3981
|
return s && typeof s.toString == "function" ? s.toString() : s;
|
|
3623
3982
|
}
|
|
3624
|
-
class
|
|
3983
|
+
class bt {
|
|
3625
3984
|
constructor(t = {}) {
|
|
3626
3985
|
t = t || {}, this.bankAccount = t.bankAccount, this.contactInformation = t.contactInformation, this.name = t.name, this.logo = t.logo;
|
|
3627
3986
|
}
|
|
@@ -3660,18 +4019,18 @@ class Ct {
|
|
|
3660
4019
|
}), this;
|
|
3661
4020
|
}
|
|
3662
4021
|
}
|
|
3663
|
-
const
|
|
4022
|
+
const li = [
|
|
3664
4023
|
"purchaseOptions",
|
|
3665
4024
|
"qty",
|
|
3666
4025
|
"status"
|
|
3667
4026
|
];
|
|
3668
|
-
class
|
|
4027
|
+
class ht extends v {
|
|
3669
4028
|
constructor(t = {}) {
|
|
3670
4029
|
t = t || {}, super(t);
|
|
3671
|
-
const { _Amount: e, _Product:
|
|
3672
|
-
this._Amount = e && e._superclass ===
|
|
4030
|
+
const { _Amount: e, _Product: i, _Status: r } = t._constructor || {};
|
|
4031
|
+
this._Amount = e && e._superclass === h._superclass ? e : h, this._Product = i && i._superclass === D._superclass ? i : D, this._Status = r && r._superclass === b._superclass ? r : b, this._eventRegistration = t._eventRegistration, this._invoiceLine = t._invoiceLine, this._product = t._product, this._tenant = t._tenant, this._transaction = t._transaction, this._type = t._type || "WalletItem";
|
|
3673
4032
|
const n = t._id || t.id;
|
|
3674
|
-
this.id =
|
|
4033
|
+
this.id = di(n), this.invoiceLineCode = t.invoiceLineCode, this.productCode = t.productCode, this.purchaseOptions = p.initOnlyValidFromArray(t.purchaseOptions), this.qty = t.qty || 1, this.status = this._Status.init(t.status), this.transactionCode = t.transactionCode, this.walletItemCode = hi(t, "walletItemCode");
|
|
3675
4034
|
}
|
|
3676
4035
|
// Class methods
|
|
3677
4036
|
static dummyData() {
|
|
@@ -3680,7 +4039,7 @@ class ut extends O {
|
|
|
3680
4039
|
// companyCode: 'demo',
|
|
3681
4040
|
productCode: "5cd4f5430c2b874ad7ed8cfd",
|
|
3682
4041
|
qty: 1,
|
|
3683
|
-
status:
|
|
4042
|
+
status: b.dummyData(),
|
|
3684
4043
|
tenantCode: "tenantCode",
|
|
3685
4044
|
transactionCode: "transactionCode"
|
|
3686
4045
|
};
|
|
@@ -3769,10 +4128,10 @@ class ut extends O {
|
|
|
3769
4128
|
}
|
|
3770
4129
|
get displayPurchaseOptions() {
|
|
3771
4130
|
return this.purchaseOptions.length > 0 ? this.purchaseOptions.reduce((t, e) => {
|
|
3772
|
-
const { value:
|
|
3773
|
-
return t +=
|
|
4131
|
+
const { value: i } = e;
|
|
4132
|
+
return t += i.reduce((r, n) => {
|
|
3774
4133
|
const { label: a, value: u } = n;
|
|
3775
|
-
return
|
|
4134
|
+
return r += `<div><span>${a}: </span><span>${u}</span></div>`;
|
|
3776
4135
|
}, "");
|
|
3777
4136
|
}, "") : "";
|
|
3778
4137
|
}
|
|
@@ -3832,12 +4191,12 @@ class ut extends O {
|
|
|
3832
4191
|
return this.walletItemCode;
|
|
3833
4192
|
}
|
|
3834
4193
|
getPurchaseOptionValue(t) {
|
|
3835
|
-
const { delimiter: e, key:
|
|
3836
|
-
return
|
|
4194
|
+
const { delimiter: e, key: i, tag: r } = t || {};
|
|
4195
|
+
return Wt({
|
|
3837
4196
|
delimiter: e,
|
|
3838
|
-
key:
|
|
4197
|
+
key: i,
|
|
3839
4198
|
purchaseOptions: this.purchaseOptions,
|
|
3840
|
-
tag:
|
|
4199
|
+
tag: r
|
|
3841
4200
|
});
|
|
3842
4201
|
}
|
|
3843
4202
|
isApplicableCoupon(t) {
|
|
@@ -3887,12 +4246,12 @@ class ut extends O {
|
|
|
3887
4246
|
setRefundRejected(t) {
|
|
3888
4247
|
const e = this.status.refundRequested;
|
|
3889
4248
|
this.unSetRefundRequested();
|
|
3890
|
-
const
|
|
3891
|
-
|
|
4249
|
+
const i = _.foundValueByKey(this.metadata, "REFUND_REJECTED_HISTORY") || [];
|
|
4250
|
+
i.push({
|
|
3892
4251
|
...t,
|
|
3893
4252
|
refundRequested: e,
|
|
3894
4253
|
created: (/* @__PURE__ */ new Date()).valueOf()
|
|
3895
|
-
}), this.metadata = _.insertOrUpdateRecord(this.metadata, "REFUND_REJECTED_HISTORY",
|
|
4254
|
+
}), this.metadata = _.insertOrUpdateRecord(this.metadata, "REFUND_REJECTED_HISTORY", i);
|
|
3896
4255
|
}
|
|
3897
4256
|
setShared() {
|
|
3898
4257
|
return this.status.setShared(), this;
|
|
@@ -3924,14 +4283,14 @@ class ut extends O {
|
|
|
3924
4283
|
// }
|
|
3925
4284
|
// }
|
|
3926
4285
|
updatePurchaseOptions(t) {
|
|
3927
|
-
const { purchaseOptions: e } = this,
|
|
3928
|
-
return
|
|
3929
|
-
purchaseOptions:
|
|
4286
|
+
const { purchaseOptions: e } = this, i = _.foundValueByKey(this.metadata, "PURCHASE_OPTION_HISTORY") || [];
|
|
4287
|
+
return i.push({
|
|
4288
|
+
purchaseOptions: $.cloneDeep(e),
|
|
3930
4289
|
created: (/* @__PURE__ */ new Date()).valueOf()
|
|
3931
|
-
}), this.metadata = _.insertOrUpdateRecord(this.metadata, "PURCHASE_OPTION_HISTORY",
|
|
3932
|
-
const { key: n, value: a } =
|
|
3933
|
-
a.forEach((c,
|
|
3934
|
-
Object.assign(c, u[
|
|
4290
|
+
}), this.metadata = _.insertOrUpdateRecord(this.metadata, "PURCHASE_OPTION_HISTORY", i), e.forEach((r) => {
|
|
4291
|
+
const { key: n, value: a } = r, { value: u } = t.find((c) => c.key === n);
|
|
4292
|
+
a.forEach((c, o) => {
|
|
4293
|
+
Object.assign(c, u[o]);
|
|
3935
4294
|
});
|
|
3936
4295
|
}), this;
|
|
3937
4296
|
}
|
|
@@ -3952,35 +4311,35 @@ class ut extends O {
|
|
|
3952
4311
|
}
|
|
3953
4312
|
update(t) {
|
|
3954
4313
|
return Object.keys(t).forEach((e) => {
|
|
3955
|
-
|
|
4314
|
+
li.includes(e) && (e === "purchaseOptions" ? this[e] = p.initOnlyValidFromArray(t[e]) : e === "status" ? this[e] = this._Status.init(t[e]) : this[e] = t[e]);
|
|
3956
4315
|
}), super.update(t);
|
|
3957
4316
|
}
|
|
3958
4317
|
}
|
|
3959
|
-
function
|
|
4318
|
+
function di(s) {
|
|
3960
4319
|
return s && typeof s.toString == "function" ? s.toString() : s;
|
|
3961
4320
|
}
|
|
3962
|
-
function
|
|
4321
|
+
function hi(s, t) {
|
|
3963
4322
|
const e = s || {};
|
|
3964
|
-
return e[t] ? e[t] :
|
|
4323
|
+
return e[t] ? e[t] : O.setCode();
|
|
3965
4324
|
}
|
|
3966
|
-
const
|
|
4325
|
+
const mi = [
|
|
3967
4326
|
"amount",
|
|
3968
4327
|
"couponCodes",
|
|
3969
4328
|
// 'refundedAmount',
|
|
3970
4329
|
"status"
|
|
3971
4330
|
];
|
|
3972
|
-
class
|
|
4331
|
+
class J extends v {
|
|
3973
4332
|
constructor(t = {}) {
|
|
3974
4333
|
t = t || {}, super(t);
|
|
3975
|
-
const { _Amount: e, _PaymentResultFactory:
|
|
3976
|
-
this._Amount = e && e._superclass ===
|
|
4334
|
+
const { _Amount: e, _PaymentResultFactory: i, _Status: r, _WalletItem: n } = t._constructor || {};
|
|
4335
|
+
this._Amount = e && e._superclass === h._superclass ? e : h, this._PaymentResultFactory = i, this._Status = r && r._superclass === b._superclass ? r : b, this._WalletItem = n && n._superclass === ht._superclass ? n : ht, this._coupons = t._coupons, this._creditNotes = t._creditNotes, this._invoice = t._invoice, this._paymentGateway = t._paymentGateway, this._paymentResults = t._paymentResults, this._walletItems = t._walletItems;
|
|
3977
4336
|
const a = t._id || t.id;
|
|
3978
|
-
this.id =
|
|
4337
|
+
this.id = gi(a), this._type = t._type || "Transaction", this.amount = this._Amount.init(t.amount), this.couponCodes = t.couponCodes || [], this.creditNoteCodes = t.creditNoteCodes || [], this.invoiceCode = t.invoiceCode, this.paymentGatewayCode = t.paymentGatewayCode, this.paymentResultRef = t.paymentResultRef, this.status = this._Status.init(t.status), this.transactionCode = pi(t, "transactionCode");
|
|
3979
4338
|
}
|
|
3980
4339
|
// class method
|
|
3981
4340
|
static dummyData() {
|
|
3982
4341
|
return {
|
|
3983
|
-
status:
|
|
4342
|
+
status: b.dummyData(),
|
|
3984
4343
|
tenantCode: "tenantCode"
|
|
3985
4344
|
};
|
|
3986
4345
|
}
|
|
@@ -4196,7 +4555,7 @@ class Y extends O {
|
|
|
4196
4555
|
}
|
|
4197
4556
|
update(t) {
|
|
4198
4557
|
return Object.keys(t).forEach((e) => {
|
|
4199
|
-
|
|
4558
|
+
mi.includes(e) && (e === "amount" ? this[e] = this._Amount.init(t[e]) : e === "status" ? this[e] = this._Status.init(t[e]) : this[e] = t[e]);
|
|
4200
4559
|
}), super.update(t);
|
|
4201
4560
|
}
|
|
4202
4561
|
// updatePayment(payment = {}) {
|
|
@@ -4210,14 +4569,14 @@ class Y extends O {
|
|
|
4210
4569
|
// return setTotal(obj, key)
|
|
4211
4570
|
// }
|
|
4212
4571
|
}
|
|
4213
|
-
function
|
|
4572
|
+
function pi(s, t) {
|
|
4214
4573
|
const e = s || {};
|
|
4215
|
-
return e[t] ? e[t] :
|
|
4574
|
+
return e[t] ? e[t] : O.setCode();
|
|
4216
4575
|
}
|
|
4217
|
-
function
|
|
4576
|
+
function gi(s) {
|
|
4218
4577
|
return s && typeof s.toString == "function" ? s.toString() : s;
|
|
4219
4578
|
}
|
|
4220
|
-
const
|
|
4579
|
+
const fi = [
|
|
4221
4580
|
"billToUserCode",
|
|
4222
4581
|
"checkoutDateTime",
|
|
4223
4582
|
"description",
|
|
@@ -4227,13 +4586,13 @@ const Xs = [
|
|
|
4227
4586
|
"revisionNumber",
|
|
4228
4587
|
"status"
|
|
4229
4588
|
];
|
|
4230
|
-
class
|
|
4589
|
+
class K extends v {
|
|
4231
4590
|
constructor(t) {
|
|
4232
4591
|
t = t || {}, super(t);
|
|
4233
|
-
const { _Amount: e, _BillToUser:
|
|
4234
|
-
this._Amount = e && e._superclass ===
|
|
4235
|
-
const
|
|
4236
|
-
this.id =
|
|
4592
|
+
const { _Amount: e, _BillToUser: i, _Cart: r, _InvoiceLine: n, _Issuer: a, _Status: u, _Transaction: c } = t._constructor || {};
|
|
4593
|
+
this._Amount = e && e._superclass === h._superclass ? e : h, this._BillToUser = i, this._Cart = r && r._superclass === ct._superclass ? r : ct, this._InvoiceLine = n && n._superclass === z._superclass ? n : z, this._Issuer = a && a._superclass === bt._superclass ? a : bt, this._Status = u && u._superclass === b._superclass ? u : b, this._Transaction = c && c._superclass === J._superclass ? c : J, this._billToUser = t._billToUser, this._cart = t._cart, this._invoiceLines = t._invoiceLines, this._transactions = t._transactions;
|
|
4594
|
+
const o = t._id || t.id;
|
|
4595
|
+
this.id = Ci(o), this._type = t._type || "Invoice", this.amount = this._Amount.init(t.amount), this.billToUserCode = t.billToUserCode, this.cartCode = t.cartCode, this.checkoutDateTime = t.checkoutDateTime || (/* @__PURE__ */ new Date()).valueOf(), this.description = t.description, this.invoiceCode = yi(t, "invoiceCode"), this.invoiceDate = t.invoiceDate || (/* @__PURE__ */ new Date()).valueOf(), this.invoiceNumber = t.invoiceNumber, this.invoiceType = t.invoiceType || "Invoice", this.issuer = this._Issuer.init(t.issuer), this.outstanding = this._Amount.init(t.outstanding), this.revisionNumber = t.revisionNumber || 0, this.status = this._Status.init(t.status);
|
|
4237
4596
|
}
|
|
4238
4597
|
static dummyData() {
|
|
4239
4598
|
return {
|
|
@@ -4269,8 +4628,8 @@ class W extends O {
|
|
|
4269
4628
|
}
|
|
4270
4629
|
get merchandisesSummary() {
|
|
4271
4630
|
return this.merchandises.reduce((t, e) => {
|
|
4272
|
-
const
|
|
4273
|
-
return
|
|
4631
|
+
const i = t.find((r) => r.merchandiseCode === e.merchandiseCode);
|
|
4632
|
+
return i ? i.qty += 1 : t.push({
|
|
4274
4633
|
...e.summary,
|
|
4275
4634
|
qty: 1
|
|
4276
4635
|
}), t;
|
|
@@ -4281,8 +4640,8 @@ class W extends O {
|
|
|
4281
4640
|
}
|
|
4282
4641
|
get productsSummary() {
|
|
4283
4642
|
return this.products.reduce((t, e) => {
|
|
4284
|
-
const
|
|
4285
|
-
return
|
|
4643
|
+
const i = t.find((r) => r.productCode === e.productCode);
|
|
4644
|
+
return i ? i.qty += 1 : t.push({
|
|
4286
4645
|
...e.summary,
|
|
4287
4646
|
qty: 1
|
|
4288
4647
|
}), t;
|
|
@@ -4351,92 +4710,92 @@ class W extends O {
|
|
|
4351
4710
|
}
|
|
4352
4711
|
update(t) {
|
|
4353
4712
|
return Object.keys(t).forEach((e) => {
|
|
4354
|
-
|
|
4713
|
+
fi.includes(e) && (e === "amount" || e === "outstanding" ? this[e] = this._Amount.init(t[e]) : e === "issuer" ? this[e] = this._Issuer.init(t[e]) : e === "status" ? this[e] = this._Status.init(t[e]) : this[e] = t[e]);
|
|
4355
4714
|
}), super.update(t);
|
|
4356
4715
|
}
|
|
4357
4716
|
updateOutstanding({ actorCode: t } = {}) {
|
|
4358
|
-
var
|
|
4717
|
+
var r;
|
|
4359
4718
|
const e = this.invoiceLines;
|
|
4360
4719
|
if (e.length === 0)
|
|
4361
4720
|
return this;
|
|
4362
|
-
if (((
|
|
4721
|
+
if (((r = this.outstanding) == null ? void 0 : r.value) <= 0)
|
|
4363
4722
|
return this;
|
|
4364
|
-
const
|
|
4723
|
+
const i = e.reduce((n, a) => {
|
|
4365
4724
|
var u;
|
|
4366
4725
|
return a.updateOutstanding({ actorCode: t }), n + ((u = a == null ? void 0 : a.outstanding) == null ? void 0 : u.value);
|
|
4367
4726
|
}, 0);
|
|
4368
|
-
return
|
|
4727
|
+
return i <= 0 && this.setClosed(Date.now(), t), this._invoiceLines = e, this.update({
|
|
4369
4728
|
outstanding: {
|
|
4370
4729
|
currencyCode: this.getCurrencyCode(),
|
|
4371
|
-
value:
|
|
4730
|
+
value: i
|
|
4372
4731
|
}
|
|
4373
4732
|
});
|
|
4374
4733
|
}
|
|
4375
4734
|
}
|
|
4376
|
-
function
|
|
4735
|
+
function yi(s, t) {
|
|
4377
4736
|
const e = s || {};
|
|
4378
|
-
return e[t] ? e[t] :
|
|
4737
|
+
return e[t] ? e[t] : O.setCode();
|
|
4379
4738
|
}
|
|
4380
|
-
function
|
|
4739
|
+
function Ci(s) {
|
|
4381
4740
|
return s && typeof s.toString == "function" ? s.toString() : s;
|
|
4382
4741
|
}
|
|
4383
|
-
let
|
|
4384
|
-
function
|
|
4385
|
-
const
|
|
4386
|
-
return !(
|
|
4742
|
+
let mt = null, Qt = null, B = {}, M = null;
|
|
4743
|
+
function _i(s, t, e) {
|
|
4744
|
+
const i = [], { status: r } = s;
|
|
4745
|
+
return !(r instanceof b) || r.isCancelled || ((r.isCompleted || s.amount && s.amount.value === 0) && (i.push({
|
|
4387
4746
|
css: {
|
|
4388
4747
|
element: "__button"
|
|
4389
4748
|
},
|
|
4390
4749
|
icon: "fa fa-download",
|
|
4391
|
-
label:
|
|
4392
|
-
onClick:
|
|
4393
|
-
}),
|
|
4750
|
+
label: B.DOWNLOAD,
|
|
4751
|
+
onClick: M.onOrderListAction("downloadInvoice")
|
|
4752
|
+
}), i.push({
|
|
4394
4753
|
css: {
|
|
4395
4754
|
element: "__button"
|
|
4396
4755
|
},
|
|
4397
4756
|
icon: "fa fa-paper-plane",
|
|
4398
|
-
label:
|
|
4399
|
-
onClick:
|
|
4400
|
-
})),
|
|
4757
|
+
label: B.SENDEMAIL,
|
|
4758
|
+
onClick: M.onOrderListAction("sendInvoice")
|
|
4759
|
+
})), r.isPending && (Qt ? (i.push({
|
|
4401
4760
|
css: {
|
|
4402
4761
|
element: "__button"
|
|
4403
4762
|
},
|
|
4404
4763
|
icon: "fa fa-edit",
|
|
4405
|
-
label:
|
|
4406
|
-
onClick:
|
|
4407
|
-
}),
|
|
4764
|
+
label: B.ADMIN_SETTLE,
|
|
4765
|
+
onClick: M.onOrderListAction("adminSettle")
|
|
4766
|
+
}), mt && mt.allowWaived && i.push({
|
|
4408
4767
|
css: {
|
|
4409
4768
|
element: "__button"
|
|
4410
4769
|
},
|
|
4411
4770
|
icon: "fa fa-edit",
|
|
4412
|
-
label:
|
|
4413
|
-
onClick:
|
|
4414
|
-
})) :
|
|
4771
|
+
label: B.WAIVED,
|
|
4772
|
+
onClick: M.onOrderListAction("waived")
|
|
4773
|
+
})) : i.push({
|
|
4415
4774
|
css: {
|
|
4416
4775
|
element: "__button"
|
|
4417
4776
|
},
|
|
4418
4777
|
icon: "fa fa-money",
|
|
4419
|
-
label:
|
|
4420
|
-
onClick:
|
|
4421
|
-
}),
|
|
4778
|
+
label: B.PAY,
|
|
4779
|
+
onClick: M.onOrderListAction("payOnline")
|
|
4780
|
+
}), i.push({
|
|
4422
4781
|
css: {
|
|
4423
4782
|
element: "__button"
|
|
4424
4783
|
},
|
|
4425
4784
|
icon: "fa fa-trash",
|
|
4426
|
-
label:
|
|
4427
|
-
onClick:
|
|
4428
|
-
}))),
|
|
4429
|
-
}
|
|
4430
|
-
function
|
|
4431
|
-
return
|
|
4432
|
-
const
|
|
4433
|
-
const
|
|
4434
|
-
return
|
|
4435
|
-
...
|
|
4436
|
-
amount:
|
|
4437
|
-
value:
|
|
4438
|
-
currencyCode:
|
|
4439
|
-
default:
|
|
4785
|
+
label: B.CANCEL,
|
|
4786
|
+
onClick: M.onOrderListAction("cancel")
|
|
4787
|
+
}))), i;
|
|
4788
|
+
}
|
|
4789
|
+
function Ai(s, t) {
|
|
4790
|
+
return K.initFromArray(t).map((i) => {
|
|
4791
|
+
const r = Yt(i.invoiceDate, "YYYY-MM-DD HH:mm"), { amount: n, itemNames: a, qty: u } = i.invoiceLines.reduce((l, d) => {
|
|
4792
|
+
const m = s.find((g) => g.merchandiseCode === d.merchandiseCode);
|
|
4793
|
+
return m && (l.itemNames.push(m.name), l.qty.push(d.qty)), {
|
|
4794
|
+
...l,
|
|
4795
|
+
amount: i.amount && i.amount.value ? i.amount : {
|
|
4796
|
+
value: l.amount.value + d.amount.value * d.qty,
|
|
4797
|
+
currencyCode: d.amount.currencyCode,
|
|
4798
|
+
default: l.amount.default && d.amount.default
|
|
4440
4799
|
}
|
|
4441
4800
|
};
|
|
4442
4801
|
}, {
|
|
@@ -4447,37 +4806,37 @@ function sr(s, t) {
|
|
|
4447
4806
|
},
|
|
4448
4807
|
itemNames: [],
|
|
4449
4808
|
qty: []
|
|
4450
|
-
}), c = a.reduce((
|
|
4809
|
+
}), c = a.reduce((l, d, m) => (l.push(`<div>${d} x ${u[m]}</div>`), l), []), o = i.revisionNumber > 1 ? `R${i.revisionNumber}` : "";
|
|
4451
4810
|
return {
|
|
4452
|
-
...
|
|
4453
|
-
_invoiceDate:
|
|
4811
|
+
...i,
|
|
4812
|
+
_invoiceDate: r,
|
|
4454
4813
|
_amountValue: `${n.currencyCode} ${(n.value / 100).toFixed(2)}`,
|
|
4455
4814
|
_amountCurrency: n.currencyCode,
|
|
4456
|
-
_status:
|
|
4815
|
+
_status: vi(i.status),
|
|
4457
4816
|
_itemNames: c.join(`
|
|
4458
4817
|
`),
|
|
4459
|
-
_invoiceNumber: `${
|
|
4818
|
+
_invoiceNumber: `${i.invoiceNumber} ${o}`
|
|
4460
4819
|
};
|
|
4461
4820
|
});
|
|
4462
4821
|
}
|
|
4463
|
-
function
|
|
4822
|
+
function vi(s) {
|
|
4464
4823
|
let t = "";
|
|
4465
|
-
if (!(s instanceof
|
|
4824
|
+
if (!(s instanceof b))
|
|
4466
4825
|
return t;
|
|
4467
4826
|
if (s.isCancelled)
|
|
4468
4827
|
return t = "cancelled", t;
|
|
4469
4828
|
if (s.isCompleted)
|
|
4470
4829
|
return t = "completed", t;
|
|
4471
4830
|
let e = 0;
|
|
4472
|
-
return t = Object.keys(s).reduce((
|
|
4831
|
+
return t = Object.keys(s).reduce((i, r) => (s[r] > e && (e = s[r], i = r), i), ""), t;
|
|
4473
4832
|
}
|
|
4474
|
-
function
|
|
4833
|
+
function Oi(s) {
|
|
4475
4834
|
return [
|
|
4476
4835
|
...s,
|
|
4477
4836
|
{
|
|
4478
4837
|
label: "Actions",
|
|
4479
4838
|
customComponentName: "q-list-body-row-cell-action",
|
|
4480
|
-
actionBuilder:
|
|
4839
|
+
actionBuilder: _i,
|
|
4481
4840
|
css: { element: "__action" },
|
|
4482
4841
|
labelButton: {
|
|
4483
4842
|
DOWNLOAD: "Download",
|
|
@@ -4488,80 +4847,82 @@ function ir(s) {
|
|
|
4488
4847
|
}
|
|
4489
4848
|
];
|
|
4490
4849
|
}
|
|
4491
|
-
function
|
|
4850
|
+
function Pi({
|
|
4492
4851
|
component: s,
|
|
4493
4852
|
config: t,
|
|
4494
4853
|
merchandises: e,
|
|
4495
|
-
invoices:
|
|
4496
|
-
defaultHeaders:
|
|
4854
|
+
invoices: i,
|
|
4855
|
+
defaultHeaders: r,
|
|
4497
4856
|
isAdmin: n,
|
|
4498
4857
|
label: a = {}
|
|
4499
4858
|
}) {
|
|
4500
|
-
|
|
4501
|
-
const c =
|
|
4859
|
+
M = s, mt = t, Qt = n, B = a.button || {};
|
|
4860
|
+
const c = Ai(e, i).sort((l, d) => l.invoiceDate < d.invoiceDate ? 1 : -1), o = Oi(r);
|
|
4502
4861
|
return {
|
|
4503
4862
|
rows: c,
|
|
4504
|
-
headers:
|
|
4863
|
+
headers: o
|
|
4505
4864
|
};
|
|
4506
4865
|
}
|
|
4507
|
-
function
|
|
4866
|
+
function bi(s, t) {
|
|
4508
4867
|
if (!t)
|
|
4509
4868
|
return s;
|
|
4510
4869
|
let e = null;
|
|
4511
4870
|
switch (typeof t) {
|
|
4512
4871
|
case "function":
|
|
4513
|
-
return s.forEach((
|
|
4514
|
-
e = t(
|
|
4515
|
-
}), e.length === 0 || s.sort((
|
|
4872
|
+
return s.forEach((i) => {
|
|
4873
|
+
e = t(i);
|
|
4874
|
+
}), e.length === 0 || s.sort((i, r) => i[e] < r[e] ? 1 : -1), s;
|
|
4516
4875
|
case "string":
|
|
4517
|
-
return e = t, s.sort((
|
|
4876
|
+
return e = t, s.sort((i, r) => i[e] < r[e] ? 1 : -1), s;
|
|
4518
4877
|
default:
|
|
4519
4878
|
return s;
|
|
4520
4879
|
}
|
|
4521
4880
|
}
|
|
4522
|
-
function
|
|
4523
|
-
const [e] = s,
|
|
4524
|
-
return s.every((
|
|
4881
|
+
function wi({ arr: s = [], key: t }) {
|
|
4882
|
+
const [e] = s, i = e[t];
|
|
4883
|
+
return s.every((r) => r[t] === i);
|
|
4525
4884
|
}
|
|
4526
|
-
function
|
|
4527
|
-
const e = s.length - 1,
|
|
4528
|
-
return
|
|
4885
|
+
function Ii({ arr: s = [], key: t }) {
|
|
4886
|
+
const e = s.length - 1, i = s[0][t], r = s[e][t];
|
|
4887
|
+
return i < r;
|
|
4529
4888
|
}
|
|
4530
|
-
const
|
|
4889
|
+
const Si = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4531
4890
|
__proto__: null,
|
|
4532
|
-
Chain:
|
|
4533
|
-
ChainManager:
|
|
4534
|
-
ChainTarget:
|
|
4535
|
-
ComplimentaryItemManager:
|
|
4536
|
-
CouponManager:
|
|
4537
|
-
adminSettle:
|
|
4538
|
-
calculateAmount:
|
|
4539
|
-
calculateByCoupon:
|
|
4540
|
-
calculator:
|
|
4541
|
-
checkDuplicate:
|
|
4542
|
-
defaultComparator:
|
|
4543
|
-
defaultSort:
|
|
4544
|
-
eleInArrayComparator:
|
|
4545
|
-
firstLetterToLower:
|
|
4546
|
-
getFakeClass:
|
|
4547
|
-
getSubClass:
|
|
4548
|
-
handlerOrderList:
|
|
4549
|
-
isAllEqual:
|
|
4550
|
-
isDescendingOrder:
|
|
4551
|
-
makeResponseHelper:
|
|
4552
|
-
objectAllInArrayComparator:
|
|
4553
|
-
objectComparator:
|
|
4554
|
-
objectOrderInArrayComparator:
|
|
4555
|
-
setQuery:
|
|
4556
|
-
stringHelper:
|
|
4557
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
4558
|
-
"
|
|
4891
|
+
Chain: S,
|
|
4892
|
+
ChainManager: Vt,
|
|
4893
|
+
ChainTarget: Dt,
|
|
4894
|
+
ComplimentaryItemManager: Ke,
|
|
4895
|
+
CouponManager: ke,
|
|
4896
|
+
adminSettle: $e,
|
|
4897
|
+
calculateAmount: Ne,
|
|
4898
|
+
calculateByCoupon: Et,
|
|
4899
|
+
calculator: Y,
|
|
4900
|
+
checkDuplicate: jt,
|
|
4901
|
+
defaultComparator: Ut,
|
|
4902
|
+
defaultSort: bi,
|
|
4903
|
+
eleInArrayComparator: Xe,
|
|
4904
|
+
firstLetterToLower: Nt,
|
|
4905
|
+
getFakeClass: Ue,
|
|
4906
|
+
getSubClass: je,
|
|
4907
|
+
handlerOrderList: Pi,
|
|
4908
|
+
isAllEqual: wi,
|
|
4909
|
+
isDescendingOrder: Ii,
|
|
4910
|
+
makeResponseHelper: us,
|
|
4911
|
+
objectAllInArrayComparator: ts,
|
|
4912
|
+
objectComparator: Ze,
|
|
4913
|
+
objectOrderInArrayComparator: es,
|
|
4914
|
+
setQuery: cs,
|
|
4915
|
+
stringHelper: O
|
|
4916
|
+
}, Symbol.toStringTag, { value: "Module" })), Ri = [
|
|
4917
|
+
"default",
|
|
4918
|
+
"name",
|
|
4919
|
+
"segment"
|
|
4559
4920
|
];
|
|
4560
|
-
class
|
|
4921
|
+
class Vi extends v {
|
|
4561
4922
|
constructor(t) {
|
|
4562
4923
|
t = t || {}, super(t);
|
|
4563
4924
|
const e = t._id || t.id;
|
|
4564
|
-
this.id =
|
|
4925
|
+
this.id = Di(e), this._type = t._type || "BillingAccount", this.billingAccountCode = t.billingAccountCode, this.default = !!t.default, this.name = t.name, this.segment = t.segment;
|
|
4565
4926
|
}
|
|
4566
4927
|
static dummyData() {
|
|
4567
4928
|
return {
|
|
@@ -4579,21 +4940,70 @@ class lr extends O {
|
|
|
4579
4940
|
// }
|
|
4580
4941
|
update(t) {
|
|
4581
4942
|
return Object.keys(t).forEach((e) => {
|
|
4582
|
-
|
|
4943
|
+
Ri.includes(e) && (this[e] = t[e]);
|
|
4583
4944
|
}), super.update(t);
|
|
4584
4945
|
}
|
|
4585
4946
|
}
|
|
4586
|
-
function
|
|
4947
|
+
function Di(s) {
|
|
4587
4948
|
return s && typeof s.toString == "function" ? s.toString() : s;
|
|
4588
4949
|
}
|
|
4589
|
-
const
|
|
4590
|
-
"
|
|
4950
|
+
const Ei = [
|
|
4951
|
+
"description"
|
|
4952
|
+
];
|
|
4953
|
+
class Ti extends v {
|
|
4954
|
+
constructor(t = {}) {
|
|
4955
|
+
t = t || {}, super(t);
|
|
4956
|
+
const { _Amount: e } = t._constructor || {};
|
|
4957
|
+
this._Amount = e && e._superclass === h._superclass ? e : h;
|
|
4958
|
+
const i = t._id || t.id;
|
|
4959
|
+
this.id = xi(i), this._type = t._type || "BillingLedgerEntry", this.billingAccountCode = t.billingAccountCode, this.billingLedgerEntryCode = Fi(t, "billingLedgerEntryCode"), this.billingProjectCode = t.billingProjectCode, this.creditAmount = this._Amount.init(t.creditAmount), this.currencyCode = t.currencyCode, this.debitAmount = this._Amount.init(t.debitAmount), this.description = t.description, this.postingDate = t.postingDate, this.sourceDocumentCode = t.sourceDocumentCode, this.sourceDocumentType = t.sourceDocumentType, this.sourceLineCode = t.sourceLineCode;
|
|
4960
|
+
}
|
|
4961
|
+
static dummyData() {
|
|
4962
|
+
return {
|
|
4963
|
+
billingAccountCode: "billingAccountCode",
|
|
4964
|
+
billingProjectCode: "billingProjectCode",
|
|
4965
|
+
creditAmount: h.dummyData(),
|
|
4966
|
+
currencyCode: "USD",
|
|
4967
|
+
postingDate: Date.now(),
|
|
4968
|
+
sourceDocumentCode: "sourceDocumentCode",
|
|
4969
|
+
sourceDocumentType: "Invoice",
|
|
4970
|
+
tenantCode: "tenantCode"
|
|
4971
|
+
};
|
|
4972
|
+
}
|
|
4973
|
+
static get _classname() {
|
|
4974
|
+
return "BillingLedgerEntry";
|
|
4975
|
+
}
|
|
4976
|
+
static get _superclass() {
|
|
4977
|
+
return "BillingLedgerEntry";
|
|
4978
|
+
}
|
|
4979
|
+
get hasOneSideAmount() {
|
|
4980
|
+
return !!this.debitAmount && !this.creditAmount || !this.debitAmount && !!this.creditAmount;
|
|
4981
|
+
}
|
|
4982
|
+
get isValid() {
|
|
4983
|
+
return super.isValid && !!this.billingAccountCode && !!this.billingProjectCode && !!this.currencyCode && this.hasOneSideAmount && !!this.postingDate && !!this.sourceDocumentCode && !!this.sourceDocumentType;
|
|
4984
|
+
}
|
|
4985
|
+
update(t) {
|
|
4986
|
+
return Object.keys(t).forEach((e) => {
|
|
4987
|
+
Ei.includes(e) && (this[e] = t[e]);
|
|
4988
|
+
}), super.update(t);
|
|
4989
|
+
}
|
|
4990
|
+
}
|
|
4991
|
+
function Fi(s, t) {
|
|
4992
|
+
const e = s || {};
|
|
4993
|
+
return e[t] ? e[t] : O.setCode();
|
|
4994
|
+
}
|
|
4995
|
+
function xi(s) {
|
|
4996
|
+
return s && typeof s.toString == "function" ? s.toString() : s;
|
|
4997
|
+
}
|
|
4998
|
+
const Li = [
|
|
4999
|
+
"name",
|
|
5000
|
+
"receivableBillingAccountCode"
|
|
4591
5001
|
];
|
|
4592
|
-
class
|
|
5002
|
+
class Bi extends v {
|
|
4593
5003
|
constructor(t) {
|
|
4594
5004
|
t = t || {}, super(t);
|
|
4595
5005
|
const e = t._id || t.id;
|
|
4596
|
-
this.id =
|
|
5006
|
+
this.id = Mi(e), this._type = t._type || "BillingProject", this.billingProjectCode = t.billingProjectCode, this.name = t.name, this.receivableBillingAccountCode = t.receivableBillingAccountCode;
|
|
4597
5007
|
}
|
|
4598
5008
|
static dummyData() {
|
|
4599
5009
|
return {
|
|
@@ -4611,14 +5021,14 @@ class pr extends O {
|
|
|
4611
5021
|
// }
|
|
4612
5022
|
update(t) {
|
|
4613
5023
|
return Object.keys(t).forEach((e) => {
|
|
4614
|
-
|
|
5024
|
+
Li.includes(e) && (this[e] = t[e]);
|
|
4615
5025
|
}), super.update(t);
|
|
4616
5026
|
}
|
|
4617
5027
|
}
|
|
4618
|
-
function
|
|
5028
|
+
function Mi(s) {
|
|
4619
5029
|
return s && typeof s.toString == "function" ? s.toString() : s;
|
|
4620
5030
|
}
|
|
4621
|
-
const
|
|
5031
|
+
const $i = [
|
|
4622
5032
|
"codes",
|
|
4623
5033
|
"description",
|
|
4624
5034
|
"max",
|
|
@@ -4627,13 +5037,13 @@ const gr = [
|
|
|
4627
5037
|
"priority",
|
|
4628
5038
|
"productCodes"
|
|
4629
5039
|
];
|
|
4630
|
-
class
|
|
5040
|
+
class qi extends v {
|
|
4631
5041
|
constructor(t) {
|
|
4632
5042
|
t = t || {}, super(t);
|
|
4633
5043
|
const { _Product: e } = t._constructor || {};
|
|
4634
|
-
this._Product = e && e._superclass ===
|
|
4635
|
-
const
|
|
4636
|
-
this.id =
|
|
5044
|
+
this._Product = e && e._superclass === D._superclass ? e : D, this._products = t._products, this._type = t._type || "Category";
|
|
5045
|
+
const i = t._id || t.id;
|
|
5046
|
+
this.id = ji(i), this.categoryCode = Ni(t, "categoryCode"), this.codes = t.codes || [], this.description = t.description, this.max = t.max || 1, this.min = t.min || 0, this.name = t.name, this.priority = t.priority || 10, this.productCodes = t.productCodes || [];
|
|
4637
5047
|
}
|
|
4638
5048
|
// class methods
|
|
4639
5049
|
static dummyData() {
|
|
@@ -4658,18 +5068,18 @@ class yr extends O {
|
|
|
4658
5068
|
// instance methods
|
|
4659
5069
|
update(t) {
|
|
4660
5070
|
return Object.keys(t).forEach((e) => {
|
|
4661
|
-
|
|
5071
|
+
$i.includes(e) && (this[e] = t[e]);
|
|
4662
5072
|
}), super.update(t);
|
|
4663
5073
|
}
|
|
4664
5074
|
}
|
|
4665
|
-
function
|
|
5075
|
+
function Ni(s, t) {
|
|
4666
5076
|
const e = s || {};
|
|
4667
|
-
return e[t] ? e[t] :
|
|
5077
|
+
return e[t] ? e[t] : O.setCode();
|
|
4668
5078
|
}
|
|
4669
|
-
function
|
|
5079
|
+
function ji(s) {
|
|
4670
5080
|
return s && typeof s.toString == "function" ? s.toString() : s;
|
|
4671
5081
|
}
|
|
4672
|
-
const
|
|
5082
|
+
const Ui = [
|
|
4673
5083
|
"amount",
|
|
4674
5084
|
// 'deduction',
|
|
4675
5085
|
"description",
|
|
@@ -4677,13 +5087,13 @@ const vr = [
|
|
|
4677
5087
|
"qty"
|
|
4678
5088
|
// 'unitPrice'
|
|
4679
5089
|
];
|
|
4680
|
-
class
|
|
5090
|
+
class pt extends v {
|
|
4681
5091
|
constructor(t = {}) {
|
|
4682
5092
|
t = t || {}, super(t);
|
|
4683
5093
|
const { _Amount: e } = t._constructor || {};
|
|
4684
|
-
this._Amount = e && e._superclass ===
|
|
4685
|
-
const
|
|
4686
|
-
this.id =
|
|
5094
|
+
this._Amount = e && e._superclass === h._superclass ? e : h, this._creditNote = t._creditNote, this._type = t._type || "CreditNoteLine";
|
|
5095
|
+
const i = t._id || t.id;
|
|
5096
|
+
this.id = Hi(i), this.amount = this._Amount.init(t.amount), this.creditNoteCode = t.creditNoteCode, this.creditNoteLineCode = Gi(t, "creditNoteLineCode"), this.description = t.description, this.handlingCharge = this._Amount.init(t.handlingCharge), this.qty = t.qty || 1;
|
|
4687
5097
|
}
|
|
4688
5098
|
// Class Methods
|
|
4689
5099
|
static dummyData() {
|
|
@@ -4709,28 +5119,28 @@ class dt extends O {
|
|
|
4709
5119
|
}
|
|
4710
5120
|
update(t) {
|
|
4711
5121
|
return Object.keys(t).forEach((e) => {
|
|
4712
|
-
|
|
5122
|
+
Ui.includes(e) && (e === "amount" || e === "unitPrice" || e === "deduction" ? this[e] = this._Amount.init(t[e]) : e === "purchaseOptions" ? this[e] = p.initOnlyValidFromArray(t[e]) : this[e] = t[e]);
|
|
4713
5123
|
}), super.update(t);
|
|
4714
5124
|
}
|
|
4715
5125
|
}
|
|
4716
|
-
function
|
|
5126
|
+
function Gi(s, t) {
|
|
4717
5127
|
const e = s || {};
|
|
4718
|
-
return e[t] ? e[t] :
|
|
5128
|
+
return e[t] ? e[t] : O.setCode();
|
|
4719
5129
|
}
|
|
4720
|
-
function
|
|
5130
|
+
function Hi(s) {
|
|
4721
5131
|
return s && typeof s.toString == "function" ? s.toString() : s;
|
|
4722
5132
|
}
|
|
4723
|
-
const
|
|
5133
|
+
const Wi = [
|
|
4724
5134
|
"description",
|
|
4725
5135
|
"status"
|
|
4726
5136
|
];
|
|
4727
|
-
class
|
|
5137
|
+
class gt extends v {
|
|
4728
5138
|
constructor(t = {}) {
|
|
4729
5139
|
t = t || {}, super(t);
|
|
4730
|
-
const { _Amount: e, _CreditNoteLine:
|
|
4731
|
-
this._Amount = e && e._superclass ===
|
|
5140
|
+
const { _Amount: e, _CreditNoteLine: i, _Status: r } = t._constructor || {};
|
|
5141
|
+
this._Amount = e && e._superclass === h._superclass ? e : h, this._CreditNoteLine = i && i._superclass === pt._superclass ? i : pt, this._Status = r && r._superclass === b._superclass ? r : b, this._type = t._type || "CreditNote";
|
|
4732
5142
|
const n = t._id || t.id;
|
|
4733
|
-
this.id =
|
|
5143
|
+
this.id = Ki(n), this.amount = this._Amount.init(t.amount), this.creditNoteCode = Qi(t, "creditNoteCode"), this.creditNoteLines = this._CreditNoteLine.initOnlyValidFromArray(t.creditNoteLines), this.description = t.description, this.invoiceCode = t.invoiceCode, this.handlingCharge = this._Amount.init(t.handlingCharge), this.status = this._Status.init(t.status);
|
|
4734
5144
|
}
|
|
4735
5145
|
// Class Methods
|
|
4736
5146
|
static dummyData() {
|
|
@@ -4756,10 +5166,10 @@ class ot extends O {
|
|
|
4756
5166
|
return super.isValid && !!this.invoiceCode;
|
|
4757
5167
|
}
|
|
4758
5168
|
get displayCreated() {
|
|
4759
|
-
return
|
|
5169
|
+
return _t(this.meta.created, "YYYY/MM/DD hh:mm");
|
|
4760
5170
|
}
|
|
4761
5171
|
get displayRefundedDate() {
|
|
4762
|
-
return
|
|
5172
|
+
return _t(this.meta.created, "YYYY/MM/DD hh:mm");
|
|
4763
5173
|
}
|
|
4764
5174
|
get refundedDetail() {
|
|
4765
5175
|
return p.foundValueByKey(this.metadata, "REFUNDED_DETAIL") || {};
|
|
@@ -4779,22 +5189,22 @@ class ot extends O {
|
|
|
4779
5189
|
}
|
|
4780
5190
|
update(t) {
|
|
4781
5191
|
return Object.keys(t).forEach((e) => {
|
|
4782
|
-
|
|
5192
|
+
Wi.includes(e) && (e === "amount" ? this[e] = this._Amount.init(t[e]) : e === "status" ? this[e] = this._Status.init(t[e]) : this[e] = t[e]);
|
|
4783
5193
|
}), super.update(t);
|
|
4784
5194
|
}
|
|
4785
5195
|
}
|
|
4786
|
-
function
|
|
5196
|
+
function Qi(s, t) {
|
|
4787
5197
|
const e = s || {};
|
|
4788
|
-
return e[t] ? e[t] :
|
|
5198
|
+
return e[t] ? e[t] : O.setCode();
|
|
4789
5199
|
}
|
|
4790
|
-
function
|
|
5200
|
+
function Ki(s) {
|
|
4791
5201
|
return s && typeof s.toString == "function" ? s.toString() : s;
|
|
4792
5202
|
}
|
|
4793
|
-
class
|
|
5203
|
+
class Yi extends kt {
|
|
4794
5204
|
constructor(t = {}) {
|
|
4795
5205
|
t = t || {}, super(t);
|
|
4796
5206
|
const { _CreditNote: e } = t._constructor || {};
|
|
4797
|
-
this._CreditNote = e && e._superclass ===
|
|
5207
|
+
this._CreditNote = e && e._superclass === gt._superclass ? e : gt;
|
|
4798
5208
|
}
|
|
4799
5209
|
static get _classname() {
|
|
4800
5210
|
return "CreditNoteRepo";
|
|
@@ -4803,16 +5213,16 @@ class Sr extends Ht {
|
|
|
4803
5213
|
return this._CreditNote.init(t);
|
|
4804
5214
|
}
|
|
4805
5215
|
}
|
|
4806
|
-
const
|
|
5216
|
+
const ki = [
|
|
4807
5217
|
"description",
|
|
4808
5218
|
"name",
|
|
4809
5219
|
"symbol"
|
|
4810
5220
|
];
|
|
4811
|
-
class
|
|
5221
|
+
class zi extends v {
|
|
4812
5222
|
constructor(t = {}) {
|
|
4813
5223
|
t = t || {}, super(t);
|
|
4814
5224
|
const e = t._id || t.id;
|
|
4815
|
-
this.id =
|
|
5225
|
+
this.id = Xi(e), this._type = t._type || "Currency", this.code = t.code, this.currencyCode = Ji(t, "currencyCode"), this.description = t.description, this.factor = t.factor || 1, this.name = t.name, this.symbol = t.symbol || null, this.unit = t.unit;
|
|
4816
5226
|
}
|
|
4817
5227
|
static dummyData() {
|
|
4818
5228
|
return {
|
|
@@ -4840,18 +5250,18 @@ class Rr extends O {
|
|
|
4840
5250
|
}
|
|
4841
5251
|
update(t) {
|
|
4842
5252
|
return Object.keys(t).forEach((e) => {
|
|
4843
|
-
|
|
5253
|
+
ki.includes(e) && (this[e] = t[e]);
|
|
4844
5254
|
}), super.update(t);
|
|
4845
5255
|
}
|
|
4846
5256
|
}
|
|
4847
|
-
function
|
|
5257
|
+
function Ji(s, t) {
|
|
4848
5258
|
const e = s || {};
|
|
4849
|
-
return e[t] ? e[t] :
|
|
5259
|
+
return e[t] ? e[t] : O.setCode();
|
|
4850
5260
|
}
|
|
4851
|
-
function
|
|
5261
|
+
function Xi(s) {
|
|
4852
5262
|
return s && typeof s.toString == "function" ? s.toString() : s;
|
|
4853
5263
|
}
|
|
4854
|
-
const
|
|
5264
|
+
const Zi = [
|
|
4855
5265
|
"amount",
|
|
4856
5266
|
"deduction",
|
|
4857
5267
|
"discount",
|
|
@@ -4862,17 +5272,17 @@ const Tr = [
|
|
|
4862
5272
|
"waived",
|
|
4863
5273
|
"qty"
|
|
4864
5274
|
];
|
|
4865
|
-
class
|
|
5275
|
+
class ft extends v {
|
|
4866
5276
|
constructor(t) {
|
|
4867
5277
|
t = t || {}, super(t);
|
|
4868
|
-
const { _Amount: e, _Merchandise:
|
|
4869
|
-
this._Amount = e && e._superclass ===
|
|
5278
|
+
const { _Amount: e, _Merchandise: i, _Order: r, _OrderService: n, _Status: a } = t._constructor || {};
|
|
5279
|
+
this._Amount = e && e._superclass === h._superclass ? e : h, this._Merchandise = i && i._superclass === R._superclass ? i : R, this._Order = r && r._superclass === yt._superclass ? r : yt, this._Status = a && a._superclass === lt._superclass ? a : lt, this._merchandise = t._merchandise, this._order = t._order;
|
|
4870
5280
|
const u = t._id || t.id;
|
|
4871
|
-
this.id =
|
|
5281
|
+
this.id = tr(u), this._type = t._type || "OrderLine", this.amount = this._Amount.init(t.amount), this.deduction = this._Amount.init(t.deduction), this.discount = t.discount || 0, this.note = t.note, this.unitPrice = this._Amount.init(t.unitPrice), this.status = this._Status.init(t.status), this.orderCode = t.orderCode, this.orderLineCode = t.orderLineCode, this.orderLineType = "OrderLine", this.merchandiseCode = t.merchandiseCode, this.waived = t.waived || 0, this.qty = t.qty || 1;
|
|
4872
5282
|
}
|
|
4873
5283
|
static dummyData() {
|
|
4874
5284
|
return {
|
|
4875
|
-
amount:
|
|
5285
|
+
amount: h.dummyData(),
|
|
4876
5286
|
orderCode: "orderCode",
|
|
4877
5287
|
tenantCode: "tenantCode"
|
|
4878
5288
|
};
|
|
@@ -5012,27 +5422,27 @@ class lt extends O {
|
|
|
5012
5422
|
// }
|
|
5013
5423
|
update(t) {
|
|
5014
5424
|
return Object.keys(t).forEach((e) => {
|
|
5015
|
-
|
|
5425
|
+
Zi.includes(e) && (e === "purchaseOptions" ? this[e] = p.initOnlyValidFromArray(t[e]) : e === "amount" || e === "deduction" || e === "unitPrice" ? this[e] = this[e] instanceof this._Amount ? this[e].update(t[e]) : this._Amount.init(t[e]) : e === "status" ? this[e] = this[e] instanceof this._Status ? this[e].update(t[e]) : this._Status.init(t[e]) : this[e] = t[e]);
|
|
5016
5426
|
}), super.update(t);
|
|
5017
5427
|
}
|
|
5018
5428
|
}
|
|
5019
|
-
function
|
|
5429
|
+
function tr(s) {
|
|
5020
5430
|
return s && typeof s.toString == "function" ? s.toString() : s;
|
|
5021
5431
|
}
|
|
5022
|
-
const
|
|
5432
|
+
const er = [
|
|
5023
5433
|
"amount",
|
|
5024
5434
|
// 'orderNumber',
|
|
5025
5435
|
// 'revisionNumber',
|
|
5026
5436
|
"status",
|
|
5027
5437
|
"name"
|
|
5028
5438
|
];
|
|
5029
|
-
class
|
|
5439
|
+
class yt extends v {
|
|
5030
5440
|
constructor(t) {
|
|
5031
5441
|
t = t || {}, super(t);
|
|
5032
|
-
const { _Amount: e, _OrderLine:
|
|
5033
|
-
this._Amount = e && e._superclass ===
|
|
5442
|
+
const { _Amount: e, _OrderLine: i, _Status: r } = t._constructor || {};
|
|
5443
|
+
this._Amount = e && e._superclass === h._superclass ? e : h, this._OrderLine = i && i._superclass === ft._superclass ? i : ft, this._Status = r && r._superclass === ot._superclass ? r : ot, this._orderLines = t._orderLines;
|
|
5034
5444
|
const n = t._id || t.id;
|
|
5035
|
-
this.id =
|
|
5445
|
+
this.id = sr(n), this._type = t._type || "Order", this.amount = this._Amount.init(t.amount), this.orderCode = t.orderCode, this.orderType = "Order", this.status = this._Status.init(t.status), this.name = t.name;
|
|
5036
5446
|
}
|
|
5037
5447
|
static dummyData() {
|
|
5038
5448
|
return {
|
|
@@ -5098,16 +5508,16 @@ class ht extends O {
|
|
|
5098
5508
|
}
|
|
5099
5509
|
update(t) {
|
|
5100
5510
|
return Object.keys(t).forEach((e) => {
|
|
5101
|
-
|
|
5511
|
+
er.includes(e) && (e === "amount" ? this[e] = this.amount instanceof this._Amount ? this.amount.update(t[e]) : this._Amount.init(t[e]) : e === "status" ? this[e] = this.status instanceof this._Status ? this.status.update(t[e]) : this._Status.init(t[e]) : this[e] = t[e]);
|
|
5102
5512
|
}), super.update(t);
|
|
5103
5513
|
}
|
|
5104
5514
|
updateAmount() {
|
|
5105
5515
|
const t = this.orderLines;
|
|
5106
5516
|
if (t.length === 0)
|
|
5107
5517
|
return this;
|
|
5108
|
-
const e = t.reduce((
|
|
5518
|
+
const e = t.reduce((i, r) => {
|
|
5109
5519
|
var n;
|
|
5110
|
-
return
|
|
5520
|
+
return i + ((n = r == null ? void 0 : r.amount) == null ? void 0 : n.value) || 0;
|
|
5111
5521
|
}, 0);
|
|
5112
5522
|
return this.update({
|
|
5113
5523
|
amount: {
|
|
@@ -5117,22 +5527,22 @@ class ht extends O {
|
|
|
5117
5527
|
});
|
|
5118
5528
|
}
|
|
5119
5529
|
}
|
|
5120
|
-
function
|
|
5530
|
+
function sr(s) {
|
|
5121
5531
|
return s && typeof s.toString == "function" ? s.toString() : s;
|
|
5122
5532
|
}
|
|
5123
|
-
const
|
|
5533
|
+
const ir = [
|
|
5124
5534
|
"active",
|
|
5125
5535
|
"deleted",
|
|
5126
5536
|
"remarks",
|
|
5127
5537
|
"result"
|
|
5128
5538
|
];
|
|
5129
|
-
class
|
|
5539
|
+
class rr extends v {
|
|
5130
5540
|
constructor(t = {}) {
|
|
5131
5541
|
t = t || {}, super(t);
|
|
5132
5542
|
const { _Transaction: e } = t._constructor || {};
|
|
5133
|
-
this._Transaction = e && e._superclass ===
|
|
5134
|
-
const
|
|
5135
|
-
this.id =
|
|
5543
|
+
this._Transaction = e && e._superclass === J._superclass ? e : J, this._transaction = t._transaction, this._type = t._type || "PaymentResult";
|
|
5544
|
+
const i = t._id || t.id;
|
|
5545
|
+
this.id = ar(i), this.paymentResultCode = nr(t, "paymentResultCode"), this.paymentResultType = t.paymentResultType || "PaymentResult", this.result = t.result, this.resultRef = t.resultRef, this.resultType = t.resultType, this.transactionCode = t.transactionCode;
|
|
5136
5546
|
}
|
|
5137
5547
|
// class method
|
|
5138
5548
|
static dummyData() {
|
|
@@ -5231,18 +5641,18 @@ class Mr extends O {
|
|
|
5231
5641
|
}
|
|
5232
5642
|
update(t) {
|
|
5233
5643
|
return Object.keys(t).forEach((e) => {
|
|
5234
|
-
|
|
5644
|
+
ir.includes(e) && (this[e] = t[e]);
|
|
5235
5645
|
}), super.update(t);
|
|
5236
5646
|
}
|
|
5237
5647
|
}
|
|
5238
|
-
function
|
|
5648
|
+
function nr(s, t) {
|
|
5239
5649
|
const e = s || {};
|
|
5240
|
-
return e[t] ? e[t] :
|
|
5650
|
+
return e[t] ? e[t] : O.setCode();
|
|
5241
5651
|
}
|
|
5242
|
-
function
|
|
5652
|
+
function ar(s) {
|
|
5243
5653
|
return s && typeof s.toString == "function" ? s.toString() : s;
|
|
5244
5654
|
}
|
|
5245
|
-
const
|
|
5655
|
+
const ur = [
|
|
5246
5656
|
"active",
|
|
5247
5657
|
"deleted",
|
|
5248
5658
|
"description",
|
|
@@ -5258,13 +5668,13 @@ const Br = [
|
|
|
5258
5668
|
"requiredStoreItemCode",
|
|
5259
5669
|
"stock"
|
|
5260
5670
|
];
|
|
5261
|
-
class
|
|
5671
|
+
class cr {
|
|
5262
5672
|
constructor(t = {}) {
|
|
5263
5673
|
t = t || {};
|
|
5264
5674
|
const { _ItemOption: e } = t._constructor || {};
|
|
5265
|
-
this._ItemOption = e && e._superclass ===
|
|
5266
|
-
const
|
|
5267
|
-
this.id =
|
|
5675
|
+
this._ItemOption = e && e._superclass === T ? e : T;
|
|
5676
|
+
const i = t._id || t.id;
|
|
5677
|
+
this.id = or(i), this._type = t._type || "StoreItem", this.active = typeof t.active < "u" ? !!t.active : !0, this.created = t.created || (/* @__PURE__ */ new Date()).valueOf(), this.creator = t.creator, this.deleted = t.deleted || !1, this.description = t.description || "", this.intangible = t.intangible || !1, this.limitPercentage = t.limitPercentage || 100, this.lineOptions = this._ItemOption.initOnlyValidFromArray(t.lineOptions), this.maxPerWallet = t.maxPerWallet || 1, this.metadata = _.initOnlyValidFromArray(t.metadata), this.modified = t.modified || (/* @__PURE__ */ new Date()).valueOf(), this.name = t.name || "", this.originalStock = t.originalStock || 0, this.owner = t.owner, this.productCode = lr(t, "productCode"), this.productOptions = this._ItemOption.initOnlyValidFromArray(t.productOptions), this.requiredStoreItemCode = t.requiredStoreItemCode, this.remarks = p.initOnlyValidFromArray(t.remarks), this.stock = t.stock || 0, this.storeItemType = t.storeItemType || "StoreItem", this.tenantCode = t.tenantCode;
|
|
5268
5678
|
}
|
|
5269
5679
|
// class method
|
|
5270
5680
|
static dummyData() {
|
|
@@ -5313,9 +5723,9 @@ class Nr {
|
|
|
5313
5723
|
return this.maxPerWallet >= t;
|
|
5314
5724
|
}
|
|
5315
5725
|
checkStoreItemItemOptions(t = []) {
|
|
5316
|
-
return
|
|
5317
|
-
const n =
|
|
5318
|
-
return a ? (a.isValidFillInValue(
|
|
5726
|
+
return Q.getItemOptionFillInsByTarget({ itemOptionFillIns: t, target: "StoreItem", targetCode: this.productCode }).reduce((i, r) => {
|
|
5727
|
+
const n = r.getKey(), a = this.getStoreItemOptionByKey(n);
|
|
5728
|
+
return a ? (a.isValidFillInValue(r.getValue()) || i.errMsgs.push(`the product(${this.productCode}) option's(${n}) fillInValue is invalid`), i) : (i.errMsgs.push(`options of the product(${this.productCode}) does not contain key: "${n}"`), i);
|
|
5319
5729
|
}, { errMsgs: [] });
|
|
5320
5730
|
}
|
|
5321
5731
|
getCode() {
|
|
@@ -5333,7 +5743,7 @@ class Nr {
|
|
|
5333
5743
|
}
|
|
5334
5744
|
isQualified(t) {
|
|
5335
5745
|
const e = this.getMetadataValueByKey("RULES") || [];
|
|
5336
|
-
return e.length === 0 ? !0 : e.reduce((
|
|
5746
|
+
return e.length === 0 ? !0 : e.reduce((i, r) => i || wt(r, t, dr, p), !1);
|
|
5337
5747
|
}
|
|
5338
5748
|
isTicket() {
|
|
5339
5749
|
return !1;
|
|
@@ -5343,126 +5753,142 @@ class Nr {
|
|
|
5343
5753
|
}
|
|
5344
5754
|
update(t) {
|
|
5345
5755
|
return Object.keys(t).forEach((e) => {
|
|
5346
|
-
|
|
5756
|
+
ur.includes(e) && (e === "metadata" ? this[e] = _.initOnlyValidFromArray(t[e]) : e === "productOptions" ? this[e] = this._ItemOption.initOnlyValidFromArray(t[e]) : e === "remarks" ? this[e] = p.initOnlyValidFromArray(t[e]) : this[e] = t[e]);
|
|
5347
5757
|
}), this.setModified();
|
|
5348
5758
|
}
|
|
5349
5759
|
}
|
|
5350
|
-
function
|
|
5760
|
+
function or(s) {
|
|
5351
5761
|
return s && typeof s.toString == "function" ? s.toString() : s;
|
|
5352
5762
|
}
|
|
5353
|
-
function
|
|
5763
|
+
function lr(s, t) {
|
|
5354
5764
|
const e = s || {};
|
|
5355
|
-
return e[t] ? e[t] :
|
|
5765
|
+
return e[t] ? e[t] : O.setCode();
|
|
5356
5766
|
}
|
|
5357
|
-
function
|
|
5358
|
-
return
|
|
5767
|
+
function dr(s, t) {
|
|
5768
|
+
return It(s.split("."), t);
|
|
5359
5769
|
}
|
|
5360
|
-
const
|
|
5770
|
+
const hr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
5361
5771
|
__proto__: null,
|
|
5362
|
-
|
|
5363
|
-
|
|
5364
|
-
|
|
5365
|
-
|
|
5366
|
-
|
|
5367
|
-
|
|
5368
|
-
|
|
5369
|
-
|
|
5370
|
-
|
|
5371
|
-
|
|
5372
|
-
|
|
5373
|
-
|
|
5374
|
-
|
|
5375
|
-
|
|
5772
|
+
AccountAllocation: H,
|
|
5773
|
+
AccountAllocationGroup: at,
|
|
5774
|
+
Amount: h,
|
|
5775
|
+
BillingAccount: Vi,
|
|
5776
|
+
BillingLedgerEntry: Ti,
|
|
5777
|
+
BillingProject: Bi,
|
|
5778
|
+
Cart: ct,
|
|
5779
|
+
CartItem: Z,
|
|
5780
|
+
Category: qi,
|
|
5781
|
+
CreditNote: gt,
|
|
5782
|
+
CreditNoteLine: pt,
|
|
5783
|
+
CreditNoteRepo: Yi,
|
|
5784
|
+
Currency: zi,
|
|
5785
|
+
Invoice: K,
|
|
5786
|
+
InvoiceLine: z,
|
|
5787
|
+
ItemOption: T,
|
|
5788
|
+
ItemOptionLocale: nt,
|
|
5376
5789
|
KeyValueObject: p,
|
|
5377
|
-
Merchandise:
|
|
5378
|
-
|
|
5379
|
-
|
|
5380
|
-
|
|
5381
|
-
|
|
5382
|
-
|
|
5383
|
-
|
|
5384
|
-
|
|
5385
|
-
|
|
5386
|
-
|
|
5387
|
-
|
|
5790
|
+
Merchandise: R,
|
|
5791
|
+
MerchandiseBilling: qs,
|
|
5792
|
+
Order: yt,
|
|
5793
|
+
OrderLine: ft,
|
|
5794
|
+
PaymentCharge: dt,
|
|
5795
|
+
PaymentGateway: q,
|
|
5796
|
+
PaymentGatewayBilling: zs,
|
|
5797
|
+
PaymentItem: k,
|
|
5798
|
+
PaymentResult: rr,
|
|
5799
|
+
Price: V,
|
|
5800
|
+
PriceStrategy: X,
|
|
5801
|
+
Product: D,
|
|
5802
|
+
ProductBilling: Fs,
|
|
5803
|
+
Receipt: j,
|
|
5388
5804
|
ReceiptLine: N,
|
|
5389
|
-
|
|
5390
|
-
|
|
5391
|
-
|
|
5392
|
-
|
|
5393
|
-
|
|
5394
|
-
|
|
5395
|
-
|
|
5396
|
-
|
|
5397
|
-
|
|
5398
|
-
|
|
5399
|
-
|
|
5400
|
-
|
|
5401
|
-
...
|
|
5805
|
+
RefundAccountAllocation: W,
|
|
5806
|
+
RefundAccountAllocationGroup: ut,
|
|
5807
|
+
Status: b,
|
|
5808
|
+
StatusQStore: E,
|
|
5809
|
+
StatusQStoreInvoice: Js,
|
|
5810
|
+
StatusQStoreInvoiceLine: Xs,
|
|
5811
|
+
StatusQStoreOrder: ot,
|
|
5812
|
+
StatusQStoreOrderLine: lt,
|
|
5813
|
+
StoreItem: cr,
|
|
5814
|
+
Transaction: J,
|
|
5815
|
+
WalletItem: ht
|
|
5816
|
+
}, Symbol.toStringTag, { value: "Module" })), gr = {
|
|
5817
|
+
...Me,
|
|
5818
|
+
...Si,
|
|
5819
|
+
...hr
|
|
5402
5820
|
};
|
|
5403
5821
|
export {
|
|
5404
|
-
|
|
5405
|
-
|
|
5406
|
-
|
|
5407
|
-
|
|
5408
|
-
|
|
5409
|
-
|
|
5410
|
-
|
|
5411
|
-
|
|
5412
|
-
|
|
5413
|
-
|
|
5414
|
-
|
|
5415
|
-
|
|
5416
|
-
|
|
5417
|
-
|
|
5418
|
-
|
|
5419
|
-
|
|
5420
|
-
|
|
5421
|
-
|
|
5422
|
-
|
|
5423
|
-
|
|
5424
|
-
|
|
5425
|
-
|
|
5426
|
-
|
|
5427
|
-
|
|
5428
|
-
|
|
5429
|
-
|
|
5430
|
-
|
|
5431
|
-
|
|
5432
|
-
|
|
5433
|
-
|
|
5434
|
-
|
|
5435
|
-
|
|
5822
|
+
H as AccountAllocation,
|
|
5823
|
+
at as AccountAllocationGroup,
|
|
5824
|
+
h as Amount,
|
|
5825
|
+
Vi as BillingAccount,
|
|
5826
|
+
Ti as BillingLedgerEntry,
|
|
5827
|
+
Bi as BillingProject,
|
|
5828
|
+
ct as Cart,
|
|
5829
|
+
Z as CartItem,
|
|
5830
|
+
qi as Category,
|
|
5831
|
+
S as Chain,
|
|
5832
|
+
Vt as ChainManager,
|
|
5833
|
+
qt as ChainManagerFactory,
|
|
5834
|
+
Dt as ChainTarget,
|
|
5835
|
+
Ke as ComplimentaryItemManager,
|
|
5836
|
+
ke as CouponManager,
|
|
5837
|
+
gt as CreditNote,
|
|
5838
|
+
pt as CreditNoteLine,
|
|
5839
|
+
Yi as CreditNoteRepo,
|
|
5840
|
+
zi as Currency,
|
|
5841
|
+
K as Invoice,
|
|
5842
|
+
z as InvoiceLine,
|
|
5843
|
+
T as ItemOption,
|
|
5844
|
+
nt as ItemOptionLocale,
|
|
5845
|
+
Cr as KeyValueObject,
|
|
5846
|
+
R as Merchandise,
|
|
5847
|
+
qs as MerchandiseBilling,
|
|
5848
|
+
yt as Order,
|
|
5849
|
+
ft as OrderLine,
|
|
5850
|
+
dt as PaymentCharge,
|
|
5851
|
+
q as PaymentGateway,
|
|
5852
|
+
zs as PaymentGatewayBilling,
|
|
5853
|
+
k as PaymentItem,
|
|
5854
|
+
rr as PaymentResult,
|
|
5855
|
+
V as Price,
|
|
5856
|
+
X as PriceStrategy,
|
|
5857
|
+
D as Product,
|
|
5858
|
+
Fs as ProductBilling,
|
|
5859
|
+
j as Receipt,
|
|
5436
5860
|
N as ReceiptLine,
|
|
5437
|
-
|
|
5438
|
-
|
|
5439
|
-
|
|
5440
|
-
|
|
5441
|
-
|
|
5442
|
-
|
|
5443
|
-
|
|
5444
|
-
|
|
5445
|
-
|
|
5446
|
-
|
|
5447
|
-
|
|
5448
|
-
|
|
5449
|
-
|
|
5450
|
-
|
|
5451
|
-
|
|
5452
|
-
|
|
5453
|
-
|
|
5454
|
-
|
|
5455
|
-
|
|
5456
|
-
|
|
5457
|
-
|
|
5458
|
-
|
|
5459
|
-
|
|
5460
|
-
|
|
5461
|
-
|
|
5462
|
-
|
|
5463
|
-
|
|
5464
|
-
|
|
5465
|
-
|
|
5466
|
-
|
|
5861
|
+
W as RefundAccountAllocation,
|
|
5862
|
+
ut as RefundAccountAllocationGroup,
|
|
5863
|
+
b as Status,
|
|
5864
|
+
E as StatusQStore,
|
|
5865
|
+
Js as StatusQStoreInvoice,
|
|
5866
|
+
Xs as StatusQStoreInvoiceLine,
|
|
5867
|
+
ot as StatusQStoreOrder,
|
|
5868
|
+
lt as StatusQStoreOrderLine,
|
|
5869
|
+
cr as StoreItem,
|
|
5870
|
+
J as Transaction,
|
|
5871
|
+
ht as WalletItem,
|
|
5872
|
+
$e as adminSettle,
|
|
5873
|
+
Ne as calculateAmount,
|
|
5874
|
+
Et as calculateByCoupon,
|
|
5875
|
+
Y as calculator,
|
|
5876
|
+
jt as checkDuplicate,
|
|
5877
|
+
gr as default,
|
|
5878
|
+
Ut as defaultComparator,
|
|
5879
|
+
bi as defaultSort,
|
|
5880
|
+
Xe as eleInArrayComparator,
|
|
5881
|
+
Nt as firstLetterToLower,
|
|
5882
|
+
Ue as getFakeClass,
|
|
5883
|
+
je as getSubClass,
|
|
5884
|
+
Pi as handlerOrderList,
|
|
5885
|
+
wi as isAllEqual,
|
|
5886
|
+
Ii as isDescendingOrder,
|
|
5887
|
+
us as makeResponseHelper,
|
|
5888
|
+
ts as objectAllInArrayComparator,
|
|
5889
|
+
Ze as objectComparator,
|
|
5890
|
+
es as objectOrderInArrayComparator,
|
|
5891
|
+
cs as setQuery,
|
|
5892
|
+
O as stringHelper
|
|
5467
5893
|
};
|
|
5468
5894
|
//# sourceMappingURL=q-store-model.esm.js.map
|