complete new audit system
This commit is contained in:
+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
|
||||
Reference in New Issue
Block a user