Skip to content

Applying a Discount with more than 2 decimals ends up in wrong calculation #723

@pannagger

Description

@pannagger

Hi folks,

We encountered an issue when applying a discount on a ZFItem with more than 2 decimal places, for example, "12.20040000" Euros. This number results from a discount on the document level divided by an odd quantity.

The problem occurs in:

mustangproject/library/src/main/java/org/mustangproject/ZUGFeRD/LineCalculator.java at Line 59.

Here, the setScale(..) method uses 2 as the new scale, which causes the total net amount (with other similar positions) to be 211.10 instead of 211.094000. After applying the VAT of 19% and rounding the result to 2 decimal places, the total becomes 251.21 instead of 251.20.

I recommend to adapt the mentioned line to use a scale of 18 like in Line 58.

Kind regards
Philip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions