fix(SPG-675) Error saat confirm status pending ( hanya bisa refund status settled ) padahal status sudah berubah ke proces refund

pull/42/head
Aswin Ashar Abdullah 2024-07-30 13:08:50 +07:00
parent 3e85d40885
commit d9bbe1290d
2 changed files with 12 additions and 2 deletions

View File

@ -17,7 +17,12 @@ import { STATUS } from 'src/core/strings/constants/base.constants';
@Injectable()
export class BatchConfirmRefundManager extends BaseBatchUpdateStatusManager<RefundEntity> {
async validateData(data: RefundEntity): Promise<void> {
if (data?.['transaction']?.status != STATUS.SETTLED) {
if (
this.data.status == STATUS.DRAFT &&
data['trnsaction']?.status != STATUS.SETTLED &&
this.data.status == STATUS.PENDING &&
data['trnsaction']?.status != STATUS.PROCESS_REFUND
) {
throw new UnprocessableEntityException({
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
message: `Failed! only transaction with status ${STATUS.SETTLED} can be refund`,

View File

@ -38,7 +38,12 @@ export class ConfirmRefundManager extends BaseUpdateStatusManager<RefundEntity>
relations: ['transaction'],
});
if (data.transaction.status != STATUS.SETTLED) {
if (
data.status == STATUS.DRAFT &&
data.transaction.status != STATUS.SETTLED &&
data.status == STATUS.PENDING &&
data.transaction.status != STATUS.PROCESS_REFUND
) {
throw new UnprocessableEntityException({
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
message: `Failed! only transaction with status ${STATUS.SETTLED} can be refund`,