@aptos-scp/scp-component-store-selling-features-domain-model 2.9.0-patch.1 → 2.9.0-patch.3

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.
@@ -7,6 +7,7 @@ import { AllowRefund } from "./configuration/ITendersConfig";
7
7
  import { ILabel, IPinRules, OverTenderRule, TenderAuthCategory } from "./Constants";
8
8
  import { MerchandiseTransaction } from "./MerchandiseTransaction";
9
9
  import { IOriginalTender, IOriginalTransactionDetails } from "./TenderHandlingSession";
10
+ export declare const mapTenderTypeToI18nCode: Map<string, string>;
10
11
  export declare enum TenderSignatureCapturePolicy {
11
12
  AuthResponseOnly = "AuthResponseOnly",
12
13
  ConfigurationOnly = "ConfigurationOnly",
@@ -40,6 +41,7 @@ export interface ITenderGroup {
40
41
  tenderType?: string;
41
42
  groupLabel?: ILabel;
42
43
  subType?: TenderSubType;
44
+ refundableAmount?: Money;
43
45
  }
44
46
  export interface IChangeBehaviorDefinition {
45
47
  forfeitChange?: boolean;
@@ -98,7 +100,7 @@ export declare class TenderType {
98
100
  static getActiveConfiguredTenderGroups(container: Container, accountingCurrency: string, activeTenders: TenderType[]): ITenderGroup[];
99
101
  static getActiveRefundConfiguredTenderGroups(container: Container, accountingCurrency: string, withTransaction: boolean, activeTenders: TenderType[], originalTransactionsDetails: IOriginalTransactionDetails[], withOfflineTransaction: boolean): ITenderGroup[];
100
102
  static tenderIsCreditOrDebit(tenderType: any): boolean;
101
- static getRefundableAmountByGroup(group: ITenderGroup, displayInfo: any, currency: string, configuration: IConfigurationManager, refundDue?: Money): Money;
103
+ static getRefundableAmountByGroup(group: ITenderGroup, displayInfo: any, currency: string, configuration: IConfigurationManager, refundDue?: Money, useGroupRefundableAmount?: boolean): Money;
102
104
  static getFeesTotal(displayInfo: any, accountingCurrency: string): Money;
103
105
  static getTenderedAmountsWithoutTransaction(tenderDisplayLines: any[], accountingCurrency: string, configurationManager: IConfigurationManager): Money;
104
106
  static getTenderedAmountsWithTransaction(tenderDisplayLines: any[], accountingCurrency: string, configurationManager: IConfigurationManager): Money;
@@ -159,6 +161,10 @@ export declare class TenderType {
159
161
  private static convertTenderTypeToGroup;
160
162
  private static getActiveCashTenders;
161
163
  }
164
+ export declare function combineOriginalUnreferencedAndMappedTenders(tender: IOriginalTender, unreferencedAndMappedTenders: IOriginalTender[]): void;
165
+ export declare function getConfiguredTender(originalTenderId: string, configurationManager: IConfigurationManager): any;
166
+ export declare function getAllRefundableCardTypes(tenderTypeBehavior: any): string[];
167
+ export declare function getMappedCardTypeNames(tenderConfig: any, refundCardTypes: any): string[];
162
168
  export declare function getActiveTendersByConfiguredPaymentRestrictions(activeTenderTypes: TenderType[], saleItemTypes: string[], diContainer: Container, orderTypes?: string[], productAttributeTypes?: string[]): TenderType[];
163
169
  export declare function getRefundableTendersByPaymentRestrictions(originalRefundableTenders: IOriginalTender[], saleItemTypes: string[], diContainer: Container, orderTypes?: string[], productAttributeTypes?: string[]): IOriginalTender[];
164
170
  export declare function getSaleItemTypes(transaction: MerchandiseTransaction): string[];
@@ -167,6 +173,8 @@ export declare function getProductAttributeTypes(transaction: MerchandiseTransac
167
173
  export declare function transactionHasPaymentRestrictionTypes(itemTypes: string[], orderTypes: string[], productAttributeTypes: string[]): boolean;
168
174
  export declare function getPaymentRestrictionBehaviors(diContainer: Container, tenderType: string): IConfigurationValues;
169
175
  export declare function isPaymentRestrictionBehaviorsConfigured(diContainer: Container, activeTenderTypes: TenderType[]): boolean;
176
+ export declare function sortOriginalTenders(originalTenders: IOriginalTender[]): IOriginalTender[];
177
+ export declare function buildMappedOriginalTender(originalTender: IOriginalTender, tenderName: string, tenderType: string, tenderId: string, tenderAuthCategory: TenderAuthCategory, transactionId: string, originalTransactions: IOriginalTransactionDetails[], subType: TenderSubType, cardType?: string, excludedCardTypes?: string[]): IOriginalTender;
170
178
  export declare function tenderIsActive(tenderDef: IConfigurationValues, isRefund: boolean, withTransaction: boolean, withReference: boolean, mappedTender: boolean, offlineTransaction: boolean, accountingCurrency: string): boolean;
171
179
  export declare function findConfiguredTenderFor(activeTenders: TenderType[], responseData: IAuthorizationResponse, tenderAuthCategory?: TenderAuthCategory): TenderType | TenderAuthFailureReasonCode;
172
180
  export declare function getReturnOrCancelTotalAmount(originalTran: IOriginalTransactionDetails): Money;
@@ -175,3 +183,4 @@ export declare function allowWalletSpecificTender(tenderAuthCategory: TenderAuth
175
183
  export declare function paymentDeviceCardExists(activeTenders: TenderType[]): boolean;
176
184
  export declare function walletSpecificTenderExists(activeTenders: TenderType[]): boolean;
177
185
  export declare function getTenderAuthCategoryFromTenderType(tenderType: string): TenderAuthCategory;
186
+ export declare function getCardTypeExceptions(tenderId: string, tenderDefinitions: any, tenderTypeBehavior: any): any;
@@ -13,7 +13,7 @@ const ItemLine_1 = require("./item/ItemLine");
13
13
  const utility_1 = require("../utility");
14
14
  const TenderHandlingSession_1 = require("./TenderHandlingSession");
15
15
  const logger = scp_component_logging_1.LogManager.getLogger("com.aptos.storesellingfeatures.domain.model.tendertype");
16
- const mapTenderTypeToI18nCode = new Map([
16
+ exports.mapTenderTypeToI18nCode = new Map([
17
17
  [scp_types_commerce_devices_1.TenderType.Credit, "tenderTypeCredit"],
18
18
  [scp_types_commerce_devices_1.TenderType.Debit, "tenderTypeDebit"],
19
19
  [scp_types_commerce_devices_1.TenderType.Cash, "tenderTypeCash"],
@@ -88,7 +88,7 @@ class TenderType {
88
88
  var _a, _b;
89
89
  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);
90
90
  }
91
- static getRefundableAmountByGroup(group, displayInfo, currency, configuration, refundDue) {
91
+ static getRefundableAmountByGroup(group, displayInfo, currency, configuration, refundDue, useGroupRefundableAmount = false) {
92
92
  var _a, _b, _c, _d;
93
93
  const withoutTransactionTotal = TenderType.getWithoutTransactionTotal(displayInfo, currency, configuration);
94
94
  const withTransactionTotal = TenderType.getWithTransactionTotal(displayInfo, currency, configuration);
@@ -127,14 +127,19 @@ class TenderType {
127
127
  }
128
128
  });
129
129
  let refundableAmount = new scp_component_business_core_1.Money(0, currency);
130
- if (tenderAllowRefund.includes(ITendersConfig_1.AllowRefund.WithTransaction)) {
131
- refundableAmount = refundableAmount.plus(withTransactionTotal);
130
+ if (group.refundableAmount && useGroupRefundableAmount) {
131
+ refundableAmount = group.refundableAmount;
132
132
  }
133
- if (tenderAllowRefund.includes(ITendersConfig_1.AllowRefund.WithoutTransaction)) {
134
- refundableAmount = refundableAmount.plus(withoutTransactionTotal);
135
- }
136
- if (tenderAllowRefund.includes(ITendersConfig_1.AllowRefund.WithOfflineTransaction)) {
137
- refundableAmount = refundableAmount.plus(withOfflineTransactionTotal);
133
+ else {
134
+ if (tenderAllowRefund.includes(ITendersConfig_1.AllowRefund.WithTransaction)) {
135
+ refundableAmount = refundableAmount.plus(withTransactionTotal);
136
+ }
137
+ if (tenderAllowRefund.includes(ITendersConfig_1.AllowRefund.WithoutTransaction)) {
138
+ refundableAmount = refundableAmount.plus(withoutTransactionTotal);
139
+ }
140
+ if (tenderAllowRefund.includes(ITendersConfig_1.AllowRefund.WithOfflineTransaction)) {
141
+ refundableAmount = refundableAmount.plus(withOfflineTransactionTotal);
142
+ }
138
143
  }
139
144
  return getLowestRefundDue(refundDue, undefined, refundableAmount);
140
145
  }
@@ -704,6 +709,7 @@ function combineOriginalUnreferencedAndMappedTenders(tender, unreferencedAndMapp
704
709
  unreferencedAndMappedTenders.push(_.cloneDeep(tender));
705
710
  }
706
711
  }
712
+ exports.combineOriginalUnreferencedAndMappedTenders = combineOriginalUnreferencedAndMappedTenders;
707
713
  function getOriginalTenderRefundableAmount(originalTender, refundDue, originalTransactionDetails, withTransactionTotal, withoutTransactionTotal, withOfflineTransactionTotal) {
708
714
  var _a;
709
715
  if (!originalTender) {
@@ -771,6 +777,7 @@ function getConfiguredTender(originalTenderId, configurationManager) {
771
777
  return (_b = (_a = configurationManager
772
778
  .getTendersValues()) === null || _a === void 0 ? void 0 : _a.tenderDefinitions) === null || _b === void 0 ? void 0 : _b.find((tender) => tender.tenderId === originalTenderId);
773
779
  }
780
+ exports.getConfiguredTender = getConfiguredTender;
774
781
  function getConfiguredMappedTenders(originalTender, configurationManager, transactionId, originalTransactions, refundDue) {
775
782
  var _a, _b, _c, _d, _e, _f;
776
783
  const mappedTenders = [];
@@ -782,12 +789,12 @@ function getConfiguredMappedTenders(originalTender, configurationManager, transa
782
789
  let refundCardTypes;
783
790
  let refundTenderTypes;
784
791
  let excludeCardTypes;
785
- const cardTypeExceptionsForOriginalTender = getCardTypeExceptions(originalTender, tenderDefinitions, tenderTypeBehavior);
792
+ const cardTypeExceptionsForOriginalTender = getCardTypeExceptions(originalTender.tenderId, tenderDefinitions, tenderTypeBehavior);
786
793
  // If the card type for the original tender is defined in the cardTypeExceptions, then use that
787
794
  if (!_.isEmpty(cardTypeExceptionsForOriginalTender)) {
788
795
  refundTenderTypes = cardTypeExceptionsForOriginalTender.refundTenderTypes;
789
796
  refundCardTypes = cardTypeExceptionsForOriginalTender.refundCardTypes;
790
- const mappedCardTypeNames = getMappedCardTypeNames(originalTender, tenderConfig, refundCardTypes);
797
+ const mappedCardTypeNames = getMappedCardTypeNames(tenderConfig, refundCardTypes);
791
798
  excludeCardTypes = mappedCardTypeNames;
792
799
  addCardTypeTendersToMappedTenders(mappedCardTypeNames, tenderDefinitions, mappedTenders, originalTender, transactionId, originalTransactions);
793
800
  }
@@ -819,6 +826,7 @@ function getAllRefundableCardTypes(tenderTypeBehavior) {
819
826
  }
820
827
  return refundableCardTypes;
821
828
  }
829
+ exports.getAllRefundableCardTypes = getAllRefundableCardTypes;
822
830
  function addCardTypeTendersToMappedTenders(mappedCardTypeNames, tenderDefinitions, mappedTenders, originalTender, transactionId, originalTransactions) {
823
831
  var _a;
824
832
  (_a = mappedCardTypeNames) === null || _a === void 0 ? void 0 : _a.forEach((cardType) => {
@@ -845,7 +853,7 @@ function addTenderTypesToMappedTenders(mappedTenderTypeNames, tenderDefinitions,
845
853
  if ((_a = tenderDefs) === null || _a === void 0 ? void 0 : _a.length) {
846
854
  tenderDefs.forEach((tenderDef) => {
847
855
  const label = tenderDef.tenderType === scp_types_commerce_devices_1.TenderType.Cash
848
- ? I18n.t(mapTenderTypeToI18nCode.get(tenderType), { defaultValue: tenderDef.tenderName })
856
+ ? I18n.t(exports.mapTenderTypeToI18nCode.get(tenderType), { defaultValue: tenderDef.tenderName })
849
857
  : (tenderDef.tenderLabel &&
850
858
  I18n.t(tenderDef.tenderLabel.i18nCode, {
851
859
  defaultValue: tenderDef.tenderLabel.default,
@@ -855,7 +863,7 @@ function addTenderTypesToMappedTenders(mappedTenderTypeNames, tenderDefinitions,
855
863
  });
856
864
  }
857
865
  else {
858
- const tenderName = I18n.t(mapTenderTypeToI18nCode.get(tenderType), { defaultValue: tenderType });
866
+ const tenderName = I18n.t(exports.mapTenderTypeToI18nCode.get(tenderType), { defaultValue: tenderType });
859
867
  mappedTenders.push(buildMappedOriginalTender(originalTender, tenderName, tenderType, undefined, getTenderAuthCategoryFromTenderType(tenderType), transactionId, originalTransactions, undefined, undefined, excludedCardTypes));
860
868
  }
861
869
  });
@@ -870,7 +878,7 @@ function getMappedTenderTypeNames(originalTender, tenderConfig, originalTransact
870
878
  isOriginalTenderAmountAllowed(originalTender, mappedRefundTenderType, originalTransactions, refundDue));
871
879
  }));
872
880
  }
873
- function getMappedCardTypeNames(originalTender, tenderConfig, refundCardTypes) {
881
+ function getMappedCardTypeNames(tenderConfig, refundCardTypes) {
874
882
  return (refundCardTypes &&
875
883
  Object.keys(refundCardTypes).filter((cardType) => {
876
884
  const mappedRefundCardType = refundCardTypes[cardType];
@@ -879,6 +887,7 @@ function getMappedCardTypeNames(originalTender, tenderConfig, refundCardTypes) {
879
887
  (!mappedRefundCardType.hasOwnProperty("allowed") || mappedRefundCardType["allowed"] === true));
880
888
  }));
881
889
  }
890
+ exports.getMappedCardTypeNames = getMappedCardTypeNames;
882
891
  function getActiveTendersByConfiguredPaymentRestrictions(activeTenderTypes, saleItemTypes, diContainer, orderTypes, productAttributeTypes) {
883
892
  let nonRestrictedTenderTypes = [];
884
893
  let restrictedTenderTypes = [];
@@ -1129,6 +1138,7 @@ function sortOriginalTenders(originalTenders) {
1129
1138
  return a.originalTenderAmount.gt(b.originalTenderAmount) ? -1 : 0;
1130
1139
  });
1131
1140
  }
1141
+ exports.sortOriginalTenders = sortOriginalTenders;
1132
1142
  function allowMappedTender(tenderType, tenderConfig) {
1133
1143
  return tenderConfig.tenderDefinitions.some((tender) => { var _a; return tender.tenderType === tenderType && ((_a = tender.allowRefund) === null || _a === void 0 ? void 0 : _a.indexOf("WhenMapped")) > -1; });
1134
1144
  }
@@ -1167,6 +1177,7 @@ function buildMappedOriginalTender(originalTender, tenderName, tenderType, tende
1167
1177
  mappedOriginTenderId: originalTender.tenderId,
1168
1178
  };
1169
1179
  }
1180
+ exports.buildMappedOriginalTender = buildMappedOriginalTender;
1170
1181
  function isOriginalTenderFullyRefunded(originalTender, returnTotalAmount) {
1171
1182
  var _a;
1172
1183
  const totalRefundedAmount = originalTender &&
@@ -1616,14 +1627,15 @@ function getChangeAmount(balanceDue, tenderAmount) {
1616
1627
  return tenderAmount.minus(balanceDue);
1617
1628
  }
1618
1629
  }
1619
- function getCardTypeExceptions(originalTender, tenderDefinitions, tenderTypeBehavior) {
1630
+ function getCardTypeExceptions(tenderId, tenderDefinitions, tenderTypeBehavior) {
1620
1631
  var _a, _b;
1621
1632
  // Find the tender definition for the original tender
1622
- const originalTenderDefinition = tenderDefinitions.find((tender) => tender.tenderId === originalTender.tenderId);
1633
+ const originalTenderDefinition = tenderDefinitions.find((tender) => tender.tenderId === tenderId);
1623
1634
  // If
1624
1635
  if (originalTenderDefinition && ((_b = (_a = tenderTypeBehavior) === null || _a === void 0 ? void 0 : _a.cardTypeExceptions) === null || _b === void 0 ? void 0 : _b.enabled)) {
1625
1636
  // Is there an entry for the card type in the cardTypeExceptions?
1626
1637
  return tenderTypeBehavior.cardTypeExceptions[originalTenderDefinition.cardType];
1627
1638
  }
1628
1639
  }
1640
+ exports.getCardTypeExceptions = getCardTypeExceptions;
1629
1641
  //# sourceMappingURL=TenderType.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.9.0-patch.1",
3
+ "version": "2.9.0-patch.3",
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",