Billing: refund a payment; void invoices that aren't paid (none, or all refunded)
Void was refused while any payment was recorded, so a paid-then-refunded invoice could only be voided by deleting the payment and losing the record. A payment can now be marked refunded: kept with its receipt, no longer counted as paid, shown on the statement as money going back out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -346,6 +346,27 @@ describe('payments and statements', () => {
|
||||
expect(later.openingCents).toBe(35000);
|
||||
expect(later.closingCents).toBe(90000);
|
||||
});
|
||||
|
||||
test('a refunded payment no longer counts as paid, from the day it was refunded (2.0.2)', () => {
|
||||
const refunded = { amountCents: 55000, paidOn: day('2026-12-02'), refundedAt: day('2026-12-10') };
|
||||
expect(invoiceState(inv('A', '2026-12-01', 55000, [refunded]), '2026-12-05').state).toBe('paid');
|
||||
expect(invoiceState(inv('A', '2026-12-01', 55000, [refunded]), '2026-12-10')).toMatchObject({ paidCents: 0, balanceCents: 55000 });
|
||||
});
|
||||
|
||||
test('a statement shows the refund going back out', () => {
|
||||
const p = { receiptNumber: 'REC-9', amountCents: 55000, paidOn: day('2026-12-02'), refundedAt: day('2026-12-10'), refundNote: 'EFT back', invoice: { number: 'INV-9' } };
|
||||
const invoices = [inv('INV-9', '2026-12-01', 55000, [p])];
|
||||
const st = statement({ invoices, payments: [p], from: '2026-12-01', to: '2026-12-31' });
|
||||
expect(st.entries.map(e => [e.date, e.kind, e.debitCents, e.creditCents, e.balanceCents])).toEqual([
|
||||
['2026-12-01', 'invoice', 55000, 0, 55000],
|
||||
['2026-12-02', 'payment', 0, 55000, 0],
|
||||
['2026-12-10', 'refund', 55000, 0, 55000],
|
||||
]);
|
||||
expect(st.entries[2].description).toBe('Refund of REC-9 (EFT back)');
|
||||
expect(st.outstanding.map(o => o.balanceCents)).toEqual([55000]);
|
||||
// The month after: brought forward includes the refund.
|
||||
expect(statement({ invoices, payments: [p], from: '2027-01-01', to: '2027-01-31' }).openingCents).toBe(55000);
|
||||
});
|
||||
});
|
||||
|
||||
describe('the church\'s address (one per church, never discounted)', () => {
|
||||
|
||||
Reference in New Issue
Block a user