Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0035137Openbravo ERPZ. Otherspublic2017-02-02 13:202017-03-22 01:01
maite 
AtulOpenbravo 
urgentmajoralways
closedfixed 
5
 
3.0PR17Q2 
markmm82
Advanced Payables and Receivables Mngmt
No
0035137: Concurrency problem: current balance wrongly calculated when 2 transactions are processed at same time
In case 2 transactions are processed at same time, current balance field is only updated with second transaction's amount. Problem is that for these 2 transactions same value is returned in financialAccount.getCurrentBalance() as process is not ensuring that transactions are processed in sequential order
1. In order to easily simulate the 2 transactions are processed at same time it is necessary to set a break-point just after execution of following code (line 119) in FIN_TransactionProcess.java:

financialAccount.setCurrentBalance(financialAccount.getCurrentBalance().add( transaction.getDepositAmount().subtract(transaction.getPaymentAmount())));

2. Access any Financial Account and check value of "Current Balance" fiel. Go to Transactions tab and create new record setting any GL Item and amount=10. Press "Process" button and execution should be stopped in previous break-point
3. Open "new incognito window" in Chrome and access same Financial Account, go to Transactions tab and create new record setting any GL Item and amount=20. Press "Process" button and execution should be stopped in previous break-point
4. Press "Resume" button (F8) in Eclipse's execution to resume both processes
5. Realize that "Current Balance" field has only been update with +20 amount (instead of +30)
No tags attached.
related to defect 0034021 closed Sanjota Concurrency problem: is possible to process same transaction document more than one time when accessing from different sessions 
related to defect 0039672 closed Sandrahuguet Improve contention problems in fin_financial_account 
causes defect 0035523 closed AtulOpenbravo It is not possible to process certain transactions from Financial Account 
Issue History
2017-02-02 13:20maiteNew Issue
2017-02-02 13:20maiteAssigned To => Triage Finance
2017-02-02 13:20maiteModules => Advanced Payables and Receivables Mngmt
2017-02-02 13:20maiteResolution time => 1487804400
2017-02-02 13:20maiteTriggers an Emergency Pack => No
2017-02-02 13:22maiteIssue Monitored: networkb
2017-02-02 13:32maiteRelationship addedrelated to 0034021
2017-02-02 17:15markmm82Assigned ToTriage Finance => Sanjota
2017-02-06 12:30SanjotaNote Added: 0094072
2017-02-06 12:34SanjotaNote Edited: 0094072bug_revision_view_page.php?bugnote_id=0094072#r14475
2017-02-06 13:43SanjotaStatusnew => scheduled
2017-03-07 18:27markmm82Assigned ToSanjota => AtulOpenbravo
2017-03-13 19:42markmm82Note Deleted: 0094072
2017-03-13 19:47markmm82Note Added: 0094984
2017-03-13 20:07markmm82Note Edited: 0094984bug_revision_view_page.php?bugnote_id=0094984#r14787
2017-03-14 17:36markmm82Note Added: 0095004
2017-03-15 00:13hgbotCheckin
2017-03-15 00:13hgbotNote Added: 0095007
2017-03-15 00:13hgbotStatusscheduled => resolved
2017-03-15 00:13hgbotResolutionopen => fixed
2017-03-15 00:13hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/498699b38a5d0ddb368c9be379e25eb2732ee091 [^]
2017-03-15 00:15markmm82Review Assigned To => markmm82
2017-03-15 00:15markmm82Note Added: 0095008
2017-03-15 00:15markmm82Statusresolved => closed
2017-03-15 00:15markmm82Fixed in Version => 3.0PR17Q2
2017-03-15 14:52markmm82Note Added: 0095050
2017-03-15 14:52markmm82Statusclosed => new
2017-03-15 14:52markmm82Resolutionfixed => open
2017-03-15 14:52markmm82Fixed in Version3.0PR17Q2 =>
2017-03-15 15:01markmm82Note Edited: 0095050bug_revision_view_page.php?bugnote_id=0095050#r14809
2017-03-15 16:50markmm82Relationship addedcauses 0035523
2017-03-15 20:22hudsonbotCheckin
2017-03-15 20:22hudsonbotNote Added: 0095300
2017-03-21 16:43AtulOpenbravoStatusnew => scheduled
2017-03-21 17:20AtulOpenbravoNote Added: 0095481
2017-03-21 17:26hgbotCheckin
2017-03-21 17:26hgbotNote Added: 0095482
2017-03-21 17:26hgbotStatusscheduled => resolved
2017-03-21 17:26hgbotResolutionopen => fixed
2017-03-21 17:26hgbotFixed in SCM revisionhttp://code.openbravo.com/erp/devel/pi/rev/498699b38a5d0ddb368c9be379e25eb2732ee091 [^] => http://code.openbravo.com/erp/devel/pi/rev/d6f59afe1b6c08718f8431fb41d5dcf9158bfda8 [^]
2017-03-21 17:26hgbotCheckin
2017-03-21 17:26hgbotNote Added: 0095483
2017-03-21 17:27aferrazNote Added: 0095484
2017-03-21 17:27aferrazStatusresolved => closed
2017-03-21 17:27aferrazFixed in Version => 3.0PR17Q2
2017-03-22 01:01hudsonbotCheckin
2017-03-22 01:01hudsonbotNote Added: 0095495
2017-03-22 01:01hudsonbotCheckin
2017-03-22 01:01hudsonbotNote Added: 0095496
2018-11-22 09:54SandrahuguetRelationship addedrelated to 0039672

Notes
(0094984)
markmm82   
2017-03-13 19:47   
(edited on: 2017-03-13 20:07)
Test Plan 1

1. Set the breakpoint in the line setting the current balance: financialAccount.setCurrentBalance(…);
2. Access any Financial Account and check value of "Current Balance" field.
3. Go to Transactions tab and create a new BP Deposit record setting any GL Item and amount=10. Save it.
4. Open "new incognito window" in Chrome and access same Financial Account, go to Transactions tab and create another BP Deposit record setting any GL Item and amount=20.
5. Press "Process" button for transaction created in step 3 and execution should be stopped in previous break-point.
6. Press "Process" button for transaction created in step 4 and execution should be stopped in previous break-point.
7. Press "Resume" button (F8) in Eclipse's execution to resume both processes.
8. Realize that "Current Balance" field has been update with +30 amount (+10 of first transaction and +20 of the second one)

Repeat the test above but creating the transaction document as Bank Fee and BP Withdrawal

(0095004)
markmm82   
2017-03-14 17:36   
Test Plan 2

1. Set the breakpoint in the line setting the current balance: financialAccount.setCurrentBalance(…);
2. Access Caja Financial Account and check value of "Current Balance" field. For instance = 0.
3. Go to Transactions tab and create a new BP Deposit record setting any GL Item and Deposit amount=10. Save it.
4. Open "new incognito window" in Chrome and access same Financial Account, go to Transactions tab and create a Bank Fee record setting any GL Item and withdrawal amount=20.
5. Open "new incognito window" in Chrome and create a new Payment In window:
   Select any BP for F&B España.
   Payment method = Al contado
   Amount = 50
6. Add details to payment:
   Action Regarding Document = Process Received Payment(s) and Deposit
   Overpayment Action = Leave the credit to be used later
   Press done and execution should be stopped in previous break-point.
7. Press "Process" button for transaction created in step 3 and execution should be stopped in previous break-point.
6. Press "Process" button for transaction created in step 4 and execution should be stopped in previous break-point.
7. Press "Resume" button (F8) in Eclipse's execution to resume three processes.
8. Realize that "Current Balance" field has been updated with +40 amount (+10 of first transaction and -20 of the second one and +50 of the payment)
(0095007)
hgbot   
2017-03-15 00:13   
Repository: erp/devel/pi
Changeset: 498699b38a5d0ddb368c9be379e25eb2732ee091
Author: Atul Gaware <atul.gaware <at> openbravo.com>
Date: Sat Mar 11 00:46:09 2017 +0530
URL: http://code.openbravo.com/erp/devel/pi/rev/498699b38a5d0ddb368c9be379e25eb2732ee091 [^]

Fixes Issue 35137: Concurrency problem: current balance wrongly calculated
when 2 transactions are processed at same time

Lock added at database level for financial account being used while processing
or reactivating transaction.

---
M modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_TransactionProcess.java
---
(0095008)
markmm82   
2017-03-15 00:15   
Code review + Testing OK
(0095050)
markmm82   
2017-03-15 14:52   
(edited on: 2017-03-15 15:01)
Reopened because failing of some APRM tests and causing a regression

(0095300)
hudsonbot   
2017-03-15 20:22   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/54e102bef53e [^]
Maturity status: Test
(0095481)
AtulOpenbravo   
2017-03-21 17:20   
Test Plan

- Login as "F&B International Group Admin" role, go to Payment In window.

- Create a new record using the following values:
    Payment Date: Current date
    Received From: Alimentos y Supermercados, S.A.
    Payment Method: Cheque
    Amount: 10.00
    Save that record and click Add Details process.

- In the Add Details popup, click GL Items section to open it and create the following row:
    G/L Item: Capital social
    Received In: 10.00
    Paid Out: 0.00

- At the bottom of the Add Detail popup, fill "Action Regarding Document" field with "Process Received Payment(s)" value. Then click "Done".

- Navigate to "Financial Account" window, select Cuenta de Banco record and go to Transaction Tab.

- Create a new record will the following values:
    Transaction Type: BP Deposit
    Transaction Date: Current date
    Accounting Date: Current date
    Payment: (The just created payment from "Alimentos y Supermercados, S.A.
    business partner)
    Save the record.

- Click "Process" button. Then click Ok in the shown popup to process it.

- Check that It is successfully processed.
(0095482)
hgbot   
2017-03-21 17:26   
Repository: erp/devel/pi
Changeset: d6f59afe1b6c08718f8431fb41d5dcf9158bfda8
Author: Atul Gaware <atul.gaware <at> openbravo.com>
Date: Sat Mar 11 00:46:09 2017 +0530
URL: http://code.openbravo.com/erp/devel/pi/rev/d6f59afe1b6c08718f8431fb41d5dcf9158bfda8 [^]

Fixes Issue 35137: Concurrency problem: current balance wrongly calculated
when 2 transactions are processed at same time

Lock added at database level for financial account being used while processing
or reactivating transaction.

---
M modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_TransactionProcess.java
---
(0095483)
hgbot   
2017-03-21 17:26   
Repository: erp/devel/pi
Changeset: 5df11a52814649fae4c55427332479ed3b1c5ca8
Author: Atul Gaware <atul.gaware <at> openbravo.com>
Date: Tue Mar 21 10:09:56 2017 +0530
URL: http://code.openbravo.com/erp/devel/pi/rev/5df11a52814649fae4c55427332479ed3b1c5ca8 [^]

Related to issue 35137: Avoid financial account lazy initialization error

---
M modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_TransactionProcess.java
M modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/utility/FIN_Utility.java
---
(0095484)
aferraz   
2017-03-21 17:27   
Code review + Testing of second change OK.
(0095495)
hudsonbot   
2017-03-22 01:01   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/f76f24f98700 [^]
Maturity status: Test
(0095496)
hudsonbot   
2017-03-22 01:01   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/f76f24f98700 [^]
Maturity status: Test