final touches for beta skymoney (at least i think)
This commit is contained in:
34
api/check-allocations.cjs
Normal file
34
api/check-allocations.cjs
Normal file
@@ -0,0 +1,34 @@
|
||||
const {PrismaClient} = require('@prisma/client');
|
||||
|
||||
async function checkAllocations() {
|
||||
const p = new PrismaClient();
|
||||
|
||||
try {
|
||||
const user = await p.user.findUnique({
|
||||
where: { email: 'test@skymoney.com' }
|
||||
});
|
||||
|
||||
const income = await p.incomeEvent.findFirst({
|
||||
where: { userId: user.id },
|
||||
orderBy: { postedAt: 'desc' },
|
||||
include: { allocations: true }
|
||||
});
|
||||
|
||||
console.log('\n💵 LATEST INCOME:', Number(income.amountCents)/100);
|
||||
console.log('\n📊 ALLOCATIONS:');
|
||||
|
||||
for (const a of income.allocations) {
|
||||
if (a.kind === 'fixed') {
|
||||
const plan = await p.fixedPlan.findUnique({ where: { id: a.toId } });
|
||||
console.log(' Fixed -', plan.name + ':', Number(a.amountCents)/100);
|
||||
} else if (a.kind === 'variable') {
|
||||
const cat = await p.variableCategory.findUnique({ where: { id: a.toId } });
|
||||
console.log(' Variable -', cat.name + ':', Number(a.amountCents)/100);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
await p.$disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
checkAllocations();
|
||||
Reference in New Issue
Block a user