complete new audit system

This commit is contained in:
2026-03-21 18:23:54 +01:00
parent 38b3b7da73
commit fd55742c57
159 changed files with 2841 additions and 736 deletions
+9 -7
View File
@@ -32,11 +32,13 @@ var __importStar = (this && this.__importStar) || (function () {
return result;
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getCockpitData = getCockpitData;
const client_1 = require("@prisma/client");
const prisma_js_1 = __importDefault(require("../lib/prisma.js"));
const appSettingService = __importStar(require("./appSetting.service.js"));
const prisma = new client_1.PrismaClient();
// Hilfsfunktion: Tage bis zu einem Datum berechnen
function daysUntil(date) {
if (!date)
@@ -108,7 +110,7 @@ async function getCockpitData() {
const docExpiryCriticalDays = parseInt(settings.documentExpiryCriticalDays) || 30;
const docExpiryWarningDays = parseInt(settings.documentExpiryWarningDays) || 90;
// Lade alle relevanten Verträge (inkl. CANCELLED/DEACTIVATED für Schlussrechnung-Check)
const contracts = await prisma.contract.findMany({
const contracts = await prisma_js_1.default.contract.findMany({
where: {
status: {
in: ['ACTIVE', 'PENDING', 'DRAFT', 'CANCELLED', 'DEACTIVATED', 'EXPIRED'],
@@ -197,7 +199,7 @@ async function getCockpitData() {
},
};
// Consent-Daten batch-laden für alle Kunden
const allConsents = await prisma.customerConsent.findMany({
const allConsents = await prisma_js_1.default.customerConsent.findMany({
where: { status: 'GRANTED' },
select: { customerId: true, consentType: true },
});
@@ -210,7 +212,7 @@ async function getCockpitData() {
grantedConsentsMap.get(c.customerId).add(c.consentType);
}
// Widerrufene Consents laden
const withdrawnConsents = await prisma.customerConsent.findMany({
const withdrawnConsents = await prisma_js_1.default.customerConsent.findMany({
where: { status: 'WITHDRAWN' },
select: { customerId: true, consentType: true },
});
@@ -629,7 +631,7 @@ async function getCockpitData() {
async function getDocumentExpiryAlerts(criticalDays, warningDays) {
const now = new Date();
const inWarningDays = new Date(now.getTime() + warningDays * 24 * 60 * 60 * 1000);
const documents = await prisma.identityDocument.findMany({
const documents = await prisma_js_1.default.identityDocument.findMany({
where: {
isActive: true,
expiryDate: { lte: inWarningDays },
@@ -668,7 +670,7 @@ async function getDocumentExpiryAlerts(criticalDays, warningDays) {
* Vom Kunden gemeldete Zählerstände die noch nicht übertragen wurden
*/
async function getReportedMeterReadings() {
const readings = await prisma.meterReading.findMany({
const readings = await prisma_js_1.default.meterReading.findMany({
where: { status: 'REPORTED' },
include: {
meter: {