Search in sources :

Example 1 with Pack

use of com.axelor.apps.sale.db.Pack in project axelor-open-suite by axelor.

the class PackLineController method getPack.

public Pack getPack(Context context) {
    Context parentContext = context.getParent();
    PackLine packLine = context.asType(PackLine.class);
    Pack pack = packLine.getPack();
    if (parentContext != null && parentContext.getContextClass().equals(Pack.class)) {
        pack = parentContext.asType(Pack.class);
    }
    return pack;
}
Also used : Context(com.axelor.rpc.Context) Pack(com.axelor.apps.sale.db.Pack) PackLine(com.axelor.apps.sale.db.PackLine)

Example 2 with Pack

use of com.axelor.apps.sale.db.Pack in project axelor-open-suite by axelor.

the class SaleOrderController method addPack.

public void addPack(ActionRequest request, ActionResponse response) {
    Context context = request.getContext();
    String saleOrderId = context.get("_id").toString();
    SaleOrder saleOrder = Beans.get(SaleOrderRepository.class).find(Long.parseLong(saleOrderId));
    @SuppressWarnings("unchecked") LinkedHashMap<String, Object> packMap = (LinkedHashMap<String, Object>) request.getContext().get("pack");
    String packId = packMap.get("id").toString();
    Pack pack = Beans.get(PackRepository.class).find(Long.parseLong(packId));
    String qty = context.get("qty").toString();
    BigDecimal packQty = new BigDecimal(qty);
    saleOrder = Beans.get(SaleOrderService.class).addPack(saleOrder, pack, packQty);
    response.setCanClose(true);
}
Also used : Context(com.axelor.rpc.Context) PackRepository(com.axelor.apps.sale.db.repo.PackRepository) SaleOrderRepository(com.axelor.apps.sale.db.repo.SaleOrderRepository) SaleOrder(com.axelor.apps.sale.db.SaleOrder) Pack(com.axelor.apps.sale.db.Pack) BigDecimal(java.math.BigDecimal) LinkedHashMap(java.util.LinkedHashMap)

Example 3 with Pack

use of com.axelor.apps.sale.db.Pack in project axelor-open-suite by axelor.

the class PackLineController method getProductInformation.

public void getProductInformation(ActionRequest request, ActionResponse response) {
    Context context = request.getContext();
    PackLine packLine = context.asType(PackLine.class);
    Pack pack = this.getPack(context);
    Product product = packLine.getProduct();
    PackLineService packLineService = Beans.get(PackLineService.class);
    if (product == null) {
        packLine = packLineService.resetProductInformation(packLine);
        response.setValues(packLine);
        return;
    }
    try {
        packLine = packLineService.computeProductInformation(pack, packLine);
        response.setValues(packLine);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : Context(com.axelor.rpc.Context) Product(com.axelor.apps.base.db.Product) Pack(com.axelor.apps.sale.db.Pack) PackLineService(com.axelor.apps.sale.service.PackLineService) PackLine(com.axelor.apps.sale.db.PackLine)

Aggregations

Pack (com.axelor.apps.sale.db.Pack)3 Context (com.axelor.rpc.Context)3 PackLine (com.axelor.apps.sale.db.PackLine)2 Product (com.axelor.apps.base.db.Product)1 SaleOrder (com.axelor.apps.sale.db.SaleOrder)1 PackRepository (com.axelor.apps.sale.db.repo.PackRepository)1 SaleOrderRepository (com.axelor.apps.sale.db.repo.SaleOrderRepository)1 PackLineService (com.axelor.apps.sale.service.PackLineService)1 BigDecimal (java.math.BigDecimal)1 LinkedHashMap (java.util.LinkedHashMap)1