@aptos-scp/scp-component-store-selling-features-domain-model 2.2.0 → 2.3.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.
@@ -99,6 +99,7 @@ export declare enum UiInputKey {
99
99
  ASSIGN_CUSTOMER = "input_assignCustomer",
100
100
  ASSIGN_TO_TRANSACTION = "input_assignToTransaction",
101
101
  AUTHORIZATION_DEVICE_ID = "input_authorizationDeviceId",
102
+ AMOUNT_DUE = "input_amountDue",
102
103
  BUSINESS_DAY_DATE = "input_businessDayDate",
103
104
  SAME_AS_BILLTO = "input_sameAsBillTo",
104
105
  BILLING = "input_billing",
@@ -462,6 +463,7 @@ export declare enum CollectedDataKey {
462
463
  ApplyDiscountToBasePrice = "ApplyDiscountToBasePrice",
463
464
  AuthorizationDeviceId = "AuthorizationDeviceId",
464
465
  AutoApplied = "AutoApplied",
466
+ AmountDue = "AmountDue",
465
467
  BalanceInquiry = "BalanceInquiry",
466
468
  Billing = "Billing",
467
469
  SameAsBillTo = "SameAsBillTo",
@@ -101,6 +101,7 @@ var UiInputKey;
101
101
  UiInputKey["ASSIGN_CUSTOMER"] = "input_assignCustomer";
102
102
  UiInputKey["ASSIGN_TO_TRANSACTION"] = "input_assignToTransaction";
103
103
  UiInputKey["AUTHORIZATION_DEVICE_ID"] = "input_authorizationDeviceId";
104
+ UiInputKey["AMOUNT_DUE"] = "input_amountDue";
104
105
  UiInputKey["BUSINESS_DAY_DATE"] = "input_businessDayDate";
105
106
  UiInputKey["SAME_AS_BILLTO"] = "input_sameAsBillTo";
106
107
  UiInputKey["BILLING"] = "input_billing";
@@ -470,6 +471,7 @@ var CollectedDataKey;
470
471
  CollectedDataKey["ApplyDiscountToBasePrice"] = "ApplyDiscountToBasePrice";
471
472
  CollectedDataKey["AuthorizationDeviceId"] = "AuthorizationDeviceId";
472
473
  CollectedDataKey["AutoApplied"] = "AutoApplied";
474
+ CollectedDataKey["AmountDue"] = "AmountDue";
473
475
  CollectedDataKey["BalanceInquiry"] = "BalanceInquiry";
474
476
  CollectedDataKey["Billing"] = "Billing";
475
477
  CollectedDataKey["SameAsBillTo"] = "SameAsBillTo";
@@ -1,3 +1,4 @@
1
+ import { Money } from "@aptos-scp/scp-component-business-core";
1
2
  import { DeviceIdentity, ITransaction, ITransactionLine, ITransactionLineFactory, IUser } from "@aptos-scp/scp-component-store-selling-core";
2
3
  import { IFiscalSignature } from "@aptos-scp/scp-types-commerce-transaction";
3
4
  import { ITransactionReferenceFormatter } from "../service";
@@ -27,6 +28,7 @@ export declare class TenderControlTransaction extends RetailTransaction {
27
28
  get fiscalTransactionNumber(): string;
28
29
  get fiscalSignature(): IFiscalSignature;
29
30
  get fiscalError(): IFiscalError;
31
+ get transactionChangeDue(): Money | undefined;
30
32
  findLineByLineNumber(lineNumber: number): ITransactionLine;
31
33
  toJSON(): object;
32
34
  protected newTransaction(): RetailTransaction;
@@ -34,3 +36,5 @@ export declare class TenderControlTransaction extends RetailTransaction {
34
36
  private generateTransactionReferenceNumber;
35
37
  }
36
38
  export declare const isTenderControlTransaction: (transaction: ITransaction) => transaction is TenderControlTransaction;
39
+ export declare const isPayOnAccountTransaction: (transaction: ITransaction) => transaction is TenderControlTransaction;
40
+ export declare const isCompletePayOnAccountTransaction: (transaction: ITransaction) => transaction is TenderControlTransaction;
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const _ = require("lodash");
4
+ const scp_component_business_core_1 = require("@aptos-scp/scp-component-business-core");
3
5
  const scp_component_store_selling_core_1 = require("@aptos-scp/scp-component-store-selling-core");
6
+ const scp_types_commerce_devices_1 = require("@aptos-scp/scp-types-commerce-devices");
4
7
  const scp_types_commerce_transaction_1 = require("@aptos-scp/scp-types-commerce-transaction");
5
8
  const config_1 = require("../../config");
6
9
  const RetailTransaction_1 = require("./RetailTransaction");
@@ -102,6 +105,33 @@ class TenderControlTransaction extends RetailTransaction_1.RetailTransaction {
102
105
  get fiscalError() {
103
106
  return this._fiscalError;
104
107
  }
108
+ get transactionChangeDue() {
109
+ var _a, _b;
110
+ let changeDue;
111
+ // For Account payments there are 3 possible amounts but only 2 that need to be considered:
112
+ // 1. the amount the customer wants to pay on the account (requestedAmount in the TenderAuthStatus result line)
113
+ // - this could be less than the tendered amount and/or more than the amount actually applied to the account for partial approvals (unlikely with cash)
114
+ // 2. the amount of Cash tendered (tenderAmount in the TenderExchangeInLine)
115
+ // - amount tendered by the customer, could be more than the requested amount.
116
+ // - amount approved by the processor, could be less than both the requested and tendered amounts
117
+ // 3. approved amount (tenderAmount in the TenderExchangeOutLine)
118
+ // - amount approved by the processor, could be less than both the requested and tendered amounts
119
+ // To calculate the change due, we need the difference between the tendered amount #3 and the applied amount #2.
120
+ if (this.isAccountPaymentTransaction && !_.isEmpty(this.lines)) {
121
+ const tenderExchangeInLine = _.last(this.lines.filter((line) => line.lineType === tender_1.TENDER_EXCHANGE_IN_LINE_TYPE));
122
+ if (((_a = tenderExchangeInLine) === null || _a === void 0 ? void 0 : _a.tenderTypeName) === scp_types_commerce_devices_1.TenderType.Cash &&
123
+ tenderExchangeInLine.tenderAmount && ((_b = tenderExchangeInLine.transactionLineReference) === null || _b === void 0 ? void 0 : _b.lineNumber)) {
124
+ const tenderExchangeOutLine = _.last(this.lines.filter((line) => line.lineType === tender_1.TENDER_EXCHANGE_OUT_LINE_TYPE));
125
+ if (tenderExchangeOutLine) {
126
+ changeDue = tenderExchangeInLine.tenderAmount.minus(tenderExchangeOutLine.tenderAmount);
127
+ }
128
+ }
129
+ }
130
+ if (!changeDue && this._accountingCurrency) {
131
+ changeDue = new scp_component_business_core_1.Money(0, this._accountingCurrency);
132
+ }
133
+ return changeDue;
134
+ }
105
135
  findLineByLineNumber(lineNumber) {
106
136
  if (lineNumber && super.lines.length > 0) {
107
137
  return super.findLineByLineNumber(lineNumber);
@@ -161,4 +191,10 @@ exports.isTenderControlTransaction = (transaction) => {
161
191
  return (transaction instanceof TenderControlTransaction ||
162
192
  ((_a = transaction) === null || _a === void 0 ? void 0 : _a.transactionType) === exports.TENDER_CONTROL_TRANSACTION_TYPE);
163
193
  };
194
+ exports.isPayOnAccountTransaction = (transaction) => {
195
+ return exports.isTenderControlTransaction(transaction) && transaction.isAccountPaymentTransaction;
196
+ };
197
+ exports.isCompletePayOnAccountTransaction = (transaction) => {
198
+ return exports.isTenderControlTransaction(transaction) && transaction.isCompleteAccountPaymentTransaction;
199
+ };
164
200
  //# sourceMappingURL=TenderControlTransaction.js.map
@@ -10,6 +10,7 @@ export declare const TENDER_AUTH_STATUS_LINE_TYPE: string;
10
10
  export declare class TenderAuthorizationStatusLine extends BaseTransactionLine implements ITransactionLineReference {
11
11
  private _status;
12
12
  private _tenderAmount;
13
+ private _amountDue;
13
14
  private _authResponse;
14
15
  private _failureReasonCode;
15
16
  private _authorizationDeviceId;
@@ -40,6 +41,7 @@ export declare class TenderAuthorizationStatusLine extends BaseTransactionLine i
40
41
  get couldAffectPricing(): boolean;
41
42
  get status(): TenderAuthorizationStatus;
42
43
  get tenderAmount(): Money;
44
+ get amountDue(): Money;
43
45
  get authResponse(): IAuthorizationResponse;
44
46
  get failureReasonCode(): TenderAuthFailureReasonCode;
45
47
  get authorizationDeviceId(): string;
@@ -67,7 +69,7 @@ export declare class TenderAuthorizationStatusLine extends BaseTransactionLine i
67
69
  get isTenderAuthorizationFallback(): boolean;
68
70
  get payByLinkCustomer(): IPayByLinkCustomer;
69
71
  get storeLanguage(): string;
70
- protected constructor(lineNumber: number, lineType: string, status: TenderAuthorizationStatus, tenderAmount: Money, authResponse: IAuthorizationResponse, failureReasonCode: TenderAuthFailureReasonCode, authorizationDeviceId: string, transactionLineReference: ITransactionLineReferenceType, forcedAuthorizationApproval: boolean, cardNumber: string, giftCardPin: string, valueCertificateNumber: string, offlineAuthorizationCode: string, offlineApprovalCode: string, tenderAuthCategory: TenderAuthCategory, tenderType: TenderType, tenderTypeName: string, entryMethod: EntryMethod, tenderReversalFailed: boolean, originalTenderLineReferences: IOriginalTransactionRefundReference[], actionType: ActionType, mappedRefundTenderTypeName: string, mappedRefundCardTypeName: string, excludedRefundCardTypeNames: string[], subType: TenderSubType, isChangeProcessing: boolean, isTenderAuthorizationFallback: boolean, payByLinkCustomer: IPayByLinkCustomer, storeLanguage: string);
72
+ protected constructor(lineNumber: number, lineType: string, status: TenderAuthorizationStatus, tenderAmount: Money, amountDue: Money, authResponse: IAuthorizationResponse, failureReasonCode: TenderAuthFailureReasonCode, authorizationDeviceId: string, transactionLineReference: ITransactionLineReferenceType, forcedAuthorizationApproval: boolean, cardNumber: string, giftCardPin: string, valueCertificateNumber: string, offlineAuthorizationCode: string, offlineApprovalCode: string, tenderAuthCategory: TenderAuthCategory, tenderType: TenderType, tenderTypeName: string, entryMethod: EntryMethod, tenderReversalFailed: boolean, originalTenderLineReferences: IOriginalTransactionRefundReference[], actionType: ActionType, mappedRefundTenderTypeName: string, mappedRefundCardTypeName: string, excludedRefundCardTypeNames: string[], subType: TenderSubType, isChangeProcessing: boolean, isTenderAuthorizationFallback: boolean, payByLinkCustomer: IPayByLinkCustomer, storeLanguage: string);
71
73
  protected newTransactionLine(): TenderAuthorizationStatusLine;
72
74
  }
73
75
  export declare function isTenderAuthorizationStatusLine(transactionLine: ITransactionLine): transactionLine is TenderAuthorizationStatusLine;
@@ -9,10 +9,11 @@ const Constants_1 = require("../Constants");
9
9
  const TenderType_1 = require("../TenderType");
10
10
  exports.TENDER_AUTH_STATUS_LINE_TYPE = "TenderAuthorizationStatus";
11
11
  class TenderAuthorizationStatusLine extends BaseTransactionLine_1.BaseTransactionLine {
12
- constructor(lineNumber, lineType, status, tenderAmount, authResponse, failureReasonCode, authorizationDeviceId, transactionLineReference, forcedAuthorizationApproval, cardNumber, giftCardPin, valueCertificateNumber, offlineAuthorizationCode, offlineApprovalCode, tenderAuthCategory, tenderType, tenderTypeName, entryMethod, tenderReversalFailed, originalTenderLineReferences, actionType, mappedRefundTenderTypeName, mappedRefundCardTypeName, excludedRefundCardTypeNames, subType, isChangeProcessing, isTenderAuthorizationFallback, payByLinkCustomer, storeLanguage) {
12
+ constructor(lineNumber, lineType, status, tenderAmount, amountDue, authResponse, failureReasonCode, authorizationDeviceId, transactionLineReference, forcedAuthorizationApproval, cardNumber, giftCardPin, valueCertificateNumber, offlineAuthorizationCode, offlineApprovalCode, tenderAuthCategory, tenderType, tenderTypeName, entryMethod, tenderReversalFailed, originalTenderLineReferences, actionType, mappedRefundTenderTypeName, mappedRefundCardTypeName, excludedRefundCardTypeNames, subType, isChangeProcessing, isTenderAuthorizationFallback, payByLinkCustomer, storeLanguage) {
13
13
  super(lineNumber, lineType);
14
14
  this._status = status;
15
15
  this._tenderAmount = tenderAmount;
16
+ this._amountDue = amountDue;
16
17
  this._authResponse = authResponse;
17
18
  this._failureReasonCode = failureReasonCode;
18
19
  this._authorizationDeviceId = authorizationDeviceId;
@@ -43,6 +44,7 @@ class TenderAuthorizationStatusLine extends BaseTransactionLine_1.BaseTransactio
43
44
  var _a;
44
45
  const status = collectedData.get(Constants_1.CollectedDataKey.TenderAuthorizationStatus);
45
46
  const tenderAmount = collectedData.get(Constants_1.CollectedDataKey.TenderAmount);
47
+ const amountDue = collectedData.get(Constants_1.CollectedDataKey.AmountDue);
46
48
  const authResponse = collectedData.get(Constants_1.CollectedDataKey.TenderAuthResponse);
47
49
  const failureReasonCode = collectedData.get(Constants_1.CollectedDataKey.TenderAuthFailureReasonCode);
48
50
  const authorizationDeviceId = collectedData.get(Constants_1.CollectedDataKey.AuthorizationDeviceId);
@@ -71,7 +73,7 @@ class TenderAuthorizationStatusLine extends BaseTransactionLine_1.BaseTransactio
71
73
  const isTenderAuthorizationFallback = collectedData.get(Constants_1.CollectedDataKey.IsTenderFallback);
72
74
  const payByLinkCustomer = collectedData.get(Constants_1.CollectedDataKey.PayByLinkCustomer);
73
75
  const storeLanguage = collectedData.get(Constants_1.CollectedDataKey.PrimaryLanguage);
74
- return new TenderAuthorizationStatusLine(lineNumber, lineType, status, tenderAmount, authResponse, failureReasonCode, authorizationDeviceId, transactionLineReference, forcedAuthorizationApproval, cardNumber, giftCardPin, valueCertificateNumber, offlineAuthorizationCode, offlineApprovalCode, tenderAuthCategory, tenderType, tenderTypeName, entryMethod, tenderReversalFailed, originalTenderLineReferences, actionType, mappedRefundTenderTypeName, mappedRefundCardTypeNames, excludedRefundCardTypeNames, subType, isChangeProcessing, isTenderAuthorizationFallback, payByLinkCustomer, storeLanguage);
76
+ return new TenderAuthorizationStatusLine(lineNumber, lineType, status, tenderAmount, amountDue, authResponse, failureReasonCode, authorizationDeviceId, transactionLineReference, forcedAuthorizationApproval, cardNumber, giftCardPin, valueCertificateNumber, offlineAuthorizationCode, offlineApprovalCode, tenderAuthCategory, tenderType, tenderTypeName, entryMethod, tenderReversalFailed, originalTenderLineReferences, actionType, mappedRefundTenderTypeName, mappedRefundCardTypeNames, excludedRefundCardTypeNames, subType, isChangeProcessing, isTenderAuthorizationFallback, payByLinkCustomer, storeLanguage);
75
77
  }
76
78
  static createFromJsonObject(transactionLineJsonObj) {
77
79
  const lineNumber = BaseTransactionLine_1.BaseTransactionLine.lineNumberFromJsonObject(transactionLineJsonObj);
@@ -101,6 +103,10 @@ class TenderAuthorizationStatusLine extends BaseTransactionLine_1.BaseTransactio
101
103
  if (transactionLineJsonObj._tenderAmount) {
102
104
  tenderAmount = new scp_component_business_core_1.Money(transactionLineJsonObj._tenderAmount);
103
105
  }
106
+ let amountDue;
107
+ if (transactionLineJsonObj._amountDue) {
108
+ amountDue = new scp_component_business_core_1.Money(transactionLineJsonObj._amountDue);
109
+ }
104
110
  const authResponse = transactionLineJsonObj._authResponse;
105
111
  if (transactionLineJsonObj._authResponse) {
106
112
  if (transactionLineJsonObj._authResponse.balance) {
@@ -117,7 +123,7 @@ class TenderAuthorizationStatusLine extends BaseTransactionLine_1.BaseTransactio
117
123
  const failureReasonCode = scp_types_commerce_transaction_1.TenderAuthFailureReasonCode[transactionLineJsonObj._failureReasonCode];
118
124
  const payByLinkCustomer = transactionLineJsonObj._payByLinkCustomer;
119
125
  const storeLanguage = transactionLineJsonObj._storeLanguage;
120
- const tenderAuthorizationStatusLine = new TenderAuthorizationStatusLine(lineNumber, lineType, status, tenderAmount, authResponse, failureReasonCode, authorizationDeviceId, transactionLineReference, forcedAuthorizationApproval, cardNumber, giftCardPin, valueCertificateNumber, offlineAuthorizationCode, offlineApprovalCode, tenderAuthCategory, tenderType, tenderTypeName, entryMethod, tenderReversalFailed, originalTenderLineReferences, actionType, mappedRefundTenderTypeName, mappedRefundCardTypeName, excludedRefundCardTypeNames, subType, isChangeProcessing, isTenderAuthorizationFallback, payByLinkCustomer, storeLanguage);
126
+ const tenderAuthorizationStatusLine = new TenderAuthorizationStatusLine(lineNumber, lineType, status, tenderAmount, amountDue, authResponse, failureReasonCode, authorizationDeviceId, transactionLineReference, forcedAuthorizationApproval, cardNumber, giftCardPin, valueCertificateNumber, offlineAuthorizationCode, offlineApprovalCode, tenderAuthCategory, tenderType, tenderTypeName, entryMethod, tenderReversalFailed, originalTenderLineReferences, actionType, mappedRefundTenderTypeName, mappedRefundCardTypeName, excludedRefundCardTypeNames, subType, isChangeProcessing, isTenderAuthorizationFallback, payByLinkCustomer, storeLanguage);
121
127
  tenderAuthorizationStatusLine.loadFromJsonObject(transactionLineJsonObj);
122
128
  return tenderAuthorizationStatusLine;
123
129
  }
@@ -130,6 +136,9 @@ class TenderAuthorizationStatusLine extends BaseTransactionLine_1.BaseTransactio
130
136
  get tenderAmount() {
131
137
  return this._tenderAmount;
132
138
  }
139
+ get amountDue() {
140
+ return this._amountDue;
141
+ }
133
142
  get authResponse() {
134
143
  return this._authResponse;
135
144
  }
@@ -212,7 +221,7 @@ class TenderAuthorizationStatusLine extends BaseTransactionLine_1.BaseTransactio
212
221
  return this._storeLanguage;
213
222
  }
214
223
  newTransactionLine() {
215
- return new TenderAuthorizationStatusLine(this.lineNumber, this.lineType, this.status, this.tenderAmount, this.authResponse, this.failureReasonCode, this.authorizationDeviceId, this.transactionLineReference, this.forcedAuthorizationApproval, this.cardNumber, this.giftCardPin, this._valueCertificateNumber, this.offlineAuthorizationCode, this.offlineApprovalCode, this.tenderAuthCategory, this._tenderType, this.tenderTypeName, this._entryMethod, this._tenderReversalFailed, this._originalTenderLineReferences, this._actionType, this._mappedRefundTenderTypeName, this._mappedRefundCardTypeName, this._excludedRefundCardTypeNames, this._subType, this._isChangeProcessing, this._isTenderAuthorizationFallback, this._payByLinkCustomer, this._storeLanguage);
224
+ return new TenderAuthorizationStatusLine(this.lineNumber, this.lineType, this.status, this.tenderAmount, this.amountDue, this.authResponse, this.failureReasonCode, this.authorizationDeviceId, this.transactionLineReference, this.forcedAuthorizationApproval, this.cardNumber, this.giftCardPin, this._valueCertificateNumber, this.offlineAuthorizationCode, this.offlineApprovalCode, this.tenderAuthCategory, this._tenderType, this.tenderTypeName, this._entryMethod, this._tenderReversalFailed, this._originalTenderLineReferences, this._actionType, this._mappedRefundTenderTypeName, this._mappedRefundCardTypeName, this._excludedRefundCardTypeNames, this._subType, this._isChangeProcessing, this._isTenderAuthorizationFallback, this._payByLinkCustomer, this._storeLanguage);
216
225
  }
217
226
  }
218
227
  exports.TenderAuthorizationStatusLine = TenderAuthorizationStatusLine;
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.2.0",
3
+ "version": "2.3.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",
@@ -55,7 +55,7 @@
55
55
  "@aptos-scp/scp-component-business-core": "^1.12.7",
56
56
  "@aptos-scp/scp-component-logging": "^2.1.16",
57
57
  "@aptos-scp/scp-component-pricing": "^7.62.0",
58
- "@aptos-scp/scp-component-store-items": "^1.20.0",
58
+ "@aptos-scp/scp-component-store-items": "^1.21.0",
59
59
  "@aptos-scp/scp-component-store-selling-core": "^18.9.3",
60
60
  "@aptos-scp/scp-component-taxation": "^5.28.0",
61
61
  "@aptos-scp/scp-component-user": "^1.4.0",