@aptos-scp/scp-component-store-selling-features-domain-model 2.23.0 → 2.24.0-patch.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.
- package/README.md +1 -0
- package/lib/domain/UIBusinessEventTypes.d.ts +2 -0
- package/lib/domain/UIBusinessEventTypes.js +2 -0
- package/lib/domain/model/Constants.d.ts +10 -1
- package/lib/domain/model/Constants.js +9 -0
- package/lib/domain/model/OrderHandlingSession.d.ts +113 -0
- package/lib/domain/model/OrderHandlingSession.js +316 -0
- package/lib/domain/model/configuration/IAccessPolicyConfig.d.ts +8 -2
- package/lib/domain/model/configuration/IAutomaticLogOffOnTransactionCloseConfig.d.ts +8 -0
- package/lib/domain/model/configuration/IAutomaticLogOffOnTransactionCloseConfig.js +3 -0
- package/lib/domain/model/configuration/index.d.ts +1 -0
- package/lib/domain/model/fee/FeeLine.d.ts +1 -0
- package/lib/domain/model/fee/FeeLine.js +8 -0
- package/lib/domain/model/fiscalDevice/FiscalDeviceStatusLine.js +2 -0
- package/lib/domain/model/index.d.ts +1 -0
- package/lib/domain/model/index.js +1 -0
- package/lib/domain/utility/feeRefundUtils.d.ts +20 -0
- package/lib/domain/utility/feeRefundUtils.js +63 -0
- package/lib/domain/utility/index.d.ts +2 -0
- package/lib/domain/utility/index.js +2 -0
- package/lib/domain/utility/orderFeeUtils.d.ts +58 -0
- package/lib/domain/utility/orderFeeUtils.js +588 -0
- package/package.json +2 -2
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const scp_component_business_core_1 = require("@aptos-scp/scp-component-business-core");
|
|
4
|
+
/**
|
|
5
|
+
* Known refund codes that identify legitimate fee refunds/credits.
|
|
6
|
+
* - SSARefund: Refunds generated through Store Selling App return flow
|
|
7
|
+
* - NonSSAShippingAppeasement: Shipping fee credits/appeasements from external OMS
|
|
8
|
+
*/
|
|
9
|
+
const KNOWN_REFUND_CODES = ["SSARefund", "NonSSAShippingAppeasement"];
|
|
10
|
+
/**
|
|
11
|
+
* Checks if an AmountModifier represents a known refund/credit operation.
|
|
12
|
+
* Checks controlledOperation.reason.code first (more universal across OMS implementations),
|
|
13
|
+
* then falls back to amountModificationRule.name.
|
|
14
|
+
*
|
|
15
|
+
* @param modifier - The amount modifier to check
|
|
16
|
+
* @returns true if the modifier has a known refund code
|
|
17
|
+
*/
|
|
18
|
+
function isKnownRefundModifier(modifier) {
|
|
19
|
+
var _a, _b, _c;
|
|
20
|
+
// Primary: Check controlledOperation.reason.code (more universal across OMS implementations)
|
|
21
|
+
const reasonCode = (_b = (_a = modifier.controlledOperation) === null || _a === void 0 ? void 0 : _a.reason) === null || _b === void 0 ? void 0 : _b.code;
|
|
22
|
+
if (reasonCode && KNOWN_REFUND_CODES.includes(reasonCode)) {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
// Fallback: Check amountModificationRule.name
|
|
26
|
+
const ruleName = (_c = modifier.amountModificationRule) === null || _c === void 0 ? void 0 : _c.name;
|
|
27
|
+
if (ruleName && KNOWN_REFUND_CODES.includes(ruleName)) {
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Calculates the total amount previously refunded from a fee's amountModifiers.
|
|
34
|
+
* Only counts modifiers with "Subtract" action code AND a known refund code
|
|
35
|
+
* (SSARefund, NonSSAShippingAppeasement) to avoid counting other types of subtractions.
|
|
36
|
+
*
|
|
37
|
+
* @param amountModifiers - The array of amount modifiers from the order fee
|
|
38
|
+
* @param currency - The currency code for creating Money objects
|
|
39
|
+
* @returns The total previously refunded amount as a Money object
|
|
40
|
+
*/
|
|
41
|
+
function calculatePreviouslyRefundedAmount(amountModifiers, currency) {
|
|
42
|
+
if (!amountModifiers || amountModifiers.length === 0) {
|
|
43
|
+
return new scp_component_business_core_1.Money("0", currency);
|
|
44
|
+
}
|
|
45
|
+
return amountModifiers
|
|
46
|
+
.filter((modifier) => modifier.actionCode === "Subtract" && isKnownRefundModifier(modifier))
|
|
47
|
+
.reduce((total, modifier) => {
|
|
48
|
+
return total.plus(scp_component_business_core_1.Money.fromIMoney(modifier.amount));
|
|
49
|
+
}, new scp_component_business_core_1.Money("0", currency));
|
|
50
|
+
}
|
|
51
|
+
exports.calculatePreviouslyRefundedAmount = calculatePreviouslyRefundedAmount;
|
|
52
|
+
/**
|
|
53
|
+
* Calculates the refundable amount remaining after subtracting previously refunded amounts.
|
|
54
|
+
*
|
|
55
|
+
* @param originalAmount - The original fee amount
|
|
56
|
+
* @param previouslyRefundedAmount - The amount already refunded
|
|
57
|
+
* @returns The remaining refundable amount as a Money object
|
|
58
|
+
*/
|
|
59
|
+
function calculateRefundableAmount(originalAmount, previouslyRefundedAmount) {
|
|
60
|
+
return originalAmount.minus(previouslyRefundedAmount);
|
|
61
|
+
}
|
|
62
|
+
exports.calculateRefundableAmount = calculateRefundableAmount;
|
|
63
|
+
//# sourceMappingURL=feeRefundUtils.js.map
|
|
@@ -5,5 +5,7 @@ function __export(m) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
__export(require("./utils"));
|
|
7
7
|
__export(require("./orderUtils"));
|
|
8
|
+
__export(require("./orderFeeUtils"));
|
|
8
9
|
__export(require("./itemImageUtils"));
|
|
10
|
+
__export(require("./feeRefundUtils"));
|
|
9
11
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { IMoney, IPrice, Money, Price } from "@aptos-scp/scp-component-business-core";
|
|
2
|
+
import { IConfigurationManager } from "@aptos-scp/scp-component-store-selling-core";
|
|
3
|
+
import { FeeType, IFeeLine, IFeeSubline, IQuantity, ITaxByTaxAuthority, ITaxByTaxRule, ITaxOverride } from "@aptos-scp/scp-types-commerce-transaction";
|
|
4
|
+
import { Approval as OrderApproval, Associate as OrderAssociate, ControlledOperation as OrderControlledOperation, Employee as OrderEmployee, ExtensibilityData as OrderExtensibilityData, ExtensibilityDataSet as OrderExtensibilityDataSet, Fee as OrderFee, MeasuredQuantity as OrderMeasuredQuantity, Operator as OrderOperator, PersonName as OrderPersonName, Reason as OrderReason, Tax as OrderTax, TaxCollection as OrderTaxCollection } from "@aptos-scp/scp-types-orders";
|
|
5
|
+
import { IFeeDefinition, IShippingMethod } from "../model";
|
|
6
|
+
/**
|
|
7
|
+
* Converts an order fee to a fee line.
|
|
8
|
+
* @param orderFee - The order fee to convert.
|
|
9
|
+
* @param configurationManager - The configuration manager for data enrichment when order fee doesn't support tracking certain fields.
|
|
10
|
+
* @returns The converted fee line.
|
|
11
|
+
*/
|
|
12
|
+
export declare function convertOrderFee(orderFee: OrderFee, orderReferenceId: string, configurationManager: IConfigurationManager): IFeeLine | undefined;
|
|
13
|
+
export declare enum OrderFeeType {
|
|
14
|
+
Shipping = "Shipping",
|
|
15
|
+
Bag = "Bag",
|
|
16
|
+
Custom = "Custom",
|
|
17
|
+
RetailDelivery = "RetailDelivery",
|
|
18
|
+
PublicImprovement = "PublicImprovement",
|
|
19
|
+
HandlingFee = "HandlingFee",
|
|
20
|
+
WEEE = "WEEE",
|
|
21
|
+
EWaste = "EWaste",
|
|
22
|
+
BatteryFee = "BatteryFee",
|
|
23
|
+
FuelSurcharge = "FuelSurcharge",
|
|
24
|
+
EnvironmentalRecovery = "EnvironmentalRecovery",
|
|
25
|
+
Unknown = "Unknown"
|
|
26
|
+
}
|
|
27
|
+
export declare function convertFeeType(feeType: OrderFeeType): FeeType;
|
|
28
|
+
export declare function getFeeTaxGroupIdFromConfig(orderFee: OrderFee, configurationManager: IConfigurationManager): string;
|
|
29
|
+
export declare function getFeePercentFromConfig(orderFee: OrderFee, configurationManager: IConfigurationManager): number;
|
|
30
|
+
export declare function convertFeeTaxes(taxCollection: OrderTaxCollection, taxableAmount: Money): ITaxByTaxAuthority[];
|
|
31
|
+
export declare function convertTax(tax: OrderTax, taxableAmount?: Money): OrderTax;
|
|
32
|
+
export declare function convertControlledOperation(controlledOperation: OrderControlledOperation): OrderControlledOperation;
|
|
33
|
+
export declare function convertApproval(appproval: OrderApproval): OrderApproval;
|
|
34
|
+
export declare function convertControlledOperationReason(reason: OrderReason): OrderReason;
|
|
35
|
+
export declare function convertAssociate(associate: OrderAssociate): OrderAssociate;
|
|
36
|
+
export declare function convertOperator(operator: OrderOperator): OrderOperator;
|
|
37
|
+
export declare function convertToPersonName(personName: OrderPersonName): OrderPersonName;
|
|
38
|
+
export declare function convertEmployee(employee: OrderEmployee): OrderEmployee;
|
|
39
|
+
export declare function convertExtensibilityData(extensibilityData: OrderExtensibilityData): any;
|
|
40
|
+
export declare function convertExtensibilityDataSet(extensibilityDataSet: OrderExtensibilityDataSet): OrderExtensibilityDataSet;
|
|
41
|
+
export declare function convertTaxRules(taxByRules: OrderTax[]): ITaxByTaxRule[];
|
|
42
|
+
export declare function convertTaxRule(tax: OrderTax): ITaxByTaxRule;
|
|
43
|
+
export declare function convertFeeSublines(fee: OrderFee[]): IFeeSubline[];
|
|
44
|
+
export declare function calculateFeeSublineExtendedAmounts(orderFee: OrderFee, extendedAmount: IMoney): {
|
|
45
|
+
extendedAmountExcludingTax: IMoney;
|
|
46
|
+
extendedAmountIncludingTax: IMoney;
|
|
47
|
+
};
|
|
48
|
+
export declare function convertShippingFeeTaxes(taxes: OrderTaxCollection): ITaxByTaxAuthority[];
|
|
49
|
+
export declare function convertToPrice(money: Money, quantity?: number | string, units?: string): Price;
|
|
50
|
+
export declare function convertFeeExtendedAmount(orderFee: OrderFee): IMoney;
|
|
51
|
+
export declare function getItemTaxExemptAmount(taxes: OrderTax[]): IMoney | undefined;
|
|
52
|
+
export declare function getItemTaxAdjustmentAmount(taxes: OrderTax[]): IMoney | undefined;
|
|
53
|
+
export declare function convertQuantity(count: number, measure?: OrderMeasuredQuantity): IQuantity;
|
|
54
|
+
export declare function getFeeDefinitionByFeeId(feeId: string, configurationManager: IConfigurationManager): IFeeDefinition | undefined;
|
|
55
|
+
export declare function getShippingMethodConfigByFeeId(feeId: string, configurationManager: IConfigurationManager): IShippingMethod | undefined;
|
|
56
|
+
export declare function convertTaxOverride(taxes: OrderTaxCollection, quantity?: number): ITaxOverride | undefined;
|
|
57
|
+
export declare function convertPreTaxOverrideDetails(taxes: OrderTaxCollection): ITaxByTaxRule[];
|
|
58
|
+
export declare function convertFeeUnitPrice(unitPrice: Price | IPrice): Price;
|