fix(SPG-708) Muncul error saat meng cancel status pending - warninnya hanya bisa meng cancel status pending juga

pull/43/head
Aswin Ashar Abdullah 2024-07-30 18:26:50 +07:00
parent 197b3478ae
commit c154af6cb7
5 changed files with 17 additions and 6 deletions

View File

@ -49,14 +49,14 @@ export abstract class BaseBatchUpdateStatusManager<Entity> extends BaseManager {
});
}
this.oldData = _.cloneDeep(entity);
await this.validateData(entity);
Object.assign(entity, {
status: this.dataStatus,
editor_id: this.user.id,
editor_name: this.user.name,
updated_at: new Date().getTime(),
});
await this.validateData(entity);
await new ValidateRelationHelper(
id,
this.dataService,

View File

@ -27,7 +27,7 @@ export class BatchCancelRefundManager extends BaseBatchUpdateStatusManager<Refun
) {
throw new UnprocessableEntityException({
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
message: `Failed! only data with status ${STATUS.REFUNDED}, ${STATUS.PROCESS_REFUND} , ${STATUS.PARTIAL_REFUND} and ${STATUS.PENDING} can be cancelled`,
message: `Gagal! hanya data dengan status ${STATUS.REFUNDED}, ${STATUS.PROCESS_REFUND} , ${STATUS.PARTIAL_REFUND} dan ${STATUS.PENDING} yang dapat dicancel`,
error: 'Unprocessable Entity',
});
}

View File

@ -26,11 +26,11 @@ export class CancelRefundManager extends BaseUpdateStatusManager<RefundEntity> {
STATUS.PENDING,
STATUS.PROCESS_REFUND,
STATUS.PARTIAL_REFUND,
].includes(this.data.status)
].includes(this.oldData.status)
) {
throw new UnprocessableEntityException({
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
message: `Failed! only data with status ${STATUS.REFUNDED}, ${STATUS.PROCESS_REFUND} , ${STATUS.PARTIAL_REFUND} and ${STATUS.PENDING} can be cancelled`,
message: `Gagal! hanya data dengan status ${STATUS.REFUNDED}, ${STATUS.PROCESS_REFUND} , ${STATUS.PARTIAL_REFUND} dan ${STATUS.PENDING} yang dapat dicancel`,
error: 'Unprocessable Entity',
});
}

View File

@ -20,7 +20,7 @@ export class BatchCancelTransactionManager extends BaseBatchUpdateStatusManager<
if (![STATUS.EXPIRED, STATUS.PENDING].includes(data.status)) {
throw new UnprocessableEntityException({
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
message: `Failed! only data booking with status ${STATUS.ACTIVE} can be confirm`,
message: `Gagal! hanya tranksaksi dengan status ${STATUS.PENDING} dan ${STATUS.EXPIRED} yang dapat di${this.dataStatus}`,
error: 'Unprocessable Entity',
});
}

View File

@ -15,6 +15,7 @@ import { BatchCancelTransactionManager } from './managers/batch-cancel-transacti
import { ConfirmDataTransactionManager } from './managers/confirm-data-transaction.manager';
import { BatchConfirmDataTransactionManager } from './managers/batch-confirm-data-transaction.manager';
import { MidtransService } from 'src/modules/configuration/midtrans/data/services/midtrans.service';
import { InvoiceTransactionManager } from './managers/download-invoice-transaction.manager';
@Injectable()
export class TransactionDataOrchestrator {
@ -29,6 +30,7 @@ export class TransactionDataOrchestrator {
private batchDeleteManager: BatchDeleteTransactionManager,
private cancelManager: CancelTransactionManager,
private batchCancelManager: BatchCancelTransactionManager,
private invoiceManager: InvoiceTransactionManager,
private serviceData: TransactionDataService,
private midtransService: MidtransService,
) {}
@ -47,6 +49,15 @@ export class TransactionDataOrchestrator {
return this.updateManager.getResult();
}
async invoice(dataId): Promise<any> {
this.invoiceManager.setData({
id: dataId,
});
this.invoiceManager.setService(this.serviceData, TABLE_NAME.TRANSACTION);
await this.invoiceManager.execute();
return this.invoiceManager.getResult();
}
async delete(dataId): Promise<string> {
this.deleteManager.setData(dataId);
this.deleteManager.setService(this.serviceData, TABLE_NAME.TRANSACTION);