Improvements for #616 and others.

This commit is contained in:
James Cole
2017-08-23 21:21:42 +02:00
parent 1a89e379a4
commit 394e92d538
19 changed files with 383 additions and 55 deletions

View File

@@ -46,6 +46,7 @@ class AmountFormat extends Twig_Extension
{
return [
$this->formatAmountByAccount(),
$this->formatAmountBySymbol(),
$this->transactionAmount(),
$this->journalAmount(),
$this->formatDestinationAfter(),
@@ -108,6 +109,26 @@ class AmountFormat extends Twig_Extension
);
}
/**
* Will format the amount by the currency related to the given account.
*
* @return Twig_SimpleFunction
*/
protected function formatAmountBySymbol(): Twig_SimpleFunction
{
return new Twig_SimpleFunction(
'formatAmountBySymbol', function (string $amount, string $symbol, int $decimalPlaces = 2, bool $coloured = true): string {
$currency = new TransactionCurrency;
$currency->symbol = $symbol;
$currency->decimal_places = $decimalPlaces;
return app('amount')->formatAnything($currency, $amount, $coloured);
}, ['is_safe' => ['html']]
);
}
/**
* Will format the amount by the currency related to the given account.
*