Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0045017Openbravo ERP09. Financial managementpublic2020-09-04 22:312020-09-10 13:21
lbressan 
inigo_lerga 
highmajoralways
closedfixed 
5
pi 
PR20Q3.1PR20Q3.1 
Core
2019-08-22
3.0PR19Q4
https://gitlab.com/openbravo/product/openbravo/-/commit/fc2fdb6259fb3cf3532e4c71f2188dcb1eb404d0 [^]
No
0045017: 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.
blocks defect 0044996 closed inigo_lerga Error in the Recalculate Amortization process 
Issue History
2020-09-09 16:14dmiguelezTypedefect => backport
2020-09-09 16:14dmiguelezTarget Version => PR20Q3.1
2020-09-10 12:26hgbotNote Added: 0122917
2020-09-10 13:21hgbotResolutionopen => fixed
2020-09-10 13:21hgbotStatusscheduled => closed
2020-09-10 13:21hgbotNote Added: 0122918
2020-09-10 13:21hgbotFixed in Version => PR20Q3.1
2020-09-10 13:21hgbotNote Added: 0122919

Notes
(0122917)
hgbot   
2020-09-10 12:26   
Merge Request created: https://gitlab.com/openbravo/product/openbravo/-/merge_requests/160 [^]
(0122918)
hgbot   
2020-09-10 13:21   
Merge request merged: https://gitlab.com/openbravo/product/openbravo/-/merge_requests/160 [^]
(0122919)
hgbot   
2020-09-10 13:21   
Directly closing issue as related merge request is already approved.

Repository: https://gitlab.com/openbravo/product/openbravo [^]
Changeset: 2b0f972fd8534ce16ced5c071b923f054771ec10
Author: inigo_lerga <inigo.lerga@openbravo.com>
Date: 2020-09-10T12:24:41+02:00
URL: https://gitlab.com/openbravo/product/openbravo/-/commit/2b0f972fd8534ce16ced5c071b923f054771ec10 [^]

fixes BUG-45017:Explicit deletion of Amortization lines

When an Asset's Amortization is recalculated, only its Amortization
records need to be deleted.

Backport of Regression 44996.

---
M src/org/openbravo/erpCommon/ad_process/assets/AssetLinearDepreciationMethodProcess.java
---