source: prisma/seed.js@ 5d6f37a

main
Last change on this file since 5d6f37a was 5d6f37a, checked in by Naum Shapkarovski <naumshapkarovski@…>, 7 weeks ago

add customer

  • Property mode set to 100644
File size: 3.0 KB
Line 
1import { PrismaClient } from '@prisma/client';
2
3const prisma = new PrismaClient();
4
5async function main() {
6 console.log('🌱 Seeding database...');
7
8 // Create Customers
9 const customer1 = await prisma.customer.create({
10 data: {
11 name: 'Acme Corp',
12 email: 'contact@acme.com',
13 street: '123 Main St',
14 city: 'New York',
15 country: 'USA',
16 state: 'NY',
17 zip: '10001',
18 phoneNumber: '+1 555-555-5555',
19 vatNumber: 'US123456789',
20 companyNumber: '123456789',
21 representative: 'John Doe',
22 status: 'ACTIVE',
23 logoUrl: 'https://example.com/logo.png',
24 },
25 });
26
27 const customer2 = await prisma.customer.create({
28 data: {
29 name: 'Globex Ltd.',
30 email: 'info@globex.com',
31 street: '456 Industrial Rd',
32 city: 'Los Angeles',
33 country: 'USA',
34 state: 'CA',
35 zip: '90001',
36 phoneNumber: '+1 555-123-4567',
37 vatNumber: 'US987654321',
38 companyNumber: '987654321',
39 representative: 'Jane Smith',
40 status: 'INACTIVE',
41 logoUrl: 'https://example.com/logo2.png',
42 },
43 });
44
45 // Create Bank Accounts
46 await prisma.bankAccount.createMany({
47 data: [
48 {
49 customerId: customer1.id,
50 accountNumber: '1234567890',
51 bicSwift: 'ACMEUS33',
52 iban: 'US12345678901234567890',
53 routingNumber: '111000025',
54 currency: 'USD',
55 },
56 {
57 customerId: customer2.id,
58 accountNumber: '0987654321',
59 bicSwift: 'GLOBEXUS12',
60 iban: 'US09876543210987654321',
61 routingNumber: '222000033',
62 currency: 'EUR',
63 },
64 ],
65 });
66
67 // Create Services
68 const service1 = await prisma.service.create({
69 data: {
70 name: 'Web Development',
71 sprintPrice: 5000.0,
72 hourPrice: 100.0,
73 monthPrice: 20000.0,
74 },
75 });
76
77 const service2 = await prisma.service.create({
78 data: {
79 name: 'SEO Optimization',
80 sprintPrice: 3000.0,
81 hourPrice: 75.0,
82 monthPrice: 12000.0,
83 },
84 });
85
86 // Create Invoices
87 const invoice1 = await prisma.invoice.create({
88 data: {
89 dueDate: new Date('2025-03-15'),
90 status: 'PENDING',
91 currency: 'USD',
92 quantityType: 'HOUR',
93 subTotal: 5000.0,
94 createDate: new Date(),
95 month: 'FEBRUARY',
96 discount: 0.0,
97 taxes: 500.0,
98 totalAmount: 5500.0,
99 invoiceNumber: 'INV-2025-001',
100 pdfRef: 'https://example.com/invoice1.pdf',
101 invoiceFromId: customer1.id,
102 invoiceToId: customer2.id,
103 },
104 });
105
106 // Create Invoice Items
107 await prisma.invoiceItem.create({
108 data: {
109 title: 'Web Development - Sprint 1',
110 price: 5000.0,
111 total: 5000.0,
112 quantity: 1,
113 description: 'Development of the MVP frontend',
114 serviceId: service1.id,
115 invoiceId: invoice1.id,
116 },
117 });
118
119 console.log('✅ Seeding complete!');
120}
121
122main()
123 .catch((e) => {
124 console.error(e);
125 process.exit(1);
126 })
127 .finally(async () => {
128 await prisma.$disconnect();
129 });
Note: See TracBrowser for help on using the repository browser.