use of com.axelor.apps.stock.db.StockLocationLine in project axelor-open-suite by axelor.
the class StockLocationLineServiceImpl method getOrCreateDetailLocationLine.
@Override
public StockLocationLine getOrCreateDetailLocationLine(StockLocation detailLocation, Product product, TrackingNumber trackingNumber) {
StockLocationLine detailLocationLine = this.getDetailLocationLine(detailLocation, product, trackingNumber);
if (detailLocationLine == null) {
detailLocationLine = this.createDetailLocationLine(detailLocation, product, trackingNumber);
}
LOG.debug("Récupération ligne de détail de stock: Entrepot? {}, Produit? {}, Qté actuelle? {}, Qté future? {}, Date? {}, Variante? {}, Num de suivi? {} ", detailLocationLine.getDetailsStockLocation().getName(), product.getCode(), detailLocationLine.getCurrentQty(), detailLocationLine.getFutureQty(), detailLocationLine.getLastFutureStockMoveDate(), detailLocationLine.getTrackingNumber());
return detailLocationLine;
}
use of com.axelor.apps.stock.db.StockLocationLine in project axelor-open-suite by axelor.
the class StockLocationLineServiceImpl method createLocationLine.
@Override
public StockLocationLine createLocationLine(StockLocation stockLocation, Product product) {
LOG.debug("Création d'une ligne de stock : Entrepot? {}, Produit? {} ", stockLocation.getName(), product.getCode());
StockLocationLine stockLocationLine = new StockLocationLine();
stockLocationLine.setStockLocation(stockLocation);
stockLocation.addStockLocationLineListItem(stockLocationLine);
stockLocationLine.setProduct(product);
stockLocationLine.setUnit(product.getUnit());
stockLocationLine.setCurrentQty(BigDecimal.ZERO);
stockLocationLine.setFutureQty(BigDecimal.ZERO);
return stockLocationLine;
}
use of com.axelor.apps.stock.db.StockLocationLine in project axelor-open-suite by axelor.
the class StockLocationLineServiceImpl method updateLocation.
@Override
@Transactional(rollbackOn = { Exception.class })
public void updateLocation(StockLocation stockLocation, Product product, Unit stockMoveLineUnit, BigDecimal qty, boolean current, boolean future, boolean isIncrement, LocalDate lastFutureStockMoveDate) throws AxelorException {
StockLocationLine stockLocationLine = this.getOrCreateStockLocationLine(stockLocation, product);
if (stockLocationLine == null) {
return;
}
Unit stockLocationLineUnit = stockLocationLine.getUnit();
if (stockLocationLineUnit == null) {
throw new AxelorException(TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.LOCATION_LINE_MISSING_UNIT), stockLocation.getName(), product.getFullName());
}
if (!stockLocationLineUnit.equals(stockMoveLineUnit)) {
qty = unitConversionService.convert(stockMoveLineUnit, stockLocationLineUnit, qty, qty.scale(), product);
}
LOG.debug("Mise à jour du stock : Entrepot? {}, Produit? {}, Quantité? {}, Actuel? {}, Futur? {}, Incrément? {}, Date? {} ", stockLocation.getName(), product.getCode(), qty, current, future, isIncrement, lastFutureStockMoveDate);
if (!isIncrement) {
minStockRules(product, qty, stockLocationLine, current, future);
} else {
maxStockRules(product, qty, stockLocationLine, current, future);
}
stockLocationLine = this.updateLocation(stockLocationLine, stockMoveLineUnit, product, qty, current, future, isIncrement, lastFutureStockMoveDate);
this.checkStockMin(stockLocationLine, false);
stockLocationLineRepo.save(stockLocationLine);
}
use of com.axelor.apps.stock.db.StockLocationLine in project axelor-open-suite by axelor.
the class StockLocationLineServiceImpl method updateDetailLocation.
@Override
@Transactional(rollbackOn = { Exception.class })
public void updateDetailLocation(StockLocation stockLocation, Product product, Unit stockMoveLineUnit, BigDecimal qty, boolean current, boolean future, boolean isIncrement, LocalDate lastFutureStockMoveDate, TrackingNumber trackingNumber) throws AxelorException {
StockLocationLine detailLocationLine = this.getOrCreateDetailLocationLine(stockLocation, product, trackingNumber);
if (detailLocationLine == null) {
return;
}
Unit stockLocationLineUnit = detailLocationLine.getUnit();
if (stockLocationLineUnit == null) {
throw new AxelorException(TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.DETAIL_LOCATION_LINE_MISSING_UNIT), trackingNumber.getTrackingNumberSeq(), stockLocation.getName(), product.getFullName());
}
if (!stockLocationLineUnit.equals(stockMoveLineUnit)) {
qty = unitConversionService.convert(stockMoveLineUnit, stockLocationLineUnit, qty, qty.scale(), product);
}
LOG.debug("Mise à jour du detail du stock : Entrepot? {}, Produit? {}, Quantité? {}, Actuel? {}, Futur? {}, Incrément? {}, Date? {}, Num de suivi? {} ", stockLocation.getName(), product.getCode(), qty, current, future, isIncrement, lastFutureStockMoveDate, trackingNumber);
detailLocationLine = this.updateLocation(detailLocationLine, stockMoveLineUnit, product, qty, current, future, isIncrement, lastFutureStockMoveDate);
this.checkStockMin(detailLocationLine, true);
stockLocationLineRepo.save(detailLocationLine);
}
use of com.axelor.apps.stock.db.StockLocationLine in project axelor-open-suite by axelor.
the class StockLocationLineServiceImpl method getOrCreateStockLocationLine.
@Override
public StockLocationLine getOrCreateStockLocationLine(StockLocation stockLocation, Product product) {
if (!product.getStockManaged()) {
return null;
}
StockLocationLine stockLocationLine = this.getStockLocationLine(stockLocation, product);
if (stockLocationLine == null) {
stockLocationLine = this.createLocationLine(stockLocation, product);
}
LOG.debug("Récupération ligne de stock: Entrepot? {}, Produit? {}, Qté actuelle? {}, Qté future? {}, Date? {} ", stockLocationLine.getStockLocation().getName(), product.getCode(), stockLocationLine.getCurrentQty(), stockLocationLine.getFutureQty(), stockLocationLine.getLastFutureStockMoveDate());
return stockLocationLine;
}
Aggregations