The Percentage Increase/Decrease calculation formula is strange. . .
Scenario:
Say you want to raise all of your product prices by 10%. You go into the batch product editor and raise site price 10%.
Then you want to off 10% off to certain customers via a price group.
The prices do Not match the original prices.
Example:
Product A Price: $100
You raise price by 10%.
Product A Price: $110
Customer 1 is in Price group that gives 10% off.
Product A Price for Customer 1: $99
It *should* be $100, but its $99 instead. This becomes a problem when you are dealing with large prices like $2000.
This code is located in BVSoftware.BVC5.Core > Utilities > Utilities.vb
BV Commerce Formula:
Code:
Public Shared Function ApplyDiscountPercent(ByVal monetaryAmount As Decimal, ByVal percentage As Decimal) As Decimal
Return Math.Round((monetaryAmount * ((100 - percentage) / 100)), 2)
End Function
Public Shared Function ApplyIncreasedPercent(ByVal monetaryAmount As Decimal, ByVal percentage As Decimal) As Decimal
Return Math.Round((monetaryAmount * ((100 + percentage) / 100)), 2)
End Function
Solution:
Correct Forumla:Code:
Public Shared Function ApplyDiscountPercent(ByVal monetaryAmount As Decimal, ByVal percentage As Decimal) As Decimal
'Return Math.Round((monetaryAmount * ((100 - percentage) / 100)), 2)
percentage = percentage / 100 + 1
Return Math.Round((monetaryAmount / percentage), 2)
End Function
Public Shared Function ApplyIncreasedPercent(ByVal monetaryAmount As Decimal, ByVal percentage As Decimal) As Decimal
'Return Math.Round((monetaryAmount * ((100 + percentage) / 100)), 2)
percentage = percentage / 100 + 1
Return Math.Round((monetaryAmount * percentage), 2)
End Function
Effectively this changes the formula to:
Amount * 1.x
Where x = Percent to add.
Or
Amount / 1.x
Where x = Percent to subtract.
Using this formula you can add 10% and then subtract 10% and end up with the original number.
Please make this modification to your code for future releases.