mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-06 04:34:00 +00:00
Small code improv #3578
This commit is contained in:
@@ -137,8 +137,7 @@ class JavascriptController extends Controller
|
|||||||
$currency = $repository->getAccountCurrency($account) ?? $currency;
|
$currency = $repository->getAccountCurrency($account) ?? $currency;
|
||||||
}
|
}
|
||||||
|
|
||||||
$localeconv = app('amount')->getLocaleInfo();
|
$accounting = app('amount')->getJsConfig();
|
||||||
$accounting = app('amount')->getJsConfig($localeconv);
|
|
||||||
$accounting['frac_digits'] = $currency->decimal_places;
|
$accounting['frac_digits'] = $currency->decimal_places;
|
||||||
$pref = app('preferences')->get('language', config('firefly.default_language', 'en_US'));
|
$pref = app('preferences')->get('language', config('firefly.default_language', 'en_US'));
|
||||||
/** @noinspection NullPointerExceptionInspection */
|
/** @noinspection NullPointerExceptionInspection */
|
||||||
|
@@ -115,19 +115,20 @@ class Amount
|
|||||||
* This method returns the correct format rules required by accounting.js,
|
* This method returns the correct format rules required by accounting.js,
|
||||||
* the library used to format amounts in charts.
|
* the library used to format amounts in charts.
|
||||||
*
|
*
|
||||||
* @param array $config
|
* Used only in one place.
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getJsConfig(array $config): array
|
public function getJsConfig(): array
|
||||||
{
|
{
|
||||||
$negative = self::getAmountJsConfig($config['n_sep_by_space'], $config['n_sign_posn'], $config['negative_sign'], $config['n_cs_precedes']);
|
$config = $this->getLocaleInfo();
|
||||||
$positive = self::getAmountJsConfig($config['p_sep_by_space'], $config['p_sign_posn'], $config['positive_sign'], $config['p_cs_precedes']);
|
$negative = self::getAmountJsConfig($config['n_sep_by_space'], $config['n_sign_posn'], $config['negative_sign'], $config['n_cs_precedes']);
|
||||||
|
$positive = self::getAmountJsConfig($config['p_sep_by_space'], $config['p_sign_posn'], $config['positive_sign'], $config['p_cs_precedes']);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'mon_decimal_point' => $config['mon_decimal_point'],
|
'mon_decimal_point' => $config['mon_decimal_point'],
|
||||||
'mon_thousands_sep' => $config['mon_thousands_sep'],
|
'mon_thousands_sep' => $config['mon_thousands_sep'],
|
||||||
'format' => [
|
'format' => [
|
||||||
'pos' => $positive,
|
'pos' => $positive,
|
||||||
'neg' => $negative,
|
'neg' => $negative,
|
||||||
'zero' => $positive,
|
'zero' => $positive,
|
||||||
@@ -138,7 +139,7 @@ class Amount
|
|||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getLocaleInfo(): array
|
private function getLocaleInfo(): array
|
||||||
{
|
{
|
||||||
// get config from preference, not from translation:
|
// get config from preference, not from translation:
|
||||||
$locale = app('steam')->getLocale();
|
$locale = app('steam')->getLocale();
|
||||||
|
Reference in New Issue
Block a user