Search in sources :

Example 6 with ReservedQtyService

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

the class StockMoveLineController method changeReservedQty.

/**
 * Called from stock move line request quantity wizard view. Call {@link
 * ReservedQtyService#updateReservedQty(StockMoveLine, BigDecimal)}.
 *
 * @param request
 * @param response
 */
public void changeReservedQty(ActionRequest request, ActionResponse response) {
    try {
        StockMoveLine stockMoveLine = request.getContext().asType(StockMoveLine.class);
        BigDecimal newReservedQty = stockMoveLine.getReservedQty();
        stockMoveLine = Beans.get(StockMoveLineRepository.class).find(stockMoveLine.getId());
        Product product = stockMoveLine.getProduct();
        if (product == null || !product.getStockManaged()) {
            throw new AxelorException(TraceBackRepository.CATEGORY_INCONSISTENCY, I18n.get(IExceptionMessage.SALE_ORDER_LINE_PRODUCT_NOT_STOCK_MANAGED));
        }
        Beans.get(ReservedQtyService.class).updateReservedQty(stockMoveLine, newReservedQty);
        response.setReload(true);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : AxelorException(com.axelor.exception.AxelorException) ReservedQtyService(com.axelor.apps.supplychain.service.ReservedQtyService) StockMoveLine(com.axelor.apps.stock.db.StockMoveLine) Product(com.axelor.apps.base.db.Product) BigDecimal(java.math.BigDecimal) AxelorException(com.axelor.exception.AxelorException)

Example 7 with ReservedQtyService

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

the class StockMoveLineController method allocateAll.

/**
 * Called from stock move form view, on clicking allocateAll button on one stock move line. Call
 * {@link ReservedQtyService#allocateAll(StockMoveLine)}.
 *
 * @param request
 * @param response
 */
public void allocateAll(ActionRequest request, ActionResponse response) {
    try {
        StockMoveLine stockMoveLine = request.getContext().asType(StockMoveLine.class);
        stockMoveLine = Beans.get(StockMoveLineRepository.class).find(stockMoveLine.getId());
        Product product = stockMoveLine.getProduct();
        if (product == null || !product.getStockManaged()) {
            throw new AxelorException(TraceBackRepository.CATEGORY_INCONSISTENCY, I18n.get(IExceptionMessage.SALE_ORDER_LINE_PRODUCT_NOT_STOCK_MANAGED));
        }
        Beans.get(ReservedQtyService.class).allocateAll(stockMoveLine);
        response.setReload(true);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : AxelorException(com.axelor.exception.AxelorException) ReservedQtyService(com.axelor.apps.supplychain.service.ReservedQtyService) StockMoveLine(com.axelor.apps.stock.db.StockMoveLine) Product(com.axelor.apps.base.db.Product) AxelorException(com.axelor.exception.AxelorException)

Example 8 with ReservedQtyService

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

the class StockMoveLineController method deallocateAll.

/**
 * Called from stock move form view, on clicking allocateAll button on one stock move line. Call
 * {@link ReservedQtyService#updateReservedQty(stockMoveLine, BigDecimal.ZERO)}.
 *
 * @param request
 * @param response
 */
public void deallocateAll(ActionRequest request, ActionResponse response) {
    try {
        StockMoveLine stockMoveLine = request.getContext().asType(StockMoveLine.class);
        stockMoveLine = Beans.get(StockMoveLineRepository.class).find(stockMoveLine.getId());
        Beans.get(ReservedQtyService.class).updateReservedQty(stockMoveLine, BigDecimal.ZERO);
        response.setReload(true);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : ReservedQtyService(com.axelor.apps.supplychain.service.ReservedQtyService) StockMoveLine(com.axelor.apps.stock.db.StockMoveLine) AxelorException(com.axelor.exception.AxelorException)

Example 9 with ReservedQtyService

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

the class StockMoveLineController method cancelReservation.

/**
 * Called from stock move line form view, on request qty click. Call {@link
 * ReservedQtyService#cancelReservation(StockMoveLine)}.
 *
 * @param request
 * @param response
 */
public void cancelReservation(ActionRequest request, ActionResponse response) {
    try {
        StockMoveLine stockMoveLine = request.getContext().asType(StockMoveLine.class);
        stockMoveLine = Beans.get(StockMoveLineRepository.class).find(stockMoveLine.getId());
        Product product = stockMoveLine.getProduct();
        if (product == null || !product.getStockManaged()) {
            throw new AxelorException(TraceBackRepository.CATEGORY_INCONSISTENCY, I18n.get(IExceptionMessage.SALE_ORDER_LINE_PRODUCT_NOT_STOCK_MANAGED));
        }
        Beans.get(ReservedQtyService.class).cancelReservation(stockMoveLine);
        response.setReload(true);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : AxelorException(com.axelor.exception.AxelorException) ReservedQtyService(com.axelor.apps.supplychain.service.ReservedQtyService) StockMoveLine(com.axelor.apps.stock.db.StockMoveLine) Product(com.axelor.apps.base.db.Product) AxelorException(com.axelor.exception.AxelorException)

Example 10 with ReservedQtyService

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

the class StockMoveLineController method requestQty.

/**
 * Called from stock move line form view, on request qty click. Call {@link
 * ReservedQtyService#requestQty(StockMoveLine)}.
 *
 * @param request
 * @param response
 */
public void requestQty(ActionRequest request, ActionResponse response) {
    try {
        StockMoveLine stockMoveLine = request.getContext().asType(StockMoveLine.class);
        stockMoveLine = Beans.get(StockMoveLineRepository.class).find(stockMoveLine.getId());
        Product product = stockMoveLine.getProduct();
        if (product == null || !product.getStockManaged()) {
            throw new AxelorException(TraceBackRepository.CATEGORY_INCONSISTENCY, I18n.get(IExceptionMessage.SALE_ORDER_LINE_PRODUCT_NOT_STOCK_MANAGED));
        }
        Beans.get(ReservedQtyService.class).requestQty(stockMoveLine);
        response.setReload(true);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : AxelorException(com.axelor.exception.AxelorException) ReservedQtyService(com.axelor.apps.supplychain.service.ReservedQtyService) StockMoveLine(com.axelor.apps.stock.db.StockMoveLine) Product(com.axelor.apps.base.db.Product) AxelorException(com.axelor.exception.AxelorException)

Aggregations

ReservedQtyService (com.axelor.apps.supplychain.service.ReservedQtyService)10 AxelorException (com.axelor.exception.AxelorException)10 Product (com.axelor.apps.base.db.Product)8 SaleOrderLine (com.axelor.apps.sale.db.SaleOrderLine)5 StockMoveLine (com.axelor.apps.stock.db.StockMoveLine)5 BigDecimal (java.math.BigDecimal)2