Skip to content

[Bug][SubscriptionBilling] Incorrect deferral amount sign for negative lines in contract invoices and credit memos #8599

@miljance

Description

@miljance

Describe the issue

When a contract (subscription) invoice or auto-generated credit memo contains a negative line — the posted contract deferrals are calculated with the wrong sign.

Given an invoice such as:

Line Quantity Line Amount
1 1 100
2 -1 -20

Posting produces two deferral lines that are both negative, whereas the negative line (line 2) should yield a positive deferral amount. The same defect appears when releasing the contract deferrals: the resulting G/L entries carry the wrong sign. It also reproduces in automatically created credit memos when the positive amount is smaller than the negative amount.

Expected behavior

Deferral lines should follow the sign of each individual line: a negative invoice line should produce a positive (offsetting) deferral, and releasing the deferrals should post G/L entries with the correct sign. Both the customer (sales) and vendor (purchase) sides should behave consistently. It should not be possible to extend a contract with a negative quantity.

Steps to reproduce

  1. Create an item set up for subscription.
  2. Create a customer subscription contract.
  3. Extend the contract with the item.
  4. Extend the contract again with the same item, using a negative quantity for this second line (e.g. -1).
  5. Change the Calculation Base Amount to a value lower than the amount in the first line.
  6. Create a contract invoice and post it.
  7. Check the customer deferral entries → both entries are negative (the second line should be positive).

Additional context

No response

I will provide a fix for a bug

  • I will provide a fix for a bug

Metadata

Metadata

Assignees

No one assigned

    Labels

    ApprovedThe issue is approvedFinanceGitHub request for Finance area

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions