Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0047707Openbravo ERP07. Sales managementpublic2021-09-16 16:542021-10-06 08:45
lbressan 
vmromanos 
normalmajoralways
closedfixed 
5
pi 
PR22Q1 
Core
No
0047707: Wrong amount when adding a new line in the payment plan modification
Wrong amount when adding a new line in the payment plan modification in sales invoice.
Module: org.openbravo.advpaymentmngt
1)Go to the "sales invoice" window

2) Create a new invoice

3) When creating the invoice, complete the data and in "Payment Conditions" choose the option "20% after 15 days, 40% after 30 days and the rest after 60 days" or another similar option.

4) Add some lines with products, in "Invoiced quantity" enter an amount, for example, "100".

5) Complete the sales invoice.

6) Select the "Payment Plan" and click in the button called "Modify Payment Plan"

6) Delete some payments

7) Add a payment that will appear in "0", for example: 10.

8) Add another payment where a negative amount appears, for example: -10
No tags attached.
depends on defect 0047798 new Triage Platform Base Tab --> Remove Function weird behavior 
depends on defect 0047799 new Triage Platform Base Tab --> Add Function different problems with the new record created 
Not all the children of this issue are yet resolved or closed.
zip ticket28640.zip (966,471) 2021-09-16 16:54
https://issues.openbravo.com/file_download.php?file_id=16200&type=bug
Issue History
2021-09-16 16:54lbressanNew Issue
2021-09-16 16:54lbressanAssigned To => Triage Finance
2021-09-16 16:54lbressanFile Added: ticket28640.zip
2021-09-16 16:54lbressanModules => Core
2021-09-16 16:54lbressanRegression date => 2021-10-01
2021-09-16 16:54lbressanTriggers an Emergency Pack => No
2021-09-17 07:55ivancaceresIssue Monitored: ivancaceres
2021-09-18 12:13eugeniIssue Monitored: eugeni
2021-09-20 13:29vmromanosRegression date2021-10-01 =>
2021-09-20 13:29vmromanosNote Added: 0131926
2021-09-20 13:48vmromanosAssigned ToTriage Finance => aferraz
2021-09-20 13:48vmromanosStatusnew => acknowledged
2021-10-01 17:53vmromanosStatusacknowledged => scheduled
2021-10-01 17:53vmromanosAssigned Toaferraz => vmromanos
2021-10-01 18:20vmromanosRelationship addeddepends on 0047798
2021-10-01 18:20vmromanosRelationship addeddepends on 0047799
2021-10-01 18:42hgbotNote Added: 0132102
2021-10-04 13:35vmromanosNote Added: 0132131
2021-10-06 08:45hgbotNote Added: 0132180
2021-10-06 08:45hgbotResolutionopen => fixed
2021-10-06 08:45hgbotStatusscheduled => closed
2021-10-06 08:45hgbotFixed in Version => PR22Q1
2021-10-06 08:45hgbotNote Added: 0132181

Notes
(0131926)
vmromanos   
2021-09-20 13:29   
Filled due date from the regression date
(0132102)
hgbot   
2021-10-01 18:42   
Merge Request created: https://gitlab.com/openbravo/product/openbravo/-/merge_requests/437 [^]
(0132131)
vmromanos   
2021-10-04 13:35   
Test plan:

As System Admin.
Go to Window, Tabs and Fields. Search for Sales Invoice window.
Select Payment Plan tab.
Search for the Modify Payment Plan field which is hidden.
Set Displayed = Y

Change role to F&B group admin
Go to Payment Term window.
Create a header for * org
 - Overdue Payment Days Rule : 100
Create the following lines:
 - Percentage due: 25, Overdue Payment Days Rule: 10
 - Percentage due: 35, Overdue Payment Days Rule: 15
 - Percentage due: 20, Overdue Payment Days Rule: 90

Go to Sales Invoice window and create a new record. Select the above payment term in the header.
Enter any line with some amount (greater than 100 for easier testing).
Complete the invoice.

Go to Payment Plan tab and select any record.
Press Modify Payment Plan button.
A grid is opened with several lines.

Delete any of the lines.
Now create a new one. Verify the outstanding amount = expected amount, and it's exactly the same amount as the record previously removed.
Set a lower outstanding amount and press enter.
Enter a new record. Verify the proposed outstanding amount is the amount you have just subtract in the previous record.
Verify the amounts match and press Submit.
Verify the payment plan is successfully updated.

Now partially pay a payment plan line through the Add Payment button. Make sure you leave some amount pending to be paid in the payment plan line.
Open the Modify Payment Plan process.
Decrease the outstanding amount of the payment plan line partially paid.
Now enter a new line. Verify the outstanding amount proposed is the amount you have just subtract in the previous record.
Cancel the changes.

Now fully pay the previously partially paid payment plan line through the Add Payment button.
Open the Modify Payment Plan process. Check the fully paid line is not shown anymore.
Delete any of the lines.
Now create a new one. Verify the outstanding amount = expected amount, and it's exactly the same amount as the record previously removed.



Note that there are two weird behaviors that are outside of the scope of this fix:
- Payment Method is not properly defaulted when creating a new record.
- You need to press Enter (or click into another row's outstanding amount) for a proper validation.
See 0047799 for details
(0132180)
hgbot   
2021-10-06 08:45   
Merge request merged: https://gitlab.com/openbravo/product/openbravo/-/merge_requests/437 [^]
(0132181)
hgbot   
2021-10-06 08:45   
Directly closing issue as related merge request is already approved.

Repository: https://gitlab.com/openbravo/product/openbravo [^]
Changeset: ba5b80a20c408e5e3186292f93c392497ad990a4
Author: Víctor Martínez Romanos <victor.martinez@openbravo.com>
Date: 2021-10-04T13:39:29+02:00
URL: https://gitlab.com/openbravo/product/openbravo/-/commit/ba5b80a20c408e5e3186292f93c392497ad990a4 [^]

Fixed ISSUE-47707: Modify Payment Plan wrong amounts autocalculated

Important: this is a partial fix that improves the situation in most
of the scenarios, but not in all. The platform used to validate and
generate new records is very weak and makes it impossible to properly
control all the scenarios. See 0047798 and 0047799 for details.

The main problem was while trying to retrieve the invoice header information.
The code was wrongly using "grid.view.parentWindow.activeView.getContextInfo"
which retrieves the Payment Plan record. Now we use
"grid.view.parentWindow.views[0].getContextInfo" to get the invoice header info.

totalExpected and totalReceived calculations were not used, so they are removed.

When adding a new record (OB.APRM.addNew) the calculation was doing:
outstandingAmt = Sum(GridExpected) - Sum(GridReceived) - Sum(GridOutstanding)

This algorithm won't work in the moment we delete a record in the grid.

Instead the algorithm now calculates the outstanding amount as:
outstandingAmt = invoiceOutstandingAmt - Sum(GridOutstandingAmt)

This is safer because it works with these scenarios:
1) If no payment plan is fully paid yet. Then all the records are displayed in the grid.
2) If there is any payment plan fully paid. Then those paid payment plans are not displayed.
3) If the user has changed any outstanding amount before creating the new record.

Then, the new record's expected amount is set equal to the calculated outstanding amount,
because it's a new record so both amount should always match.
If there are more adjustements in other lines' outstanding amount, the expected amounts will be
automatically recalculated.

The payment method information set in the new record is removed because the
"selectedRecord" object doesn't have this information. Instead, the payment method (and
any other information should be given in the moment of creating the new object by cloning
and existing one).

---
M modules/org.openbravo.advpaymentmngt/web/org.openbravo.advpaymentmngt/js/ob-aprm-utilities.js
---