Package com.jpoweredcart.common.entity.localisation

Examples of com.jpoweredcart.common.entity.localisation.Currency


    final Map<String, Currency> dataMap = new HashMap<String, Currency>();
    getJdbcOperations().query(sql, new Object[]{Status.ENABLED}, new RowCallbackHandler(){
     
      @Override
      public void processRow(ResultSet rs) throws SQLException {
        Currency currency = new Currency();
        currency.setId(rs.getInt("currency_id"));
        currency.setCode(rs.getString("code"));
        currency.setTitle(rs.getString("title"));
        currency.setSymbolLeft(rs.getString("symbol_left"));
        currency.setSymbolRight(rs.getString("symbol_right"));
        try{
          currency.setDecimalPlace(rs.getInt("decimal_place"));
        }catch(Exception e){
          e.printStackTrace();
        }
        currency.setValue(rs.getBigDecimal("value"));
        if(currency.getValue().intValue()==1){
          CurrencyServiceImpl.this.defaultCurrencyCode = currency.getCode();
        }
        dataMap.put(currency.getCode(), currency);
        if(autoUpdate){
          long lastModified = rs.getTimestamp("date_modified").getTime();
          long current = new Date().getTime();
          long diff = ((current-lastModified)/(3600*1000));
          if(diff>whenDiff){
 
View Full Code Here


  }
 
 
  @Override
  public Integer getId(String code) {
    Currency currency = currencyMap.get(code);
    if(currency!=null) return currency.getId();
    return null;
  }
View Full Code Here

    return null;
  }
 
  @Override
  public BigDecimal getValue(String code) {
    Currency currency = currencyMap.get(code);
    if(currency!=null) return currency.getValue();
    return null;
  }
View Full Code Here

  }
 
  @Override
  public String format(BigDecimal number, String code, BigDecimal overrideRate, Locale locale) {
   
    Currency currency = currencyMap.get(code);
    if(currency==null){
      throw new IllegalArgumentException("Undefined currency code: "+code);
    }
   
    String result = "";
    if(currency.getSymbolLeft()!=null) result = currency.getSymbolLeft();
   
    NumberFormat numberFormat = locale==null?NumberFormat.getInstance():
      NumberFormat.getInstance(locale);
   
    BigDecimal value = null;
    if(overrideRate!=null){
      value = number.multiply(overrideRate);
    }else{
      value = number.multiply(currency.getValue());
    }
   
    result += numberFormat.format(value);
   
    if(currency.getSymbolRight()!=null) result += currency.getSymbolRight();
   
    return result;
  }
View Full Code Here

  @Override
  public BigDecimal convert(BigDecimal number, String fromCode, String toCode) {
    if(number==null){
      return BigDecimal.ZERO;
    }
    Currency fromCurrency = currencyMap.get(fromCode);
    BigDecimal from = null;
    if(fromCurrency!=null){
      from = fromCurrency.getValue();
      if(from==null||from.equals(BigDecimal.ZERO)){
        throw new RuntimeException("Invalid currency value for code: "+
            fromCode+", value: "+from);
      }
    }else{
      throw new IllegalArgumentException("Undefined currency code: "+fromCode);
    }
    Currency toCurrency = currencyMap.get(toCode);
    BigDecimal to = BigDecimal.ZERO;
    if(toCurrency!=null){
      to = toCurrency.getValue();
    }
   
    return number.multiply(to.divide(from));
  }
View Full Code Here

    return number.multiply(to.divide(from));
  }
 
  @Override
  public String getSymbolLeft(String code) {
    Currency currency = currencyMap.get(code);
    if(currency!=null) return currency.getSymbolLeft();
    return null;
  }
View Full Code Here

    return null;
  }

  @Override
  public String getSymbolRight(String code) {
    Currency currency = currencyMap.get(code);
    if(currency!=null) return currency.getSymbolRight();
    return null;
  }
View Full Code Here

    return null;
  }

  @Override
  public Integer getDecimalPlace(String code) {
    Currency currency = currencyMap.get(code);
    if(currency!=null) return currency.getDecimalPlace();
    return null;
  }
View Full Code Here

   
    zone = zoneAdminModel.get(orderForm.getPaymentZoneId());
    String paymentZone = zone.getName();
   
    String currencyCode = getSettingService().getConfig(SettingKey.CFG_CURRENCY);
    Currency currency = currencyAdminModel.getOneByCode(currencyCode);
    Integer currencyId = currency.getId();
    BigDecimal currencyValue = currency.getValue();
   
   
  }
View Full Code Here

TOP

Related Classes of com.jpoweredcart.common.entity.localisation.Currency

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.