-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: [Contracts] API - Approve contract by NGO
- Loading branch information
1 parent
902bc71
commit b4bd65d
Showing
4 changed files
with
71 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
backend/src/usecases/documents/new_contracts/approve-document-contract-by-ngo.usecase.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { ExceptionsService } from 'src/infrastructure/exceptions/exceptions.service'; | ||
import { DocumentContractStatus } from 'src/modules/documents/enums/contract-status.enum'; | ||
import { ContractExceptionMessages } from 'src/modules/documents/exceptions/contract.exceptions'; | ||
import { DocumentContractFacade } from 'src/modules/documents/services/document-contract.facade'; | ||
|
||
@Injectable() | ||
export class ApproveDocumentContractByNgoUsecase { | ||
constructor( | ||
private readonly documentContractFacade: DocumentContractFacade, | ||
private readonly exceptionService: ExceptionsService, | ||
) {} | ||
|
||
async execute( | ||
documentContractId: string, | ||
organizationId: string, | ||
): Promise<void> { | ||
const exists = await this.documentContractFacade.exists({ | ||
id: documentContractId, | ||
organizationId, | ||
status: DocumentContractStatus.PENDING_APPROVAL_NGO, | ||
}); | ||
|
||
if (!exists) { | ||
this.exceptionService.notFoundException( | ||
ContractExceptionMessages.CONTRACT_002, | ||
); | ||
} | ||
try { | ||
await this.documentContractFacade.approveDocumentContractByNGO( | ||
documentContractId, | ||
); | ||
} catch (error) { | ||
this.exceptionService.internalServerErrorException({ | ||
message: `Error while approving the contract by NGO ${error?.message}`, | ||
code_error: 'APPROVE_DOCUMENT_CONTRACT_BY_NGO_001', | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters