fix(SPG-618) Error pada saat mengkonfirmasi / save pengembalian wahana baru

pull/36/head
Aswin Ashar Abdullah 2024-07-22 11:40:43 +07:00
parent 000c3f1800
commit ef2697a3b1
1 changed files with 13 additions and 0 deletions

View File

@ -30,6 +30,19 @@ export class CreateRefundManager extends BaseCreateManager<RefundEntity> {
refund_items: refund_items,
});
const exist = await this.dataService.getOneByOptions({
where: {
transaction_id: this.data.transaction.id,
},
});
if (exist) {
throw new UnprocessableEntityException({
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
message: `Failed! refund transaction with invoice ${this.data.transaction.invoice_code} already exist`,
error: 'Unprocessable Entity',
});
}
const transaction = await this.dataServiceFirstOpt.getOneByOptions({
where: {
id: this.data.transaction.id,