use of com.axelor.apps.stock.db.LogisticalFormLine in project axelor-open-suite by axelor.
the class LogisticalFormServiceImpl method updateProductNetMass.
public void updateProductNetMass(LogisticalForm logisticalForm) {
BigDecimal totalNetMass = BigDecimal.ZERO;
if (logisticalForm.getLogisticalFormLineList() != null) {
for (LogisticalFormLine logisticalFormLine : logisticalForm.getLogisticalFormLineList()) {
if (logisticalFormLine.getStockMoveLine() != null && logisticalFormLine.getStockMoveLine().getProduct() != null && logisticalFormLine.getTypeSelect().equals(LogisticalFormLineRepository.TYPE_DETAIL)) {
Product product = productRepository.find(logisticalFormLine.getStockMoveLine().getProduct().getId());
logisticalFormLine.setUnitNetMass(product.getNetMass());
totalNetMass = totalNetMass.add(logisticalFormLine.getQty().multiply(product.getNetMass()));
}
}
logisticalForm.setTotalNetMass(totalNetMass);
}
}
use of com.axelor.apps.stock.db.LogisticalFormLine in project axelor-open-suite by axelor.
the class LogisticalFormServiceImpl method addParcelPalletLine.
@Override
public void addParcelPalletLine(LogisticalForm logisticalForm, int typeSelect) {
LogisticalFormLine logisticalFormLine = new LogisticalFormLine();
logisticalFormLine.setTypeSelect(typeSelect);
logisticalFormLine.setParcelPalletNumber(getNextParcelPalletNumber(logisticalForm, typeSelect));
logisticalFormLine.setSequence(getNextLineSequence(logisticalForm));
addLogisticalFormLineListItem(logisticalForm, logisticalFormLine);
}
use of com.axelor.apps.stock.db.LogisticalFormLine 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.LogisticalFormLine in project axelor-open-suite by axelor.
the class LogisticalFormServiceImpl method createLogisticalFormLine.
protected LogisticalFormLine createLogisticalFormLine(LogisticalForm logisticalForm, StockMoveLine stockMoveLine, BigDecimal qty) {
LogisticalFormLine logisticalFormLine = new LogisticalFormLine();
logisticalFormLine.setTypeSelect(LogisticalFormLineRepository.TYPE_DETAIL);
logisticalFormLine.setStockMoveLine(stockMoveLine);
logisticalFormLine.setQty(qty);
logisticalFormLine.setSequence(getNextLineSequence(logisticalForm));
logisticalFormLine.setUnitNetMass(stockMoveLine.getNetMass());
return logisticalFormLine;
}
use of com.axelor.apps.stock.db.LogisticalFormLine in project axelor-open-suite by axelor.
the class LogisticalFormServiceImpl method computeTotals.
@Override
public void computeTotals(LogisticalForm logisticalForm) throws LogisticalFormError {
BigDecimal totalNetMass = BigDecimal.ZERO;
BigDecimal totalGrossMass = BigDecimal.ZERO;
BigDecimal totalVolume = BigDecimal.ZERO;
if (logisticalForm.getLogisticalFormLineList() != null) {
ScriptHelper scriptHelper = getScriptHelper(logisticalForm);
LogisticalFormLineService logisticalFormLineService = Beans.get(LogisticalFormLineService.class);
for (LogisticalFormLine logisticalFormLine : logisticalForm.getLogisticalFormLineList()) {
StockMoveLine stockMoveLine = logisticalFormLine.getStockMoveLine();
if (logisticalFormLine.getTypeSelect() != LogisticalFormLineRepository.TYPE_DETAIL) {
if (logisticalFormLine.getGrossMass() != null) {
totalGrossMass = totalGrossMass.add(logisticalFormLine.getGrossMass());
}
BigDecimal toAdd = logisticalFormLineService.evalVolume(logisticalFormLine, scriptHelper);
if (toAdd == null) {
throw new LogisticalFormError(logisticalForm, I18n.get(IExceptionMessage.LOGISTICAL_FORM_INVALID_DIMENSIONS));
} else {
totalVolume = totalVolume.add(toAdd);
}
} else if (stockMoveLine != null) {
totalNetMass = totalNetMass.add(logisticalFormLine.getQty().multiply(stockMoveLine.getNetMass()));
}
}
totalVolume = totalVolume.divide(new BigDecimal(1_000_000), 10, RoundingMode.HALF_UP);
logisticalForm.setTotalNetMass(totalNetMass.setScale(3, RoundingMode.HALF_UP));
logisticalForm.setTotalGrossMass(totalGrossMass.setScale(3, RoundingMode.HALF_UP));
logisticalForm.setTotalVolume(totalVolume.setScale(3, RoundingMode.HALF_UP));
}
}
Aggregations