use of com.axelor.apps.stock.db.LogisticalForm in project axelor-open-suite by axelor.
the class LogisticalFormServiceImpl method getFullySpreadStockMoveLineList.
@Override
public List<StockMoveLine> getFullySpreadStockMoveLineList(LogisticalForm logisticalForm) {
List<StockMoveLine> stockMoveLineList = new ArrayList<>();
Map<StockMoveLine, BigDecimal> spreadableQtyMap = new HashMap<>();
for (LogisticalForm item : findPendingLogisticalForms(logisticalForm)) {
spreadableQtyMap.putAll(getSpreadableQtyMap(item));
}
for (Entry<StockMoveLine, BigDecimal> entry : spreadableQtyMap.entrySet()) {
StockMoveLine stockMoveLine = entry.getKey();
BigDecimal spreadableQty = entry.getValue();
if (spreadableQty.signum() <= 0) {
stockMoveLineList.add(stockMoveLine);
}
}
return stockMoveLineList;
}
use of com.axelor.apps.stock.db.LogisticalForm in project axelor-open-suite by axelor.
the class LogisticalFormServiceImpl method getSpreadableQtyMap.
@Override
public Map<StockMoveLine, BigDecimal> getSpreadableQtyMap(LogisticalForm logisticalForm) {
Set<StockMove> stockMoveSet = new LinkedHashSet<>();
Map<StockMoveLine, BigDecimal> spreadableQtyMap = new LinkedHashMap<>();
if (logisticalForm.getLogisticalFormLineList() != null) {
StockMoveLineService stockMoveLineService = Beans.get(StockMoveLineService.class);
logisticalForm.getLogisticalFormLineList().stream().filter(logisticalFormLine -> logisticalFormLine.getTypeSelect() == LogisticalFormLineRepository.TYPE_DETAIL && logisticalFormLine.getStockMoveLine() != null && logisticalFormLine.getStockMoveLine().getStockMove() != null).forEach(logisticalFormLine -> stockMoveSet.add(logisticalFormLine.getStockMoveLine().getStockMove()));
for (StockMove stockMove : stockMoveSet) {
if (stockMove.getStockMoveLineList() == null) {
continue;
}
for (StockMoveLine stockMoveLine : stockMove.getStockMoveLineList()) {
BigDecimal spreadableQty = stockMoveLineService.computeSpreadableQtyOverLogisticalFormLines(stockMoveLine, logisticalForm);
spreadableQtyMap.put(stockMoveLine, spreadableQty);
}
}
}
return spreadableQtyMap;
}
use of com.axelor.apps.stock.db.LogisticalForm in project axelor-open-suite by axelor.
the class LogisticalFormController method computeTotals.
public void computeTotals(ActionRequest request, ActionResponse response) {
try {
LogisticalForm logisticalForm = request.getContext().asType(LogisticalForm.class);
Beans.get(LogisticalFormService.class).computeTotals(logisticalForm);
response.setValue("totalNetMass", logisticalForm.getTotalNetMass());
response.setValue("totalGrossMass", logisticalForm.getTotalGrossMass());
response.setValue("totalVolume", logisticalForm.getTotalVolume());
} catch (LogisticalFormError e) {
response.setError(e.getLocalizedMessage());
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.stock.db.LogisticalForm in project axelor-open-suite by axelor.
the class LogisticalFormController method addStockMove.
public void addStockMove(ActionRequest request, ActionResponse response) {
try {
@SuppressWarnings("unchecked") Map<String, Object> stockMoveMap = (Map<String, Object>) request.getContext().get("stockMove");
if (stockMoveMap != null) {
StockMove stockMove = Mapper.toBean(StockMove.class, stockMoveMap);
stockMove = Beans.get(StockMoveRepository.class).find(stockMove.getId());
if (stockMove.getStockMoveLineList() != null) {
LogisticalForm logisticalForm = request.getContext().asType(LogisticalForm.class);
LogisticalFormService logisticalFormService = Beans.get(LogisticalFormService.class);
logisticalFormService.addDetailLines(logisticalForm, stockMove);
response.setValue("logisticalFormLineList", logisticalForm.getLogisticalFormLineList());
response.setValue("$stockMove", null);
}
}
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.stock.db.LogisticalForm in project axelor-open-suite by axelor.
the class LogisticalFormController method setCustomerAccountNumberToCarrier.
public void setCustomerAccountNumberToCarrier(ActionRequest request, ActionResponse response) {
try {
LogisticalForm logisticalForm = request.getContext().asType(LogisticalForm.class);
Optional<String> customerAccountNumberToCarrier = Beans.get(LogisticalFormService.class).getCustomerAccountNumberToCarrier(logisticalForm);
response.setValue("customerAccountNumberToCarrier", customerAccountNumberToCarrier.orElse(null));
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
Aggregations