fix: opening balance direction, safe return paths, backup failure detection, review fixes

- opening balance: "person 2 owes person 1" was stored the wrong way round
- retour param: reject backslash/control chars (open redirect)
- backup: pipefail + check dump completeness, failed dumps no longer logged OK
- deleting a recurring occurrence marks it skipped so sync does not recreate it
- editing a charge regenerates future occurrences of incomes allocated to it
- settlements (incl. opening balance) listed in settings and deletable

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
YugonitoandClaude Opus 5.5 committed 2026-10-27 18:51:49 +01:00
1 parent a0bcea4eb1
commit 5b402691f0
15 files changed
+222 -15

No files matched your search

+23
View File
@@ -4,6 +4,7 @@ import {
confirmOperation,
deleteOperation,
saveOperation,
deleteSettlement,
saveSettlement,
skipOperation,
type OperationInput,
@@ -108,6 +109,19 @@ describe("saveOperation", () => {
});
});
describe("deleteOperation on a recurring occurrence", () => {
it("does not come back at the next sync", async () => {
const r = await saveOperation(expense({ makeRecurring: { frequency: "MONTHLY", endDate: null } }), H);
if (!r.ok) throw new Error(r.error);
await deleteOperation(r.id);
expect(await syncRecurrings("2026-10-27")).toBe(11);
const october = await prisma.operation.findMany({
where: { date: new Date("2026-10-27T00:00:00Z"), status: { not: "SKIPPED" } },
});
expect(october).toHaveLength(0);
});
});
describe("confirm / skip", () => {
it("confirms a planned operation with an adjusted amount and date", async () => {
const r = await saveOperation(expense({ status: "PLANNED" }), H);
@@ -130,6 +144,15 @@ describe("confirm / skip", () => {
});
});
describe("deleteSettlement", () => {
it("removes a repayment entered by mistake", async () => {
await saveSettlement({ fromUserId: C, toUserId: H, amount: "450", date: "2026-10-27" });
const s = await prisma.settlement.findFirstOrThrow();
expect(await deleteSettlement(s.id)).toEqual({ ok: true });
expect(await prisma.settlement.count()).toBe(0);
});
});
describe("saveSettlement", () => {
it("records a repayment and refuses one to oneself", async () => {
expect(await saveSettlement({ fromUserId: C, toUserId: H, amount: "450", date: "2026-10-27" })).toEqual({ ok: true });