Files
finance/prisma/seed.ts
GitHub Copilot 07fbb82385 Fix: Update button remaining disabled in transaction edit mode
This commit resolves an issue where the Update button in the transaction form
would remain disabled when attempting to edit a transaction. The problem was
in how the transactionStore was managing state updates during transaction editing.

Key changes:
- Enhanced startEditingTransaction function in transactionStore.ts to ensure proper reactivity
- Added clean copy creation of transaction objects to avoid reference issues
- Implemented a state update cycle with null value first to force reactivity
- Added a small timeout to ensure state changes are properly detected by components

The Transaction form now correctly enables the Update button when in edit mode,
regardless of account selection state.
2025-05-05 21:29:36 +00:00

88 lines
2.1 KiB
TypeScript

import { PrismaClient } from '@prisma/client';
const prisma = new PrismaClient();
async function main() {
console.log('Starting database seeding...');
// Clear existing data
await prisma.transaction.deleteMany({});
await prisma.account.deleteMany({});
console.log('Cleared existing data');
// Create accounts
const checkingAccount = await prisma.account.create({
data: {
bankName: 'First National Bank',
accountNumber: '432198',
name: 'Checking Account',
type: 'CHECKING',
balance: 2500.0,
notes: 'Primary checking account',
},
});
const savingsAccount = await prisma.account.create({
data: {
bankName: 'First National Bank',
accountNumber: '876543',
name: 'Savings Account',
type: 'SAVINGS',
balance: 10000.0,
notes: 'Emergency fund',
},
});
console.log('Created accounts:', {
checkingAccount: checkingAccount.id,
savingsAccount: savingsAccount.id,
});
// Create transactions
const transactions = await Promise.all([
prisma.transaction.create({
data: {
accountId: checkingAccount.id,
date: new Date('2025-04-20'),
description: 'Grocery Store',
amount: -75.5,
category: 'Groceries',
type: 'WITHDRAWAL',
},
}),
prisma.transaction.create({
data: {
accountId: checkingAccount.id,
date: new Date('2025-04-21'),
description: 'Salary Deposit',
amount: 3000.0,
category: 'Income',
type: 'DEPOSIT',
},
}),
prisma.transaction.create({
data: {
accountId: savingsAccount.id,
date: new Date('2025-04-22'),
description: 'Transfer to Savings',
amount: 500.0,
category: 'Transfer',
type: 'TRANSFER',
},
}),
]);
console.log(`Created ${transactions.length} transactions`);
console.log('Seeding completed successfully!');
}
main()
.catch((e) => {
console.error('Error during seeding:', e);
process.exit(1);
})
.finally(async () => {
await prisma.$disconnect();
});