Search in sources :

Example 31 with FixedAsset

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

the class TestFixedAssetService method testGenerateAndComputeLinesUsProrataLinearFixedAssetLastLine.

@Test
public void testGenerateAndComputeLinesUsProrataLinearFixedAssetLastLine() {
    FixedAsset fixedAsset = generateAndComputeLineUsProrataLinearFixedAsset();
    assertFixedAssetLineEquals(createFixedAssetLine(LocalDate.of(2027, 6, 30), new BigDecimal("7331.32"), new BigDecimal("102638.35"), new BigDecimal("0.00")), fixedAsset.getFixedAssetLineList().get(7));
}
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 32 with FixedAsset

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

the class TestFixedAssetService method testGenerateAndComputeLinesUsProrataLinearFixedAssetFourthLine.

@Test
public void testGenerateAndComputeLinesUsProrataLinearFixedAssetFourthLine() {
    FixedAsset fixedAsset = generateAndComputeLineUsProrataLinearFixedAsset();
    assertFixedAssetLineEquals(createFixedAssetLine(LocalDate.of(2023, 12, 31), new BigDecimal("14662.62"), new BigDecimal("51319.17"), new BigDecimal("51319.18")), fixedAsset.getFixedAssetLineList().get(3));
}
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 33 with FixedAsset

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

the class TestFixedAssetService method testGenerateAndComputeLinesProrataDegressiveFixedAssetFirstLine.

@Test
public void testGenerateAndComputeLinesProrataDegressiveFixedAssetFirstLine() {
    FixedAsset fixedAsset = generateAndComputeLinesProrataDegressiveFixedAsset();
    assertFixedAssetLineEquals(createFixedAssetLine(LocalDate.of(2021, 12, 31), new BigDecimal("16495.45"), new BigDecimal("16495.45"), new BigDecimal("86142.90")), 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)

Example 34 with FixedAsset

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

the class FixedAssetController method validate.

public void validate(ActionRequest request, ActionResponse response) {
    FixedAsset fixedAsset = Beans.get(FixedAssetRepository.class).find(request.getContext().asType(FixedAsset.class).getId());
    if (fixedAsset.getStatusSelect() == FixedAssetRepository.STATUS_DRAFT) {
        try {
            Beans.get(FixedAssetService.class).validate(fixedAsset);
        } catch (Exception e) {
            TraceBackService.trace(response, e);
        }
    }
    response.setReload(true);
}
Also used : FixedAssetService(com.axelor.apps.account.service.fixedasset.FixedAssetService) FixedAssetRepository(com.axelor.apps.account.db.repo.FixedAssetRepository) FixedAsset(com.axelor.apps.account.db.FixedAsset) AxelorException(com.axelor.exception.AxelorException)

Example 35 with FixedAsset

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

the class FixedAssetController method disposal.

public void disposal(ActionRequest request, ActionResponse response) throws AxelorException {
    Context context = request.getContext();
    if (context.get("disposalDate") == null || context.get("disposalAmount") == null) {
        return;
    }
    LocalDate disposalDate = (LocalDate) context.get("disposalDate");
    BigDecimal disposalAmount = new BigDecimal(context.get("disposalAmount").toString());
    Long fixedAssetId = Long.valueOf(context.get("_id").toString());
    FixedAsset fixedAsset = Beans.get(FixedAssetRepository.class).find(fixedAssetId);
    Beans.get(FixedAssetService.class).disposal(disposalDate, disposalAmount, fixedAsset);
    response.setCanClose(true);
}
Also used : Context(com.axelor.rpc.Context) FixedAssetService(com.axelor.apps.account.service.fixedasset.FixedAssetService) FixedAssetRepository(com.axelor.apps.account.db.repo.FixedAssetRepository) FixedAsset(com.axelor.apps.account.db.FixedAsset) LocalDate(java.time.LocalDate) BigDecimal(java.math.BigDecimal)

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