money: count real Joint recurring items before the move instead of a flat €900/mo
Some checks failed
Deploy production / deploy (push) Has been cancelled

This commit is contained in:
2026-10-26 07:34:49 +00:00
parent e33afe5387
commit 2e8658bf33
3 changed files with 13 additions and 17 deletions

View File

@@ -98,23 +98,23 @@ describe('runScenario', () => {
});
it('pays salary on payday, sweeps the excess the day after and counts recurring income and costs', () => {
const points = runScenario(inputs, flat).points;
// Without history the contract payday (the 25th) is used; €900 pre-move household is
// spread at €30 a day in November.
// Without history the contract payday (the 25th) is used. Before the move only the Joint
// recurring items count: €50 groceries (living with parents), spread at €1.67 a day.
expect(on(points, '2026-11-25').total - on(points, '2026-11-24').total).toBeCloseTo(
300000 + 51250 - 3000,
300000 + 51250 - 5000 / 30,
0
);
// The benefit (paid on the 1st, a Sunday) moves to Monday.
expect(on(points, '2026-11-02').total - on(points, '2026-11-01').total).toBeCloseTo(
10000 - 3000,
10000 - 5000 / 30,
0
);
expect(on(points, '2026-11-25').cash).toBeGreaterThan(500000);
expect(on(points, '2026-11-26').cash).toBe(500000);
// Rest of October: 7/31 of the €900 pre-move household. November: 300k salary + 10k benefit
// + 28k one-off + 13th month 3/12 − 3k gym − 90k pre-move household.
// Rest of October: 7/31 of the €50 groceries. November: 300k salary + 10k benefit
// + 28k one-off + 13th month 3/12 − 3k gym − 5k groceries. No flat Joint contribution.
expect(on(points, '2026-11-30').total).toBeCloseTo(
350000 - (90000 * 7) / 31 + 300000 + 10000 + 28000 + 51250 - 3000 - 90000,
350000 - (5000 * 7) / 31 + 300000 + 10000 + 28000 + 51250 - 3000 - 5000,
0
);
});
@@ -149,10 +149,7 @@ describe('runScenario', () => {
const points = runScenario(withHistory, flat).points;
// 21 November 2026 is a Saturday, so the salary lands on Friday the 20th.
expect(on(points, '2026-11-20').total - on(points, '2026-11-19').total).toBeGreaterThan(300000);
expect(on(points, '2026-12-21').total - on(points, '2026-12-20').total).toBeCloseTo(
300000 - 90000 / 31,
0
);
expect(on(points, '2026-12-21').total - on(points, '2026-12-20').total).toBeCloseTo(300000, 0);
});
it('orders the default scenarios from pessimistic to optimistic', () => {
const [pessimistic, realistic, optimistic] = (