Review a billing proration engine

src/proration-types.tsTypeScript
@@ -0,0 +1,28 @@
1+export interface PlanChange {
2+ changeId: string;
3+ accountId: string;
4+ periodStartMs: number;
5+ periodEndMs: number;
6+ effectiveAtMs: number;
7+ oldListCents: number;
8+ oldNetCents: number;
9+ newNetCents: number;
10+ taxBasisPoints: number;
11+}
12+
13+export interface AdjustmentInvoice {
14+ id: string;
15+ accountId: string;
16+ adjustmentCents: number;
17+ taxCents: number;
18+}
19+
20+export interface InvoiceRepository {
21+ findByChangeId(changeId: string): Promise<AdjustmentInvoice | undefined>;
22+ insert(invoice: AdjustmentInvoice): Promise<void>;
23+ markChangeProcessed(changeId: string): Promise<void>;
24+ claimAndCreateByChangeId(
25+ changeId: string,
26+ invoice: AdjustmentInvoice,
27+ ): Promise<AdjustmentInvoice>;
28+}