use of com.axelor.apps.stock.db.StockMoveLine in project axelor-open-suite by axelor.
the class StockMoveServiceImpl method copyPlannedStockMovLines.
protected void copyPlannedStockMovLines(StockMove stockMove) {
List<StockMoveLine> stockMoveLineList = MoreObjects.firstNonNull(stockMove.getStockMoveLineList(), Collections.emptyList());
stockMove.clearPlannedStockMoveLineList();
stockMoveLineList.forEach(stockMoveLine -> {
StockMoveLine copy = stockMoveLineRepo.copy(stockMoveLine, false);
copy.setArchived(true);
stockMove.addPlannedStockMoveLineListItem(copy);
});
}
use of com.axelor.apps.stock.db.StockMoveLine in project axelor-open-suite by axelor.
the class StockMoveServiceImpl method copyAndSplitStockMove.
@Override
public Optional<StockMove> copyAndSplitStockMove(StockMove stockMove, List<StockMoveLine> stockMoveLines) throws AxelorException {
stockMoveLines = MoreObjects.firstNonNull(stockMoveLines, Collections.emptyList());
StockMove newStockMove = stockMoveRepo.copy(stockMove, false);
// In copy OriginTypeSelect set null.
newStockMove.setOriginTypeSelect(stockMove.getOriginTypeSelect());
newStockMove.setOriginId(stockMove.getOriginId());
newStockMove.setOrigin(stockMove.getOrigin());
for (StockMoveLine stockMoveLine : stockMoveLines) {
if (stockMoveLine.getQty().compareTo(stockMoveLine.getRealQty()) > 0) {
StockMoveLine newStockMoveLine = copySplittedStockMoveLine(stockMoveLine);
newStockMove.addStockMoveLineListItem(newStockMoveLine);
}
}
if (ObjectUtils.isEmpty(newStockMove.getStockMoveLineList())) {
return Optional.empty();
}
newStockMove.setRealDate(null);
newStockMove.setStockMoveSeq(stockMoveToolService.getSequenceStockMove(newStockMove.getTypeSelect(), newStockMove.getCompany()));
newStockMove.setName(stockMoveToolService.computeName(newStockMove, newStockMove.getStockMoveSeq() + " " + I18n.get(IExceptionMessage.STOCK_MOVE_7) + " " + stockMove.getStockMoveSeq() + " )"));
newStockMove.setExTaxTotal(stockMoveToolService.compute(newStockMove));
plan(newStockMove);
newStockMove.setStockMoveOrigin(stockMove);
stockMoveRepo.save(newStockMove);
stockMove.setBackorderId(newStockMove.getId());
return Optional.of(newStockMove);
}
use of com.axelor.apps.stock.db.StockMoveLine in project axelor-open-suite by axelor.
the class StockMoveServiceImpl method updateProductNetMass.
@Override
@Transactional
public void updateProductNetMass(StockMove stockMove) throws AxelorException {
if (stockMove.getStockMoveLineList() != null) {
for (StockMoveLine stockMoveLine : stockMove.getStockMoveLineList()) {
if (stockMoveLine.getProduct() != null) {
Product product = productRepository.find(stockMoveLine.getProduct().getId());
stockMoveLine.setNetMass(product.getNetMass());
stockMoveLineRepo.save(stockMoveLine);
}
}
}
}
use of com.axelor.apps.stock.db.StockMoveLine in project axelor-open-suite by axelor.
the class StockMoveLineController method openTrackNumberWizard.
public void openTrackNumberWizard(ActionRequest request, ActionResponse response) {
Context context = request.getContext();
StockMoveLine stockMoveLine = context.asType(StockMoveLine.class);
StockMove stockMove = null;
if (context.getParent() != null && context.getParent().get("_model").equals("com.axelor.apps.stock.db.StockMove")) {
stockMove = context.getParent().asType(StockMove.class);
} else if (stockMoveLine.getStockMove() != null && stockMoveLine.getStockMove().getId() != null) {
stockMove = Beans.get(StockMoveRepository.class).find(stockMoveLine.getStockMove().getId());
}
boolean _hasWarranty = false, _isPerishable = false;
if (stockMoveLine.getProduct() != null) {
_hasWarranty = stockMoveLine.getProduct().getHasWarranty();
_isPerishable = stockMoveLine.getProduct().getIsPerishable();
}
response.setView(ActionView.define(I18n.get(IExceptionMessage.TRACK_NUMBER_WIZARD_TITLE)).model(Wizard.class.getName()).add("form", "stock-move-line-track-number-wizard-form").param("popup", "reload").param("show-toolbar", "false").param("show-confirm", "false").param("width", "large").param("popup-save", "false").context("_stockMove", stockMove).context("_stockMoveLine", stockMoveLine).context("_hasWarranty", _hasWarranty).context("_isPerishable", _isPerishable).map());
}
use of com.axelor.apps.stock.db.StockMoveLine in project axelor-open-suite by axelor.
the class StockMoveLineController method splitStockMoveLineByTrackingNumber.
public void splitStockMoveLineByTrackingNumber(ActionRequest request, ActionResponse response) {
Context context = request.getContext();
if (context.get("trackingNumbers") == null) {
response.setAlert(I18n.get(IExceptionMessage.TRACK_NUMBER_WIZARD_NO_RECORD_ADDED_ERROR));
} else {
@SuppressWarnings("unchecked") LinkedHashMap<String, Object> stockMoveLineMap = (LinkedHashMap<String, Object>) context.get("_stockMoveLine");
Integer stockMoveLineId = (Integer) stockMoveLineMap.get("id");
StockMoveLine stockMoveLine = Beans.get(StockMoveLineRepository.class).find(new Long(stockMoveLineId));
@SuppressWarnings("unchecked") ArrayList<LinkedHashMap<String, Object>> trackingNumbers = (ArrayList<LinkedHashMap<String, Object>>) context.get("trackingNumbers");
Beans.get(StockMoveLineService.class).splitStockMoveLineByTrackingNumber(stockMoveLine, trackingNumbers);
response.setCanClose(true);
}
}
Aggregations