mirror of
https://git.meshkee.com/Meshkee/backend.git
synced 2026-08-11 22:30:59 +04:30
Expand invoices with full templates, public viewer API, and account holder.
Add invoice template CRUD, key points/accounts, public GET endpoint, and migration 039 for account_holder_name. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
co-authored by
Cursor
parent
426316d53c
commit
3faeb9bc0d
+122
-15
@@ -92,6 +92,7 @@ model Business {
|
||||
invoices Invoice[] @relation("InvoiceBusiness")
|
||||
invoicesIssued Invoice[] @relation("InvoiceIssuerBusiness")
|
||||
invoiceItemTemplates InvoiceItemTemplate[]
|
||||
invoiceTemplates InvoiceTemplate[]
|
||||
website_brand_groups website_brand_groups[]
|
||||
website_category_groups website_category_groups[]
|
||||
website_sliders website_sliders[]
|
||||
@@ -1147,27 +1148,98 @@ enum InvoiceStatus {
|
||||
}
|
||||
|
||||
model InvoiceItemTemplate {
|
||||
id BigInt @id @default(autoincrement())
|
||||
ownerScope InvoiceOwnerScope @map("owner_scope")
|
||||
businessId BigInt? @map("business_id")
|
||||
title String @db.VarChar(255)
|
||||
duration String? @db.VarChar(100)
|
||||
worktime String? @db.VarChar(100)
|
||||
description String?
|
||||
price Decimal @default(0) @db.Decimal(12, 2)
|
||||
discountedPrice Decimal? @map("discounted_price") @db.Decimal(12, 2)
|
||||
sortOrder Int @default(0) @map("sort_order")
|
||||
isActive Boolean @default(true) @map("is_active")
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(6)
|
||||
updatedAt DateTime @default(now()) @updatedAt @map("updated_at") @db.Timestamptz(6)
|
||||
business Business? @relation(fields: [businessId], references: [id], onDelete: Cascade, onUpdate: NoAction)
|
||||
invoiceItems InvoiceItem[]
|
||||
id BigInt @id @default(autoincrement())
|
||||
ownerScope InvoiceOwnerScope @map("owner_scope")
|
||||
businessId BigInt? @map("business_id")
|
||||
title String @db.VarChar(255)
|
||||
duration String? @db.VarChar(100)
|
||||
worktime String? @db.VarChar(100)
|
||||
description String?
|
||||
price Decimal @default(0) @db.Decimal(12, 2)
|
||||
discountedPrice Decimal? @map("discounted_price") @db.Decimal(12, 2)
|
||||
sortOrder Int @default(0) @map("sort_order")
|
||||
isActive Boolean @default(true) @map("is_active")
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(6)
|
||||
updatedAt DateTime @default(now()) @updatedAt @map("updated_at") @db.Timestamptz(6)
|
||||
business Business? @relation(fields: [businessId], references: [id], onDelete: Cascade, onUpdate: NoAction)
|
||||
invoiceItems InvoiceItem[]
|
||||
invoiceTemplateItems InvoiceTemplateItem[]
|
||||
|
||||
@@index([ownerScope, sortOrder], map: "idx_invoice_item_templates_owner_scope")
|
||||
@@index([businessId, sortOrder], map: "idx_invoice_item_templates_business_id")
|
||||
@@map("invoice_item_templates")
|
||||
}
|
||||
|
||||
model InvoiceTemplate {
|
||||
id BigInt @id @default(autoincrement())
|
||||
ownerScope InvoiceOwnerScope @map("owner_scope")
|
||||
businessId BigInt? @map("business_id")
|
||||
name String @db.VarChar(255)
|
||||
topText String? @map("top_text")
|
||||
sortOrder Int @default(0) @map("sort_order")
|
||||
isActive Boolean @default(true) @map("is_active")
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(6)
|
||||
updatedAt DateTime @default(now()) @updatedAt @map("updated_at") @db.Timestamptz(6)
|
||||
business Business? @relation(fields: [businessId], references: [id], onDelete: Cascade, onUpdate: NoAction)
|
||||
items InvoiceTemplateItem[]
|
||||
keyPoints InvoiceTemplateKeyPoint[]
|
||||
accounts InvoiceTemplateAccount[]
|
||||
invoices Invoice[]
|
||||
|
||||
@@index([ownerScope, sortOrder], map: "idx_invoice_templates_owner_scope")
|
||||
@@index([businessId, sortOrder], map: "idx_invoice_templates_business_id")
|
||||
@@map("invoice_templates")
|
||||
}
|
||||
|
||||
model InvoiceTemplateItem {
|
||||
id BigInt @id @default(autoincrement())
|
||||
templateId BigInt @map("template_id")
|
||||
itemTemplateId BigInt? @map("item_template_id")
|
||||
title String @db.VarChar(255)
|
||||
duration String? @db.VarChar(100)
|
||||
worktime String? @db.VarChar(100)
|
||||
description String?
|
||||
price Decimal @default(0) @db.Decimal(12, 2)
|
||||
discountedPrice Decimal? @map("discounted_price") @db.Decimal(12, 2)
|
||||
sortOrder Int @default(0) @map("sort_order")
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(6)
|
||||
updatedAt DateTime @default(now()) @updatedAt @map("updated_at") @db.Timestamptz(6)
|
||||
template InvoiceTemplate @relation(fields: [templateId], references: [id], onDelete: Cascade, onUpdate: NoAction)
|
||||
itemTemplate InvoiceItemTemplate? @relation(fields: [itemTemplateId], references: [id], onUpdate: NoAction)
|
||||
|
||||
@@index([templateId, sortOrder], map: "idx_invoice_template_items_template_id")
|
||||
@@map("invoice_template_items")
|
||||
}
|
||||
|
||||
model InvoiceTemplateKeyPoint {
|
||||
id BigInt @id @default(autoincrement())
|
||||
templateId BigInt @map("template_id")
|
||||
text String
|
||||
sortOrder Int @default(0) @map("sort_order")
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(6)
|
||||
updatedAt DateTime @default(now()) @updatedAt @map("updated_at") @db.Timestamptz(6)
|
||||
template InvoiceTemplate @relation(fields: [templateId], references: [id], onDelete: Cascade, onUpdate: NoAction)
|
||||
|
||||
@@index([templateId, sortOrder], map: "idx_invoice_template_key_points_template_id")
|
||||
@@map("invoice_template_key_points")
|
||||
}
|
||||
|
||||
model InvoiceTemplateAccount {
|
||||
id BigInt @id @default(autoincrement())
|
||||
templateId BigInt @map("template_id")
|
||||
bankName String @map("bank_name") @db.VarChar(255)
|
||||
accountHolderName String? @map("account_holder_name") @db.VarChar(255)
|
||||
cardNumber String? @map("card_number") @db.VarChar(64)
|
||||
iban String? @db.VarChar(64)
|
||||
sortOrder Int @default(0) @map("sort_order")
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(6)
|
||||
updatedAt DateTime @default(now()) @updatedAt @map("updated_at") @db.Timestamptz(6)
|
||||
template InvoiceTemplate @relation(fields: [templateId], references: [id], onDelete: Cascade, onUpdate: NoAction)
|
||||
|
||||
@@index([templateId, sortOrder], map: "idx_invoice_template_accounts_template_id")
|
||||
@@map("invoice_template_accounts")
|
||||
}
|
||||
|
||||
model Invoice {
|
||||
id BigInt @id @default(autoincrement())
|
||||
businessId BigInt @map("business_id")
|
||||
@@ -1175,7 +1247,9 @@ model Invoice {
|
||||
issuerBusinessId BigInt? @map("issuer_business_id")
|
||||
status InvoiceStatus @default(issued)
|
||||
name String? @db.VarChar(255)
|
||||
topText String? @map("top_text")
|
||||
notes String?
|
||||
invoiceTemplateId BigInt? @map("invoice_template_id")
|
||||
issuedBy BigInt? @map("issued_by")
|
||||
issuedAt DateTime @default(now()) @map("issued_at") @db.Timestamptz(6)
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(6)
|
||||
@@ -1183,12 +1257,16 @@ model Invoice {
|
||||
business Business @relation("InvoiceBusiness", fields: [businessId], references: [id], onDelete: Cascade, onUpdate: NoAction)
|
||||
issuerBusiness Business? @relation("InvoiceIssuerBusiness", fields: [issuerBusinessId], references: [id], onUpdate: NoAction)
|
||||
issuer User? @relation("InvoiceIssuer", fields: [issuedBy], references: [id], onUpdate: NoAction)
|
||||
invoiceTemplate InvoiceTemplate? @relation(fields: [invoiceTemplateId], references: [id], onUpdate: NoAction)
|
||||
items InvoiceItem[]
|
||||
keyPoints InvoiceKeyPoint[]
|
||||
accounts InvoiceAccount[]
|
||||
|
||||
@@index([businessId, createdAt(sort: Desc)], map: "idx_invoices_business_created")
|
||||
@@index([ownerScope, createdAt(sort: Desc)], map: "idx_invoices_owner_scope")
|
||||
@@index([issuerBusinessId, createdAt(sort: Desc)], map: "idx_invoices_issuer_business_id")
|
||||
@@index([status], map: "idx_invoices_status")
|
||||
@@index([invoiceTemplateId], map: "idx_invoices_invoice_template_id")
|
||||
@@map("invoices")
|
||||
}
|
||||
|
||||
@@ -1212,3 +1290,32 @@ model InvoiceItem {
|
||||
@@index([templateId], map: "idx_invoice_items_template_id")
|
||||
@@map("invoice_items")
|
||||
}
|
||||
|
||||
model InvoiceKeyPoint {
|
||||
id BigInt @id @default(autoincrement())
|
||||
invoiceId BigInt @map("invoice_id")
|
||||
text String
|
||||
sortOrder Int @default(0) @map("sort_order")
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(6)
|
||||
updatedAt DateTime @default(now()) @updatedAt @map("updated_at") @db.Timestamptz(6)
|
||||
invoice Invoice @relation(fields: [invoiceId], references: [id], onDelete: Cascade, onUpdate: NoAction)
|
||||
|
||||
@@index([invoiceId, sortOrder], map: "idx_invoice_key_points_invoice_id")
|
||||
@@map("invoice_key_points")
|
||||
}
|
||||
|
||||
model InvoiceAccount {
|
||||
id BigInt @id @default(autoincrement())
|
||||
invoiceId BigInt @map("invoice_id")
|
||||
bankName String @map("bank_name") @db.VarChar(255)
|
||||
accountHolderName String? @map("account_holder_name") @db.VarChar(255)
|
||||
cardNumber String? @map("card_number") @db.VarChar(64)
|
||||
iban String? @db.VarChar(64)
|
||||
sortOrder Int @default(0) @map("sort_order")
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(6)
|
||||
updatedAt DateTime @default(now()) @updatedAt @map("updated_at") @db.Timestamptz(6)
|
||||
invoice Invoice @relation(fields: [invoiceId], references: [id], onDelete: Cascade, onUpdate: NoAction)
|
||||
|
||||
@@index([invoiceId, sortOrder], map: "idx_invoice_accounts_invoice_id")
|
||||
@@map("invoice_accounts")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user