35 lines
1.0 KiB
JavaScript
35 lines
1.0 KiB
JavaScript
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();
|