1 | generator client {
|
---|
2 | provider = "prisma-client-js"
|
---|
3 | }
|
---|
4 |
|
---|
5 | datasource db {
|
---|
6 | provider = "postgresql"
|
---|
7 | url = env("DATABASE_URL")
|
---|
8 | }
|
---|
9 |
|
---|
10 | model Customer {
|
---|
11 | id String @id @default(uuid())
|
---|
12 | companyId String? // Optional company identifier
|
---|
13 | name String
|
---|
14 | email String @unique
|
---|
15 | address Json
|
---|
16 | logoUrl String?
|
---|
17 | phoneNumber String?
|
---|
18 | vatNumber String?
|
---|
19 | companyNumber String?
|
---|
20 | representative String
|
---|
21 | status CustomerStatus @default(active)
|
---|
22 |
|
---|
23 | bankAccounts BankAccount[] // One-to-many relation
|
---|
24 | invoicesSent Invoice[] @relation("InvoiceFrom")
|
---|
25 | invoicesReceived Invoice[] @relation("InvoiceTo")
|
---|
26 | }
|
---|
27 |
|
---|
28 | model BankAccount {
|
---|
29 | id String @id @default(uuid())
|
---|
30 | customerId String
|
---|
31 | customer Customer @relation(fields: [customerId], references: [id], onDelete: Cascade)
|
---|
32 | accountNumber String?
|
---|
33 | bicSwift String?
|
---|
34 | iban String?
|
---|
35 | routingNumber String?
|
---|
36 | currency Currency
|
---|
37 | }
|
---|
38 |
|
---|
39 | model Service {
|
---|
40 | id String @id @default(uuid())
|
---|
41 | name String
|
---|
42 | sprintPrice Float
|
---|
43 | hourPrice Float
|
---|
44 | monthPrice Float
|
---|
45 |
|
---|
46 | invoiceItems InvoiceItem[]
|
---|
47 | }
|
---|
48 |
|
---|
49 | model Invoice {
|
---|
50 | id String @id @default(uuid())
|
---|
51 | sent Int? // Number of times sent
|
---|
52 | dueDate DateTime
|
---|
53 | status InvoiceStatus
|
---|
54 | currency Currency
|
---|
55 | quantityType QuantityType
|
---|
56 | subTotal Float
|
---|
57 | createDate DateTime
|
---|
58 | month Month
|
---|
59 | discount Float?
|
---|
60 | taxes Float?
|
---|
61 | totalAmount Float
|
---|
62 | invoiceNumber String @unique
|
---|
63 | pdfRef String?
|
---|
64 |
|
---|
65 | invoiceFromId String
|
---|
66 | invoiceFrom Customer @relation("InvoiceFrom", fields: [invoiceFromId], references: [id], onDelete: Cascade)
|
---|
67 |
|
---|
68 | invoiceToId String
|
---|
69 | invoiceTo Customer @relation("InvoiceTo", fields: [invoiceToId], references: [id], onDelete: Cascade)
|
---|
70 |
|
---|
71 | items InvoiceItem[]
|
---|
72 | }
|
---|
73 |
|
---|
74 | model InvoiceItem {
|
---|
75 | id String @id @default(uuid())
|
---|
76 | title String
|
---|
77 | price Float
|
---|
78 | total Float
|
---|
79 | quantity Int
|
---|
80 | description String?
|
---|
81 | serviceId String
|
---|
82 | service Service @relation(fields: [serviceId], references: [id], onDelete: Cascade)
|
---|
83 | invoiceId String
|
---|
84 | invoice Invoice @relation(fields: [invoiceId], references: [id], onDelete: Cascade)
|
---|
85 | }
|
---|
86 |
|
---|
87 | // Enums
|
---|
88 | enum CustomerStatus {
|
---|
89 | active
|
---|
90 | banned
|
---|
91 | inactive
|
---|
92 | }
|
---|
93 |
|
---|
94 | enum InvoiceStatus {
|
---|
95 | DRAFT
|
---|
96 | PROCESSING
|
---|
97 | PENDING
|
---|
98 | OVERDUE
|
---|
99 | PAID
|
---|
100 | }
|
---|
101 |
|
---|
102 | enum Currency {
|
---|
103 | EUR
|
---|
104 | USD
|
---|
105 | }
|
---|
106 |
|
---|
107 | enum QuantityType {
|
---|
108 | UNIT
|
---|
109 | HOUR
|
---|
110 | SPRINT
|
---|
111 | MONTH
|
---|
112 | }
|
---|
113 |
|
---|
114 | enum Month {
|
---|
115 | JANUARY
|
---|
116 | FEBRUARY
|
---|
117 | MARCH
|
---|
118 | APRIL
|
---|
119 | MAY
|
---|
120 | JUNE
|
---|
121 | JULY
|
---|
122 | AUGUST
|
---|
123 | SEPTEMBER
|
---|
124 | OCTOBER
|
---|
125 | NOVEMBER
|
---|
126 | DECEMBER
|
---|
127 | }
|
---|