Examples of Buying


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

    this.coreManager = coreManager;
 

  @Get("json")
  public Object getMe(){
    Buying b = coreManager.get(Buying.class, 1);

    return mapper.map(b, DisplayBuying.class);
       
  }
View Full Code Here

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

  }

  @Post("json")
  public SgwtRestResponseBase getRepresent(SgwtRequest request){
   
    Buying respBuying = null;
    Integer id = (Integer) request.getData().get("id");
   
    if(request.getOperationType() == OPERATION_TYPE.FETCH){
     
      try{
        respBuying = coreManager.get(Buying.class, id);
      }catch (ObjectRetrievalFailureException e) {
        //buying info not found
      }
     
    }else if(request.getOperationType() == OPERATION_TYPE.UPDATE){

      Double buyingPrice = ((Number) request.getData().get("buyingPrice")).doubleValue();
      Double disc1 = ((Number) request.getData().get("disc1")).doubleValue();
      Double disc2 = ((Number) request.getData().get("disc2")).doubleValue();
      Double disc3 = ((Number) request.getData().get("disc3")).doubleValue();
      Double disc4 = ((Number) request.getData().get("disc4")).doubleValue();
      Boolean taxIncluded = (Boolean) request.getData().get("taxIncluded");
      Double discPrice = ((Number) request.getData().get("discPrice")).doubleValue();
     
      Integer measurementSelectionId = RequestUtil.getInteger(request.getData().get("measurementSelectionId"));
      Integer supplierId = RequestUtil.getInteger(request.getData().get("supplierId"));
     
      Buying b = coreManager.get(Buying.class, id);
      b.setBuyingPrice(buyingPrice);
      b.setDisc1(disc1);
      b.setDisc2(disc2);
      b.setDisc3(disc3);
      b.setDisc4(disc4);
      b.setTaxIncluded(taxIncluded);
      b.setDiscPrice(discPrice);

      if(measurementSelectionId.intValue() != b.getMeasurement().getId().intValue()){
        Measurement selm = coreManager.get(Measurement.class, measurementSelectionId);
        b.setMeasurement(selm);
      }
     
      if(supplierId.intValue() != b.getSupplier().getId().intValue()){
        Supplier supp = coreManager.get(Supplier.class, supplierId);
        b.setSupplier(supp);
      }
           
      try{
        respBuying = coreManager.save(Buying.class, b);
      }catch (Exception e) {
        SgwtRestErrorResponse resp = new SgwtRestErrorResponse(SgwtRestResponseBase.RESPONSE_FAILURE);
        resp.addError("exception", e.getMessage());
        return resp;
      }
     
    }else if(request.getOperationType() == OPERATION_TYPE.ADD){
     
      Double buyingPrice = RequestUtil.getDouble(request.getData().get("buyingPrice"));
      Double disc1 = RequestUtil.getDouble(request.getData().get("disc1"));
      Double disc2 = RequestUtil.getDouble(request.getData().get("disc2"));
      Double disc3 = RequestUtil.getDouble(request.getData().get("disc3"));
      Double disc4 = RequestUtil.getDouble(request.getData().get("disc4"));     
      Boolean taxIncluded = RequestUtil.getBoolean(request.getData().get("taxIncluded"));     
      Double discPrice = RequestUtil.getDouble(request.getData().get("discPrice"));
     
      Integer measurementSelectionId = RequestUtil.getInteger(request.getData().get("measurementSelectionId"));
      Integer supplierId = RequestUtil.getInteger(request.getData().get("supplierId"));

      Buying b = new Buying();
      b.setId(id);
      b.setBuyingPrice(buyingPrice);
      b.setDisc1(disc1);
      b.setDisc2(disc2);
      b.setDisc3(disc3);
      b.setDisc4(disc4);
      b.setTaxIncluded(taxIncluded);
      b.setDiscPrice(discPrice);
     
      Measurement selm = coreManager.get(Measurement.class, measurementSelectionId);
      b.setMeasurement(selm);

      Supplier supp = coreManager.get(Supplier.class, supplierId);
      b.setSupplier(supp);
     
      Product prod = coreManager.get(Product.class, id);
      b.setProduct(prod);
           
      try{
        respBuying = coreManager.save(Buying.class, b);
      }catch (Exception e) {
        e.printStackTrace();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.