fix: transaction NaN without discount
continuous-integration/drone/push Build is passing Details

pull/100/head
shancheas 2024-09-21 23:04:59 +07:00
parent 34ae5964c4
commit 22f4e732db
1 changed files with 3 additions and 2 deletions

View File

@ -165,7 +165,7 @@ export function mappingRevertTransaction(data, type) {
const discountPercent =
discount_value && +discount_value > 0
? +discount_value / +payment_sub_total
: discount_percentage / 100;
: discount_percentage ?? 0 / 100;
const discountValue = payment_sub_total * discountPercent;
Object.assign(data, {
@ -192,7 +192,8 @@ export function mappingRevertTransaction(data, type) {
item.bundling_items = item.item.bundling_items?.map((bundling) => {
if (bundling.item_id) return bundling;
const basePrice = bundling.item_rates ?? bundling.base_price;
const basePrice =
(bundling.item_rates ?? bundling.base_price) * +item.qty;
const discount = discountPercent * basePrice;
const total = basePrice - discount;