feat: app shell, UI kit, data loading, recurring sync
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
23f3192cd0
commit
08f23f909f
14 files changed
+493
-7
No files matched your search
@@ -0,0 +1,58 @@
|
||||
import type { Operation, OperationSplit, Recurring, RecurringSplit, Settlement as SettlementRow } from "@prisma/client";
|
||||
import { centsFromDecimal } from "@/domain/money";
|
||||
import type { RecurringDef } from "@/domain/recurrence";
|
||||
import type { Op, Settlement, Split } from "@/domain/types";
|
||||
import { toIsoDate } from "@/lib/dates";
|
||||
|
||||
export const splitOf = (rows: { userId: string; basisPoints: number }[]): Split =>
|
||||
Object.fromEntries(rows.map((s) => [s.userId, s.basisPoints]));
|
||||
|
||||
export const splitRows = (split: Split) =>
|
||||
Object.entries(split).map(([userId, basisPoints]) => ({ userId, basisPoints }));
|
||||
|
||||
export function toOp(row: Operation & { splits: OperationSplit[] }): Op {
|
||||
return {
|
||||
id: row.id,
|
||||
kind: row.kind,
|
||||
amount: centsFromDecimal(row.amount),
|
||||
date: toIsoDate(row.date),
|
||||
label: row.label,
|
||||
categoryId: row.categoryId,
|
||||
accountUserId: row.accountUserId,
|
||||
status: row.status,
|
||||
split: splitOf(row.splits),
|
||||
recurringId: row.recurringId,
|
||||
allocatedToRecurringId: row.allocatedToRecurringId,
|
||||
allocatedToOperationId: row.allocatedToOperationId,
|
||||
allocationMode: row.allocationMode,
|
||||
};
|
||||
}
|
||||
|
||||
export function toRecurringDef(row: Recurring & { splits: RecurringSplit[] }): RecurringDef {
|
||||
return {
|
||||
id: row.id,
|
||||
kind: row.kind,
|
||||
amount: centsFromDecimal(row.amount),
|
||||
label: row.label,
|
||||
categoryId: row.categoryId,
|
||||
accountUserId: row.accountUserId,
|
||||
split: splitOf(row.splits),
|
||||
frequency: row.frequency,
|
||||
dayOfMonth: row.dayOfMonth,
|
||||
startDate: toIsoDate(row.startDate),
|
||||
endDate: row.endDate ? toIsoDate(row.endDate) : null,
|
||||
paused: row.paused,
|
||||
allocatedToRecurringId: row.allocatedToRecurringId,
|
||||
allocationMode: row.allocationMode,
|
||||
};
|
||||
}
|
||||
|
||||
export function toSettlement(row: SettlementRow): Settlement {
|
||||
return {
|
||||
id: row.id,
|
||||
fromUserId: row.fromUserId,
|
||||
toUserId: row.toUserId,
|
||||
amount: centsFromDecimal(row.amount),
|
||||
date: toIsoDate(row.date),
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user