first commit

This commit is contained in:
Stefan Hacker
2026-01-29 01:16:54 +01:00
commit 31f807fbd0
12106 changed files with 2480685 additions and 0 deletions
+69
View File
@@ -0,0 +1,69 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getAllContractCategories = getAllContractCategories;
exports.getContractCategoryById = getContractCategoryById;
exports.getContractCategoryByCode = getContractCategoryByCode;
exports.createContractCategory = createContractCategory;
exports.updateContractCategory = updateContractCategory;
exports.deleteContractCategory = deleteContractCategory;
const client_1 = require("@prisma/client");
const prisma = new client_1.PrismaClient();
async function getAllContractCategories(includeInactive = false) {
return prisma.contractCategory.findMany({
where: includeInactive ? {} : { isActive: true },
orderBy: [{ sortOrder: 'asc' }, { name: 'asc' }],
include: {
_count: {
select: { contracts: true },
},
},
});
}
async function getContractCategoryById(id) {
return prisma.contractCategory.findUnique({
where: { id },
include: {
_count: {
select: { contracts: true },
},
},
});
}
async function getContractCategoryByCode(code) {
return prisma.contractCategory.findUnique({
where: { code },
});
}
async function createContractCategory(data) {
return prisma.contractCategory.create({
data,
include: {
_count: {
select: { contracts: true },
},
},
});
}
async function updateContractCategory(id, data) {
return prisma.contractCategory.update({
where: { id },
data,
include: {
_count: {
select: { contracts: true },
},
},
});
}
async function deleteContractCategory(id) {
// Check if category has contracts
const category = await prisma.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 } });
}
//# sourceMappingURL=contractCategory.service.js.map