upgrade amount api
This commit is contained in:
parent
50e51429ee
commit
80ab8ccce9
@ -140,7 +140,7 @@ export function CreatePage({
|
|||||||
}: Props): VNode {
|
}: Props): VNode {
|
||||||
const [value, valueHandler] = useState(with_defaults(instanceConfig));
|
const [value, valueHandler] = useState(with_defaults(instanceConfig));
|
||||||
const config = useConfigContext();
|
const config = useConfigContext();
|
||||||
const zero = Amounts.getZero(config.currency);
|
const zero = Amounts.zeroOfCurrency(config.currency);
|
||||||
|
|
||||||
const inventoryList = Object.values(value.inventoryProducts || {});
|
const inventoryList = Object.values(value.inventoryProducts || {});
|
||||||
const productList = Object.values(value.products || {});
|
const productList = Object.values(value.products || {});
|
||||||
|
@ -432,7 +432,7 @@ function PaidPage({
|
|||||||
const refund_taken = order.refund_details.reduce((prev, cur) => {
|
const refund_taken = order.refund_details.reduce((prev, cur) => {
|
||||||
if (cur.pending) return prev;
|
if (cur.pending) return prev;
|
||||||
return Amounts.add(prev, Amounts.parseOrThrow(cur.amount)).amount;
|
return Amounts.add(prev, Amounts.parseOrThrow(cur.amount)).amount;
|
||||||
}, Amounts.getZero(amount.currency));
|
}, Amounts.zeroOfCurrency(amount.currency));
|
||||||
value.refund_taken = Amounts.stringify(refund_taken);
|
value.refund_taken = Amounts.stringify(refund_taken);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -268,14 +268,14 @@ export function RefundModal({
|
|||||||
.map((r) => r.amount)
|
.map((r) => r.amount)
|
||||||
.reduce(
|
.reduce(
|
||||||
(p, c) => Amounts.add(p, Amounts.parseOrThrow(c)).amount,
|
(p, c) => Amounts.add(p, Amounts.parseOrThrow(c)).amount,
|
||||||
Amounts.getZero(config.currency)
|
Amounts.zeroOfCurrency(config.currency)
|
||||||
);
|
);
|
||||||
const orderPrice =
|
const orderPrice =
|
||||||
order.order_status === "paid"
|
order.order_status === "paid"
|
||||||
? Amounts.parseOrThrow(order.contract_terms.amount)
|
? Amounts.parseOrThrow(order.contract_terms.amount)
|
||||||
: undefined;
|
: undefined;
|
||||||
const totalRefundable = !orderPrice
|
const totalRefundable = !orderPrice
|
||||||
? Amounts.getZero(totalRefunded.currency)
|
? Amounts.zeroOfCurrency(totalRefunded.currency)
|
||||||
: refunds.length
|
: refunds.length
|
||||||
? Amounts.sub(orderPrice, totalRefunded).amount
|
? Amounts.sub(orderPrice, totalRefunded).amount
|
||||||
: orderPrice;
|
: orderPrice;
|
||||||
|
Loading…
Reference in New Issue
Block a user