Files
paperlessmanager/paperless-backend/src/kontonummern/kontonummern.service.ts
T
bjoernpoettker 66aeab282c
Build and Push Multi-Platform Images / build-and-push (push) Successful in 19s
Revert "fix: resolve all ESLint errors in backend and frontend"
This reverts commit 07dfd7e840.
2026-06-16 16:19:11 +02:00

36 lines
1005 B
TypeScript

import { Injectable, NotFoundException } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { Kontonummer } from '../database/entities';
@Injectable()
export class KontonummernService {
constructor(
@InjectRepository(Kontonummer)
private readonly kontonummerRepo: Repository<Kontonummer>,
) {}
async findByCorrespondent(correspondentId: number): Promise<Kontonummer[]> {
return this.kontonummerRepo.find({
where: { CorrespondentId: correspondentId },
});
}
async create(correspondentId: number, nummer: string): Promise<Kontonummer> {
const existing = await this.kontonummerRepo.findOne({
where: { CorrespondentId: correspondentId, Nummer: nummer },
});
if (existing) {
return existing;
}
const kontonummer = this.kontonummerRepo.create({
CorrespondentId: correspondentId,
Nummer: nummer,
});
return this.kontonummerRepo.save(kontonummer);
}
}