feat: calculate discount for bundling
parent
e6066b534c
commit
901c67137b
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue