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:
1 parent
a0bcea4eb1
commit
5b402691f0
15 files changed
+222
-15
No files matched your search
@@ -50,6 +50,34 @@ describe("saveRecurring", () => {
|
||||
expect(future.every((o) => o.amount.toString() === "1050")).toBe(true);
|
||||
});
|
||||
|
||||
it("re-splits future allocated incomes when the charge's split changes", async () => {
|
||||
const rent = await saveRecurring(rentInput, TODAY);
|
||||
if (!rent.ok) throw new Error(rent.error);
|
||||
const employer = await saveRecurring(
|
||||
{
|
||||
...rentInput,
|
||||
kind: "INCOME",
|
||||
amount: "200",
|
||||
label: "Part loyer employeur",
|
||||
categoryId: await categoryId("Remboursement employeur"),
|
||||
split: { [H]: 10000, [C]: 0 },
|
||||
allocatedToRecurringId: rent.id,
|
||||
allocationMode: "REDUCE_SHARED",
|
||||
},
|
||||
TODAY,
|
||||
);
|
||||
if (!employer.ok) throw new Error(employer.error);
|
||||
await saveRecurring({ ...rentInput, id: rent.id, split: { [H]: 6000, [C]: 4000 } }, TODAY);
|
||||
const future = await prisma.operation.findMany({
|
||||
where: { recurringId: employer.id, status: "PLANNED", date: { gte: fromIsoDate(TODAY) } },
|
||||
include: { splits: true },
|
||||
});
|
||||
expect(future.length).toBeGreaterThan(0);
|
||||
for (const o of future) {
|
||||
expect(Object.fromEntries(o.splits.map((s) => [s.userId, s.basisPoints]))).toEqual({ [H]: 6000, [C]: 4000 });
|
||||
}
|
||||
});
|
||||
|
||||
it("validates the input", async () => {
|
||||
expect(await saveRecurring({ ...rentInput, amount: "0" }, TODAY)).toEqual({ ok: false, error: "Montant invalide." });
|
||||
expect(await saveRecurring({ ...rentInput, dayOfMonth: 32 }, TODAY)).toEqual({ ok: false, error: "Jour du mois invalide (1 à 31)." });
|
||||
|
||||
Reference in new issue
Block a user