@adtrackify/at-service-common 4.0.35 → 5.0.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.
- package/dist/cjs/__tests__/services/cost/cost-calculator-service.spec.js +19 -7
- package/dist/cjs/__tests__/services/cost/cost-calculator-service.spec.js.map +1 -1
- package/dist/cjs/clients/internal-api/accounts-client.d.ts +1 -1
- package/dist/cjs/clients/internal-api/accounts-client.js +3 -3
- package/dist/cjs/clients/internal-api/accounts-client.js.map +1 -1
- package/dist/cjs/services/cost/cost-calculator-service.js +3 -2
- package/dist/cjs/services/cost/cost-calculator-service.js.map +1 -1
- package/dist/esm/__tests__/services/cost/cost-calculator-service.spec.js +19 -7
- package/dist/esm/__tests__/services/cost/cost-calculator-service.spec.js.map +1 -1
- package/dist/esm/clients/internal-api/accounts-client.d.ts +1 -1
- package/dist/esm/clients/internal-api/accounts-client.js +3 -3
- package/dist/esm/clients/internal-api/accounts-client.js.map +1 -1
- package/dist/esm/services/cost/cost-calculator-service.js +3 -2
- package/dist/esm/services/cost/cost-calculator-service.js.map +1 -1
- package/package.json +1 -1
|
@@ -144,17 +144,17 @@ describe('CostCalculatorService', () => {
|
|
|
144
144
|
const liCosts = initLineItemCosts();
|
|
145
145
|
expect(cost_calculator_service_1.CostCalculatorService.calculateHandlingCost(configs, lineItems, liCosts, 'USD', emptyRatesMap)).toBe(0);
|
|
146
146
|
});
|
|
147
|
-
it('should apply
|
|
147
|
+
it('should apply the fee per unit, multiplied by quantity', () => {
|
|
148
148
|
const configs = createConfigs({
|
|
149
149
|
globalProductOverride: { globalHandlingFee: 2, currency: 'USD' },
|
|
150
150
|
});
|
|
151
151
|
const lineItems = [createLineItem({ lineItemId: '1', quantity: 3 })];
|
|
152
152
|
const liCosts = initLineItemCosts();
|
|
153
153
|
const result = cost_calculator_service_1.CostCalculatorService.calculateHandlingCost(configs, lineItems, liCosts, 'USD', emptyRatesMap);
|
|
154
|
-
expect(result).toBe(
|
|
155
|
-
expect(liCosts['1'].totalLineItemHandlingCost).toBe(
|
|
154
|
+
expect(result).toBe(6);
|
|
155
|
+
expect(liCosts['1'].totalLineItemHandlingCost).toBe(6);
|
|
156
156
|
});
|
|
157
|
-
it('should sum across multiple line items', () => {
|
|
157
|
+
it('should sum across multiple line items using each quantity', () => {
|
|
158
158
|
const configs = createConfigs({
|
|
159
159
|
globalProductOverride: { globalHandlingFee: 2, currency: 'USD' },
|
|
160
160
|
});
|
|
@@ -164,9 +164,21 @@ describe('CostCalculatorService', () => {
|
|
|
164
164
|
];
|
|
165
165
|
const liCosts = initLineItemCosts(['1', '2']);
|
|
166
166
|
const result = cost_calculator_service_1.CostCalculatorService.calculateHandlingCost(configs, lineItems, liCosts, 'USD', emptyRatesMap);
|
|
167
|
-
expect(result).toBe(
|
|
168
|
-
expect(liCosts['1'].totalLineItemHandlingCost).toBe(
|
|
169
|
-
expect(liCosts['2'].totalLineItemHandlingCost).toBe(
|
|
167
|
+
expect(result).toBe(10);
|
|
168
|
+
expect(liCosts['1'].totalLineItemHandlingCost).toBe(4);
|
|
169
|
+
expect(liCosts['2'].totalLineItemHandlingCost).toBe(6);
|
|
170
|
+
});
|
|
171
|
+
it('should match the variant-level fee when both are the same amount', () => {
|
|
172
|
+
const configs = createConfigs({
|
|
173
|
+
globalProductOverride: { globalHandlingFee: 2, currency: 'USD' },
|
|
174
|
+
});
|
|
175
|
+
const quantity = 4;
|
|
176
|
+
const globalCosts = initLineItemCosts();
|
|
177
|
+
const globalTotal = cost_calculator_service_1.CostCalculatorService.calculateHandlingCost(configs, [createLineItem({ lineItemId: '1', quantity })], globalCosts, 'USD', emptyRatesMap);
|
|
178
|
+
const variantTotal = cost_calculator_service_1.CostCalculatorService.calculateLineItemHandlingCosts([
|
|
179
|
+
createLineItem({ lineItemId: '1', quantity, variantHandlingFee: 2 }),
|
|
180
|
+
]);
|
|
181
|
+
expect(globalTotal).toBe(variantTotal['1']);
|
|
170
182
|
});
|
|
171
183
|
it('should convert currency when config currency differs from order currency', () => {
|
|
172
184
|
const configs = createConfigs({
|