fix: price calculation
This commit is contained in:
parent
3c7dc85abb
commit
c9bf0c1ab5
@ -94,11 +94,12 @@ function TariffPage() {
|
|||||||
currentTariffs,
|
currentTariffs,
|
||||||
isUserNko
|
isUserNko
|
||||||
);
|
);
|
||||||
|
console.log('AAAAAAAAAAAa', priceAfterDiscounts, priceBeforeDiscounts,(priceBeforeDiscounts - priceAfterDiscounts))
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TariffCard
|
<TariffCard
|
||||||
key={tariff._id}
|
key={tariff._id}
|
||||||
discount={`${((priceBeforeDiscounts - priceAfterDiscounts) / (priceBeforeDiscounts / 100)).toFixed(0)}%`}
|
discount={(priceBeforeDiscounts - priceAfterDiscounts)?`${((priceBeforeDiscounts - priceAfterDiscounts) / (priceBeforeDiscounts / 100)).toFixed(0)}%`:""}
|
||||||
icon={
|
icon={
|
||||||
<NumberIcon
|
<NumberIcon
|
||||||
number={index + 1}
|
number={index + 1}
|
||||||
|
@ -16,10 +16,28 @@ export function calcIndividualTariffPrices(
|
|||||||
let priceAfterDiscounts = priceBeforeDiscounts
|
let priceAfterDiscounts = priceBeforeDiscounts
|
||||||
|
|
||||||
const cart = calcCart([...currentTariffs, tariff], discounts, purchasesAmount, isUserNko)
|
const cart = calcCart([...currentTariffs, tariff], discounts, purchasesAmount, isUserNko)
|
||||||
|
|
||||||
|
priceAfterDiscounts*=findDiscountFactor(cart.appliedLoyaltyDiscount)
|
||||||
|
priceAfterDiscounts*=findDiscountFactor(cart.appliedCartPurchasesDiscount)
|
||||||
|
cart.services.forEach(s => {
|
||||||
|
if (s.serviceKey === tariff.privileges[0].serviceKey) {
|
||||||
|
|
||||||
cart.allAppliedDiscounts.forEach((discount) => {
|
priceAfterDiscounts *=findDiscountFactor(s.appliedServiceDiscount)
|
||||||
priceAfterDiscounts *= findDiscountFactor(discount)
|
// s.tariffs.forEach(t => {
|
||||||
})
|
// if (t.id === tariff._id) {
|
||||||
|
// const apl = t.privileges.reduce((a,n) => a+n.price*findDiscountFactor(n.appliedPrivilegeDiscount),0)
|
||||||
|
// const sum = t.privileges.reduce((a,n)=>a+n.price,0)
|
||||||
|
// console.log(sum,apl)
|
||||||
|
// if (sum-apl)
|
||||||
|
// priceAfterDiscounts*= (sum-apl)/sum
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// cart.allAppliedDiscounts.forEach((discount) => {
|
||||||
|
// priceAfterDiscounts *= findDiscountFactor(discount)
|
||||||
|
// })
|
||||||
|
|
||||||
return { priceBeforeDiscounts, priceAfterDiscounts }
|
return { priceBeforeDiscounts, priceAfterDiscounts }
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user