feat: enter a custom split in euros, other share completed automatically
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c3c371aefe
commit
9fbcf12323
6 files changed
+175
-57
No files matched your search
@@ -8,9 +8,23 @@ import {
|
||||
parseEuro,
|
||||
percentToBp,
|
||||
shareAmounts,
|
||||
splitFromAmounts,
|
||||
validateSplit,
|
||||
} from "@/domain/money";
|
||||
|
||||
describe("splitFromAmounts", () => {
|
||||
it("turns the amount each person pays into basis points summing to 100 %", () => {
|
||||
expect(splitFromAmounts({ h: 60000, s: 39000 }, 99000)).toEqual({ h: 6061, s: 3939 });
|
||||
expect(splitFromAmounts({ a: 10000, b: 10000, c: 10000 }, 30000)).toEqual({ a: 3334, b: 3333, c: 3333 });
|
||||
expect(splitFromAmounts({ h: 99000, s: 0 }, 99000)).toEqual({ h: 10000, s: 0 });
|
||||
});
|
||||
|
||||
it("returns null when the amounts do not add up to the total", () => {
|
||||
expect(splitFromAmounts({ h: 50000, s: 39000 }, 99000)).toBeNull();
|
||||
expect(splitFromAmounts({ h: 0, s: 0 }, 0)).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
const fr = (n: number) =>
|
||||
new Intl.NumberFormat("fr-FR", { style: "currency", currency: "EUR" }).format(n);
|
||||
|
||||
|
||||
Reference in new issue
Block a user