@aptos-scp/scp-component-store-selling-features-domain-model 1.31.0 → 1.33.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.
@@ -309,7 +309,9 @@ export declare const FIND_VALUE_CERTIFICATES_EVENT: string;
309
309
  export declare const UPLOAD_DEVICE_LOGS_EVENT: string;
310
310
  export declare const BYPASS_REFUNDED_TAX_FREE_WARNING_EVENT: string;
311
311
  export declare const CLEAR_VALUE_CERTIFICATE_INQUIRY_RESULTS_EVENT: string;
312
+ export declare const VOID_ITEM_EXTENSIBILITY_FORM_DATA_EVENT: string;
312
313
  export declare const APPLY_ITEM_EXTENSIBILITY_FORM_DATA_EVENT: string;
314
+ export declare const APPLY_ITEM_EXTENSIBILITY_FORM_COMMENT_DATA_EVENT: string;
313
315
  export declare const APPLY_ITEM_SEND_SALE_EVENT: string;
314
316
  export declare const UPDATE_LINE_DISPLAY_EVENT: string;
315
317
  export declare const AUTO_LOG_ON_EVENT: string;
@@ -316,7 +316,9 @@ exports.FIND_VALUE_CERTIFICATES_EVENT = "FindValueCertificates";
316
316
  exports.UPLOAD_DEVICE_LOGS_EVENT = "UploadDeviceLogsEvent";
317
317
  exports.BYPASS_REFUNDED_TAX_FREE_WARNING_EVENT = "BypassRefundedTaxFreeWarning";
318
318
  exports.CLEAR_VALUE_CERTIFICATE_INQUIRY_RESULTS_EVENT = "ClearValueCertificateResults";
319
+ exports.VOID_ITEM_EXTENSIBILITY_FORM_DATA_EVENT = "VoidItemExtensibilityFormData";
319
320
  exports.APPLY_ITEM_EXTENSIBILITY_FORM_DATA_EVENT = "ApplyItemExtensibilityFormData";
321
+ exports.APPLY_ITEM_EXTENSIBILITY_FORM_COMMENT_DATA_EVENT = "ApplyItemExtensibilityFormCommentData";
320
322
  exports.APPLY_ITEM_SEND_SALE_EVENT = "ApplyItemSendSale";
321
323
  exports.UPDATE_LINE_DISPLAY_EVENT = "UpdateLineDisplay";
322
324
  exports.AUTO_LOG_ON_EVENT = "AutoLogOn";
@@ -1,6 +1,6 @@
1
1
  import { Container } from "inversify";
2
2
  import { Money } from "@aptos-scp/scp-component-business-core";
3
- import { IConfigurationValues } from "@aptos-scp/scp-component-store-selling-core";
3
+ import { IConfigurationManager, IConfigurationValues } from "@aptos-scp/scp-component-store-selling-core";
4
4
  import { CardType, EntryMethod, IAuthorizationResponse, TenderSubType } from "@aptos-scp/scp-types-commerce-devices";
5
5
  import { TenderAuthFailureReasonCode } from "@aptos-scp/scp-types-commerce-transaction";
6
6
  import { AllowRefund } from "./configuration/ITendersConfig";
@@ -97,9 +97,10 @@ export declare class TenderType {
97
97
  static getActiveConfiguredTenderGroups(container: Container, accountingCurrency: string, activeTenders: TenderType[]): ITenderGroup[];
98
98
  static getActiveRefundConfiguredTenderGroups(container: Container, accountingCurrency: string, withTransaction: boolean, activeTenders: TenderType[], originalTransactionsDetails: IOriginalTransactionDetails[], withOfflineTransaction: boolean): ITenderGroup[];
99
99
  static tenderIsCreditOrDebit(tenderType: any): boolean;
100
- static getWithoutTransactionTotal(displayInfo: any, accountingCurrency: string): Money;
101
- static getWithTransactionTotal(displayInfo: any, accountingCurrency: string): Money;
102
- static getWithOfflineTransactionTotal(displayInfo: any, accountingCurrency: string): Money;
100
+ static getRefundableAmountByGroup(group: ITenderGroup, displayInfo: any, currency: string, configuration: IConfigurationManager, refundDue?: Money): Money;
101
+ static getWithoutTransactionTotal(displayInfo: any, accountingCurrency: string, configurationManager: IConfigurationManager): Money;
102
+ static getWithTransactionTotal(displayInfo: any, accountingCurrency: string, configurationManager: IConfigurationManager): Money;
103
+ static getWithOfflineTransactionTotal(displayInfo: any, accountingCurrency: string, configurationManager: IConfigurationManager): Money;
103
104
  static getOriginalRefundableTenders(container: Container, accountingCurrency: string, originalTransactionsDetails: IOriginalTransactionDetails[], balanceDue: Money, itemTypes?: string[], orderTypes?: string[], isRefund?: boolean, productAttributeTypes?: string[], displayInfo?: any): IOriginalTender[];
104
105
  static getDefaultConfiguredTenderType(container: Container, accountingCurrency: string): TenderType;
105
106
  static createFromJsonObject(tenderTypeFromJson: any): TenderType;
@@ -87,51 +87,125 @@ class TenderType {
87
87
  var _a, _b;
88
88
  return (((_a = tenderType) === null || _a === void 0 ? void 0 : _a.tenderType) === scp_types_commerce_devices_1.TenderType.Credit || ((_b = tenderType) === null || _b === void 0 ? void 0 : _b.tenderTyp) === scp_types_commerce_devices_1.TenderType.Debit);
89
89
  }
90
- static getWithoutTransactionTotal(displayInfo, accountingCurrency) {
91
- var _a, _b;
90
+ static getRefundableAmountByGroup(group, displayInfo, currency, configuration, refundDue) {
91
+ var _a, _b, _c, _d;
92
+ const withoutTransactionTotal = TenderType.getWithoutTransactionTotal(displayInfo, currency, configuration);
93
+ const withTransactionTotal = TenderType.getWithTransactionTotal(displayInfo, currency, configuration);
94
+ const withOfflineTransactionTotal = TenderType.getWithOfflineTransactionTotal(displayInfo, currency, configuration);
95
+ const tenderAuthCategory = group.tenderAuthCategory;
96
+ const tenderIds = group.tenderIds;
97
+ const tenderType = group.tenderType;
98
+ const tenderDefinitions = (_b = (_a = configuration) === null || _a === void 0 ? void 0 : _a.getTendersValues()) === null || _b === void 0 ? void 0 : _b.tenderDefinitions;
99
+ const tenders = [];
100
+ if (!_.isEmpty(tenderIds)) {
101
+ tenderIds.forEach((id) => {
102
+ var _a;
103
+ tenders.push((_a = tenderDefinitions) === null || _a === void 0 ? void 0 : _a.find((tender) => tender.tenderId === id && tender.active));
104
+ });
105
+ }
106
+ else if (!_.isEmpty(tenderAuthCategory)) {
107
+ (_c = tenderDefinitions) === null || _c === void 0 ? void 0 : _c.forEach((tender) => {
108
+ var _a;
109
+ if ((tender.tenderAuthCategory === tenderAuthCategory || ((_a = tender.additionalTenderAuthCategories) === null || _a === void 0 ? void 0 : _a.includes(tenderAuthCategory))) &&
110
+ tender.active) {
111
+ tenders.push(tender);
112
+ }
113
+ });
114
+ }
115
+ else if (!_.isEmpty(tenderType)) {
116
+ (_d = tenderDefinitions) === null || _d === void 0 ? void 0 : _d.forEach((tender) => {
117
+ if (tender.tenderType === tenderType && tender.active) {
118
+ tenders.push(tender);
119
+ }
120
+ });
121
+ }
122
+ let tenderAllowRefund = [];
123
+ tenders.forEach((tender) => {
124
+ if (tender.allowRefund) {
125
+ tenderAllowRefund = _.union(tenderAllowRefund, tender.allowRefund);
126
+ }
127
+ });
128
+ let refundableAmount = new scp_component_business_core_1.Money(0, currency);
129
+ if (tenderAllowRefund.includes(ITendersConfig_1.AllowRefund.WithTransaction)) {
130
+ refundableAmount = refundableAmount.plus(withTransactionTotal);
131
+ }
132
+ if (tenderAllowRefund.includes(ITendersConfig_1.AllowRefund.WithoutTransaction)) {
133
+ refundableAmount = refundableAmount.plus(withoutTransactionTotal);
134
+ }
135
+ if (tenderAllowRefund.includes(ITendersConfig_1.AllowRefund.WithOfflineTransaction)) {
136
+ refundableAmount = refundableAmount.plus(withOfflineTransactionTotal);
137
+ }
138
+ return getLowestRefundDue(refundDue, undefined, refundableAmount);
139
+ }
140
+ static getWithoutTransactionTotal(displayInfo, accountingCurrency, configurationManager) {
141
+ var _a, _b, _c, _d;
92
142
  let withoutTransactionTotal = new scp_component_business_core_1.Money(0, accountingCurrency);
93
143
  (_b = (_a = displayInfo) === null || _a === void 0 ? void 0 : _a.itemDisplayLines) === null || _b === void 0 ? void 0 : _b.forEach((itemDisplayLine) => {
94
144
  if ((itemDisplayLine.lineType === scp_types_commerce_transaction_1.LineType.ItemOrder && itemDisplayLine.cancelled) ||
95
145
  (itemDisplayLine.lineType === scp_types_commerce_transaction_1.LineType.ItemReturn &&
96
- _.isEmpty(itemDisplayLine.lineNumberFromReturnTransaction) &&
97
- _.isEmpty(itemDisplayLine.sublineIndexFromReturnItem))) {
146
+ _.isUndefined(itemDisplayLine.lineNumberFromReturnTransaction) &&
147
+ _.isUndefined(itemDisplayLine.sublineIndexFromReturnItem) &&
148
+ _.isUndefined(itemDisplayLine.offlineReturnReferenceNumber))) {
98
149
  withoutTransactionTotal = withoutTransactionTotal.plus(itemDisplayLine.extendedAmount.abs());
99
150
  withoutTransactionTotal = !_.isEmpty(itemDisplayLine.totalLineTax)
100
151
  ? withoutTransactionTotal.plus(itemDisplayLine.totalLineTax.abs())
101
152
  : withoutTransactionTotal;
102
153
  }
103
154
  });
155
+ (_d = (_c = displayInfo) === null || _c === void 0 ? void 0 : _c.tenderDisplayLines) === null || _d === void 0 ? void 0 : _d.forEach((tenderDisplayLine) => {
156
+ var _a, _b;
157
+ const tender = getConfiguredTender(tenderDisplayLine.tenderId, configurationManager);
158
+ if (_.isEmpty(tenderDisplayLine.originalTenderReferences) &&
159
+ ((_b = (_a = tender) === null || _a === void 0 ? void 0 : _a.allowRefund) === null || _b === void 0 ? void 0 : _b.indexOf(ITendersConfig_1.AllowRefund.WithoutTransaction)) >= 0) {
160
+ withoutTransactionTotal = withoutTransactionTotal.minus(tenderDisplayLine.tenderAmount.abs());
161
+ }
162
+ });
104
163
  return withoutTransactionTotal;
105
164
  }
106
- static getWithTransactionTotal(displayInfo, accountingCurrency) {
107
- var _a, _b;
165
+ static getWithTransactionTotal(displayInfo, accountingCurrency, configurationManager) {
166
+ var _a, _b, _c, _d;
108
167
  let withTransactionTotal = new scp_component_business_core_1.Money(0, accountingCurrency);
109
168
  (_b = (_a = displayInfo) === null || _a === void 0 ? void 0 : _a.itemDisplayLines) === null || _b === void 0 ? void 0 : _b.forEach((itemDisplayLine) => {
110
169
  if (itemDisplayLine.lineType === scp_types_commerce_transaction_1.LineType.ItemCancel ||
111
170
  (itemDisplayLine.lineType === scp_types_commerce_transaction_1.LineType.ItemReturn &&
112
- !_.isEmpty(itemDisplayLine.lineNumberFromReturnTransaction) &&
113
- !_.isEmpty(itemDisplayLine.sublineIndexFromReturnItem))) {
171
+ !_.isUndefined(itemDisplayLine.lineNumberFromReturnTransaction) &&
172
+ !_.isUndefined(itemDisplayLine.sublineIndexFromReturnItem))) {
114
173
  withTransactionTotal = withTransactionTotal.plus(itemDisplayLine.extendedAmount.abs());
115
174
  withTransactionTotal = !_.isEmpty(itemDisplayLine.totalLineTax)
116
175
  ? withTransactionTotal.plus(itemDisplayLine.totalLineTax.abs())
117
176
  : withTransactionTotal;
118
177
  }
119
178
  });
179
+ (_d = (_c = displayInfo) === null || _c === void 0 ? void 0 : _c.tenderDisplayLines) === null || _d === void 0 ? void 0 : _d.forEach((tenderDisplayLine) => {
180
+ var _a, _b;
181
+ const tender = getConfiguredTender(tenderDisplayLine.tenderId, configurationManager);
182
+ if (((_b = (_a = tender) === null || _a === void 0 ? void 0 : _a.allowRefund) === null || _b === void 0 ? void 0 : _b.indexOf(ITendersConfig_1.AllowRefund.WithTransaction)) >= 0 ||
183
+ !_.isEmpty(tenderDisplayLine.originalTenderReferences)) {
184
+ withTransactionTotal = withTransactionTotal.minus(tenderDisplayLine.tenderAmount.abs());
185
+ }
186
+ });
120
187
  return withTransactionTotal;
121
188
  }
122
- static getWithOfflineTransactionTotal(displayInfo, accountingCurrency) {
123
- var _a, _b;
189
+ static getWithOfflineTransactionTotal(displayInfo, accountingCurrency, configurationManager) {
190
+ var _a, _b, _c, _d;
124
191
  let withOfflineTransactionTotal = new scp_component_business_core_1.Money(0, accountingCurrency);
125
192
  (_b = (_a = displayInfo) === null || _a === void 0 ? void 0 : _a.itemDisplayLines) === null || _b === void 0 ? void 0 : _b.forEach((itemDisplayLine) => {
126
193
  var _a, _b;
127
194
  if (itemDisplayLine.lineType === scp_types_commerce_transaction_1.LineType.ItemReturn &&
128
- !_.isEmpty(itemDisplayLine.offlineReturnReferenceNumber)) {
195
+ !_.isUndefined(itemDisplayLine.offlineReturnReferenceNumber)) {
129
196
  withOfflineTransactionTotal = withOfflineTransactionTotal.plus((_a = itemDisplayLine.extendedAmount) === null || _a === void 0 ? void 0 : _a.abs());
130
197
  withOfflineTransactionTotal = !_.isEmpty(itemDisplayLine.totalLineTax)
131
198
  ? withOfflineTransactionTotal.plus((_b = itemDisplayLine.totalLineTax) === null || _b === void 0 ? void 0 : _b.abs())
132
199
  : undefined;
133
200
  }
134
201
  });
202
+ (_d = (_c = displayInfo) === null || _c === void 0 ? void 0 : _c.tenderDisplayLines) === null || _d === void 0 ? void 0 : _d.forEach((tenderDisplayLine) => {
203
+ var _a, _b;
204
+ const tender = getConfiguredTender(tenderDisplayLine.tenderId, configurationManager);
205
+ if (((_b = (_a = tender) === null || _a === void 0 ? void 0 : _a.allowRefund) === null || _b === void 0 ? void 0 : _b.indexOf(ITendersConfig_1.AllowRefund.WithOfflineTransaction)) >= 0) {
206
+ withOfflineTransactionTotal = withOfflineTransactionTotal.minus(tenderDisplayLine.tenderAmount.abs());
207
+ }
208
+ });
135
209
  return withOfflineTransactionTotal;
136
210
  }
137
211
  static getOriginalRefundableTenders(container, accountingCurrency, originalTransactionsDetails, balanceDue, itemTypes, orderTypes, isRefund, productAttributeTypes, displayInfo) {
@@ -140,9 +214,9 @@ class TenderType {
140
214
  const suggestedRefundTenders = TenderType.getActiveSuggestedRefundTenders(container, accountingCurrency);
141
215
  let originalRefundableTenders = [];
142
216
  let originalReferencedTenders = [];
143
- const withoutTransactionTotal = this.getWithoutTransactionTotal(displayInfo, accountingCurrency);
144
- const withTransactionTotal = this.getWithTransactionTotal(displayInfo, accountingCurrency);
145
- const offlineTransactionTotal = this.getWithOfflineTransactionTotal(displayInfo, accountingCurrency);
217
+ const withoutTransactionTotal = this.getWithoutTransactionTotal(displayInfo, accountingCurrency, configurationManager);
218
+ const withTransactionTotal = this.getWithTransactionTotal(displayInfo, accountingCurrency, configurationManager);
219
+ const offlineTransactionTotal = this.getWithOfflineTransactionTotal(displayInfo, accountingCurrency, configurationManager);
146
220
  const originalUnreferencedAndMappedTenders = [];
147
221
  (_a = originalTransactionsDetails) === null || _a === void 0 ? void 0 : _a.forEach((origTranDetail) => {
148
222
  var _a;
@@ -152,7 +226,7 @@ class TenderType {
152
226
  const configuredTransactionReferenceTender = (_a = suggestedRefundTenders) === null || _a === void 0 ? void 0 : _a.find((tender) => tender.id === originalTender.tenderId);
153
227
  if (configuredTransactionReferenceTender) {
154
228
  if (originalTender.showReference) {
155
- originalReferencedTenders.push(originalTender);
229
+ originalReferencedTenders.push(_.cloneDeep(originalTender));
156
230
  }
157
231
  else if (originalTender.tenderAuthCategory !== Constants_1.TenderAuthCategory.LoyaltyVoucherService) {
158
232
  combineOriginalUnreferencedAndMappedTenders(originalTender, originalUnreferencedAndMappedTenders);
@@ -169,7 +243,7 @@ class TenderType {
169
243
  originalRefundableTenders = [...originalReferencedTenders, ...originalUnreferencedAndMappedTenders];
170
244
  originalRefundableTenders.forEach((tender) => {
171
245
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
172
- const configuredTender = getConfiguredTender(tender, configurationManager);
246
+ const configuredTender = getConfiguredTender(tender.tenderId, configurationManager);
173
247
  const withoutTransaction = ((_b = (_a = configuredTender) === null || _a === void 0 ? void 0 : _a.allowRefund) === null || _b === void 0 ? void 0 : _b.indexOf(ITendersConfig_1.AllowRefund.WithoutTransaction)) >= 0;
174
248
  const withTransaction = ((_d = (_c = configuredTender) === null || _c === void 0 ? void 0 : _c.allowRefund) === null || _d === void 0 ? void 0 : _d.indexOf(ITendersConfig_1.AllowRefund.WithTransaction)) >= 0;
175
249
  const withOfflineTransaction = ((_f = (_e = configuredTender) === null || _e === void 0 ? void 0 : _e.allowRefund) === null || _f === void 0 ? void 0 : _f.indexOf(ITendersConfig_1.AllowRefund.WithOfflineTransaction)) >= 0;
@@ -536,7 +610,9 @@ function combineOriginalUnreferencedAndMappedTenders(tender, unreferencedAndMapp
536
610
  matchingUnreferencedTender.adjustmentAmount = matchingUnreferencedTender.adjustmentAmount.plus(tender.adjustmentAmount);
537
611
  }
538
612
  if (matchingUnreferencedTender.originalTransactionReferences) {
539
- if (((_a = tender.originalTransactionReferences) === null || _a === void 0 ? void 0 : _a.length) > 0) {
613
+ // If original tender is fully refunded, do not add its transaction reference with its refundable amount
614
+ if (!isOriginalTenderFullyRefunded(tender, undefined) &&
615
+ ((_a = tender.originalTransactionReferences) === null || _a === void 0 ? void 0 : _a.length) > 0) {
540
616
  tender.originalTransactionReferences.forEach((origTranRef) => {
541
617
  const matchingTranReference = matchingUnreferencedTender.originalTransactionReferences.find((ref) => ref.transactionLineReference.transactionId ===
542
618
  origTranRef.transactionLineReference.transactionId &&
@@ -550,12 +626,17 @@ function combineOriginalUnreferencedAndMappedTenders(tender, unreferencedAndMapp
550
626
  });
551
627
  }
552
628
  }
553
- else {
629
+ else if (!isOriginalTenderFullyRefunded(tender, undefined)) {
554
630
  matchingUnreferencedTender.originalTransactionReferences = tender.originalTransactionReferences;
555
631
  }
632
+ // If unreferencedOriginal tender also has a matching mappedTender and is not fully refunded, set it to mapped
633
+ if (tender.isMappedTender && !isOriginalTenderFullyRefunded(matchingUnreferencedTender, undefined)) {
634
+ matchingUnreferencedTender.isMappedTender = true;
635
+ matchingUnreferencedTender.mappedOriginTenderId = tender.mappedOriginTenderId;
636
+ }
556
637
  }
557
638
  else {
558
- unreferencedAndMappedTenders.push(tender);
639
+ unreferencedAndMappedTenders.push(_.cloneDeep(tender));
559
640
  }
560
641
  }
561
642
  function getOriginalTenderRefundableAmount(originalTender, refundDue, originalTransactionDetails, withTransactionTotal, withoutTransactionTotal, withOfflineTransactionTotal) {
@@ -590,7 +671,7 @@ function getOriginalTenderRefundableAmount(originalTender, refundDue, originalTr
590
671
  if (refundDue) {
591
672
  const returnTotalAmount = getReturnOrCancelTotalAmount(originalTran);
592
673
  // If transaction was partially returned, tranRef.refundableAmount will have the full original tender amount, default to the partial return total amount
593
- const originalTenderAmount = getLowestRefundDue(undefined, returnTotalAmount, adjustAmount(origTranRef.refundableAmount, originalTender.adjustmentAmount));
674
+ const originalTenderAmount = getLowestRefundDue(undefined, returnTotalAmount, origTranRef.refundableAmount);
594
675
  // Mapped tenders will only use their transaction references for refund amount calculation, if they have been fully tendered,
595
676
  // they will not have transaction references, do not subtract refunded amount
596
677
  const currentTranRefundableAmount = calculateRefundableAmount(originalTenderAmount, originalTender.isMappedTender ? undefined : originalTender.refundedAmount, returnTotalAmount, refundDue);
@@ -616,23 +697,23 @@ function getLowestRefundDue(refundDue, returnTotalAmount, remainingTenderAmount)
616
697
  : remainingTenderAmount) || lowestRefundDue);
617
698
  }
618
699
  function calculateRefundableAmount(originalTenderAmount, refundedAmount, returnTotalAmount, refundDue) {
619
- const remainingTenderAmount = (refundedAmount && originalTenderAmount && originalTenderAmount.minus(refundedAmount)) ||
620
- originalTenderAmount;
700
+ var _a;
701
+ const remainingTenderAmount = (refundedAmount && ((_a = originalTenderAmount) === null || _a === void 0 ? void 0 : _a.minus(refundedAmount))) || originalTenderAmount;
621
702
  return getLowestRefundDue(refundDue, returnTotalAmount, remainingTenderAmount);
622
703
  }
623
- function getConfiguredTender(originalTender, configurationManager) {
704
+ function getConfiguredTender(originalTenderId, configurationManager) {
624
705
  var _a, _b;
625
706
  return (_b = (_a = configurationManager
626
- .getTendersValues()) === null || _a === void 0 ? void 0 : _a.tenderDefinitions) === null || _b === void 0 ? void 0 : _b.find((tender) => tender.tenderId === originalTender.tenderId);
707
+ .getTendersValues()) === null || _a === void 0 ? void 0 : _a.tenderDefinitions) === null || _b === void 0 ? void 0 : _b.find((tender) => tender.tenderId === originalTenderId);
627
708
  }
628
709
  function getConfiguredMappedTenders(originalTender, configurationManager, transactionId, originalTransactions, refundDue) {
629
- var _a, _b, _c, _d, _e;
710
+ var _a, _b, _c, _d, _e, _f;
630
711
  const mappedTenders = [];
631
712
  const tenderConfig = (_a = configurationManager) === null || _a === void 0 ? void 0 : _a.getTendersValues();
632
713
  const tenderTypeBehaviors = (_c = (_b = tenderConfig) === null || _b === void 0 ? void 0 : _b.tenderBehaviors) === null || _c === void 0 ? void 0 : _c.tenderTypeBehaviors;
633
714
  const tenderDefinitions = (_d = tenderConfig) === null || _d === void 0 ? void 0 : _d.tenderDefinitions;
634
- const configuredTender = getConfiguredTender(originalTender, configurationManager);
635
- const tenderTypeBehavior = configuredTender && tenderTypeBehaviors && tenderTypeBehaviors[configuredTender.tenderType];
715
+ const configuredTender = getConfiguredTender(originalTender.tenderId, configurationManager);
716
+ const tenderTypeBehavior = configuredTender && ((_e = tenderTypeBehaviors) === null || _e === void 0 ? void 0 : _e[configuredTender.tenderType]);
636
717
  let refundCardTypes;
637
718
  let refundTenderTypes;
638
719
  let excludeCardTypes;
@@ -647,7 +728,7 @@ function getConfiguredMappedTenders(originalTender, configurationManager, transa
647
728
  }
648
729
  else {
649
730
  // otherwise use the refundTenderTypes from the root tenderTypeBehavior
650
- refundTenderTypes = (_e = tenderTypeBehavior) === null || _e === void 0 ? void 0 : _e.refundTenderTypes;
731
+ refundTenderTypes = (_f = tenderTypeBehavior) === null || _f === void 0 ? void 0 : _f.refundTenderTypes;
651
732
  // exclude ANY refundableCardTypes that exist under cardTypeExceptions
652
733
  excludeCardTypes = getAllRefundableCardTypes(tenderTypeBehavior);
653
734
  }
@@ -1022,11 +1103,12 @@ function buildMappedOriginalTender(originalTender, tenderName, tenderType, tende
1022
1103
  };
1023
1104
  }
1024
1105
  function isOriginalTenderFullyRefunded(originalTender, returnTotalAmount) {
1106
+ var _a;
1025
1107
  const totalRefundedAmount = originalTender &&
1026
1108
  calculateTotalRefundedAmount(originalTender.previouslyRefundedAmount, originalTender.refundedAmount);
1027
1109
  const adjustedOriginalTenderAmount = adjustAmount(originalTender.originalTenderAmount, originalTender.adjustmentAmount);
1028
- return ((totalRefundedAmount && totalRefundedAmount.gte(adjustedOriginalTenderAmount)) ||
1029
- originalTender.refundedAmount.gte(returnTotalAmount));
1110
+ return (((_a = totalRefundedAmount) === null || _a === void 0 ? void 0 : _a.gte(adjustedOriginalTenderAmount)) ||
1111
+ (returnTotalAmount && originalTender.refundedAmount.gte(returnTotalAmount)));
1030
1112
  }
1031
1113
  function calculateTotalRefundedAmount(previouslyRefundedAmount, refundedAmount) {
1032
1114
  if (previouslyRefundedAmount && refundedAmount) {
@@ -1317,10 +1399,10 @@ function getReturnOrCancelTotalAmount(originalTran) {
1317
1399
  }
1318
1400
  exports.getReturnOrCancelTotalAmount = getReturnOrCancelTotalAmount;
1319
1401
  function isTenderCurrentlyRefunded(originalTender, refundableAmount) {
1320
- var _a, _b, _c;
1402
+ var _a, _b, _c, _d;
1321
1403
  const refundedAmount = adjustAmount((_a = originalTender) === null || _a === void 0 ? void 0 : _a.refundedAmount, (_b = originalTender) === null || _b === void 0 ? void 0 : _b.adjustmentAmount);
1322
- return (refundableAmount &&
1323
- (((_c = originalTender) === null || _c === void 0 ? void 0 : _c.isMappedTender) ? !refundableAmount.isPositive() : refundedAmount.gte(refundableAmount)));
1404
+ return (!_.isEmpty(refundableAmount) &&
1405
+ (((_c = originalTender) === null || _c === void 0 ? void 0 : _c.isMappedTender) ? !refundableAmount.isPositive() : (_d = refundedAmount) === null || _d === void 0 ? void 0 : _d.gte(refundableAmount)));
1324
1406
  }
1325
1407
  exports.isTenderCurrentlyRefunded = isTenderCurrentlyRefunded;
1326
1408
  function allowWalletSpecificTender(tenderAuthCategory, tenders) {
@@ -0,0 +1,16 @@
1
+ import { ISameTransactionLineReference } from "@aptos-scp/scp-types-commerce-transaction";
2
+ import { BaseLineDecorator } from "../BaseLineDecorator";
3
+ import { ExtensibilityFormDataLine } from "./ExtensibilityFormDataLine";
4
+ import { IExtensibilityFormFields } from "./IExtensibilityForm";
5
+ export declare abstract class BaseExtensibilityFormDataLineDecorator extends BaseLineDecorator<ExtensibilityFormDataLine> {
6
+ get couldAffectPricing(): boolean;
7
+ get itemLineReference(): ISameTransactionLineReference;
8
+ get formName(): string;
9
+ get namespace(): string;
10
+ get fields(): IExtensibilityFormFields;
11
+ get prevFields(): IExtensibilityFormFields;
12
+ get allowVoid(): boolean;
13
+ get preventsTransactionVoid(): boolean;
14
+ protected constructor(lineDecoratorType: string, decoratedTransactionLine: ExtensibilityFormDataLine, annotationDescription: string, annotationSourceType: string, annotationSourceLineNumber?: number);
15
+ protected clone(): BaseExtensibilityFormDataLineDecorator;
16
+ }
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const BaseLineDecorator_1 = require("../BaseLineDecorator");
4
+ class BaseExtensibilityFormDataLineDecorator extends BaseLineDecorator_1.BaseLineDecorator {
5
+ get couldAffectPricing() {
6
+ return this.decoratedTransactionLine.couldAffectPricing;
7
+ }
8
+ get itemLineReference() {
9
+ return this.decoratedTransactionLine.itemLineReference;
10
+ }
11
+ get formName() {
12
+ return this.decoratedTransactionLine.formName;
13
+ }
14
+ get namespace() {
15
+ return this.decoratedTransactionLine.namespace;
16
+ }
17
+ get fields() {
18
+ return this.decoratedTransactionLine.fields;
19
+ }
20
+ get prevFields() {
21
+ return this.decoratedTransactionLine.prevFields;
22
+ }
23
+ get allowVoid() {
24
+ return true;
25
+ }
26
+ get preventsTransactionVoid() {
27
+ return false;
28
+ }
29
+ constructor(lineDecoratorType, decoratedTransactionLine, annotationDescription, annotationSourceType, annotationSourceLineNumber) {
30
+ super(lineDecoratorType, decoratedTransactionLine, annotationDescription, annotationSourceType, annotationSourceLineNumber);
31
+ }
32
+ clone() {
33
+ const newBaseExtensibilityFormDataLineDecorator = super.clone();
34
+ return newBaseExtensibilityFormDataLineDecorator;
35
+ }
36
+ }
37
+ exports.BaseExtensibilityFormDataLineDecorator = BaseExtensibilityFormDataLineDecorator;
38
+ //# sourceMappingURL=BaseExtensibilityFormDataLineDecorator.js.map
@@ -1,10 +1,12 @@
1
1
  import { ITransactionLine, UiBusinessEvent } from "@aptos-scp/scp-component-store-selling-core";
2
2
  import { ISameTransactionLineReference } from "@aptos-scp/scp-types-commerce-transaction";
3
3
  import { BaseTransactionLine } from "../BaseTransactionLine";
4
+ import { VoidSource } from "../Constants";
5
+ import { IVoidableLine } from "../VoidInterfaces";
4
6
  import { IExtensibilityFormFields } from "./IExtensibilityForm";
5
7
  export declare const ADD_EXTENSIBILITY_FORM_DATA_LINE_TYPE = "AddExtensibilityFormData";
6
8
  export declare const MODIFY_EXTENSIBILITY_FORM_DATA_LINE_TYPE = "ModifyExtensibilityFormData";
7
- export declare class ExtensibilityFormDataLine extends BaseTransactionLine {
9
+ export declare class ExtensibilityFormDataLine extends BaseTransactionLine implements IVoidableLine {
8
10
  private _itemLineReference;
9
11
  private _formName;
10
12
  private _namespace;
@@ -18,6 +20,10 @@ export declare class ExtensibilityFormDataLine extends BaseTransactionLine {
18
20
  get formName(): string;
19
21
  get namespace(): string;
20
22
  get fields(): IExtensibilityFormFields;
23
+ get voided(): boolean;
24
+ get preventsTransactionVoid(): boolean;
25
+ get allowVoid(): boolean;
26
+ get voidSource(): VoidSource;
21
27
  get prevFields(): IExtensibilityFormFields;
22
28
  get couldAffectPricing(): boolean;
23
29
  }
@@ -49,6 +49,18 @@ class ExtensibilityFormDataLine extends BaseTransactionLine_1.BaseTransactionLin
49
49
  get fields() {
50
50
  return this._fields;
51
51
  }
52
+ get voided() {
53
+ return false;
54
+ }
55
+ get preventsTransactionVoid() {
56
+ return false;
57
+ }
58
+ get allowVoid() {
59
+ return true;
60
+ }
61
+ get voidSource() {
62
+ return undefined;
63
+ }
52
64
  get prevFields() {
53
65
  return this._prevFields;
54
66
  }
@@ -0,0 +1,15 @@
1
+ import { ITransactionLineFactory } from "@aptos-scp/scp-component-store-selling-core";
2
+ import { VoidSource } from "../Constants";
3
+ import { BaseExtensibilityFormDataLineDecorator } from "./BaseExtensibilityFormDataLineDecorator";
4
+ import { ExtensibilityFormDataLine } from "./ExtensibilityFormDataLine";
5
+ export declare const DECORATOR_TYPE_VOIDED_EXTENSIBILITY_FORM_DATA_LINE: string;
6
+ export declare class VoidedExtensibilityFormDataLineDecorator extends BaseExtensibilityFormDataLineDecorator {
7
+ private _voidSource;
8
+ static createFromJsonObject(transactionLineJsonObj: any, transactionLineFactory: ITransactionLineFactory): VoidedExtensibilityFormDataLineDecorator;
9
+ get preventsTransactionVoid(): boolean;
10
+ get allowVoid(): boolean;
11
+ get voided(): boolean;
12
+ get voidSource(): VoidSource;
13
+ constructor(voidSource: VoidSource, extensibilityFormDataLine: ExtensibilityFormDataLine, annotationSourceLineNumber: number);
14
+ protected newTransactionLine(): VoidedExtensibilityFormDataLineDecorator;
15
+ }
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const BaseLineDecorator_1 = require("../BaseLineDecorator");
4
+ const VoidedLineDecorator_1 = require("../void/VoidedLineDecorator");
5
+ const BaseExtensibilityFormDataLineDecorator_1 = require("./BaseExtensibilityFormDataLineDecorator");
6
+ const VOIDED_EXTENSIBILITY_FORM_DATA_ANNOTATION_SOURCE_TYPE = "VoidedExtensibilityFormData";
7
+ exports.DECORATOR_TYPE_VOIDED_EXTENSIBILITY_FORM_DATA_LINE = "VOIDED_EXTENSIBILITY_FORM_DATA_DECORATOR";
8
+ class VoidedExtensibilityFormDataLineDecorator extends BaseExtensibilityFormDataLineDecorator_1.BaseExtensibilityFormDataLineDecorator {
9
+ constructor(voidSource, extensibilityFormDataLine, annotationSourceLineNumber) {
10
+ super(exports.DECORATOR_TYPE_VOIDED_EXTENSIBILITY_FORM_DATA_LINE, extensibilityFormDataLine, VoidedLineDecorator_1.DECORATOR_DESCRIPTION_VOIDED, VOIDED_EXTENSIBILITY_FORM_DATA_ANNOTATION_SOURCE_TYPE, annotationSourceLineNumber);
11
+ this._voidSource = voidSource;
12
+ }
13
+ static createFromJsonObject(transactionLineJsonObj, transactionLineFactory) {
14
+ const decoratedTransactionLineJsonObj = BaseLineDecorator_1.BaseLineDecorator.getDecoratedTransactionLineJsonObjectFromJsonObject(transactionLineJsonObj);
15
+ const decoratedLine = transactionLineFactory.createTransactionLineFromJsonObj(decoratedTransactionLineJsonObj);
16
+ const annotationSourceLineNumber = BaseLineDecorator_1.BaseLineDecorator.getAnnotationSourceLineNumberFromJsonObject(transactionLineJsonObj);
17
+ const voidSource = transactionLineJsonObj._voidSource;
18
+ const voidedExtensibilityFormDataLineDecorator = new VoidedExtensibilityFormDataLineDecorator(voidSource, decoratedLine, annotationSourceLineNumber);
19
+ return voidedExtensibilityFormDataLineDecorator;
20
+ }
21
+ get preventsTransactionVoid() {
22
+ return false;
23
+ }
24
+ get allowVoid() {
25
+ return true;
26
+ }
27
+ get voided() {
28
+ return true;
29
+ }
30
+ get voidSource() {
31
+ return this._voidSource;
32
+ }
33
+ newTransactionLine() {
34
+ return new VoidedExtensibilityFormDataLineDecorator(this._voidSource, this.decoratedTransactionLine, this.annotationSourceLineNumber);
35
+ }
36
+ }
37
+ exports.VoidedExtensibilityFormDataLineDecorator = VoidedExtensibilityFormDataLineDecorator;
38
+ //# sourceMappingURL=VoidedExtensibilityFormDataLineDecorator.js.map
@@ -1,2 +1,4 @@
1
1
  export * from "./IExtensibilityForm";
2
2
  export * from "./ExtensibilityFormDataLine";
3
+ export * from "./VoidedExtensibilityFormDataLineDecorator";
4
+ export * from "./BaseExtensibilityFormDataLineDecorator";
@@ -4,4 +4,6 @@ function __export(m) {
4
4
  }
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  __export(require("./ExtensibilityFormDataLine"));
7
+ __export(require("./VoidedExtensibilityFormDataLineDecorator"));
8
+ __export(require("./BaseExtensibilityFormDataLineDecorator"));
7
9
  //# sourceMappingURL=index.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": "1.31.0",
3
+ "version": "1.33.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",