diff --git a/backend/src/services/contract.service.ts b/backend/src/services/contract.service.ts
index 2ba1354b..fb144efe 100644
--- a/backend/src/services/contract.service.ts
+++ b/backend/src/services/contract.service.ts
@@ -95,6 +95,13 @@ export async function getAllContracts(filters: ContractFilters) {
provider: true,
tariff: true,
contractCategory: true,
+ mobileDetails: {
+ select: {
+ phoneNumber: true,
+ simCards: { select: { phoneNumber: true, isMain: true } },
+ },
+ },
+ carInsuranceDetails: { select: { licensePlate: true } },
},
}),
prisma.contract.count({ where }),
@@ -845,6 +852,13 @@ export interface ContractTreeNode {
provider?: { id: number; name: string } | null;
tariff?: { id: number; name: string } | null;
contractCategory?: { id: number; name: string } | null;
+ customer?: { id: number; firstName: string; lastName: string; companyName: string | null; customerNumber: string } | null;
+ address?: { street: string; houseNumber: string; postalCode: string; city: string } | null;
+ mobileDetails?: {
+ phoneNumber: string | null;
+ simCards: { phoneNumber: string | null; isMain: boolean }[];
+ } | null;
+ carInsuranceDetails?: { licensePlate: string | null } | null;
};
predecessors: ContractTreeNode[];
hasHistory: boolean;
@@ -875,6 +889,15 @@ export async function getContractTreeForCustomer(customerId: number): Promise
+ {typeInfo.label}: {typeInfo.value} +
+ ) : null; + })()} {contract.startDate && (Beginn: {formatDate(contract.startDate)} @@ -455,12 +464,19 @@ export default function ContractList() {
- {data.data.map((contract) => ( + {data.data.map((contract) => { + const typeInfo = getContractTypeInfo(contract as any); + return (+ {typeInfo.label}: {typeInfo.value} +
+ ) : null; + })()} {contract.startDate && (Beginn: {formatDate(contract.startDate)} diff --git a/frontend/src/services/api.ts b/frontend/src/services/api.ts index 684401ba..dbe9c8f6 100644 --- a/frontend/src/services/api.ts +++ b/frontend/src/services/api.ts @@ -601,6 +601,13 @@ export interface ContractTreeNodeContract { provider?: { id: number; name: string } | null; tariff?: { id: number; name: string } | null; contractCategory?: { id: number; name: string } | null; + customer?: { id: number; firstName: string; lastName: string; companyName: string | null; customerNumber: string } | null; + address?: { street: string; houseNumber: string; postalCode: string; city: string } | null; + mobileDetails?: { + phoneNumber: string | null; + simCards: { phoneNumber: string | null; isMain: boolean }[]; + } | null; + carInsuranceDetails?: { licensePlate: string | null } | null; } export interface ContractTreeNode { diff --git a/frontend/src/utils/contractInfo.ts b/frontend/src/utils/contractInfo.ts new file mode 100644 index 00000000..e38d2e91 --- /dev/null +++ b/frontend/src/utils/contractInfo.ts @@ -0,0 +1,54 @@ +interface ContractInfoData { + type: string; + address?: { street: string; houseNumber: string; postalCode: string; city: string } | null; + mobileDetails?: { + phoneNumber: string | null; + simCards: { phoneNumber: string | null; isMain: boolean }[]; + } | null; + carInsuranceDetails?: { licensePlate: string | null } | null; +} + +export interface ContractTypeInfo { + label: string; + value: string; +} + +export function getContractTypeInfo(contract: ContractInfoData): ContractTypeInfo | null { + const { type } = contract; + + if (type === 'ELECTRICITY' || type === 'GAS') { + const a = contract.address; + if (!a) return null; + return { + label: 'Lieferadresse', + value: `${a.street} ${a.houseNumber}, ${a.postalCode} ${a.city}`, + }; + } + + if (type === 'DSL' || type === 'FIBER' || type === 'CABLE') { + const a = contract.address; + if (!a) return null; + return { + label: 'Anschlussadresse', + value: `${a.street} ${a.houseNumber}, ${a.postalCode} ${a.city}`, + }; + } + + if (type === 'MOBILE') { + const md = contract.mobileDetails; + if (!md) return null; + const mainSim = md.simCards?.find((s) => s.isMain && s.phoneNumber); + const anySim = md.simCards?.find((s) => s.phoneNumber); + const phone = mainSim?.phoneNumber || anySim?.phoneNumber || md.phoneNumber; + if (!phone) return null; + return { label: 'Rufnummer', value: phone }; + } + + if (type === 'CAR_INSURANCE') { + const plate = contract.carInsuranceDetails?.licensePlate; + if (!plate) return null; + return { label: 'Kennzeichen', value: plate }; + } + + return null; +}