contractnumber provider added, old provider number field only if no previous contact exist

This commit is contained in:
2026-02-08 14:34:56 +01:00
parent 55f257fffd
commit 4f588015a4
30 changed files with 2046 additions and 744 deletions
+58 -6
View File
@@ -119,8 +119,12 @@ export declare function getAllContracts(filters: ContractFilters): Promise<{
cancellationPeriodId: number | null;
contractDurationId: number | null;
previousContractId: number | null;
previousProviderId: number | null;
previousCustomerNumber: string | null;
previousContractNumber: string | null;
providerId: number | null;
tariffId: number | null;
contractNumberAtProvider: string | null;
priceFirst12Months: string | null;
priceFrom13Months: string | null;
priceAfter24Months: string | null;
@@ -256,6 +260,7 @@ export declare function getContractById(id: number, decryptPassword?: boolean):
} & {
id: number;
meterId: number | null;
previousCustomerNumber: string | null;
contractId: number;
maloId: string | null;
annualConsumption: number | null;
@@ -264,7 +269,6 @@ export declare function getContractById(id: number, decryptPassword?: boolean):
unitPrice: number | null;
bonus: number | null;
previousProviderName: string | null;
previousCustomerNumber: string | null;
}) | null;
stressfreiEmail: {
id: number;
@@ -445,6 +449,7 @@ export declare function getContractById(id: number, decryptPassword?: boolean):
} & {
id: number;
meterId: number | null;
previousCustomerNumber: string | null;
contractId: number;
maloId: string | null;
annualConsumption: number | null;
@@ -453,7 +458,6 @@ export declare function getContractById(id: number, decryptPassword?: boolean):
unitPrice: number | null;
bonus: number | null;
previousProviderName: string | null;
previousCustomerNumber: string | null;
}) | null;
carInsuranceDetails: {
id: number;
@@ -549,8 +553,12 @@ export declare function getContractById(id: number, decryptPassword?: boolean):
cancellationPeriodId: number | null;
contractDurationId: number | null;
previousContractId: number | null;
previousProviderId: number | null;
previousCustomerNumber: string | null;
previousContractNumber: string | null;
providerId: number | null;
tariffId: number | null;
contractNumberAtProvider: string | null;
priceFirst12Months: string | null;
priceFrom13Months: string | null;
priceAfter24Months: string | null;
@@ -572,6 +580,16 @@ export declare function getContractById(id: number, decryptPassword?: boolean):
status: import(".prisma/client").$Enums.ContractStatus;
contractNumber: string;
} | null;
previousProvider: {
id: number;
isActive: boolean;
createdAt: Date;
updatedAt: Date;
name: string;
portalUrl: string | null;
usernameFieldName: string | null;
passwordFieldName: string | null;
} | null;
} & {
id: number;
customerId: number;
@@ -595,8 +613,12 @@ export declare function getContractById(id: number, decryptPassword?: boolean):
cancellationPeriodId: number | null;
contractDurationId: number | null;
previousContractId: number | null;
previousProviderId: number | null;
previousCustomerNumber: string | null;
previousContractNumber: string | null;
providerId: number | null;
tariffId: number | null;
contractNumberAtProvider: string | null;
priceFirst12Months: string | null;
priceFrom13Months: string | null;
priceAfter24Months: string | null;
@@ -764,6 +786,7 @@ export declare function createContract(data: ContractCreateData): Promise<{
energyDetails: {
id: number;
meterId: number | null;
previousCustomerNumber: string | null;
contractId: number;
maloId: string | null;
annualConsumption: number | null;
@@ -772,7 +795,6 @@ export declare function createContract(data: ContractCreateData): Promise<{
unitPrice: number | null;
bonus: number | null;
previousProviderName: string | null;
previousCustomerNumber: string | null;
} | null;
carInsuranceDetails: {
id: number;
@@ -881,8 +903,12 @@ export declare function createContract(data: ContractCreateData): Promise<{
cancellationPeriodId: number | null;
contractDurationId: number | null;
previousContractId: number | null;
previousProviderId: number | null;
previousCustomerNumber: string | null;
previousContractNumber: string | null;
providerId: number | null;
tariffId: number | null;
contractNumberAtProvider: string | null;
priceFirst12Months: string | null;
priceFrom13Months: string | null;
priceAfter24Months: string | null;
@@ -1011,6 +1037,7 @@ export declare function updateContract(id: number, data: Partial<ContractCreateD
} & {
id: number;
meterId: number | null;
previousCustomerNumber: string | null;
contractId: number;
maloId: string | null;
annualConsumption: number | null;
@@ -1019,7 +1046,6 @@ export declare function updateContract(id: number, data: Partial<ContractCreateD
unitPrice: number | null;
bonus: number | null;
previousProviderName: string | null;
previousCustomerNumber: string | null;
}) | null;
stressfreiEmail: {
id: number;
@@ -1200,6 +1226,7 @@ export declare function updateContract(id: number, data: Partial<ContractCreateD
} & {
id: number;
meterId: number | null;
previousCustomerNumber: string | null;
contractId: number;
maloId: string | null;
annualConsumption: number | null;
@@ -1208,7 +1235,6 @@ export declare function updateContract(id: number, data: Partial<ContractCreateD
unitPrice: number | null;
bonus: number | null;
previousProviderName: string | null;
previousCustomerNumber: string | null;
}) | null;
carInsuranceDetails: {
id: number;
@@ -1304,8 +1330,12 @@ export declare function updateContract(id: number, data: Partial<ContractCreateD
cancellationPeriodId: number | null;
contractDurationId: number | null;
previousContractId: number | null;
previousProviderId: number | null;
previousCustomerNumber: string | null;
previousContractNumber: string | null;
providerId: number | null;
tariffId: number | null;
contractNumberAtProvider: string | null;
priceFirst12Months: string | null;
priceFrom13Months: string | null;
priceAfter24Months: string | null;
@@ -1327,6 +1357,16 @@ export declare function updateContract(id: number, data: Partial<ContractCreateD
status: import(".prisma/client").$Enums.ContractStatus;
contractNumber: string;
} | null;
previousProvider: {
id: number;
isActive: boolean;
createdAt: Date;
updatedAt: Date;
name: string;
portalUrl: string | null;
usernameFieldName: string | null;
passwordFieldName: string | null;
} | null;
} & {
id: number;
customerId: number;
@@ -1350,8 +1390,12 @@ export declare function updateContract(id: number, data: Partial<ContractCreateD
cancellationPeriodId: number | null;
contractDurationId: number | null;
previousContractId: number | null;
previousProviderId: number | null;
previousCustomerNumber: string | null;
previousContractNumber: string | null;
providerId: number | null;
tariffId: number | null;
contractNumberAtProvider: string | null;
priceFirst12Months: string | null;
priceFrom13Months: string | null;
priceAfter24Months: string | null;
@@ -1391,8 +1435,12 @@ export declare function deleteContract(id: number): Promise<{
cancellationPeriodId: number | null;
contractDurationId: number | null;
previousContractId: number | null;
previousProviderId: number | null;
previousCustomerNumber: string | null;
previousContractNumber: string | null;
providerId: number | null;
tariffId: number | null;
contractNumberAtProvider: string | null;
priceFirst12Months: string | null;
priceFrom13Months: string | null;
priceAfter24Months: string | null;
@@ -1462,6 +1510,7 @@ export declare function createFollowUpContract(previousContractId: number): Prom
energyDetails: {
id: number;
meterId: number | null;
previousCustomerNumber: string | null;
contractId: number;
maloId: string | null;
annualConsumption: number | null;
@@ -1470,7 +1519,6 @@ export declare function createFollowUpContract(previousContractId: number): Prom
unitPrice: number | null;
bonus: number | null;
previousProviderName: string | null;
previousCustomerNumber: string | null;
} | null;
carInsuranceDetails: {
id: number;
@@ -1579,8 +1627,12 @@ export declare function createFollowUpContract(previousContractId: number): Prom
cancellationPeriodId: number | null;
contractDurationId: number | null;
previousContractId: number | null;
previousProviderId: number | null;
previousCustomerNumber: string | null;
previousContractNumber: string | null;
providerId: number | null;
tariffId: number | null;
contractNumberAtProvider: string | null;
priceFirst12Months: string | null;
priceFrom13Months: string | null;
priceAfter24Months: string | null;
File diff suppressed because one or more lines are too long
+1
View File
@@ -119,6 +119,7 @@ async function getContractById(id, decryptPassword = false) {
provider: true,
tariff: true,
contractCategory: true,
previousProvider: true,
previousContract: {
include: {
energyDetails: { include: { meter: { include: { readings: true } }, invoices: true } },
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"contractCockpit.service.d.ts","sourceRoot":"","sources":["../../src/services/contractCockpit.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,cAAc,EACpC,MAAM,gBAAgB,CAAC;AAMxB,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG,SAAS,GAAG,IAAI,GAAG,MAAM,CAAC;AAElE,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,YAAY,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,cAAc,CAAC;IACvB,QAAQ,EAAE;QACR,EAAE,EAAE,MAAM,CAAC;QACX,cAAc,EAAE,MAAM,CAAC;QACvB,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IACF,QAAQ,CAAC,EAAE;QACT,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IACF,MAAM,CAAC,EAAE;QACP,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IACF,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,cAAc,EAAE,YAAY,CAAC;CAC9B;AAED,MAAM,WAAW,cAAc;IAC7B,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE;QACV,qBAAqB,EAAE,MAAM,CAAC;QAC9B,cAAc,EAAE,MAAM,CAAC;QACvB,kBAAkB,EAAE,MAAM,CAAC;QAC3B,WAAW,EAAE,MAAM,CAAC;QACpB,eAAe,EAAE,MAAM,CAAC;QACxB,SAAS,EAAE,MAAM,CAAC;QAClB,gBAAgB,EAAE,MAAM,CAAC;QACzB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;CACH;AAED,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,eAAe,EAAE,CAAC;IAC7B,OAAO,EAAE,cAAc,CAAC;IACxB,UAAU,EAAE;QACV,YAAY,EAAE,MAAM,CAAC;QACrB,WAAW,EAAE,MAAM,CAAC;QACpB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH;AAyED,wBAAsB,cAAc,IAAI,OAAO,CAAC,aAAa,CAAC,CAyc7D"}
{"version":3,"file":"contractCockpit.service.d.ts","sourceRoot":"","sources":["../../src/services/contractCockpit.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,cAAc,EACpC,MAAM,gBAAgB,CAAC;AAMxB,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG,SAAS,GAAG,IAAI,GAAG,MAAM,CAAC;AAElE,MAAM,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EAAE,eAAe,EAAE,CAAC;IAC7B,OAAO,EAAE,cAAc,CAAC;IACxB,UAAU,EAAE;QACV,YAAY,EAAE,MAAM,CAAC;QACrB,WAAW,EAAE,MAAM,CAAC;QACpB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH;AAyED,wBAAsB,cAAc,IAAI,OAAO,CAAC,aAAa,CAAC,CAod7D"}
+10
View File
@@ -307,6 +307,16 @@ async function getCockpitData() {
});
summary.byCategory.missingData++;
}
// 4b. KEINE VERTRAGSNUMMER BEIM ANBIETER
if (!contract.contractNumberAtProvider) {
issues.push({
type: 'missing_contract_number',
label: 'Vertragsnummer fehlt',
urgency: 'warning',
details: 'Vertragsnummer beim Anbieter fehlt',
});
summary.byCategory.missingData++;
}
// 5. KEIN ANBIETER/TARIF
if (!contract.providerId && !contract.providerName) {
issues.push({
File diff suppressed because one or more lines are too long
+4
View File
@@ -180,8 +180,12 @@ export declare function getCustomerById(id: number): Promise<({
cancellationPeriodId: number | null;
contractDurationId: number | null;
previousContractId: number | null;
previousProviderId: number | null;
previousCustomerNumber: string | null;
previousContractNumber: string | null;
providerId: number | null;
tariffId: number | null;
contractNumberAtProvider: string | null;
priceFirst12Months: string | null;
priceFrom13Months: string | null;
priceAfter24Months: string | null;
File diff suppressed because one or more lines are too long
+7 -4
View File
File diff suppressed because one or more lines are too long
+4
View File
@@ -412,11 +412,15 @@ exports.Prisma.ContractScalarFieldEnum = {
cancellationPeriodId: 'cancellationPeriodId',
contractDurationId: 'contractDurationId',
previousContractId: 'previousContractId',
previousProviderId: 'previousProviderId',
previousCustomerNumber: 'previousCustomerNumber',
previousContractNumber: 'previousContractNumber',
providerId: 'providerId',
tariffId: 'tariffId',
providerName: 'providerName',
tariffName: 'tariffName',
customerNumberAtProvider: 'customerNumberAtProvider',
contractNumberAtProvider: 'contractNumberAtProvider',
priceFirst12Months: 'priceFirst12Months',
priceFrom13Months: 'priceFrom13Months',
priceAfter24Months: 'priceAfter24Months',
+1069
View File
File diff suppressed because it is too large Load Diff
+7 -4
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1,5 +1,5 @@
{
"name": "prisma-client-05071f627540060c098bd6f9ad2705f280d372ae8cdaf0576ff7e91f8d0f9863",
"name": "prisma-client-ab03eeebd49b41f4edbc7df102e0a7779d814508dbccb860745760460e9e271f",
"main": "index.js",
"types": "index.d.ts",
"browser": "index-browser.js",
+8
View File
@@ -413,6 +413,7 @@ model Provider {
isActive Boolean @default(true)
tariffs Tariff[]
contracts Contract[]
previousContracts Contract[] @relation("PreviousProvider") // Verträge wo dieser Provider Altanbieter ist
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
@@ -509,6 +510,12 @@ model Contract {
previousContract Contract? @relation("ContractHistory", fields: [previousContractId], references: [id])
followUpContract Contract? @relation("ContractHistory")
// Altanbieter-Daten (nur wenn kein Vorgängervertrag existiert)
previousProviderId Int?
previousProvider Provider? @relation("PreviousProvider", fields: [previousProviderId], references: [id])
previousCustomerNumber String? // Kundennummer beim Altanbieter
previousContractNumber String? // Vertragsnummer beim Altanbieter
// Anbieter & Tarif (neue Verknüpfung)
providerId Int?
provider Provider? @relation(fields: [providerId], references: [id])
@@ -519,6 +526,7 @@ model Contract {
providerName String?
tariffName String?
customerNumberAtProvider String?
contractNumberAtProvider String? // Vertragsnummer beim Anbieter
priceFirst12Months String? // Preis erste 12 Monate
priceFrom13Months String? // Preis ab 13. Monat
priceAfter24Months String? // Preis nach 24 Monaten
+4
View File
@@ -412,11 +412,15 @@ exports.Prisma.ContractScalarFieldEnum = {
cancellationPeriodId: 'cancellationPeriodId',
contractDurationId: 'contractDurationId',
previousContractId: 'previousContractId',
previousProviderId: 'previousProviderId',
previousCustomerNumber: 'previousCustomerNumber',
previousContractNumber: 'previousContractNumber',
providerId: 'providerId',
tariffId: 'tariffId',
providerName: 'providerName',
tariffName: 'tariffName',
customerNumberAtProvider: 'customerNumberAtProvider',
contractNumberAtProvider: 'contractNumberAtProvider',
priceFirst12Months: 'priceFirst12Months',
priceFrom13Months: 'priceFrom13Months',
priceAfter24Months: 'priceAfter24Months',
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE `Contract` ADD COLUMN `contractNumberAtProvider` VARCHAR(191) NULL;
@@ -0,0 +1,7 @@
-- AlterTable
ALTER TABLE `Contract` ADD COLUMN `previousContractNumber` VARCHAR(191) NULL,
ADD COLUMN `previousCustomerNumber` VARCHAR(191) NULL,
ADD COLUMN `previousProviderId` INTEGER NULL;
-- AddForeignKey
ALTER TABLE `Contract` ADD CONSTRAINT `Contract_previousProviderId_fkey` FOREIGN KEY (`previousProviderId`) REFERENCES `Provider`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
+8
View File
@@ -413,6 +413,7 @@ model Provider {
isActive Boolean @default(true)
tariffs Tariff[]
contracts Contract[]
previousContracts Contract[] @relation("PreviousProvider") // Verträge wo dieser Provider Altanbieter ist
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
@@ -509,6 +510,12 @@ model Contract {
previousContract Contract? @relation("ContractHistory", fields: [previousContractId], references: [id])
followUpContract Contract? @relation("ContractHistory")
// Altanbieter-Daten (nur wenn kein Vorgängervertrag existiert)
previousProviderId Int?
previousProvider Provider? @relation("PreviousProvider", fields: [previousProviderId], references: [id])
previousCustomerNumber String? // Kundennummer beim Altanbieter
previousContractNumber String? // Vertragsnummer beim Altanbieter
// Anbieter & Tarif (neue Verknüpfung)
providerId Int?
provider Provider? @relation(fields: [providerId], references: [id])
@@ -519,6 +526,7 @@ model Contract {
providerName String?
tariffName String?
customerNumberAtProvider String?
contractNumberAtProvider String? // Vertragsnummer beim Anbieter
priceFirst12Months String? // Preis erste 12 Monate
priceFrom13Months String? // Preis ab 13. Monat
priceAfter24Months String? // Preis nach 24 Monaten
+1
View File
@@ -122,6 +122,7 @@ export async function getContractById(id: number, decryptPassword = false) {
provider: true,
tariff: true,
contractCategory: true,
previousProvider: true,
previousContract: {
include: {
energyDetails: { include: { meter: { include: { readings: true } }, invoices: true } },
@@ -361,6 +361,17 @@ export async function getCockpitData(): Promise<CockpitResult> {
summary.byCategory.missingData++;
}
// 4b. KEINE VERTRAGSNUMMER BEIM ANBIETER
if (!contract.contractNumberAtProvider) {
issues.push({
type: 'missing_contract_number',
label: 'Vertragsnummer fehlt',
urgency: 'warning',
details: 'Vertragsnummer beim Anbieter fehlt',
});
summary.byCategory.missingData++;
}
// 5. KEIN ANBIETER/TARIF
if (!contract.providerId && !contract.providerName) {
issues.push({