formatForHumans in cash flow widget

This commit is contained in:
Denis Duliçi 2022-08-31 18:16:14 +03:00
parent e3edfcfc83
commit 3f20c1f8c4
2 changed files with 19 additions and 6 deletions

View File

@ -53,10 +53,17 @@ class CashFlow extends Widget
->setDataset(trans('general.outgoing'), 'column', $expense)
->setDataset(trans_choice('general.profits', 1), 'line', $profit);
$incoming_amount = money(array_sum($income), setting('default.currency'), true);
$outgoing_amount = money(abs(array_sum($expense)), setting('default.currency'), true);
$profit_amount = money(array_sum($profit), setting('default.currency'), true);
$totals = [
'incoming' => money(array_sum($income), setting('default.currency'), true),
'outgoing' => money(abs(array_sum($expense)), setting('default.currency'), true),
'profit' => money(array_sum($profit), setting('default.currency'), true),
'incoming_exact' => $incoming_amount->format(),
'incoming_for_humans' => $incoming_amount->formatForHumans(),
'outgoing_exact' => $outgoing_amount->format(),
'outgoing_for_humans' => $outgoing_amount->formatForHumans(),
'profit_exact' => $profit_amount->format(),
'profit_for_humans' => $profit_amount->formatForHumans(),
];
return $this->view('widgets.cash_flow', [

View File

@ -9,7 +9,9 @@
<div class="w-full lg:w-1/12 mt-11 space-y-2">
<div class="flex flex-col items-center justify-between text-center">
<div class="flex justify-end lg:block text-lg">
{{ $totals['incoming'] }}
<x-tooltip id="tooltip-cashflow-incoming" placement="top" message="{{ $totals['incoming_exact'] }}">
{{ $totals['incoming_for_humans'] }}
</x-tooltip>
</div>
<span class="text-green text-xs">
@ -21,7 +23,9 @@
<div class="flex flex-col items-center justify-between">
<div class="flex justify-end lg:block text-lg">
{{ $totals['outgoing'] }}
<x-tooltip id="tooltip-cashflow-outgoing" placement="top" message="{{ $totals['outgoing_exact'] }}">
{{ $totals['outgoing_for_humans'] }}
</x-tooltip>
</div>
<span class="text-rose text-xs">
@ -33,7 +37,9 @@
<div class="flex flex-col items-center justify-between">
<div class="flex justify-end lg:block text-lg">
{{ $totals['profit'] }}
<x-tooltip id="tooltip-cashflow-profit" placement="top" message="{{ $totals['profit_exact'] }}">
{{ $totals['profit_for_humans'] }}
</x-tooltip>
</div>
<span class="text-purple text-xs">{{ trans_choice('general.profits', 1) }}</span>