@aptos-scp/scp-component-store-selling-features-domain-model 2.49.1 → 2.50.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.
@@ -1052,6 +1052,8 @@ export declare const TRANSACTION_WAITING_ON_STARTUP_EVENT: string;
1052
1052
  export declare const TRANSACTION_RESUMING_ON_STARTUP_EVENT: string;
1053
1053
  export declare const STORED_VALUE_REVERSAL_COMPLETED_EVENT_TYPE: string;
1054
1054
  export declare const STORED_VALUE_CERTIFICATE_REVERSAL_COMPLETED_EVENT_TYPE: string;
1055
+ export declare const PAYMENT_AUTH_INITIALIZE_START_EVENT_TYPE: string;
1056
+ export declare const PAYMENT_AUTH_START_EVENT_TYPE: string;
1055
1057
  export declare const TENDER_CHANGE_CANCEL_EVENT_TYPE: string;
1056
1058
  export declare const CASH_DRAWER_SELECTED_EVENT: string;
1057
1059
  export declare const CASH_DRAWER_OPEN_REQUESTED_EVENT: string;
@@ -1063,6 +1063,8 @@ exports.TRANSACTION_WAITING_ON_STARTUP_EVENT = "Transaction.WaitingOnStartup";
1063
1063
  exports.TRANSACTION_RESUMING_ON_STARTUP_EVENT = "Transaction.ResumingOnStartup";
1064
1064
  exports.STORED_VALUE_REVERSAL_COMPLETED_EVENT_TYPE = "StoredValue.ReversalCompleted";
1065
1065
  exports.STORED_VALUE_CERTIFICATE_REVERSAL_COMPLETED_EVENT_TYPE = "StoredValueCertificate.ReversalCompleted";
1066
+ exports.PAYMENT_AUTH_INITIALIZE_START_EVENT_TYPE = "PaymentAuth.InitializeStart";
1067
+ exports.PAYMENT_AUTH_START_EVENT_TYPE = "PaymentAuth.Start";
1066
1068
  exports.TENDER_CHANGE_CANCEL_EVENT_TYPE = "TenderChange.Cancel";
1067
1069
  exports.CASH_DRAWER_SELECTED_EVENT = "CashDrawer.Selected";
1068
1070
  exports.CASH_DRAWER_OPEN_REQUESTED_EVENT = "CashDrawer.OpenRequested";
@@ -835,11 +835,17 @@ class MerchandiseTransaction extends RetailTransaction_1.RetailTransaction {
835
835
  const transactionChangeDue = this.transactionTotalTendered
836
836
  .plus(this.denominationRounding)
837
837
  .minus(this.transactionTotal);
838
- if (transactionChangeDue.isPositive() && this.transactionTotal.isPositive()) {
839
- return transactionChangeDue;
838
+ // Reward card tenders do not generate change; the remaining balance is handled separately.
839
+ if (utils_1.isLastTenderRewardCard(this)) {
840
+ return new scp_component_business_core_1.Money(0, this._accountingCurrency);
840
841
  }
841
842
  else {
842
- return new scp_component_business_core_1.Money(0, this._accountingCurrency);
843
+ if (transactionChangeDue.isPositive() && this.transactionTotal.isPositive()) {
844
+ return transactionChangeDue;
845
+ }
846
+ else {
847
+ return new scp_component_business_core_1.Money(0, this._accountingCurrency);
848
+ }
843
849
  }
844
850
  }
845
851
  get returnTotal() {
@@ -1377,12 +1383,20 @@ class MerchandiseTransaction extends RetailTransaction_1.RetailTransaction {
1377
1383
  if (removeTotalTendered) {
1378
1384
  balanceDue = balanceDue.minus(totalTendered.plus(this.denominationRounding));
1379
1385
  }
1380
- if ((totalAmount.isPositive() && balanceDue.isPositive()) ||
1381
- (totalAmount.isNegative() && balanceDue.isNegative())) {
1386
+ // When the last tender is a reward card, return the raw balance without clamping to zero.
1387
+ // This allows the UI to display the outstanding balance that remains after the reward card
1388
+ // was applied, even when the signed balance would normally be suppressed.
1389
+ if (utils_1.isLastTenderRewardCard(this)) {
1382
1390
  return balanceDue;
1383
1391
  }
1384
1392
  else {
1385
- return new scp_component_business_core_1.Money(0, this._accountingCurrency);
1393
+ if ((totalAmount.isPositive() && balanceDue.isPositive()) ||
1394
+ (totalAmount.isNegative() && balanceDue.isNegative())) {
1395
+ return balanceDue;
1396
+ }
1397
+ else {
1398
+ return new scp_component_business_core_1.Money(0, this._accountingCurrency);
1399
+ }
1386
1400
  }
1387
1401
  }
1388
1402
  generateTransactionReferenceNumber(transaction) {
@@ -6,3 +6,17 @@ export declare function getLocaleCodeForTranslationSet<T>(translationSet: {
6
6
  export declare const getTradeType: (transaction: ITransaction) => MerchandiseTransactionTradeType;
7
7
  export declare const isTimeOutError: (error: PosError) => boolean;
8
8
  export declare const getServiceResult: (isSuccess: boolean, error?: Error, statusCode?: number) => IServiceResult;
9
+ /**
10
+ * Returns true when the most recently applied non-voided tender in the transaction was a
11
+ * reward card (RewardCardTenderLine or RewardCardTenderRefundLine).
12
+ *
13
+ * The check follows a three-step reference chain that is written by the authorization flow:
14
+ * TenderLine.transactionLineReference
15
+ * → TenderAuthorizationStatusLine.transactionLineReference
16
+ * → RewardCardTenderLine | RewardCardTenderRefundLine
17
+ *
18
+ * When a reward card tender is the last tender, callers suppress change-due and skip the
19
+ * balance-due sign-clamp so the remaining balance is shown correctly to the cashier during
20
+ * a return/RWR flow where the original sale included a reward card tender.
21
+ */
22
+ export declare const isLastTenderRewardCard: (transaction: ITransaction) => boolean;
@@ -85,4 +85,36 @@ exports.getServiceResult = (isSuccess, error, statusCode) => {
85
85
  };
86
86
  }
87
87
  };
88
+ /**
89
+ * Returns true when the most recently applied non-voided tender in the transaction was a
90
+ * reward card (RewardCardTenderLine or RewardCardTenderRefundLine).
91
+ *
92
+ * The check follows a three-step reference chain that is written by the authorization flow:
93
+ * TenderLine.transactionLineReference
94
+ * → TenderAuthorizationStatusLine.transactionLineReference
95
+ * → RewardCardTenderLine | RewardCardTenderRefundLine
96
+ *
97
+ * When a reward card tender is the last tender, callers suppress change-due and skip the
98
+ * balance-due sign-clamp so the remaining balance is shown correctly to the cashier during
99
+ * a return/RWR flow where the original sale included a reward card tender.
100
+ */
101
+ exports.isLastTenderRewardCard = (transaction) => {
102
+ var _a, _b, _c, _d, _e;
103
+ if (model_1.isMerchandiseTransaction(transaction)) {
104
+ const tenderLines = (_a = transaction.lines) === null || _a === void 0 ? void 0 : _a.filter((line) => model_1.isTenderLine(line) && !line.voided);
105
+ if (((_b = tenderLines) === null || _b === void 0 ? void 0 : _b.length) > 0) {
106
+ const lastTenderLine = tenderLines[tenderLines.length - 1];
107
+ if ((_c = lastTenderLine.transactionLineReference) === null || _c === void 0 ? void 0 : _c.lineNumber) {
108
+ const transactionStatusLine = transaction.findLineByLineNumber(lastTenderLine.transactionLineReference.lineNumber);
109
+ if (transactionStatusLine &&
110
+ model_1.isTenderAuthorizationStatusLine(transactionStatusLine) && ((_d = transactionStatusLine.transactionLineReference) === null || _d === void 0 ? void 0 : _d.lineNumber)) {
111
+ const transactionLine = transaction.findLineByLineNumber((_e = transactionStatusLine.transactionLineReference) === null || _e === void 0 ? void 0 : _e.lineNumber);
112
+ return (transactionLine &&
113
+ (model_1.isRewardCardTenderLine(transactionLine) || model_1.isRewardCardTenderRefundLine(transactionLine)));
114
+ }
115
+ }
116
+ }
117
+ }
118
+ return false;
119
+ };
88
120
  //# sourceMappingURL=utils.js.map
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.49.1",
3
+ "version": "2.50.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",