Search in sources :

Example 6 with FixedAssetLine

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

the class TestFixedAssetLineComputationService method testComputeLastFixedAssetLineWithProrata.

@Test
public void testComputeLastFixedAssetLineWithProrata() {
    FixedAsset fixedAsset = createFixedAsset(FixedAssetRepository.COMPUTATION_METHOD_LINEAR, LocalDate.of(2020, 10, 4), LocalDate.of(2020, 12, 31), 5, 12, createFixedAssetCategoryFromIsProrataTemporis(true), new BigDecimal("500.00"));
    FixedAssetLine previousFixedAssetLine = createFixedAssetLine(LocalDate.of(2024, 12, 31), new BigDecimal("100.00"), new BigDecimal("423.89"), new BigDecimal("76.11"));
    FixedAssetLine fixedAssetLine = fixedAssetLineComputationService.computePlannedFixedAssetLine(fixedAsset, previousFixedAssetLine);
    assertFixedAssetLineEquals(createFixedAssetLine(LocalDate.of(2025, 10, 3), new BigDecimal("76.11"), 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 7 with FixedAssetLine

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

the class TestFixedAssetLineComputationService method testComputeFirstDegressiveAssetLine.

@Test
public void testComputeFirstDegressiveAssetLine() {
    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 fixedAssetLine = fixedAssetLineComputationService.computeInitialPlannedFixedAssetLine(fixedAsset);
    assertFixedAssetLineEquals(createFixedAssetLine(LocalDate.of(2020, 12, 31), new BigDecimal("5250.00"), new BigDecimal("5250.00"), new BigDecimal("14750.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 8 with FixedAssetLine

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

the class TestFixedAssetLineComputationService method testComputeLastFixedAssetLineWithUsProrata.

@Test
public void testComputeLastFixedAssetLineWithUsProrata() {
    FixedAsset fixedAsset = createFixedAsset(FixedAssetRepository.COMPUTATION_METHOD_LINEAR, LocalDate.of(2020, 7, 1), LocalDate.of(2020, 12, 31), 7, 12, createFixedAssetCategoryFromIsProrataTemporis(true, true), new BigDecimal("102638.35"));
    FixedAssetLine previousFixedAssetLine = createFixedAssetLine(LocalDate.of(2026, 12, 31), new BigDecimal("14662.62"), new BigDecimal("95307.03"), new BigDecimal("7331.32"));
    FixedAssetLine fixedAssetLine = fixedAssetLineComputationService.computePlannedFixedAssetLine(fixedAsset, previousFixedAssetLine);
    assertFixedAssetLineEquals(createFixedAssetLine(LocalDate.of(2027, 6, 30), new BigDecimal("7331.32"), new BigDecimal("102638.35"), 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 9 with FixedAssetLine

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

the class TestFixedAssetLineComputationService method testComputeInitialPlannedFixedAssetLineWithProrata.

@Test
public void testComputeInitialPlannedFixedAssetLineWithProrata() {
    FixedAsset fixedAsset = createFixedAsset(FixedAssetRepository.COMPUTATION_METHOD_LINEAR, LocalDate.of(2020, 10, 5), LocalDate.of(2020, 12, 31), 5, 12, createFixedAssetCategoryFromIsProrataTemporis(true), new BigDecimal("500.00"));
    FixedAssetLine fixedAssetLine = fixedAssetLineComputationService.computeInitialPlannedFixedAssetLine(fixedAsset);
    assertFixedAssetLineEquals(createFixedAssetLine(LocalDate.of(2020, 12, 31), new BigDecimal("23.89"), new BigDecimal("23.89"), new BigDecimal("476.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 10 with FixedAssetLine

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

the class FixedAssetLineController method realize.

public void realize(ActionRequest request, ActionResponse response) {
    FixedAssetLine fixedAssetLine = request.getContext().asType(FixedAssetLine.class);
    fixedAssetLine = Beans.get(FixedAssetLineRepository.class).find(fixedAssetLine.getId());
    try {
        Beans.get(FixedAssetLineMoveService.class).realize(fixedAssetLine);
        response.setReload(true);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : FixedAssetLineMoveService(com.axelor.apps.account.service.fixedasset.FixedAssetLineMoveService) FixedAssetLine(com.axelor.apps.account.db.FixedAssetLine)

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