Search in sources :

Example 1 with FETCH_LIMIT

use of com.axelor.apps.base.service.administration.AbstractBatch.FETCH_LIMIT in project axelor-open-suite by axelor.

the class AccountingCutOffServiceImpl method getStockMoveLines.

public List<Long> getStockMoveLines(Batch batch) {
    int offset = 0;
    Boolean includeNotStockManagedProduct = batch.getSupplychainBatch().getIncludeNotStockManagedProduct();
    List<StockMoveLine> stockMoveLineList;
    List<Long> stockMoveLineIdList = new ArrayList<>();
    Query<StockMove> stockMoveQuery = stockMoverepository.all().filter(":batch MEMBER OF self.batchSet").bind("batch", batch);
    List<Long> stockMoveIdList = stockMoveQuery.select("id").fetch(0, 0).stream().map(m -> (Long) m.get("id")).collect(Collectors.toList());
    if (stockMoveIdList.isEmpty()) {
        stockMoveLineIdList.add(0L);
    } else {
        Query<StockMoveLine> stockMoveLineQuery = stockMoveLineRepository.all().filter("self.stockMove.id IN :stockMoveIdList").bind("stockMoveIdList", stockMoveIdList).order("id");
        while (!(stockMoveLineList = stockMoveLineQuery.fetch(FETCH_LIMIT, offset)).isEmpty()) {
            offset += stockMoveLineList.size();
            for (StockMoveLine stockMoveLine : stockMoveLineList) {
                Product product = stockMoveLine.getProduct();
                if (!checkStockMoveLine(stockMoveLine, product, includeNotStockManagedProduct)) {
                    stockMoveLineIdList.add(stockMoveLine.getId());
                }
            }
            JPA.clear();
        }
    }
    return stockMoveLineIdList;
}
Also used : TaxAccountService(com.axelor.apps.account.service.TaxAccountService) AppAccountService(com.axelor.apps.account.service.app.AppAccountService) Move(com.axelor.apps.account.db.Move) Inject(com.google.inject.Inject) Transactional(com.google.inject.persist.Transactional) BigDecimal(java.math.BigDecimal) SaleOrderRepository(com.axelor.apps.sale.db.repo.SaleOrderRepository) TaxLine(com.axelor.apps.account.db.TaxLine) MoveCreateService(com.axelor.apps.account.service.move.MoveCreateService) MoveToolService(com.axelor.apps.account.service.move.MoveToolService) MoveValidateService(com.axelor.apps.account.service.move.MoveValidateService) SaleOrder(com.axelor.apps.sale.db.SaleOrder) RoundingMode(java.math.RoundingMode) AnalyticMoveLineRepository(com.axelor.apps.account.db.repo.AnalyticMoveLineRepository) AccountManagementAccountService(com.axelor.apps.account.service.AccountManagementAccountService) InvoiceLineManagement(com.axelor.apps.account.service.invoice.generator.line.InvoiceLineManagement) FETCH_LIMIT(com.axelor.apps.base.service.administration.AbstractBatch.FETCH_LIMIT) StockMove(com.axelor.apps.stock.db.StockMove) StockMoveRepository(com.axelor.apps.stock.db.repo.StockMoveRepository) Collectors(java.util.stream.Collectors) Currency(com.axelor.apps.base.db.Currency) List(java.util.List) SaleOrderLine(com.axelor.apps.sale.db.SaleOrderLine) Product(com.axelor.apps.base.db.Product) PurchaseOrder(com.axelor.apps.purchase.db.PurchaseOrder) AccountConfigSupplychainService(com.axelor.apps.supplychain.service.config.AccountConfigSupplychainService) LocalDate(java.time.LocalDate) Partner(com.axelor.apps.base.db.Partner) Company(com.axelor.apps.base.db.Company) Query(com.axelor.db.Query) PurchaseOrderLine(com.axelor.apps.purchase.db.PurchaseOrderLine) StockMoveLineRepository(com.axelor.apps.stock.db.repo.StockMoveLineRepository) AccountConfig(com.axelor.apps.account.db.AccountConfig) PurchaseOrderRepository(com.axelor.apps.purchase.db.repo.PurchaseOrderRepository) AnalyticMoveLineService(com.axelor.apps.account.service.AnalyticMoveLineService) ArrayList(java.util.ArrayList) AxelorException(com.axelor.exception.AxelorException) MoveLine(com.axelor.apps.account.db.MoveLine) UnitConversionService(com.axelor.apps.base.service.UnitConversionService) Batch(com.axelor.apps.base.db.Batch) AppAccountRepository(com.axelor.apps.base.db.repo.AppAccountRepository) MoveLineService(com.axelor.apps.account.service.move.MoveLineService) JPA(com.axelor.db.JPA) Iterator(java.util.Iterator) SupplychainBatchRepository(com.axelor.apps.supplychain.db.repo.SupplychainBatchRepository) ReconcileService(com.axelor.apps.account.service.ReconcileService) AnalyticDistributionTemplate(com.axelor.apps.account.db.AnalyticDistributionTemplate) Account(com.axelor.apps.account.db.Account) StockMoveLine(com.axelor.apps.stock.db.StockMoveLine) Comparator(java.util.Comparator) Collections(java.util.Collections) MoveRepository(com.axelor.apps.account.db.repo.MoveRepository) AnalyticMoveLine(com.axelor.apps.account.db.AnalyticMoveLine) Tax(com.axelor.apps.account.db.Tax) StockMove(com.axelor.apps.stock.db.StockMove) ArrayList(java.util.ArrayList) StockMoveLine(com.axelor.apps.stock.db.StockMoveLine) Product(com.axelor.apps.base.db.Product)

Aggregations

Account (com.axelor.apps.account.db.Account)1 AccountConfig (com.axelor.apps.account.db.AccountConfig)1 AnalyticDistributionTemplate (com.axelor.apps.account.db.AnalyticDistributionTemplate)1 AnalyticMoveLine (com.axelor.apps.account.db.AnalyticMoveLine)1 Move (com.axelor.apps.account.db.Move)1 MoveLine (com.axelor.apps.account.db.MoveLine)1 Tax (com.axelor.apps.account.db.Tax)1 TaxLine (com.axelor.apps.account.db.TaxLine)1 AnalyticMoveLineRepository (com.axelor.apps.account.db.repo.AnalyticMoveLineRepository)1 MoveRepository (com.axelor.apps.account.db.repo.MoveRepository)1 AccountManagementAccountService (com.axelor.apps.account.service.AccountManagementAccountService)1 AnalyticMoveLineService (com.axelor.apps.account.service.AnalyticMoveLineService)1 ReconcileService (com.axelor.apps.account.service.ReconcileService)1 TaxAccountService (com.axelor.apps.account.service.TaxAccountService)1 AppAccountService (com.axelor.apps.account.service.app.AppAccountService)1 InvoiceLineManagement (com.axelor.apps.account.service.invoice.generator.line.InvoiceLineManagement)1 MoveCreateService (com.axelor.apps.account.service.move.MoveCreateService)1 MoveLineService (com.axelor.apps.account.service.move.MoveLineService)1 MoveToolService (com.axelor.apps.account.service.move.MoveToolService)1 MoveValidateService (com.axelor.apps.account.service.move.MoveValidateService)1