@aptos-scp/scp-component-store-selling-features-domain-model 2.49.0 → 2.49.2

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.
@@ -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) {
@@ -23,18 +23,7 @@ function buildTimeIntervalFromCode(code) {
23
23
  }
24
24
  exports.buildTimeIntervalFromCode = buildTimeIntervalFromCode;
25
25
  function buildDeliveryFrequencyTextFromTimeInterval(interval) {
26
- var _a;
27
- const labels = {
28
- Day: ["day", "days"],
29
- Week: ["week", "weeks"],
30
- Month: ["month", "months"],
31
- Year: ["year", "years"],
32
- };
33
- const [singular, plural] = (_a = labels[interval.unit], (_a !== null && _a !== void 0 ? _a : [
34
- interval.unit.toLowerCase(),
35
- `${interval.unit.toLowerCase()}s`,
36
- ]));
37
- return interval.value === 1 ? `Every ${singular}` : `Every ${interval.value} ${plural}`;
26
+ return `${interval.value} ${interval.unit}`;
38
27
  }
39
28
  exports.buildDeliveryFrequencyTextFromTimeInterval = buildDeliveryFrequencyTextFromTimeInterval;
40
29
  //# sourceMappingURL=subscriptionFrequencyUtils.js.map
@@ -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.0",
3
+ "version": "2.49.2",
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",