Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0044996Openbravo ERP09. Financial managementpublic2020-09-04 22:312020-09-09 16:15
lbressan 
inigo_lerga 
highmajoralways
closedfixed 
5
pi 
PR20Q4 
dmiguelez
Core
2019-08-22
3.0PR19Q4
https://gitlab.com/openbravo/product/openbravo/-/commit/fc2fdb6259fb3cf3532e4c71f2188dcb1eb404d0 [^]
No
0044996: Error in the Recalculate Amortization process
From the assets window, when we select an asset record and click on the "Recalculate amortization" button, this process deletes the records associated an X amortization, including records of that amortization that correspond to other assets.

In the Assets window:
1. Create a record with the following data:
        Organization: F&B España, S.A
        Search Key: coche1
        Name: coche1
        Asset Category: Vehiculos
        Document No.: 10000006
        Currency: EUR
        Depreciate: true
        Depreciation Type: Linear
        Calculate Type: Time
        Usable Life - Months: 120
        Every Month Is 30Days: true
        Amortize: Monthly
        Depreciation Start Date : 01-03-2013
        Asset Value: 23000
        Residual Asset Value : 0.00
        Depreciation Amt: 23000
        Previously Depreciated Amt : 0.00

2. Then click on the button "Create Amortization"
3. Create another record idem to the previous one:

        Organization: F&B España, S.A
        Search Key: coche2
        Name: coche2
        Asset Category: Vehiculos
        Document No.: 10000007
        Currency: EUR
        Depreciate: true
        Depreciation Type: Linear
        Calculate Type: Time
        Usable Life - Months: 120
        Every Month Is 30Days: true
        Amortize: Monthly
        Depreciation Start Date : 01-03-2013
        Asset Value: 23000
        Residual Asset Value : 0.00
        Depreciation Amt: 23000
        Previously Depreciated Amt : 0.00

4. Repeat step 2.


Navigate to the Amortization window:

     1. Filter the records by the date field with value "30-07-2020"
     2. Observe that there are two records in the lines of that amortization, one corresponds to the first asset and the other to the second asset.

In the Assets window:

    1. Select the record that corresponds to the second asset created and click on the "Recalculate Amortization" button.
    2. Navigate to the Amortization window and refresh the previously filtered record.
    3. There it can be seen that the lines corresponding to the other asset have disappeared.

In conclusion, when an asset is recalculated, only the records that correspond to the depreciation of that asset should be deleted.

We attach a video with the aforementioned example.
Only delete records that correspond to the asset that is being recalculated.
Code where the error occurs:

Class: AssetLinearDepreciationMethodProcess.java
Line numer: from 143

    // Remove unprocessed Amortization and its line when recalculating
    final List<AmortizationLine> amortizationLineListToRemove = new ArrayList<>();
    for (AmortizationLine al : amortizationLineList) {
      final Amortization amortization = OBDal.getInstance()
          .get(Amortization.class, al.getAmortization().getId());
      if (StringUtils.equals(amortization.getProcessed(), "N")) {
        amortizationLineListToRemove.add(al);
        amortization.getFinancialMgmtAmortizationLineList().clear();
        OBDal.getInstance().remove(amortization);
      }
    }
    asset.getFinancialMgmtAmortizationLineList().removeAll(amortizationLineListToRemove);
    OBDal.getInstance().flush();

It's important to have on mind:
After solving this bug, it will be necessary to have a script or method to correct the missing amounts of the records that have been eliminated from assets that were not associated with the asset in question, bearing in mind that the accounting periods have already been closed.
No tags attached.
depends on backport 0045017PR20Q3.1 closed inigo_lerga Error in the Recalculate Amortization process 
depends on backport 0045018PR20Q2.2 closed inigo_lerga Error in the Recalculate Amortization process 
caused by defect 0041297 closed AtulOpenbravo Not possible to recalculate an amortization 
? Openbravo - Amortization.mp4 (2,873,976) 2020-09-04 22:31
https://issues.openbravo.com/file_download.php?file_id=14940&type=bug
Issue History
2020-09-04 22:31lbressanNew Issue
2020-09-04 22:31lbressanAssigned To => Triage Finance
2020-09-04 22:31lbressanFile Added: Openbravo - Amortization.mp4
2020-09-04 22:31lbressanModules => Core
2020-09-04 22:31lbressanResolution time => 1597701600
2020-09-04 22:31lbressanTriggers an Emergency Pack => No
2020-09-04 22:51lbressanNote Added: 0122695
2020-09-04 22:51lbressanDescription Updatedbug_revision_view_page.php?rev_id=21629#r21629
2020-09-04 22:51lbressanProposed Solution updated
2020-09-04 23:22lbressanRegression introduced by commit => https://gitlab.com/openbravo/product/openbravo/-/commit/fc2fdb6259fb3cf3532e4c71f2188dcb1eb404d0 [^]
2020-09-07 09:20dmiguelezResolution time1597701600 => 1600984800
2020-09-07 16:08dmiguelezAssigned ToTriage Finance => inigo_lerga
2020-09-07 16:13dmiguelezNote Added: 0122758
2020-09-07 16:25lbressanRegression date => 2019-08-22
2020-09-07 16:25lbressanRegression introduced in release => 3.0PR19Q4
2020-09-07 16:32lbressanNote Added: 0122761
2020-09-07 16:59rafarodaRelationship addedcaused by 0041297
2020-09-08 08:17inigo_lergaStatusnew => scheduled
2020-09-08 14:23hgbotNote Added: 0122792
2020-09-08 14:35inigo_lergaNote Added: 0122802
2020-09-09 15:39hgbotResolutionopen => fixed
2020-09-09 15:39hgbotStatusscheduled => closed
2020-09-09 15:39hgbotFixed in Version => PR20Q4
2020-09-09 15:39hgbotNote Added: 0122884
2020-09-09 15:39hgbotNote Added: 0122885
2020-09-09 16:13dmiguelezStatusclosed => new
2020-09-09 16:13dmiguelezResolutionfixed => open
2020-09-09 16:14dmiguelezFixed in VersionPR20Q4 =>
2020-09-09 16:14dmiguelezStatusnew => scheduled
2020-09-09 16:14dmiguelezStatusscheduled => resolved
2020-09-09 16:14dmiguelezFixed in Version => PR20Q4
2020-09-09 16:14dmiguelezFixed in SCM revision => https://gitlab.com/openbravo/product/openbravo/-/commit/4275f8d696686a8df665f8e87bda837896adbfa5 [^]
2020-09-09 16:14dmiguelezResolutionopen => fixed
2020-09-09 16:15dmiguelezReview Assigned To => dmiguelez
2020-09-09 16:15dmiguelezNote Added: 0122887
2020-09-09 16:15dmiguelezStatusresolved => closed

Notes
(0122695)
lbressan   
2020-09-04 22:51   
It's important to have on mind:
After solving this bug, it will be necessary to have a script or method to correct the missing amounts of the records that have been eliminated from assets that were not associated with the asset in question, bearing in mind that the accounting periods have already been closed.
(0122758)
dmiguelez   
2020-09-07 16:13   
Notes about the affected data:

- Only not processed Amortizations are affected by this issue, any Amortization that was processed (therefore validated by the user) is kept as it was. Only draft Amortizations are deleted
- Periods only matter while processing an Amortization. It is possible to recalculate Amortizations for any date regardless of the status of the Period. Only when processing the Amortization the check is done
- It is possible to Recalculate the Amortization again for the missing Assets. When the lines are deleted, launching the process again for the missing Assets will include them back in the Amortization.

That last point can be used as the workaround to fix the data, as it is only necessary to launch the process again for the missing assets. Also, as explained above, only Amortizations in draft status (not validated by the user) are affected.

A script or process to fix the data should be considered only if the amount of records to be processed is big enough that is not practical to do it manually.
(0122761)
lbressan   
2020-09-07 16:32   
Notes about the affected data:
The client wants to note this because they have more than 2000 assets that have been affected by this issue and they need a script to solve this problem and it is not feasible for them to reinsert those lines for the periods that are already closed.
(0122792)
hgbot   
2020-09-08 14:23   
Merge Request created: https://gitlab.com/openbravo/product/openbravo/-/merge_requests/151 [^]
(0122802)
inigo_lerga   
2020-09-08 14:35   
--Test Plan Mantis--

As the F&B International Group Admin role in Backend:
1º- Go to Assets window and create a new record with the following data:
      - Organization: F&B España, S.A
      - Search Key: coche1
      - Name: coche1
      - Asset Category: Vehiculos
      - Document No.: 10000006
      - Currency: EUR
      - Depreciate: true
      - Depreciation Type: Linear
      - Calculate Type: Time
      - Usable Life - Months: 120
      - Every Month Is 30Days: true
      - Amortize: Monthly
      - Depreciation Start Date : 01-03-2013
      - Asset Value: 23000
      - Residual Asset Value : 0.00
      - Depreciation Amt: 23000
      - Previously Depreciated Amt : 0.00

2º- Press the Create Amortization button and OK in the popup window.

3º- Create a new record in the same Assets window with the following data:
      - Organization: F&B España, S.A
      - Search Key: coche2
      - Name: coche2
      - Asset Category: Vehiculos
      - Document No.: 10000007
      - Currency: EUR
      - Depreciate: true
      - Depreciation Type: Linear
      - Calculate Type: Time
      - Usable Life - Months: 120
      - Every Month Is 30Days: true
      - Amortize: Monthly
      - Depreciation Start Date : 01-03-2013
      - Asset Value: 23000
      - Residual Asset Value : 0.00
      - Depreciation Amt: 23000
      - Previously Depreciated Amt : 0.00

4º- Press the Create Amortization button and OK in the popup window.

5º- Now, in the second record created, press the Recalculate Amortization button.

6º- Go to the Amortization window and open the "31-12-2020" record.

    #You will see that both Assets appear in the Lines Tab as, with the fix applied,
    only the selected Asset when Recalculating Amortization process is launched
    gets his Amortization records deleted (and created again later).#
    
    #Before, both Assets' records were eliminated and only the one selected while launching the process
    was recreated later.#
(0122884)
hgbot   
2020-09-09 15:39   
Directly closing issue as related merge request is already approved.

Repository: https://gitlab.com/openbravo/product/openbravo [^]
Changeset: 4275f8d696686a8df665f8e87bda837896adbfa5
Author: Iñigo Lerga Valencia <inigo.lerga@openbravo.com>
Date: 2020-09-09T13:39:37+00:00
URL: https://gitlab.com/openbravo/product/openbravo/-/commit/4275f8d696686a8df665f8e87bda837896adbfa5 [^]

fixes BUG-44996:Only delete records of recalculated asset

When an Asset's Amortization is recalculated, only its Amortization
records need to be deleted. Before this fix, all were deleted.

---
M src/org/openbravo/erpCommon/ad_process/assets/AssetLinearDepreciationMethodProcess.java
---
(0122885)
hgbot   
2020-09-09 15:39   
Merge request merged: https://gitlab.com/openbravo/product/openbravo/-/merge_requests/151 [^]
(0122887)
dmiguelez   
2020-09-09 16:15   
Code Review + Testing Ok