From 58a03d04981a72fcdd42bc16418a950f4bc9e04e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=BCneyt=20=C5=9Eent=C3=BCrk?= Date: Fri, 5 Aug 2022 09:56:18 +0300 Subject: [PATCH] summary amount format change for Humans.. --- .../View/Components/Contacts/Index.php | 7 ++++--- .../View/Components/Documents/Index.php | 10 ++++++---- .../Controllers/Banking/Reconciliations.php | 12 +++++++++++- app/Http/Controllers/Banking/Transactions.php | 15 ++++++++++++++- app/View/Components/Contacts/Show/Content.php | 17 +++++++++++++++-- .../views/banking/accounts/show.blade.php | 18 +++++++++++++++--- .../banking/reconciliations/index.blade.php | 6 ++++-- .../views/banking/transactions/index.blade.php | 9 ++++++--- .../components/contacts/show/content.blade.php | 18 +++++++++++++++--- .../views/components/index/summary.blade.php | 2 +- .../components/show/summary/right.blade.php | 2 +- 11 files changed, 92 insertions(+), 24 deletions(-) diff --git a/app/Abstracts/View/Components/Contacts/Index.php b/app/Abstracts/View/Components/Contacts/Index.php index a5e591a02..a29b02a00 100644 --- a/app/Abstracts/View/Components/Contacts/Index.php +++ b/app/Abstracts/View/Components/Contacts/Index.php @@ -281,9 +281,10 @@ abstract class Index extends Component foreach ($totals as $key => $total) { $items[] = [ - 'title' => ($key == 'overdue') ? trans('general.overdue') : trans('documents.statuses.' . $key), - 'href' => route($route, ['search' => 'status:' . $key]), - 'amount' => money($total, setting('default.currency'), true), + 'title' => ($key == 'overdue') ? trans('general.overdue') : trans('documents.statuses.' . $key), + 'href' => route($route, ['search' => 'status:' . $key]), + 'amount' => money($total, setting('default.currency'), true)->formatForHumans(), + 'tooltip' => money($total, setting('default.currency'), true)->format(), ]; } diff --git a/app/Abstracts/View/Components/Documents/Index.php b/app/Abstracts/View/Components/Documents/Index.php index 2fd3cda5d..0fc38f681 100644 --- a/app/Abstracts/View/Components/Documents/Index.php +++ b/app/Abstracts/View/Components/Documents/Index.php @@ -392,12 +392,14 @@ abstract class Index extends Component foreach ($totals as $key => $total) { $title = ($key == 'overdue') ? trans('general.overdue') : trans('documents.statuses.' . $key); $href = route($route, ['search' => 'status:' . $key]); - $amount = money($total, setting('default.currency'), true); + $amount = money($total, setting('default.currency'), true)->formatForHumans(); + $tooltip = money($total, setting('default.currency'), true)->format(); $items[] = [ - 'title' => $title, - 'href' => $href, - 'amount' => $amount, + 'title' => $title, + 'href' => $href, + 'amount' => $amount, + 'tooltip' => $tooltip, ]; } diff --git a/app/Http/Controllers/Banking/Reconciliations.php b/app/Http/Controllers/Banking/Reconciliations.php index 28fd8f03a..80467a7fc 100644 --- a/app/Http/Controllers/Banking/Reconciliations.php +++ b/app/Http/Controllers/Banking/Reconciliations.php @@ -24,7 +24,17 @@ class Reconciliations extends Controller { $reconciliations = Reconciliation::with('account')->collect(); - return $this->response('banking.reconciliations.index', compact('reconciliations')); + $reconciled_amount = money($reconciliations->where('reconciled', 1)->sum('closing_balance'), setting('default.currency'), true); + $in_progress_amount = money($reconciliations->where('reconciled', 0)->sum('closing_balance'), setting('default.currency'), true); + + $summary_amounts = [ + 'amount_exact' => $reconciled_amount->format(), + 'amount_for_humans' => $reconciled_amount->formatForHumans(), + 'in_progress_exact' => $in_progress_amount->format(), + 'in_progress_for_humans' => $in_progress_amount->formatForHumans(), + ]; + + return $this->response('banking.reconciliations.index', compact('reconciliations', 'summary_amounts')); } /** diff --git a/app/Http/Controllers/Banking/Transactions.php b/app/Http/Controllers/Banking/Transactions.php index b8101a397..56c317bae 100644 --- a/app/Http/Controllers/Banking/Transactions.php +++ b/app/Http/Controllers/Banking/Transactions.php @@ -56,12 +56,25 @@ class Transactions extends Controller $totals['profit'] = $totals['income'] - $totals['expense']; + $incoming_amount = money($totals['income'], setting('default.currency'), true); + $expense_amount = money($totals['expense'], setting('default.currency'), true); + $profit_amount = money($totals['profit'], setting('default.currency'), true); + + $summary_amounts = [ + 'incoming_exact' => $incoming_amount->format(), + 'incoming_for_humans' => $incoming_amount->formatForHumans(), + 'expense_exact' => $expense_amount->format(), + 'expense_for_humans' => $expense_amount->formatForHumans(), + 'profit_exact' => $profit_amount->format(), + 'profit_for_humans' => $profit_amount->formatForHumans(), + ]; + $translations = $this->getTranslationsForConnect('income'); return $this->response('banking.transactions.index', compact( 'transactions', 'translations', - 'totals' + 'summary_amounts' )); } diff --git a/app/View/Components/Contacts/Show/Content.php b/app/View/Components/Contacts/Show/Content.php index 03d278578..d5dca21f3 100644 --- a/app/View/Components/Contacts/Show/Content.php +++ b/app/View/Components/Contacts/Show/Content.php @@ -12,7 +12,7 @@ class Content extends Component { public $counts; - public $totals; + public $summary_amounts; public $transactions; @@ -72,7 +72,20 @@ class Content extends Component $totals['paid'] += $item->getAmountConvertedToDefault(); }); - $this->totals = $totals; + $open_amount = money($totals['open'], setting('default.currency'), true); + $overdue_amount = money($totals['overdue'], setting('default.currency'), true); + $paid_amount = money($totals['paid'], setting('default.currency'), true); + + $summary_amounts = [ + 'open_exact' => $open_amount->format(), + 'open_for_humans' => $open_amount->formatForHumans(), + 'overdue_exact' => $overdue_amount->format(), + 'overdue_for_humans' => $overdue_amount->formatForHumans(), + 'paid_exact' => $paid_amount->format(), + 'paid_for_humans' => $paid_amount->formatForHumans(), + ]; + + $this->summary_amounts = $summary_amounts; $this->transactions = $this->paginate($this->transactions->sortByDesc('paid_at')); $this->documents = $this->paginate($this->documents->sortByDesc('issued_at')); diff --git a/resources/views/banking/accounts/show.blade.php b/resources/views/banking/accounts/show.blade.php index c15287aaa..4b7c04956 100644 --- a/resources/views/banking/accounts/show.blade.php +++ b/resources/views/banking/accounts/show.blade.php @@ -116,15 +116,27 @@ @stack('summary_incoming_start') - + @stack('summary_incoming_end') @stack('summary_outgoing_start') - + @stack('summary_outgoing_end') @stack('summary_current_start') - + @stack('summary_current_end') diff --git a/resources/views/banking/reconciliations/index.blade.php b/resources/views/banking/reconciliations/index.blade.php index 78810f779..4be72dfff 100644 --- a/resources/views/banking/reconciliations/index.blade.php +++ b/resources/views/banking/reconciliations/index.blade.php @@ -20,14 +20,16 @@ diff --git a/resources/views/banking/transactions/index.blade.php b/resources/views/banking/transactions/index.blade.php index af3e802be..63b8d9fb6 100644 --- a/resources/views/banking/transactions/index.blade.php +++ b/resources/views/banking/transactions/index.blade.php @@ -44,21 +44,24 @@ diff --git a/resources/views/components/contacts/show/content.blade.php b/resources/views/components/contacts/show/content.blade.php index a1b2ab407..e9190897a 100644 --- a/resources/views/components/contacts/show/content.blade.php +++ b/resources/views/components/contacts/show/content.blade.php @@ -30,19 +30,31 @@ @stack('summary_overdue_start') @if (! $hideOverdue) - + @endif @stack('summary_overdue_end') @stack('summary_open_start') @if (! $hideOpen) - + @endif @stack('summary_open_end') @stack('summary_paid_start') @if (! $hidePaid) - + @endif @stack('summary_paid_end') diff --git a/resources/views/components/index/summary.blade.php b/resources/views/components/index/summary.blade.php index 67d38408f..35e53f31e 100644 --- a/resources/views/components/index/summary.blade.php +++ b/resources/views/components/index/summary.blade.php @@ -5,7 +5,7 @@ @foreach ($items as $item)
@if (! empty($item['tooltip'])) - + @php $text_color = (! empty($item['text_color'])) ? $item['text_color'] : 'text-purple group-hover:text-purple-700'; @endphp
diff --git a/resources/views/components/show/summary/right.blade.php b/resources/views/components/show/summary/right.blade.php index 4f64facf3..3c7b975ca 100644 --- a/resources/views/components/show/summary/right.blade.php +++ b/resources/views/components/show/summary/right.blade.php @@ -5,7 +5,7 @@ @foreach ($items as $item)