seperate delivery and billig adresses in contract added

This commit is contained in:
2026-02-04 08:48:25 +01:00
parent fdef6d1d3b
commit 312e879221
15 changed files with 922 additions and 216 deletions
+20 -14
View File
@@ -148,19 +148,20 @@ enum AddressType {
}
model Address {
id Int @id @default(autoincrement())
customerId Int
customer Customer @relation(fields: [customerId], references: [id], onDelete: Cascade)
type AddressType @default(DELIVERY_RESIDENCE)
street String
houseNumber String
postalCode String
city String
country String @default("Deutschland")
isDefault Boolean @default(false)
contracts Contract[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
id Int @id @default(autoincrement())
customerId Int
customer Customer @relation(fields: [customerId], references: [id], onDelete: Cascade)
type AddressType @default(DELIVERY_RESIDENCE)
street String
houseNumber String
postalCode String
city String
country String @default("Deutschland")
isDefault Boolean @default(false)
contractsAsDelivery Contract[] @relation("DeliveryAddress")
contractsAsBilling Contract[] @relation("BillingAddress")
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
// ==================== BANK CARDS ====================
@@ -481,8 +482,13 @@ model Contract {
contractCategoryId Int?
contractCategory ContractCategory? @relation(fields: [contractCategoryId], references: [id])
// Lieferadresse
addressId Int?
address Address? @relation(fields: [addressId], references: [id])
address Address? @relation("DeliveryAddress", fields: [addressId], references: [id])
// Rechnungsadresse (falls leer, wird Lieferadresse verwendet)
billingAddressId Int?
billingAddress Address? @relation("BillingAddress", fields: [billingAddressId], references: [id])
bankCardId Int?
bankCard BankCard? @relation(fields: [bankCardId], references: [id])