use of com.axelor.apps.stock.db.LogisticalFormLine in project axelor-open-suite by axelor.
the class LogisticalFormServiceImpl method getNextParcelPalletNumber.
@Override
public int getNextParcelPalletNumber(LogisticalForm logisticalForm, int typeSelect) {
int highest = 0;
Set<Integer> parcelPalletNumberSet = new HashSet<>();
if (logisticalForm.getLogisticalFormLineList() != null) {
for (LogisticalFormLine logisticalFormLine : logisticalForm.getLogisticalFormLineList()) {
if (logisticalFormLine.getTypeSelect() == typeSelect && logisticalFormLine.getParcelPalletNumber() != null) {
parcelPalletNumberSet.add(logisticalFormLine.getParcelPalletNumber());
if (logisticalFormLine.getParcelPalletNumber() > highest) {
highest = logisticalFormLine.getParcelPalletNumber();
}
}
}
}
for (int i = 1; i < highest; ++i) {
if (!parcelPalletNumberSet.contains(i)) {
return i;
}
}
return highest + 1;
}
use of com.axelor.apps.stock.db.LogisticalFormLine in project axelor-open-suite by axelor.
the class LogisticalFormLineController method setQty.
public void setQty(ActionRequest request, ActionResponse response) {
try {
LogisticalFormLine logisticalFormLine = getLogisticalFormLine(request);
if (logisticalFormLine.getQty() == null) {
BigDecimal qty = Beans.get(LogisticalFormLineService.class).getUnspreadQty(logisticalFormLine);
response.setValue("qty", qty);
}
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.stock.db.LogisticalFormLine in project axelor-open-suite by axelor.
the class LogisticalFormLineController method initParcelPallet.
public void initParcelPallet(ActionRequest request, ActionResponse response) {
try {
LogisticalFormLine logisticalFormLine = getLogisticalFormLine(request);
Beans.get(LogisticalFormLineService.class).initParcelPallet(logisticalFormLine);
response.setValue("parcelPalletNumber", logisticalFormLine.getParcelPalletNumber());
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.stock.db.LogisticalFormLine in project axelor-open-suite by axelor.
the class LogisticalFormSupplychainServiceImpl method createLogisticalFormLine.
@Override
protected LogisticalFormLine createLogisticalFormLine(LogisticalForm logisticalForm, StockMoveLine stockMoveLine, BigDecimal qty) {
LogisticalFormLine logisticalFormLine = super.createLogisticalFormLine(logisticalForm, stockMoveLine, qty);
if (!Beans.get(AppSupplychainService.class).isApp("supplychain")) {
return logisticalFormLine;
}
StockMove stockMove = logisticalFormLine.getStockMoveLine() != null ? logisticalFormLine.getStockMoveLine().getStockMove() : null;
if (stockMove != null && stockMove.getOriginId() != null && stockMove.getOriginId() != 0 && stockMove.getOriginTypeSelect().equals(StockMoveRepository.ORIGIN_SALE_ORDER)) {
logisticalFormLine.setSaleOrder(Beans.get(SaleOrderRepository.class).find(stockMove.getOriginId()));
}
return logisticalFormLine;
}
use of com.axelor.apps.stock.db.LogisticalFormLine 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 "));
}
Aggregations