rerobe-js-orm 4.9.9 → 4.9.10
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/lib/helpers/OrderHelpers.js +20 -6
- package/package.json +1 -1
|
@@ -742,16 +742,30 @@ class OrderHelpers {
|
|
|
742
742
|
fractionDigits: 2,
|
|
743
743
|
}),
|
|
744
744
|
refundLineItems: (order.refunds || []).flatMap((refund) => (refund.refundLineItems || []).map((item) => {
|
|
745
|
-
var _a, _b;
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
745
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
746
|
+
// A stored RefundLineItem is { lineItem, quantityRefund,
|
|
747
|
+
// quantityCancel, subtotalRefund(Presentment), subtotalCanceled(
|
|
748
|
+
// Presentment) } — the title/amount live on `lineItem`, not flat on
|
|
749
|
+
// the item. Returned units = refunded + canceled (a cancellation of
|
|
750
|
+
// unfulfilled units still returns money). The subtotals are net of
|
|
751
|
+
// tax (originalUnitPrice basis), so gross them up for the receipt.
|
|
752
|
+
const lineItem = item.lineItem || {};
|
|
753
|
+
const quantity = Number(item.quantityRefund || 0) + Number(item.quantityCancel || 0);
|
|
754
|
+
const net = Number((_d = (_b = (_a = item.subtotalRefundPresentment) === null || _a === void 0 ? void 0 : _a.amount) !== null && _b !== void 0 ? _b : (_c = item.subtotalRefund) === null || _c === void 0 ? void 0 : _c.amount) !== null && _d !== void 0 ? _d : 0) +
|
|
755
|
+
Number((_h = (_f = (_e = item.subtotalCanceledPresentment) === null || _e === void 0 ? void 0 : _e.amount) !== null && _f !== void 0 ? _f : (_g = item.subtotalCanceled) === null || _g === void 0 ? void 0 : _g.amount) !== null && _h !== void 0 ? _h : 0);
|
|
756
|
+
const taxRate = Number(lineItem.taxRate || 0);
|
|
757
|
+
const gross = lineItem.isTaxable && taxRate ? net * (1 + taxRate) : net;
|
|
758
|
+
return {
|
|
759
|
+
title: (0, MarketplaceLineDisplayHelpers_1.formatMarketplaceLineDisplayTitle)({ lineItem }, { includeSellerPrefix: includeMarketplaceSellerPrefix }) ||
|
|
760
|
+
lineItem.title ||
|
|
761
|
+
'',
|
|
762
|
+
quantity,
|
|
749
763
|
price: (0, Utilities_1.formatPrice)({
|
|
750
764
|
currencyCode,
|
|
751
|
-
amount: -
|
|
765
|
+
amount: -Math.abs(gross),
|
|
752
766
|
fractionDigits: 2,
|
|
753
767
|
}),
|
|
754
|
-
}
|
|
768
|
+
};
|
|
755
769
|
})),
|
|
756
770
|
}));
|
|
757
771
|
}
|