@medusajs/utils 1.8.2 → 1.8.3-canary-20230512135047
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/tax/calculate-price-tax-amount.d.ts +13 -0
- package/dist/tax/calculate-price-tax-amount.js +20 -0
- package/dist/tax/calculate-price-tax-amount.js.map +1 -0
- package/dist/tax/index.d.ts +1 -0
- package/dist/tax/index.js +18 -0
- package/dist/tax/index.js.map +1 -0
- package/dist/totals/index.d.ts +1 -0
- package/dist/totals/index.js +18 -0
- package/dist/totals/index.js.map +1 -0
- package/dist/totals/totals.d.ts +191 -0
- package/dist/totals/totals.js +508 -0
- package/dist/totals/totals.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Return the tax amount that
|
|
3
|
+
* - is includes in the price if it is tax inclusive
|
|
4
|
+
* - will be applied on to the price if it is tax exclusive
|
|
5
|
+
* @param price
|
|
6
|
+
* @param includesTax
|
|
7
|
+
* @param taxRate
|
|
8
|
+
*/
|
|
9
|
+
export declare function calculatePriceTaxAmount({ price, includesTax, taxRate, }: {
|
|
10
|
+
price: number;
|
|
11
|
+
includesTax?: boolean;
|
|
12
|
+
taxRate: number;
|
|
13
|
+
}): number;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.calculatePriceTaxAmount = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Return the tax amount that
|
|
6
|
+
* - is includes in the price if it is tax inclusive
|
|
7
|
+
* - will be applied on to the price if it is tax exclusive
|
|
8
|
+
* @param price
|
|
9
|
+
* @param includesTax
|
|
10
|
+
* @param taxRate
|
|
11
|
+
*/
|
|
12
|
+
function calculatePriceTaxAmount(_a) {
|
|
13
|
+
var price = _a.price, includesTax = _a.includesTax, taxRate = _a.taxRate;
|
|
14
|
+
if (includesTax) {
|
|
15
|
+
return (taxRate * price) / (1 + taxRate);
|
|
16
|
+
}
|
|
17
|
+
return price * taxRate;
|
|
18
|
+
}
|
|
19
|
+
exports.calculatePriceTaxAmount = calculatePriceTaxAmount;
|
|
20
|
+
//# sourceMappingURL=calculate-price-tax-amount.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calculate-price-tax-amount.js","sourceRoot":"","sources":["../../src/tax/calculate-price-tax-amount.ts"],"names":[],"mappings":";;;AAAA;;;;;;;GAOG;AACH,SAAgB,uBAAuB,CAAC,EAQvC;QAPC,KAAK,WAAA,EACL,WAAW,iBAAA,EACX,OAAO,aAAA;IAMP,IAAI,WAAW,EAAE;QACf,OAAO,CAAC,OAAO,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,OAAO,CAAC,CAAA;KACzC;IAED,OAAO,KAAK,GAAG,OAAO,CAAA;AACxB,CAAC;AAdD,0DAcC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./calculate-price-tax-amount";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./calculate-price-tax-amount"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tax/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+DAA4C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./totals";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./totals"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/totals/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAwB"}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { LineAllocationsMap, TaxTypes } from "@medusajs/types";
|
|
2
|
+
declare type LineItemTotals = {
|
|
3
|
+
unit_price: number;
|
|
4
|
+
quantity: number;
|
|
5
|
+
subtotal: number;
|
|
6
|
+
tax_total: number;
|
|
7
|
+
total: number;
|
|
8
|
+
original_total: number;
|
|
9
|
+
original_tax_total: number;
|
|
10
|
+
tax_lines: any;
|
|
11
|
+
discount_total: number;
|
|
12
|
+
raw_discount_total: number;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Associates a line item and discount allocation.
|
|
16
|
+
*/
|
|
17
|
+
export declare type LineDiscount = {
|
|
18
|
+
lineItem: any;
|
|
19
|
+
variant: string;
|
|
20
|
+
amount: number;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Associates a line item and discount allocation.
|
|
24
|
+
*/
|
|
25
|
+
export declare type LineDiscountAmount = {
|
|
26
|
+
item: any;
|
|
27
|
+
amount: number;
|
|
28
|
+
customAdjustmentsAmount: number;
|
|
29
|
+
};
|
|
30
|
+
declare type AllocationMapOptions = {
|
|
31
|
+
exclude_gift_cards?: boolean;
|
|
32
|
+
exclude_discounts?: boolean;
|
|
33
|
+
};
|
|
34
|
+
declare type GetLineItemTotalsContext = {
|
|
35
|
+
includeTax?: boolean;
|
|
36
|
+
calculationContext: TaxTypes.TaxCalculationContext;
|
|
37
|
+
lineItemsTaxLinesMap: {
|
|
38
|
+
[lineItemId: string]: any;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
declare type GetShippingMethodTotalsContext = {
|
|
42
|
+
includeTax?: boolean;
|
|
43
|
+
calculationContext: TaxTypes.TaxCalculationContext;
|
|
44
|
+
discounts?: any;
|
|
45
|
+
shippingMethodsTaxLinesMap: {
|
|
46
|
+
[shippingMethodId: string]: any;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
declare type GiftCardTransaction = {
|
|
50
|
+
tax_rate: number | null;
|
|
51
|
+
is_taxable: boolean | null;
|
|
52
|
+
amount: number;
|
|
53
|
+
gift_card: any;
|
|
54
|
+
};
|
|
55
|
+
declare type ShippingMethodTotals = {
|
|
56
|
+
price: number;
|
|
57
|
+
tax_total: number;
|
|
58
|
+
total: number;
|
|
59
|
+
subtotal: number;
|
|
60
|
+
original_total: number;
|
|
61
|
+
original_tax_total: number;
|
|
62
|
+
tax_lines: any;
|
|
63
|
+
};
|
|
64
|
+
export class TotalsService {
|
|
65
|
+
/**
|
|
66
|
+
* Calculate and return the items totals for either the legacy calculation or the new calculation
|
|
67
|
+
* @param items
|
|
68
|
+
* @param includeTax
|
|
69
|
+
* @param calculationContext
|
|
70
|
+
* @param taxRate
|
|
71
|
+
*/
|
|
72
|
+
static getLineItemTotals(items: any[], { includeTax, calculationContext, lineItemsTaxLinesMap, }: GetLineItemTotalsContext): Promise<{
|
|
73
|
+
[lineItemId: string]: LineItemTotals;
|
|
74
|
+
}>;
|
|
75
|
+
/**
|
|
76
|
+
* Calculate and return the totals for an item
|
|
77
|
+
* @param item
|
|
78
|
+
* @param includeTax
|
|
79
|
+
* @param lineItemAllocation
|
|
80
|
+
* @param taxLines Only needed to force the usage of the specified tax lines, often in the case where the item does not hold the tax lines
|
|
81
|
+
* @param calculationContext
|
|
82
|
+
*/
|
|
83
|
+
protected static getLineItemTotals_(item: any, // LineItem,
|
|
84
|
+
{ includeTax, lineItemAllocation, taxLines, calculationContext, }: {
|
|
85
|
+
includeTax?: boolean;
|
|
86
|
+
lineItemAllocation: LineAllocationsMap[number];
|
|
87
|
+
taxLines?: any;
|
|
88
|
+
calculationContext: TaxTypes.TaxCalculationContext;
|
|
89
|
+
}): Promise<LineItemTotals>;
|
|
90
|
+
/**
|
|
91
|
+
* Return the amount that can be refund on a line item
|
|
92
|
+
* @param lineItem
|
|
93
|
+
* @param calculationContext
|
|
94
|
+
* @param taxRate
|
|
95
|
+
*/
|
|
96
|
+
static getLineItemRefund(lineItem: {
|
|
97
|
+
id: string;
|
|
98
|
+
unit_price: number;
|
|
99
|
+
includes_tax: boolean;
|
|
100
|
+
quantity: number;
|
|
101
|
+
tax_lines: any;
|
|
102
|
+
}, { calculationContext, taxRate, }: {
|
|
103
|
+
calculationContext: TaxTypes.TaxCalculationContext;
|
|
104
|
+
taxRate?: number | null;
|
|
105
|
+
}): number;
|
|
106
|
+
/**
|
|
107
|
+
* Calculate and return the gift cards totals
|
|
108
|
+
* @param giftCardableAmount
|
|
109
|
+
* @param giftCardTransactions
|
|
110
|
+
* @param region
|
|
111
|
+
* @param giftCards
|
|
112
|
+
*/
|
|
113
|
+
static getGiftCardTotals(giftCardableAmount: number, { giftCardTransactions, region, giftCards, }: {
|
|
114
|
+
region: any;
|
|
115
|
+
giftCardTransactions?: GiftCardTransaction[];
|
|
116
|
+
giftCards?: any;
|
|
117
|
+
}): Promise<{
|
|
118
|
+
total: number;
|
|
119
|
+
tax_total: number;
|
|
120
|
+
}>;
|
|
121
|
+
/**
|
|
122
|
+
* Calculate and return the gift cards totals based on their transactions
|
|
123
|
+
* @param gift_card_transactions
|
|
124
|
+
* @param region
|
|
125
|
+
*/
|
|
126
|
+
static getGiftCardTransactionsTotals({ giftCardTransactions, region, }: {
|
|
127
|
+
giftCardTransactions: GiftCardTransaction[];
|
|
128
|
+
region: {
|
|
129
|
+
gift_cards_taxable: boolean;
|
|
130
|
+
tax_rate: number;
|
|
131
|
+
};
|
|
132
|
+
}): {
|
|
133
|
+
total: number;
|
|
134
|
+
tax_total: number;
|
|
135
|
+
};
|
|
136
|
+
/**
|
|
137
|
+
* Calculate and return the shipping methods totals for either the legacy calculation or the new calculation
|
|
138
|
+
* @param shippingMethods
|
|
139
|
+
* @param includeTax
|
|
140
|
+
* @param discounts
|
|
141
|
+
* @param taxRate
|
|
142
|
+
* @param calculationContext
|
|
143
|
+
*/
|
|
144
|
+
static getShippingMethodTotals(shippingMethods: any, // ShippingMethod | ShippingMethod[],
|
|
145
|
+
{ includeTax, discounts, calculationContext, shippingMethodsTaxLinesMap, }: GetShippingMethodTotalsContext): Promise<{
|
|
146
|
+
[shippingMethodId: string]: ShippingMethodTotals;
|
|
147
|
+
}>;
|
|
148
|
+
/**
|
|
149
|
+
* Calculate and return the shipping method totals
|
|
150
|
+
* @param shippingMethod
|
|
151
|
+
* @param includeTax
|
|
152
|
+
* @param calculationContext
|
|
153
|
+
* @param taxLines
|
|
154
|
+
* @param discounts
|
|
155
|
+
*/
|
|
156
|
+
protected static getShippingMethodTotals_(shippingMethod: any, // ShippingMethod,
|
|
157
|
+
{ includeTax, calculationContext, taxLines, discounts, }: {
|
|
158
|
+
includeTax?: boolean;
|
|
159
|
+
calculationContext: TaxTypes.TaxCalculationContext;
|
|
160
|
+
taxLines?: any;
|
|
161
|
+
discounts?: any;
|
|
162
|
+
}): Promise<ShippingMethodTotals>;
|
|
163
|
+
/**
|
|
164
|
+
* Returns the discount amount allocated to the line items of an order.
|
|
165
|
+
* @param cartOrOrder - the cart or order to get line discount allocations for
|
|
166
|
+
* @param discount - the discount to use as context for the calculation
|
|
167
|
+
* @return the allocations that the discount has on the items in the cart or
|
|
168
|
+
* order
|
|
169
|
+
*/
|
|
170
|
+
static getLineDiscounts(cartOrOrder: {
|
|
171
|
+
items: any;
|
|
172
|
+
swaps?: any;
|
|
173
|
+
claims?: any;
|
|
174
|
+
}, discount?: any): LineDiscountAmount[];
|
|
175
|
+
/**
|
|
176
|
+
* Gets a map of discounts and gift cards that apply to line items in an
|
|
177
|
+
* order. The function calculates the amount of a discount or gift card that
|
|
178
|
+
* applies to a specific line item.
|
|
179
|
+
* @param orderOrCart - the order or cart to get an allocation map for
|
|
180
|
+
* @param options - controls what should be included in allocation map
|
|
181
|
+
* @return the allocation map for the line items in the cart or order.
|
|
182
|
+
*/
|
|
183
|
+
static getAllocationMap(orderOrCart: {
|
|
184
|
+
discounts?: any;
|
|
185
|
+
items: any;
|
|
186
|
+
swaps?: any;
|
|
187
|
+
claims?: any;
|
|
188
|
+
}, options?: AllocationMapOptions): Promise<LineAllocationsMap>;
|
|
189
|
+
}
|
|
190
|
+
export { };
|
|
191
|
+
|
|
@@ -0,0 +1,508 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (_) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
50
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
51
|
+
if (ar || !(i in from)) {
|
|
52
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
53
|
+
ar[i] = from[i];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
57
|
+
};
|
|
58
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
59
|
+
var medusa_core_utils_1 = require("medusa-core-utils");
|
|
60
|
+
var tax_1 = require("../tax");
|
|
61
|
+
var TotalsService = /** @class */ (function () {
|
|
62
|
+
function TotalsService() {
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Calculate and return the items totals for either the legacy calculation or the new calculation
|
|
66
|
+
* @param items
|
|
67
|
+
* @param includeTax
|
|
68
|
+
* @param calculationContext
|
|
69
|
+
* @param taxRate
|
|
70
|
+
*/
|
|
71
|
+
TotalsService.getLineItemTotals = function (
|
|
72
|
+
// items: LineItem | LineItem[],
|
|
73
|
+
items, _a) {
|
|
74
|
+
var includeTax = _a.includeTax, calculationContext = _a.calculationContext, lineItemsTaxLinesMap = _a.lineItemsTaxLinesMap;
|
|
75
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
76
|
+
var itemsTotals, _i, items_1, item, lineItemAllocation, _b, _c;
|
|
77
|
+
return __generator(this, function (_d) {
|
|
78
|
+
switch (_d.label) {
|
|
79
|
+
case 0:
|
|
80
|
+
items = Array.isArray(items) ? items : [items];
|
|
81
|
+
itemsTotals = {};
|
|
82
|
+
_i = 0, items_1 = items;
|
|
83
|
+
_d.label = 1;
|
|
84
|
+
case 1:
|
|
85
|
+
if (!(_i < items_1.length)) return [3 /*break*/, 4];
|
|
86
|
+
item = items_1[_i];
|
|
87
|
+
lineItemAllocation = calculationContext.allocation_map[item.id] || {};
|
|
88
|
+
_b = itemsTotals;
|
|
89
|
+
_c = item.id;
|
|
90
|
+
return [4 /*yield*/, this.getLineItemTotals_(item, {
|
|
91
|
+
includeTax: includeTax,
|
|
92
|
+
lineItemAllocation: lineItemAllocation,
|
|
93
|
+
taxLines: lineItemsTaxLinesMap[item.id],
|
|
94
|
+
calculationContext: calculationContext,
|
|
95
|
+
})];
|
|
96
|
+
case 2:
|
|
97
|
+
_b[_c] = _d.sent();
|
|
98
|
+
_d.label = 3;
|
|
99
|
+
case 3:
|
|
100
|
+
_i++;
|
|
101
|
+
return [3 /*break*/, 1];
|
|
102
|
+
case 4: return [2 /*return*/, itemsTotals];
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* Calculate and return the totals for an item
|
|
109
|
+
* @param item
|
|
110
|
+
* @param includeTax
|
|
111
|
+
* @param lineItemAllocation
|
|
112
|
+
* @param taxLines Only needed to force the usage of the specified tax lines, often in the case where the item does not hold the tax lines
|
|
113
|
+
* @param calculationContext
|
|
114
|
+
*/
|
|
115
|
+
TotalsService.getLineItemTotals_ = function (item, // LineItem,
|
|
116
|
+
_a) {
|
|
117
|
+
var _b, _c, _d, _e, _f, _g;
|
|
118
|
+
var includeTax = _a.includeTax, lineItemAllocation = _a.lineItemAllocation, taxLines = _a.taxLines, calculationContext = _a.calculationContext;
|
|
119
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
120
|
+
var subtotal, raw_discount_total, discount_total, totals, taxCalculationStrategy, _h, noDiscountContext, _j;
|
|
121
|
+
return __generator(this, function (_k) {
|
|
122
|
+
switch (_k.label) {
|
|
123
|
+
case 0:
|
|
124
|
+
subtotal = item.unit_price * item.quantity;
|
|
125
|
+
if (item.includes_tax) {
|
|
126
|
+
subtotal = 0; // in that case we need to know the tax rate to compute it later
|
|
127
|
+
}
|
|
128
|
+
raw_discount_total = (_c = (_b = lineItemAllocation.discount) === null || _b === void 0 ? void 0 : _b.amount) !== null && _c !== void 0 ? _c : 0;
|
|
129
|
+
discount_total = Math.round(raw_discount_total);
|
|
130
|
+
totals = {
|
|
131
|
+
unit_price: item.unit_price,
|
|
132
|
+
quantity: item.quantity,
|
|
133
|
+
subtotal: subtotal,
|
|
134
|
+
discount_total: discount_total,
|
|
135
|
+
total: subtotal - discount_total,
|
|
136
|
+
original_total: subtotal,
|
|
137
|
+
original_tax_total: 0,
|
|
138
|
+
tax_total: 0,
|
|
139
|
+
tax_lines: (_d = item.tax_lines) !== null && _d !== void 0 ? _d : [],
|
|
140
|
+
raw_discount_total: raw_discount_total,
|
|
141
|
+
};
|
|
142
|
+
if (includeTax) {
|
|
143
|
+
totals.tax_lines = totals.tax_lines.length
|
|
144
|
+
? totals.tax_lines
|
|
145
|
+
// : (taxLines as LineItemTaxLine[])
|
|
146
|
+
: taxLines;
|
|
147
|
+
if (!totals.tax_lines && item.variant_id) {
|
|
148
|
+
throw new medusa_core_utils_1.MedusaError(medusa_core_utils_1.MedusaError.Types.UNEXPECTED_STATE, "Tax Lines must be joined to calculate taxes");
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
if (item.is_return) {
|
|
152
|
+
if (!(0, medusa_core_utils_1.isDefined)(item.tax_lines) && item.variant_id) {
|
|
153
|
+
throw new medusa_core_utils_1.MedusaError(medusa_core_utils_1.MedusaError.Types.UNEXPECTED_STATE, "Return Line Items must join tax lines");
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
if (!(((_e = totals.tax_lines) === null || _e === void 0 ? void 0 : _e.length) > 0)) return [3 /*break*/, 3];
|
|
157
|
+
taxCalculationStrategy = calculationContext === null || calculationContext === void 0 ? void 0 : calculationContext.tax_calculation_strategy;
|
|
158
|
+
_h = totals;
|
|
159
|
+
return [4 /*yield*/, taxCalculationStrategy.calculate([item], totals.tax_lines, calculationContext)];
|
|
160
|
+
case 1:
|
|
161
|
+
_h.tax_total =
|
|
162
|
+
(_f = (_k.sent())) !== null && _f !== void 0 ? _f : 0;
|
|
163
|
+
noDiscountContext = __assign(__assign({}, calculationContext), { allocation_map: {} });
|
|
164
|
+
_j = totals;
|
|
165
|
+
return [4 /*yield*/, taxCalculationStrategy.calculate([item], totals.tax_lines, noDiscountContext)];
|
|
166
|
+
case 2:
|
|
167
|
+
_j.original_tax_total =
|
|
168
|
+
(_g = (_k.sent())) !== null && _g !== void 0 ? _g : 0;
|
|
169
|
+
if (item.includes_tax) {
|
|
170
|
+
totals.subtotal +=
|
|
171
|
+
totals.unit_price * totals.quantity - totals.original_tax_total;
|
|
172
|
+
totals.total += totals.subtotal;
|
|
173
|
+
totals.original_total += totals.subtotal;
|
|
174
|
+
}
|
|
175
|
+
totals.total += totals.tax_total;
|
|
176
|
+
totals.original_total += totals.original_tax_total;
|
|
177
|
+
_k.label = 3;
|
|
178
|
+
case 3: return [2 /*return*/, totals];
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
};
|
|
183
|
+
/**
|
|
184
|
+
* Return the amount that can be refund on a line item
|
|
185
|
+
* @param lineItem
|
|
186
|
+
* @param calculationContext
|
|
187
|
+
* @param taxRate
|
|
188
|
+
*/
|
|
189
|
+
TotalsService.getLineItemRefund = function (lineItem, _a) {
|
|
190
|
+
var _b, _c;
|
|
191
|
+
var calculationContext = _a.calculationContext, taxRate = _a.taxRate;
|
|
192
|
+
var includesTax = lineItem.includes_tax;
|
|
193
|
+
var discountAmount = (((_c = (_b = calculationContext.allocation_map[lineItem.id]) === null || _b === void 0 ? void 0 : _b.discount) === null || _c === void 0 ? void 0 : _c.unit_amount) ||
|
|
194
|
+
0) * lineItem.quantity;
|
|
195
|
+
if (!(0, medusa_core_utils_1.isDefined)(lineItem.tax_lines)) {
|
|
196
|
+
throw new medusa_core_utils_1.MedusaError(medusa_core_utils_1.MedusaError.Types.UNEXPECTED_STATE, "Cannot compute line item refund amount, tax lines are missing from the line item");
|
|
197
|
+
}
|
|
198
|
+
var totalTaxRate = lineItem.tax_lines.reduce(function (acc, next) {
|
|
199
|
+
return acc + next.rate / 100;
|
|
200
|
+
}, 0);
|
|
201
|
+
var taxAmountIncludedInPrice = !includesTax
|
|
202
|
+
? 0
|
|
203
|
+
: Math.round((0, tax_1.calculatePriceTaxAmount)({
|
|
204
|
+
price: lineItem.unit_price,
|
|
205
|
+
taxRate: totalTaxRate,
|
|
206
|
+
includesTax: includesTax,
|
|
207
|
+
}));
|
|
208
|
+
var lineSubtotal = (lineItem.unit_price - taxAmountIncludedInPrice) * lineItem.quantity -
|
|
209
|
+
discountAmount;
|
|
210
|
+
var taxTotal = lineItem.tax_lines.reduce(function (acc, next) {
|
|
211
|
+
return acc + Math.round(lineSubtotal * (next.rate / 100));
|
|
212
|
+
}, 0);
|
|
213
|
+
return lineSubtotal + taxTotal;
|
|
214
|
+
};
|
|
215
|
+
/**
|
|
216
|
+
* Calculate and return the gift cards totals
|
|
217
|
+
* @param giftCardableAmount
|
|
218
|
+
* @param giftCardTransactions
|
|
219
|
+
* @param region
|
|
220
|
+
* @param giftCards
|
|
221
|
+
*/
|
|
222
|
+
TotalsService.getGiftCardTotals = function (giftCardableAmount, _a) {
|
|
223
|
+
var giftCardTransactions = _a.giftCardTransactions, region = _a.region, giftCards = _a.giftCards;
|
|
224
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
225
|
+
var result, _b, totalGiftCardBalance, totalTaxFromGiftCards;
|
|
226
|
+
return __generator(this, function (_c) {
|
|
227
|
+
if (!giftCards && !giftCardTransactions) {
|
|
228
|
+
throw new medusa_core_utils_1.MedusaError(medusa_core_utils_1.MedusaError.Types.UNEXPECTED_STATE, "Cannot calculate the gift cart totals. Neither the gift cards or gift card transactions have been provided");
|
|
229
|
+
}
|
|
230
|
+
if (giftCardTransactions === null || giftCardTransactions === void 0 ? void 0 : giftCardTransactions.length) {
|
|
231
|
+
return [2 /*return*/, this.getGiftCardTransactionsTotals({
|
|
232
|
+
giftCardTransactions: giftCardTransactions,
|
|
233
|
+
region: region,
|
|
234
|
+
})];
|
|
235
|
+
}
|
|
236
|
+
result = {
|
|
237
|
+
total: 0,
|
|
238
|
+
tax_total: 0,
|
|
239
|
+
};
|
|
240
|
+
if (!(giftCards === null || giftCards === void 0 ? void 0 : giftCards.length)) {
|
|
241
|
+
return [2 /*return*/, result];
|
|
242
|
+
}
|
|
243
|
+
_b = giftCards.reduce(function (acc, giftCard) {
|
|
244
|
+
var taxableAmount = 0;
|
|
245
|
+
acc.totalGiftCardBalance += giftCard.balance;
|
|
246
|
+
taxableAmount = Math.min(acc.giftCardableBalance, giftCard.balance);
|
|
247
|
+
// skip tax, if the taxable amount is not a positive number or tax rate is not set
|
|
248
|
+
if (taxableAmount <= 0 || !giftCard.tax_rate) {
|
|
249
|
+
return acc;
|
|
250
|
+
}
|
|
251
|
+
var taxAmountFromGiftCard = Math.round(taxableAmount * (giftCard.tax_rate / 100));
|
|
252
|
+
acc.totalTaxFromGiftCards += taxAmountFromGiftCard;
|
|
253
|
+
// Update the balance, pass it over to the next gift card (if any) for calculating tax on balance.
|
|
254
|
+
acc.giftCardableBalance -= taxableAmount;
|
|
255
|
+
return acc;
|
|
256
|
+
}, {
|
|
257
|
+
totalGiftCardBalance: 0,
|
|
258
|
+
totalTaxFromGiftCards: 0,
|
|
259
|
+
giftCardableBalance: giftCardableAmount,
|
|
260
|
+
}), totalGiftCardBalance = _b.totalGiftCardBalance, totalTaxFromGiftCards = _b.totalTaxFromGiftCards;
|
|
261
|
+
result.tax_total = Math.round(totalTaxFromGiftCards);
|
|
262
|
+
result.total = Math.min(giftCardableAmount, totalGiftCardBalance);
|
|
263
|
+
return [2 /*return*/, result];
|
|
264
|
+
});
|
|
265
|
+
});
|
|
266
|
+
};
|
|
267
|
+
/**
|
|
268
|
+
* Calculate and return the gift cards totals based on their transactions
|
|
269
|
+
* @param gift_card_transactions
|
|
270
|
+
* @param region
|
|
271
|
+
*/
|
|
272
|
+
TotalsService.getGiftCardTransactionsTotals = function (_a) {
|
|
273
|
+
var giftCardTransactions = _a.giftCardTransactions, region = _a.region;
|
|
274
|
+
return giftCardTransactions.reduce(function (acc, next) {
|
|
275
|
+
var _a, _b, _c;
|
|
276
|
+
var taxMultiplier = (next.tax_rate || 0) / 100;
|
|
277
|
+
// Previously we did not record whether a gift card was taxable or not.
|
|
278
|
+
// All gift cards where is_taxable === null are from the old system,
|
|
279
|
+
// where we defaulted to taxable gift cards.
|
|
280
|
+
//
|
|
281
|
+
// This is a backwards compatability fix for orders that were created
|
|
282
|
+
// before we added the gift card tax rate.
|
|
283
|
+
// We prioritize the giftCard.tax_rate as we create a snapshot of the tax
|
|
284
|
+
// on order creation to create gift cards on the gift card itself.
|
|
285
|
+
// If its created outside of the order, we refer to the region tax
|
|
286
|
+
if (next.is_taxable === null) {
|
|
287
|
+
if ((region === null || region === void 0 ? void 0 : region.gift_cards_taxable) || ((_a = next.gift_card) === null || _a === void 0 ? void 0 : _a.tax_rate)) {
|
|
288
|
+
taxMultiplier = ((_c = (_b = next.gift_card) === null || _b === void 0 ? void 0 : _b.tax_rate) !== null && _c !== void 0 ? _c : region.tax_rate) / 100;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
return {
|
|
292
|
+
total: acc.total + next.amount,
|
|
293
|
+
tax_total: Math.round(acc.tax_total + next.amount * taxMultiplier),
|
|
294
|
+
};
|
|
295
|
+
}, {
|
|
296
|
+
total: 0,
|
|
297
|
+
tax_total: 0,
|
|
298
|
+
});
|
|
299
|
+
};
|
|
300
|
+
/**
|
|
301
|
+
* Calculate and return the shipping methods totals for either the legacy calculation or the new calculation
|
|
302
|
+
* @param shippingMethods
|
|
303
|
+
* @param includeTax
|
|
304
|
+
* @param discounts
|
|
305
|
+
* @param taxRate
|
|
306
|
+
* @param calculationContext
|
|
307
|
+
*/
|
|
308
|
+
TotalsService.getShippingMethodTotals = function (shippingMethods, // ShippingMethod | ShippingMethod[],
|
|
309
|
+
_a) {
|
|
310
|
+
var includeTax = _a.includeTax, discounts = _a.discounts, calculationContext = _a.calculationContext, shippingMethodsTaxLinesMap = _a.shippingMethodsTaxLinesMap;
|
|
311
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
312
|
+
var shippingMethodsTotals, _i, shippingMethods_1, shippingMethod, _b, _c;
|
|
313
|
+
return __generator(this, function (_d) {
|
|
314
|
+
switch (_d.label) {
|
|
315
|
+
case 0:
|
|
316
|
+
shippingMethods = Array.isArray(shippingMethods)
|
|
317
|
+
? shippingMethods
|
|
318
|
+
: [shippingMethods];
|
|
319
|
+
shippingMethodsTotals = {};
|
|
320
|
+
_i = 0, shippingMethods_1 = shippingMethods;
|
|
321
|
+
_d.label = 1;
|
|
322
|
+
case 1:
|
|
323
|
+
if (!(_i < shippingMethods_1.length)) return [3 /*break*/, 4];
|
|
324
|
+
shippingMethod = shippingMethods_1[_i];
|
|
325
|
+
_b = shippingMethodsTotals;
|
|
326
|
+
_c = shippingMethod.id;
|
|
327
|
+
return [4 /*yield*/, this.getShippingMethodTotals_(shippingMethod, {
|
|
328
|
+
includeTax: includeTax,
|
|
329
|
+
calculationContext: calculationContext,
|
|
330
|
+
taxLines: shippingMethodsTaxLinesMap[shippingMethod.id],
|
|
331
|
+
discounts: discounts,
|
|
332
|
+
})];
|
|
333
|
+
case 2:
|
|
334
|
+
_b[_c] =
|
|
335
|
+
_d.sent();
|
|
336
|
+
_d.label = 3;
|
|
337
|
+
case 3:
|
|
338
|
+
_i++;
|
|
339
|
+
return [3 /*break*/, 1];
|
|
340
|
+
case 4: return [2 /*return*/, shippingMethodsTotals];
|
|
341
|
+
}
|
|
342
|
+
});
|
|
343
|
+
});
|
|
344
|
+
};
|
|
345
|
+
/**
|
|
346
|
+
* Calculate and return the shipping method totals
|
|
347
|
+
* @param shippingMethod
|
|
348
|
+
* @param includeTax
|
|
349
|
+
* @param calculationContext
|
|
350
|
+
* @param taxLines
|
|
351
|
+
* @param discounts
|
|
352
|
+
*/
|
|
353
|
+
TotalsService.getShippingMethodTotals_ = function (shippingMethod, // ShippingMethod,
|
|
354
|
+
_a) {
|
|
355
|
+
var _b, _c;
|
|
356
|
+
var includeTax = _a.includeTax, calculationContext = _a.calculationContext, taxLines = _a.taxLines, discounts = _a.discounts;
|
|
357
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
358
|
+
var totals, calculationContext_, includesTax, taxCalculationStrategy, _d, hasFreeShipping;
|
|
359
|
+
return __generator(this, function (_e) {
|
|
360
|
+
switch (_e.label) {
|
|
361
|
+
case 0:
|
|
362
|
+
totals = {
|
|
363
|
+
price: shippingMethod.price,
|
|
364
|
+
original_total: shippingMethod.price,
|
|
365
|
+
total: shippingMethod.price,
|
|
366
|
+
subtotal: shippingMethod.price,
|
|
367
|
+
original_tax_total: 0,
|
|
368
|
+
tax_total: 0,
|
|
369
|
+
tax_lines: (_b = shippingMethod.tax_lines) !== null && _b !== void 0 ? _b : [],
|
|
370
|
+
};
|
|
371
|
+
if (includeTax) {
|
|
372
|
+
totals.tax_lines = totals.tax_lines.length
|
|
373
|
+
? totals.tax_lines
|
|
374
|
+
// : (taxLines as ShippingMethodTaxLine[])
|
|
375
|
+
: taxLines;
|
|
376
|
+
if (!totals.tax_lines) {
|
|
377
|
+
throw new medusa_core_utils_1.MedusaError(medusa_core_utils_1.MedusaError.Types.UNEXPECTED_STATE, "Tax Lines must be joined to calculate taxes");
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
calculationContext_ = __assign(__assign({}, calculationContext), { shipping_methods: [shippingMethod] });
|
|
381
|
+
if (!totals.tax_lines.length) return [3 /*break*/, 2];
|
|
382
|
+
includesTax = shippingMethod.includes_tax;
|
|
383
|
+
taxCalculationStrategy = calculationContext === null || calculationContext === void 0 ? void 0 : calculationContext.tax_calculation_strategy;
|
|
384
|
+
_d = totals;
|
|
385
|
+
return [4 /*yield*/, taxCalculationStrategy.calculate([], totals.tax_lines, calculationContext_)];
|
|
386
|
+
case 1:
|
|
387
|
+
_d.original_tax_total =
|
|
388
|
+
(_c = (_e.sent())) !== null && _c !== void 0 ? _c : 0;
|
|
389
|
+
totals.tax_total = totals.original_tax_total;
|
|
390
|
+
if (includesTax) {
|
|
391
|
+
totals.subtotal -= totals.tax_total;
|
|
392
|
+
}
|
|
393
|
+
else {
|
|
394
|
+
totals.original_total += totals.original_tax_total;
|
|
395
|
+
totals.total += totals.tax_total;
|
|
396
|
+
}
|
|
397
|
+
_e.label = 2;
|
|
398
|
+
case 2:
|
|
399
|
+
hasFreeShipping = discounts === null || discounts === void 0 ? void 0 : discounts.some(
|
|
400
|
+
// (d) => d.rule.type === DiscountRuleType.FREE_SHIPPING
|
|
401
|
+
function (d) { return d.rule.type === "free_shipping"; });
|
|
402
|
+
if (hasFreeShipping) {
|
|
403
|
+
totals.total = 0;
|
|
404
|
+
totals.subtotal = 0;
|
|
405
|
+
totals.tax_total = 0;
|
|
406
|
+
}
|
|
407
|
+
return [2 /*return*/, totals];
|
|
408
|
+
}
|
|
409
|
+
});
|
|
410
|
+
});
|
|
411
|
+
};
|
|
412
|
+
/**
|
|
413
|
+
* Returns the discount amount allocated to the line items of an order.
|
|
414
|
+
* @param cartOrOrder - the cart or order to get line discount allocations for
|
|
415
|
+
* @param discount - the discount to use as context for the calculation
|
|
416
|
+
* @return the allocations that the discount has on the items in the cart or
|
|
417
|
+
* order
|
|
418
|
+
*/
|
|
419
|
+
TotalsService.getLineDiscounts = function (cartOrOrder, discount // Discount
|
|
420
|
+
) {
|
|
421
|
+
var _a, _b, _c;
|
|
422
|
+
// let merged: LineItem[] = [...(cartOrOrder.items ?? [])]
|
|
423
|
+
var merged = __spreadArray([], ((_a = cartOrOrder.items) !== null && _a !== void 0 ? _a : []), true);
|
|
424
|
+
// merge items from order with items from order swaps
|
|
425
|
+
if ("swaps" in cartOrOrder && ((_b = cartOrOrder.swaps) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
426
|
+
for (var _i = 0, _d = cartOrOrder.swaps; _i < _d.length; _i++) {
|
|
427
|
+
var s = _d[_i];
|
|
428
|
+
merged = __spreadArray(__spreadArray([], merged, true), s.additional_items, true);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
if ("claims" in cartOrOrder && ((_c = cartOrOrder.claims) === null || _c === void 0 ? void 0 : _c.length)) {
|
|
432
|
+
for (var _e = 0, _f = cartOrOrder.claims; _e < _f.length; _e++) {
|
|
433
|
+
var c = _f[_e];
|
|
434
|
+
merged = __spreadArray(__spreadArray([], merged, true), c.additional_items, true);
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
return merged.map(function (item) {
|
|
438
|
+
var adjustments = (item === null || item === void 0 ? void 0 : item.adjustments) || [];
|
|
439
|
+
var discountAdjustments = discount
|
|
440
|
+
? adjustments.filter(function (adjustment) { return adjustment.discount_id === discount.id; })
|
|
441
|
+
: [];
|
|
442
|
+
var customAdjustments = adjustments.filter(function (adjustment) { return adjustment.discount_id === null; });
|
|
443
|
+
var sumAdjustments = function (total, adjustment) { return total + adjustment.amount; };
|
|
444
|
+
return {
|
|
445
|
+
item: item,
|
|
446
|
+
amount: item.allow_discounts
|
|
447
|
+
? discountAdjustments.reduce(sumAdjustments, 0)
|
|
448
|
+
: 0,
|
|
449
|
+
customAdjustmentsAmount: customAdjustments.reduce(sumAdjustments, 0),
|
|
450
|
+
};
|
|
451
|
+
});
|
|
452
|
+
};
|
|
453
|
+
/**
|
|
454
|
+
* Gets a map of discounts and gift cards that apply to line items in an
|
|
455
|
+
* order. The function calculates the amount of a discount or gift card that
|
|
456
|
+
* applies to a specific line item.
|
|
457
|
+
* @param orderOrCart - the order or cart to get an allocation map for
|
|
458
|
+
* @param options - controls what should be included in allocation map
|
|
459
|
+
* @return the allocation map for the line items in the cart or order.
|
|
460
|
+
*/
|
|
461
|
+
TotalsService.getAllocationMap = function (orderOrCart, options) {
|
|
462
|
+
var _a;
|
|
463
|
+
if (options === void 0) { options = {}; }
|
|
464
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
465
|
+
var allocationMap, discount, lineDiscounts, _i, lineDiscounts_1, ld, adjustmentAmount;
|
|
466
|
+
return __generator(this, function (_b) {
|
|
467
|
+
allocationMap = {};
|
|
468
|
+
if (!options.exclude_discounts) {
|
|
469
|
+
discount = (_a = orderOrCart.discounts) === null || _a === void 0 ? void 0 : _a.find(
|
|
470
|
+
// ({ rule }) => rule.type !== DiscountRuleType.FREE_SHIPPING
|
|
471
|
+
function (_a) {
|
|
472
|
+
var rule = _a.rule;
|
|
473
|
+
return rule.type !== "free_shipping";
|
|
474
|
+
});
|
|
475
|
+
lineDiscounts = this.getLineDiscounts(orderOrCart, discount);
|
|
476
|
+
for (_i = 0, lineDiscounts_1 = lineDiscounts; _i < lineDiscounts_1.length; _i++) {
|
|
477
|
+
ld = lineDiscounts_1[_i];
|
|
478
|
+
adjustmentAmount = ld.amount + ld.customAdjustmentsAmount;
|
|
479
|
+
if (allocationMap[ld.item.id]) {
|
|
480
|
+
allocationMap[ld.item.id].discount = {
|
|
481
|
+
amount: adjustmentAmount,
|
|
482
|
+
/**
|
|
483
|
+
* Used for the refund computation
|
|
484
|
+
*/
|
|
485
|
+
unit_amount: adjustmentAmount / ld.item.quantity,
|
|
486
|
+
};
|
|
487
|
+
}
|
|
488
|
+
else {
|
|
489
|
+
allocationMap[ld.item.id] = {
|
|
490
|
+
discount: {
|
|
491
|
+
amount: adjustmentAmount,
|
|
492
|
+
/**
|
|
493
|
+
* Used for the refund computation
|
|
494
|
+
*/
|
|
495
|
+
unit_amount: Math.round(adjustmentAmount / ld.item.quantity),
|
|
496
|
+
},
|
|
497
|
+
};
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
return [2 /*return*/, allocationMap];
|
|
502
|
+
});
|
|
503
|
+
});
|
|
504
|
+
};
|
|
505
|
+
return TotalsService;
|
|
506
|
+
}());
|
|
507
|
+
exports.default = TotalsService;
|
|
508
|
+
//# sourceMappingURL=totals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"totals.js","sourceRoot":"","sources":["../../src/totals/totals.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA,uDAA0D;AAC1D,8BAAgD;AAyEhD;IAAA;IA6lBA,CAAC;IA5lBC;;;;;;OAMG;IACU,+BAAiB,GAA9B;IACE,gCAAgC;IAChC,KAAY,EACZ,EAI2B;YAHzB,UAAU,gBAAA,EACV,kBAAkB,wBAAA,EAClB,oBAAoB,0BAAA;;;;;;wBAGtB,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA;wBAoBxC,WAAW,GAA6C,EAAE,CAAA;8BAExC,EAAL,eAAK;;;6BAAL,CAAA,mBAAK,CAAA;wBAAb,IAAI;wBACP,kBAAkB,GACtB,kBAAkB,CAAC,cAAc,CAAC,IAAI,CAA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135047",
|
|
4
4
|
"description": "Medusa utilities functions shared by Medusa core and Modules",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"author": "Medusa",
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@medusajs/types": "1.8.
|
|
20
|
+
"@medusajs/types": "1.8.4-canary-20230512135047",
|
|
21
21
|
"@types/express": "^4.17.17",
|
|
22
22
|
"cross-env": "^5.2.1",
|
|
23
23
|
"jest": "^25.5.4",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"awilix": "^8.0.0",
|
|
29
29
|
"class-transformer": "^0.5.1",
|
|
30
30
|
"class-validator": "^0.13.2",
|
|
31
|
-
"typeorm": "
|
|
31
|
+
"typeorm": "npm:@medusajs/typeorm@0.3.16-next.0",
|
|
32
32
|
"ulid": "^2.3.0"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|