fix: privilege discount on amount

This commit is contained in:
skeris 2023-12-14 01:28:48 +03:00
parent 3aff04bf4a
commit 5327da77ea
2 changed files with 2 additions and 1 deletions

@ -6,6 +6,7 @@ export type PrivilegeCartData = {
privilegeId: string;
description: string;
price: number;
amount: number;
appliedPrivilegeDiscount: Discount | null;
};

@ -9,7 +9,7 @@ export function applyPrivilegeDiscounts(
cartData.services.forEach(service => {
service.tariffs.forEach(tariff => {
tariff.privileges.forEach(privilege => {
const privilegeDiscount = findPrivilegeDiscount(privilege.privilegeId, privilege.price, discounts);
const privilegeDiscount = findPrivilegeDiscount(privilege.privilegeId, privilege.amount, discounts);
if (!privilegeDiscount) return;
const discountAmount = privilege.price * (1 - findDiscountFactor(privilegeDiscount));