61 lines
1.5 KiB
TypeScript
61 lines
1.5 KiB
TypeScript
// Metro module 3845 (f3846).
|
|
import Module12 from "../../_bundle/Module12";
|
|
export function coalesceInvoiceItems(a0) {
|
|
const r2 = [];
|
|
let c13681_0 = r2;
|
|
let c13681_1 = new Set();
|
|
a0.map((a0) => {
|
|
for (const item of c13681_0) {
|
|
if (item.subscriptionPlanId !== a0.subscriptionPlanId) {
|
|
continue;
|
|
}
|
|
if (item.subscriptionPlanPrice !== a0.subscriptionPlanPrice) {
|
|
continue;
|
|
}
|
|
if (item.amount !== a0.amount) {
|
|
continue;
|
|
}
|
|
if (!Module12.isEqual(item.discounts, a0.discounts)) {
|
|
continue;
|
|
}
|
|
c13681_1.add(item.subscriptionPlanId);
|
|
item.quantity = item.quantity + a0.quantity;
|
|
return void 0;
|
|
}
|
|
c13681_0.push({
|
|
...a0
|
|
});
|
|
});
|
|
return r2.map((item) => {
|
|
const r1 = {
|
|
...item
|
|
};
|
|
let c24738_0 = r1;
|
|
if (c13681_1.has(item.subscriptionPlanId)) {
|
|
r1.amount = r1.amount * r1.quantity;
|
|
r1.discounts = r1.discounts.map((discount) => ({
|
|
...discount,
|
|
amount: discount.amount * c24738_0.quantity
|
|
}));
|
|
if (r1.tax != null) {
|
|
r1.tax = r1.tax * r1.quantity;
|
|
}
|
|
}
|
|
return r1;
|
|
});
|
|
}
|
|
export function createInvoiceItemFromServer(a0) {
|
|
return {
|
|
id: a0.id,
|
|
subscriptionPlanId: a0.subscription_plan_id,
|
|
subscriptionPlanPrice: a0.subscription_plan_price,
|
|
amount: a0.amount,
|
|
quantity: a0.quantity,
|
|
discounts: a0.discounts,
|
|
unitPrice: a0.unit_price,
|
|
tax: a0.tax,
|
|
taxCode: a0.tax_code,
|
|
nominalTaxRate: a0.nominal_tax_rate
|
|
};
|
|
}
|