use of com.axelor.apps.stock.db.LogisticalFormLine in project axelor-open-suite by axelor.
the class LogisticalFormServiceImpl method checkEmptyParcelPalletLines.
protected void checkEmptyParcelPalletLines(LogisticalForm logisticalForm, List<String> errorMessageList) throws LogisticalFormError {
if (logisticalForm.getLogisticalFormLineList() == null) {
return;
}
Map<LogisticalFormLine, BigDecimal> qtyMap = new HashMap<>();
LogisticalFormLine currentLine = null;
for (LogisticalFormLine logisticalFormLine : logisticalForm.getLogisticalFormLineList()) {
if (logisticalFormLine.getTypeSelect() != LogisticalFormLineRepository.TYPE_DETAIL) {
currentLine = logisticalFormLine;
qtyMap.put(currentLine, BigDecimal.ZERO);
} else {
if (currentLine == null) {
throw new LogisticalFormError(logisticalForm, I18n.get(IExceptionMessage.LOGISTICAL_FORM_LINES_ORPHAN_DETAIL));
}
qtyMap.merge(currentLine, logisticalFormLine.getQty(), BigDecimal::add);
}
}
for (Entry<LogisticalFormLine, BigDecimal> entry : qtyMap.entrySet()) {
LogisticalFormLine logisticalFormLine = entry.getKey();
BigDecimal qty = entry.getValue();
if (qty.signum() <= 0) {
String msg;
if (logisticalFormLine.getTypeSelect() == LogisticalFormLineRepository.TYPE_PARCEL) {
msg = I18n.get(IExceptionMessage.LOGISTICAL_FORM_LINES_EMPTY_PARCEL);
} else {
msg = I18n.get(IExceptionMessage.LOGISTICAL_FORM_LINES_EMPTY_PALLET);
}
String errorMessage = String.format(msg, logisticalFormLine.getParcelPalletNumber());
errorMessageList.add(errorMessage);
}
}
}
use of com.axelor.apps.stock.db.LogisticalFormLine in project axelor-open-suite by axelor.
the class LogisticalFormServiceImpl method addDetailLine.
protected void addDetailLine(LogisticalForm logisticalForm, StockMoveLine stockMoveLine, BigDecimal qty) {
Preconditions.checkNotNull(logisticalForm);
Preconditions.checkNotNull(stockMoveLine);
LogisticalFormLine logisticalFormLine = createLogisticalFormLine(logisticalForm, stockMoveLine, qty);
addLogisticalFormLineListItem(logisticalForm, logisticalFormLine);
}
use of com.axelor.apps.stock.db.LogisticalFormLine in project axelor-open-suite by axelor.
the class LogisticalFormServiceImpl method processCollected.
@Override
@Transactional(rollbackOn = { Exception.class })
public void processCollected(LogisticalForm logisticalForm) throws AxelorException {
if (logisticalForm.getLogisticalFormLineList() == null) {
return;
}
Set<StockMove> stockMoveSet = new HashSet<>();
logisticalForm.getLogisticalFormLineList().stream().filter(logisticalFormLine -> logisticalFormLine.getTypeSelect() == LogisticalFormLineRepository.TYPE_DETAIL && logisticalFormLine.getStockMoveLine() != null && logisticalFormLine.getStockMoveLine().getStockMove() != null).forEach(logisticalFormLine -> stockMoveSet.add(logisticalFormLine.getStockMoveLine().getStockMove()));
StockMoveService stockMoveService = Beans.get(StockMoveService.class);
stockMoveSet.forEach(stockMoveService::updateFullySpreadOverLogisticalFormsFlag);
StockConfigService stockConfigService = Beans.get(StockConfigService.class);
StockConfig stockConfig = stockConfigService.getStockConfig(logisticalForm.getCompany());
if (stockConfig.getRealizeStockMovesUponParcelPalletCollection()) {
for (StockMove stockMove : stockMoveSet) {
if (stockMove.getFullySpreadOverLogisticalFormsFlag()) {
stockMoveService.realize(stockMove);
}
}
}
logisticalForm.setStatusSelect(LogisticalFormRepository.STATUS_COLLECTED);
}
use of com.axelor.apps.stock.db.LogisticalFormLine in project axelor-open-suite by axelor.
the class LogisticalFormLineController method setStockMoveLineDomain.
public void setStockMoveLineDomain(ActionRequest request, ActionResponse response) {
try {
LogisticalFormLine logisticalFormLine = getLogisticalFormLine(request);
String domain = Beans.get(LogisticalFormLineService.class).getStockMoveLineDomain(logisticalFormLine);
response.setAttr("stockMoveLine", "domain", domain);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
Aggregations