@aptos-scp/scp-component-store-selling-features-domain-model 2.35.2 → 2.36.0
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/lib/domain/UIBusinessEventTypes.d.ts +1 -0
- package/lib/domain/UIBusinessEventTypes.js +1 -0
- package/lib/domain/model/MerchandiseTransaction.d.ts +2 -0
- package/lib/domain/model/MerchandiseTransaction.js +8 -0
- package/lib/domain/model/TenderHandlingSession.d.ts +1 -0
- package/lib/domain/model/TenderHandlingSession.js +19 -4
- package/package.json +2 -1
|
@@ -50,6 +50,7 @@ export declare const ITEM_TAX_OVERRIDE_EVENT = "ItemTaxOverride";
|
|
|
50
50
|
export declare const SELL_ITEM_NOT_ON_FILE_EVENT: string;
|
|
51
51
|
export declare const ORDER_ITEM_NOT_ON_FILE_EVENT: string;
|
|
52
52
|
export declare const ORDER_ITEM_CANCELLATION_EVENT: string;
|
|
53
|
+
export declare const FINALIZE_ORDER_ITEM_CANCELLATION_EVENT: string;
|
|
53
54
|
export declare const ORDER_ITEM_RESTORE_EVENT: string;
|
|
54
55
|
export declare const RESERVED_ORDER_ITEM_CANCELLATION_EVENT: string;
|
|
55
56
|
export declare const ORDER_ITEM_PICKUP_EVENT: string;
|
|
@@ -53,6 +53,7 @@ exports.ITEM_TAX_OVERRIDE_EVENT = "ItemTaxOverride";
|
|
|
53
53
|
exports.SELL_ITEM_NOT_ON_FILE_EVENT = "SellItemNotOnFile";
|
|
54
54
|
exports.ORDER_ITEM_NOT_ON_FILE_EVENT = "OrderItemNotOnFile";
|
|
55
55
|
exports.ORDER_ITEM_CANCELLATION_EVENT = "OrderItemCancellation";
|
|
56
|
+
exports.FINALIZE_ORDER_ITEM_CANCELLATION_EVENT = "FinalizeOrderItemCancellation";
|
|
56
57
|
exports.ORDER_ITEM_RESTORE_EVENT = "OrderItemRestore";
|
|
57
58
|
exports.RESERVED_ORDER_ITEM_CANCELLATION_EVENT = "ReservedOrderItemCancellation";
|
|
58
59
|
exports.ORDER_ITEM_PICKUP_EVENT = "OrderItemPickup";
|
|
@@ -124,6 +124,7 @@ export declare class MerchandiseTransaction extends RetailTransaction implements
|
|
|
124
124
|
private _shouldUpdatePricing;
|
|
125
125
|
private _hasPromisedToPayWithPLCC;
|
|
126
126
|
private _shouldUpdateTaxation;
|
|
127
|
+
private _fulfillmentAuthorizationStatus?;
|
|
127
128
|
private _referenceNumber;
|
|
128
129
|
private _giftReceipt;
|
|
129
130
|
private _giftReceiptMode;
|
|
@@ -324,6 +325,7 @@ export declare class MerchandiseTransaction extends RetailTransaction implements
|
|
|
324
325
|
get shouldUpdatePricing(): boolean;
|
|
325
326
|
get hasPromisedToPayWithPLCC(): boolean;
|
|
326
327
|
get shouldUpdateTaxation(): boolean;
|
|
328
|
+
get fulfillmentAuthorizationStatus(): string | undefined;
|
|
327
329
|
get giftReceiptMode(): GiftReceiptMode;
|
|
328
330
|
get giftReceipt(): boolean;
|
|
329
331
|
get transactionTotal(): Money;
|
|
@@ -69,6 +69,7 @@ class MerchandiseTransaction extends RetailTransaction_1.RetailTransaction {
|
|
|
69
69
|
this._shouldUpdatePricing = false;
|
|
70
70
|
this._hasPromisedToPayWithPLCC = false;
|
|
71
71
|
this._shouldUpdateTaxation = false;
|
|
72
|
+
this._fulfillmentAuthorizationStatus = undefined;
|
|
72
73
|
this._transactionReferenceFormatter = transactionReferenceFormatter;
|
|
73
74
|
this._giftReceiptMode = giftReceiptMode;
|
|
74
75
|
this._giftReceipt = giftReceipt;
|
|
@@ -186,6 +187,7 @@ class MerchandiseTransaction extends RetailTransaction_1.RetailTransaction {
|
|
|
186
187
|
transaction._shouldUpdatePricing = this._shouldUpdatePricing;
|
|
187
188
|
transaction._hasPromisedToPayWithPLCC = this._hasPromisedToPayWithPLCC;
|
|
188
189
|
transaction._shouldUpdateTaxation = this._shouldUpdateTaxation;
|
|
190
|
+
transaction._fulfillmentAuthorizationStatus = this._fulfillmentAuthorizationStatus;
|
|
189
191
|
transaction._transactionReferenceFormatter = this._transactionReferenceFormatter;
|
|
190
192
|
transaction._referenceNumber = this._referenceNumber;
|
|
191
193
|
transaction._giftReceiptMode = this._giftReceiptMode;
|
|
@@ -802,6 +804,9 @@ class MerchandiseTransaction extends RetailTransaction_1.RetailTransaction {
|
|
|
802
804
|
get shouldUpdateTaxation() {
|
|
803
805
|
return this._shouldUpdateTaxation;
|
|
804
806
|
}
|
|
807
|
+
get fulfillmentAuthorizationStatus() {
|
|
808
|
+
return this._fulfillmentAuthorizationStatus;
|
|
809
|
+
}
|
|
805
810
|
get giftReceiptMode() {
|
|
806
811
|
return this._giftReceiptMode;
|
|
807
812
|
}
|
|
@@ -891,6 +896,7 @@ class MerchandiseTransaction extends RetailTransaction_1.RetailTransaction {
|
|
|
891
896
|
["transaction.feeTax", this.transactionFeeTax],
|
|
892
897
|
["transaction.totalFee", this.transactionTotalFee],
|
|
893
898
|
["transaction.hasPromisedToPayWithPLCC", this._hasPromisedToPayWithPLCC],
|
|
899
|
+
["transaction.fulfillmentAuthorizationStatus", this._fulfillmentAuthorizationStatus],
|
|
894
900
|
["transaction.transactionTotalFeeAfterTaxAdjustment", this._transactionTotalFeeAfterTaxAdjustment],
|
|
895
901
|
["transaction.returnSubTotal", this._returnSubTotal],
|
|
896
902
|
["transaction.returnSubTotalExcludingTax", this._returnSubTotalExcludingTax],
|
|
@@ -1033,6 +1039,7 @@ class MerchandiseTransaction extends RetailTransaction_1.RetailTransaction {
|
|
|
1033
1039
|
_shouldUpdatePricing: this.shouldUpdatePricing,
|
|
1034
1040
|
_hasPromisedToPayWithPLCC: this.hasPromisedToPayWithPLCC,
|
|
1035
1041
|
_shouldUpdateTaxation: this.shouldUpdateTaxation,
|
|
1042
|
+
_fulfillmentAuthorizationStatus: this.fulfillmentAuthorizationStatus,
|
|
1036
1043
|
_referenceNumber: this.referenceNumber,
|
|
1037
1044
|
_giftReceiptMode: this.giftReceiptMode,
|
|
1038
1045
|
_giftReceipt: this.giftReceipt,
|
|
@@ -1182,6 +1189,7 @@ class MerchandiseTransaction extends RetailTransaction_1.RetailTransaction {
|
|
|
1182
1189
|
this._shouldUpdatePricing = transactionJsonObj._shouldUpdatePricing;
|
|
1183
1190
|
this._hasPromisedToPayWithPLCC = transactionJsonObj._hasPromisedToPayWithPLCC;
|
|
1184
1191
|
this._shouldUpdateTaxation = transactionJsonObj._shouldUpdateTaxation;
|
|
1192
|
+
this._fulfillmentAuthorizationStatus = transactionJsonObj._fulfillmentAuthorizationStatus;
|
|
1185
1193
|
this._referenceNumber = transactionJsonObj._referenceNumber;
|
|
1186
1194
|
this._giftReceiptMode = transactionJsonObj._giftReceiptMode;
|
|
1187
1195
|
this._giftReceipt = transactionJsonObj._giftReceipt;
|
|
@@ -5,6 +5,7 @@ const scp_component_business_core_1 = require("@aptos-scp/scp-component-business
|
|
|
5
5
|
const scp_component_logging_1 = require("@aptos-scp/scp-component-logging");
|
|
6
6
|
const scp_types_commerce_devices_1 = require("@aptos-scp/scp-types-commerce-devices");
|
|
7
7
|
const scp_types_commerce_transaction_1 = require("@aptos-scp/scp-types-commerce-transaction");
|
|
8
|
+
const scp_types_fiscal_transaction_1 = require("@aptos-scp/scp-types-fiscal-transaction");
|
|
8
9
|
const Constants_1 = require("./Constants");
|
|
9
10
|
const logger = scp_component_logging_1.LogManager.getLogger("com.aptos.storesellingfeatures.domain.model.TenderHandlingSession");
|
|
10
11
|
exports.TENDER_SESSION = "TenderHandlingSession";
|
|
@@ -139,11 +140,11 @@ function getOriginalTransactionDetails(originalTransaction, configuredTenders) {
|
|
|
139
140
|
const originalTenderLines = ((_c = originalTransactionLines) === null || _c === void 0 ? void 0 : _c.filter((line) => scp_types_commerce_transaction_1.isTenderLine && line.lineType === scp_types_commerce_transaction_1.LineType.TenderPayment)) || [];
|
|
140
141
|
let originalTenders = [];
|
|
141
142
|
originalTenderLines.forEach((tenderLine) => {
|
|
142
|
-
var _a, _b;
|
|
143
|
+
var _a, _b, _c;
|
|
143
144
|
if (scp_types_commerce_transaction_1.isTenderLine(tenderLine)) {
|
|
144
145
|
const { tenderAuthCategory, additionalTenderAuthCategories } = (_a = getTenderAuthCategories(tenderLine.tenderId, configuredTenders), (_a !== null && _a !== void 0 ? _a : {}));
|
|
145
146
|
if (originalTenderNeeded(tenderLine, tenderAuthCategory, originalTenders)) {
|
|
146
|
-
originalTenders.push(getOriginalTenderFromLine(tenderLine, tenderAuthCategory, getAssociatedAdditionalData(originalTransaction.additionalData, tenderLine.sequenceNumberFromReturnCanonicalTransaction), (_b = originalTransaction.transaction) === null || _b === void 0 ? void 0 : _b.transactionId, additionalTenderAuthCategories));
|
|
147
|
+
originalTenders.push(getOriginalTenderFromLine(tenderLine, tenderAuthCategory, getAssociatedAdditionalData(originalTransaction.additionalData, tenderLine.sequenceNumberFromReturnCanonicalTransaction), (_b = originalTransaction.transaction) === null || _b === void 0 ? void 0 : _b.transactionId, additionalTenderAuthCategories, (_c = originalTransaction.transaction) === null || _c === void 0 ? void 0 : _c.order));
|
|
147
148
|
}
|
|
148
149
|
else {
|
|
149
150
|
combineUnreferenceOriginalTenders(originalTenders, tenderLine, getAssociatedAdditionalData(originalTransaction.additionalData, tenderLine.sequenceNumberFromReturnCanonicalTransaction));
|
|
@@ -214,7 +215,7 @@ function originalTenderNeeded(tenderLine, tenderAuthCategory, currentOriginalTen
|
|
|
214
215
|
return !((_a = currentOriginalTenders) === null || _a === void 0 ? void 0 : _a.find((tender) => tender.tenderId === tenderLine.tenderId));
|
|
215
216
|
}
|
|
216
217
|
}
|
|
217
|
-
function getOriginalTenderFromLine(tenderLine, tenderAuthCategory, additionalLineData, originalTransactionId, additionalTenderAuthCategories = []) {
|
|
218
|
+
function getOriginalTenderFromLine(tenderLine, tenderAuthCategory, additionalLineData, originalTransactionId, additionalTenderAuthCategories = [], order) {
|
|
218
219
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
219
220
|
const showReference = (tenderAuthCategory === Constants_1.TenderAuthCategory.TapToPayOnPOS ||
|
|
220
221
|
tenderAuthCategory === Constants_1.TenderAuthCategory.PaymentDevice ||
|
|
@@ -222,6 +223,7 @@ function getOriginalTenderFromLine(tenderLine, tenderAuthCategory, additionalLin
|
|
|
222
223
|
tenderAuthCategory === Constants_1.TenderAuthCategory.PayByLink) &&
|
|
223
224
|
tenderLine.tenderDetails &&
|
|
224
225
|
tenderLine.tenderDetails.paymentProvider !== scp_types_commerce_devices_1.PaymentProvider.NonIntegrated;
|
|
226
|
+
const isPreAuthorized = isTenderPreAuthorizedInOrder(order, tenderLine);
|
|
225
227
|
const originalTenderAmount = tenderLine.tenderAmount && scp_component_business_core_1.Money.fromIMoney(tenderLine.tenderAmount);
|
|
226
228
|
const initialRefundedAmount = tenderLine.tenderAmount && new scp_component_business_core_1.Money(0, tenderLine.tenderAmount.currency);
|
|
227
229
|
const previouslyRefundedAmount = getAdditionalDataRefundedAmount(additionalLineData) || initialRefundedAmount;
|
|
@@ -239,7 +241,7 @@ function getOriginalTenderFromLine(tenderLine, tenderAuthCategory, additionalLin
|
|
|
239
241
|
];
|
|
240
242
|
return {
|
|
241
243
|
originalTenderAmount,
|
|
242
|
-
refundedAmount: initialRefundedAmount,
|
|
244
|
+
refundedAmount: isPreAuthorized ? originalTenderAmount : initialRefundedAmount,
|
|
243
245
|
previouslyRefundedAmount,
|
|
244
246
|
refundAllowed,
|
|
245
247
|
showReference,
|
|
@@ -257,8 +259,20 @@ function getOriginalTenderFromLine(tenderLine, tenderAuthCategory, additionalLin
|
|
|
257
259
|
lastFour,
|
|
258
260
|
originalTransactionReferences: getOriginalTransactionReferences(originalTransactionId, originalLineReferences),
|
|
259
261
|
additionalTenderAuthCategories,
|
|
262
|
+
isPreAuthorized,
|
|
260
263
|
};
|
|
261
264
|
}
|
|
265
|
+
function isTenderPreAuthorizedInOrder(order, tenderLine) {
|
|
266
|
+
var _a, _b, _c, _d, _e, _f;
|
|
267
|
+
const tenderId = (_a = tenderLine) === null || _a === void 0 ? void 0 : _a.tenderId;
|
|
268
|
+
const referenceNumber = (_c = (_b = tenderLine) === null || _b === void 0 ? void 0 : _b.tenderDetails) === null || _c === void 0 ? void 0 : _c.referenceNumber;
|
|
269
|
+
if (!((_f = (_e = (_d = order) === null || _d === void 0 ? void 0 : _d.trade) === null || _e === void 0 ? void 0 : _e.lineItems) === null || _f === void 0 ? void 0 : _f.length) || !tenderId)
|
|
270
|
+
return false;
|
|
271
|
+
return order.trade.lineItems.some((lineItem) => {
|
|
272
|
+
var _a, _b, _c, _d, _e;
|
|
273
|
+
return ((_b = (_a = lineItem.tenderIn) === null || _a === void 0 ? void 0 : _a.tender) === null || _b === void 0 ? void 0 : _b.tenderId) === tenderId && ((_e = (_d = (_c = lineItem.tenderIn) === null || _c === void 0 ? void 0 : _c.tender) === null || _d === void 0 ? void 0 : _d.authorizations) === null || _e === void 0 ? void 0 : _e.some((auth) => auth.typeCode === scp_types_fiscal_transaction_1.TenderAuthorizationTypeEnum.Authorization && auth.id === referenceNumber));
|
|
274
|
+
});
|
|
275
|
+
}
|
|
262
276
|
function getOriginalTransactionReferences(transactionId, originalLineReferences) {
|
|
263
277
|
var _a;
|
|
264
278
|
return (_a = originalLineReferences) === null || _a === void 0 ? void 0 : _a.map((originalLineReference) => {
|
|
@@ -362,6 +376,7 @@ function createOrigTenderFromJson(jsonObject) {
|
|
|
362
376
|
refundableAmount: jsonObject.refundableAmount && scp_component_business_core_1.Money.fromIMoney(jsonObject.refundableAmount),
|
|
363
377
|
mappedOriginTenderId: jsonObject.mappedOriginTenderId,
|
|
364
378
|
additionalTenderAuthCategories: jsonObject.additionalTenderAuthCategories,
|
|
379
|
+
isPreAuthorized: jsonObject.isPreAuthorized,
|
|
365
380
|
};
|
|
366
381
|
}
|
|
367
382
|
function createOriginalTransactionReferencesFromJson(jsonObject) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aptos-scp/scp-component-store-selling-features-domain-model",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.36.0",
|
|
4
4
|
"description": "This component library provides the common components to handle the coordination of processing the business events from the UI.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
"prettier:format": "prettier --write ."
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
+
"@aptos-scp/scp-types-canonical-orders-web-services": "^1.1.1",
|
|
42
43
|
"@aptos-scp/scp-types-country-box": "^1.3.0",
|
|
43
44
|
"big.js": "^6.1.1",
|
|
44
45
|
"crc-32": "^1.2.0",
|