[Bug][SubscriptionBilling] Incorrect deferral amount sign for negative lines in contract invoices and credit memos
Nobody has claimed this yet.
- Dominant language
- AL
- Stars
- 683
- Forks
- 459
- Avg merge
- 3d 26m
- Merged PRs (30d)
- 633
Description
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
- Create an item set up for subscription.
- Create a customer subscription contract.
- Extend the contract with the item.
- Extend the contract again with the same item, using a negative quantity for this second line (e.g.
-1). - Change the Calculation Base Amount to a value lower than the amount in the first line.
- Create a contract invoice and post it.
- 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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue using the subscription contract steps, including a negative quantity and a calculation base below the first line amount. Inspect the contract invoice and automatically created credit memo deferral entries, then release the deferrals and verify that negative lines produce positive offsetting amounts and correct G/L signs for both customer and vendor flows.
Written by the indexing model from the issue text.
Assessment
- Domain
- payments
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100