Skip to content

Fix discount percentage calculation to account for quantity #2157

@mlellah

Description

@mlellah

return (self.discount_fixed / self.price_unit) * 100

The _get_discount_from_fixed_discount method currently calculates the discount percentage based only on price_unit and discount_fixed.
This approach does not consider the quantity of items, which can lead to incorrect discount percentages when more than one unit is sold.

if float_is_zero(self.quantity, precision_rounding=currency.rounding): return 0.0

return (self.discount_fixed / (self.price_unit * self.quantity)) * 100

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions