diff --git a/src/modules/transaction/transaction/domain/usecases/managers/helpers/mapping-transaction.helper.ts b/src/modules/transaction/transaction/domain/usecases/managers/helpers/mapping-transaction.helper.ts index 6940c52..b56f44f 100644 --- a/src/modules/transaction/transaction/domain/usecases/managers/helpers/mapping-transaction.helper.ts +++ b/src/modules/transaction/transaction/domain/usecases/managers/helpers/mapping-transaction.helper.ts @@ -189,11 +189,19 @@ export function mappingRevertTransaction(data, type) { const total_share_tenant = share_margin > 0 ? (Number(share_margin) / 100) * total_price : 0; + const bundlingTotalPrice = + (item.item?.bundling_items?.reduce( + (a, b) => a + Number(b.item_rates ?? b.base_price), + 0, + ) ?? 0) * +item.qty; + const totalAndBundlingRatio = total_price / bundlingTotalPrice; item.bundling_items = item.item.bundling_items?.map((bundling) => { if (bundling.item_id) return bundling; const basePrice = - (bundling.item_rates ?? bundling.base_price) * +item.qty; + (bundling.item_rates ?? bundling.base_price) * + +item.qty * + totalAndBundlingRatio; const discount = discountPercent * basePrice; const total = basePrice - discount;