Updates a currency
542308
protected function updateCurrency()
    {
        $this->controlAccess('currency_edit');

        if ($this->currency->update($this->data_currency['code'], $this->getSubmitted())) {
            $this->redirect('admin/settings/currency', $this->text('Currency has been updated'), 'success');
        }

        $this->redirect('', $this->text('Currency has not been updated'), 'warning');
    }
1289068
def format_currency_field(__, prec, number, locale):
    """"""
    locale = Locale.parse(locale)
    currency = get_territory_currencies(locale.territory)[0]
    if prec is None:
        pattern, currency_digits = None, True
    else:
        prec = int(prec)
        pattern = locale.currency_formats['standard']
        pattern = modify_number_pattern(pattern, frac_prec=(prec, prec))
        currency_digits = False
    return format_currency(number, currency, pattern, locale=locale,
                           currency_digits=currency_digits)
977423
private function retrieveExchangeRateFor(Currency $currency): void
    {
        $response = $this->client->request('GET', self::EXCHANGE_RATE_API_URL . '/latest', [
            'query' => [
                'access_key' => $this->apiKey,
                'base'       => $this->baseCurrency->getCode(),
            ],
        ]);

        $data = json_decode($response->getBody(), true);

        if ($data['success'] !== true) {
            throw FixerIoException::couldNotRetrieveRates($data['error']);
        }

        if (! array_key_exists($currency->getCode(), $data['rates'])) {
            throw FixerIoException::currencyNotFound($currency->getCode());
        }

        $this->exchangeRates[$currency->getCode()] = $data['rates'][$currency->getCode()];
    }
876540
public function updateRatesAction()
    {
        // Check current user authorization
        if (null !== $response = $this->checkAuth($this->resourceCode, array(), AccessManager::UPDATE)) {
            return $response;
        }

        try {
            $event = new CurrencyUpdateRateEvent();

            $this->dispatch(TheliaEvents::CURRENCY_UPDATE_RATES, $event);

            if ($event->hasUndefinedRates()) {
                return $this->render('currencies', [
                    'undefined_rates' => $event->getUndefinedRates()
                ]);
            }
        } catch (\Exception $ex) {
            // Any error
            return $this->errorPage($ex);
        }

        return $this->redirectToListTemplate();
    }
466213
def convert_money(amount, currency_from, currency_to):
    
    new_amount = base_convert_money(amount, currency_from, currency_to)
    return moneyed.Money(new_amount, currency_to)
381739
private function setUserCurrency($currency, $request)
    {
        $currency = strtoupper($currency);

        // Set user selection globally
        currency()->setUserCurrency($currency);

        // Save it for later too!
        $request->getSession()->put(['currency' => $currency]);

        return $currency;
    }
21813
private CurrencyData getCurrencyData(String code) {
    CurrencyData data = currencies.get(code);
    if (data == null) {
      data = new CurrencyData();
      data.setCode(code);
      currencies.put(code, data);
    }
    return data;
  }
1123837
private void processCurrency(Row row)
   {
      String currencyName = row.getString("curr_short_name");
      DecimalFormatSymbols symbols = new DecimalFormatSymbols();
      symbols.setDecimalSeparator(row.getString("decimal_symbol").charAt(0));
      symbols.setGroupingSeparator(row.getString("digit_group_symbol").charAt(0));
      DecimalFormat nf = new DecimalFormat();
      nf.setDecimalFormatSymbols(symbols);
      nf.applyPattern("#.#");
      m_currencyMap.put(currencyName, nf);

      if (currencyName.equalsIgnoreCase(m_defaultCurrencyName))
      {
         m_numberFormat = nf;
         m_defaultCurrencyData = row;
      }
   }
4248
public function setCurrency($currency = 'USD')
    {
        $allowedCurrencies = ['AUD', 'BRL', 'CAD', 'CZK', 'DKK', 'EUR', 'HKD', 'HUF', 'ILS', 'INR', 'JPY', 'MYR', 'MXN', 'NOK', 'NZD', 'PHP', 'PLN', 'GBP', 'SGD', 'SEK', 'CHF', 'TWD', 'THB', 'USD', 'RUB'];

        // Check if provided currency is valid.
        if (!in_array($currency, $allowedCurrencies)) {
            throw new \Exception('Currency is not supported by PayPal.');
        }

        $this->currency = $currency;

        return $this;
    }
299412
public function setCurrency($value)
    {
        if ($value === null || $value === '') {
            $this->_currency = null;
        } elseif (TypeCast::canCastToEnumString($value)) {
            $value = strtoupper($value);
            if (!CurrencyCode::valueExists($value)) {
                throw new \InvalidArgumentException('Invalid currency value: "' . $value . '"');
            }
            $this->_currency = $value;
        } else {
            throw new \InvalidArgumentException('Invalid currency value type: "' . gettype($value) . '"');
        }
    }
1079313
public function setCurrency($currency)
    {
        if ( ! in_array($currency, self::$supportedCurrencies)) {
            throw new CurrencyNotSupported(sprintf('Currency "%s" is not supported.', $currency));
        }
        $this->currency = $currency;
    }
654548
def set_money_currency(self, money_currency):
        
        if money_currency not in self.money_formats:
            raise CurrencyDoesNotExist

        self.money_currency = money_currency
603103
def convert_currency(self, base_fiat, base_amount, target_fiat):
        
        url = "http://api.fixer.io/latest?base=%s" % base_fiat
        data = self.get_url(url).json()
        try:
            return data['rates'][target_fiat.upper()] * base_amount
        except KeyError:
            raise Exception("Can not convert %s to %s" % (base_fiat, target_fiat))
521586
protected function validateCurrency()
    {
        $id = $this->getUpdatingId();

        if ($id === false) {
            return null;
        }

        $data = $this->currency->get($id);

        if (empty($data)) {
            $this->setErrorUnavailable('update', $this->translation->text('Currency'));
            return false;
        }

        $this->setUpdating($data);
        return true;
    }
1370144
function updateFee() {
		// Check for amount errors
		if(undefined === $("#amount").val() || !nem.utils.helpers.isTextAmountValid($("#amount").val())) return alert('Invalid amount !');

		// Set the cleaned amount into transfer transaction object
		transferTransaction.amount = nem.utils.helpers.cleanTextAmount($("#amount").val());

		// Set the message into transfer transaction object
		transferTransaction.message = $("#message").val();

		// Prepare the updated transfer transaction object
		var transactionEntity = nem.model.transactions.prepare("transferTransaction")(common, transferTransaction, nem.model.network.data.testnet.id);

		// Format fee returned in prepared object
		var feeString = nem.utils.format.nemValue(transactionEntity.fee)[0] + "." + nem.utils.format.nemValue(transactionEntity.fee)[1];

		//Set fee in view
		$("#fee").html(feeString);
	}
323262
public void setCurrency(String currency) {
		currency = StringUtils.upperCase(currency);
		if (!CurrencyUtils.getInstance().isValidCurrency(currency)) {
			currency = "EUR";
		}
		this.currency = currency;
	}
1188872
function currency(value, opts) {
  let that = this;

  if(!(that instanceof currency)) {
    return new currency(value, opts);
  }

  let settings = Object.assign({}, defaults, opts)
    , precision = pow(settings.precision)
    , v = parse(value, settings);

  that.intValue = v;
  that.value = v / precision;

  // Set default incremental value
  settings.increment = settings.increment || (1 / precision);

  // Support vedic numbering systems
  // see: https://en.wikipedia.org/wiki/Indian_numbering_system
  if(settings.useVedic) {
    settings.groups = vedicRegex;
  } else {
    settings.groups = groupRegex;
  }

  // Intended for internal usage only - subject to change
  this._settings = settings;
  this._precision = precision;
}