added place to telecommunication, added contract documents, added invoice to other contracts

This commit is contained in:
2026-03-25 16:55:48 +01:00
parent eaa94e766a
commit 3dd4f7b656
30 changed files with 3424 additions and 90 deletions
+12
View File
@@ -137,6 +137,8 @@ export async function getContractById(id: number, decryptPassword = false) {
tvDetails: true,
carInsuranceDetails: true,
stressfreiEmail: true,
invoices: { orderBy: { invoiceDate: 'desc' as const } },
documents: { orderBy: { createdAt: 'desc' as const } },
followUpContract: {
select: { id: true, contractNumber: true, status: true },
},
@@ -210,6 +212,10 @@ interface ContractCreateData {
// Internet-Zugangsdaten
internetUsername?: string;
internetPassword?: string;
// Objekt & Lage
propertyType?: string;
propertyLocation?: string;
connectionLocation?: string;
// Glasfaser-spezifisch
homeId?: string;
// Vodafone DSL/Kabel spezifisch
@@ -302,6 +308,9 @@ export async function createContract(data: ContractCreateData) {
internetPasswordEncrypted: internetDetails.internetPassword
? encrypt(internetDetails.internetPassword)
: undefined,
propertyType: internetDetails.propertyType,
propertyLocation: internetDetails.propertyLocation,
connectionLocation: internetDetails.connectionLocation,
homeId: internetDetails.homeId,
activationCode: internetDetails.activationCode,
phoneNumbers: internetDetails.phoneNumbers && internetDetails.phoneNumbers.length > 0
@@ -462,6 +471,9 @@ export async function updateContract(
...(internetPassword
? { internetPasswordEncrypted: encrypt(internetPassword) }
: {}),
propertyType: internetData.propertyType,
propertyLocation: internetData.propertyLocation,
connectionLocation: internetData.connectionLocation,
homeId: internetData.homeId,
activationCode: internetData.activationCode,
};
+23
View File
@@ -59,6 +59,7 @@ export async function addInvoice(energyContractDetailsId: number, data: CreateIn
return prisma.invoice.create({
data: {
energyContractDetailsId,
contractId: energyDetails.contractId,
invoiceDate: data.invoiceDate,
invoiceType: data.invoiceType,
documentPath: data.documentPath,
@@ -67,6 +68,28 @@ export async function addInvoice(energyContractDetailsId: number, data: CreateIn
});
}
/**
* Rechnung direkt über contractId hinzufügen (für alle Vertragstypen)
*/
export async function addInvoiceByContract(contractId: number, data: CreateInvoiceData) {
return prisma.invoice.create({
data: {
contractId,
invoiceDate: data.invoiceDate,
invoiceType: data.invoiceType,
documentPath: data.documentPath,
notes: data.notes,
},
});
}
export async function getInvoicesByContract(contractId: number) {
return prisma.invoice.findMany({
where: { contractId },
orderBy: { invoiceDate: 'desc' },
});
}
/**
* Rechnung aktualisieren
*/