@aptos-scp/scp-component-store-selling-features-domain-model 2.48.1 → 2.49.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.
@@ -40,7 +40,6 @@ export interface IFeatureAccessConfig {
40
40
  tender?: {
41
41
  autoPopulateCardNumberFromCustomer?: boolean;
42
42
  allowEmployee?: boolean;
43
- issueNewOnRefundAuthFailure?: boolean;
44
43
  };
45
44
  errorMessages?: {
46
45
  [errorCode: string]: {
@@ -2,7 +2,7 @@ import { Money, Price, Quantity } from "@aptos-scp/scp-component-business-core";
2
2
  import { IUser } from "@aptos-scp/scp-component-store-selling-core";
3
3
  import { IAppliedTax } from "@aptos-scp/scp-component-taxation";
4
4
  import { IAuthorizationResponse } from "@aptos-scp/scp-types-commerce-devices";
5
- import { ActionType, IPriceChange, ISubline as IPostableSubline, ITaxByTaxRule, ITaxExempt, ITaxOverride, ITaxOverrideDetails, ItemType, ITransactionLineReferenceType, SourceIndicator, UnitPriceSourceIndicator, StyleTypeEnum } from "@aptos-scp/scp-types-commerce-transaction";
5
+ import { ActionType, IPriceChange, ISubline as IPostableSubline, ITaxByTaxRule, ITaxExempt, ITaxOverride, ITaxOverrideDetails, ItemType, ITransactionLineReferenceType, SourceIndicator, UnitPriceSourceIndicator, StyleTypeEnum, ITimeInterval } from "@aptos-scp/scp-types-commerce-transaction";
6
6
  import { ItemSubType } from "@aptos-scp/scp-types-store-items";
7
7
  import { ISublinePricingAdjustmentWithSource } from "./ISerializedPriceCalculationResultsWithSource";
8
8
  import { BaseLineDecorator } from "../../model/BaseLineDecorator";
@@ -130,6 +130,9 @@ export declare abstract class BaseItemLineDecorator extends BaseLineDecorator<II
130
130
  get presentation(): IItemLine;
131
131
  get extendedPresentationAmount(): Money;
132
132
  get subscriptionFrequencyCodes(): string[];
133
+ get deliveryCode(): string | undefined;
134
+ get deliveryInterval(): ITimeInterval | undefined;
135
+ get deliveryFrequencyText(): string | undefined;
133
136
  get subType(): ItemSubType;
134
137
  get autoSubscribe(): boolean;
135
138
  get cancelled(): boolean;
@@ -339,6 +339,15 @@ class BaseItemLineDecorator extends BaseLineDecorator_1.BaseLineDecorator {
339
339
  get subscriptionFrequencyCodes() {
340
340
  return this.decoratedTransactionLine.subscriptionFrequencyCodes;
341
341
  }
342
+ get deliveryCode() {
343
+ return this.decoratedTransactionLine.deliveryCode;
344
+ }
345
+ get deliveryInterval() {
346
+ return this.decoratedTransactionLine.deliveryInterval;
347
+ }
348
+ get deliveryFrequencyText() {
349
+ return this.decoratedTransactionLine.deliveryFrequencyText;
350
+ }
342
351
  get subType() {
343
352
  return this.decoratedTransactionLine.subType;
344
353
  }
@@ -2,7 +2,7 @@ import { Money, Price, Quantity } from "@aptos-scp/scp-component-business-core";
2
2
  import { ITransactionLine, IUser } from "@aptos-scp/scp-component-store-selling-core";
3
3
  import { IAppliedTax } from "@aptos-scp/scp-component-taxation";
4
4
  import { IAuthorizationResponse } from "@aptos-scp/scp-types-commerce-devices";
5
- import { ActionType, IPriceChange, ISubline as IPostableSubline, ITaxByTaxAuthority, ITaxByTaxRule, ITaxExempt, ITaxOverride, ITaxOverrideDetails, ItemType, ITransactionLineReferenceType, IUser as IPostedUser, LoyaltyRedemptionType, SourceIndicator, UnitPriceSourceIndicator, ICompetitivePriceInformation, IProratedItemLineReference, IReason, StyleTypeEnum } from "@aptos-scp/scp-types-commerce-transaction";
5
+ import { ActionType, IPriceChange, ISubline as IPostableSubline, ITaxByTaxAuthority, ITaxByTaxRule, ITaxExempt, ITaxOverride, ITaxOverrideDetails, ItemType, ITransactionLineReferenceType, IUser as IPostedUser, LoyaltyRedemptionType, SourceIndicator, UnitPriceSourceIndicator, ICompetitivePriceInformation, IProratedItemLineReference, IReason, StyleTypeEnum, ITimeInterval } from "@aptos-scp/scp-types-commerce-transaction";
6
6
  import { ItemSubType } from "@aptos-scp/scp-types-store-items";
7
7
  import { ISerializedSublinePricingAdjustmentWithSource, ISublinePricingAdjustmentWithSource } from "./ISerializedPriceCalculationResultsWithSource";
8
8
  import { SecurityAuthorizationStatusType } from "../Constants";
@@ -270,6 +270,19 @@ export interface IItemLine extends ITransactionLine, IVoidableLine, IPriceProvid
270
270
  * For pre-order items, the available date of the item.
271
271
  */
272
272
  readonly preOrderAvailableDate?: string;
273
+ /**
274
+ * For subscription items, the delivery code of the item.
275
+ */
276
+ readonly deliveryCode?: string;
277
+ /**
278
+ * For subscription items, the delivery interval of the item.
279
+ * This is the interval of the subscription frequency code.
280
+ */
281
+ readonly deliveryInterval?: ITimeInterval;
282
+ /**
283
+ * For subscription items, the delivery frequency text of the item.
284
+ */
285
+ readonly deliveryFrequencyText?: string;
273
286
  setTransactionLineTaxes(transactionLineTaxes: ITransactionLineTaxes, extendedAmount?: Money): IItemLine;
274
287
  setSublines(sublines: IItemSubline[]): IItemLine;
275
288
  setTaxExemptInformation(taxExemptLine: ItemTaxExemptLine | TransactionTaxExemptLine, preTaxExemptDetails: IAppliedTax[]): IItemLine;
@@ -3,7 +3,7 @@ import { ICopyableLine } from "@aptos-scp/scp-component-store-selling-core/lib/d
3
3
  import { IExtendedAmountMaintainer, ITransactionLine, IUser, UiBusinessEvent } from "@aptos-scp/scp-component-store-selling-core";
4
4
  import { IAppliedTax } from "@aptos-scp/scp-component-taxation";
5
5
  import { IAuthorizationResponse } from "@aptos-scp/scp-types-commerce-devices";
6
- import { ActionType, ISameTransactionLineReference, ISubline as IPostableSubline, ITaxByTaxRule, ITaxExempt, ITaxOverride, ITaxOverrideDetails, ItemType, ITransactionLineReferenceType, SourceIndicator, UnitPriceSourceIndicator, IPriceChange, IReason, StyleTypeEnum } from "@aptos-scp/scp-types-commerce-transaction";
6
+ import { ActionType, ISameTransactionLineReference, ISubline as IPostableSubline, ITaxByTaxRule, ITaxExempt, ITaxOverride, ITaxOverrideDetails, ItemType, ITransactionLineReferenceType, SourceIndicator, UnitPriceSourceIndicator, IPriceChange, IReason, StyleTypeEnum, ITimeInterval } from "@aptos-scp/scp-types-commerce-transaction";
7
7
  import { ItemSubType } from "@aptos-scp/scp-types-store-items";
8
8
  import { ISublinePricingAdjustmentWithSource } from "./ISerializedPriceCalculationResultsWithSource";
9
9
  import { ItemTaxExemptLine, TransactionTaxExemptLine } from "../../model/taxExempt";
@@ -118,6 +118,9 @@ export declare class ItemLine extends BaseTransactionLine implements IItemLine,
118
118
  private _rewardCardTenders?;
119
119
  private _preOrder?;
120
120
  private _preOrderAvailableDate?;
121
+ private _deliveryCode?;
122
+ private _deliveryInterval?;
123
+ private _deliveryFrequencyText?;
121
124
  /**
122
125
  * The create method is called by the transaction line factory to create an instance and initialize it from the
123
126
  * data collected during the qualification process.
@@ -279,6 +282,9 @@ export declare class ItemLine extends BaseTransactionLine implements IItemLine,
279
282
  get extendedAmountAfterTaxAdjustment(): Money;
280
283
  get unitPriceAfterTaxAdjustment(): Price;
281
284
  get rewardCardTenders(): IRewardCardTender[];
285
+ get deliveryCode(): string;
286
+ get deliveryInterval(): ITimeInterval;
287
+ get deliveryFrequencyText(): string;
282
288
  updateExtendedAmount(amount: Money): ITransactionLine;
283
289
  updateExtendedAmountExcludingTax(amount: Money): ITransactionLine;
284
290
  updateExtendedAmountIncludingTax(amount: Money): ITransactionLine;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const scp_component_business_core_1 = require("@aptos-scp/scp-component-business-core");
4
4
  const scp_types_commerce_transaction_1 = require("@aptos-scp/scp-types-commerce-transaction");
5
5
  const orderUtils_1 = require("../../../domain/utility/orderUtils");
6
+ const subscriptionFrequencyUtils_1 = require("../../../domain/utility/subscriptionFrequencyUtils");
6
7
  const BaseTransactionLine_1 = require("../BaseTransactionLine");
7
8
  const Constants_1 = require("../Constants");
8
9
  const Customer_1 = require("../Customer");
@@ -39,7 +40,7 @@ class ItemLine extends BaseTransactionLine_1.BaseTransactionLine {
39
40
  // tslint:disable-next-line:cyclomatic-complexity
40
41
  // eslint-disable-next-line complexity
41
42
  static create(lineNumber, lineType, uiBusinessEvent, collectedData) {
42
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
43
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
43
44
  let accountingCurrency = collectedData.get("accountingCurrency");
44
45
  const additionalItemInfo = collectedData.get("additionalItemInfo");
45
46
  const authResponse = collectedData.get(Constants_1.CollectedDataKey.TenderAuthResponse);
@@ -106,6 +107,15 @@ class ItemLine extends BaseTransactionLine_1.BaseTransactionLine {
106
107
  itemLine._subscriptionFrequencyCodes = storeItem.subscriptionFrequencyCodes;
107
108
  itemLine._subType = (_d = storeItem) === null || _d === void 0 ? void 0 : _d.subType;
108
109
  itemLine._autoSubscribe = (_e = storeItem) === null || _e === void 0 ? void 0 : _e.autoSubscribe;
110
+ const isLoyaltyMembershipNonMerchSubscription = storeItem.itemType === scp_types_commerce_transaction_1.ItemType.NonMerch && storeItem.subType === "LoyaltyMembership";
111
+ const intervalFromSubscriptionCode = isLoyaltyMembershipNonMerchSubscription && ((_f = storeItem.subscriptionFrequencyCodes) === null || _f === void 0 ? void 0 : _f[0])
112
+ ? subscriptionFrequencyUtils_1.buildTimeIntervalFromCode((_g = storeItem.subscriptionFrequencyCodes) === null || _g === void 0 ? void 0 : _g[0])
113
+ : undefined;
114
+ if (intervalFromSubscriptionCode && isLoyaltyMembershipNonMerchSubscription) {
115
+ itemLine._deliveryCode = `${intervalFromSubscriptionCode.value}${intervalFromSubscriptionCode.unit}`;
116
+ itemLine._deliveryInterval = intervalFromSubscriptionCode;
117
+ itemLine._deliveryFrequencyText = subscriptionFrequencyUtils_1.buildDeliveryFrequencyTextFromTimeInterval(intervalFromSubscriptionCode);
118
+ }
109
119
  if (collectedData.get(Constants_1.CollectedDataKey.OriginalAlternativeLookupCodesExternalItem)) {
110
120
  itemLine._itemLookupKeys = ItemLine.getItemLookupKeyFromCollectedData(collectedData.get(Constants_1.CollectedDataKey.OriginalAlternativeLookupCodesExternalItem));
111
121
  }
@@ -204,13 +214,13 @@ class ItemLine extends BaseTransactionLine_1.BaseTransactionLine {
204
214
  if (taxIndicatorOnReceipt) {
205
215
  itemLine._taxIndicatorOnReceipt = taxIndicatorOnReceipt;
206
216
  }
207
- if (((_f = originalLoyaltyInformation) === null || _f === void 0 ? void 0 : _f.length) > 0) {
217
+ if (((_h = originalLoyaltyInformation) === null || _h === void 0 ? void 0 : _h.length) > 0) {
208
218
  itemLine._originalLoyaltyInformation = originalLoyaltyInformation;
209
219
  }
210
220
  if (originalCompetitivePriceInformation) {
211
221
  itemLine._originalCompetitivePriceInformation = originalCompetitivePriceInformation;
212
222
  }
213
- if (((_g = originalSupervisorOverrideInformation) === null || _g === void 0 ? void 0 : _g.length) > 0) {
223
+ if (((_j = originalSupervisorOverrideInformation) === null || _j === void 0 ? void 0 : _j.length) > 0) {
214
224
  itemLine._originalSupervisorOverrideInformation = originalSupervisorOverrideInformation;
215
225
  }
216
226
  if (originalTaxOverride) {
@@ -218,7 +228,7 @@ class ItemLine extends BaseTransactionLine_1.BaseTransactionLine {
218
228
  itemLine._taxOverride = originalTaxOverride.taxOverride;
219
229
  itemLine._preTaxOverrideDetails = originalTaxOverride.preTaxOverrideDetails;
220
230
  }
221
- if (((_h = originalRewardCardTenders) === null || _h === void 0 ? void 0 : _h.length) > 0) {
231
+ if (((_k = originalRewardCardTenders) === null || _k === void 0 ? void 0 : _k.length) > 0) {
222
232
  itemLine._originalRewardCardTenders = originalRewardCardTenders;
223
233
  }
224
234
  }
@@ -252,11 +262,11 @@ class ItemLine extends BaseTransactionLine_1.BaseTransactionLine {
252
262
  itemLine._originalAdjustments = originalAdjustments;
253
263
  }
254
264
  const originalRedemptionLoyaltyTransactionKeys = collectedData.get(Constants_1.CollectedDataKey.OriginalRedemptionLoyaltyTransactionKeys);
255
- if (((_j = originalRedemptionLoyaltyTransactionKeys) === null || _j === void 0 ? void 0 : _j.length) > 0) {
265
+ if (((_l = originalRedemptionLoyaltyTransactionKeys) === null || _l === void 0 ? void 0 : _l.length) > 0) {
256
266
  itemLine._originalRedemptionLoyaltyTransactionKeys = originalRedemptionLoyaltyTransactionKeys;
257
267
  }
258
268
  const originalSaleLoyaltyTransactionKeys = collectedData.get(Constants_1.CollectedDataKey.OriginalSaleLoyaltyTransactionKeys);
259
- if (((_k = originalSaleLoyaltyTransactionKeys) === null || _k === void 0 ? void 0 : _k.length) > 0) {
269
+ if (((_m = originalSaleLoyaltyTransactionKeys) === null || _m === void 0 ? void 0 : _m.length) > 0) {
260
270
  itemLine._originalSaleLoyaltyTransactionKeys = originalSaleLoyaltyTransactionKeys;
261
271
  }
262
272
  const originalTransactionLineReference = collectedData.get(Constants_1.CollectedDataKey.OriginalTransactionLineReference);
@@ -751,6 +761,15 @@ class ItemLine extends BaseTransactionLine_1.BaseTransactionLine {
751
761
  get rewardCardTenders() {
752
762
  return this._rewardCardTenders;
753
763
  }
764
+ get deliveryCode() {
765
+ return this._deliveryCode;
766
+ }
767
+ get deliveryInterval() {
768
+ return this._deliveryInterval;
769
+ }
770
+ get deliveryFrequencyText() {
771
+ return this._deliveryFrequencyText;
772
+ }
754
773
  updateExtendedAmount(amount) {
755
774
  amount = adjustSignForLineType(this.lineType, amount);
756
775
  return this.updateExtendedAmountValue(amount).setExtendedAmountExcludingAndIncludingTax();
@@ -979,6 +998,9 @@ class ItemLine extends BaseTransactionLine_1.BaseTransactionLine {
979
998
  newItemLine._originalAdjustments = this._originalAdjustments;
980
999
  newItemLine._originalRewardCardTenders = this._originalRewardCardTenders;
981
1000
  newItemLine._rewardCardTenders = this._rewardCardTenders;
1001
+ newItemLine._deliveryCode = this._deliveryCode;
1002
+ newItemLine._deliveryInterval = this._deliveryInterval;
1003
+ newItemLine._deliveryFrequencyText = this._deliveryFrequencyText;
982
1004
  return newItemLine;
983
1005
  }
984
1006
  // eslint-disable-next-line complexity
@@ -1128,6 +1150,9 @@ class ItemLine extends BaseTransactionLine_1.BaseTransactionLine {
1128
1150
  this._originalAdjustments = transactionLineJsonObj._originalAdjustments;
1129
1151
  this._originalRewardCardTenders = transactionLineJsonObj._originalRewardCardTenders;
1130
1152
  this._rewardCardTenders = transactionLineJsonObj._rewardCardTenders;
1153
+ this._deliveryCode = transactionLineJsonObj._deliveryCode;
1154
+ this._deliveryInterval = transactionLineJsonObj._deliveryInterval;
1155
+ this._deliveryFrequencyText = transactionLineJsonObj._deliveryFrequencyText;
1131
1156
  }
1132
1157
  newTransactionLine() {
1133
1158
  return new ItemLine(this.lineNumber, this.lineType, this._accountingCurrency);
@@ -3,3 +3,4 @@ export * from "./orderUtils";
3
3
  export * from "./orderFeeUtils";
4
4
  export * from "./itemImageUtils";
5
5
  export * from "./feeRefundUtils";
6
+ export * from "./subscriptionFrequencyUtils";
@@ -8,4 +8,5 @@ __export(require("./orderUtils"));
8
8
  __export(require("./orderFeeUtils"));
9
9
  __export(require("./itemImageUtils"));
10
10
  __export(require("./feeRefundUtils"));
11
+ __export(require("./subscriptionFrequencyUtils"));
11
12
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,3 @@
1
+ import { ITimeInterval } from "@aptos-scp/scp-types-commerce-transaction";
2
+ export declare function buildTimeIntervalFromCode(code: string): ITimeInterval | undefined;
3
+ export declare function buildDeliveryFrequencyTextFromTimeInterval(interval: ITimeInterval): string;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const UNIT_SUFFIX_MAP = {
4
+ d: "Day",
5
+ w: "Week",
6
+ m: "Month",
7
+ y: "Year",
8
+ day: "Day",
9
+ week: "Week",
10
+ month: "Month",
11
+ year: "Year",
12
+ };
13
+ function buildTimeIntervalFromCode(code) {
14
+ var _a;
15
+ const match = (_a = code) === null || _a === void 0 ? void 0 : _a.match(/^(\d+)([a-zA-Z]+)$/);
16
+ if (!match) {
17
+ return undefined;
18
+ }
19
+ const value = parseInt(match[1], 10);
20
+ const suffix = match[2].toLowerCase();
21
+ const unit = UNIT_SUFFIX_MAP[suffix];
22
+ return unit ? { unit, value } : undefined;
23
+ }
24
+ exports.buildTimeIntervalFromCode = buildTimeIntervalFromCode;
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}`;
38
+ }
39
+ exports.buildDeliveryFrequencyTextFromTimeInterval = buildDeliveryFrequencyTextFromTimeInterval;
40
+ //# sourceMappingURL=subscriptionFrequencyUtils.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.48.1",
3
+ "version": "2.49.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",
@@ -64,7 +64,7 @@
64
64
  "@aptos-scp/scp-types-client-registration": "^1.4.0",
65
65
  "@aptos-scp/scp-types-core-config": "^2.2.1",
66
66
  "@aptos-scp/scp-types-commerce-devices": "^6.10.0",
67
- "@aptos-scp/scp-types-commerce-transaction": "^1.93.0",
67
+ "@aptos-scp/scp-types-commerce-transaction": "^1.95.0",
68
68
  "@aptos-scp/scp-types-customer": "^3.7.0",
69
69
  "@aptos-scp/scp-types-einvoice": "^1.17.0",
70
70
  "@aptos-scp/scp-types-inventory": "^2.0.0",
@@ -86,7 +86,7 @@
86
86
  "@aptos-scp/scp-component-user": "^1.4.0",
87
87
  "@aptos-scp/scp-types-client-registration": "^1.4.0",
88
88
  "@aptos-scp/scp-types-commerce-devices": "^6.12.0",
89
- "@aptos-scp/scp-types-commerce-transaction": "^1.94.0",
89
+ "@aptos-scp/scp-types-commerce-transaction": "^1.95.0",
90
90
  "@aptos-scp/scp-types-core": "^1.0.5",
91
91
  "@aptos-scp/scp-types-core-config": "^2.2.1",
92
92
  "@aptos-scp/scp-types-currency-conversion": "^1.2.0",