Update amount thing, simpler code (I hope). Includes config for negative values.

This commit is contained in:
James Cole
2017-01-08 17:54:52 +01:00
parent 8208d44466
commit 19990f49b0
2 changed files with 95 additions and 25 deletions

View File

@@ -111,34 +111,10 @@ class Range
$dateTimeFormat = (string)trans('config.date_time');
$defaultCurrency = Amount::getDefaultCurrency();
$localeconv = localeconv();
$accounting = Amount::getJsConfig($localeconv);
// decimal places is overruled by TransactionCurrency
$localeconv['frac_digits'] = $defaultCurrency->decimal_places;
$positiveSpace = ' ';
$negativeSpace = ' ';
// positive number:
if (!$localeconv['p_sep_by_space']) {
$positiveSpace = '';
}
// negative number:
if (!$localeconv['n_sep_by_space']) {
$negativeSpace = '';
}
// by default, put symbols before:
$accounting = [
'pos' => '%s' . $positiveSpace . '%v',
'neg' => '%s' . $negativeSpace . '-%v',
'zero' => '%s' . $positiveSpace . '%v',
];
// but might be after:
if (!$localeconv['n_cs_precedes']) {
$accounting['neg'] = '-%v' . $negativeSpace . '%s';
}
if (!$localeconv['p_cs_precedes']) {
$accounting['pos'] = '%v' . $negativeSpace . '%s';
$accounting['zero'] = '%v' . $negativeSpace . '%s';
}
View::share('monthFormat', $monthFormat);
View::share('monthAndDayFormat', $monthAndDayFormat);