upgrade amount api

This commit is contained in:
Sebastian 2022-11-04 10:58:13 -03:00
parent 50e51429ee
commit 80ab8ccce9
No known key found for this signature in database
GPG Key ID: BE4FF68352439FC1
3 changed files with 4 additions and 4 deletions

View File

@ -140,7 +140,7 @@ export function CreatePage({
}: Props): VNode {
const [value, valueHandler] = useState(with_defaults(instanceConfig));
const config = useConfigContext();
const zero = Amounts.getZero(config.currency);
const zero = Amounts.zeroOfCurrency(config.currency);
const inventoryList = Object.values(value.inventoryProducts || {});
const productList = Object.values(value.products || {});

View File

@ -432,7 +432,7 @@ function PaidPage({
const refund_taken = order.refund_details.reduce((prev, cur) => {
if (cur.pending) return prev;
return Amounts.add(prev, Amounts.parseOrThrow(cur.amount)).amount;
}, Amounts.getZero(amount.currency));
}, Amounts.zeroOfCurrency(amount.currency));
value.refund_taken = Amounts.stringify(refund_taken);
return (

View File

@ -268,14 +268,14 @@ export function RefundModal({
.map((r) => r.amount)
.reduce(
(p, c) => Amounts.add(p, Amounts.parseOrThrow(c)).amount,
Amounts.getZero(config.currency)
Amounts.zeroOfCurrency(config.currency)
);
const orderPrice =
order.order_status === "paid"
? Amounts.parseOrThrow(order.contract_terms.amount)
: undefined;
const totalRefundable = !orderPrice
? Amounts.getZero(totalRefunded.currency)
? Amounts.zeroOfCurrency(totalRefunded.currency)
: refunds.length
? Amounts.sub(orderPrice, totalRefunded).amount
: orderPrice;