Refactored accountRepository::getJournals > accountTasker > getJournals

This commit is contained in:
James Cole
2016-10-09 21:36:03 +02:00
parent 5bb8c6a366
commit e94ae126fd
25 changed files with 843 additions and 167 deletions

View File

@@ -119,6 +119,41 @@ class Amount
return $this->formatAnything($currency, strval($transaction->amount), $coloured);
}
/**
* This method will properly format the given number, in color or "black and white",
* as a currency, given two things: the currency required and the currency code.
*
* @param string $code
* @param string $amount
* @param bool $coloured
*
* @return string
*/
public function formatWithCode(string $code, string $amount, bool $coloured = true): string
{
$locale = setlocale(LC_MONETARY, 0);
$float = round($amount, 2);
$formatter = new NumberFormatter($locale, NumberFormatter::CURRENCY);
$result = $formatter->formatCurrency($float, $code);
if ($coloured === true) {
if ($amount > 0) {
return '<span class="text-success" title="' . e($float) . '">' . $result . '</span>';
} else {
if ($amount < 0) {
return '<span class="text-danger" title="' . e($float) . '">' . $result . '</span>';
}
}
return '<span style="color:#999" title="' . e($float) . '">' . $result . '</span>';
}
return $result;
}
/**
* @return Collection
*/