Search in sources :

Example 41 with FixedAsset

use of com.axelor.apps.account.db.FixedAsset 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 42 with FixedAsset

use of com.axelor.apps.account.db.FixedAsset 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)

Example 43 with FixedAsset

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

the class TestFixedAssetLineComputationService method testComputeLastFixedAssetLineWithoutProrata.

@Test
public void testComputeLastFixedAssetLineWithoutProrata() {
    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 previousFixedAssetLine = createFixedAssetLine(LocalDate.of(2023, 12, 31), new BigDecimal("100.00"), new BigDecimal("400.00"), new BigDecimal("100.00"));
    FixedAssetLine fixedAssetLine = fixedAssetLineComputationService.computePlannedFixedAssetLine(fixedAsset, previousFixedAssetLine);
    assertFixedAssetLineEquals(createFixedAssetLine(LocalDate.of(2024, 12, 31), new BigDecimal("100.00"), new BigDecimal("500.00"), new BigDecimal("0.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 44 with FixedAsset

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

the class TestFixedAssetService method testGenerateAndComputeLinesProrataLinearFixedAssetNoProrataNeededFifthLine.

@Test
public void testGenerateAndComputeLinesProrataLinearFixedAssetNoProrataNeededFifthLine() {
    FixedAsset fixedAsset = generateAndComputeLineProrataLinearFixedAssetNoProrataNeeded();
    assertFixedAssetLineEquals(createFixedAssetLine(LocalDate.of(2024, 12, 31), new BigDecimal("100.00"), new BigDecimal("500.00"), new BigDecimal("0.00")), fixedAsset.getFixedAssetLineList().get(4));
}
Also used : FixedAsset(com.axelor.apps.account.db.FixedAsset) FixedAssetTestTool.createFixedAsset(com.axelor.apps.account.service.fixedasset.FixedAssetTestTool.createFixedAsset) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 45 with FixedAsset

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

the class TestFixedAssetService method testGenerateAndComputeLinesProrataLinearFixedAssetFirstLine.

@Test
public void testGenerateAndComputeLinesProrataLinearFixedAssetFirstLine() {
    FixedAsset fixedAsset = generateAndComputeLineProrataLinearFixedAsset();
    assertFixedAssetLineEquals(createFixedAssetLine(LocalDate.of(2020, 12, 31), new BigDecimal("23.89"), new BigDecimal("23.89"), new BigDecimal("476.11")), fixedAsset.getFixedAssetLineList().get(0));
}
Also used : FixedAsset(com.axelor.apps.account.db.FixedAsset) FixedAssetTestTool.createFixedAsset(com.axelor.apps.account.service.fixedasset.FixedAssetTestTool.createFixedAsset) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Aggregations

FixedAsset (com.axelor.apps.account.db.FixedAsset)65 FixedAssetTestTool.createFixedAsset (com.axelor.apps.account.service.fixedasset.FixedAssetTestTool.createFixedAsset)52 BigDecimal (java.math.BigDecimal)52 Test (org.junit.Test)47 FixedAssetLine (com.axelor.apps.account.db.FixedAssetLine)12 FixedAssetTestTool.createFixedAssetLine (com.axelor.apps.account.service.fixedasset.FixedAssetTestTool.createFixedAssetLine)10 Transactional (com.google.inject.persist.Transactional)6 AxelorException (com.axelor.exception.AxelorException)5 ArrayList (java.util.ArrayList)5 LocalDate (java.time.LocalDate)4 MoveLine (com.axelor.apps.account.db.MoveLine)3 FixedAssetRepository (com.axelor.apps.account.db.repo.FixedAssetRepository)3 FixedAssetService (com.axelor.apps.account.service.fixedasset.FixedAssetService)3 Account (com.axelor.apps.account.db.Account)2 AccountConfig (com.axelor.apps.account.db.AccountConfig)2 InvoiceLine (com.axelor.apps.account.db.InvoiceLine)2 Journal (com.axelor.apps.account.db.Journal)2 Move (com.axelor.apps.account.db.Move)2 Company (com.axelor.apps.base.db.Company)2 Partner (com.axelor.apps.base.db.Partner)2