How to avoid sum-issues in stimulsoft
Posted: Tue Dec 24, 2024 4:16 am
Hello,
I use 'Stimulsoft Reports.Net' to calculate a total price based on multiple items with different prices, ammount and tax-rates. This is my code:
Positions is a Bussines-Object, each object of Positions has exactly one Article. While Positions.UnitPrice and Positions.Amount are multiplied correctly, Stimulsoft uses for every calculation the same Positions.Article.TaxRate, instead the TaxRate which fits to its Position. For example:
Position | UnitPrice | Amount | TaxRate
So the calculation should be:
Instead stimulsoft calculates this: (In this example it uses only the TaxRate of Position 1)
How do I stop stimulsoft from doing so?
I use 'Stimulsoft Reports.Net' to calculate a total price based on multiple items with different prices, ammount and tax-rates. This is my code:
Code: Select all
{
Sum
(
DataBandTax,
(
Positions.UnitPrice *
Positions.Amount *
(
Positions.Article.TaxRate +
100
)
) /
100
)
}
Position | UnitPrice | Amount | TaxRate
Code: Select all
1 | 100 | 3 | 5
2 | 50 | 10 | 10
3 | 20 | 5 | 3
Code: Select all
((100 * 3 * (5 + 100)) / 100)
+ ((50 * 10 * (10 + 100)) / 100)
+ ((20 * 5 * (3 + 100)) / 100)
= 315 + 550 + 103
= 968
Code: Select all
((100 * 3) + (50 * 10) + (20 * 5))
* (1+(5/100))
= (300 + 200 + 100) * 1.05
= 600 * 1.05
= 630