Search in sources :

Example 11 with FixedAssetLine

use of com.axelor.apps.account.db.FixedAssetLine in project axelor-open-suite by axelor.

the class TestFixedAssetLineComputationService method testComputePlannedFixedAssetLineWithProrata.

@Test
public void testComputePlannedFixedAssetLineWithProrata() {
    FixedAsset fixedAsset = createFixedAsset(FixedAssetRepository.COMPUTATION_METHOD_LINEAR, LocalDate.of(2020, 10, 4), LocalDate.of(2020, 12, 31), 5, 12, createFixedAssetCategoryFromIsProrataTemporis(false), new BigDecimal("500.00"));
    FixedAssetLine firstFixedAssetLine = createFixedAssetLine(LocalDate.of(2020, 12, 31), new BigDecimal("23.89"), new BigDecimal("23.89"), new BigDecimal("476.11"));
    FixedAssetLine fixedAssetLine = fixedAssetLineComputationService.computePlannedFixedAssetLine(fixedAsset, firstFixedAssetLine);
    assertFixedAssetLineEquals(createFixedAssetLine(LocalDate.of(2021, 12, 31), new BigDecimal("100.00"), new BigDecimal("123.89"), new BigDecimal("376.11")), fixedAssetLine);
}
Also used : FixedAssetTestTool.createFixedAssetLine(com.axelor.apps.account.service.fixedasset.FixedAssetTestTool.createFixedAssetLine) FixedAssetLine(com.axelor.apps.account.db.FixedAssetLine) FixedAssetTestTool.createFixedAsset(com.axelor.apps.account.service.fixedasset.FixedAssetTestTool.createFixedAsset) FixedAsset(com.axelor.apps.account.db.FixedAsset) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 12 with FixedAssetLine

use of com.axelor.apps.account.db.FixedAssetLine in project axelor-open-suite by axelor.

the class TestFixedAssetLineComputationService method testComputeOngoingDegressiveAssetLine.

@Test
public void testComputeOngoingDegressiveAssetLine() {
    FixedAsset fixedAsset = createFixedAsset(FixedAssetRepository.COMPUTATION_METHOD_DEGRESSIVE, new BigDecimal("1.75"), LocalDate.of(2020, 3, 31), LocalDate.of(2020, 12, 31), 5, 12, createFixedAssetCategoryFromIsProrataTemporis(true, false), new BigDecimal("20000.00"));
    FixedAssetLine previousFixedAssetLine = createFixedAssetLine(LocalDate.of(2020, 12, 31), new BigDecimal("5250.00"), new BigDecimal("5250.00"), new BigDecimal("14750.00"));
    fixedAsset.addFixedAssetLineListItem(previousFixedAssetLine);
    FixedAssetLine fixedAssetLine = fixedAssetLineComputationService.computePlannedFixedAssetLine(fixedAsset, previousFixedAssetLine);
    assertFixedAssetLineEquals(createFixedAssetLine(LocalDate.of(2021, 12, 31), new BigDecimal("5162.50"), new BigDecimal("10412.50"), new BigDecimal("9587.50")), fixedAssetLine);
}
Also used : FixedAssetTestTool.createFixedAssetLine(com.axelor.apps.account.service.fixedasset.FixedAssetTestTool.createFixedAssetLine) FixedAssetLine(com.axelor.apps.account.db.FixedAssetLine) FixedAssetTestTool.createFixedAsset(com.axelor.apps.account.service.fixedasset.FixedAssetTestTool.createFixedAsset) FixedAsset(com.axelor.apps.account.db.FixedAsset) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 13 with FixedAssetLine

use of com.axelor.apps.account.db.FixedAssetLine in project axelor-open-suite by axelor.

the class TestFixedAssetLineComputationService method testComputePlannedFixedAssetLineWithoutProrata.

@Test
public void testComputePlannedFixedAssetLineWithoutProrata() {
    FixedAsset fixedAsset = createFixedAsset(FixedAssetRepository.COMPUTATION_METHOD_LINEAR, LocalDate.of(2020, 10, 4), LocalDate.of(2020, 12, 31), 5, 12, createFixedAssetCategoryFromIsProrataTemporis(false), new BigDecimal("500.00"));
    FixedAssetLine firstFixedAssetLine = createFixedAssetLine(LocalDate.of(2020, 12, 31), new BigDecimal("100.00"), new BigDecimal("100.00"), new BigDecimal("400.00"));
    FixedAssetLine fixedAssetLine = fixedAssetLineComputationService.computePlannedFixedAssetLine(fixedAsset, firstFixedAssetLine);
    assertFixedAssetLineEquals(createFixedAssetLine(LocalDate.of(2021, 12, 31), new BigDecimal("100.00"), new BigDecimal("200.00"), new BigDecimal("300.00")), fixedAssetLine);
}
Also used : FixedAssetTestTool.createFixedAssetLine(com.axelor.apps.account.service.fixedasset.FixedAssetTestTool.createFixedAssetLine) FixedAssetLine(com.axelor.apps.account.db.FixedAssetLine) FixedAssetTestTool.createFixedAsset(com.axelor.apps.account.service.fixedasset.FixedAssetTestTool.createFixedAsset) FixedAsset(com.axelor.apps.account.db.FixedAsset) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 14 with FixedAssetLine

use of com.axelor.apps.account.db.FixedAssetLine in project axelor-open-suite by axelor.

the class TestFixedAssetLineComputationService method testComputeOngoingDegressiveAssetLineSwitchToLinear.

@Test
public void testComputeOngoingDegressiveAssetLineSwitchToLinear() {
    FixedAsset fixedAsset = createFixedAsset(FixedAssetRepository.COMPUTATION_METHOD_DEGRESSIVE, new BigDecimal("1.75"), LocalDate.of(2020, 3, 31), LocalDate.of(2020, 12, 31), 5, 12, createFixedAssetCategoryFromIsProrataTemporis(true, false), new BigDecimal("20000.00"));
    // fill with empty previous line, should not change the result
    for (int i = 0; i < 2; i++) {
        fixedAsset.addFixedAssetLineListItem(createFixedAssetLine(LocalDate.now(), BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO));
    }
    FixedAssetLine previousFixedAssetLine = createFixedAssetLine(LocalDate.of(2020, 12, 31), new BigDecimal("3356.00"), new BigDecimal("13769.00"), new BigDecimal("6231.00"));
    fixedAsset.addFixedAssetLineListItem(previousFixedAssetLine);
    FixedAssetLine fixedAssetLine = fixedAssetLineComputationService.computePlannedFixedAssetLine(fixedAsset, previousFixedAssetLine);
    assertFixedAssetLineEquals(createFixedAssetLine(LocalDate.of(2021, 12, 31), new BigDecimal("3115.50"), new BigDecimal("16884.50"), new BigDecimal("3115.50")), fixedAssetLine);
}
Also used : FixedAssetTestTool.createFixedAssetLine(com.axelor.apps.account.service.fixedasset.FixedAssetTestTool.createFixedAssetLine) FixedAssetLine(com.axelor.apps.account.db.FixedAssetLine) FixedAssetTestTool.createFixedAsset(com.axelor.apps.account.service.fixedasset.FixedAssetTestTool.createFixedAsset) FixedAsset(com.axelor.apps.account.db.FixedAsset) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 15 with FixedAssetLine

use of com.axelor.apps.account.db.FixedAssetLine in project axelor-open-suite by axelor.

the class TestFixedAssetLineComputationService method testComputeInitialPlannedFixedAssetLineWithoutProrata.

@Test
public void testComputeInitialPlannedFixedAssetLineWithoutProrata() {
    FixedAsset fixedAsset = createFixedAsset(FixedAssetRepository.COMPUTATION_METHOD_LINEAR, LocalDate.of(2020, 10, 4), LocalDate.of(2020, 12, 31), 5, 12, createFixedAssetCategoryFromIsProrataTemporis(false), new BigDecimal("500.00"));
    FixedAssetLine fixedAssetLine = fixedAssetLineComputationService.computeInitialPlannedFixedAssetLine(fixedAsset);
    assertFixedAssetLineEquals(createFixedAssetLine(LocalDate.of(2020, 12, 31), new BigDecimal("100.00"), new BigDecimal("100.00"), new BigDecimal("400.00")), fixedAssetLine);
}
Also used : FixedAssetTestTool.createFixedAssetLine(com.axelor.apps.account.service.fixedasset.FixedAssetTestTool.createFixedAssetLine) FixedAssetLine(com.axelor.apps.account.db.FixedAssetLine) FixedAssetTestTool.createFixedAsset(com.axelor.apps.account.service.fixedasset.FixedAssetTestTool.createFixedAsset) FixedAsset(com.axelor.apps.account.db.FixedAsset) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Aggregations

FixedAssetLine (com.axelor.apps.account.db.FixedAssetLine)18 BigDecimal (java.math.BigDecimal)13 FixedAsset (com.axelor.apps.account.db.FixedAsset)12 FixedAssetTestTool.createFixedAsset (com.axelor.apps.account.service.fixedasset.FixedAssetTestTool.createFixedAsset)10 FixedAssetTestTool.createFixedAssetLine (com.axelor.apps.account.service.fixedasset.FixedAssetTestTool.createFixedAssetLine)10 Test (org.junit.Test)10 LocalDate (java.time.LocalDate)3 FixedAssetLineRepository (com.axelor.apps.account.db.repo.FixedAssetLineRepository)2 Transactional (com.google.inject.persist.Transactional)2 AccountConfig (com.axelor.apps.account.db.AccountConfig)1 AnalyticDistributionTemplate (com.axelor.apps.account.db.AnalyticDistributionTemplate)1 Invoice (com.axelor.apps.account.db.Invoice)1 InvoiceLine (com.axelor.apps.account.db.InvoiceLine)1 MoveLine (com.axelor.apps.account.db.MoveLine)1 FixedAssetRepository (com.axelor.apps.account.db.repo.FixedAssetRepository)1 IExceptionMessage (com.axelor.apps.account.exception.IExceptionMessage)1 AccountConfigService (com.axelor.apps.account.service.config.AccountConfigService)1 FixedAssetLineMoveService (com.axelor.apps.account.service.fixedasset.FixedAssetLineMoveService)1 MoveLineService (com.axelor.apps.account.service.move.MoveLineService)1 JPA (com.axelor.db.JPA)1