Search in sources :

Example 56 with FixedAsset

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

the class TestFixedAssetService method testGenerateAndComputeLinesProrataLinearFixedAssetNoProrataNeeded.

@Test
public void testGenerateAndComputeLinesProrataLinearFixedAssetNoProrataNeeded() {
    FixedAsset fixedAsset = generateAndComputeLineProrataLinearFixedAssetNoProrataNeeded();
    Assert.assertTrue(fixedAsset.getFixedAssetLineList() != null && fixedAsset.getFixedAssetLineList().size() == 5);
}
Also used : FixedAsset(com.axelor.apps.account.db.FixedAsset) FixedAssetTestTool.createFixedAsset(com.axelor.apps.account.service.fixedasset.FixedAssetTestTool.createFixedAsset) Test(org.junit.Test)

Example 57 with FixedAsset

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

the class TestFixedAssetService method testGenerateAndComputeLinesSimpleLinearFixedAsset.

@Test
public void testGenerateAndComputeLinesSimpleLinearFixedAsset() {
    FixedAsset fixedAsset = generateAndComputeLineSimpleLinearFixedAsset();
    Assert.assertTrue(fixedAsset.getFixedAssetLineList() != null && fixedAsset.getFixedAssetLineList().size() == 5);
}
Also used : FixedAsset(com.axelor.apps.account.db.FixedAsset) FixedAssetTestTool.createFixedAsset(com.axelor.apps.account.service.fixedasset.FixedAssetTestTool.createFixedAsset) Test(org.junit.Test)

Example 58 with FixedAsset

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

the class TestFixedAssetService method testGenerateAndComputeLinesSimpleLinearFixedAssetFifthLine.

@Test
public void testGenerateAndComputeLinesSimpleLinearFixedAssetFifthLine() {
    FixedAsset fixedAsset = generateAndComputeLineSimpleLinearFixedAsset();
    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 59 with FixedAsset

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

the class TestFixedAssetService method testGenerateAndComputeLinesProrataLinearFixedAssetNoProrataNeededFourthLine.

@Test
public void testGenerateAndComputeLinesProrataLinearFixedAssetNoProrataNeededFourthLine() {
    FixedAsset fixedAsset = generateAndComputeLineProrataLinearFixedAssetNoProrataNeeded();
    assertFixedAssetLineEquals(createFixedAssetLine(LocalDate.of(2023, 12, 31), new BigDecimal("100.00"), new BigDecimal("400.00"), new BigDecimal("100.00")), 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 60 with FixedAsset

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

the class FixedAssetServiceSupplyChainImpl method createFixedAssets.

@Transactional
@Override
public List<FixedAsset> createFixedAssets(Invoice invoice) throws AxelorException {
    List<FixedAsset> fixedAssetList = super.createFixedAssets(invoice);
    if (!Beans.get(AppSupplychainService.class).isApp("supplychain")) {
        return fixedAssetList;
    }
    if (fixedAssetList.isEmpty()) {
        return new ArrayList<>();
    }
    StockLocation stockLocation = invoice.getPurchaseOrder() != null ? invoice.getPurchaseOrder().getStockLocation() : null;
    for (FixedAsset fixedAsset : fixedAssetList) {
        PurchaseOrderLine pol = fixedAsset.getInvoiceLine().getPurchaseOrderLine();
        fixedAsset.setStockLocation(stockLocation);
        if (fixedAsset.getInvoiceLine().getIncomingStockMove() != null && CollectionUtils.isNotEmpty(fixedAsset.getInvoiceLine().getIncomingStockMove().getStockMoveLineList())) {
            fixedAsset.setTrackingNumber(fixedAsset.getInvoiceLine().getIncomingStockMove().getStockMoveLineList().stream().filter(l -> pol.equals(l.getPurchaseOrderLine())).findFirst().map(StockMoveLine::getTrackingNumber).orElse(null));
            fixedAsset.setStockLocation(fixedAsset.getInvoiceLine().getIncomingStockMove().getToStockLocation());
        }
    }
    return fixedAssetList;
}
Also used : PurchaseOrderLine(com.axelor.apps.purchase.db.PurchaseOrderLine) StockLocation(com.axelor.apps.stock.db.StockLocation) ArrayList(java.util.ArrayList) StockMoveLine(com.axelor.apps.stock.db.StockMoveLine) FixedAsset(com.axelor.apps.account.db.FixedAsset) Transactional(com.google.inject.persist.Transactional)

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