Skip to content

[18.0] account_payment_term_extension - Fixed amount on first line breaks percentage calculation #924

@temuccio

Description

@temuccio

Module

account_payment_term_extension

Describe the bug

When a fixed amount is set on the first line of a payment term, the amount is not subtracted from the invoice total before calculating the percentage-based lines.

As a result, the percentage lines are calculated on the full invoice total instead of the residual amount (total minus fixed amount), which leads to an incorrect final installment. In some cases, this produces a negative amount on the last payment term line.

To Reproduce

Affected versions:

Odoo 18.0

Module: account_payment_term_extension

Steps to reproduce the behavior:

Create a payment term with:

Line 1: Fixed amount = 400€, Due immediately (0 days)
Line 2: 33% at 30 days
Line 3: 33% at 60 days
Line 4: 34% at 90 days

Create a customer invoice for 1,000€.

Apply the payment term to the invoice.

Expected behavior

The fixed amount (400€) should be subtracted from the invoice total before applying the percentage calculations.

Correct expected calculation for a 1,000€ invoice:

400€ at day 0
198€ at 30 days (33% of 600€)
198€ at 60 days (33% of 600€)
204€ at 90 days (34% of 600€)

Total: 1,000€

Actual behavior

The module calculates the percentage lines on the full invoice amount (1,000€), resulting in:

400.00€ due immediately
330.00€ at 30 days
330.00€ at 60 days
-60.00€ at 90 days

The last installment becomes negative because the total of previous lines exceeds the invoice total.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions