Search in sources :

Example 1 with StockRulesRepository

use of com.axelor.apps.stock.db.repo.StockRulesRepository in project axelor-open-suite by axelor.

the class StockLocationServiceImpl method getBadStockLocationLineId.

public List<Long> getBadStockLocationLineId() {
    List<StockLocationLine> stockLocationLineList = Beans.get(StockLocationLineRepository.class).all().filter("self.stockLocation.typeSelect = 1 OR self.stockLocation.typeSelect = 2").fetch();
    List<Long> idList = new ArrayList<>();
    StockRulesRepository stockRulesRepository = Beans.get(StockRulesRepository.class);
    for (StockLocationLine stockLocationLine : stockLocationLineList) {
        StockRules stockRules = stockRulesRepository.all().filter("self.stockLocation = ?1 AND self.product = ?2", stockLocationLine.getStockLocation(), stockLocationLine.getProduct()).fetchOne();
        if (stockRules != null && stockLocationLine.getFutureQty().compareTo(stockRules.getMinQty()) < 0) {
            idList.add(stockLocationLine.getId());
        }
    }
    if (idList.isEmpty()) {
        idList.add(0L);
    }
    return idList;
}
Also used : StockRulesRepository(com.axelor.apps.stock.db.repo.StockRulesRepository) StockLocationLineRepository(com.axelor.apps.stock.db.repo.StockLocationLineRepository) ArrayList(java.util.ArrayList) StockLocationLine(com.axelor.apps.stock.db.StockLocationLine) StockRules(com.axelor.apps.stock.db.StockRules)

Aggregations

StockLocationLine (com.axelor.apps.stock.db.StockLocationLine)1 StockRules (com.axelor.apps.stock.db.StockRules)1 StockLocationLineRepository (com.axelor.apps.stock.db.repo.StockLocationLineRepository)1 StockRulesRepository (com.axelor.apps.stock.db.repo.StockRulesRepository)1 ArrayList (java.util.ArrayList)1