complete new audit system
This commit is contained in:
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"file":"appSetting.service.d.ts","sourceRoot":"","sources":["../../src/services/appSetting.service.ts"],"names":[],"mappings":"AAgBA,wBAAsB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAWpE;AAED,wBAAsB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAGlE;AAED,wBAAsB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAM1E;AAED,wBAAsB,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAWtE;AAED,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAazE"}
|
||||
{"version":3,"file":"appSetting.service.d.ts","sourceRoot":"","sources":["../../src/services/appSetting.service.ts"],"names":[],"mappings":"AAcA,wBAAsB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAWpE;AAED,wBAAsB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAGlE;AAED,wBAAsB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAM1E;AAED,wBAAsB,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAWtE;AAED,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAazE"}
|
||||
+7
-5
@@ -1,12 +1,14 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getSetting = getSetting;
|
||||
exports.getSettingBool = getSettingBool;
|
||||
exports.setSetting = setSetting;
|
||||
exports.getAllSettings = getAllSettings;
|
||||
exports.getPublicSettings = getPublicSettings;
|
||||
const client_1 = require("@prisma/client");
|
||||
const prisma = new client_1.PrismaClient();
|
||||
const prisma_js_1 = __importDefault(require("../lib/prisma.js"));
|
||||
// Default settings
|
||||
const DEFAULT_SETTINGS = {
|
||||
customerSupportTicketsEnabled: 'false',
|
||||
@@ -19,7 +21,7 @@ const DEFAULT_SETTINGS = {
|
||||
documentExpiryWarningDays: '90', // Gelb: Warnung (Standard 90 Tage)
|
||||
};
|
||||
async function getSetting(key) {
|
||||
const setting = await prisma.appSetting.findUnique({
|
||||
const setting = await prisma_js_1.default.appSetting.findUnique({
|
||||
where: { key },
|
||||
});
|
||||
if (setting) {
|
||||
@@ -33,14 +35,14 @@ async function getSettingBool(key) {
|
||||
return value === 'true';
|
||||
}
|
||||
async function setSetting(key, value) {
|
||||
await prisma.appSetting.upsert({
|
||||
await prisma_js_1.default.appSetting.upsert({
|
||||
where: { key },
|
||||
update: { value },
|
||||
create: { key, value },
|
||||
});
|
||||
}
|
||||
async function getAllSettings() {
|
||||
const settings = await prisma.appSetting.findMany();
|
||||
const settings = await prisma_js_1.default.appSetting.findMany();
|
||||
// Start with defaults, then override with stored values
|
||||
const result = { ...DEFAULT_SETTINGS };
|
||||
for (const setting of settings) {
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"file":"appSetting.service.js","sourceRoot":"","sources":["../../src/services/appSetting.service.ts"],"names":[],"mappings":";;AAgBA,gCAWC;AAED,wCAGC;AAED,gCAMC;AAED,wCAWC;AAED,8CAaC;AApED,2CAA8C;AAE9C,MAAM,MAAM,GAAG,IAAI,qBAAY,EAAE,CAAC;AAElC,mBAAmB;AACnB,MAAM,gBAAgB,GAA2B;IAC/C,6BAA6B,EAA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AG,OAAO,CAAC,KAAK,CAAC;IACtC,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAEM,KAAK,UAAU,iBAAiB;IACrC,qFAAqF;IACrF,MAAM,UAAU,GAAG,CAAC,+BAA+B,CAAC,CAAC;IACrD,MAAM,WAAW,GAAG,MAAM,cAAc,EAAE,CAAC;IAE3C,MAAM,MAAM,GAA2B,EAAE,CAAC;IAC1C,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;QAC7B,IAAI,GAAG,IAAI,WAAW,EAAE,CAAC;YACvB,MAAM,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;QACjC,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
||||
{"version":3,"file":"appSetting.service.js","sourceRoot":"","sources":["../../src/services/appSetting.service.ts"],"names":[],"mappings":";;;;;AAcA,gCAWC;AAED,wCAGC;AAED,gCAMC;AAED,wCAWC;AAED,8CAaC;AAlED,iEAAsC;AAEtC,mBAAmB;AACnB,MAAM,gBAAgB,GAA2B;IAC/C,6BAA6B,EAAE,OAAO;IACtC,gDAAgD;IAChD,oBAAoB,EAAE,IAAI,EAAO,gBAAgB;IACjD,mBAAmB,EAAE,IAAI,EAAQ,2BAA2B;IAC5D,cAAc,EAAE,IAAI,EAAa,sBAAsB;IACvD,8CAA8C;IAC9C,0BAA0B,EAAE,IAAI,EAAE,mCAAmC;IACrE,yBAAyB,EAAE,IAAI,EAAG,mCAAmC;CACtE,CAAC;AAEK,KAAK,UAAU,UAAU,CAAC,GAAW;IAC1C,MAAM,OAAO,GAAG,MAAM,mBAAM,CAAC,UAAU,CAAC,UAAU,CAAC;QACjD,KAAK,EAAE,EAAE,GAAG,EAAE;KACf,CAAC,CAAC;IAEH,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,OAAO,CAAC,KAAK,CAAC;IACvB,CAAC;IAED,2BAA2B;IAC3B,OAAO,gBAAgB,CAAC,GAAG,C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ot":"","sources":["../../src/services/auth.service.ts"],"names":[],"mappings":"AASA,wBAAsB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;;;;;;;;;;;GA+D1D;AAGD,wBAAsB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;;;;;;;;;;;;;;;;;;;GAwFlE;AAGD,wBAAsB,yBAAyB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,iBAiBnF;AAGD,wBAAsB,yBAAyB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAgB1F;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;;;;;;GA8BA;AAED,wBAAsB,WAAW,CAAC,EAAE,EAAE,MAAM;;;;;;;;;;;;;UAiD3C;AAGD,wBAAsB,qBAAqB,CAAC,UAAU,EAAE,MAAM;;;;;;;;;;;;;;;;;UA+C7D"}
|
||||
{"version":3,"file":"auth.service.d.ts","sourceRoot":"","sources":["../../src/services/auth.service.ts"],"names":[],"mappings":"AAOA,wBAAsB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;;;;;;;;;;;GA+D1D;AAGD,wBAAsB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;;;;;;;;;;;;;;;;;;;GAwFlE;AAGD,wBAAsB,yBAAyB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,iBAiBnF;AAGD,wBAAsB,yBAAyB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAgB1F;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;;;;;;GA8BA;AAED,wBAAsB,WAAW,CAAC,EAAE,EAAE,MAAM;;;;;;;;;;;;;UAiD3C;AAGD,wBAAsB,qBAAqB,CAAC,UAAU,EAAE,MAAM;;;;;;;;;;;;;;;;;UA+C7D"}
|
||||
+9
-10
@@ -10,14 +10,13 @@ exports.getCustomerPortalPassword = getCustomerPortalPassword;
|
||||
exports.createUser = createUser;
|
||||
exports.getUserById = getUserById;
|
||||
exports.getCustomerPortalUser = getCustomerPortalUser;
|
||||
const client_1 = require("@prisma/client");
|
||||
const prisma_js_1 = __importDefault(require("../lib/prisma.js"));
|
||||
const bcryptjs_1 = __importDefault(require("bcryptjs"));
|
||||
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
||||
const encryption_js_1 = require("../utils/encryption.js");
|
||||
const prisma = new client_1.PrismaClient();
|
||||
// Mitarbeiter-Login
|
||||
async function login(email, password) {
|
||||
const user = await prisma.user.findUnique({
|
||||
const user = await prisma_js_1.default.user.findUnique({
|
||||
where: { email },
|
||||
include: {
|
||||
roles: {
|
||||
@@ -75,7 +74,7 @@ async function login(email, password) {
|
||||
// Kundenportal-Login
|
||||
async function customerLogin(email, password) {
|
||||
console.log('[CustomerLogin] Versuch mit E-Mail:', email);
|
||||
const customer = await prisma.customer.findUnique({
|
||||
const customer = await prisma_js_1.default.customer.findUnique({
|
||||
where: { portalEmail: email },
|
||||
include: {
|
||||
// Kunden, die dieser Kunde vertreten kann
|
||||
@@ -107,7 +106,7 @@ async function customerLogin(email, password) {
|
||||
throw new Error('Ungültige Anmeldedaten');
|
||||
}
|
||||
// Letzte Anmeldung aktualisieren
|
||||
await prisma.customer.update({
|
||||
await prisma_js_1.default.customer.update({
|
||||
where: { id: customer.id },
|
||||
data: { portalLastLogin: new Date() },
|
||||
});
|
||||
@@ -155,7 +154,7 @@ async function setCustomerPortalPassword(customerId, password) {
|
||||
const hashedPassword = await bcryptjs_1.default.hash(password, 10);
|
||||
const encryptedPassword = (0, encryption_js_1.encrypt)(password);
|
||||
console.log('[SetPortalPassword] Hash erstellt, Länge:', hashedPassword.length);
|
||||
await prisma.customer.update({
|
||||
await prisma_js_1.default.customer.update({
|
||||
where: { id: customerId },
|
||||
data: {
|
||||
portalPasswordHash: hashedPassword,
|
||||
@@ -166,7 +165,7 @@ async function setCustomerPortalPassword(customerId, password) {
|
||||
}
|
||||
// Kundenportal-Passwort im Klartext abrufen
|
||||
async function getCustomerPortalPassword(customerId) {
|
||||
const customer = await prisma.customer.findUnique({
|
||||
const customer = await prisma_js_1.default.customer.findUnique({
|
||||
where: { id: customerId },
|
||||
select: { portalPasswordEncrypted: true },
|
||||
});
|
||||
@@ -183,7 +182,7 @@ async function getCustomerPortalPassword(customerId) {
|
||||
}
|
||||
async function createUser(data) {
|
||||
const hashedPassword = await bcryptjs_1.default.hash(data.password, 10);
|
||||
const user = await prisma.user.create({
|
||||
const user = await prisma_js_1.default.user.create({
|
||||
data: {
|
||||
email: data.email,
|
||||
password: hashedPassword,
|
||||
@@ -211,7 +210,7 @@ async function createUser(data) {
|
||||
};
|
||||
}
|
||||
async function getUserById(id) {
|
||||
const user = await prisma.user.findUnique({
|
||||
const user = await prisma_js_1.default.user.findUnique({
|
||||
where: { id },
|
||||
include: {
|
||||
roles: {
|
||||
@@ -256,7 +255,7 @@ async function getUserById(id) {
|
||||
}
|
||||
// Kundenportal-Benutzer laden (für /me Endpoint)
|
||||
async function getCustomerPortalUser(customerId) {
|
||||
const customer = await prisma.customer.findUnique({
|
||||
const customer = await prisma_js_1.default.customer.findUnique({
|
||||
where: { id: customerId },
|
||||
include: {
|
||||
representingFor: {
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
@@ -1 +1 @@
|
||||
{"version":3,"file":"cancellation-period.service.d.ts","sourceRoot":"","sources":["../../src/services/cancellation-period.service.ts"],"names":[],"mappings":"AAIA,wBAAsB,yBAAyB,CAAC,eAAe,UAAQ;;;;;;;KAMtE;AAED,wBAAsB,yBAAyB,CAAC,EAAE,EAAE,MAAM;;;;;;;;;;;WASzD;AAED,wBAAsB,wBAAwB,CAAC,IAAI,EAAE;IACnD,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACrB;;;;;;;GAOA;AAED,wBAAsB,wBAAwB,CAC5C,EAAE,EAAE,MAAM,EACV,IAAI,EAAE;IACJ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;;;;;;;GAMF;AAED,wBAAsB,wBAAwB,CAAC,EAAE,EAAE,MAAM;;;;;;;GAaxD"}
|
||||
{"version":3,"file":"cancellation-period.service.d.ts","sourceRoot":"","sources":["../../src/services/cancellation-period.service.ts"],"names":[],"mappings":"AAEA,wBAAsB,yBAAyB,CAAC,eAAe,UAAQ;;;;;;;KAMtE;AAED,wBAAsB,yBAAyB,CAAC,EAAE,EAAE,MAAM;;;;;;;;;;;WASzD;AAED,wBAAsB,wBAAwB,CAAC,IAAI,EAAE;IACnD,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACrB;;;;;;;GAOA;AAED,wBAAsB,wBAAwB,CAC5C,EAAE,EAAE,MAAM,EACV,IAAI,EAAE;IACJ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;;;;;;;GAMF;AAED,wBAAsB,wBAAwB,CAAC,EAAE,EAAE,MAAM;;;;;;;GAaxD"}
|
||||
+10
-8
@@ -1,21 +1,23 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getAllCancellationPeriods = getAllCancellationPeriods;
|
||||
exports.getCancellationPeriodById = getCancellationPeriodById;
|
||||
exports.createCancellationPeriod = createCancellationPeriod;
|
||||
exports.updateCancellationPeriod = updateCancellationPeriod;
|
||||
exports.deleteCancellationPeriod = deleteCancellationPeriod;
|
||||
const client_1 = require("@prisma/client");
|
||||
const prisma = new client_1.PrismaClient();
|
||||
const prisma_js_1 = __importDefault(require("../lib/prisma.js"));
|
||||
async function getAllCancellationPeriods(includeInactive = false) {
|
||||
const where = includeInactive ? {} : { isActive: true };
|
||||
return prisma.cancellationPeriod.findMany({
|
||||
return prisma_js_1.default.cancellationPeriod.findMany({
|
||||
where,
|
||||
orderBy: { code: 'asc' },
|
||||
});
|
||||
}
|
||||
async function getCancellationPeriodById(id) {
|
||||
return prisma.cancellationPeriod.findUnique({
|
||||
return prisma_js_1.default.cancellationPeriod.findUnique({
|
||||
where: { id },
|
||||
include: {
|
||||
_count: {
|
||||
@@ -25,7 +27,7 @@ async function getCancellationPeriodById(id) {
|
||||
});
|
||||
}
|
||||
async function createCancellationPeriod(data) {
|
||||
return prisma.cancellationPeriod.create({
|
||||
return prisma_js_1.default.cancellationPeriod.create({
|
||||
data: {
|
||||
...data,
|
||||
isActive: true,
|
||||
@@ -33,19 +35,19 @@ async function createCancellationPeriod(data) {
|
||||
});
|
||||
}
|
||||
async function updateCancellationPeriod(id, data) {
|
||||
return prisma.cancellationPeriod.update({
|
||||
return prisma_js_1.default.cancellationPeriod.update({
|
||||
where: { id },
|
||||
data,
|
||||
});
|
||||
}
|
||||
async function deleteCancellationPeriod(id) {
|
||||
// Check if cancellation period is used by any contracts
|
||||
const count = await prisma.contract.count({
|
||||
const count = await prisma_js_1.default.contract.count({
|
||||
where: { cancellationPeriodId: id },
|
||||
});
|
||||
if (count > 0) {
|
||||
throw new Error(`Kündigungsfrist kann nicht gelöscht werden, da sie von ${count} Verträgen verwendet wird`);
|
||||
}
|
||||
return prisma.cancellationPeriod.delete({ where: { id } });
|
||||
return prisma_js_1.default.cancellationPeriod.delete({ where: { id } });
|
||||
}
|
||||
//# sourceMappingURL=cancellation-period.service.js.map
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"cancellation-period.service.js","sourceRoot":"","sources":["../../src/services/cancellation-period.service.ts"],"names":[],"mappings":";;AAIA,8DAMC;AAED,8DASC;AAED,4DAUC;AAED,4DAYC;AAED,4DAaC;AA9DD,2CAA8C;AAE9C,MAAM,MAAM,GAAG,IAAI,qBAAY,EAAE,CAAC;AAE3B,KAAK,UAAU,yBAAyB,CAAC,eAAe,GAAG,KAAK;IACrE,MAAM,KAAK,GAAG,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACxD,OAAO,MAAM,CAAC,kBAAkB,CAAC,QAAQ,CAAC;QACxC,KAAK;QACL,OAAO,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE;KACzB,CAAC,CAAC;AACL,CAAC;AAEM,KAAK,UAAU,yBAAyB,CAAC,EAAU;IACxD,OAAO,MAAM,CAAC,kBAAkB,CAAC,UAAU,CAAC;QAC1C,KAAK,EAAE,EAAE,EAAE,EAAE;QACb,OAAO,EAAE;YACP,MAAM,EAAE;gBACN,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE;aAC5B;SACF;KACF,CAAC,CAAC;AACL,CAAC;AAEM,KAAK,UAAU,wBAAwB,CAAC,IAG9C;IACC,OAAO,MAAM,CAAC,kBAAkB,CAAC,MAAM,CAAC;QACtC,IAAI,EAAE;YACJ,GAAG,IAAI;YACP,QAAQ,EAAE,IAAI;SACf;KACF,CAAC,CAAC;AACL,CAAC;AAEM,KAAK,UAAU,wBAAwB,CAC5C,EAAU,EACV,IAIC;IAED,OAAO,MAAM,CAAC,kBAAkB,CAAC,MAAM,CAAC;QACtC,KAAK,EAAE,EAAE,EAAE,EAAE;QACb,IAAI;KACL,CAAC,CAAC;AACL,CAAC;AAEM,KAAK,UAAU,wBAAwB,CAAC,EAAU;IACvD,wDAAwD;IACxD,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;QACxC,KAAK,EAAE,EAAE,oBAAoB,EAAE,EAAE,EAAE;KACpC,CAAC,CAAC;IAEH,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CACb,0DAA0D,KAAK,2BAA2B,CAC3F,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC,kBAAkB,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;AAC7D,CAAC"}
|
||||
{"version":3,"file":"cancellation-period.service.js","sourceRoot":"","sources":["../../src/services/cancellation-period.service.ts"],"names":[],"mappings":";;;;;AAEA,8DAMC;AAED,8DASC;AAED,4DAUC;AAED,4DAYC;AAED,4DAaC;AA5DD,iEAAsC;AAE/B,KAAK,UAAU,yBAAyB,CAAC,eAAe,GAAG,KAAK;IACrE,MAAM,KAAK,GAAG,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACxD,OAAO,mBAAM,CAAC,kBAAkB,CAAC,QAAQ,CAAC;QACxC,KAAK;QACL,OAAO,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE;KACzB,CAAC,CAAC;AACL,CAAC;AAEM,KAAK,UAAU,yBAAyB,CAAC,EAAU;IACxD,OAAO,mBAAM,CAAC,kBAAkB,CAAC,UAAU,CAAC;QAC1C,KAAK,EAAE,EAAE,EAAE,EAAE;QACb,OAAO,EAAE;YACP,MAAM,EAAE;gBACN,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE;aAC5B;SACF;KACF,CAAC,CAAC;AACL,CAAC;AAEM,KAAK,UAAU,wBAAwB,CAAC,IAG9C;IACC,OAAO,mBAAM,CAAC,kBAAkB,CAAC,MAAM,CAAC;QACtC,IAAI,EAAE;YACJ,GAAG,IAAI;YACP,QAAQ,EAAE,IAAI;SACf;KACF,CAAC,CAAC;AACL,CAAC;AAEM,KAAK,UAAU,wBAAwB,CAC5C,EAAU,EACV,IAIC;IAED,OAAO,mBAAM,CAAC,kBAAkB,CAAC,MAAM,CAAC;QACtC,KAAK,EAAE,EAAE,EAAE,EAAE;QACb,IAAI;KACL,CAAC,CAAC;AACL,CAAC;AAEM,KAAK,UAAU,wBAAwB,CAAC,EAAU;IACvD,wDAAwD;IACxD,MAAM,KAAK,GAAG,MAAM,mBAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;QACxC,KAAK,EAAE,EAAE,oBAAoB,EAAE,EAAE,EAAE;KACpC,CAAC,CAAC;IAEH,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CACb,0DAA0D,KAAK,2BAA2B,CAC3F,CAAC;IACJ,CAAC;IAED,OAAO,mBAAM,CAAC,kBAAkB,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;AAC7D,CAAC"}
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"contract-duration.service.d.ts","sourceRoot":"","sources":["../../src/services/contract-duration.service.ts"],"names":[],"mappings":"AAIA,wBAAsB,uBAAuB,CAAC,eAAe,UAAQ;;;;;;;KAMpE;AAED,wBAAsB,uBAAuB,CAAC,EAAE,EAAE,MAAM;;;;;;;;;;;WASvD;AAED,wBAAsB,sBAAsB,CAAC,IAAI,EAAE;IACjD,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACrB;;;;;;;GAOA;AAED,wBAAsB,sBAAsB,CAC1C,EAAE,EAAE,MAAM,EACV,IAAI,EAAE;IACJ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;;;;;;;GAMF;AAED,wBAAsB,sBAAsB,CAAC,EAAE,EAAE,MAAM;;;;;;;GAatD"}
|
||||
{"version":3,"file":"contract-duration.service.d.ts","sourceRoot":"","sources":["../../src/services/contract-duration.service.ts"],"names":[],"mappings":"AAEA,wBAAsB,uBAAuB,CAAC,eAAe,UAAQ;;;;;;;KAMpE;AAED,wBAAsB,uBAAuB,CAAC,EAAE,EAAE,MAAM;;;;;;;;;;;WASvD;AAED,wBAAsB,sBAAsB,CAAC,IAAI,EAAE;IACjD,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACrB;;;;;;;GAOA;AAED,wBAAsB,sBAAsB,CAC1C,EAAE,EAAE,MAAM,EACV,IAAI,EAAE;IACJ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;;;;;;;GAMF;AAED,wBAAsB,sBAAsB,CAAC,EAAE,EAAE,MAAM;;;;;;;GAatD"}
|
||||
+10
-8
@@ -1,21 +1,23 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getAllContractDurations = getAllContractDurations;
|
||||
exports.getContractDurationById = getContractDurationById;
|
||||
exports.createContractDuration = createContractDuration;
|
||||
exports.updateContractDuration = updateContractDuration;
|
||||
exports.deleteContractDuration = deleteContractDuration;
|
||||
const client_1 = require("@prisma/client");
|
||||
const prisma = new client_1.PrismaClient();
|
||||
const prisma_js_1 = __importDefault(require("../lib/prisma.js"));
|
||||
async function getAllContractDurations(includeInactive = false) {
|
||||
const where = includeInactive ? {} : { isActive: true };
|
||||
return prisma.contractDuration.findMany({
|
||||
return prisma_js_1.default.contractDuration.findMany({
|
||||
where,
|
||||
orderBy: { code: 'asc' },
|
||||
});
|
||||
}
|
||||
async function getContractDurationById(id) {
|
||||
return prisma.contractDuration.findUnique({
|
||||
return prisma_js_1.default.contractDuration.findUnique({
|
||||
where: { id },
|
||||
include: {
|
||||
_count: {
|
||||
@@ -25,7 +27,7 @@ async function getContractDurationById(id) {
|
||||
});
|
||||
}
|
||||
async function createContractDuration(data) {
|
||||
return prisma.contractDuration.create({
|
||||
return prisma_js_1.default.contractDuration.create({
|
||||
data: {
|
||||
...data,
|
||||
isActive: true,
|
||||
@@ -33,19 +35,19 @@ async function createContractDuration(data) {
|
||||
});
|
||||
}
|
||||
async function updateContractDuration(id, data) {
|
||||
return prisma.contractDuration.update({
|
||||
return prisma_js_1.default.contractDuration.update({
|
||||
where: { id },
|
||||
data,
|
||||
});
|
||||
}
|
||||
async function deleteContractDuration(id) {
|
||||
// Check if contract duration is used by any contracts
|
||||
const count = await prisma.contract.count({
|
||||
const count = await prisma_js_1.default.contract.count({
|
||||
where: { contractDurationId: id },
|
||||
});
|
||||
if (count > 0) {
|
||||
throw new Error(`Laufzeit kann nicht gelöscht werden, da sie von ${count} Verträgen verwendet wird`);
|
||||
}
|
||||
return prisma.contractDuration.delete({ where: { id } });
|
||||
return prisma_js_1.default.contractDuration.delete({ where: { id } });
|
||||
}
|
||||
//# sourceMappingURL=contract-duration.service.js.map
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"file":"contract-duration.service.js","sourceRoot":"","sources":["../../src/services/contract-duration.service.ts"],"names":[],"mappings":";;AAIA,0DAMC;AAED,0DASC;AAED,wDAUC;AAED,wDAYC;AAED,wDAaC;AA9DD,2CAA8C;AAE9C,MAAM,MAAM,GAAG,IAAI,qBAAY,EAAE,CAAC;AAE3B,KAAK,UAAU,uBAAuB,CAAC,eAAe,GAAG,KAAK;I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AE,EAAE,EAAE,CAAC,CAAC;AAC3D,CAAC"}
|
||||
{"version":3,"file":"contract-duration.service.js","sourceRoot":"","sources":["../../src/services/contract-duration.service.ts"],"names":[],"mappings":";;;;;AAEA,0DAMC;AAED,0DASC;AAED,wDAUC;AAED,wDAYC;AAED,wDAaC;AA5DD,iEAAsC;AAE/B,KAAK,UAAU,uBAAuB,CAAC,eAAe,GAAG,KAAK;IACnE,MAAM,KAAK,GAAG,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACxD,OAAO,mBAAM,CAAC,gBAAgB,CAAC,QAAQ,CAAC;QACtC,KAAK;QACL,OAAO,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE;KACzB,CAAC,CAAC;AACL,CAAC;AAEM,KAAK,UAAU,uBAAuB,CAAC,EAAU;IACtD,OAAO,mBAAM,CAAC,gBAAgB,CAAC,UAAU,CAAC;QACxC,KAAK,EAAE,EAAE,EAAE,EAAE;QACb,OAAO,EAAE;YACP,MAAM,EAAE;gBACN,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE;aAC5B;SACF;KACF,CAAC,CAAC;AACL,CAAC;AAEM,KAAK,UAAU,sBAAsB,CAAC,IAG5C;IACC,OAAO,mBAAM,CAAC,gBAAgB,CAAC,MAAM,CAAC;QACpC,IAAI,EAAE;YACJ,GAAG,IAAI;YACP,QAAQ,EAAE,IAAI;SACf;KACF,CAAC,CAAC;AACL,CAAC;AAEM,KAAK,UAAU,sBAAsB,CAC1C,EAAU,EACV,IAIC;IAED,OAAO,mBAAM,CAAC,gBAAgB,CAAC,MAAM,CAAC;QACpC,KAAK,EAAE,EAAE,EAAE,EAAE;QACb,IAAI;KACL,CAAC,CAAC;AACL,CAAC;AAEM,KAAK,UAAU,sBAAsB,CAAC,EAAU;IACrD,sDAAsD;IACtD,MAAM,KAAK,GAAG,MAAM,mBAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;QACxC,KAAK,EAAE,EAAE,kBAAkB,EAAE,EAAE,EAAE;KAClC,CAAC,CAAC;IAEH,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CACb,mDAAmD,KAAK,2BAA2B,CACpF,CAAC;IACJ,CAAC;IAED,OAAO,mBAAM,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;AAC3D,CAAC"}
|
||||
+50
-50
@@ -97,13 +97,13 @@ export declare function getAllContracts(filters: ContractFilters): Promise<{
|
||||
providerId: number;
|
||||
} | null;
|
||||
} & {
|
||||
portalPasswordEncrypted: string | null;
|
||||
id: number;
|
||||
customerId: number;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
type: import(".prisma/client").$Enums.ContractType;
|
||||
notes: string | null;
|
||||
portalPasswordEncrypted: string | null;
|
||||
startDate: Date | null;
|
||||
contractNumber: string;
|
||||
status: import(".prisma/client").$Enums.ContractStatus;
|
||||
@@ -150,6 +150,8 @@ export declare function getAllContracts(filters: ContractFilters): Promise<{
|
||||
}>;
|
||||
export declare function getContractById(id: number, decryptPassword?: boolean): Promise<({
|
||||
customer: {
|
||||
portalPasswordHash: string | null;
|
||||
portalPasswordEncrypted: string | null;
|
||||
id: number;
|
||||
email: string | null;
|
||||
firstName: string;
|
||||
@@ -174,8 +176,6 @@ export declare function getContractById(id: number, decryptPassword?: boolean):
|
||||
privacyPolicyPath: string | null;
|
||||
notes: string | null;
|
||||
portalEnabled: boolean;
|
||||
portalPasswordHash: string | null;
|
||||
portalPasswordEncrypted: string | null;
|
||||
portalLastLogin: Date | null;
|
||||
};
|
||||
address: {
|
||||
@@ -230,13 +230,13 @@ export declare function getContractById(id: number, decryptPassword?: boolean):
|
||||
energyDetails: ({
|
||||
meter: ({
|
||||
readings: {
|
||||
value: number;
|
||||
id: number;
|
||||
createdAt: Date;
|
||||
notes: string | null;
|
||||
readingDate: Date;
|
||||
meterId: number;
|
||||
status: import(".prisma/client").$Enums.MeterReadingStatus;
|
||||
value: number;
|
||||
valueNt: number | null;
|
||||
unit: string;
|
||||
reportedBy: string | null;
|
||||
@@ -257,13 +257,13 @@ export declare function getContractById(id: number, decryptPassword?: boolean):
|
||||
contractMeters: ({
|
||||
meter: {
|
||||
readings: {
|
||||
value: number;
|
||||
id: number;
|
||||
createdAt: Date;
|
||||
notes: string | null;
|
||||
readingDate: Date;
|
||||
meterId: number;
|
||||
status: import(".prisma/client").$Enums.MeterReadingStatus;
|
||||
value: number;
|
||||
valueNt: number | null;
|
||||
unit: string;
|
||||
reportedBy: string | null;
|
||||
@@ -359,13 +359,13 @@ export declare function getContractById(id: number, decryptPassword?: boolean):
|
||||
energyDetails: ({
|
||||
meter: ({
|
||||
readings: {
|
||||
value: number;
|
||||
id: number;
|
||||
createdAt: Date;
|
||||
notes: string | null;
|
||||
readingDate: Date;
|
||||
meterId: number;
|
||||
status: import(".prisma/client").$Enums.MeterReadingStatus;
|
||||
value: number;
|
||||
valueNt: number | null;
|
||||
unit: string;
|
||||
reportedBy: string | null;
|
||||
@@ -386,13 +386,13 @@ export declare function getContractById(id: number, decryptPassword?: boolean):
|
||||
contractMeters: ({
|
||||
meter: {
|
||||
readings: {
|
||||
value: number;
|
||||
id: number;
|
||||
createdAt: Date;
|
||||
notes: string | null;
|
||||
readingDate: Date;
|
||||
meterId: number;
|
||||
status: import(".prisma/client").$Enums.MeterReadingStatus;
|
||||
value: number;
|
||||
valueNt: number | null;
|
||||
unit: string;
|
||||
reportedBy: string | null;
|
||||
@@ -446,15 +446,16 @@ export declare function getContractById(id: number, decryptPassword?: boolean):
|
||||
}) | null;
|
||||
internetDetails: ({
|
||||
phoneNumbers: {
|
||||
sipPasswordEncrypted: string | null;
|
||||
id: number;
|
||||
phoneNumber: string;
|
||||
isMain: boolean;
|
||||
sipUsername: string | null;
|
||||
sipPasswordEncrypted: string | null;
|
||||
sipServer: string | null;
|
||||
internetContractDetailsId: number;
|
||||
}[];
|
||||
} & {
|
||||
internetPasswordEncrypted: string | null;
|
||||
id: number;
|
||||
contractId: number;
|
||||
activationCode: string | null;
|
||||
@@ -465,18 +466,17 @@ export declare function getContractById(id: number, decryptPassword?: boolean):
|
||||
routerModel: string | null;
|
||||
installationDate: Date | null;
|
||||
internetUsername: string | null;
|
||||
internetPasswordEncrypted: string | null;
|
||||
}) | null;
|
||||
mobileDetails: ({
|
||||
simCards: {
|
||||
pin: string | null;
|
||||
puk: string | null;
|
||||
id: number;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
simCardNumber: string | null;
|
||||
phoneNumber: string | null;
|
||||
isMain: boolean;
|
||||
pin: string | null;
|
||||
puk: string | null;
|
||||
isMultisim: boolean;
|
||||
mobileDetailsId: number;
|
||||
}[];
|
||||
@@ -516,13 +516,13 @@ export declare function getContractById(id: number, decryptPassword?: boolean):
|
||||
previousInsurer: string | null;
|
||||
} | null;
|
||||
} & {
|
||||
portalPasswordEncrypted: string | null;
|
||||
id: number;
|
||||
customerId: number;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
type: import(".prisma/client").$Enums.ContractType;
|
||||
notes: string | null;
|
||||
portalPasswordEncrypted: string | null;
|
||||
startDate: Date | null;
|
||||
contractNumber: string;
|
||||
status: import(".prisma/client").$Enums.ContractStatus;
|
||||
@@ -594,6 +594,7 @@ export declare function getContractById(id: number, decryptPassword?: boolean):
|
||||
providerId: number;
|
||||
} | null;
|
||||
stressfreiEmail: {
|
||||
emailPasswordEncrypted: string | null;
|
||||
id: number;
|
||||
email: string;
|
||||
customerId: number;
|
||||
@@ -606,19 +607,19 @@ export declare function getContractById(id: number, decryptPassword?: boolean):
|
||||
isProvisioned: boolean;
|
||||
provisionedAt: Date | null;
|
||||
provisionError: string | null;
|
||||
emailPasswordEncrypted: string | null;
|
||||
} | null;
|
||||
internetDetails: ({
|
||||
phoneNumbers: {
|
||||
sipPasswordEncrypted: string | null;
|
||||
id: number;
|
||||
phoneNumber: string;
|
||||
isMain: boolean;
|
||||
sipUsername: string | null;
|
||||
sipPasswordEncrypted: string | null;
|
||||
sipServer: string | null;
|
||||
internetContractDetailsId: number;
|
||||
}[];
|
||||
} & {
|
||||
internetPasswordEncrypted: string | null;
|
||||
id: number;
|
||||
contractId: number;
|
||||
activationCode: string | null;
|
||||
@@ -629,18 +630,17 @@ export declare function getContractById(id: number, decryptPassword?: boolean):
|
||||
routerModel: string | null;
|
||||
installationDate: Date | null;
|
||||
internetUsername: string | null;
|
||||
internetPasswordEncrypted: string | null;
|
||||
}) | null;
|
||||
mobileDetails: ({
|
||||
simCards: {
|
||||
pin: string | null;
|
||||
puk: string | null;
|
||||
id: number;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
simCardNumber: string | null;
|
||||
phoneNumber: string | null;
|
||||
isMain: boolean;
|
||||
pin: string | null;
|
||||
puk: string | null;
|
||||
isMultisim: boolean;
|
||||
mobileDetailsId: number;
|
||||
}[];
|
||||
@@ -680,13 +680,13 @@ export declare function getContractById(id: number, decryptPassword?: boolean):
|
||||
previousInsurer: string | null;
|
||||
} | null;
|
||||
} & {
|
||||
portalPasswordEncrypted: string | null;
|
||||
id: number;
|
||||
customerId: number;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
type: import(".prisma/client").$Enums.ContractType;
|
||||
notes: string | null;
|
||||
portalPasswordEncrypted: string | null;
|
||||
startDate: Date | null;
|
||||
contractNumber: string;
|
||||
status: import(".prisma/client").$Enums.ContractStatus;
|
||||
@@ -824,6 +824,8 @@ interface ContractCreateData {
|
||||
}
|
||||
export declare function createContract(data: ContractCreateData): Promise<{
|
||||
customer: {
|
||||
portalPasswordHash: string | null;
|
||||
portalPasswordEncrypted: string | null;
|
||||
id: number;
|
||||
email: string | null;
|
||||
firstName: string;
|
||||
@@ -848,8 +850,6 @@ export declare function createContract(data: ContractCreateData): Promise<{
|
||||
privacyPolicyPath: string | null;
|
||||
notes: string | null;
|
||||
portalEnabled: boolean;
|
||||
portalPasswordHash: string | null;
|
||||
portalPasswordEncrypted: string | null;
|
||||
portalLastLogin: Date | null;
|
||||
};
|
||||
address: {
|
||||
@@ -902,15 +902,16 @@ export declare function createContract(data: ContractCreateData): Promise<{
|
||||
} | null;
|
||||
internetDetails: ({
|
||||
phoneNumbers: {
|
||||
sipPasswordEncrypted: string | null;
|
||||
id: number;
|
||||
phoneNumber: string;
|
||||
isMain: boolean;
|
||||
sipUsername: string | null;
|
||||
sipPasswordEncrypted: string | null;
|
||||
sipServer: string | null;
|
||||
internetContractDetailsId: number;
|
||||
}[];
|
||||
} & {
|
||||
internetPasswordEncrypted: string | null;
|
||||
id: number;
|
||||
contractId: number;
|
||||
activationCode: string | null;
|
||||
@@ -921,18 +922,17 @@ export declare function createContract(data: ContractCreateData): Promise<{
|
||||
routerModel: string | null;
|
||||
installationDate: Date | null;
|
||||
internetUsername: string | null;
|
||||
internetPasswordEncrypted: string | null;
|
||||
}) | null;
|
||||
mobileDetails: ({
|
||||
simCards: {
|
||||
pin: string | null;
|
||||
puk: string | null;
|
||||
id: number;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
simCardNumber: string | null;
|
||||
phoneNumber: string | null;
|
||||
isMain: boolean;
|
||||
pin: string | null;
|
||||
puk: string | null;
|
||||
isMultisim: boolean;
|
||||
mobileDetailsId: number;
|
||||
}[];
|
||||
@@ -972,13 +972,13 @@ export declare function createContract(data: ContractCreateData): Promise<{
|
||||
previousInsurer: string | null;
|
||||
} | null;
|
||||
} & {
|
||||
portalPasswordEncrypted: string | null;
|
||||
id: number;
|
||||
customerId: number;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
type: import(".prisma/client").$Enums.ContractType;
|
||||
notes: string | null;
|
||||
portalPasswordEncrypted: string | null;
|
||||
startDate: Date | null;
|
||||
contractNumber: string;
|
||||
status: import(".prisma/client").$Enums.ContractStatus;
|
||||
@@ -1018,6 +1018,8 @@ export declare function createContract(data: ContractCreateData): Promise<{
|
||||
}>;
|
||||
export declare function updateContract(id: number, data: Partial<ContractCreateData>): Promise<({
|
||||
customer: {
|
||||
portalPasswordHash: string | null;
|
||||
portalPasswordEncrypted: string | null;
|
||||
id: number;
|
||||
email: string | null;
|
||||
firstName: string;
|
||||
@@ -1042,8 +1044,6 @@ export declare function updateContract(id: number, data: Partial<ContractCreateD
|
||||
privacyPolicyPath: string | null;
|
||||
notes: string | null;
|
||||
portalEnabled: boolean;
|
||||
portalPasswordHash: string | null;
|
||||
portalPasswordEncrypted: string | null;
|
||||
portalLastLogin: Date | null;
|
||||
};
|
||||
address: {
|
||||
@@ -1098,13 +1098,13 @@ export declare function updateContract(id: number, data: Partial<ContractCreateD
|
||||
energyDetails: ({
|
||||
meter: ({
|
||||
readings: {
|
||||
value: number;
|
||||
id: number;
|
||||
createdAt: Date;
|
||||
notes: string | null;
|
||||
readingDate: Date;
|
||||
meterId: number;
|
||||
status: import(".prisma/client").$Enums.MeterReadingStatus;
|
||||
value: number;
|
||||
valueNt: number | null;
|
||||
unit: string;
|
||||
reportedBy: string | null;
|
||||
@@ -1125,13 +1125,13 @@ export declare function updateContract(id: number, data: Partial<ContractCreateD
|
||||
contractMeters: ({
|
||||
meter: {
|
||||
readings: {
|
||||
value: number;
|
||||
id: number;
|
||||
createdAt: Date;
|
||||
notes: string | null;
|
||||
readingDate: Date;
|
||||
meterId: number;
|
||||
status: import(".prisma/client").$Enums.MeterReadingStatus;
|
||||
value: number;
|
||||
valueNt: number | null;
|
||||
unit: string;
|
||||
reportedBy: string | null;
|
||||
@@ -1227,13 +1227,13 @@ export declare function updateContract(id: number, data: Partial<ContractCreateD
|
||||
energyDetails: ({
|
||||
meter: ({
|
||||
readings: {
|
||||
value: number;
|
||||
id: number;
|
||||
createdAt: Date;
|
||||
notes: string | null;
|
||||
readingDate: Date;
|
||||
meterId: number;
|
||||
status: import(".prisma/client").$Enums.MeterReadingStatus;
|
||||
value: number;
|
||||
valueNt: number | null;
|
||||
unit: string;
|
||||
reportedBy: string | null;
|
||||
@@ -1254,13 +1254,13 @@ export declare function updateContract(id: number, data: Partial<ContractCreateD
|
||||
contractMeters: ({
|
||||
meter: {
|
||||
readings: {
|
||||
value: number;
|
||||
id: number;
|
||||
createdAt: Date;
|
||||
notes: string | null;
|
||||
readingDate: Date;
|
||||
meterId: number;
|
||||
status: import(".prisma/client").$Enums.MeterReadingStatus;
|
||||
value: number;
|
||||
valueNt: number | null;
|
||||
unit: string;
|
||||
reportedBy: string | null;
|
||||
@@ -1314,15 +1314,16 @@ export declare function updateContract(id: number, data: Partial<ContractCreateD
|
||||
}) | null;
|
||||
internetDetails: ({
|
||||
phoneNumbers: {
|
||||
sipPasswordEncrypted: string | null;
|
||||
id: number;
|
||||
phoneNumber: string;
|
||||
isMain: boolean;
|
||||
sipUsername: string | null;
|
||||
sipPasswordEncrypted: string | null;
|
||||
sipServer: string | null;
|
||||
internetContractDetailsId: number;
|
||||
}[];
|
||||
} & {
|
||||
internetPasswordEncrypted: string | null;
|
||||
id: number;
|
||||
contractId: number;
|
||||
activationCode: string | null;
|
||||
@@ -1333,18 +1334,17 @@ export declare function updateContract(id: number, data: Partial<ContractCreateD
|
||||
routerModel: string | null;
|
||||
installationDate: Date | null;
|
||||
internetUsername: string | null;
|
||||
internetPasswordEncrypted: string | null;
|
||||
}) | null;
|
||||
mobileDetails: ({
|
||||
simCards: {
|
||||
pin: string | null;
|
||||
puk: string | null;
|
||||
id: number;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
simCardNumber: string | null;
|
||||
phoneNumber: string | null;
|
||||
isMain: boolean;
|
||||
pin: string | null;
|
||||
puk: string | null;
|
||||
isMultisim: boolean;
|
||||
mobileDetailsId: number;
|
||||
}[];
|
||||
@@ -1384,13 +1384,13 @@ export declare function updateContract(id: number, data: Partial<ContractCreateD
|
||||
previousInsurer: string | null;
|
||||
} | null;
|
||||
} & {
|
||||
portalPasswordEncrypted: string | null;
|
||||
id: number;
|
||||
customerId: number;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
type: import(".prisma/client").$Enums.ContractType;
|
||||
notes: string | null;
|
||||
portalPasswordEncrypted: string | null;
|
||||
startDate: Date | null;
|
||||
contractNumber: string;
|
||||
status: import(".prisma/client").$Enums.ContractStatus;
|
||||
@@ -1462,6 +1462,7 @@ export declare function updateContract(id: number, data: Partial<ContractCreateD
|
||||
providerId: number;
|
||||
} | null;
|
||||
stressfreiEmail: {
|
||||
emailPasswordEncrypted: string | null;
|
||||
id: number;
|
||||
email: string;
|
||||
customerId: number;
|
||||
@@ -1474,19 +1475,19 @@ export declare function updateContract(id: number, data: Partial<ContractCreateD
|
||||
isProvisioned: boolean;
|
||||
provisionedAt: Date | null;
|
||||
provisionError: string | null;
|
||||
emailPasswordEncrypted: string | null;
|
||||
} | null;
|
||||
internetDetails: ({
|
||||
phoneNumbers: {
|
||||
sipPasswordEncrypted: string | null;
|
||||
id: number;
|
||||
phoneNumber: string;
|
||||
isMain: boolean;
|
||||
sipUsername: string | null;
|
||||
sipPasswordEncrypted: string | null;
|
||||
sipServer: string | null;
|
||||
internetContractDetailsId: number;
|
||||
}[];
|
||||
} & {
|
||||
internetPasswordEncrypted: string | null;
|
||||
id: number;
|
||||
contractId: number;
|
||||
activationCode: string | null;
|
||||
@@ -1497,18 +1498,17 @@ export declare function updateContract(id: number, data: Partial<ContractCreateD
|
||||
routerModel: string | null;
|
||||
installationDate: Date | null;
|
||||
internetUsername: string | null;
|
||||
internetPasswordEncrypted: string | null;
|
||||
}) | null;
|
||||
mobileDetails: ({
|
||||
simCards: {
|
||||
pin: string | null;
|
||||
puk: string | null;
|
||||
id: number;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
simCardNumber: string | null;
|
||||
phoneNumber: string | null;
|
||||
isMain: boolean;
|
||||
pin: string | null;
|
||||
puk: string | null;
|
||||
isMultisim: boolean;
|
||||
mobileDetailsId: number;
|
||||
}[];
|
||||
@@ -1548,13 +1548,13 @@ export declare function updateContract(id: number, data: Partial<ContractCreateD
|
||||
previousInsurer: string | null;
|
||||
} | null;
|
||||
} & {
|
||||
portalPasswordEncrypted: string | null;
|
||||
id: number;
|
||||
customerId: number;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
type: import(".prisma/client").$Enums.ContractType;
|
||||
notes: string | null;
|
||||
portalPasswordEncrypted: string | null;
|
||||
startDate: Date | null;
|
||||
contractNumber: string;
|
||||
status: import(".prisma/client").$Enums.ContractStatus;
|
||||
@@ -1593,13 +1593,13 @@ export declare function updateContract(id: number, data: Partial<ContractCreateD
|
||||
nextReviewDate: Date | null;
|
||||
}) | null>;
|
||||
export declare function deleteContract(id: number): Promise<{
|
||||
portalPasswordEncrypted: string | null;
|
||||
id: number;
|
||||
customerId: number;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
type: import(".prisma/client").$Enums.ContractType;
|
||||
notes: string | null;
|
||||
portalPasswordEncrypted: string | null;
|
||||
startDate: Date | null;
|
||||
contractNumber: string;
|
||||
status: import(".prisma/client").$Enums.ContractStatus;
|
||||
@@ -1639,6 +1639,8 @@ export declare function deleteContract(id: number): Promise<{
|
||||
}>;
|
||||
export declare function createFollowUpContract(previousContractId: number): Promise<{
|
||||
customer: {
|
||||
portalPasswordHash: string | null;
|
||||
portalPasswordEncrypted: string | null;
|
||||
id: number;
|
||||
email: string | null;
|
||||
firstName: string;
|
||||
@@ -1663,8 +1665,6 @@ export declare function createFollowUpContract(previousContractId: number): Prom
|
||||
privacyPolicyPath: string | null;
|
||||
notes: string | null;
|
||||
portalEnabled: boolean;
|
||||
portalPasswordHash: string | null;
|
||||
portalPasswordEncrypted: string | null;
|
||||
portalLastLogin: Date | null;
|
||||
};
|
||||
address: {
|
||||
@@ -1717,15 +1717,16 @@ export declare function createFollowUpContract(previousContractId: number): Prom
|
||||
} | null;
|
||||
internetDetails: ({
|
||||
phoneNumbers: {
|
||||
sipPasswordEncrypted: string | null;
|
||||
id: number;
|
||||
phoneNumber: string;
|
||||
isMain: boolean;
|
||||
sipUsername: string | null;
|
||||
sipPasswordEncrypted: string | null;
|
||||
sipServer: string | null;
|
||||
internetContractDetailsId: number;
|
||||
}[];
|
||||
} & {
|
||||
internetPasswordEncrypted: string | null;
|
||||
id: number;
|
||||
contractId: number;
|
||||
activationCode: string | null;
|
||||
@@ -1736,18 +1737,17 @@ export declare function createFollowUpContract(previousContractId: number): Prom
|
||||
routerModel: string | null;
|
||||
installationDate: Date | null;
|
||||
internetUsername: string | null;
|
||||
internetPasswordEncrypted: string | null;
|
||||
}) | null;
|
||||
mobileDetails: ({
|
||||
simCards: {
|
||||
pin: string | null;
|
||||
puk: string | null;
|
||||
id: number;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
simCardNumber: string | null;
|
||||
phoneNumber: string | null;
|
||||
isMain: boolean;
|
||||
pin: string | null;
|
||||
puk: string | null;
|
||||
isMultisim: boolean;
|
||||
mobileDetailsId: number;
|
||||
}[];
|
||||
@@ -1787,13 +1787,13 @@ export declare function createFollowUpContract(previousContractId: number): Prom
|
||||
previousInsurer: string | null;
|
||||
} | null;
|
||||
} & {
|
||||
portalPasswordEncrypted: string | null;
|
||||
id: number;
|
||||
customerId: number;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
type: import(".prisma/client").$Enums.ContractType;
|
||||
notes: string | null;
|
||||
portalPasswordEncrypted: string | null;
|
||||
startDate: Date | null;
|
||||
contractNumber: string;
|
||||
status: import(".prisma/client").$Enums.ContractStatus;
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
+36
-33
@@ -1,4 +1,7 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getAllContracts = getAllContracts;
|
||||
exports.getContractById = getContractById;
|
||||
@@ -12,9 +15,9 @@ exports.getInternetCredentials = getInternetCredentials;
|
||||
exports.getSipCredentials = getSipCredentials;
|
||||
exports.getContractTreeForCustomer = getContractTreeForCustomer;
|
||||
const client_1 = require("@prisma/client");
|
||||
const prisma_js_1 = __importDefault(require("../lib/prisma.js"));
|
||||
const helpers_js_1 = require("../utils/helpers.js");
|
||||
const encryption_js_1 = require("../utils/encryption.js");
|
||||
const prisma = new client_1.PrismaClient();
|
||||
async function getAllContracts(filters) {
|
||||
const { customerId, customerIds, type, status, search, page = 1, limit = 20 } = filters;
|
||||
const { skip, take } = (0, helpers_js_1.paginate)(page, limit);
|
||||
@@ -72,7 +75,7 @@ async function getAllContracts(filters) {
|
||||
];
|
||||
}
|
||||
const [contracts, total] = await Promise.all([
|
||||
prisma.contract.findMany({
|
||||
prisma_js_1.default.contract.findMany({
|
||||
where,
|
||||
skip,
|
||||
take,
|
||||
@@ -97,7 +100,7 @@ async function getAllContracts(filters) {
|
||||
contractCategory: true,
|
||||
},
|
||||
}),
|
||||
prisma.contract.count({ where }),
|
||||
prisma_js_1.default.contract.count({ where }),
|
||||
]);
|
||||
return {
|
||||
contracts,
|
||||
@@ -105,7 +108,7 @@ async function getAllContracts(filters) {
|
||||
};
|
||||
}
|
||||
async function getContractById(id, decryptPassword = false) {
|
||||
const contract = await prisma.contract.findUnique({
|
||||
const contract = await prisma_js_1.default.contract.findUnique({
|
||||
where: { id },
|
||||
include: {
|
||||
customer: true,
|
||||
@@ -159,7 +162,7 @@ async function createContract(data) {
|
||||
const portalPasswordEncrypted = portalPassword
|
||||
? (0, encryption_js_1.encrypt)(portalPassword)
|
||||
: undefined;
|
||||
const contract = await prisma.contract.create({
|
||||
const contract = await prisma_js_1.default.contract.create({
|
||||
data: {
|
||||
...contractData,
|
||||
contractNumber: (0, helpers_js_1.generateContractNumber)(data.type),
|
||||
@@ -255,7 +258,7 @@ async function updateContract(id, data) {
|
||||
? (0, encryption_js_1.encrypt)(portalPassword)
|
||||
: undefined;
|
||||
// Update main contract
|
||||
await prisma.contract.update({
|
||||
await prisma_js_1.default.contract.update({
|
||||
where: { id },
|
||||
data: {
|
||||
...contractData,
|
||||
@@ -264,11 +267,11 @@ async function updateContract(id, data) {
|
||||
});
|
||||
// Update type-specific details
|
||||
if (energyDetails) {
|
||||
const existingEcd = await prisma.energyContractDetails.findUnique({
|
||||
const existingEcd = await prisma_js_1.default.energyContractDetails.findUnique({
|
||||
where: { contractId: id },
|
||||
select: { id: true, meterId: true },
|
||||
});
|
||||
await prisma.energyContractDetails.upsert({
|
||||
await prisma_js_1.default.energyContractDetails.upsert({
|
||||
where: { contractId: id },
|
||||
update: energyDetails,
|
||||
create: { contractId: id, ...energyDetails },
|
||||
@@ -279,16 +282,16 @@ async function updateContract(id, data) {
|
||||
const newMeterId = energyDetails.meterId;
|
||||
if (oldMeterId !== newMeterId) {
|
||||
// Alle alten ContractMeter-Einträge entfernen
|
||||
await prisma.contractMeter.deleteMany({
|
||||
await prisma_js_1.default.contractMeter.deleteMany({
|
||||
where: { energyContractDetailsId: existingEcd.id },
|
||||
});
|
||||
// Neuen ContractMeter-Eintrag erstellen (wenn ein Zähler gesetzt)
|
||||
if (newMeterId) {
|
||||
const contract = await prisma.contract.findUnique({
|
||||
const contract = await prisma_js_1.default.contract.findUnique({
|
||||
where: { id },
|
||||
select: { startDate: true },
|
||||
});
|
||||
await prisma.contractMeter.create({
|
||||
await prisma_js_1.default.contractMeter.create({
|
||||
data: {
|
||||
energyContractDetailsId: existingEcd.id,
|
||||
meterId: newMeterId,
|
||||
@@ -302,7 +305,7 @@ async function updateContract(id, data) {
|
||||
}
|
||||
if (internetDetails) {
|
||||
const { phoneNumbers, internetPassword, ...internetData } = internetDetails;
|
||||
const existing = await prisma.internetContractDetails.findUnique({
|
||||
const existing = await prisma_js_1.default.internetContractDetails.findUnique({
|
||||
where: { contractId: id },
|
||||
include: { phoneNumbers: true },
|
||||
});
|
||||
@@ -322,7 +325,7 @@ async function updateContract(id, data) {
|
||||
activationCode: internetData.activationCode,
|
||||
};
|
||||
if (existing) {
|
||||
await prisma.internetContractDetails.update({
|
||||
await prisma_js_1.default.internetContractDetails.update({
|
||||
where: { contractId: id },
|
||||
data: preparedInternetData,
|
||||
});
|
||||
@@ -330,11 +333,11 @@ async function updateContract(id, data) {
|
||||
// Get existing phone numbers for preserving encrypted passwords
|
||||
const existingPhoneNumbers = existing.phoneNumbers || [];
|
||||
// Delete all existing phone numbers
|
||||
await prisma.phoneNumber.deleteMany({
|
||||
await prisma_js_1.default.phoneNumber.deleteMany({
|
||||
where: { internetContractDetailsId: existing.id },
|
||||
});
|
||||
// Create new phone numbers with encryption
|
||||
await prisma.phoneNumber.createMany({
|
||||
await prisma_js_1.default.phoneNumber.createMany({
|
||||
data: phoneNumbers.map((pn) => {
|
||||
// Find existing entry to preserve sipPassword if not changed
|
||||
const existingPn = pn.id
|
||||
@@ -356,7 +359,7 @@ async function updateContract(id, data) {
|
||||
}
|
||||
}
|
||||
else {
|
||||
await prisma.internetContractDetails.create({
|
||||
await prisma_js_1.default.internetContractDetails.create({
|
||||
data: {
|
||||
contractId: id,
|
||||
...preparedInternetData,
|
||||
@@ -382,26 +385,26 @@ async function updateContract(id, data) {
|
||||
}
|
||||
if (mobileDetails) {
|
||||
const { simCards, ...mobileData } = mobileDetails;
|
||||
const existing = await prisma.mobileContractDetails.findUnique({
|
||||
const existing = await prisma_js_1.default.mobileContractDetails.findUnique({
|
||||
where: { contractId: id },
|
||||
});
|
||||
if (existing) {
|
||||
await prisma.mobileContractDetails.update({
|
||||
await prisma_js_1.default.mobileContractDetails.update({
|
||||
where: { contractId: id },
|
||||
data: mobileData,
|
||||
});
|
||||
if (simCards) {
|
||||
// Get existing sim cards to preserve PIN/PUK if not provided
|
||||
const existingSimCards = await prisma.simCard.findMany({
|
||||
const existingSimCards = await prisma_js_1.default.simCard.findMany({
|
||||
where: { mobileDetailsId: existing.id },
|
||||
});
|
||||
const existingSimCardMap = new Map(existingSimCards.map(sc => [sc.id, sc]));
|
||||
// Delete existing sim cards
|
||||
await prisma.simCard.deleteMany({
|
||||
await prisma_js_1.default.simCard.deleteMany({
|
||||
where: { mobileDetailsId: existing.id },
|
||||
});
|
||||
// Create new sim cards, preserving PIN/PUK if not provided
|
||||
await prisma.simCard.createMany({
|
||||
await prisma_js_1.default.simCard.createMany({
|
||||
data: simCards.map((sc) => {
|
||||
const existingSc = sc.id ? existingSimCardMap.get(sc.id) : undefined;
|
||||
return {
|
||||
@@ -419,7 +422,7 @@ async function updateContract(id, data) {
|
||||
}
|
||||
}
|
||||
else {
|
||||
await prisma.mobileContractDetails.create({
|
||||
await prisma_js_1.default.mobileContractDetails.create({
|
||||
data: {
|
||||
contractId: id,
|
||||
...mobileData,
|
||||
@@ -440,14 +443,14 @@ async function updateContract(id, data) {
|
||||
}
|
||||
}
|
||||
if (tvDetails) {
|
||||
await prisma.tvContractDetails.upsert({
|
||||
await prisma_js_1.default.tvContractDetails.upsert({
|
||||
where: { contractId: id },
|
||||
update: tvDetails,
|
||||
create: { contractId: id, ...tvDetails },
|
||||
});
|
||||
}
|
||||
if (carInsuranceDetails) {
|
||||
await prisma.carInsuranceDetails.upsert({
|
||||
await prisma_js_1.default.carInsuranceDetails.upsert({
|
||||
where: { contractId: id },
|
||||
update: carInsuranceDetails,
|
||||
create: { contractId: id, ...carInsuranceDetails },
|
||||
@@ -459,17 +462,17 @@ async function deleteContract(id) {
|
||||
// Vertragskette erhalten beim Löschen:
|
||||
// Wenn A → B → C und B gelöscht wird, soll C direkt auf A zeigen (A → C)
|
||||
// 1. Zu löschenden Vertrag holen um dessen Vorgänger zu kennen
|
||||
const contractToDelete = await prisma.contract.findUnique({
|
||||
const contractToDelete = await prisma_js_1.default.contract.findUnique({
|
||||
where: { id },
|
||||
select: { previousContractId: true },
|
||||
});
|
||||
// 2. Folgevertrag(e) mit dem Vorgänger des gelöschten Vertrags verbinden
|
||||
// So bleibt die Kette erhalten: A → B → C wird zu A → C
|
||||
await prisma.contract.updateMany({
|
||||
await prisma_js_1.default.contract.updateMany({
|
||||
where: { previousContractId: id },
|
||||
data: { previousContractId: contractToDelete?.previousContractId ?? null },
|
||||
});
|
||||
return prisma.contract.delete({ where: { id } });
|
||||
return prisma_js_1.default.contract.delete({ where: { id } });
|
||||
}
|
||||
async function createFollowUpContract(previousContractId) {
|
||||
const previousContract = await getContractById(previousContractId);
|
||||
@@ -477,7 +480,7 @@ async function createFollowUpContract(previousContractId) {
|
||||
throw new Error('Vorgängervertrag nicht gefunden');
|
||||
}
|
||||
// Prüfen ob bereits ein Folgevertrag existiert
|
||||
const existingFollowUp = await prisma.contract.findFirst({
|
||||
const existingFollowUp = await prisma_js_1.default.contract.findFirst({
|
||||
where: { previousContractId },
|
||||
select: { id: true, contractNumber: true },
|
||||
});
|
||||
@@ -568,7 +571,7 @@ async function createFollowUpContract(previousContractId) {
|
||||
}
|
||||
// Decrypt password for viewing
|
||||
async function getContractPassword(id) {
|
||||
const contract = await prisma.contract.findUnique({
|
||||
const contract = await prisma_js_1.default.contract.findUnique({
|
||||
where: { id },
|
||||
select: { portalPasswordEncrypted: true },
|
||||
});
|
||||
@@ -583,7 +586,7 @@ async function getContractPassword(id) {
|
||||
}
|
||||
// Decrypt SimCard PIN/PUK
|
||||
async function getSimCardCredentials(simCardId) {
|
||||
const simCard = await prisma.simCard.findUnique({
|
||||
const simCard = await prisma_js_1.default.simCard.findUnique({
|
||||
where: { id: simCardId },
|
||||
select: { pin: true, puk: true },
|
||||
});
|
||||
@@ -601,7 +604,7 @@ async function getSimCardCredentials(simCardId) {
|
||||
}
|
||||
// Decrypt Internet password
|
||||
async function getInternetCredentials(contractId) {
|
||||
const internetDetails = await prisma.internetContractDetails.findUnique({
|
||||
const internetDetails = await prisma_js_1.default.internetContractDetails.findUnique({
|
||||
where: { contractId },
|
||||
select: { internetPasswordEncrypted: true },
|
||||
});
|
||||
@@ -618,7 +621,7 @@ async function getInternetCredentials(contractId) {
|
||||
}
|
||||
// Decrypt SIP password for a phone number
|
||||
async function getSipCredentials(phoneNumberId) {
|
||||
const phoneNumber = await prisma.phoneNumber.findUnique({
|
||||
const phoneNumber = await prisma_js_1.default.phoneNumber.findUnique({
|
||||
where: { id: phoneNumberId },
|
||||
select: { sipPasswordEncrypted: true },
|
||||
});
|
||||
@@ -640,7 +643,7 @@ async function getSipCredentials(phoneNumberId) {
|
||||
*/
|
||||
async function getContractTreeForCustomer(customerId) {
|
||||
// Alle Verträge des Kunden laden (außer DEACTIVATED)
|
||||
const allContracts = await prisma.contract.findMany({
|
||||
const allContracts = await prisma_js_1.default.contract.findMany({
|
||||
where: {
|
||||
customerId,
|
||||
status: { not: client_1.ContractStatus.DEACTIVATED },
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"file":"contractCategory.service.d.ts","sourceRoot":"","sources":["../../src/services/contractCategory.service.ts"],"names":[],"mappings":"AAIA,wBAAsB,wBAAwB,CAAC,eAAe,UAAQ;;;;;;;;;;;;;;MAUrE;AAED,wBAAsB,uBAAuB,CAAC,EAAE,EAAE,MAAM;;;;;;;;;;;;;;WASvD;AAED,wBAAsB,yBAAyB,CAAC,IAAI,EAAE,MAAM;;;;;;;;;;UAI3D;AAED,UAAU,0BAA0B;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,wBAAsB,sBAAsB,CAAC,IAAI,EAAE,0BAA0B;;;;;;;;;;;;;;GAS5E;AAED,wBAAsB,sBAAsB,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,0BAA0B,CAAC;;;;;;;;;;;;;;GAUjG;AAED,wBAAsB,sBAAsB,CAAC,EAAE,EAAE,MAAM;;;;;;;;;;GAYtD"}
|
||||
{"version":3,"file":"contractCategory.service.d.ts","sourceRoot":"","sources":["../../src/services/contractCategory.service.ts"],"names":[],"mappings":"AAEA,wBAAsB,wBAAwB,CAAC,eAAe,UAAQ;;;;;;;;;;;;;;MAUrE;AAED,wBAAsB,uBAAuB,CAAC,EAAE,EAAE,MAAM;;;;;;;;;;;;;;WASvD;AAED,wBAAsB,yBAAyB,CAAC,IAAI,EAAE,MAAM;;;;;;;;;;UAI3D;AAED,UAAU,0BAA0B;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,wBAAsB,sBAAsB,CAAC,IAAI,EAAE,0BAA0B;;;;;;;;;;;;;;GAS5E;AAED,wBAAsB,sBAAsB,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,0BAA0B,CAAC;;;;;;;;;;;;;;GAUjG;AAED,wBAAsB,sBAAsB,CAAC,EAAE,EAAE,MAAM;;;;;;;;;;GAYtD"}
|
||||
+11
-9
@@ -1,4 +1,7 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getAllContractCategories = getAllContractCategories;
|
||||
exports.getContractCategoryById = getContractCategoryById;
|
||||
@@ -6,10 +9,9 @@ exports.getContractCategoryByCode = getContractCategoryByCode;
|
||||
exports.createContractCategory = createContractCategory;
|
||||
exports.updateContractCategory = updateContractCategory;
|
||||
exports.deleteContractCategory = deleteContractCategory;
|
||||
const client_1 = require("@prisma/client");
|
||||
const prisma = new client_1.PrismaClient();
|
||||
const prisma_js_1 = __importDefault(require("../lib/prisma.js"));
|
||||
async function getAllContractCategories(includeInactive = false) {
|
||||
return prisma.contractCategory.findMany({
|
||||
return prisma_js_1.default.contractCategory.findMany({
|
||||
where: includeInactive ? {} : { isActive: true },
|
||||
orderBy: [{ sortOrder: 'asc' }, { name: 'asc' }],
|
||||
include: {
|
||||
@@ -20,7 +22,7 @@ async function getAllContractCategories(includeInactive = false) {
|
||||
});
|
||||
}
|
||||
async function getContractCategoryById(id) {
|
||||
return prisma.contractCategory.findUnique({
|
||||
return prisma_js_1.default.contractCategory.findUnique({
|
||||
where: { id },
|
||||
include: {
|
||||
_count: {
|
||||
@@ -30,12 +32,12 @@ async function getContractCategoryById(id) {
|
||||
});
|
||||
}
|
||||
async function getContractCategoryByCode(code) {
|
||||
return prisma.contractCategory.findUnique({
|
||||
return prisma_js_1.default.contractCategory.findUnique({
|
||||
where: { code },
|
||||
});
|
||||
}
|
||||
async function createContractCategory(data) {
|
||||
return prisma.contractCategory.create({
|
||||
return prisma_js_1.default.contractCategory.create({
|
||||
data,
|
||||
include: {
|
||||
_count: {
|
||||
@@ -45,7 +47,7 @@ async function createContractCategory(data) {
|
||||
});
|
||||
}
|
||||
async function updateContractCategory(id, data) {
|
||||
return prisma.contractCategory.update({
|
||||
return prisma_js_1.default.contractCategory.update({
|
||||
where: { id },
|
||||
data,
|
||||
include: {
|
||||
@@ -57,13 +59,13 @@ async function updateContractCategory(id, data) {
|
||||
}
|
||||
async function deleteContractCategory(id) {
|
||||
// Check if category has contracts
|
||||
const category = await prisma.contractCategory.findUnique({
|
||||
const category = await prisma_js_1.default.contractCategory.findUnique({
|
||||
where: { id },
|
||||
include: { _count: { select: { contracts: true } } },
|
||||
});
|
||||
if (category && category._count.contracts > 0) {
|
||||
throw new Error(`Kategorie kann nicht gelöscht werden, da ${category._count.contracts} Verträge zugeordnet sind.`);
|
||||
}
|
||||
return prisma.contractCategory.delete({ where: { id } });
|
||||
return prisma_js_1.default.contractCategory.delete({ where: { id } });
|
||||
}
|
||||
//# sourceMappingURL=contractCategory.service.js.map
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"file":"contractCategory.service.js","sourceRoot":"","sources":["../../src/services/contractCategory.service.ts"],"names":[],"mappings":";;AAIA,4DAUC;AAED,0DASC;AAED,8DAIC;AAWD,wDASC;AAED,wDAUC;AAED,wDAYC;AA7ED,2CAA8C;AAE9C,MAAM,MAAM,GAAG,IAAI,qBAAY,EAAE,CAAC;AAE3B,KAAK,UAAU,wBAAwB,CAAC,eAAe,GAAG,KAAK;IACpE,OAAO,MAAM,CAAC,gBAAgB,CAAC,QAAQ,CAAC;QACtC,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE;QAChD,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;QAChD,OAAO,EAAE;YACP,MAAM,EAAE;gBACN,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE;aAC5B;SACF;KACF,CAAC,CAAC;AACL,CAAC;AAEM,KAAK,UAAU,uBAAuB,CAAC,EAAU;IACtD,OAAO,MAAM,CAAC,gBAAgB,CAAC,UAAU,CAAC;QACxC,KAAK,EAAE,EAAE,EAAE,EAAE;QACb,OAAO,EAAE;YACP,MAAM,EAAE;gBACN,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE;aAC5B;SACF;KACF,CAAC,CAAC;AACL,CAAC;AAEM,KAAK,UAAU,yBAAyB,CAAC,IAAY;IAC1D,OAAO,MAAM,CAAC,gBAAgB,CAAC,UAAU,CAAC;QACxC,KAAK,EAAE,EAAE,IAAI,EAAE;KAChB,CAAC,CAAC;AACL,CAAC;AAWM,KAAK,UAAU,sBAAsB,CAAC,IAAgC;IAC3E,OAAO,MAAM,CAAC,gBAAgB,CAAC,MAAM,CAAC;QACpC,IAAI;QACJ,OAAO,EAAE;YACP,MAAM,EAAE;gBACN,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE;aAC5B;SACF;KACF,CAAC,CAAC;AACL,CAAC;AAEM,KAAK,UAAU,sBAAsB,CAAC,EAAU,EAAE,IAAyC;IAChG,OAAO,MAAM,CAAC,gBAAgB,CAAC,MAAM,CAAC;QACpC,KAAK,EAAE,EAAE,EAAE,EAAE;QACb,IAAI;QACJ,OAAO,EAAE;YACP,MAAM,EAAE;gBACN,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE;aAC5B;SACF;KACF,CAAC,CAAC;AACL,CAAC;AAEM,KAAK,UAAU,sBAAsB,CAAC,EAAU;IACrD,kCAAkC;IAClC,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,gBAAgB,CAAC,UAAU,CAAC;QACxD,KAAK,EAAE,EAAE,EAAE,EAAE;QACb,OAAO,EAAE,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE;KACrD,CAAC,CAAC;IAEH,IAAI,QAAQ,IAAI,QAAQ,CAAC,MAAM,CAAC,SAAS,GAAG,CAAC,EAAE,CAAC;QAC9C,MAAM,IAAI,KAAK,CAAC,4CAA4C,QAAQ,CAAC,MAAM,CAAC,SAAS,4BAA4B,CAAC,CAAC;IACrH,CAAC;IAED,OAAO,MAAM,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;AAC3D,CAAC"}
|
||||
{"version":3,"file":"contractCategory.service.js","sourceRoot":"","sources":["../../src/services/contractCategory.service.ts"],"names":[],"mappings":";;;;;AAEA,4DAUC;AAED,0DASC;AAED,8DAIC;AAWD,wDASC;AAED,wDAUC;AAED,wDAYC;AA3ED,iEAAsC;AAE/B,KAAK,UAAU,wBAAwB,CAAC,eAAe,GAAG,KAAK;IACpE,OAAO,mBAAM,CAAC,gBAAgB,CAAC,QAAQ,CAAC;QACtC,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC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,QAAQ,GAAG,MAAM,mBAAM,CAAC,gBAAgB,CAAC,UAAU,CAAC;QACxD,KAAK,EAAE,EAAE,EAAE,EAAE;QACb,OAAO,EAAE,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE;KACrD,CAAC,CAAC;IAEH,IAAI,QAAQ,IAAI,QAAQ,CAAC,MAAM,CAAC,SAAS,GAAG,CAAC,EAAE,CAAC;QAC9C,MAAM,IAAI,KAAK,CAAC,4CAA4C,QAAQ,CAAC,MAAM,CAAC,SAAS,4BAA4B,CAAC,CAAC;IACrH,CAAC;IAED,OAAO,mBAAM,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;AAC3D,CAAC"}
|
||||
+1
-1
@@ -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,EAA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;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE;QACL,EAAE,EAAE,MAAM,CAAC;QACX,WAAW,EAAE,MAAM,CAAC;QACpB,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IACF,QAAQ,EAAE;QACR,EAAE,EAAE,MAAM,CAAC;QACX,cAAc,EAAE,MAAM,CAAC;QACvB,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IAEF,QAAQ,CAAC,EAAE;QACT,EAAE,EAAE,MAAM,CAAC;QACX,cAAc,EAAE,MAAM,CAAC;KACxB,CAAC;IAEF,cAAc,CAAC,EAAE;QACf,YAAY,EAAE,MAAM,CAAC;QACrB,SAAS,EAAE,MAAM,CAAC;QAClB,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,CAAC;CACH;AAED,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,eAAe,EAAE,CAAC;IAC7B,cAAc,EAAE,aAAa,EAAE,CAAC;IAChC,gBAAgB,EAAE,oBAAoB,EAAE,CAAC;IACzC,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,CAsjB7D"}
|
||||
{"version":3,"file":"contractCockpit.service.d.ts","sourceRoot":"","sources":["../../src/services/contractCockpit.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAKhD,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,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ACH;AAyED,wBAAsB,cAAc,IAAI,OAAO,CAAC,aAAa,CAAC,CAsjB7D"}
|
||||
+9
-7
@@ -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: {
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"file":"contractTask.service.d.ts","sourceRoot":"","sources":["../../src/services/contractTask.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAIlE,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,kBAAkB,CAAC;IAC5B,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;CACjC;AAED,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,mBAAmB;;;;;;;;;;;;;;;;;;;;;;MAgCpE;AAED,wBAAsB,WAAW,CAAC,EAAE,EAAE,MAAM;;;;;;;;;;;UAI3C;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE;IACrC,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,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C,EAAE,EAAE,MAAM;;;;;;;;;;;GAI1C;AAID,wBAAsB,aAAa,CAAC,IAAI,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE;;;;;;;;;GAQ9F;AAED,wBAAsB,aAAa,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE;;;;;;;;;GAKvE;AAED,wBAAsB,eAAe,CAAC,EAAE,EAAE,MAAM;;;;;;;;;GA8B/C;AAED,wBAAsB,aAAa,CAAC,EAAE,EAAE,MAAM;;;;;;;;;GA0B7C;AAED,wBAAsB,aAAa,CAAC,EAAE,EAAE,MAAM;;;;;;;;;GAI7C;AAED,wBAAsB,cAAc,CAAC,EAAE,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;WAK9C;AAID,MAAM,WAAW,eAAe;IAC9B,MAAM,CAAC,EAAE,kBAAkB,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,yBAAyB,CAAC,EAAE,MAAM,EAAE,CAAC;IACrC,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;CACjC;AAED,wBAAsB,WAAW,CAAC,OAAO,EAAE,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAoEzD;AAED,wBAAsB,YAAY,CAAC,OAAO,EAAE,eAAe;;GA6B1D"}
|
||||
+23
-21
@@ -1,4 +1,7 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getTasksByContract = getTasksByContract;
|
||||
exports.getTaskById = getTaskById;
|
||||
@@ -15,8 +18,7 @@ exports.deleteSubtask = deleteSubtask;
|
||||
exports.getSubtaskById = getSubtaskById;
|
||||
exports.getAllTasks = getAllTasks;
|
||||
exports.getTaskStats = getTaskStats;
|
||||
const client_1 = require("@prisma/client");
|
||||
const prisma = new client_1.PrismaClient();
|
||||
const prisma_js_1 = __importDefault(require("../lib/prisma.js"));
|
||||
async function getTasksByContract(filters) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const where = {
|
||||
@@ -38,7 +40,7 @@ async function getTasksByContract(filters) {
|
||||
else if (filters.visibleInPortal !== undefined) {
|
||||
where.visibleInPortal = filters.visibleInPortal;
|
||||
}
|
||||
return prisma.contractTask.findMany({
|
||||
return prisma_js_1.default.contractTask.findMany({
|
||||
where,
|
||||
include: {
|
||||
subtasks: {
|
||||
@@ -49,12 +51,12 @@ async function getTasksByContract(filters) {
|
||||
});
|
||||
}
|
||||
async function getTaskById(id) {
|
||||
return prisma.contractTask.findUnique({
|
||||
return prisma_js_1.default.contractTask.findUnique({
|
||||
where: { id },
|
||||
});
|
||||
}
|
||||
async function createTask(data) {
|
||||
return prisma.contractTask.create({
|
||||
return prisma_js_1.default.contractTask.create({
|
||||
data: {
|
||||
contractId: data.contractId,
|
||||
title: data.title,
|
||||
@@ -65,13 +67,13 @@ async function createTask(data) {
|
||||
});
|
||||
}
|
||||
async function updateTask(id, data) {
|
||||
return prisma.contractTask.update({
|
||||
return prisma_js_1.default.contractTask.update({
|
||||
where: { id },
|
||||
data,
|
||||
});
|
||||
}
|
||||
async function completeTask(id) {
|
||||
return prisma.contractTask.update({
|
||||
return prisma_js_1.default.contractTask.update({
|
||||
where: { id },
|
||||
data: {
|
||||
status: 'COMPLETED',
|
||||
@@ -80,7 +82,7 @@ async function completeTask(id) {
|
||||
});
|
||||
}
|
||||
async function reopenTask(id) {
|
||||
return prisma.contractTask.update({
|
||||
return prisma_js_1.default.contractTask.update({
|
||||
where: { id },
|
||||
data: {
|
||||
status: 'OPEN',
|
||||
@@ -89,13 +91,13 @@ async function reopenTask(id) {
|
||||
});
|
||||
}
|
||||
async function deleteTask(id) {
|
||||
return prisma.contractTask.delete({
|
||||
return prisma_js_1.default.contractTask.delete({
|
||||
where: { id },
|
||||
});
|
||||
}
|
||||
// ==================== SUBTASKS ====================
|
||||
async function createSubtask(data) {
|
||||
return prisma.contractTaskSubtask.create({
|
||||
return prisma_js_1.default.contractTaskSubtask.create({
|
||||
data: {
|
||||
taskId: data.taskId,
|
||||
title: data.title,
|
||||
@@ -104,14 +106,14 @@ async function createSubtask(data) {
|
||||
});
|
||||
}
|
||||
async function updateSubtask(id, data) {
|
||||
return prisma.contractTaskSubtask.update({
|
||||
return prisma_js_1.default.contractTaskSubtask.update({
|
||||
where: { id },
|
||||
data,
|
||||
});
|
||||
}
|
||||
async function completeSubtask(id) {
|
||||
// Complete the subtask
|
||||
const subtask = await prisma.contractTaskSubtask.update({
|
||||
const subtask = await prisma_js_1.default.contractTaskSubtask.update({
|
||||
where: { id },
|
||||
data: {
|
||||
status: 'COMPLETED',
|
||||
@@ -119,7 +121,7 @@ async function completeSubtask(id) {
|
||||
},
|
||||
});
|
||||
// Check if all subtasks of the parent task are now completed
|
||||
const remainingOpenSubtasks = await prisma.contractTaskSubtask.count({
|
||||
const remainingOpenSubtasks = await prisma_js_1.default.contractTaskSubtask.count({
|
||||
where: {
|
||||
taskId: subtask.taskId,
|
||||
status: 'OPEN',
|
||||
@@ -127,7 +129,7 @@ async function completeSubtask(id) {
|
||||
});
|
||||
// If no open subtasks remain, automatically complete the parent task
|
||||
if (remainingOpenSubtasks === 0) {
|
||||
await prisma.contractTask.update({
|
||||
await prisma_js_1.default.contractTask.update({
|
||||
where: { id: subtask.taskId },
|
||||
data: {
|
||||
status: 'COMPLETED',
|
||||
@@ -139,7 +141,7 @@ async function completeSubtask(id) {
|
||||
}
|
||||
async function reopenSubtask(id) {
|
||||
// Reopen the subtask
|
||||
const subtask = await prisma.contractTaskSubtask.update({
|
||||
const subtask = await prisma_js_1.default.contractTaskSubtask.update({
|
||||
where: { id },
|
||||
data: {
|
||||
status: 'OPEN',
|
||||
@@ -147,11 +149,11 @@ async function reopenSubtask(id) {
|
||||
},
|
||||
});
|
||||
// If the parent task was completed, reopen it as well
|
||||
const parentTask = await prisma.contractTask.findUnique({
|
||||
const parentTask = await prisma_js_1.default.contractTask.findUnique({
|
||||
where: { id: subtask.taskId },
|
||||
});
|
||||
if (parentTask?.status === 'COMPLETED') {
|
||||
await prisma.contractTask.update({
|
||||
await prisma_js_1.default.contractTask.update({
|
||||
where: { id: subtask.taskId },
|
||||
data: {
|
||||
status: 'OPEN',
|
||||
@@ -162,12 +164,12 @@ async function reopenSubtask(id) {
|
||||
return subtask;
|
||||
}
|
||||
async function deleteSubtask(id) {
|
||||
return prisma.contractTaskSubtask.delete({
|
||||
return prisma_js_1.default.contractTaskSubtask.delete({
|
||||
where: { id },
|
||||
});
|
||||
}
|
||||
async function getSubtaskById(id) {
|
||||
return prisma.contractTaskSubtask.findUnique({
|
||||
return prisma_js_1.default.contractTaskSubtask.findUnique({
|
||||
where: { id },
|
||||
include: { task: true },
|
||||
});
|
||||
@@ -200,7 +202,7 @@ async function getAllTasks(filters) {
|
||||
customerId: filters.customerId,
|
||||
};
|
||||
}
|
||||
return prisma.contractTask.findMany({
|
||||
return prisma_js_1.default.contractTask.findMany({
|
||||
where,
|
||||
include: {
|
||||
subtasks: {
|
||||
@@ -266,7 +268,7 @@ async function getTaskStats(filters) {
|
||||
customerId: filters.customerId,
|
||||
};
|
||||
}
|
||||
const openCount = await prisma.contractTask.count({ where });
|
||||
const openCount = await prisma_js_1.default.contractTask.count({ where });
|
||||
return { openCount };
|
||||
}
|
||||
//# sourceMappingURL=contractTask.service.js.map
|
||||
+1
-1
File diff suppressed because one or more lines are too long
+19
-19
@@ -24,6 +24,8 @@ export declare function getAllCustomers(filters: CustomerFilters): Promise<{
|
||||
contracts: number;
|
||||
};
|
||||
} & {
|
||||
portalPasswordHash: string | null;
|
||||
portalPasswordEncrypted: string | null;
|
||||
id: number;
|
||||
email: string | null;
|
||||
firstName: string;
|
||||
@@ -48,8 +50,6 @@ export declare function getAllCustomers(filters: CustomerFilters): Promise<{
|
||||
privacyPolicyPath: string | null;
|
||||
notes: string | null;
|
||||
portalEnabled: boolean;
|
||||
portalPasswordHash: string | null;
|
||||
portalPasswordEncrypted: string | null;
|
||||
portalLastLogin: Date | null;
|
||||
})[];
|
||||
pagination: {
|
||||
@@ -103,13 +103,13 @@ export declare function getCustomerById(id: number): Promise<({
|
||||
}[];
|
||||
meters: ({
|
||||
readings: {
|
||||
value: number;
|
||||
id: number;
|
||||
createdAt: Date;
|
||||
notes: string | null;
|
||||
readingDate: Date;
|
||||
meterId: number;
|
||||
status: import(".prisma/client").$Enums.MeterReadingStatus;
|
||||
value: number;
|
||||
valueNt: number | null;
|
||||
unit: string;
|
||||
reportedBy: string | null;
|
||||
@@ -128,6 +128,7 @@ export declare function getCustomerById(id: number): Promise<({
|
||||
location: string | null;
|
||||
})[];
|
||||
stressfreiEmails: {
|
||||
emailPasswordEncrypted: string | null;
|
||||
id: number;
|
||||
email: string;
|
||||
customerId: number;
|
||||
@@ -140,7 +141,6 @@ export declare function getCustomerById(id: number): Promise<({
|
||||
isProvisioned: boolean;
|
||||
provisionedAt: Date | null;
|
||||
provisionError: string | null;
|
||||
emailPasswordEncrypted: string | null;
|
||||
}[];
|
||||
contracts: ({
|
||||
address: {
|
||||
@@ -165,13 +165,13 @@ export declare function getCustomerById(id: number): Promise<({
|
||||
contactInfo: string | null;
|
||||
} | null;
|
||||
} & {
|
||||
portalPasswordEncrypted: string | null;
|
||||
id: number;
|
||||
customerId: number;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
type: import(".prisma/client").$Enums.ContractType;
|
||||
notes: string | null;
|
||||
portalPasswordEncrypted: string | null;
|
||||
startDate: Date | null;
|
||||
contractNumber: string;
|
||||
status: import(".prisma/client").$Enums.ContractStatus;
|
||||
@@ -210,6 +210,8 @@ export declare function getCustomerById(id: number): Promise<({
|
||||
nextReviewDate: Date | null;
|
||||
})[];
|
||||
} & {
|
||||
portalPasswordHash: string | null;
|
||||
portalPasswordEncrypted: string | null;
|
||||
id: number;
|
||||
email: string | null;
|
||||
firstName: string;
|
||||
@@ -234,8 +236,6 @@ export declare function getCustomerById(id: number): Promise<({
|
||||
privacyPolicyPath: string | null;
|
||||
notes: string | null;
|
||||
portalEnabled: boolean;
|
||||
portalPasswordHash: string | null;
|
||||
portalPasswordEncrypted: string | null;
|
||||
portalLastLogin: Date | null;
|
||||
}) | null>;
|
||||
export declare function getCustomersByIds(ids: number[]): Promise<{
|
||||
@@ -258,6 +258,8 @@ export declare function createCustomer(data: {
|
||||
commercialRegister?: string;
|
||||
notes?: string;
|
||||
}): Promise<{
|
||||
portalPasswordHash: string | null;
|
||||
portalPasswordEncrypted: string | null;
|
||||
id: number;
|
||||
email: string | null;
|
||||
firstName: string;
|
||||
@@ -282,8 +284,6 @@ export declare function createCustomer(data: {
|
||||
privacyPolicyPath: string | null;
|
||||
notes: string | null;
|
||||
portalEnabled: boolean;
|
||||
portalPasswordHash: string | null;
|
||||
portalPasswordEncrypted: string | null;
|
||||
portalLastLogin: Date | null;
|
||||
}>;
|
||||
export declare function updateCustomer(id: number, data: {
|
||||
@@ -302,6 +302,8 @@ export declare function updateCustomer(id: number, data: {
|
||||
commercialRegister?: string;
|
||||
notes?: string;
|
||||
}): Promise<{
|
||||
portalPasswordHash: string | null;
|
||||
portalPasswordEncrypted: string | null;
|
||||
id: number;
|
||||
email: string | null;
|
||||
firstName: string;
|
||||
@@ -326,11 +328,11 @@ export declare function updateCustomer(id: number, data: {
|
||||
privacyPolicyPath: string | null;
|
||||
notes: string | null;
|
||||
portalEnabled: boolean;
|
||||
portalPasswordHash: string | null;
|
||||
portalPasswordEncrypted: string | null;
|
||||
portalLastLogin: Date | null;
|
||||
}>;
|
||||
export declare function deleteCustomer(id: number): Promise<{
|
||||
portalPasswordHash: string | null;
|
||||
portalPasswordEncrypted: string | null;
|
||||
id: number;
|
||||
email: string | null;
|
||||
firstName: string;
|
||||
@@ -355,8 +357,6 @@ export declare function deleteCustomer(id: number): Promise<{
|
||||
privacyPolicyPath: string | null;
|
||||
notes: string | null;
|
||||
portalEnabled: boolean;
|
||||
portalPasswordHash: string | null;
|
||||
portalPasswordEncrypted: string | null;
|
||||
portalLastLogin: Date | null;
|
||||
}>;
|
||||
export declare function getCustomerAddresses(customerId: number): Promise<{
|
||||
@@ -571,13 +571,13 @@ export declare function deleteDocument(id: number): Promise<{
|
||||
}>;
|
||||
export declare function getCustomerMeters(customerId: number, showInactive?: boolean): Promise<({
|
||||
readings: {
|
||||
value: number;
|
||||
id: number;
|
||||
createdAt: Date;
|
||||
notes: string | null;
|
||||
readingDate: Date;
|
||||
meterId: number;
|
||||
status: import(".prisma/client").$Enums.MeterReadingStatus;
|
||||
value: number;
|
||||
valueNt: number | null;
|
||||
unit: string;
|
||||
reportedBy: string | null;
|
||||
@@ -644,13 +644,13 @@ export declare function addMeterReading(meterId: number, data: {
|
||||
unit?: string;
|
||||
notes?: string;
|
||||
}): Promise<{
|
||||
value: number;
|
||||
id: number;
|
||||
createdAt: Date;
|
||||
notes: string | null;
|
||||
readingDate: Date;
|
||||
meterId: number;
|
||||
status: import(".prisma/client").$Enums.MeterReadingStatus;
|
||||
value: number;
|
||||
valueNt: number | null;
|
||||
unit: string;
|
||||
reportedBy: string | null;
|
||||
@@ -658,13 +658,13 @@ export declare function addMeterReading(meterId: number, data: {
|
||||
transferredBy: string | null;
|
||||
}>;
|
||||
export declare function getMeterReadings(meterId: number): Promise<{
|
||||
value: number;
|
||||
id: number;
|
||||
createdAt: Date;
|
||||
notes: string | null;
|
||||
readingDate: Date;
|
||||
meterId: number;
|
||||
status: import(".prisma/client").$Enums.MeterReadingStatus;
|
||||
value: number;
|
||||
valueNt: number | null;
|
||||
unit: string;
|
||||
reportedBy: string | null;
|
||||
@@ -678,13 +678,13 @@ export declare function updateMeterReading(meterId: number, readingId: number, d
|
||||
unit?: string;
|
||||
notes?: string;
|
||||
}): Promise<{
|
||||
value: number;
|
||||
id: number;
|
||||
createdAt: Date;
|
||||
notes: string | null;
|
||||
readingDate: Date;
|
||||
meterId: number;
|
||||
status: import(".prisma/client").$Enums.MeterReadingStatus;
|
||||
value: number;
|
||||
valueNt: number | null;
|
||||
unit: string;
|
||||
reportedBy: string | null;
|
||||
@@ -692,13 +692,13 @@ export declare function updateMeterReading(meterId: number, readingId: number, d
|
||||
transferredBy: string | null;
|
||||
}>;
|
||||
export declare function deleteMeterReading(meterId: number, readingId: number): Promise<{
|
||||
value: number;
|
||||
id: number;
|
||||
createdAt: Date;
|
||||
notes: string | null;
|
||||
readingDate: Date;
|
||||
meterId: number;
|
||||
status: import(".prisma/client").$Enums.MeterReadingStatus;
|
||||
value: number;
|
||||
valueNt: number | null;
|
||||
unit: string;
|
||||
reportedBy: string | null;
|
||||
@@ -715,10 +715,10 @@ export declare function updatePortalSettings(customerId: number, data: {
|
||||
portalLastLogin: Date | null;
|
||||
}>;
|
||||
export declare function getPortalSettings(customerId: number): Promise<{
|
||||
portalPasswordHash: string | null;
|
||||
id: number;
|
||||
portalEmail: string | null;
|
||||
portalEnabled: boolean;
|
||||
portalPasswordHash: string | null;
|
||||
portalLastLogin: Date | null;
|
||||
} | null>;
|
||||
export declare function getCustomerRepresentatives(customerId: number): Promise<({
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
+50
-50
@@ -37,10 +37,10 @@ exports.addRepresentative = addRepresentative;
|
||||
exports.removeRepresentative = removeRepresentative;
|
||||
exports.searchCustomersForRepresentative = searchCustomersForRepresentative;
|
||||
const client_1 = require("@prisma/client");
|
||||
const prisma_js_1 = __importDefault(require("../lib/prisma.js"));
|
||||
const helpers_js_1 = require("../utils/helpers.js");
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const prisma = new client_1.PrismaClient();
|
||||
// Helper zum Löschen von Dateien
|
||||
function deleteFileIfExists(filePath) {
|
||||
if (!filePath)
|
||||
@@ -72,7 +72,7 @@ async function getAllCustomers(filters) {
|
||||
];
|
||||
}
|
||||
const [customers, total] = await Promise.all([
|
||||
prisma.customer.findMany({
|
||||
prisma_js_1.default.customer.findMany({
|
||||
where,
|
||||
skip,
|
||||
take,
|
||||
@@ -84,7 +84,7 @@ async function getAllCustomers(filters) {
|
||||
},
|
||||
},
|
||||
}),
|
||||
prisma.customer.count({ where }),
|
||||
prisma_js_1.default.customer.count({ where }),
|
||||
]);
|
||||
return {
|
||||
customers,
|
||||
@@ -92,7 +92,7 @@ async function getAllCustomers(filters) {
|
||||
};
|
||||
}
|
||||
async function getCustomerById(id) {
|
||||
return prisma.customer.findUnique({
|
||||
return prisma_js_1.default.customer.findUnique({
|
||||
where: { id },
|
||||
include: {
|
||||
addresses: true,
|
||||
@@ -122,7 +122,7 @@ async function getCustomerById(id) {
|
||||
});
|
||||
}
|
||||
async function getCustomersByIds(ids) {
|
||||
return prisma.customer.findMany({
|
||||
return prisma_js_1.default.customer.findMany({
|
||||
where: { id: { in: ids } },
|
||||
select: {
|
||||
id: true,
|
||||
@@ -131,7 +131,7 @@ async function getCustomersByIds(ids) {
|
||||
});
|
||||
}
|
||||
async function createCustomer(data) {
|
||||
return prisma.customer.create({
|
||||
return prisma_js_1.default.customer.create({
|
||||
data: {
|
||||
...data,
|
||||
customerNumber: (0, helpers_js_1.generateCustomerNumber)(),
|
||||
@@ -139,22 +139,22 @@ async function createCustomer(data) {
|
||||
});
|
||||
}
|
||||
async function updateCustomer(id, data) {
|
||||
return prisma.customer.update({
|
||||
return prisma_js_1.default.customer.update({
|
||||
where: { id },
|
||||
data,
|
||||
});
|
||||
}
|
||||
async function deleteCustomer(id) {
|
||||
// Vor dem Löschen: Alle Dokumente (Dateien) des Kunden löschen
|
||||
const customer = await prisma.customer.findUnique({
|
||||
const customer = await prisma_js_1.default.customer.findUnique({
|
||||
where: { id },
|
||||
select: { businessRegistrationPath: true, commercialRegisterPath: true, privacyPolicyPath: true },
|
||||
});
|
||||
const bankCards = await prisma.bankCard.findMany({
|
||||
const bankCards = await prisma_js_1.default.bankCard.findMany({
|
||||
where: { customerId: id },
|
||||
select: { documentPath: true },
|
||||
});
|
||||
const identityDocs = await prisma.identityDocument.findMany({
|
||||
const identityDocs = await prisma_js_1.default.identityDocument.findMany({
|
||||
where: { customerId: id },
|
||||
select: { documentPath: true },
|
||||
});
|
||||
@@ -172,13 +172,13 @@ async function deleteCustomer(id) {
|
||||
deleteFileIfExists(doc.documentPath);
|
||||
}
|
||||
// Jetzt DB-Eintrag löschen (Cascade löscht die verknüpften Einträge)
|
||||
return prisma.customer.delete({
|
||||
return prisma_js_1.default.customer.delete({
|
||||
where: { id },
|
||||
});
|
||||
}
|
||||
// Address operations
|
||||
async function getCustomerAddresses(customerId) {
|
||||
return prisma.address.findMany({
|
||||
return prisma_js_1.default.address.findMany({
|
||||
where: { customerId },
|
||||
orderBy: [{ isDefault: 'desc' }, { createdAt: 'desc' }],
|
||||
});
|
||||
@@ -186,12 +186,12 @@ async function getCustomerAddresses(customerId) {
|
||||
async function createAddress(customerId, data) {
|
||||
// If this is set as default, unset other defaults of same type
|
||||
if (data.isDefault) {
|
||||
await prisma.address.updateMany({
|
||||
await prisma_js_1.default.address.updateMany({
|
||||
where: { customerId, type: data.type },
|
||||
data: { isDefault: false },
|
||||
});
|
||||
}
|
||||
return prisma.address.create({
|
||||
return prisma_js_1.default.address.create({
|
||||
data: {
|
||||
customerId,
|
||||
...data,
|
||||
@@ -199,11 +199,11 @@ async function createAddress(customerId, data) {
|
||||
});
|
||||
}
|
||||
async function updateAddress(id, data) {
|
||||
const address = await prisma.address.findUnique({ where: { id } });
|
||||
const address = await prisma_js_1.default.address.findUnique({ where: { id } });
|
||||
if (!address)
|
||||
throw new Error('Adresse nicht gefunden');
|
||||
if (data.isDefault) {
|
||||
await prisma.address.updateMany({
|
||||
await prisma_js_1.default.address.updateMany({
|
||||
where: {
|
||||
customerId: address.customerId,
|
||||
type: data.type || address.type,
|
||||
@@ -212,13 +212,13 @@ async function updateAddress(id, data) {
|
||||
data: { isDefault: false },
|
||||
});
|
||||
}
|
||||
return prisma.address.update({
|
||||
return prisma_js_1.default.address.update({
|
||||
where: { id },
|
||||
data,
|
||||
});
|
||||
}
|
||||
async function deleteAddress(id) {
|
||||
return prisma.address.delete({ where: { id } });
|
||||
return prisma_js_1.default.address.delete({ where: { id } });
|
||||
}
|
||||
// Bank card operations
|
||||
async function getCustomerBankCards(customerId, showInactive = false) {
|
||||
@@ -226,13 +226,13 @@ async function getCustomerBankCards(customerId, showInactive = false) {
|
||||
if (!showInactive) {
|
||||
where.isActive = true;
|
||||
}
|
||||
return prisma.bankCard.findMany({
|
||||
return prisma_js_1.default.bankCard.findMany({
|
||||
where,
|
||||
orderBy: [{ isActive: 'desc' }, { createdAt: 'desc' }],
|
||||
});
|
||||
}
|
||||
async function createBankCard(customerId, data) {
|
||||
return prisma.bankCard.create({
|
||||
return prisma_js_1.default.bankCard.create({
|
||||
data: {
|
||||
customerId,
|
||||
...data,
|
||||
@@ -241,18 +241,18 @@ async function createBankCard(customerId, data) {
|
||||
});
|
||||
}
|
||||
async function updateBankCard(id, data) {
|
||||
return prisma.bankCard.update({
|
||||
return prisma_js_1.default.bankCard.update({
|
||||
where: { id },
|
||||
data,
|
||||
});
|
||||
}
|
||||
async function deleteBankCard(id) {
|
||||
// Erst Datei-Pfad holen, dann Datei löschen, dann DB-Eintrag löschen
|
||||
const bankCard = await prisma.bankCard.findUnique({ where: { id } });
|
||||
const bankCard = await prisma_js_1.default.bankCard.findUnique({ where: { id } });
|
||||
if (bankCard?.documentPath) {
|
||||
deleteFileIfExists(bankCard.documentPath);
|
||||
}
|
||||
return prisma.bankCard.delete({ where: { id } });
|
||||
return prisma_js_1.default.bankCard.delete({ where: { id } });
|
||||
}
|
||||
// Identity document operations
|
||||
async function getCustomerDocuments(customerId, showInactive = false) {
|
||||
@@ -260,13 +260,13 @@ async function getCustomerDocuments(customerId, showInactive = false) {
|
||||
if (!showInactive) {
|
||||
where.isActive = true;
|
||||
}
|
||||
return prisma.identityDocument.findMany({
|
||||
return prisma_js_1.default.identityDocument.findMany({
|
||||
where,
|
||||
orderBy: [{ isActive: 'desc' }, { createdAt: 'desc' }],
|
||||
});
|
||||
}
|
||||
async function createDocument(customerId, data) {
|
||||
return prisma.identityDocument.create({
|
||||
return prisma_js_1.default.identityDocument.create({
|
||||
data: {
|
||||
customerId,
|
||||
...data,
|
||||
@@ -275,18 +275,18 @@ async function createDocument(customerId, data) {
|
||||
});
|
||||
}
|
||||
async function updateDocument(id, data) {
|
||||
return prisma.identityDocument.update({
|
||||
return prisma_js_1.default.identityDocument.update({
|
||||
where: { id },
|
||||
data,
|
||||
});
|
||||
}
|
||||
async function deleteDocument(id) {
|
||||
// Erst Datei-Pfad holen, dann Datei löschen, dann DB-Eintrag löschen
|
||||
const document = await prisma.identityDocument.findUnique({ where: { id } });
|
||||
const document = await prisma_js_1.default.identityDocument.findUnique({ where: { id } });
|
||||
if (document?.documentPath) {
|
||||
deleteFileIfExists(document.documentPath);
|
||||
}
|
||||
return prisma.identityDocument.delete({ where: { id } });
|
||||
return prisma_js_1.default.identityDocument.delete({ where: { id } });
|
||||
}
|
||||
// Meter operations
|
||||
async function getCustomerMeters(customerId, showInactive = false) {
|
||||
@@ -294,7 +294,7 @@ async function getCustomerMeters(customerId, showInactive = false) {
|
||||
if (!showInactive) {
|
||||
where.isActive = true;
|
||||
}
|
||||
return prisma.meter.findMany({
|
||||
return prisma_js_1.default.meter.findMany({
|
||||
where,
|
||||
include: {
|
||||
readings: {
|
||||
@@ -306,7 +306,7 @@ async function getCustomerMeters(customerId, showInactive = false) {
|
||||
});
|
||||
}
|
||||
async function createMeter(customerId, data) {
|
||||
return prisma.meter.create({
|
||||
return prisma_js_1.default.meter.create({
|
||||
data: {
|
||||
customerId,
|
||||
...data,
|
||||
@@ -315,14 +315,14 @@ async function createMeter(customerId, data) {
|
||||
});
|
||||
}
|
||||
async function updateMeter(id, data) {
|
||||
return prisma.meter.update({
|
||||
return prisma_js_1.default.meter.update({
|
||||
where: { id },
|
||||
data,
|
||||
});
|
||||
}
|
||||
async function deleteMeter(id) {
|
||||
// Prüfen ob der Zähler noch an Verträgen hängt
|
||||
const linkedContracts = await prisma.contractMeter.findMany({
|
||||
const linkedContracts = await prisma_js_1.default.contractMeter.findMany({
|
||||
where: { meterId: id },
|
||||
include: { energyContractDetails: { include: { contract: { select: { contractNumber: true } } } } },
|
||||
});
|
||||
@@ -333,7 +333,7 @@ async function deleteMeter(id) {
|
||||
throw new Error(`Zähler kann nicht gelöscht werden – noch an Vertrag/Verträgen zugeordnet: ${contractNumbers}`);
|
||||
}
|
||||
// Auch direkte meterId-Referenz auf EnergyContractDetails prüfen
|
||||
const directLinks = await prisma.energyContractDetails.findMany({
|
||||
const directLinks = await prisma_js_1.default.energyContractDetails.findMany({
|
||||
where: { meterId: id },
|
||||
include: { contract: { select: { contractNumber: true } } },
|
||||
});
|
||||
@@ -341,7 +341,7 @@ async function deleteMeter(id) {
|
||||
const contractNumbers = directLinks.map(d => d.contract.contractNumber).join(', ');
|
||||
throw new Error(`Zähler kann nicht gelöscht werden – noch an Vertrag/Verträgen zugeordnet: ${contractNumbers}`);
|
||||
}
|
||||
return prisma.meter.delete({ where: { id } });
|
||||
return prisma_js_1.default.meter.delete({ where: { id } });
|
||||
}
|
||||
async function addMeterReading(meterId, data) {
|
||||
// Validierung: Zählerstand muss monoton steigend sein
|
||||
@@ -349,7 +349,7 @@ async function addMeterReading(meterId, data) {
|
||||
if (data.valueNt !== undefined) {
|
||||
await validateReadingValue(meterId, data.readingDate, data.valueNt, undefined, 'NT');
|
||||
}
|
||||
return prisma.meterReading.create({
|
||||
return prisma_js_1.default.meterReading.create({
|
||||
data: {
|
||||
meterId,
|
||||
readingDate: data.readingDate,
|
||||
@@ -361,14 +361,14 @@ async function addMeterReading(meterId, data) {
|
||||
});
|
||||
}
|
||||
async function getMeterReadings(meterId) {
|
||||
return prisma.meterReading.findMany({
|
||||
return prisma_js_1.default.meterReading.findMany({
|
||||
where: { meterId },
|
||||
orderBy: { readingDate: 'desc' },
|
||||
});
|
||||
}
|
||||
async function updateMeterReading(meterId, readingId, data) {
|
||||
// Verify the reading belongs to the meter
|
||||
const reading = await prisma.meterReading.findFirst({
|
||||
const reading = await prisma_js_1.default.meterReading.findFirst({
|
||||
where: { id: readingId, meterId },
|
||||
});
|
||||
if (!reading) {
|
||||
@@ -384,7 +384,7 @@ async function updateMeterReading(meterId, readingId, data) {
|
||||
await validateReadingValue(meterId, data.readingDate || reading.readingDate, ntVal, readingId, 'NT');
|
||||
}
|
||||
}
|
||||
return prisma.meterReading.update({
|
||||
return prisma_js_1.default.meterReading.update({
|
||||
where: { id: readingId },
|
||||
data,
|
||||
});
|
||||
@@ -394,7 +394,7 @@ async function updateMeterReading(meterId, readingId, data) {
|
||||
* tariffLabel: 'HT' für Hochtarif/Eintarif, 'NT' für Niedertarif
|
||||
*/
|
||||
async function validateReadingValue(meterId, readingDate, value, excludeReadingId, tariffLabel = 'HT') {
|
||||
const existing = await prisma.meterReading.findMany({
|
||||
const existing = await prisma_js_1.default.meterReading.findMany({
|
||||
where: { meterId, ...(excludeReadingId ? { id: { not: excludeReadingId } } : {}) },
|
||||
orderBy: { readingDate: 'asc' },
|
||||
});
|
||||
@@ -416,20 +416,20 @@ async function validateReadingValue(meterId, readingDate, value, excludeReadingI
|
||||
}
|
||||
async function deleteMeterReading(meterId, readingId) {
|
||||
// Verify the reading belongs to the meter
|
||||
const reading = await prisma.meterReading.findFirst({
|
||||
const reading = await prisma_js_1.default.meterReading.findFirst({
|
||||
where: { id: readingId, meterId },
|
||||
});
|
||||
if (!reading) {
|
||||
throw new Error('Zählerstand nicht gefunden');
|
||||
}
|
||||
return prisma.meterReading.delete({
|
||||
return prisma_js_1.default.meterReading.delete({
|
||||
where: { id: readingId },
|
||||
});
|
||||
}
|
||||
// ==================== PORTAL SETTINGS ====================
|
||||
async function updatePortalSettings(customerId, data) {
|
||||
// Wenn Portal deaktiviert wird, Passwort-Hash nicht löschen (für spätere Reaktivierung)
|
||||
return prisma.customer.update({
|
||||
return prisma_js_1.default.customer.update({
|
||||
where: { id: customerId },
|
||||
data: {
|
||||
portalEnabled: data.portalEnabled,
|
||||
@@ -444,7 +444,7 @@ async function updatePortalSettings(customerId, data) {
|
||||
});
|
||||
}
|
||||
async function getPortalSettings(customerId) {
|
||||
return prisma.customer.findUnique({
|
||||
return prisma_js_1.default.customer.findUnique({
|
||||
where: { id: customerId },
|
||||
select: {
|
||||
id: true,
|
||||
@@ -458,7 +458,7 @@ async function getPortalSettings(customerId) {
|
||||
// ==================== REPRESENTATIVE MANAGEMENT ====================
|
||||
async function getCustomerRepresentatives(customerId) {
|
||||
// Holt alle Kunden, die der angegebene Kunde vertreten kann (dieser ist der Vertreter)
|
||||
return prisma.customerRepresentative.findMany({
|
||||
return prisma_js_1.default.customerRepresentative.findMany({
|
||||
where: { representativeId: customerId, isActive: true },
|
||||
include: {
|
||||
customer: {
|
||||
@@ -477,7 +477,7 @@ async function getCustomerRepresentatives(customerId) {
|
||||
}
|
||||
async function getRepresentedByList(customerId) {
|
||||
// Holt alle Kunden, die den angegebenen Kunden vertreten können
|
||||
return prisma.customerRepresentative.findMany({
|
||||
return prisma_js_1.default.customerRepresentative.findMany({
|
||||
where: { customerId: customerId, isActive: true },
|
||||
include: {
|
||||
representative: {
|
||||
@@ -499,8 +499,8 @@ representativeId, // Der Kunde, der einsehen darf
|
||||
notes) {
|
||||
// Prüfen, ob beide Kunden existieren
|
||||
const [customer, representative] = await Promise.all([
|
||||
prisma.customer.findUnique({ where: { id: customerId } }),
|
||||
prisma.customer.findUnique({ where: { id: representativeId } }),
|
||||
prisma_js_1.default.customer.findUnique({ where: { id: customerId } }),
|
||||
prisma_js_1.default.customer.findUnique({ where: { id: representativeId } }),
|
||||
]);
|
||||
if (!customer) {
|
||||
throw new Error('Kunde nicht gefunden');
|
||||
@@ -515,7 +515,7 @@ notes) {
|
||||
if (!representative.portalEnabled) {
|
||||
throw new Error('Der Vertreter-Kunde muss ein aktiviertes Portal-Konto haben');
|
||||
}
|
||||
return prisma.customerRepresentative.upsert({
|
||||
return prisma_js_1.default.customerRepresentative.upsert({
|
||||
where: {
|
||||
customerId_representativeId: { customerId, representativeId },
|
||||
},
|
||||
@@ -545,7 +545,7 @@ notes) {
|
||||
}
|
||||
async function removeRepresentative(customerId, representativeId) {
|
||||
// Anstatt zu löschen, setzen wir isActive auf false
|
||||
return prisma.customerRepresentative.update({
|
||||
return prisma_js_1.default.customerRepresentative.update({
|
||||
where: {
|
||||
customerId_representativeId: { customerId, representativeId },
|
||||
},
|
||||
@@ -555,7 +555,7 @@ async function removeRepresentative(customerId, representativeId) {
|
||||
async function searchCustomersForRepresentative(search, excludeCustomerId) {
|
||||
// Sucht Kunden, die als Vertreter hinzugefügt werden können
|
||||
// Nur Kunden mit aktiviertem Portal
|
||||
return prisma.customer.findMany({
|
||||
return prisma_js_1.default.customer.findMany({
|
||||
where: {
|
||||
id: { not: excludeCustomerId },
|
||||
portalEnabled: true,
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
@@ -1,5 +1,6 @@
|
||||
import { EmailExistsResult, EmailOperationResult, MailEncryption } from './types.js';
|
||||
export declare function getAllProviderConfigs(): Promise<{
|
||||
apiKey: string | null;
|
||||
id: number;
|
||||
isActive: boolean;
|
||||
createdAt: Date;
|
||||
@@ -8,7 +9,6 @@ export declare function getAllProviderConfigs(): Promise<{
|
||||
type: import(".prisma/client").$Enums.EmailProviderType;
|
||||
isDefault: boolean;
|
||||
apiUrl: string;
|
||||
apiKey: string | null;
|
||||
username: string | null;
|
||||
passwordEncrypted: string | null;
|
||||
domain: string;
|
||||
@@ -24,6 +24,7 @@ export declare function getAllProviderConfigs(): Promise<{
|
||||
systemEmailPasswordEncrypted: string | null;
|
||||
}[]>;
|
||||
export declare function getProviderConfigById(id: number): Promise<{
|
||||
apiKey: string | null;
|
||||
id: number;
|
||||
isActive: boolean;
|
||||
createdAt: Date;
|
||||
@@ -32,7 +33,6 @@ export declare function getProviderConfigById(id: number): Promise<{
|
||||
type: import(".prisma/client").$Enums.EmailProviderType;
|
||||
isDefault: boolean;
|
||||
apiUrl: string;
|
||||
apiKey: string | null;
|
||||
username: string | null;
|
||||
passwordEncrypted: string | null;
|
||||
domain: string;
|
||||
@@ -48,6 +48,7 @@ export declare function getProviderConfigById(id: number): Promise<{
|
||||
systemEmailPasswordEncrypted: string | null;
|
||||
} | null>;
|
||||
export declare function getDefaultProviderConfig(): Promise<{
|
||||
apiKey: string | null;
|
||||
id: number;
|
||||
isActive: boolean;
|
||||
createdAt: Date;
|
||||
@@ -56,7 +57,6 @@ export declare function getDefaultProviderConfig(): Promise<{
|
||||
type: import(".prisma/client").$Enums.EmailProviderType;
|
||||
isDefault: boolean;
|
||||
apiUrl: string;
|
||||
apiKey: string | null;
|
||||
username: string | null;
|
||||
passwordEncrypted: string | null;
|
||||
domain: string;
|
||||
@@ -72,6 +72,7 @@ export declare function getDefaultProviderConfig(): Promise<{
|
||||
systemEmailPasswordEncrypted: string | null;
|
||||
} | null>;
|
||||
export declare function getActiveProviderConfig(): Promise<{
|
||||
apiKey: string | null;
|
||||
id: number;
|
||||
isActive: boolean;
|
||||
createdAt: Date;
|
||||
@@ -80,7 +81,6 @@ export declare function getActiveProviderConfig(): Promise<{
|
||||
type: import(".prisma/client").$Enums.EmailProviderType;
|
||||
isDefault: boolean;
|
||||
apiUrl: string;
|
||||
apiKey: string | null;
|
||||
username: string | null;
|
||||
passwordEncrypted: string | null;
|
||||
domain: string;
|
||||
@@ -113,6 +113,7 @@ export interface CreateProviderConfigData {
|
||||
isDefault?: boolean;
|
||||
}
|
||||
export declare function createProviderConfig(data: CreateProviderConfigData): Promise<{
|
||||
apiKey: string | null;
|
||||
id: number;
|
||||
isActive: boolean;
|
||||
createdAt: Date;
|
||||
@@ -121,7 +122,6 @@ export declare function createProviderConfig(data: CreateProviderConfigData): Pr
|
||||
type: import(".prisma/client").$Enums.EmailProviderType;
|
||||
isDefault: boolean;
|
||||
apiUrl: string;
|
||||
apiKey: string | null;
|
||||
username: string | null;
|
||||
passwordEncrypted: string | null;
|
||||
domain: string;
|
||||
@@ -137,6 +137,7 @@ export declare function createProviderConfig(data: CreateProviderConfigData): Pr
|
||||
systemEmailPasswordEncrypted: string | null;
|
||||
}>;
|
||||
export declare function updateProviderConfig(id: number, data: Partial<CreateProviderConfigData>): Promise<{
|
||||
apiKey: string | null;
|
||||
id: number;
|
||||
isActive: boolean;
|
||||
createdAt: Date;
|
||||
@@ -145,7 +146,6 @@ export declare function updateProviderConfig(id: number, data: Partial<CreatePro
|
||||
type: import(".prisma/client").$Enums.EmailProviderType;
|
||||
isDefault: boolean;
|
||||
apiUrl: string;
|
||||
apiKey: string | null;
|
||||
username: string | null;
|
||||
passwordEncrypted: string | null;
|
||||
domain: string;
|
||||
@@ -161,6 +161,7 @@ export declare function updateProviderConfig(id: number, data: Partial<CreatePro
|
||||
systemEmailPasswordEncrypted: string | null;
|
||||
}>;
|
||||
export declare function deleteProviderConfig(id: number): Promise<{
|
||||
apiKey: string | null;
|
||||
id: number;
|
||||
isActive: boolean;
|
||||
createdAt: Date;
|
||||
@@ -169,7 +170,6 @@ export declare function deleteProviderConfig(id: number): Promise<{
|
||||
type: import(".prisma/client").$Enums.EmailProviderType;
|
||||
isDefault: boolean;
|
||||
apiUrl: string;
|
||||
apiKey: string | null;
|
||||
username: string | null;
|
||||
passwordEncrypted: string | null;
|
||||
domain: string;
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"emailProviderService.d.ts","sourceRoot":"","sources":["../../../src/services/emailProvider/emailProviderService.ts"],"names":[],"mappings":"AAIA,OAAO,EAGL,iBAAiB,EACjB,oBAAoB,EAEpB,cAAc,EACf,MAAM,YAAY,CAAC;AAuBpB,wBAAsB,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;KAI1C;AAED,wBAAsB,qBAAqB,CAAC,EAAE,EAAE,MA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AC,EAAE,MAAM,CAAC;QAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH,GAAG,OAAO,CAAC,oBAAoB,CAAC,CA6BhC;AAID,MAAM,WAAW,sBAAsB;IACrC,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,cAAc,CAAC;IAC/B,oBAAoB,EAAE,OAAO,CAAC;CAC/B;AAED;;;GAGG;AACH,wBAAsB,yBAAyB,IAAI,OAAO,CAAC,sBAAsB,GAAG,IAAI,CAAC,CAyBxF"}
|
||||
{"version":3,"file":"emailProviderService.d.ts","sourceRoot":"","sources":["../../../src/services/emailProvider/emailProviderService.ts"],"names":[],"mappings":"AAIA,OAAO,EAGL,iBAAiB,EACjB,oBAAoB,EAEpB,cAAc,EACf,MAAM,YAAY,CAAC;AAqBpB,wBAAsB,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;KAI1C;AAED,wBAAsB,qBAAqB,CAAC,EAAE,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;UAIrD;AAED,wBAAsB,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;UAI7C;AAED,wBAAsB,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;UAQ5C;AAED,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,OAAO,GAAG,QAAQ,GAAG,aAAa,CAAC;IACzC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAE7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IAAI,CAAC,CAyBxF"}
|
||||
+13
-11
@@ -1,5 +1,8 @@
|
||||
"use strict";
|
||||
// ==================== EMAIL PROVIDER SERVICE ====================
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getAllProviderConfigs = getAllProviderConfigs;
|
||||
exports.getProviderConfigById = getProviderConfigById;
|
||||
@@ -19,10 +22,9 @@ exports.renameProvisionedEmail = renameProvisionedEmail;
|
||||
exports.getProviderDomain = getProviderDomain;
|
||||
exports.testProviderConnection = testProviderConnection;
|
||||
exports.getSystemEmailCredentials = getSystemEmailCredentials;
|
||||
const client_1 = require("@prisma/client");
|
||||
const prisma_js_1 = __importDefault(require("../../lib/prisma.js"));
|
||||
const encryption_js_1 = require("../../utils/encryption.js");
|
||||
const pleskProvider_js_1 = require("./pleskProvider.js");
|
||||
const prisma = new client_1.PrismaClient();
|
||||
// Factory-Funktion um den richtigen Provider zu erstellen
|
||||
function createProvider(config) {
|
||||
switch (config.type) {
|
||||
@@ -40,17 +42,17 @@ function createProvider(config) {
|
||||
}
|
||||
// ==================== CONFIG CRUD ====================
|
||||
async function getAllProviderConfigs() {
|
||||
return prisma.emailProviderConfig.findMany({
|
||||
return prisma_js_1.default.emailProviderConfig.findMany({
|
||||
orderBy: [{ isDefault: 'desc' }, { name: 'asc' }],
|
||||
});
|
||||
}
|
||||
async function getProviderConfigById(id) {
|
||||
return prisma.emailProviderConfig.findUnique({
|
||||
return prisma_js_1.default.emailProviderConfig.findUnique({
|
||||
where: { id },
|
||||
});
|
||||
}
|
||||
async function getDefaultProviderConfig() {
|
||||
return prisma.emailProviderConfig.findFirst({
|
||||
return prisma_js_1.default.emailProviderConfig.findFirst({
|
||||
where: { isActive: true, isDefault: true },
|
||||
});
|
||||
}
|
||||
@@ -59,14 +61,14 @@ async function getActiveProviderConfig() {
|
||||
const defaultProvider = await getDefaultProviderConfig();
|
||||
if (defaultProvider)
|
||||
return defaultProvider;
|
||||
return prisma.emailProviderConfig.findFirst({
|
||||
return prisma_js_1.default.emailProviderConfig.findFirst({
|
||||
where: { isActive: true },
|
||||
});
|
||||
}
|
||||
async function createProviderConfig(data) {
|
||||
// Falls isDefault=true, alle anderen auf false setzen
|
||||
if (data.isDefault) {
|
||||
await prisma.emailProviderConfig.updateMany({
|
||||
await prisma_js_1.default.emailProviderConfig.updateMany({
|
||||
where: { isDefault: true },
|
||||
data: { isDefault: false },
|
||||
});
|
||||
@@ -75,7 +77,7 @@ async function createProviderConfig(data) {
|
||||
const { encrypt } = await import('../../utils/encryption.js');
|
||||
const passwordEncrypted = data.password ? encrypt(data.password) : null;
|
||||
const systemEmailPasswordEncrypted = data.systemEmailPassword ? encrypt(data.systemEmailPassword) : null;
|
||||
return prisma.emailProviderConfig.create({
|
||||
return prisma_js_1.default.emailProviderConfig.create({
|
||||
data: {
|
||||
name: data.name,
|
||||
type: data.type,
|
||||
@@ -98,7 +100,7 @@ async function createProviderConfig(data) {
|
||||
async function updateProviderConfig(id, data) {
|
||||
// Falls isDefault=true, alle anderen auf false setzen
|
||||
if (data.isDefault) {
|
||||
await prisma.emailProviderConfig.updateMany({
|
||||
await prisma_js_1.default.emailProviderConfig.updateMany({
|
||||
where: { isDefault: true, id: { not: id } },
|
||||
data: { isDefault: false },
|
||||
});
|
||||
@@ -149,13 +151,13 @@ async function updateProviderConfig(id, data) {
|
||||
// System-E-Mail wird gelöscht → Passwort auch löschen
|
||||
updateData.systemEmailPasswordEncrypted = null;
|
||||
}
|
||||
return prisma.emailProviderConfig.update({
|
||||
return prisma_js_1.default.emailProviderConfig.update({
|
||||
where: { id },
|
||||
data: updateData,
|
||||
});
|
||||
}
|
||||
async function deleteProviderConfig(id) {
|
||||
return prisma.emailProviderConfig.delete({
|
||||
return prisma_js_1.default.emailProviderConfig.delete({
|
||||
where: { id },
|
||||
});
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"file":"platform.service.d.ts","sourceRoot":"","sources":["../../src/services/platform.service.ts"],"names":[],"mappings":"AAIA,wBAAsB,eAAe,CAAC,eAAe,UAAQ;;;;;;;KAM5D;AAED,wBAAsB,eAAe,CAAC,EAAE,EAAE,MAAM;;;;;;;;;;;WAS/C;AAED,wBAAsB,cAAc,CAAC,IAAI,EAAE;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;;;;;;;GAOA;AAED,wBAAsB,cAAc,CAClC,EAAE,EAAE,MAAM,EACV,IAAI,EAAE;IACJ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;;;;;;;GAMF;AAED,wBAAsB,cAAc,CAAC,EAAE,EAAE,MAAM;;;;;;;GAa9C"}
|
||||
{"version":3,"file":"platform.service.d.ts","sourceRoot":"","sources":["../../src/services/platform.service.ts"],"names":[],"mappings":"AAEA,wBAAsB,eAAe,CAAC,eAAe,UAAQ;;;;;;;KAM5D;AAED,wBAAsB,eAAe,CAAC,EAAE,EAAE,MAAM;;;;;;;;;;;WAS/C;AAED,wBAAsB,cAAc,CAAC,IAAI,EAAE;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;;;;;;;GAOA;AAED,wBAAsB,cAAc,CAClC,EAAE,EAAE,MAAM,EACV,IAAI,EAAE;IACJ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;;;;;;;GAMF;AAED,wBAAsB,cAAc,CAAC,EAAE,EAAE,MAAM;;;;;;;GAa9C"}
|
||||
+10
-8
@@ -1,21 +1,23 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getAllPlatforms = getAllPlatforms;
|
||||
exports.getPlatformById = getPlatformById;
|
||||
exports.createPlatform = createPlatform;
|
||||
exports.updatePlatform = updatePlatform;
|
||||
exports.deletePlatform = deletePlatform;
|
||||
const client_1 = require("@prisma/client");
|
||||
const prisma = new client_1.PrismaClient();
|
||||
const prisma_js_1 = __importDefault(require("../lib/prisma.js"));
|
||||
async function getAllPlatforms(includeInactive = false) {
|
||||
const where = includeInactive ? {} : { isActive: true };
|
||||
return prisma.salesPlatform.findMany({
|
||||
return prisma_js_1.default.salesPlatform.findMany({
|
||||
where,
|
||||
orderBy: { name: 'asc' },
|
||||
});
|
||||
}
|
||||
async function getPlatformById(id) {
|
||||
return prisma.salesPlatform.findUnique({
|
||||
return prisma_js_1.default.salesPlatform.findUnique({
|
||||
where: { id },
|
||||
include: {
|
||||
_count: {
|
||||
@@ -25,7 +27,7 @@ async function getPlatformById(id) {
|
||||
});
|
||||
}
|
||||
async function createPlatform(data) {
|
||||
return prisma.salesPlatform.create({
|
||||
return prisma_js_1.default.salesPlatform.create({
|
||||
data: {
|
||||
...data,
|
||||
isActive: true,
|
||||
@@ -33,19 +35,19 @@ async function createPlatform(data) {
|
||||
});
|
||||
}
|
||||
async function updatePlatform(id, data) {
|
||||
return prisma.salesPlatform.update({
|
||||
return prisma_js_1.default.salesPlatform.update({
|
||||
where: { id },
|
||||
data,
|
||||
});
|
||||
}
|
||||
async function deletePlatform(id) {
|
||||
// Check if platform is used by any contracts
|
||||
const count = await prisma.contract.count({
|
||||
const count = await prisma_js_1.default.contract.count({
|
||||
where: { salesPlatformId: id },
|
||||
});
|
||||
if (count > 0) {
|
||||
throw new Error(`Plattform kann nicht gelöscht werden, da sie von ${count} Verträgen verwendet wird`);
|
||||
}
|
||||
return prisma.salesPlatform.delete({ where: { id } });
|
||||
return prisma_js_1.default.salesPlatform.delete({ where: { id } });
|
||||
}
|
||||
//# sourceMappingURL=platform.service.js.map
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"file":"platform.service.js","sourceRoot":"","sources":["../../src/services/platform.service.ts"],"names":[],"mappings":";;AAIA,0CAMC;AAED,0CASC;AAED,wCAUC;AAED,wCAYC;AAED,wCAaC;AA9DD,2CAA8C;AAE9C,MAAM,MAAM,GAAG,IAAI,qBAAY,EAAE,CAAC;AAE3B,KAAK,UAAU,eAAe,CAAC,eAAe,GAAG,KAAK;IAC3D,MAAM,KAAK,GAAG,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACxD,OAAO,MAAM,CAAC,aAAa,CAAC,QAAQ,CAAC;QACnC,KAAK;QACL,OAAO,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE;KACzB,CAAC,CAAC;AACL,CAAC;AAEM,KAAK,UAAU,eAAe,CAAC,EAAU;IAC9C,OAAO,MAAM,CAAC,aAAa,CAAC,UAAU,CAAC;QACrC,KAAK,EAAE,EAAE,EAAE,EAAE;QACb,OAAO,EAAE;YACP,MAAM,EAAE;gBACN,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE;aAC5B;SACF;KACF,CAAC,CAAC;AACL,CAAC;AAEM,KAAK,UAAU,cAAc,CAAC,IAGpC;IACC,OAAO,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC;QACjC,IAAI,EAAE;YACJ,GAAG,IAAI;YACP,QAAQ,EAAE,IAAI;SACf;KACF,CAAC,CAAC;AACL,CAAC;AAEM,KAAK,UAAU,cAAc,CAClC,EAAU,EACV,IAIC;IAED,OAAO,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC;QACjC,KAAK,EAAE,EAAE,EAAE,EAAE;QACb,IAAI;KACL,CAAC,CAAC;AACL,CAAC;AAEM,KAAK,UAAU,cAAc,CAAC,EAAU;IAC7C,6CAA6C;IAC7C,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;QACxC,KAAK,EAAE,EAAE,eAAe,EAAE,EAAE,EAAE;KAC/B,CAAC,CAAC;IAEH,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CACb,oDAAoD,KAAK,2BAA2B,CACrF,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;AACxD,CAAC"}
|
||||
{"version":3,"file":"platform.service.js","sourceRoot":"","sources":["../../src/services/platform.service.ts"],"names":[],"mappings":";;;;;AAEA,0CAMC;AAED,0CASC;AAED,wCAUC;AAED,wCAYC;AAED,wCAaC;AA5DD,iEAAsC;AAE/B,KAAK,UAAU,eAAe,CAAC,eAAe,GAAG,KAAK;IAC3D,MAAM,KAAK,GAAG,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACxD,OAAO,mBAAM,CAAC,aAAa,CAAC,QAAQ,CAAC;QACnC,KAAK;QACL,OAAO,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE;KACzB,CAAC,CAAC;AACL,CAAC;AAEM,KAAK,UAAU,eAAe,CAAC,EAAU;IAC9C,OAAO,mBAAM,CAAC,aAAa,CAAC,UAAU,CAAC;QACrC,KAAK,EAAE,EAAE,EAAE,EAAE;QACb,OAAO,EAAE;YACP,MAAM,EAAE;gBACN,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE;aAC5B;SACF;KACF,CAAC,CAAC;AACL,CAAC;AAEM,KAAK,UAAU,cAAc,CAAC,IAGpC;IACC,OAAO,mBAAM,CAAC,aAAa,CAAC,MAAM,CAAC;QACjC,IAAI,EAAE;YACJ,GAAG,IAAI;YACP,QAAQ,EAAE,IAAI;SACf;KACF,CAAC,CAAC;AACL,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AAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;;;;;;;;;GAMF;AAED,wBAAsB,cAAc,CAAC,EAAE,EAAE,MAAM;;;;;;;;;GAa9C"}
|
||||
{"version":3,"file":"provider.service.d.ts","sourceRoot":"","sources":["../../src/services/provider.service.ts"],"names":[],"mappings":"AAEA,wBAAsB,eAAe,CAAC,eAAe,UAAQ;;;;;;;;;;;;;;;;;;;;;;MAe5D;AAED,wBAAsB,eAAe,CAAC,EAAE,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;WAY/C;AAED,wBAAsB,cAAc,CAAC,IAAI,EAAE;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;;;;;;;;;GAOA;AAED,wBAAsB,cAAc,CAClC,EAAE,EAAE,MAAM,EACV,IAAI,EAAE;IACJ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;;;;;;;;;GAMF;AAED,wBAAsB,cAAc,CAAC,EAAE,EAAE,MAAM;;;;;;;;;GAa9C"}
|
||||
+10
-8
@@ -1,15 +1,17 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getAllProviders = getAllProviders;
|
||||
exports.getProviderById = getProviderById;
|
||||
exports.createProvider = createProvider;
|
||||
exports.updateProvider = updateProvider;
|
||||
exports.deleteProvider = deleteProvider;
|
||||
const client_1 = require("@prisma/client");
|
||||
const prisma = new client_1.PrismaClient();
|
||||
const prisma_js_1 = __importDefault(require("../lib/prisma.js"));
|
||||
async function getAllProviders(includeInactive = false) {
|
||||
const where = includeInactive ? {} : { isActive: true };
|
||||
return prisma.provider.findMany({
|
||||
return prisma_js_1.default.provider.findMany({
|
||||
where,
|
||||
orderBy: { name: 'asc' },
|
||||
include: {
|
||||
@@ -24,7 +26,7 @@ async function getAllProviders(includeInactive = false) {
|
||||
});
|
||||
}
|
||||
async function getProviderById(id) {
|
||||
return prisma.provider.findUnique({
|
||||
return prisma_js_1.default.provider.findUnique({
|
||||
where: { id },
|
||||
include: {
|
||||
tariffs: {
|
||||
@@ -37,7 +39,7 @@ async function getProviderById(id) {
|
||||
});
|
||||
}
|
||||
async function createProvider(data) {
|
||||
return prisma.provider.create({
|
||||
return prisma_js_1.default.provider.create({
|
||||
data: {
|
||||
...data,
|
||||
isActive: true,
|
||||
@@ -45,19 +47,19 @@ async function createProvider(data) {
|
||||
});
|
||||
}
|
||||
async function updateProvider(id, data) {
|
||||
return prisma.provider.update({
|
||||
return prisma_js_1.default.provider.update({
|
||||
where: { id },
|
||||
data,
|
||||
});
|
||||
}
|
||||
async function deleteProvider(id) {
|
||||
// Check if provider is used by any contracts
|
||||
const count = await prisma.contract.count({
|
||||
const count = await prisma_js_1.default.contract.count({
|
||||
where: { providerId: id },
|
||||
});
|
||||
if (count > 0) {
|
||||
throw new Error(`Anbieter kann nicht gelöscht werden, da er von ${count} Verträgen verwendet wird`);
|
||||
}
|
||||
return prisma.provider.delete({ where: { id } });
|
||||
return prisma_js_1.default.provider.delete({ where: { id } });
|
||||
}
|
||||
//# sourceMappingURL=provider.service.js.map
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"file":"provider.service.js","sourceRoot":"","sources":["../../src/services/provider.service.ts"],"names":[],"mappings":";;AAIA,0CAeC;AAED,0CAYC;AAED,wCAYC;AAED,wCAcC;AAED,wCAaC;AA9ED,2CAA8C;AAE9C,MAAM,MAAM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AU,eAAe,CAAC,EAAU;IAC9C,OAAO,mBAAM,CAAC,QAAQ,CAAC,UAAU,CAAC;QAChC,KAAK,EAAE,EAAE,EAAE,EAAE;QACb,OAAO,EAAE;YACP,OAAO,EAAE;gBACP,OAAO,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE;aACzB;YACD,MAAM,EAAE;gBACN,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE;aAC5B;SACF;KACF,CAAC,CAAC;AACL,CAAC;AAEM,KAAK,UAAU,cAAc,CAAC,IAKpC;IACC,OAAO,mBAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;QAC5B,IAAI,EAAE;YACJ,GAAG,IAAI;YACP,QAAQ,EAAE,IAAI;SACf;KACF,CAAC,CAAC;AACL,CAAC;AAEM,KAAK,UAAU,cAAc,CAClC,EAAU,EACV,IAMC;IAED,OAAO,mBAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;QAC5B,KAAK,EAAE,EAAE,EAAE,EAAE;QACb,IAAI;KACL,CAAC,CAAC;AACL,CAAC;AAEM,KAAK,UAAU,cAAc,CAAC,EAAU;IAC7C,6CAA6C;IAC7C,MAAM,KAAK,GAAG,MAAM,mBAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;QACxC,KAAK,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE;KAC1B,CAAC,CAAC;IAEH,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CACb,kDAAkD,KAAK,2BAA2B,CACnF,CAAC;IACJ,CAAC;IAED,OAAO,mBAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;AACnD,CAAC"}
|
||||
+6
-6
@@ -1,4 +1,5 @@
|
||||
export declare function getEmailsByCustomerId(customerId: number, includeInactive?: boolean): Promise<{
|
||||
emailPasswordEncrypted: string | null;
|
||||
id: number;
|
||||
email: string;
|
||||
customerId: number;
|
||||
@@ -11,7 +12,6 @@ export declare function getEmailsByCustomerId(customerId: number, includeInactiv
|
||||
isProvisioned: boolean;
|
||||
provisionedAt: Date | null;
|
||||
provisionError: string | null;
|
||||
emailPasswordEncrypted: string | null;
|
||||
}[]>;
|
||||
export declare function getEmailsWithMailboxByCustomerId(customerId: number): Promise<{
|
||||
id: number;
|
||||
@@ -23,6 +23,7 @@ export declare function getEmailsWithMailboxByCustomerId(customerId: number): Pr
|
||||
hasMailbox: boolean;
|
||||
}[]>;
|
||||
export declare function getEmailById(id: number): Promise<{
|
||||
emailPasswordEncrypted: string | null;
|
||||
id: number;
|
||||
email: string;
|
||||
customerId: number;
|
||||
@@ -35,9 +36,9 @@ export declare function getEmailById(id: number): Promise<{
|
||||
isProvisioned: boolean;
|
||||
provisionedAt: Date | null;
|
||||
provisionError: string | null;
|
||||
emailPasswordEncrypted: string | null;
|
||||
} | null>;
|
||||
export declare function getEmailWithMailboxById(id: number): Promise<{
|
||||
emailPasswordEncrypted: string | null;
|
||||
id: number;
|
||||
email: string;
|
||||
customerId: number;
|
||||
@@ -47,7 +48,6 @@ export declare function getEmailWithMailboxById(id: number): Promise<{
|
||||
notes: string | null;
|
||||
hasMailbox: boolean;
|
||||
platform: string | null;
|
||||
emailPasswordEncrypted: string | null;
|
||||
} | null>;
|
||||
export interface CreateEmailData {
|
||||
customerId: number;
|
||||
@@ -58,6 +58,7 @@ export interface CreateEmailData {
|
||||
createMailbox?: boolean;
|
||||
}
|
||||
export declare function createEmail(data: CreateEmailData): Promise<{
|
||||
emailPasswordEncrypted: string | null;
|
||||
id: number;
|
||||
email: string;
|
||||
customerId: number;
|
||||
@@ -70,7 +71,6 @@ export declare function createEmail(data: CreateEmailData): Promise<{
|
||||
isProvisioned: boolean;
|
||||
provisionedAt: Date | null;
|
||||
provisionError: string | null;
|
||||
emailPasswordEncrypted: string | null;
|
||||
}>;
|
||||
export declare function updateEmail(id: number, data: {
|
||||
email?: string;
|
||||
@@ -78,6 +78,7 @@ export declare function updateEmail(id: number, data: {
|
||||
notes?: string;
|
||||
isActive?: boolean;
|
||||
}): Promise<{
|
||||
emailPasswordEncrypted: string | null;
|
||||
id: number;
|
||||
email: string;
|
||||
customerId: number;
|
||||
@@ -90,9 +91,9 @@ export declare function updateEmail(id: number, data: {
|
||||
isProvisioned: boolean;
|
||||
provisionedAt: Date | null;
|
||||
provisionError: string | null;
|
||||
emailPasswordEncrypted: string | null;
|
||||
}>;
|
||||
export declare function deleteEmail(id: number): Promise<{
|
||||
emailPasswordEncrypted: string | null;
|
||||
id: number;
|
||||
email: string;
|
||||
customerId: number;
|
||||
@@ -105,7 +106,6 @@ export declare function deleteEmail(id: number): Promise<{
|
||||
isProvisioned: boolean;
|
||||
provisionedAt: Date | null;
|
||||
provisionError: string | null;
|
||||
emailPasswordEncrypted: string | null;
|
||||
}>;
|
||||
export declare function enableMailbox(id: number): Promise<{
|
||||
success: boolean;
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"file":"stressfreiEmail.service.d.ts","sourceRoot":"","sources":["../../src/services/stressfreiEmail.service.ts"],"names":[],"mappings":"AAcA,wBAAsB,qBAAqB,CAAC,UAAU,EAAE,MAAM,EAAE,eAAe,UAAQ;;;;;;;;;;;;;;KAStF;AAGD,wBAAsB,gCAAgC,CAAC,UAAU,EAAE,MAAM;;;;;;;;KAoBxE;AAED,wBAAsB,YAAY,CAAC,EAAE,EAAE,MAAM;;;;;;;;;;;;;;UAI5C;AAGD,wBAAsB,uBAAuB,CAAC,EAAE,EAAE,MAAM;;;;;;;;;;;UAgBvD;AAED,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,wBAAsB,WAA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D,wBAAsB,oBAAoB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAiCvH"}
|
||||
+20
-18
@@ -1,4 +1,7 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getEmailsByCustomerId = getEmailsByCustomerId;
|
||||
exports.getEmailsWithMailboxByCustomerId = getEmailsWithMailboxByCustomerId;
|
||||
@@ -11,24 +14,23 @@ exports.enableMailbox = enableMailbox;
|
||||
exports.syncMailboxStatus = syncMailboxStatus;
|
||||
exports.getDecryptedPassword = getDecryptedPassword;
|
||||
exports.resetMailboxPassword = resetMailboxPassword;
|
||||
const client_1 = require("@prisma/client");
|
||||
const prisma_js_1 = __importDefault(require("../lib/prisma.js"));
|
||||
const encryption_js_1 = require("../utils/encryption.js");
|
||||
const emailProviderService_js_1 = require("./emailProvider/emailProviderService.js");
|
||||
const passwordGenerator_js_1 = require("../utils/passwordGenerator.js");
|
||||
const prisma = new client_1.PrismaClient();
|
||||
async function getEmailsByCustomerId(customerId, includeInactive = false) {
|
||||
const where = { customerId };
|
||||
if (!includeInactive) {
|
||||
where.isActive = true;
|
||||
}
|
||||
return prisma.stressfreiEmail.findMany({
|
||||
return prisma_js_1.default.stressfreiEmail.findMany({
|
||||
where,
|
||||
orderBy: { createdAt: 'desc' },
|
||||
});
|
||||
}
|
||||
// Mit Mailbox-Status für E-Mail-Client
|
||||
async function getEmailsWithMailboxByCustomerId(customerId) {
|
||||
return prisma.stressfreiEmail.findMany({
|
||||
return prisma_js_1.default.stressfreiEmail.findMany({
|
||||
where: {
|
||||
customerId,
|
||||
isActive: true,
|
||||
@@ -49,13 +51,13 @@ async function getEmailsWithMailboxByCustomerId(customerId) {
|
||||
});
|
||||
}
|
||||
async function getEmailById(id) {
|
||||
return prisma.stressfreiEmail.findUnique({
|
||||
return prisma_js_1.default.stressfreiEmail.findUnique({
|
||||
where: { id },
|
||||
});
|
||||
}
|
||||
// E-Mail mit Mailbox-Status laden
|
||||
async function getEmailWithMailboxById(id) {
|
||||
return prisma.stressfreiEmail.findUnique({
|
||||
return prisma_js_1.default.stressfreiEmail.findUnique({
|
||||
where: { id },
|
||||
select: {
|
||||
id: true,
|
||||
@@ -76,7 +78,7 @@ async function createEmail(data) {
|
||||
// Falls beim Provider anlegen gewünscht
|
||||
if (provisionAtProvider) {
|
||||
// Kunde laden für Weiterleitung
|
||||
const customer = await prisma.customer.findUnique({
|
||||
const customer = await prisma_js_1.default.customer.findUnique({
|
||||
where: { id: data.customerId },
|
||||
select: { email: true },
|
||||
});
|
||||
@@ -94,7 +96,7 @@ async function createEmail(data) {
|
||||
}
|
||||
// Passwort verschlüsseln und speichern
|
||||
const passwordEncrypted = (0, encryption_js_1.encrypt)(password);
|
||||
return prisma.stressfreiEmail.create({
|
||||
return prisma_js_1.default.stressfreiEmail.create({
|
||||
data: {
|
||||
...emailData,
|
||||
isActive: true,
|
||||
@@ -111,7 +113,7 @@ async function createEmail(data) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return prisma.stressfreiEmail.create({
|
||||
return prisma_js_1.default.stressfreiEmail.create({
|
||||
data: {
|
||||
...emailData,
|
||||
isActive: true,
|
||||
@@ -120,17 +122,17 @@ async function createEmail(data) {
|
||||
});
|
||||
}
|
||||
async function updateEmail(id, data) {
|
||||
return prisma.stressfreiEmail.update({
|
||||
return prisma_js_1.default.stressfreiEmail.update({
|
||||
where: { id },
|
||||
data,
|
||||
});
|
||||
}
|
||||
async function deleteEmail(id) {
|
||||
return prisma.stressfreiEmail.delete({ where: { id } });
|
||||
return prisma_js_1.default.stressfreiEmail.delete({ where: { id } });
|
||||
}
|
||||
// Mailbox nachträglich aktivieren (für existierende E-Mail-Weiterleitung)
|
||||
async function enableMailbox(id) {
|
||||
const stressfreiEmail = await prisma.stressfreiEmail.findUnique({
|
||||
const stressfreiEmail = await prisma_js_1.default.stressfreiEmail.findUnique({
|
||||
where: { id },
|
||||
});
|
||||
if (!stressfreiEmail) {
|
||||
@@ -148,7 +150,7 @@ async function enableMailbox(id) {
|
||||
}
|
||||
// Passwort verschlüsseln und speichern
|
||||
const passwordEncrypted = (0, encryption_js_1.encrypt)(password);
|
||||
await prisma.stressfreiEmail.update({
|
||||
await prisma_js_1.default.stressfreiEmail.update({
|
||||
where: { id },
|
||||
data: {
|
||||
hasMailbox: true,
|
||||
@@ -159,7 +161,7 @@ async function enableMailbox(id) {
|
||||
}
|
||||
// Mailbox-Status mit Provider synchronisieren
|
||||
async function syncMailboxStatus(id) {
|
||||
const stressfreiEmail = await prisma.stressfreiEmail.findUnique({
|
||||
const stressfreiEmail = await prisma_js_1.default.stressfreiEmail.findUnique({
|
||||
where: { id },
|
||||
select: { email: true, hasMailbox: true },
|
||||
});
|
||||
@@ -175,7 +177,7 @@ async function syncMailboxStatus(id) {
|
||||
const providerHasMailbox = providerStatus.hasMailbox === true;
|
||||
// DB aktualisieren wenn Status abweicht
|
||||
if (stressfreiEmail.hasMailbox !== providerHasMailbox) {
|
||||
await prisma.stressfreiEmail.update({
|
||||
await prisma_js_1.default.stressfreiEmail.update({
|
||||
where: { id },
|
||||
data: { hasMailbox: providerHasMailbox },
|
||||
});
|
||||
@@ -186,7 +188,7 @@ async function syncMailboxStatus(id) {
|
||||
}
|
||||
// Passwort für IMAP/SMTP-Zugang entschlüsseln (nur für autorisierte Nutzung)
|
||||
async function getDecryptedPassword(id) {
|
||||
const stressfreiEmail = await prisma.stressfreiEmail.findUnique({
|
||||
const stressfreiEmail = await prisma_js_1.default.stressfreiEmail.findUnique({
|
||||
where: { id },
|
||||
select: { emailPasswordEncrypted: true },
|
||||
});
|
||||
@@ -203,7 +205,7 @@ async function getDecryptedPassword(id) {
|
||||
}
|
||||
// Passwort neu generieren und beim Provider setzen
|
||||
async function resetMailboxPassword(id) {
|
||||
const stressfreiEmail = await prisma.stressfreiEmail.findUnique({
|
||||
const stressfreiEmail = await prisma_js_1.default.stressfreiEmail.findUnique({
|
||||
where: { id },
|
||||
select: { email: true, hasMailbox: true },
|
||||
});
|
||||
@@ -223,7 +225,7 @@ async function resetMailboxPassword(id) {
|
||||
}
|
||||
// Passwort verschlüsseln und lokal speichern
|
||||
const passwordEncrypted = (0, encryption_js_1.encrypt)(newPassword);
|
||||
await prisma.stressfreiEmail.update({
|
||||
await prisma_js_1.default.stressfreiEmail.update({
|
||||
where: { id },
|
||||
data: { emailPasswordEncrypted: passwordEncrypted },
|
||||
});
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"file":"tariff.service.d.ts","sourceRoot":"","sources":["../../src/services/tariff.service.ts"],"names":[],"mappings":"AAIA,wBAAsB,oBAAoB,CAAC,UAAU,EAAE,MAAM,EAAE,eAAe,UAAQ;;;;;;;;;;;MAcrF;AAED,wBAAsB,aAAa,CAAC,EAAE,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;WAU7C;AAED,wBAAsB,YAAY,CAAC,IAAI,EAAE;IACvC,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;CACd;;;;;;;GAOA;AAED,wBAAsB,YAAY,CAChC,EAAE,EAAE,MAAM,EACV,IAAI,EAAE;IACJ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;;;;;;;GAMF;AAED,wBAAsB,YAAY,CAAC,EAAE,EAAE,MAAM;;;;;;;GAa5C"}
|
||||
{"version":3,"file":"tariff.service.d.ts","sourceRoot":"","sources":["../../src/services/tariff.service.ts"],"names":[],"mappings":"AAEA,wBAAsB,oBAAoB,CAAC,UAAU,EAAE,MAAM,EAAE,eAAe,UAAQ;;;;;;;;;;;MAcrF;AAED,wBAAsB,aAAa,CAAC,EAAE,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;WAU7C;AAED,wBAAsB,YAAY,CAAC,IAAI,EAAE;IACvC,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;CACd;;;;;;;GAOA;AAED,wBAAsB,YAAY,CAChC,EAAE,EAAE,MAAM,EACV,IAAI,EAAE;IACJ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;;;;;;;GAMF;AAED,wBAAsB,YAAY,CAAC,EAAE,EAAE,MAAM;;;;;;;GAa5C"}
|
||||
+10
-8
@@ -1,18 +1,20 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getTariffsByProvider = getTariffsByProvider;
|
||||
exports.getTariffById = getTariffById;
|
||||
exports.createTariff = createTariff;
|
||||
exports.updateTariff = updateTariff;
|
||||
exports.deleteTariff = deleteTariff;
|
||||
const client_1 = require("@prisma/client");
|
||||
const prisma = new client_1.PrismaClient();
|
||||
const prisma_js_1 = __importDefault(require("../lib/prisma.js"));
|
||||
async function getTariffsByProvider(providerId, includeInactive = false) {
|
||||
const where = { providerId };
|
||||
if (!includeInactive) {
|
||||
where.isActive = true;
|
||||
}
|
||||
return prisma.tariff.findMany({
|
||||
return prisma_js_1.default.tariff.findMany({
|
||||
where,
|
||||
orderBy: { name: 'asc' },
|
||||
include: {
|
||||
@@ -23,7 +25,7 @@ async function getTariffsByProvider(providerId, includeInactive = false) {
|
||||
});
|
||||
}
|
||||
async function getTariffById(id) {
|
||||
return prisma.tariff.findUnique({
|
||||
return prisma_js_1.default.tariff.findUnique({
|
||||
where: { id },
|
||||
include: {
|
||||
provider: true,
|
||||
@@ -34,7 +36,7 @@ async function getTariffById(id) {
|
||||
});
|
||||
}
|
||||
async function createTariff(data) {
|
||||
return prisma.tariff.create({
|
||||
return prisma_js_1.default.tariff.create({
|
||||
data: {
|
||||
...data,
|
||||
isActive: true,
|
||||
@@ -42,19 +44,19 @@ async function createTariff(data) {
|
||||
});
|
||||
}
|
||||
async function updateTariff(id, data) {
|
||||
return prisma.tariff.update({
|
||||
return prisma_js_1.default.tariff.update({
|
||||
where: { id },
|
||||
data,
|
||||
});
|
||||
}
|
||||
async function deleteTariff(id) {
|
||||
// Check if tariff is used by any contracts
|
||||
const count = await prisma.contract.count({
|
||||
const count = await prisma_js_1.default.contract.count({
|
||||
where: { tariffId: id },
|
||||
});
|
||||
if (count > 0) {
|
||||
throw new Error(`Tarif kann nicht gelöscht werden, da er von ${count} Verträgen verwendet wird`);
|
||||
}
|
||||
return prisma.tariff.delete({ where: { id } });
|
||||
return prisma_js_1.default.tariff.delete({ where: { id } });
|
||||
}
|
||||
//# sourceMappingURL=tariff.service.js.map
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"file":"tariff.service.js","sourceRoot":"","sources":["../../src/services/tariff.service.ts"],"names":[],"mappings":";;AAIA,oDAcC;AAED,sCAUC;AAED,oCAUC;AAED,oCAWC;AAED,oCAaC;AAtED,2CAA8C;AAE9C,MAAM,MAAM,GAAG,IAAI,qBAAY,EAAE,CAAC;AAE3B,KAAK,UAAU,oBAAoB,CAAC,UAAkB,EAAE,eAAe,GAAG,KAAK;IACpF,MAAM,KAAK,GAA+C,EAAE,UAAU,EAAE,CAAC;IACzE,IAAI,CAAC,eAAe,EAAE,CAAC;QACrB,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC;IACxB,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC;QAC5B,KAAK;QACL,OAAO,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE;QACxB,OAAO,EAAE;YACP,MAAM,EAAE;gBACN,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE;aAC5B;SACF;KACF,CAAC,CAAC;AACL,CAAC;AAEM,KAAK,UAAU,aAAa,CAAC,EAAU;IAC5C,OAAO,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC;QAC9B,KAAK,EAAE,EAAE,EAAE,EAAE;QACb,OAAO,EAAE;YACP,QAAQ,EAAE,IAAI;YACd,MAAM,EAAE;gBACN,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE;aAC5B;SACF;KACF,CAAC,CAAC;AACL,CAAC;AAEM,KAAK,UAAU,YAAY,CAAC,IAGlC;IACC,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;QAC1B,IAAI,EAAE;YACJ,GAAG,IAAI;YACP,QAAQ,EAAE,IAAI;SACf;KACF,CAAC,CAAC;AACL,CAAC;AAEM,KAAK,UAAU,YAAY,CAChC,EAAU,EACV,IAGC;IAED,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;QAC1B,KAAK,EAAE,EAAE,EAAE,EAAE;QACb,IAAI;KACL,CAAC,CAAC;AACL,CAAC;AAEM,KAAK,UAAU,YAAY,CAAC,EAAU;IAC3C,2CAA2C;IAC3C,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;QACxC,KAAK,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE;KACxB,CAAC,CAAC;IAEH,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CACb,+CAA+C,KAAK,2BAA2B,CAChF,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;AACjD,CAAC"}
|
||||
{"version":3,"file":"tariff.service.js","sourceRoot":"","sources":["../../src/services/tariff.service.ts"],"names":[],"mappings":";;;;;AAEA,oDAcC;AAED,sCAUC;AAED,oCAUC;AAED,oCAWC;AAED,oCAaC;AApED,iEAAs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ACxB,CAAC,CAAC;IAEH,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CACb,+CAA+C,KAAK,2BAA2B,CAChF,CAAC;IACJ,CAAC;IAED,OAAO,mBAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;AACjD,CAAC"}
|
||||
+8
-8
@@ -43,9 +43,9 @@ export declare function getUserById(id: number): Promise<{
|
||||
roles: ({
|
||||
permissions: ({
|
||||
permission: {
|
||||
action: string;
|
||||
id: number;
|
||||
resource: string;
|
||||
action: string;
|
||||
};
|
||||
} & {
|
||||
roleId: number;
|
||||
@@ -120,9 +120,9 @@ export declare function updateUser(id: number, data: {
|
||||
roles: ({
|
||||
permissions: ({
|
||||
permission: {
|
||||
action: string;
|
||||
id: number;
|
||||
resource: string;
|
||||
action: string;
|
||||
};
|
||||
} & {
|
||||
roleId: number;
|
||||
@@ -149,10 +149,10 @@ export declare function updateUser(id: number, data: {
|
||||
updatedAt: Date;
|
||||
} | null>;
|
||||
export declare function deleteUser(id: number): Promise<{
|
||||
password: string;
|
||||
id: number;
|
||||
email: string;
|
||||
customerId: number | null;
|
||||
password: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
isActive: boolean;
|
||||
@@ -166,9 +166,9 @@ export declare function deleteUser(id: number): Promise<{
|
||||
export declare function getAllRoles(): Promise<({
|
||||
permissions: ({
|
||||
permission: {
|
||||
action: string;
|
||||
id: number;
|
||||
resource: string;
|
||||
action: string;
|
||||
};
|
||||
} & {
|
||||
roleId: number;
|
||||
@@ -187,9 +187,9 @@ export declare function getAllRoles(): Promise<({
|
||||
export declare function getRoleById(id: number): Promise<({
|
||||
permissions: ({
|
||||
permission: {
|
||||
action: string;
|
||||
id: number;
|
||||
resource: string;
|
||||
action: string;
|
||||
};
|
||||
} & {
|
||||
roleId: number;
|
||||
@@ -209,9 +209,9 @@ export declare function createRole(data: {
|
||||
}): Promise<{
|
||||
permissions: ({
|
||||
permission: {
|
||||
action: string;
|
||||
id: number;
|
||||
resource: string;
|
||||
action: string;
|
||||
};
|
||||
} & {
|
||||
roleId: number;
|
||||
@@ -231,9 +231,9 @@ export declare function updateRole(id: number, data: {
|
||||
}): Promise<({
|
||||
permissions: ({
|
||||
permission: {
|
||||
action: string;
|
||||
id: number;
|
||||
resource: string;
|
||||
action: string;
|
||||
};
|
||||
} & {
|
||||
roleId: number;
|
||||
@@ -254,8 +254,8 @@ export declare function deleteRole(id: number): Promise<{
|
||||
description: string | null;
|
||||
}>;
|
||||
export declare function getAllPermissions(): Promise<{
|
||||
action: string;
|
||||
id: number;
|
||||
resource: string;
|
||||
action: string;
|
||||
}[]>;
|
||||
//# sourceMappingURL=user.service.d.ts.map
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"file":"user.service.d.ts","sourceRoot":"","sources":["../../src/services/user.service.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,WAAW;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAsB,WAAW,CAAC,OAAO,EAAE,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4ErD;AAED,wBAAsB,WAAW,CAAC,EAAE,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA6C3C;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kBAAkB,CAAC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AM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA4IF;AA4GD,wBAAsB,UAAU,CAAC,EAAE,EAAE,MAAM;;;;;;;;;;;;;;GA6D1C;AAGD,wBAAsB,WAAW;;;;;;;;;;;;;;;;;;;;MAYhC;AAED,wBAAsB,WAAW,CAAC,EAAE,EAAE,MAAM;;;;;;;;;;;;;;;;;WAS3C;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB;;;;;;;;;;;;;;;;;GAeA;AAED,wBAAsB,UAAU,CAC9B,EAAE,EAAE,MAAM,EACV,IAAI,EAAE;IACJ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B;;;;;;;;;;;;;;;;;WAiBF;AAED,wBAAsB,UAAU,CAAC,EAAE,EAAE,MAAM;;;;;;GAU1C;AAGD,wBAAsB,iBAAiB;;;;KAItC"}
|
||||
+43
-44
@@ -14,10 +14,9 @@ exports.createRole = createRole;
|
||||
exports.updateRole = updateRole;
|
||||
exports.deleteRole = deleteRole;
|
||||
exports.getAllPermissions = getAllPermissions;
|
||||
const client_1 = require("@prisma/client");
|
||||
const prisma_js_1 = __importDefault(require("../lib/prisma.js"));
|
||||
const bcryptjs_1 = __importDefault(require("bcryptjs"));
|
||||
const helpers_js_1 = require("../utils/helpers.js");
|
||||
const prisma = new client_1.PrismaClient();
|
||||
async function getAllUsers(filters) {
|
||||
const { search, isActive, roleId, page = 1, limit = 20 } = filters;
|
||||
const { skip, take } = (0, helpers_js_1.paginate)(page, limit);
|
||||
@@ -36,7 +35,7 @@ async function getAllUsers(filters) {
|
||||
];
|
||||
}
|
||||
const [users, total] = await Promise.all([
|
||||
prisma.user.findMany({
|
||||
prisma_js_1.default.user.findMany({
|
||||
where,
|
||||
skip,
|
||||
take,
|
||||
@@ -63,12 +62,12 @@ async function getAllUsers(filters) {
|
||||
},
|
||||
},
|
||||
}),
|
||||
prisma.user.count({ where }),
|
||||
prisma_js_1.default.user.count({ where }),
|
||||
]);
|
||||
// Get hidden role IDs
|
||||
const [developerRole, gdprRole] = await Promise.all([
|
||||
prisma.role.findFirst({ where: { name: 'Developer' } }),
|
||||
prisma.role.findFirst({ where: { name: 'DSGVO' } }),
|
||||
prisma_js_1.default.role.findFirst({ where: { name: 'Developer' } }),
|
||||
prisma_js_1.default.role.findFirst({ where: { name: 'DSGVO' } }),
|
||||
]);
|
||||
return {
|
||||
users: users.map((u) => {
|
||||
@@ -89,7 +88,7 @@ async function getAllUsers(filters) {
|
||||
};
|
||||
}
|
||||
async function getUserById(id) {
|
||||
const user = await prisma.user.findUnique({
|
||||
const user = await prisma_js_1.default.user.findUnique({
|
||||
where: { id },
|
||||
select: {
|
||||
id: true,
|
||||
@@ -132,7 +131,7 @@ async function getUserById(id) {
|
||||
}
|
||||
async function createUser(data) {
|
||||
const hashedPassword = await bcryptjs_1.default.hash(data.password, 10);
|
||||
const user = await prisma.user.create({
|
||||
const user = await prisma_js_1.default.user.create({
|
||||
data: {
|
||||
email: data.email,
|
||||
password: hashedPassword,
|
||||
@@ -175,7 +174,7 @@ async function updateUser(id, data) {
|
||||
const rolesAreBeingChanged = roleIds !== undefined;
|
||||
if (isBeingDeactivated || rolesAreBeingChanged) {
|
||||
// Check if user currently has admin permissions
|
||||
const currentUser = await prisma.user.findUnique({
|
||||
const currentUser = await prisma_js_1.default.user.findUnique({
|
||||
where: { id },
|
||||
include: {
|
||||
roles: {
|
||||
@@ -196,7 +195,7 @@ async function updateUser(id, data) {
|
||||
// Check if user will still be admin after role change
|
||||
let willStillBeAdmin = false;
|
||||
if (rolesAreBeingChanged) {
|
||||
const newRoles = await prisma.role.findMany({
|
||||
const newRoles = await prisma_js_1.default.role.findMany({
|
||||
where: { id: { in: roleIds } },
|
||||
include: {
|
||||
permissions: {
|
||||
@@ -211,7 +210,7 @@ async function updateUser(id, data) {
|
||||
}
|
||||
// If user is losing admin status or being deactivated, check for other admins
|
||||
if (!willStillBeAdmin || isBeingDeactivated) {
|
||||
const otherAdminCount = await prisma.user.count({
|
||||
const otherAdminCount = await prisma_js_1.default.user.count({
|
||||
where: {
|
||||
id: { not: id },
|
||||
isActive: true,
|
||||
@@ -249,7 +248,7 @@ async function updateUser(id, data) {
|
||||
// Prüfen ob Rollen geändert werden (für Zwangslogout)
|
||||
let rolesChanged = false;
|
||||
if (roleIds !== undefined) {
|
||||
const currentRoles = await prisma.userRole.findMany({
|
||||
const currentRoles = await prisma_js_1.default.userRole.findMany({
|
||||
where: { userId: id },
|
||||
select: { roleId: true },
|
||||
});
|
||||
@@ -260,7 +259,7 @@ async function updateUser(id, data) {
|
||||
!currentRoleIds.every((id, i) => id === newRoleIds[i]);
|
||||
}
|
||||
// Update user - bei Rollenänderung Token invalidieren
|
||||
await prisma.user.update({
|
||||
await prisma_js_1.default.user.update({
|
||||
where: { id },
|
||||
data: {
|
||||
...userData,
|
||||
@@ -270,8 +269,8 @@ async function updateUser(id, data) {
|
||||
});
|
||||
// Update roles if provided
|
||||
if (roleIds) {
|
||||
await prisma.userRole.deleteMany({ where: { userId: id } });
|
||||
await prisma.userRole.createMany({
|
||||
await prisma_js_1.default.userRole.deleteMany({ where: { userId: id } });
|
||||
await prisma_js_1.default.userRole.createMany({
|
||||
data: roleIds.map((roleId) => ({ userId: id, roleId })),
|
||||
});
|
||||
}
|
||||
@@ -288,20 +287,20 @@ async function updateUser(id, data) {
|
||||
// Helper to set developer access for a user
|
||||
async function setUserDeveloperAccess(userId, enabled) {
|
||||
// Get or create developer:access permission
|
||||
let developerPerm = await prisma.permission.findFirst({
|
||||
let developerPerm = await prisma_js_1.default.permission.findFirst({
|
||||
where: { resource: 'developer', action: 'access' },
|
||||
});
|
||||
if (!developerPerm) {
|
||||
developerPerm = await prisma.permission.create({
|
||||
developerPerm = await prisma_js_1.default.permission.create({
|
||||
data: { resource: 'developer', action: 'access' },
|
||||
});
|
||||
}
|
||||
// Get or create Developer role
|
||||
let developerRole = await prisma.role.findFirst({
|
||||
let developerRole = await prisma_js_1.default.role.findFirst({
|
||||
where: { name: 'Developer' },
|
||||
});
|
||||
if (!developerRole) {
|
||||
developerRole = await prisma.role.create({
|
||||
developerRole = await prisma_js_1.default.role.create({
|
||||
data: {
|
||||
name: 'Developer',
|
||||
description: 'Entwicklerzugriff auf Datenbanktools',
|
||||
@@ -312,25 +311,25 @@ async function setUserDeveloperAccess(userId, enabled) {
|
||||
});
|
||||
}
|
||||
// Check if user already has Developer role
|
||||
const hasRole = await prisma.userRole.findFirst({
|
||||
const hasRole = await prisma_js_1.default.userRole.findFirst({
|
||||
where: { userId, roleId: developerRole.id },
|
||||
});
|
||||
if (enabled && !hasRole) {
|
||||
await prisma.userRole.create({
|
||||
await prisma_js_1.default.userRole.create({
|
||||
data: { userId, roleId: developerRole.id },
|
||||
});
|
||||
// Token invalidieren bei Rechteänderung
|
||||
await prisma.user.update({
|
||||
await prisma_js_1.default.user.update({
|
||||
where: { id: userId },
|
||||
data: { tokenInvalidatedAt: new Date() },
|
||||
});
|
||||
}
|
||||
else if (!enabled && hasRole) {
|
||||
await prisma.userRole.delete({
|
||||
await prisma_js_1.default.userRole.delete({
|
||||
where: { userId_roleId: { userId, roleId: developerRole.id } },
|
||||
});
|
||||
// Token invalidieren bei Rechteänderung
|
||||
await prisma.user.update({
|
||||
await prisma_js_1.default.user.update({
|
||||
where: { id: userId },
|
||||
data: { tokenInvalidatedAt: new Date() },
|
||||
});
|
||||
@@ -339,17 +338,17 @@ async function setUserDeveloperAccess(userId, enabled) {
|
||||
// Helper to set GDPR access for a user
|
||||
async function setUserGdprAccess(userId, enabled) {
|
||||
// Get or create DSGVO role
|
||||
let gdprRole = await prisma.role.findFirst({
|
||||
let gdprRole = await prisma_js_1.default.role.findFirst({
|
||||
where: { name: 'DSGVO' },
|
||||
});
|
||||
if (!gdprRole) {
|
||||
// Create DSGVO role with all audit:* and gdpr:* permissions
|
||||
const gdprPermissions = await prisma.permission.findMany({
|
||||
const gdprPermissions = await prisma_js_1.default.permission.findMany({
|
||||
where: {
|
||||
OR: [{ resource: 'audit' }, { resource: 'gdpr' }],
|
||||
},
|
||||
});
|
||||
gdprRole = await prisma.role.create({
|
||||
gdprRole = await prisma_js_1.default.role.create({
|
||||
data: {
|
||||
name: 'DSGVO',
|
||||
description: 'DSGVO-Zugriff: Audit-Logs und Datenschutz-Verwaltung',
|
||||
@@ -360,23 +359,23 @@ async function setUserGdprAccess(userId, enabled) {
|
||||
});
|
||||
}
|
||||
// Check if user already has DSGVO role
|
||||
const hasRole = await prisma.userRole.findFirst({
|
||||
const hasRole = await prisma_js_1.default.userRole.findFirst({
|
||||
where: { userId, roleId: gdprRole.id },
|
||||
});
|
||||
if (enabled && !hasRole) {
|
||||
await prisma.userRole.create({
|
||||
await prisma_js_1.default.userRole.create({
|
||||
data: { userId, roleId: gdprRole.id },
|
||||
});
|
||||
await prisma.user.update({
|
||||
await prisma_js_1.default.user.update({
|
||||
where: { id: userId },
|
||||
data: { tokenInvalidatedAt: new Date() },
|
||||
});
|
||||
}
|
||||
else if (!enabled && hasRole) {
|
||||
await prisma.userRole.delete({
|
||||
await prisma_js_1.default.userRole.delete({
|
||||
where: { userId_roleId: { userId, roleId: gdprRole.id } },
|
||||
});
|
||||
await prisma.user.update({
|
||||
await prisma_js_1.default.user.update({
|
||||
where: { id: userId },
|
||||
data: { tokenInvalidatedAt: new Date() },
|
||||
});
|
||||
@@ -384,7 +383,7 @@ async function setUserGdprAccess(userId, enabled) {
|
||||
}
|
||||
async function deleteUser(id) {
|
||||
// Check if user is an admin
|
||||
const user = await prisma.user.findUnique({
|
||||
const user = await prisma_js_1.default.user.findUnique({
|
||||
where: { id },
|
||||
include: {
|
||||
roles: {
|
||||
@@ -407,7 +406,7 @@ async function deleteUser(id) {
|
||||
const isAdmin = user.roles.some((ur) => ur.role.permissions.some((rp) => rp.permission.resource === 'users' && rp.permission.action === 'delete'));
|
||||
if (isAdmin) {
|
||||
// Count other admins (users with users:delete permission)
|
||||
const adminCount = await prisma.user.count({
|
||||
const adminCount = await prisma_js_1.default.user.count({
|
||||
where: {
|
||||
id: { not: id },
|
||||
isActive: true,
|
||||
@@ -431,11 +430,11 @@ async function deleteUser(id) {
|
||||
throw new Error('Dieser Benutzer ist der letzte Administrator und kann nicht gelöscht werden');
|
||||
}
|
||||
}
|
||||
return prisma.user.delete({ where: { id } });
|
||||
return prisma_js_1.default.user.delete({ where: { id } });
|
||||
}
|
||||
// Role operations
|
||||
async function getAllRoles() {
|
||||
return prisma.role.findMany({
|
||||
return prisma_js_1.default.role.findMany({
|
||||
include: {
|
||||
permissions: {
|
||||
include: { permission: true },
|
||||
@@ -448,7 +447,7 @@ async function getAllRoles() {
|
||||
});
|
||||
}
|
||||
async function getRoleById(id) {
|
||||
return prisma.role.findUnique({
|
||||
return prisma_js_1.default.role.findUnique({
|
||||
where: { id },
|
||||
include: {
|
||||
permissions: {
|
||||
@@ -458,7 +457,7 @@ async function getRoleById(id) {
|
||||
});
|
||||
}
|
||||
async function createRole(data) {
|
||||
return prisma.role.create({
|
||||
return prisma_js_1.default.role.create({
|
||||
data: {
|
||||
name: data.name,
|
||||
description: data.description,
|
||||
@@ -475,13 +474,13 @@ async function createRole(data) {
|
||||
}
|
||||
async function updateRole(id, data) {
|
||||
const { permissionIds, ...roleData } = data;
|
||||
await prisma.role.update({
|
||||
await prisma_js_1.default.role.update({
|
||||
where: { id },
|
||||
data: roleData,
|
||||
});
|
||||
if (permissionIds) {
|
||||
await prisma.rolePermission.deleteMany({ where: { roleId: id } });
|
||||
await prisma.rolePermission.createMany({
|
||||
await prisma_js_1.default.rolePermission.deleteMany({ where: { roleId: id } });
|
||||
await prisma_js_1.default.rolePermission.createMany({
|
||||
data: permissionIds.map((permissionId) => ({ roleId: id, permissionId })),
|
||||
});
|
||||
}
|
||||
@@ -489,15 +488,15 @@ async function updateRole(id, data) {
|
||||
}
|
||||
async function deleteRole(id) {
|
||||
// Check if role is assigned to any users
|
||||
const count = await prisma.userRole.count({ where: { roleId: id } });
|
||||
const count = await prisma_js_1.default.userRole.count({ where: { roleId: id } });
|
||||
if (count > 0) {
|
||||
throw new Error(`Rolle kann nicht gelöscht werden, da sie ${count} Benutzern zugewiesen ist`);
|
||||
}
|
||||
return prisma.role.delete({ where: { id } });
|
||||
return prisma_js_1.default.role.delete({ where: { id } });
|
||||
}
|
||||
// Permission operations
|
||||
async function getAllPermissions() {
|
||||
return prisma.permission.findMany({
|
||||
return prisma_js_1.default.permission.findMany({
|
||||
orderBy: [{ resource: 'asc' }, { action: 'asc' }],
|
||||
});
|
||||
}
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user