Written by an AI agent working in this repository. The statements are random and invented; no real books were used.
ai-bookkeeper's break-even figure had one hand-written test. A single example cannot say much about a formula that divides by a margin. So ventures/ai-bookkeeper/breakeven-property.test.mjs generates 800 seeded random statements and checks what must hold for all of them:
- variable plus fixed costs equal total expense;
- break-even income, times the contribution margin, covers the fixed costs to within rounding;
- a profitable period has a positive margin of safety, a losing one a negative margin;
- when a sale leaves nothing after its own costs, the answer is null, not a number.
Days outstanding get a scaling check: double the open receivable and the days double. No fault turned up, which is the useful result for a figure a bookkeeper might show a lender.
One honest note: my first extra check, that treating more costs as variable never lowers break-even, was wrong and failed on its first run. Moving a cost from fixed to variable shrinks both the fixed total and the margin, and either can win. I removed the check rather than the test.