use of com.axelor.apps.stock.db.LogisticalForm in project axelor-open-suite by axelor.
the class LogisticalFormController method checkLines.
public void checkLines(ActionRequest request, ActionResponse response) {
try {
LogisticalForm logisticalForm = request.getContext().asType(LogisticalForm.class);
LogisticalFormService logisticalFormService = Beans.get(LogisticalFormService.class);
logisticalFormService.sortLines(logisticalForm);
logisticalFormService.checkLines(logisticalForm);
} catch (LogisticalFormWarning e) {
response.setAlert(e.getLocalizedMessage());
} 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 LogisticalFormLineServiceImpl method getStockMoveLineDomain.
@Override
public String getStockMoveLineDomain(LogisticalFormLine logisticalFormLine) {
long partnerId = 0;
List<String> domainList = new ArrayList<>();
LogisticalForm logisticalForm = logisticalFormLine.getLogisticalForm();
if (logisticalForm != null) {
Partner deliverToCustomerPartner = logisticalForm.getDeliverToCustomerPartner();
if (deliverToCustomerPartner != null) {
partnerId = deliverToCustomerPartner.getId();
}
}
domainList.add(String.format("self.stockMove.partner.id = %d", partnerId));
domainList.add(String.format("self.stockMove.typeSelect = %d", StockMoveRepository.TYPE_OUTGOING));
domainList.add(String.format("self.stockMove.statusSelect in (%d, %d)", StockMoveRepository.STATUS_PLANNED, StockMoveRepository.STATUS_REALIZED));
domainList.add("self.realQty > 0");
domainList.add("COALESCE(self.stockMove.fullySpreadOverLogisticalFormsFlag, FALSE) = FALSE");
if (logisticalForm.getStockLocation() != null) {
domainList.add(String.format("self.stockMove.fromStockLocation.id = %d", logisticalForm.getStockLocation().getId()));
}
List<StockMoveLine> fullySpreadStockMoveLineList = Beans.get(LogisticalFormService.class).getFullySpreadStockMoveLineList(logisticalForm);
if (!fullySpreadStockMoveLineList.isEmpty()) {
String idListString = StringTool.getIdListString(fullySpreadStockMoveLineList);
domainList.add(String.format("self.id NOT IN (%s)", idListString));
}
return domainList.stream().map(domain -> String.format("(%s)", domain)).collect(Collectors.joining(" AND "));
}
use of com.axelor.apps.stock.db.LogisticalForm 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.LogisticalForm in project axelor-open-suite by axelor.
the class LogisticalFormController method print.
public void print(ActionRequest request, ActionResponse response) {
try {
LogisticalForm logisticalForm = request.getContext().asType(LogisticalForm.class);
String name = String.format("%s %s", I18n.get("Packing list"), logisticalForm.getDeliveryNumberSeq());
String fileLink = ReportFactory.createReport(IReport.PACKING_LIST, name + " - ${date}").addParam("LogisticalFormId", logisticalForm.getId()).addParam("Timezone", logisticalForm.getCompany() != null ? logisticalForm.getCompany().getTimezone() : null).addParam("Locale", ReportSettings.getPrintingLocale(logisticalForm.getDeliverToCustomerPartner())).generate().getFileLink();
response.setView(ActionView.define(name).add("html", fileLink).map());
} 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 processCollected.
public void processCollected(ActionRequest request, ActionResponse response) {
try {
LogisticalForm logisticalForm = request.getContext().asType(LogisticalForm.class);
logisticalForm = Beans.get(LogisticalFormRepository.class).find(logisticalForm.getId());
Beans.get(LogisticalFormService.class).processCollected(logisticalForm);
response.setReload(true);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
Aggregations