Package com.swinarta.sunflower.core.model

Examples of com.swinarta.sunflower.core.model.Stock


    if(request.getOperationType() == OPERATION_TYPE.FETCH){
     
      Integer storeId = (Integer) request.getData().get("storeId");
     
      Stock s = coreManager.getStock(productId, storeId);
     
      DisplayStock dstock = null;
     
      if(s != null){
        dstock = mapper.map(s, DisplayStock.class);
        dstock.setProductId(s.getProduct().getId());
      }
     
      SgwtRestFetchResponseBase ret = new SgwtRestFetchResponseBase(dstock);
         
      return ret;
   
    }else if(request.getOperationType() == OPERATION_TYPE.ADD){
     
      Float current = RequestUtil.getFloat(request.getData().get("current"));
      Integer max = (Integer) request.getData().get("max");
      Integer min = (Integer) request.getData().get("min");
      Integer order = (Integer) request.getData().get("defaultOrder");
      Integer storeId = (Integer) request.getData().get("storeId");
     
      Product product = coreManager.get(Product.class, productId);
     
      Stock s = new Stock();
      s.setCurrent(current);
      s.setDefaultOrder(order);
      s.setMax(max);
      s.setMin(min);
      s.setLastUpdateReason(StockUpdateReason.WEB);
      s.setProduct(product);
      s.setStoreId(storeId);
     
      Stock retStock;
      DisplayStock dstock = null;
      try {
        retStock = coreManager.save(Stock.class, s);
        dstock = mapper.map(retStock, DisplayStock.class);
        dstock.setProductId(retStock.getProduct().getId());
       
      } catch (Exception e) {
        SgwtRestErrorResponse resp = new SgwtRestErrorResponse(SgwtRestResponseBase.RESPONSE_FAILURE);
        resp.addError("exception", e.getMessage());
        return resp;
      }
     
      SgwtRestFetchResponseBase ret = new SgwtRestFetchResponseBase(dstock);
     
      return ret;
    }else if(request.getOperationType() == OPERATION_TYPE.UPDATE){

      Float current = RequestUtil.getFloat(request.getData().get("current"));
      Integer max = (Integer) request.getData().get("max");
      Integer min = (Integer) request.getData().get("min");
      Integer order = (Integer) request.getData().get("defaultOrder");
      Integer storeId = (Integer) request.getData().get("storeId");

      Stock s = coreManager.getStock(productId, storeId);
      s.setCurrent(current);
      s.setDefaultOrder(order);
      s.setMax(max);
      s.setMin(min);
      s.setLastUpdateReason(StockUpdateReason.WEB);
     
      Stock retStock;
      DisplayStock dstock = null;
      try {
        retStock = coreManager.save(Stock.class, s);
        dstock = mapper.map(retStock, DisplayStock.class);
        dstock.setProductId(retStock.getProduct().getId());       
      } catch (Exception e) {
        SgwtRestErrorResponse resp = new SgwtRestErrorResponse(SgwtRestResponseBase.RESPONSE_FAILURE);
        resp.addError("exception", e.getMessage());
        return resp;
      }
View Full Code Here


   
    List<DisplayPurchasingOrderDetail> resultList = new ArrayList<DisplayPurchasingOrderDetail>();
   
    for (PurchasingOrderDetail purchasingOrderDetail : details) {
     
      Stock stock = null;
      ProductMeasurement productMeasurement = null;
     
      if(purchasingOrderDetail.getProduct().getStock() != null && !purchasingOrderDetail.getProduct().getStock().isEmpty()){
        stock = purchasingOrderDetail.getProduct().getStock().iterator().next();
      }
View Full Code Here

      PurchasingOrderDetail podResp = coreManager.save(PurchasingOrderDetail.class, pod);
      podResp = coreManager.getPurchasingOrderDetail(pod.getId());
      DisplayPurchasingOrderDetail det =  mapper.map(podResp, DisplayPurchasingOrderDetail.class);
      det.setCostPrice(podResp.getProduct().getBuying().getCostPrice());
     
      Stock stock = null;
      ProductMeasurement productMeasurement = null;     
      if(podResp.getProduct().getStock() != null && !podResp.getProduct().getStock().isEmpty()){
        stock = podResp.getProduct().getStock().iterator().next();
      }
      if(podResp.getProduct().getProductMeasurement() != null && !podResp.getProduct().getProductMeasurement().isEmpty()){
View Full Code Here

        PurchasingOrderDetail podResp = coreManager.save(PurchasingOrderDetail.class, pod);
        podResp = coreManager.getPurchasingOrderDetail(pod.getId());
        DisplayPurchasingOrderDetail det =  mapper.map(podResp, DisplayPurchasingOrderDetail.class);
        det.setCostPrice(podResp.getProduct().getBuying().getCostPrice());

        Stock stock = null;
        ProductMeasurement productMeasurement = null;     
        if(podResp.getProduct().getStock() != null && !podResp.getProduct().getStock().isEmpty()){
          stock = podResp.getProduct().getStock().iterator().next();
        }
        if(podResp.getProduct().getProductMeasurement() != null && !podResp.getProduct().getProductMeasurement().isEmpty()){
View Full Code Here

TOP

Related Classes of com.swinarta.sunflower.core.model.Stock

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.