fix(refund) perbaikan refund item
parent
84f7ed6d09
commit
c2b5f27b3b
|
@ -17,6 +17,19 @@ import { STATUS } from 'src/core/strings/constants/base.constants';
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class CreateRefundManager extends BaseCreateManager<RefundEntity> {
|
export class CreateRefundManager extends BaseCreateManager<RefundEntity> {
|
||||||
async beforeProcess(): Promise<void> {
|
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) {
|
if (this.data.transaction?.status != STATUS.SETTLED) {
|
||||||
throw new UnprocessableEntityException({
|
throw new UnprocessableEntityException({
|
||||||
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
||||||
|
|
|
@ -28,6 +28,18 @@ export class UpdateRefundManager extends BaseUpdateManager<RefundEntity> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async beforeProcess(): Promise<void> {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue