public void calculateFixed() {
   if (this.inc > 0) {
     if (this.isEndPrice == false) {
       this.price = this.price + this.inc;
       calculateEndPrice();
     } else {
       this.endprice = HibernateUtils.roundfloat(this.endprice + this.inc);
       this.price = HibernateUtils.calculateFromPercentage(this.endprice, this.taxrate);
     }
   }
 }
 private void copyToListProd(ListProduct prod) {
   prod.setEndprice(this.endprice);
   prod.setPrice(this.price);
   prod.setPercentage(
       HibernateUtils.calculatePercentageFromPrices(
           prod.getProduct().getPurchaseprice(), this.price));
 }
示例#3
0
  public ArrayList<Zone> getZones(int idcountry) {
    Session session = HibernateUtils.getSessionFactory().openSession();
    ArrayList<Zone> list = new ArrayList<Zone>();
    try {
      session.clear();
      Criteria cr = session.createCriteria(TblZone.class, "zone");
      cr.createAlias("zone.country", "country");
      cr.add(Restrictions.eq("country.idcountry", idcountry));
      cr.setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY);
      List<TblZone> zones = cr.list();
      if (zones.size() > 0) {
        for (Iterator<TblZone> iterator = zones.iterator(); iterator.hasNext(); ) {
          TblZone tblzone = iterator.next();
          Zone zone = new Zone();
          zone.convertFromTable(tblzone);
          list.add(zone);
        }
      }
      session.clear();
    } catch (HibernateException e) {
      System.err.println("ERROR IN LIST!!!!!!");
      e.printStackTrace();
      throw new ExceptionInInitializerError(e);
    } finally {

      session.close();
    }
    return list;
  }
示例#4
0
  public ArrayList<Country> getCountries() {
    Session session = HibernateUtils.getSessionFactory().openSession();
    ArrayList<Country> list = new ArrayList<Country>();
    try {
      session.clear();
      Criteria cr = session.createCriteria(TblCountry.class, "country");
      cr.setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY);
      List<TblCountry> countries = cr.list();
      if (countries.size() > 0) {
        for (Iterator<TblCountry> iterator = countries.iterator(); iterator.hasNext(); ) {
          TblCountry tblcountry = iterator.next();
          Country country = new Country();
          country.convertFromTable(tblcountry);
          list.add(country);
        }
      }
      session.clear();
    } catch (HibernateException e) {
      System.err.println("ERROR IN LIST!!!!!!");
      e.printStackTrace();
      throw new ExceptionInInitializerError(e);
    } finally {

      session.close();
    }
    return list;
  }
示例#5
0
  public ArrayList<City> getCitiesByZone(int idzone) {
    Session session = HibernateUtils.getSessionFactory().openSession();
    ArrayList<City> list = new ArrayList<City>();
    try {
      session.clear();
      Criteria cr = session.createCriteria(TblCity.class, "city");
      cr.createAlias("city.zone", "zone");
      cr.add(Restrictions.eq("zone.idzone", idzone));
      cr.setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY);
      List<TblCity> cities = cr.list();
      if (cities.size() > 0) {
        for (Iterator<TblCity> iterator = cities.iterator(); iterator.hasNext(); ) {
          TblCity tblcity = iterator.next();
          City city = new City();
          city.convertFromTable(tblcity);
          list.add(city);
        }
      }
      session.clear();
    } catch (HibernateException e) {
      System.err.println("ERROR IN LIST!!!!!!");
      e.printStackTrace();
      throw new ExceptionInInitializerError(e);
    } finally {

      session.close();
    }
    return list;
  }
 public void calculatePercentage() {
   if (this.inc > 0) {
     if (this.isEndPrice == false) {
       float increment = HibernateUtils.calculatePercentage(this.price, this.inc);
       increment = HibernateUtils.roundfloat(increment);
       this.price = HibernateUtils.roundfloat(this.price + increment);
       calculateEndPrice();
     } else {
       float increment = HibernateUtils.calculatePercentage(this.endprice, this.inc);
       increment = HibernateUtils.roundfloat(increment);
       this.endprice = HibernateUtils.roundfloat(this.endprice + increment);
       this.price = HibernateUtils.calculateFromPercentage(this.endprice, this.taxrate);
     }
   }
 }
  private void calculateEndPrice() {
    float increment = this.price / 100 * this.taxrate;

    this.endprice = HibernateUtils.roundfloat(this.price + increment);
  }