Search in sources :

Example 11 with StockLocationLine

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;
}
Also used : StockLocationLine(com.axelor.apps.stock.db.StockLocationLine)

Example 12 with StockLocationLine

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;
}
Also used : StockLocationLine(com.axelor.apps.stock.db.StockLocationLine)

Example 13 with 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);
}
Also used : AxelorException(com.axelor.exception.AxelorException) StockLocationLine(com.axelor.apps.stock.db.StockLocationLine) Unit(com.axelor.apps.base.db.Unit) Transactional(com.google.inject.persist.Transactional)

Example 14 with 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);
}
Also used : AxelorException(com.axelor.exception.AxelorException) StockLocationLine(com.axelor.apps.stock.db.StockLocationLine) Unit(com.axelor.apps.base.db.Unit) Transactional(com.google.inject.persist.Transactional)

Example 15 with StockLocationLine

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;
}
Also used : StockLocationLine(com.axelor.apps.stock.db.StockLocationLine)

Aggregations

StockLocationLine (com.axelor.apps.stock.db.StockLocationLine)42 BigDecimal (java.math.BigDecimal)25 Product (com.axelor.apps.base.db.Product)13 Transactional (com.google.inject.persist.Transactional)10 StockLocation (com.axelor.apps.stock.db.StockLocation)8 AxelorException (com.axelor.exception.AxelorException)8 Unit (com.axelor.apps.base.db.Unit)7 StockMoveLine (com.axelor.apps.stock.db.StockMoveLine)7 TrackingNumber (com.axelor.apps.stock.db.TrackingNumber)6 InventoryLine (com.axelor.apps.stock.db.InventoryLine)4 StockLocationLineRepository (com.axelor.apps.stock.db.repo.StockLocationLineRepository)4 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 Company (com.axelor.apps.base.db.Company)3 StockMove (com.axelor.apps.stock.db.StockMove)3 Beans (com.axelor.inject.Beans)3 UnitConversionService (com.axelor.apps.base.service.UnitConversionService)2 AppBaseService (com.axelor.apps.base.service.app.AppBaseService)2 SaleOrderLine (com.axelor.apps.sale.db.SaleOrderLine)2 Inventory (com.axelor.apps.stock.db.Inventory)2