use of com.axelor.apps.stock.db.StockMove 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;
}
use of com.axelor.apps.stock.db.StockMove in project axelor-open-suite by axelor.
the class ClientViewServiceImpl method getNextDeliveryIndicator.
protected String getNextDeliveryIndicator(User user) {
List<Filter> filters = getNextDeliveryOfUser(user);
StockMove stockMove = Filter.and(filters).build(StockMove.class).order("estimatedDate").fetchOne();
if (stockMove == null) {
return I18n.get(CLIENT_PORTAL_NO_DATE);
}
return stockMove.getEstimatedDate() != null ? stockMove.getEstimatedDate().format(DATE_FORMATTER) : I18n.get(CLIENT_PORTAL_NO_DATE);
}
use of com.axelor.apps.stock.db.StockMove in project axelor-open-suite by axelor.
the class StockMoveController method allocateAll.
/**
* Called from stock move form view, on available qty boolean change. Only called if the user
* accepted to allocate everything. Call {@link
* StockMoveReservedQtyService#allocateAll(StockMove)}.
*
* @param request
* @param response
*/
public void allocateAll(ActionRequest request, ActionResponse response) {
try {
StockMove stockMove = request.getContext().asType(StockMove.class);
Company company = stockMove.getCompany();
if (company == null) {
return;
}
SupplyChainConfig supplyChainConfig = Beans.get(SupplyChainConfigService.class).getSupplyChainConfig(company);
if (!Beans.get(AppSupplychainService.class).getAppSupplychain().getManageStockReservation() || !stockMove.getAvailabilityRequest() || !supplyChainConfig.getAutoAllocateOnAvailabilityRequest()) {
return;
}
Beans.get(StockMoveReservedQtyService.class).allocateAll(stockMove);
} catch (Exception e) {
TraceBackService.trace(response, e);
} finally {
response.setReload(true);
}
}
use of com.axelor.apps.stock.db.StockMove in project axelor-open-suite by axelor.
the class StockMoveController method isAllocatedStockMoveLineRemoved.
public void isAllocatedStockMoveLineRemoved(ActionRequest request, ActionResponse response) {
StockMove stockMove = request.getContext().asType(StockMove.class);
if (stockMove.getId() != null && Beans.get(StockMoveServiceSupplychain.class).isAllocatedStockMoveLineRemoved(stockMove)) {
response.setValue("stockMoveLineList", stockMove.getStockMoveLineList());
response.setFlash(I18n.get(IExceptionMessage.ALLOCATED_STOCK_MOVE_LINE_DELETED_ERROR));
}
}
use of com.axelor.apps.stock.db.StockMove in project axelor-open-suite by axelor.
the class StockMoveController method setInvoicedPartnerDomain.
/**
* Called from stock move form view, on delivered partner select. Call {@link
* PartnerSupplychainLinkService#computePartnerFilter}
*
* @param request
* @param response
*/
public void setInvoicedPartnerDomain(ActionRequest request, ActionResponse response) {
try {
StockMove stockMove = request.getContext().asType(StockMove.class);
String strFilter = Beans.get(PartnerSupplychainLinkService.class).computePartnerFilter(stockMove.getPartner(), PartnerSupplychainLinkTypeRepository.TYPE_SELECT_INVOICED_BY);
response.setAttr("invoicedPartner", "domain", strFilter);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
Aggregations