seperate delivery and billig adresses in contract added

This commit is contained in:
2026-02-04 08:48:25 +01:00
parent 88e5f47158
commit a55b58265b
15 changed files with 922 additions and 216 deletions
+4 -3
View File
File diff suppressed because one or more lines are too long
+1
View File
@@ -405,6 +405,7 @@ exports.Prisma.ContractScalarFieldEnum = {
status: 'status',
contractCategoryId: 'contractCategoryId',
addressId: 'addressId',
billingAddressId: 'billingAddressId',
bankCardId: 'bankCardId',
identityDocumentId: 'identityDocumentId',
salesPlatformId: 'salesPlatformId',
+712 -79
View File
File diff suppressed because it is too large Load Diff
+4 -3
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1,5 +1,5 @@
{
"name": "prisma-client-3c4bb688688ba372393d0bf86523c07e8b4de3ff0d9ad23a89f905f15047a1a5",
"name": "prisma-client-5918fcf1a24d6a26f6b4fad7137d1ae3a684231bfa7340820c473996737deea6",
"main": "index.js",
"types": "index.d.ts",
"browser": "index-browser.js",
+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])
+1
View File
@@ -405,6 +405,7 @@ exports.Prisma.ContractScalarFieldEnum = {
status: 'status',
contractCategoryId: 'contractCategoryId',
addressId: 'addressId',
billingAddressId: 'billingAddressId',
bankCardId: 'bankCardId',
identityDocumentId: 'identityDocumentId',
salesPlatformId: 'salesPlatformId',
@@ -0,0 +1,5 @@
-- AlterTable
ALTER TABLE `Contract` ADD COLUMN `billingAddressId` INTEGER NULL;
-- AddForeignKey
ALTER TABLE `Contract` ADD CONSTRAINT `Contract_billingAddressId_fkey` FOREIGN KEY (`billingAddressId`) REFERENCES `Address`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
+8 -2
View File
@@ -158,7 +158,8 @@ model Address {
city String
country String @default("Deutschland")
isDefault Boolean @default(false)
contracts Contract[]
contractsAsDelivery Contract[] @relation("DeliveryAddress")
contractsAsBilling Contract[] @relation("BillingAddress")
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
@@ -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])
+4
View File
@@ -89,6 +89,7 @@ export async function getAllContracts(filters: ContractFilters) {
},
},
address: true,
billingAddress: true,
salesPlatform: true,
cancellationPeriod: true,
contractDuration: true,
@@ -112,6 +113,7 @@ export async function getContractById(id: number, decryptPassword = false) {
include: {
customer: true,
address: true,
billingAddress: true,
bankCard: true,
identityDocument: true,
salesPlatform: true,
@@ -163,6 +165,7 @@ interface ContractCreateData {
contractCategoryId?: number;
status?: ContractStatus;
addressId?: number;
billingAddressId?: number;
bankCardId?: number;
identityDocumentId?: number;
salesPlatformId?: number;
@@ -356,6 +359,7 @@ export async function createContract(data: ContractCreateData) {
include: {
customer: true,
address: true,
billingAddress: true,
salesPlatform: true,
energyDetails: true,
internetDetails: { include: { phoneNumbers: true } },