public void setCurrencies(Integer entityId, CurrencyDTO[] currencies)
      throws NamingException, ParseException {
    EntityBL entity = new EntityBL(entityId);

    // start by wiping out the existing data for this entity
    entity.getEntity().getCurrencies().clear();
    for (CurrencyExchangeDTO exchange : exchangeDas.findByEntity(entityId)) {
      exchangeDas.delete(exchange);
    }

    for (CurrencyDTO currency : currencies) {
      if (currency.getInUse()) {
        set(currency.getId());
        entity.getEntity().getCurrencies().add(new CurrencyDAS().find(this.currency.getId()));

        if (currency.getRate() != null) {
          CurrencyExchangeDTO exchange =
              setOrUpdateExchangeRate(currency.getRateAsDecimal(), entityId, new Date());
          exchangeDas.save(exchange);
        }
      }
    }

    invalidateCache();
    ;
  }
  /** Removes exchange data for specified date */
  public void removeExchangeRatesForDate(Integer entityId, Date date) {
    final Date dayStart = com.sapienter.jbilling.common.Util.truncateDate(date);

    final CurrencyExchangeDAS exchangeDAS = new CurrencyExchangeDAS();
    final List<CurrencyExchangeDTO> companyExchanges = exchangeDAS.findByEntity(entityId);
    for (CurrencyExchangeDTO exchange : companyExchanges) {
      if (entityId.equals(exchange.getEntityId())) {
        final Date validSince = exchange.getValidSince();
        if (dayStart.equals(com.sapienter.jbilling.common.Util.truncateDate(validSince))) {
          exchangeDAS.delete(exchange);
        }
      }
    }
    /* @todo Konstantin Kulagin this should be in controller	*/
    exchangeDAS.flush();
    invalidateCache();
    ;
  }