Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0028236Openbravo ERP09. Financial managementpublic2014-11-20 12:392015-05-27 13:44
txasu 
pramakrishnan 
normalmajoralways
closedno change required 
30Ubuntu 14.10
 
 
pramakrishnan
Core
Production - Confirmed Stable
2014-04-03
3.0PR14Q2
https://code.openbravo.com/erp/devel/pi/rev/f7078a85289e6c61918f567b28d2df3fe17ddb47 [^]
No
0028236: Payment schedule amount incorrectly calculated when adding a payment from reconcile window to a sales order
Payment schedule amount incorrectly calculated when adding a payment from financial account reconcile window to a sales order
- Create a sales order from "F&B España - Región Norte" org to BP "Alimentos y Supermercados, S.A" for 1,000 and book it.
- Go to the Financial Account "Cuenta de Banco"
- Click on tab "Imported Bank Statement"
- Click on new, give it a name, and go to "Bank Statement Lines" tab.
- Click on new, give it a reference, choose "Alimentos y Supermercados, S.A" business partner, set amount in to 1,000.
- Click on save and process, and Match Statement.
- Click on "+" icon to create a transaction.
- Click on Add Payment In/Out
- Choose transaction type "Orders", set the amount to 1,000.
- Select just the 1,000 order created in the previous step.
- Click on process, and choose "Process Received payment/s and deposit", and click on Ok.
- Go to the sales order, and realize that payment schedule record says:
Expected Amount: 1,000
Received Amount: 2,000
Outstanding: -1,000
- fin_payment_schedule record is not correctly updated when running the described steps.
- fin_payment_schedule_detail records are ok. The issue is when updating the fin_payment_schedule record.
- Please notice that if you click on "Add Transaction" in Financial Account window, bug is not reproduced, only if AddTransaction servlet is invoqued from the automatic reconcile window.
No tags attached.
has duplicate defect 0030007 closed aferraz Payment schedule amount incorrectly calculated when adding a payment from reconcile window to a sales order 
blocks defect 00301703.0PR15Q3 closed aferraz Generic UpdatePaymentPlan module script 
causes defect 0029389 closed AtulOpenbravo Invoice's Payment Plan and Order's Payment Plan are not updated when reactivating partial payment 
diff Fix28236.diff (31,356) 2014-12-04 07:44
https://issues.openbravo.com/file_download.php?file_id=7572&type=bug
Issue History
2014-11-20 12:39txasuNew Issue
2014-11-20 12:39txasuAssigned To => adrianromero
2014-11-20 17:44txasuNote Added: 0071857
2014-11-20 18:08txasuNote Added: 0071858
2014-11-20 20:14txasuNote Added: 0071859
2014-11-20 20:44txasuNote Added: 0071860
2014-11-21 10:45SandrahuguetAssigned Toadrianromero => pramakrishnan
2014-11-21 10:51SandrahuguetRegression level => Production - Confirmed Stable
2014-11-21 11:28pramakrishnanStatusnew => scheduled
2014-11-21 11:28pramakrishnanfix_in_branch => pi
2014-11-21 11:58SandrahuguetProjectModules => Openbravo ERP
2014-11-21 11:59SandrahuguetModules => Core
2014-11-21 11:59SandrahuguetTriggers an Emergency Pack => No
2014-11-21 11:59SandrahuguetCategoryAdvanced Payments => 09. Financial management
2014-11-21 11:59Sandrahuguetfix_in_branchpi =>
2014-11-27 12:28SandrahuguetRegression date => 2014-04-03
2014-11-27 12:28SandrahuguetRegression introduced in release => 3.0PR14Q2
2014-11-27 12:28SandrahuguetRegression introduced by commit => https://code.openbravo.com/erp/devel/pi/rev/f7078a85289e6c61918f567b28d2df3fe17ddb47 [^]
2014-11-27 12:42pramakrishnanFile Added: Issue28236.diff
2014-11-27 12:47pramakrishnanReview Assigned To => pramakrishnan
2014-11-27 12:47pramakrishnanNote Added: 0072062
2014-11-27 12:47pramakrishnanStatusscheduled => closed
2014-11-27 12:47pramakrishnanResolutionopen => no change required
2014-11-27 12:47pramakrishnanFixed in Version => pi
2014-11-27 13:06pramakrishnanNote Added: 0072064
2014-11-27 13:06pramakrishnanStatusclosed => new
2014-11-27 13:06pramakrishnanResolutionno change required => open
2014-11-27 13:06pramakrishnanFixed in Versionpi =>
2014-11-27 13:14pramakrishnanFile Deleted: Issue28236.diff
2014-12-01 11:46pramakrishnanFile Added: Issue28236.diff
2014-12-01 11:46pramakrishnanNote Added: 0072181
2014-12-01 11:46pramakrishnanStatusnew => closed
2014-12-01 11:46pramakrishnanResolutionopen => no change required
2014-12-04 07:44pramakrishnanNote Added: 0072272
2014-12-04 07:44pramakrishnanStatusclosed => new
2014-12-04 07:44pramakrishnanResolutionno change required => open
2014-12-04 07:44pramakrishnanFile Deleted: Issue28236.diff
2014-12-04 07:44pramakrishnanFile Added: Fix28236.diff
2014-12-04 07:45pramakrishnanStatusnew => closed
2014-12-04 07:45pramakrishnanResolutionopen => no change required
2014-12-05 12:52txasuNote Added: 0072309
2015-05-26 18:29aferrazRelationship addedhas duplicate 0030007
2015-05-27 13:44aferrazRelationship addedcauses 0029389
2015-06-12 14:11vmromanosRelationship addedblocks 0030170

Notes
(0071857)
txasu   
2014-11-20 17:44   
Furthermore, if you delete the conciliation and transaction in financial account, and try to re-open the sales order, the "Related payments" error is shown, when is it false: the payment was deleted, but:
1- Due to the issue, instead of received amount=1,000 outstanding=0; the result was received amount=2,000 outstanding=-1,000
2- When deleting the payment in, then the information in the payment plan tab of the sales order is: received amount=1,000 outstanding=0. But the number of payments column says "0", and actually, the payment plan detail tab is empty.
This means that, in order to fix this issue, it's required a module script that updates all this amounts, as there is no way (through UI) to fix this :(
(0071858)
txasu   
2014-11-20 18:08   
In FIN_AddPayment.java, at line 1127, this line:
paymentSchedule.setPaidAmount(paymentSchedule.getPaidAmount().add(amount));
sets the incorrect amount, as the paymentSchedule.PaidAmount value is already updated with the amount of the payment that is being created.
Following the example in steps to reproduce. When arriving this point, the values are:
paymentSchedule.getPaidAmount() <= 1,000
amount <= 1,000
This way, the paid amount that is set is 2,000 and not 1,000.
This line was set in the 3.0RC2 tagged changeset, so there is not the problem. It seems, this function is, now, called twice during the process, or something like that.
(0071859)
txasu   
2014-11-20 20:14   
After a deeper research, here you have my two cents:

- Fin_PaymentProcess class (in line 409) calls FIN_AddPayment.updatePaymentScheduleAmounts which actually updates the paid amount of the fin_payment_schedule record.
- Afterwards, in line 447, OBDal.getInstance().flush() persists these changes.
- Once the execuction is over, and servlet finishes completely the execution, then PaidStatusEventHandler class is invoked and onUpdate function executed. As psd.isInvoicePaid() is true, then FIN_Utility.updatePaymentAmounts function is run again, duplicating the paid amount.
(0071860)
txasu   
2014-11-20 20:44   
I've gone as further as I can. I'm not used at all to this new functionality in OB of EntityPersistenceEventObserver objects.
This one task I do several times per week, and it was always working fine. I've upgraded from MP20 to PR14Q2.6, and now this issue is faced. It seems to be related to the changes done in the windows of the advanced payables and receivables module.
Thanks in advance for your help!!
(0072062)
pramakrishnan   
2014-11-27 12:47   
Issue not reproducible in PI. Attached fix for Q3 version.
(0072064)
pramakrishnan   
2014-11-27 13:06   
Module script needs to be modified for performance reasons.
(0072181)
pramakrishnan   
2014-12-01 11:46   
Issue not reproducible in PI. Attached fix for Q3 version.
(0072272)
pramakrishnan   
2014-12-04 07:44   
Reopened to attach updated patch
(0072309)
txasu   
2014-12-05 12:52   
Hi.

One question. Has the module-script been included in PI?

Thanks. Regards.