fix(refund) perbaikan refund item

pull/29/head
Aswin Ashar Abdullah 2024-07-15 18:08:44 +07:00
parent 84f7ed6d09
commit c2b5f27b3b
2 changed files with 25 additions and 0 deletions

View File

@ -17,6 +17,19 @@ import { STATUS } from 'src/core/strings/constants/base.constants';
@Injectable()
export class CreateRefundManager extends BaseCreateManager<RefundEntity> {
async beforeProcess(): Promise<void> {
const refund_items = this.data.refund_items?.map((item) => {
return {
transaction_item: item,
qty_refund: item.qty_refund,
refund_total: item.refund_total,
refund_sub_total: item.refund_sub_total,
};
});
Object.assign(this.data, {
refund_items: refund_items,
});
if (this.data.transaction?.status != STATUS.SETTLED) {
throw new UnprocessableEntityException({
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,

View File

@ -28,6 +28,18 @@ export class UpdateRefundManager extends BaseUpdateManager<RefundEntity> {
}
async beforeProcess(): Promise<void> {
const refund_items = this.data.refund_items?.map((item) => {
return {
transaction_item: item,
qty_refund: item.qty_refund,
refund_total: item.refund_total,
refund_sub_total: item.refund_sub_total,
};
});
Object.assign(this.data, {
refund_items: refund_items ?? [],
});
return;
}