Refunds
Refunds
ts
import { amount } from '@crapthings/money-safe';
export function calculateRefund(paidMinor: number, refundDecimal: string) {
const paid = amount.minor(paidMinor, 'CNY');
const refund = amount(refundDecimal, 'CNY');
const remaining = paid.minus(refund);
return {
paid: paid.toDecimal(),
refund: refund.toDecimal(),
remaining: remaining.toDecimal(),
auditPayload: refund.toJSON()
};
}The audit payload includes amountMinor, currency, and minorUnit.