@aptos-scp/scp-component-store-selling-features-domain-model 2.47.0 → 2.48.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.
@@ -53,7 +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
+ exports.FINALIZE_ORDER_ITEM_CANCELLATION_EVENT = "FinalizeOrderItemCancellation"; //Deprecated
57
57
  exports.ORDER_ITEM_RESTORE_EVENT = "OrderItemRestore";
58
58
  exports.RESERVED_ORDER_ITEM_CANCELLATION_EVENT = "ReservedOrderItemCancellation";
59
59
  exports.ORDER_ITEM_PICKUP_EVENT = "OrderItemPickup";
@@ -333,6 +333,10 @@ export declare enum UiInputKey {
333
333
  MAPPED_REFUND_TENDER_TYPE_NAME = "input_mappedRefundTenderTypeName",
334
334
  MAPPED_REFUND_CARD_TYPE_NAME = "input_mappedRefundCardTypeName",
335
335
  PRE_AUTH = "input_preAuth",
336
+ /**
337
+ * When true, APPLY_TENDER (routed to refund) is reversing tender held as authorization only (e.g. order cancel).
338
+ */
339
+ PRE_AUTHORIZATION_REVERSAL = "input_preAuthorizationReversal",
336
340
  EXCLUDED_REFUND_CARD_TYPE_NAMES = "input_excludedRefundCardTypeNames",
337
341
  TRANSACTION_NUMBER_FIELD = "input_transactionNumberField",
338
342
  TRANSACTION_REFERENCE_NUMBER_FIELD = "input_referenceNumberField",
@@ -986,6 +990,11 @@ export declare enum CollectedDataKey {
986
990
  PrepaidTaxAmount = "prepaidTaxAmount",
987
991
  PrepaidSavingsAmount = "prepaidSavingsAmount",
988
992
  PreviouslyCollectedTender = "previouslyCollectedTender",
993
+ /**
994
+ * When ToBeStarted (or legacy boolean true) as collected data with TenderAuthResponse,
995
+ * merges IAuthorizationResponse.preAuthorizationReversalStatus.
996
+ */
997
+ PreAuthorizationReversal = "PreAuthorizationReversal",
989
998
  PresetRateExemption = "presetRateExemption",
990
999
  PresetExemptionCategory = "presetExemptionCategory",
991
1000
  PresetExemptionRate = "presetExemptionRate",
@@ -334,6 +334,10 @@ var UiInputKey;
334
334
  UiInputKey["MAPPED_REFUND_TENDER_TYPE_NAME"] = "input_mappedRefundTenderTypeName";
335
335
  UiInputKey["MAPPED_REFUND_CARD_TYPE_NAME"] = "input_mappedRefundCardTypeName";
336
336
  UiInputKey["PRE_AUTH"] = "input_preAuth";
337
+ /**
338
+ * When true, APPLY_TENDER (routed to refund) is reversing tender held as authorization only (e.g. order cancel).
339
+ */
340
+ UiInputKey["PRE_AUTHORIZATION_REVERSAL"] = "input_preAuthorizationReversal";
337
341
  UiInputKey["EXCLUDED_REFUND_CARD_TYPE_NAMES"] = "input_excludedRefundCardTypeNames";
338
342
  UiInputKey["TRANSACTION_NUMBER_FIELD"] = "input_transactionNumberField";
339
343
  UiInputKey["TRANSACTION_REFERENCE_NUMBER_FIELD"] = "input_referenceNumberField";
@@ -993,6 +997,11 @@ var CollectedDataKey;
993
997
  CollectedDataKey["PrepaidTaxAmount"] = "prepaidTaxAmount";
994
998
  CollectedDataKey["PrepaidSavingsAmount"] = "prepaidSavingsAmount";
995
999
  CollectedDataKey["PreviouslyCollectedTender"] = "previouslyCollectedTender";
1000
+ /**
1001
+ * When ToBeStarted (or legacy boolean true) as collected data with TenderAuthResponse,
1002
+ * merges IAuthorizationResponse.preAuthorizationReversalStatus.
1003
+ */
1004
+ CollectedDataKey["PreAuthorizationReversal"] = "PreAuthorizationReversal";
996
1005
  CollectedDataKey["PresetRateExemption"] = "presetRateExemption";
997
1006
  CollectedDataKey["PresetExemptionCategory"] = "presetExemptionCategory";
998
1007
  CollectedDataKey["PresetExemptionRate"] = "presetExemptionRate";
@@ -352,10 +352,13 @@ class TenderType {
352
352
  return tenderType;
353
353
  }
354
354
  signatureRequired(tenderAmount, authResponse) {
355
- var _a;
355
+ var _a, _b;
356
356
  let sigRequired = false;
357
+ if (((_a = authResponse) === null || _a === void 0 ? void 0 : _a.preAuthorizationReversalStatus) != null) {
358
+ return false;
359
+ }
357
360
  //if the auth type is updateAuthorization then use signatureCapturePolicyForCallForAuth
358
- const signatureCapturePolicy = ((_a = authResponse) === null || _a === void 0 ? void 0 : _a.requestType) === scp_types_commerce_devices_1.PaymentRequestType.UpdateAuthorization
361
+ const signatureCapturePolicy = ((_b = authResponse) === null || _b === void 0 ? void 0 : _b.requestType) === scp_types_commerce_devices_1.PaymentRequestType.UpdateAuthorization
359
362
  ? this.signatureCapturePolicyForCallForAuth
360
363
  : this.signatureCapturePolicy;
361
364
  switch (signatureCapturePolicy) {
@@ -7,10 +7,9 @@ import { IManualDiscountLine } from "./IManualDiscountLine";
7
7
  import { ManualDiscountLineTotalDecorator } from "./ManualDiscountLineTotalDecorator";
8
8
  import { IRewardCardDiscountLine } from "./IRewardCardDiscountLine";
9
9
  export declare const DECORATOR_TYPE_REWARD_CARD_DISCOUNT_TOTAL: string;
10
- export declare const REWARD_CARD_TOTAL_DISCOUNT_ANNOTATION_SOURCE: string;
11
10
  export declare class RewardCardDiscountLineTotalDecorator extends ManualDiscountLineTotalDecorator implements IRewardCardDiscountLine {
12
11
  static createFromJsonObject(transactionLineJsonObj: any, transactionLineFactory: ITransactionLineFactory): RewardCardDiscountLineTotalDecorator;
13
- constructor(decoratorLineType: string, decoratedTransactionLine: IManualDiscountLine, totalDiscount: Money, annotationSourceLineNumber?: number);
12
+ constructor(decoratorLineType: string, decoratedTransactionLine: IManualDiscountLine, totalDiscount: Money, annotationSourceType: string, annotationSourceLineNumber?: number);
14
13
  get discountLevel(): ManualDiscountLevel;
15
14
  get rewardPrintedName(): string;
16
15
  get rewardPrintedNumberLabel(): string;
@@ -3,18 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const scp_component_business_core_1 = require("@aptos-scp/scp-component-business-core");
4
4
  const ManualDiscountLineTotalDecorator_1 = require("./ManualDiscountLineTotalDecorator");
5
5
  exports.DECORATOR_TYPE_REWARD_CARD_DISCOUNT_TOTAL = "DECORATOR_TYPE_REWARD_CARD_DISCOUNT_TOTAL";
6
- exports.REWARD_CARD_TOTAL_DISCOUNT_ANNOTATION_SOURCE = "REWARD_CARD_TOTAL_DISCOUNT_ANNOTATION_SOURCE";
7
6
  class RewardCardDiscountLineTotalDecorator extends ManualDiscountLineTotalDecorator_1.ManualDiscountLineTotalDecorator {
8
7
  static createFromJsonObject(transactionLineJsonObj, transactionLineFactory) {
9
8
  const decoratedTransactionLineJsonObj = this.getDecoratedTransactionLineJsonObjectFromJsonObject(transactionLineJsonObj);
10
9
  const decoratedLine = transactionLineFactory.createTransactionLineFromJsonObj(decoratedTransactionLineJsonObj);
11
10
  const totalDiscount = scp_component_business_core_1.Money.fromJSON(transactionLineJsonObj._totalDiscount);
11
+ const annotationSourceType = this.getAnnotationSourceTypeFromJsonObject(transactionLineJsonObj);
12
12
  const annotationSourceLineNumber = this.getAnnotationSourceLineNumberFromJsonObject(transactionLineJsonObj);
13
13
  const decoratorType = this.getLineDecoratorTypeFromJsonObject(transactionLineJsonObj);
14
- return new RewardCardDiscountLineTotalDecorator(decoratorType, decoratedLine, totalDiscount, annotationSourceLineNumber);
14
+ return new RewardCardDiscountLineTotalDecorator(decoratorType, decoratedLine, totalDiscount, annotationSourceType, annotationSourceLineNumber);
15
15
  }
16
- constructor(decoratorLineType, decoratedTransactionLine, totalDiscount, annotationSourceLineNumber) {
17
- super(decoratorLineType, decoratedTransactionLine, undefined, exports.REWARD_CARD_TOTAL_DISCOUNT_ANNOTATION_SOURCE, totalDiscount, annotationSourceLineNumber);
16
+ constructor(decoratorLineType, decoratedTransactionLine, totalDiscount, annotationSourceType, annotationSourceLineNumber) {
17
+ super(decoratorLineType, decoratedTransactionLine, undefined, annotationSourceType, totalDiscount, annotationSourceLineNumber);
18
18
  }
19
19
  get discountLevel() {
20
20
  return this.decoratedTransactionLine.discountLevel;
@@ -59,7 +59,7 @@ class RewardCardDiscountLineTotalDecorator extends ManualDiscountLineTotalDecora
59
59
  return this.decoratedTransactionLine.inputSource;
60
60
  }
61
61
  newTransactionLine() {
62
- return new RewardCardDiscountLineTotalDecorator(this.lineDecoratorType, this.decoratedTransactionLine, this.totalDiscount, this.annotationSourceLineNumber);
62
+ return new RewardCardDiscountLineTotalDecorator(this.lineDecoratorType, this.decoratedTransactionLine, this.totalDiscount, this.annotationSourceType, this.annotationSourceLineNumber);
63
63
  }
64
64
  }
65
65
  exports.RewardCardDiscountLineTotalDecorator = RewardCardDiscountLineTotalDecorator;
@@ -27,6 +27,7 @@ export declare abstract class BaseTenderLineDecorator extends BaseLineDecorator<
27
27
  get transactionLineReference(): ITransactionLineReferenceType;
28
28
  get refundedLineReference(): ITransactionLineReferenceType;
29
29
  get originalTenderReferences(): IOriginalTenderReference[];
30
+ get isPreAuthorizationReversal(): boolean;
30
31
  get refunded(): boolean;
31
32
  signatureRequired(): boolean;
32
33
  printDeclineDetails(): boolean;
@@ -51,6 +51,9 @@ class BaseTenderLineDecorator extends BaseLineDecorator_1.BaseLineDecorator {
51
51
  get originalTenderReferences() {
52
52
  return this.decoratedTransactionLine.originalTenderReferences;
53
53
  }
54
+ get isPreAuthorizationReversal() {
55
+ return this.decoratedTransactionLine.isPreAuthorizationReversal;
56
+ }
54
57
  get refunded() {
55
58
  return this.decoratedTransactionLine.refunded;
56
59
  }
@@ -26,6 +26,8 @@ export interface ITenderLine extends ITransactionLine, IVoidableLine {
26
26
  readonly adjustmentType?: TenderAdjustmentType;
27
27
  readonly originalTenderReferences?: IOriginalTenderReference[];
28
28
  readonly actionType?: ActionType;
29
+ /** True when this TenderRefund reverses an authorization-only hold (see IAuthorizationResponse.preAuthorizationReversalStatus). */
30
+ readonly isPreAuthorizationReversal?: boolean;
29
31
  readonly tax?: Money;
30
32
  /**
31
33
  * The amount given before the conversion
@@ -4,11 +4,10 @@ import { BaseLineDecorator } from "../BaseLineDecorator";
4
4
  import { VoidSource } from "../Constants";
5
5
  import { RewardCardTenderLine } from "./RewardCardTenderLine";
6
6
  export declare const DECORATOR_TYPE_REWARD_CARD_TENDER_APPLIED_AMOUNT: string;
7
- export declare const REWARD_CARD_TENDER_APPLIED_AMOUNT_ANNOTATION_SOURCE: string;
8
7
  export declare class RewardCardTenderAppliedAmountDecorator extends BaseLineDecorator<RewardCardTenderLine> {
9
8
  private _appliedAmount;
10
9
  static createFromJsonObject(transactionLineJsonObj: any, transactionLineFactory: ITransactionLineFactory): RewardCardTenderAppliedAmountDecorator;
11
- constructor(decoratorLineType: string, decoratedTransactionLine: RewardCardTenderLine, appliedAmount: Money, annotationSourceLineNumber?: number);
10
+ constructor(decoratorLineType: string, decoratedTransactionLine: RewardCardTenderLine, appliedAmount: Money, annotationSourceType: string, annotationSourceLineNumber?: number);
12
11
  get appliedAmount(): Money;
13
12
  get cardNumber(): string;
14
13
  get customerNumber(): string;
@@ -3,19 +3,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const scp_component_business_core_1 = require("@aptos-scp/scp-component-business-core");
4
4
  const BaseLineDecorator_1 = require("../BaseLineDecorator");
5
5
  exports.DECORATOR_TYPE_REWARD_CARD_TENDER_APPLIED_AMOUNT = "DECORATOR_TYPE_REWARD_CARD_TENDER_APPLIED_AMOUNT";
6
- exports.REWARD_CARD_TENDER_APPLIED_AMOUNT_ANNOTATION_SOURCE = "REWARD_CARD_TENDER_APPLIED_AMOUNT_ANNOTATION_SOURCE";
7
6
  class RewardCardTenderAppliedAmountDecorator extends BaseLineDecorator_1.BaseLineDecorator {
8
- constructor(decoratorLineType, decoratedTransactionLine, appliedAmount, annotationSourceLineNumber) {
9
- super(decoratorLineType, decoratedTransactionLine, exports.REWARD_CARD_TENDER_APPLIED_AMOUNT_ANNOTATION_SOURCE, exports.REWARD_CARD_TENDER_APPLIED_AMOUNT_ANNOTATION_SOURCE, annotationSourceLineNumber);
7
+ constructor(decoratorLineType, decoratedTransactionLine, appliedAmount, annotationSourceType, annotationSourceLineNumber) {
8
+ super(decoratorLineType, decoratedTransactionLine, undefined, annotationSourceType, annotationSourceLineNumber);
10
9
  this._appliedAmount = appliedAmount;
11
10
  }
12
11
  static createFromJsonObject(transactionLineJsonObj, transactionLineFactory) {
13
12
  const decoratedTransactionLineJsonObj = BaseLineDecorator_1.BaseLineDecorator.getDecoratedTransactionLineJsonObjectFromJsonObject(transactionLineJsonObj);
14
13
  const decoratedLine = transactionLineFactory.createTransactionLineFromJsonObj(decoratedTransactionLineJsonObj);
15
14
  const appliedAmount = scp_component_business_core_1.Money.fromJSON(transactionLineJsonObj._appliedAmount);
15
+ const annotationSourceType = BaseLineDecorator_1.BaseLineDecorator.getAnnotationSourceTypeFromJsonObject(transactionLineJsonObj);
16
16
  const annotationSourceLineNumber = BaseLineDecorator_1.BaseLineDecorator.getAnnotationSourceLineNumberFromJsonObject(transactionLineJsonObj);
17
17
  const decoratorType = BaseLineDecorator_1.BaseLineDecorator.getLineDecoratorTypeFromJsonObject(transactionLineJsonObj);
18
- return new RewardCardTenderAppliedAmountDecorator(decoratorType, decoratedLine, appliedAmount, annotationSourceLineNumber);
18
+ return new RewardCardTenderAppliedAmountDecorator(decoratorType, decoratedLine, appliedAmount, annotationSourceType, annotationSourceLineNumber);
19
19
  }
20
20
  get appliedAmount() {
21
21
  return this._appliedAmount;
@@ -51,7 +51,7 @@ class RewardCardTenderAppliedAmountDecorator extends BaseLineDecorator_1.BaseLin
51
51
  return this.decoratedTransactionLine.isAuthorized;
52
52
  }
53
53
  newTransactionLine() {
54
- return new RewardCardTenderAppliedAmountDecorator(this.lineDecoratorType, this.decoratedTransactionLine, this._appliedAmount, this.annotationSourceLineNumber);
54
+ return new RewardCardTenderAppliedAmountDecorator(this.lineDecoratorType, this.decoratedTransactionLine, this._appliedAmount, this.annotationSourceType, this.annotationSourceLineNumber);
55
55
  }
56
56
  }
57
57
  exports.RewardCardTenderAppliedAmountDecorator = RewardCardTenderAppliedAmountDecorator;
@@ -78,6 +78,10 @@ export declare class TenderLine extends BaseTransactionLine implements ITenderLi
78
78
  get preventsTransactionVoid(): boolean;
79
79
  get forfeitTenderChangeConfirmed(): boolean;
80
80
  get isPreviouslyCollected(): boolean;
81
+ /**
82
+ * True when this TenderRefund line reverses a tender that was only pre-authorized (authorization reversal).
83
+ */
84
+ get isPreAuthorizationReversal(): boolean;
81
85
  get allowVoid(): boolean;
82
86
  get adjustmentType(): TenderAdjustmentType;
83
87
  get voidingLine(): boolean;
@@ -61,7 +61,19 @@ class TenderLine extends BaseTransactionLine_1.BaseTransactionLine {
61
61
  // The tender could (in the future) be a foreign tender with a currency other than the accounting currency.
62
62
  const accountingCurrency = collectedData.get("accountingCurrency");
63
63
  const extendedAmount = TenderLine.determineExtendedAmount(lineType, tenderAmount, accountingCurrency);
64
- const authResponse = collectedData.get(Constants_1.CollectedDataKey.TenderAuthResponse);
64
+ // Auth payload from qualification (e.g. device response). When PreAuthorizationReversal is collected
65
+ // (order-cancel apply of OMS pre-auth), copy and stamp preAuthorizationReversalStatus so posting/display
66
+ // treat the line as a reversal; default requestType to Refund if none was supplied.
67
+ let mergedAuthResponse = collectedData.get(Constants_1.CollectedDataKey.TenderAuthResponse);
68
+ const rawPreAuthReversal = collectedData.get(Constants_1.CollectedDataKey.PreAuthorizationReversal);
69
+ const preAuthorizationReversalCollected = rawPreAuthReversal === true || rawPreAuthReversal === scp_types_commerce_devices_1.PreAuthorizationReversalStatus.ToBeStarted;
70
+ if (preAuthorizationReversalCollected) {
71
+ mergedAuthResponse = Object.assign({}, (mergedAuthResponse || {}));
72
+ mergedAuthResponse.preAuthorizationReversalStatus = scp_types_commerce_devices_1.PreAuthorizationReversalStatus.ToBeStarted;
73
+ if (mergedAuthResponse.requestType === undefined) {
74
+ mergedAuthResponse.requestType = scp_types_commerce_devices_1.PaymentRequestType.Refund;
75
+ }
76
+ }
65
77
  const authorizationDeviceId = collectedData.get(Constants_1.CollectedDataKey.AuthorizationDeviceId);
66
78
  const preventsTransactionVoid = !!collectedData.get(Constants_1.CollectedDataKey.TenderPreventsTransactionVoid);
67
79
  const adjustmentType = collectedData.get(Constants_1.CollectedDataKey.TenderAdjustmentType);
@@ -81,7 +93,7 @@ class TenderLine extends BaseTransactionLine_1.BaseTransactionLine {
81
93
  const previouslyCollectedTender = collectedData.get(Constants_1.CollectedDataKey.PreviouslyCollectedTender)
82
94
  ? collectedData.get(Constants_1.CollectedDataKey.PreviouslyCollectedTender)
83
95
  : false;
84
- return new TenderLine(lineNumber, lineType, extendedAmount, tenderAuthCategory, tenderType, tenderAmount, authResponse, authorizationDeviceId, preventsTransactionVoid, adjustmentType, transactionLineReference, refundedLineReference, referenceNumber, residentLimit, promptRuleType, originalTenderReferences, actionType, supervisorOverrideLineReference, tax, foreignTenderAmount, exchangeRateValue, exchangeRateManualEntryLineReference, forfeitTenderChangeConfirmed, previouslyCollectedTender);
96
+ return new TenderLine(lineNumber, lineType, extendedAmount, tenderAuthCategory, tenderType, tenderAmount, mergedAuthResponse, authorizationDeviceId, preventsTransactionVoid, adjustmentType, transactionLineReference, refundedLineReference, referenceNumber, residentLimit, promptRuleType, originalTenderReferences, actionType, supervisorOverrideLineReference, tax, foreignTenderAmount, exchangeRateValue, exchangeRateManualEntryLineReference, forfeitTenderChangeConfirmed, previouslyCollectedTender);
85
97
  }
86
98
  static createFromJsonObject(transactionLineJsonObj) {
87
99
  const lineNumber = BaseTransactionLine_1.BaseTransactionLine.lineNumberFromJsonObject(transactionLineJsonObj);
@@ -210,12 +222,20 @@ class TenderLine extends BaseTransactionLine_1.BaseTransactionLine {
210
222
  get isPreviouslyCollected() {
211
223
  return this._previouslyCollectedTender;
212
224
  }
225
+ /**
226
+ * True when this TenderRefund line reverses a tender that was only pre-authorized (authorization reversal).
227
+ */
228
+ get isPreAuthorizationReversal() {
229
+ var _a;
230
+ return ((_a = this._authResponse) === null || _a === void 0 ? void 0 : _a.preAuthorizationReversalStatus) != null;
231
+ }
213
232
  get allowVoid() {
214
233
  var _a;
215
234
  if (this.authResponse &&
216
- this.authResponse.paymentProvider === scp_types_commerce_devices_1.PaymentProvider.Adyen &&
217
235
  this.lineType === exports.TENDER_REFUND_LINE_TYPE &&
218
- ((_a = this.tenderType) === null || _a === void 0 ? void 0 : _a.cardType) !== scp_types_commerce_devices_1.CardType.Gift) {
236
+ ((this.authResponse.paymentProvider === scp_types_commerce_devices_1.PaymentProvider.Adyen &&
237
+ ((_a = this.tenderType) === null || _a === void 0 ? void 0 : _a.cardType) !== scp_types_commerce_devices_1.CardType.Gift) ||
238
+ this.authResponse.preAuthorizationReversalStatus != null)) {
219
239
  //a payment provider was used for a refund that can't be voided, so don't allow voiding
220
240
  return false;
221
241
  }
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.47.0",
3
+ "version": "2.48.1",
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",
@@ -85,8 +85,8 @@
85
85
  "@aptos-scp/scp-component-taxation": "^5.28.0",
86
86
  "@aptos-scp/scp-component-user": "^1.4.0",
87
87
  "@aptos-scp/scp-types-client-registration": "^1.4.0",
88
- "@aptos-scp/scp-types-commerce-devices": "^6.10.0",
89
- "@aptos-scp/scp-types-commerce-transaction": "^1.93.0",
88
+ "@aptos-scp/scp-types-commerce-devices": "^6.12.0",
89
+ "@aptos-scp/scp-types-commerce-transaction": "^1.94.0",
90
90
  "@aptos-scp/scp-types-core": "^1.0.5",
91
91
  "@aptos-scp/scp-types-core-config": "^2.2.1",
92
92
  "@aptos-scp/scp-types-currency-conversion": "^1.2.0",