Search in sources :

Example 1 with AppSupplychainService

use of com.axelor.apps.supplychain.service.app.AppSupplychainService in project axelor-open-suite by axelor.

the class StockMoveServiceSupplychainImpl method copySplittedStockMoveLine.

/**
 * The splitted stock move line needs an allocation and will be planned before the previous stock
 * move line is realized. To solve this issue, we deallocate here in the previous stock move line
 * the quantity that will be allocated in the generated stock move line. The quantity will be
 * reallocated when the generated stock move is planned.
 *
 * @param stockMoveLine the previous stock move line
 * @return the generated stock move line
 * @throws AxelorException
 */
@Override
protected StockMoveLine copySplittedStockMoveLine(StockMoveLine stockMoveLine) throws AxelorException {
    StockMoveLine newStockMoveLine = super.copySplittedStockMoveLine(stockMoveLine);
    AppSupplychainService appSupplychainService = Beans.get(AppSupplychainService.class);
    if (appSupplychainService.getAppSupplychain().getManageStockReservation() && appSupplychainService.isApp("supplychain")) {
        BigDecimal requestedReservedQty = stockMoveLine.getRequestedReservedQty().subtract(stockMoveLine.getRealQty()).max(BigDecimal.ZERO);
        newStockMoveLine.setRequestedReservedQty(requestedReservedQty);
        newStockMoveLine.setReservedQty(BigDecimal.ZERO);
        reservedQtyService.deallocateStockMoveLineAfterSplit(stockMoveLine, stockMoveLine.getReservedQty());
        stockMoveLine.setReservedQty(BigDecimal.ZERO);
    }
    return newStockMoveLine;
}
Also used : StockMoveLine(com.axelor.apps.stock.db.StockMoveLine) AppSupplychainService(com.axelor.apps.supplychain.service.app.AppSupplychainService) BigDecimal(java.math.BigDecimal)

Example 2 with AppSupplychainService

use of com.axelor.apps.supplychain.service.app.AppSupplychainService in project axelor-open-suite by axelor.

the class StockMoveServiceSupplychainImpl method plan.

@Override
@Transactional(rollbackOn = { Exception.class })
public void plan(StockMove stockMove) throws AxelorException {
    super.plan(stockMove);
    AppSupplychainService appSupplychainService = Beans.get(AppSupplychainService.class);
    if (appSupplychainService.getAppSupplychain().getManageStockReservation() && appSupplychainService.isApp("supplychain")) {
        Beans.get(ReservedQtyService.class).updateReservedQuantity(stockMove, StockMoveRepository.STATUS_PLANNED);
    }
}
Also used : AppSupplychainService(com.axelor.apps.supplychain.service.app.AppSupplychainService) Transactional(com.google.inject.persist.Transactional)

Aggregations

AppSupplychainService (com.axelor.apps.supplychain.service.app.AppSupplychainService)2 StockMoveLine (com.axelor.apps.stock.db.StockMoveLine)1 Transactional (com.google.inject.persist.Transactional)1 BigDecimal (java.math.BigDecimal)1