2026-01-04 13:45:26 +03:30
|
|
|
model SalesInvoice {
|
|
|
|
|
id Int @id @default(autoincrement())
|
|
|
|
|
code String @unique @db.VarChar(100)
|
|
|
|
|
totalAmount Decimal @db.Decimal(15, 2)
|
|
|
|
|
description String? @db.Text
|
|
|
|
|
createdAt DateTime @default(now()) @db.Timestamp(0)
|
|
|
|
|
updatedAt DateTime @updatedAt @db.Timestamp(0)
|
|
|
|
|
customerId Int?
|
|
|
|
|
customer Customer? @relation(fields: [customerId], references: [id])
|
|
|
|
|
items SalesInvoiceItem[]
|
|
|
|
|
salesInvoicePayments SalesInvoicePayment[]
|
|
|
|
|
|
|
|
|
|
@@index([customerId])
|
|
|
|
|
@@map("Sales_Invoices")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
model SalesInvoiceItem {
|
|
|
|
|
id Int @id @default(autoincrement())
|
|
|
|
|
count Decimal @db.Decimal(10, 0)
|
|
|
|
|
unitPrice Decimal @default(0.00) @db.Decimal(15, 2)
|
|
|
|
|
totalAmount Decimal @default(0.00) @db.Decimal(15, 2)
|
|
|
|
|
createdAt DateTime @default(now()) @db.Timestamp(0)
|
|
|
|
|
invoiceId Int
|
2026-02-04 13:49:07 +03:30
|
|
|
goodId Int
|
|
|
|
|
serviceId Int
|
2026-01-04 13:45:26 +03:30
|
|
|
invoice SalesInvoice @relation(fields: [invoiceId], references: [id])
|
2026-02-04 13:49:07 +03:30
|
|
|
good Good? @relation(fields: [goodId], references: [id])
|
|
|
|
|
service Service? @relation(fields: [serviceId], references: [id])
|
2026-01-04 13:45:26 +03:30
|
|
|
|
2026-02-04 13:49:07 +03:30
|
|
|
@@index([invoiceId, goodId])
|
2026-01-04 13:45:26 +03:30
|
|
|
@@map("Sales_Invoice_Items")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
model SalesInvoicePayment {
|
|
|
|
|
id Int @id @default(autoincrement())
|
|
|
|
|
invoiceId Int
|
|
|
|
|
amount Decimal @db.Decimal(15, 2)
|
|
|
|
|
paymentMethod PaymentMethodType
|
|
|
|
|
paidAt DateTime
|
|
|
|
|
createdAt DateTime @default(now())
|
|
|
|
|
|
|
|
|
|
invoice SalesInvoice @relation(fields: [invoiceId], references: [id])
|
|
|
|
|
|
|
|
|
|
@@index([invoiceId])
|
|
|
|
|
@@map("Sales_Invoice_Payments")
|
|
|
|
|
}
|