🐛 Allow deletion of a document with a file if status is refused

This commit is contained in:
Maxime Lalo 2023-10-02 14:34:58 +02:00
parent c414a5b1a6
commit 2d0517aa10

View File

@ -51,7 +51,7 @@ export default class DocumentsService extends BaseService {
if (!documentEntity) throw new Error("document not found");
const document = Document.hydrate<Document>(documentEntity, { strategy: "excludeAll" });
if (document.files && document.files.length !== 0) {
if (document.files && document.files.length !== 0 && document.document_status !== "REFUSED") {
throw new Error("Can't delete a document with file");
}
return this.documentsRepository.delete(uid);