final touches for beta skymoney (at least i think)
This commit is contained in:
@@ -11,22 +11,39 @@ async function main() {
|
||||
// 1) User
|
||||
await prisma.user.upsert({
|
||||
where: { id: userId },
|
||||
create: { id: userId, email: "demo@example.com" },
|
||||
update: {},
|
||||
create: {
|
||||
id: userId,
|
||||
email: "demo@example.com",
|
||||
incomeFrequency: "biweekly"
|
||||
},
|
||||
update: { incomeFrequency: "biweekly" },
|
||||
});
|
||||
|
||||
// 2) Variable categories (sum = 100)
|
||||
const categories = [
|
||||
{ name: "Savings", percent: 40, isSavings: true, priority: 10 },
|
||||
{ name: "Needs", percent: 40, isSavings: false, priority: 20 },
|
||||
{ name: "Wants", percent: 20, isSavings: false, priority: 30 },
|
||||
{ name: "Savings", percent: 40, isSavings: true, priority: 10, target: cents(5000) },
|
||||
{ name: "Needs", percent: 40, isSavings: false, priority: 20 },
|
||||
{ name: "Wants", percent: 20, isSavings: false, priority: 30 },
|
||||
];
|
||||
|
||||
for (const c of categories) {
|
||||
await prisma.variableCategory.upsert({
|
||||
where: { userId_name: { userId, name: c.name } },
|
||||
create: { userId, name: c.name, percent: c.percent, isSavings: c.isSavings, priority: c.priority, balanceCents: 0n },
|
||||
update: { percent: c.percent, isSavings: c.isSavings, priority: c.priority },
|
||||
create: {
|
||||
userId,
|
||||
name: c.name,
|
||||
percent: c.percent,
|
||||
isSavings: c.isSavings,
|
||||
priority: c.priority,
|
||||
balanceCents: 0n,
|
||||
savingsTargetCents: c.target ?? null,
|
||||
},
|
||||
update: {
|
||||
percent: c.percent,
|
||||
isSavings: c.isSavings,
|
||||
priority: c.priority,
|
||||
savingsTargetCents: c.target ?? null,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -82,4 +99,4 @@ main().catch((e) => {
|
||||
process.exit(1);
|
||||
}).finally(async () => {
|
||||
await prisma.$disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user