From bfb37c62c6ae320fb4ba5635f6a552fb17379fde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denis=20Duli=C3=A7i?= Date: Tue, 11 Jul 2023 12:03:14 +0300 Subject: [PATCH] applied new features of `money` package --- .../View/Components/Contacts/Index.php | 4 ++-- .../View/Components/Documents/Index.php | 4 ++-- app/Http/Controllers/Banking/Accounts.php | 6 ++--- .../Controllers/Banking/Reconciliations.php | 10 ++++---- app/Http/Controllers/Banking/Transactions.php | 6 ++--- .../Modals/DocumentTransactions.php | 6 ++--- app/Http/Middleware/Money.php | 2 +- app/Http/Resources/Banking/Account.php | 4 ++-- app/Http/Resources/Banking/Reconciliation.php | 2 +- app/Http/Resources/Banking/Transaction.php | 2 +- app/Http/Resources/Banking/Transfer.php | 2 +- app/Http/Resources/Common/Item.php | 4 ++-- app/Http/Resources/Document/Document.php | 2 +- app/Http/Resources/Document/DocumentItem.php | 4 ++-- .../Resources/Document/DocumentItemTax.php | 2 +- app/Http/Resources/Document/DocumentTotal.php | 2 +- .../CreateBankingDocumentTransaction.php | 4 ++-- .../MatchBankingDocumentTransaction.php | 4 ++-- app/Jobs/Banking/SplitTransaction.php | 2 +- .../UpdateBankingDocumentTransaction.php | 4 ++-- app/Notifications/Banking/Transaction.php | 2 +- app/Notifications/Portal/PaymentReceived.php | 4 ++-- app/Notifications/Purchase/Bill.php | 4 ++-- app/Notifications/Sale/Invoice.php | 4 ++-- app/Observers/Transaction.php | 2 +- app/Traits/Charts.php | 2 +- app/Utilities/Overrider.php | 3 +++ app/View/Components/Contacts/Show/Content.php | 6 ++--- .../Components/Documents/Show/GetPaid.php | 2 +- .../Components/Documents/Show/MakePayment.php | 2 +- app/Widgets/AccountBalance.php | 2 +- app/Widgets/CashFlow.php | 6 ++--- app/Widgets/Payables.php | 8 +++---- app/Widgets/Receivables.php | 8 +++---- composer.lock | 24 +++++++++---------- config/money.php | 4 +++- .../views/banking/accounts/show.blade.php | 2 +- .../views/banking/transfers/index.blade.php | 2 +- .../documents/show/get-paid.blade.php | 4 ++-- .../documents/show/make-payment.blade.php | 4 ++-- .../reports/detail/table/footer.blade.php | 4 ++-- .../reports/detail/table/row.blade.php | 12 +++++----- .../reports/summary/table/body.blade.php | 4 ++-- .../reports/summary/table/row.blade.php | 6 ++--- .../widgets/payment_history.blade.php | 4 ++-- .../views/portal/invoices/preview.blade.php | 2 +- .../views/portal/invoices/show.blade.php | 2 +- .../views/portal/invoices/signed.blade.php | 2 +- .../views/portal/payments/preview.blade.php | 2 +- .../views/portal/payments/show.blade.php | 2 +- .../views/portal/payments/signed.blade.php | 4 ++-- 51 files changed, 110 insertions(+), 105 deletions(-) diff --git a/app/Abstracts/View/Components/Contacts/Index.php b/app/Abstracts/View/Components/Contacts/Index.php index 9f3b4e9e2..9d223bf0d 100644 --- a/app/Abstracts/View/Components/Contacts/Index.php +++ b/app/Abstracts/View/Components/Contacts/Index.php @@ -283,8 +283,8 @@ abstract class Index extends Component $items[] = [ 'title' => ($key == 'overdue') ? trans('general.overdue') : trans('documents.statuses.' . $key), //'href' => route($route, ['search' => 'status:' . $key]), - 'amount' => money($total, default_currency(), true)->formatForHumans(), - 'tooltip' => money($total, default_currency(), true)->format(), + 'amount' => money($total)->formatForHumans(), + 'tooltip' => money($total)->format(), ]; } diff --git a/app/Abstracts/View/Components/Documents/Index.php b/app/Abstracts/View/Components/Documents/Index.php index 7671ca2f5..887043449 100644 --- a/app/Abstracts/View/Components/Documents/Index.php +++ b/app/Abstracts/View/Components/Documents/Index.php @@ -392,8 +392,8 @@ 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, default_currency(), true)->formatForHumans(); - $tooltip = money($total, default_currency(), true)->format(); + $amount = money($total)->formatForHumans(); + $tooltip = money($total)->format(); $items[] = [ 'title' => $title, diff --git a/app/Http/Controllers/Banking/Accounts.php b/app/Http/Controllers/Banking/Accounts.php index a8bcfcc5f..622e0bd06 100644 --- a/app/Http/Controllers/Banking/Accounts.php +++ b/app/Http/Controllers/Banking/Accounts.php @@ -42,9 +42,9 @@ class Accounts extends Controller ->orWhereHas('income_transaction', fn ($query) => $query->where('account_id', $account->id)) ->collect(['expense_transaction.paid_at' => 'desc']); - $incoming_amount = money($account->income_balance, $account->currency_code, true); - $outgoing_amount = money($account->expense_balance, $account->currency_code, true); - $current_amount = money($account->balance, $account->currency_code, true); + $incoming_amount = money($account->income_balance, $account->currency_code); + $outgoing_amount = money($account->expense_balance, $account->currency_code); + $current_amount = money($account->balance, $account->currency_code); $summary_amounts = [ 'incoming_exact' => $incoming_amount->format(), diff --git a/app/Http/Controllers/Banking/Reconciliations.php b/app/Http/Controllers/Banking/Reconciliations.php index 1bef98173..e3dab8708 100644 --- a/app/Http/Controllers/Banking/Reconciliations.php +++ b/app/Http/Controllers/Banking/Reconciliations.php @@ -24,8 +24,8 @@ class Reconciliations extends Controller { $reconciliations = Reconciliation::with('account')->collect(); - $reconciled_amount = money($reconciliations->where('reconciled', 1)->sum('closing_balance'), default_currency(), true); - $in_progress_amount = money($reconciliations->where('reconciled', 0)->sum('closing_balance'), default_currency(), true); + $reconciled_amount = money($reconciliations->where('reconciled', 1)->sum('closing_balance')); + $in_progress_amount = money($reconciliations->where('reconciled', 0)->sum('closing_balance')); $summary_amounts = [ 'amount_exact' => $reconciled_amount->format(), @@ -246,9 +246,9 @@ class Reconciliations extends Controller $difference = $closing_balance - $cleared_amount; - $json->closing_balance = money($closing_balance, $currency_code, true)->format(); - $json->cleared_amount = money($cleared_amount, $currency_code, true)->format(); - $json->difference = money($difference, $currency_code, true)->format(); + $json->closing_balance = money($closing_balance, $currency_code)->format(); + $json->cleared_amount = money($cleared_amount, $currency_code)->format(); + $json->difference = money($difference, $currency_code)->format(); $json->difference_raw = (int) $difference; return response()->json($json); diff --git a/app/Http/Controllers/Banking/Transactions.php b/app/Http/Controllers/Banking/Transactions.php index b3c2a2caa..15680841c 100644 --- a/app/Http/Controllers/Banking/Transactions.php +++ b/app/Http/Controllers/Banking/Transactions.php @@ -56,9 +56,9 @@ class Transactions extends Controller $totals['profit'] = $totals['income'] - $totals['expense']; - $incoming_amount = money($totals['income'], default_currency(), true); - $expense_amount = money($totals['expense'], default_currency(), true); - $profit_amount = money($totals['profit'], default_currency(), true); + $incoming_amount = money($totals['income']); + $expense_amount = money($totals['expense']); + $profit_amount = money($totals['profit']); $summary_amounts = [ 'incoming_exact' => $incoming_amount->format(), diff --git a/app/Http/Controllers/Modals/DocumentTransactions.php b/app/Http/Controllers/Modals/DocumentTransactions.php index 2e1654535..6dfc29b6e 100644 --- a/app/Http/Controllers/Modals/DocumentTransactions.php +++ b/app/Http/Controllers/Modals/DocumentTransactions.php @@ -51,9 +51,9 @@ class DocumentTransactions extends Controller $document->{$document_total->code} = $document_total->amount; } - $total = money($document->total, $currency->code, true)->format(); + $total = money($document->total, $currency->code)->format(); - $document->grand_total = money($total, $currency->code)->getAmount(); + $document->grand_total = money($total, $currency->code, false)->getAmount(); if (! empty($paid)) { $document->grand_total = round($document->total - $paid, $currency->precision); @@ -140,7 +140,7 @@ class DocumentTransactions extends Controller $number = $transaction->number; - $document->grand_total = money($transaction->amount, $currency->code)->getAmount(); + $document->grand_total = money($transaction->amount, $currency->code, false)->getAmount(); $document->paid_at = $transaction->paid_at; diff --git a/app/Http/Middleware/Money.php b/app/Http/Middleware/Money.php index 668b2e612..6b15204c8 100644 --- a/app/Http/Middleware/Money.php +++ b/app/Http/Middleware/Money.php @@ -105,7 +105,7 @@ class Money $money_format = Str::replaceFirst('.', config('money.currencies.' . $currency_code . '.decimal_mark'), $money_format); } - $amount = money($money_format, $currency_code)->getAmount(); + $amount = money($money_format, $currency_code, false)->getAmount(); } catch (InvalidArgumentException | OutOfBoundsException | UnexpectedValueException $e) { report($e); diff --git a/app/Http/Resources/Banking/Account.php b/app/Http/Resources/Banking/Account.php index 2ca0b75c7..942ae4a06 100644 --- a/app/Http/Resources/Banking/Account.php +++ b/app/Http/Resources/Banking/Account.php @@ -22,9 +22,9 @@ class Account extends JsonResource 'number' => $this->number, 'currency_code' => $this->currency_code, 'opening_balance' => $this->opening_balance, - 'opening_balance_formatted' => money($this->opening_balance, $this->currency_code, true)->format(), + 'opening_balance_formatted' => money($this->opening_balance, $this->currency_code)->format(), 'current_balance' => $this->balance, - 'current_balance_formatted' => money($this->balance, $this->currency_code, true)->format(), + 'current_balance_formatted' => money($this->balance, $this->currency_code)->format(), 'bank_name' => $this->bank_name, 'bank_phone' => $this->bank_phone, 'bank_address' => $this->bank_address, diff --git a/app/Http/Resources/Banking/Reconciliation.php b/app/Http/Resources/Banking/Reconciliation.php index 7ab6889ba..bc0d08c2f 100644 --- a/app/Http/Resources/Banking/Reconciliation.php +++ b/app/Http/Resources/Banking/Reconciliation.php @@ -22,7 +22,7 @@ class Reconciliation extends JsonResource 'started_at' => $this->started_at->toIso8601String(), 'ended_at' => $this->ended_at->toIso8601String(), 'closing_balance' => $this->closing_balance, - 'closing_balance_formatted' => money($this->closing_balance, default_currency(), true)->format(), + 'closing_balance_formatted' => money($this->closing_balance)->format(), 'reconciled' => $this->reconciled, 'created_from' => $this->created_from, 'created_by' => $this->created_by, diff --git a/app/Http/Resources/Banking/Transaction.php b/app/Http/Resources/Banking/Transaction.php index 4789757b2..dec77f211 100644 --- a/app/Http/Resources/Banking/Transaction.php +++ b/app/Http/Resources/Banking/Transaction.php @@ -25,7 +25,7 @@ class Transaction extends JsonResource 'account_id' => $this->account_id, 'paid_at' => $this->paid_at->toIso8601String(), 'amount' => $this->amount, - 'amount_formatted' => money($this->amount, $this->currency_code, true)->format(), + 'amount_formatted' => money($this->amount, $this->currency_code)->format(), 'currency_code' => $this->currency_code, 'currency_rate' => $this->currency_rate, 'document_id' => $this->document_id, diff --git a/app/Http/Resources/Banking/Transfer.php b/app/Http/Resources/Banking/Transfer.php index 72d477d1c..c8625186d 100644 --- a/app/Http/Resources/Banking/Transfer.php +++ b/app/Http/Resources/Banking/Transfer.php @@ -25,7 +25,7 @@ class Transfer extends JsonResource 'to_account' => $income_transaction->account->name, 'to_account_id' => $income_transaction->account->id, 'amount' => $expense_transaction->amount, - 'amount_formatted' => money($expense_transaction->amount, $expense_transaction->currency_code, true)->format(), + 'amount_formatted' => money($expense_transaction->amount, $expense_transaction->currency_code)->format(), 'currency_code' => $expense_transaction->currency_code, 'paid_at' => $expense_transaction->paid_at ? $expense_transaction->paid_at->toIso8601String() : '', 'created_from' => $this->created_from, diff --git a/app/Http/Resources/Common/Item.php b/app/Http/Resources/Common/Item.php index 2c249a0ce..ce8cf7ced 100644 --- a/app/Http/Resources/Common/Item.php +++ b/app/Http/Resources/Common/Item.php @@ -23,9 +23,9 @@ class Item extends JsonResource 'name' => $this->name, 'description' => $this->description, 'sale_price' => $this->sale_price, - 'sale_price_formatted' => money((double) $this->sale_price, default_currency(), true)->format(), + 'sale_price_formatted' => money((double) $this->sale_price)->format(), 'purchase_price' => $this->purchase_price, - 'purchase_price_formatted' => money((double) $this->purchase_price, default_currency(), true)->format(), + 'purchase_price_formatted' => money((double) $this->purchase_price)->format(), 'category_id' => $this->category_id, 'picture' => $this->picture, 'enabled' => $this->enabled, diff --git a/app/Http/Resources/Document/Document.php b/app/Http/Resources/Document/Document.php index 96aaaf350..6100bcdf1 100644 --- a/app/Http/Resources/Document/Document.php +++ b/app/Http/Resources/Document/Document.php @@ -32,7 +32,7 @@ class Document extends JsonResource 'issued_at' => $this->issued_at ? $this->issued_at->toIso8601String() : '', 'due_at' => $this->due_at ? $this->due_at->toIso8601String() : '', 'amount' => $this->amount, - 'amount_formatted' => money($this->amount, $this->currency_code, true)->format(), + 'amount_formatted' => money($this->amount, $this->currency_code)->format(), 'category_id' => $this->category_id, 'currency_code' => $this->currency_code, 'currency_rate' => $this->currency_rate, diff --git a/app/Http/Resources/Document/DocumentItem.php b/app/Http/Resources/Document/DocumentItem.php index c74464459..dd365fe1e 100644 --- a/app/Http/Resources/Document/DocumentItem.php +++ b/app/Http/Resources/Document/DocumentItem.php @@ -24,9 +24,9 @@ class DocumentItem extends JsonResource 'name' => $this->name, 'description' => $this->description, 'price' => $this->price, - 'price_formatted' => money($this->price, $this->document->currency_code, true)->format(), + 'price_formatted' => money($this->price, $this->document->currency_code)->format(), 'total' => $this->total, - 'total_formatted' => money($this->total, $this->document->currency_code, true)->format(), + 'total_formatted' => money($this->total, $this->document->currency_code)->format(), 'created_from' => $this->created_from, 'created_by' => $this->created_by, 'created_at' => $this->created_at ? $this->created_at->toIso8601String() : '', diff --git a/app/Http/Resources/Document/DocumentItemTax.php b/app/Http/Resources/Document/DocumentItemTax.php index b0bc5e0e2..0a74f9a99 100644 --- a/app/Http/Resources/Document/DocumentItemTax.php +++ b/app/Http/Resources/Document/DocumentItemTax.php @@ -24,7 +24,7 @@ class DocumentItemTax extends JsonResource 'tax_id' => $this->tax_id, 'name' => $this->name, 'amount' => $this->amount, - 'amount_formatted' => money($this->amount, $this->document->currency_code, true)->format(), + 'amount_formatted' => money($this->amount, $this->document->currency_code)->format(), 'created_from' => $this->created_from, 'created_by' => $this->created_by, 'created_at' => $this->created_at ? $this->created_at->toIso8601String() : '', diff --git a/app/Http/Resources/Document/DocumentTotal.php b/app/Http/Resources/Document/DocumentTotal.php index 4992e62f1..6c770bc1a 100644 --- a/app/Http/Resources/Document/DocumentTotal.php +++ b/app/Http/Resources/Document/DocumentTotal.php @@ -22,7 +22,7 @@ class DocumentTotal extends JsonResource 'code' => $this->code, 'name' => $this->name, 'amount' => $this->amount, - 'amount_formatted' => money($this->amount, $this->document->currency_code, true)->format(), + 'amount_formatted' => money($this->amount, $this->document->currency_code)->format(), 'sort_order' => $this->sort_order, 'created_from' => $this->created_from, 'created_by' => $this->created_by, diff --git a/app/Jobs/Banking/CreateBankingDocumentTransaction.php b/app/Jobs/Banking/CreateBankingDocumentTransaction.php index aa6806b56..e59298a69 100644 --- a/app/Jobs/Banking/CreateBankingDocumentTransaction.php +++ b/app/Jobs/Banking/CreateBankingDocumentTransaction.php @@ -112,7 +112,7 @@ class CreateBankingDocumentTransaction extends Job implements ShouldCreate $error_amount = round($converted_amount, $precision); } - $message = trans('messages.error.over_payment', ['amount' => money($error_amount, $code, true)]); + $message = trans('messages.error.over_payment', ['amount' => money($error_amount, $code)]); throw new \Exception($message); } else { @@ -124,7 +124,7 @@ class CreateBankingDocumentTransaction extends Job implements ShouldCreate protected function createHistory(): void { - $history_desc = money((double) $this->transaction->amount, (string) $this->transaction->currency_code, true)->format() . ' ' . trans_choice('general.payments', 1); + $history_desc = money((double) $this->transaction->amount, (string) $this->transaction->currency_code)->format() . ' ' . trans_choice('general.payments', 1); $this->dispatch(new CreateDocumentHistory($this->model, 0, $history_desc)); } diff --git a/app/Jobs/Banking/MatchBankingDocumentTransaction.php b/app/Jobs/Banking/MatchBankingDocumentTransaction.php index 49f6ebebb..2032f7ea6 100644 --- a/app/Jobs/Banking/MatchBankingDocumentTransaction.php +++ b/app/Jobs/Banking/MatchBankingDocumentTransaction.php @@ -71,7 +71,7 @@ class MatchBankingDocumentTransaction extends Job $error_amount = round($converted_amount, $precision); } - $message = trans('messages.error.over_match', ['type' => ucfirst($this->model->type), 'amount' => money($error_amount, $code, true)]); + $message = trans('messages.error.over_match', ['type' => ucfirst($this->model->type), 'amount' => money($error_amount, $code)]); throw new \Exception($message); } else { @@ -83,7 +83,7 @@ class MatchBankingDocumentTransaction extends Job protected function createHistory(): void { - $history_desc = money((double) $this->transaction->amount, (string) $this->transaction->currency_code, true)->format() . ' ' . trans_choice('general.payments', 1); + $history_desc = money((double) $this->transaction->amount, (string) $this->transaction->currency_code)->format() . ' ' . trans_choice('general.payments', 1); $this->dispatch(new CreateDocumentHistory($this->model, 0, $history_desc)); } diff --git a/app/Jobs/Banking/SplitTransaction.php b/app/Jobs/Banking/SplitTransaction.php index d3eed4432..694335894 100644 --- a/app/Jobs/Banking/SplitTransaction.php +++ b/app/Jobs/Banking/SplitTransaction.php @@ -65,7 +65,7 @@ class SplitTransaction extends Job implements ShouldUpdate $message = trans('messages.error.same_amount', [ 'transaction' => ucfirst(trans_choice('general.' . Str::plural($this->model->type), 1)), - 'amount' => money($error_amount, $this->model->currency_code, true) + 'amount' => money($error_amount, $this->model->currency_code) ]); throw new \Exception($message); diff --git a/app/Jobs/Banking/UpdateBankingDocumentTransaction.php b/app/Jobs/Banking/UpdateBankingDocumentTransaction.php index 2299c57e2..4f34fe468 100644 --- a/app/Jobs/Banking/UpdateBankingDocumentTransaction.php +++ b/app/Jobs/Banking/UpdateBankingDocumentTransaction.php @@ -112,7 +112,7 @@ class UpdateBankingDocumentTransaction extends Job implements ShouldUpdate $error_amount = round($converted_amount, $precision); } - $message = trans('messages.error.over_payment', ['amount' => money($error_amount, $code, true)]); + $message = trans('messages.error.over_payment', ['amount' => money($error_amount, $code)]); throw new \Exception($message); } else { @@ -124,7 +124,7 @@ class UpdateBankingDocumentTransaction extends Job implements ShouldUpdate protected function createHistory(): void { - $history_desc = money((double) $this->transaction->amount, (string) $this->transaction->currency_code, true)->format() . ' ' . trans_choice('general.payments', 1); + $history_desc = money((double) $this->transaction->amount, (string) $this->transaction->currency_code)->format() . ' ' . trans_choice('general.payments', 1); $this->dispatch(new CreateDocumentHistory($this->model, 0, $history_desc)); } diff --git a/app/Notifications/Banking/Transaction.php b/app/Notifications/Banking/Transaction.php index d3f77c6cf..d4df72404 100644 --- a/app/Notifications/Banking/Transaction.php +++ b/app/Notifications/Banking/Transaction.php @@ -118,7 +118,7 @@ class Transaction extends Notification ]; return [ - money($this->transaction->amount, $this->transaction->currency_code, true), + money($this->transaction->amount, $this->transaction->currency_code), company_date($this->transaction->paid_at), URL::signedRoute('signed.payments.show', $route_params), route('transactions.show', $route_params), diff --git a/app/Notifications/Portal/PaymentReceived.php b/app/Notifications/Portal/PaymentReceived.php index 324404c56..4bc0a7dc9 100644 --- a/app/Notifications/Portal/PaymentReceived.php +++ b/app/Notifications/Portal/PaymentReceived.php @@ -129,13 +129,13 @@ class PaymentReceived extends Notification return [ $this->invoice->document_number, - money($this->invoice->amount, $this->invoice->currency_code, true), + money($this->invoice->amount, $this->invoice->currency_code), company_date($this->invoice->due_at), trans('documents.statuses.' . $this->invoice->status), URL::signedRoute('signed.invoices.show', $route_params), route('invoices.show', $route_params), route('portal.invoices.show', $route_params), - money($this->transaction->amount, $this->transaction->currency_code, true), + money($this->transaction->amount, $this->transaction->currency_code), company_date($this->transaction->paid_at), $this->transaction->payment_method, $this->invoice->contact_name, diff --git a/app/Notifications/Purchase/Bill.php b/app/Notifications/Purchase/Bill.php index cd72f9551..4ec44e949 100644 --- a/app/Notifications/Purchase/Bill.php +++ b/app/Notifications/Purchase/Bill.php @@ -97,8 +97,8 @@ class Bill extends Notification return [ $this->bill->document_number, - money($this->bill->amount, $this->bill->currency_code, true), - money($this->bill->amount_due, $this->bill->currency_code, true), + money($this->bill->amount, $this->bill->currency_code), + money($this->bill->amount_due, $this->bill->currency_code), company_date($this->bill->issued_at), company_date($this->bill->due_at), route('bills.show', $route_params), diff --git a/app/Notifications/Sale/Invoice.php b/app/Notifications/Sale/Invoice.php index 8c5ebc97b..9a85fa451 100644 --- a/app/Notifications/Sale/Invoice.php +++ b/app/Notifications/Sale/Invoice.php @@ -142,8 +142,8 @@ class Invoice extends Notification return [ $this->invoice->document_number, - money($this->invoice->amount, $this->invoice->currency_code, true), - money($this->invoice->amount_due, $this->invoice->currency_code, true), + money($this->invoice->amount, $this->invoice->currency_code), + money($this->invoice->amount_due, $this->invoice->currency_code), company_date($this->invoice->issued_at), company_date($this->invoice->due_at), URL::signedRoute('signed.invoices.show', $route_params), diff --git a/app/Observers/Transaction.php b/app/Observers/Transaction.php index 3e051dfe5..7f6e2101c 100644 --- a/app/Observers/Transaction.php +++ b/app/Observers/Transaction.php @@ -60,7 +60,7 @@ class Transaction extends Observer protected function getDescription($transaction) { - $amount = money((double) $transaction->amount, (string) $transaction->currency_code, true)->format(); + $amount = money((double) $transaction->amount, (string) $transaction->currency_code)->format(); return trans('messages.success.deleted', ['type' => $amount . ' ' . trans_choice('general.payments', 1)]); } diff --git a/app/Traits/Charts.php b/app/Traits/Charts.php index 0eaa09f3a..8392d2329 100644 --- a/app/Traits/Charts.php +++ b/app/Traits/Charts.php @@ -28,7 +28,7 @@ trait Charts public function addMoneyToDonutChart($color, $amount, $description = '') { - $label = money($amount, default_currency(), true)->formatForHumans(); + $label = money($amount)->formatForHumans(); if (!empty($description)) { $label .= ' - ' . $description; diff --git a/app/Utilities/Overrider.php b/app/Utilities/Overrider.php index 51422c75a..fb3230291 100644 --- a/app/Utilities/Overrider.php +++ b/app/Utilities/Overrider.php @@ -62,6 +62,9 @@ class Overrider // Set locale for Money package Money::setLocale(app()->getLocale()); + // Money + config(['money.defaults.currency' => setting('default.currency')]); + // Set app url dynamically if empty if (! config('app.url')) { config(['app.url' => url('/')]); diff --git a/app/View/Components/Contacts/Show/Content.php b/app/View/Components/Contacts/Show/Content.php index 60679d25e..46c83f38c 100644 --- a/app/View/Components/Contacts/Show/Content.php +++ b/app/View/Components/Contacts/Show/Content.php @@ -72,9 +72,9 @@ class Content extends Component $totals['paid'] += $item->getAmountConvertedToDefault(); }); - $open_amount = money($totals['open'], default_currency(), true); - $overdue_amount = money($totals['overdue'], default_currency(), true); - $paid_amount = money($totals['paid'], default_currency(), true); + $open_amount = money($totals['open']); + $overdue_amount = money($totals['overdue']); + $paid_amount = money($totals['paid']); $summary_amounts = [ 'open_exact' => $open_amount->format(), diff --git a/app/View/Components/Documents/Show/GetPaid.php b/app/View/Components/Documents/Show/GetPaid.php index f1bf20056..83c9779f9 100644 --- a/app/View/Components/Documents/Show/GetPaid.php +++ b/app/View/Components/Documents/Show/GetPaid.php @@ -15,7 +15,7 @@ class GetPaid extends Component */ public function render() { - $this->description = trans('general.amount_due') . ': ' . '' . money($this->document->amount_due, $this->document->currency_code, true) . ''; + $this->description = trans('general.amount_due') . ': ' . '' . money($this->document->amount_due, $this->document->currency_code) . ''; return view('components.documents.show.get-paid'); } diff --git a/app/View/Components/Documents/Show/MakePayment.php b/app/View/Components/Documents/Show/MakePayment.php index c2406dbd4..db3e413b9 100644 --- a/app/View/Components/Documents/Show/MakePayment.php +++ b/app/View/Components/Documents/Show/MakePayment.php @@ -15,7 +15,7 @@ class MakePayment extends Component */ public function render() { - $this->description = trans('general.amount_due') . ': ' . '' . money($this->document->amount_due, $this->document->currency_code, true) . ''; + $this->description = trans('general.amount_due') . ': ' . '' . money($this->document->amount_due, $this->document->currency_code) . ''; return view('components.documents.show.make-payment'); } diff --git a/app/Widgets/AccountBalance.php b/app/Widgets/AccountBalance.php index fbe315e58..318e019ac 100644 --- a/app/Widgets/AccountBalance.php +++ b/app/Widgets/AccountBalance.php @@ -16,7 +16,7 @@ class AccountBalance extends Widget public function show() { $accounts = Account::with('income_transactions', 'expense_transactions')->enabled()->take(5)->get()->map(function($account) { - $account->balance_formatted = money($account->balance, $account->currency_code, true); + $account->balance_formatted = money($account->balance, $account->currency_code); return $account; })->all(); diff --git a/app/Widgets/CashFlow.php b/app/Widgets/CashFlow.php index f5337528a..42eb5d3bc 100644 --- a/app/Widgets/CashFlow.php +++ b/app/Widgets/CashFlow.php @@ -53,9 +53,9 @@ class CashFlow extends Widget ->setDataset(trans('general.outgoing'), 'column', $expense) ->setDataset(trans_choice('general.profits', 1), 'line', $profit); - $incoming_amount = money(array_sum($income), default_currency(), true); - $outgoing_amount = money(abs(array_sum($expense)), default_currency(), true); - $profit_amount = money(array_sum($profit), default_currency(), true); + $incoming_amount = money(array_sum($income)); + $outgoing_amount = money(abs(array_sum($expense))); + $profit_amount = money(array_sum($profit)); $totals = [ 'incoming_exact' => $incoming_amount->format(), diff --git a/app/Widgets/Payables.php b/app/Widgets/Payables.php index 9ca30f082..cb1ee525d 100644 --- a/app/Widgets/Payables.php +++ b/app/Widgets/Payables.php @@ -52,7 +52,7 @@ class Payables extends Widget }); foreach ($periods as $period_name => $period_amount) { - $periods[$period_name] = money($period_amount, default_currency(), true); + $periods[$period_name] = money($period_amount); } $has_progress = !empty($open) || !empty($overdue); @@ -61,9 +61,9 @@ class Payables extends Widget $grand = $open + $overdue; $totals = [ - 'grand' => money($grand, default_currency(), true), - 'open' => money($open, default_currency(), true), - 'overdue' => money($overdue, default_currency(), true), + 'grand' => money($grand), + 'open' => money($open), + 'overdue' => money($overdue), ]; $grand_total_text = trans('widgets.total_unpaid_bills'); diff --git a/app/Widgets/Receivables.php b/app/Widgets/Receivables.php index 532c012e7..e8195cb36 100644 --- a/app/Widgets/Receivables.php +++ b/app/Widgets/Receivables.php @@ -52,7 +52,7 @@ class Receivables extends Widget }); foreach ($periods as $period_name => $period_amount) { - $periods[$period_name] = money($period_amount, default_currency(), true); + $periods[$period_name] = money($period_amount); } $has_progress = !empty($open) || !empty($overdue); @@ -61,9 +61,9 @@ class Receivables extends Widget $grand = $open + $overdue; $totals = [ - 'grand' => money($grand, default_currency(), true), - 'open' => money($open, default_currency(), true), - 'overdue' => money($overdue, default_currency(), true), + 'grand' => money($grand), + 'open' => money($open), + 'overdue' => money($overdue), ]; $grand_total_text = trans('widgets.total_unpaid_invoices'); diff --git a/composer.lock b/composer.lock index dc93056c9..99ddf2278 100644 --- a/composer.lock +++ b/composer.lock @@ -409,16 +409,16 @@ }, { "name": "akaunting/laravel-money", - "version": "5.0.0", + "version": "5.1.0", "source": { "type": "git", "url": "https://github.com/akaunting/laravel-money.git", - "reference": "104d41aabc144150054d225fec6b2a0ae8b76d1d" + "reference": "dc6dd201aaf1c2b9ced3f98e208ddc6af1f0a722" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/akaunting/laravel-money/zipball/104d41aabc144150054d225fec6b2a0ae8b76d1d", - "reference": "104d41aabc144150054d225fec6b2a0ae8b76d1d", + "url": "https://api.github.com/repos/akaunting/laravel-money/zipball/dc6dd201aaf1c2b9ced3f98e208ddc6af1f0a722", + "reference": "dc6dd201aaf1c2b9ced3f98e208ddc6af1f0a722", "shasum": "" }, "require": { @@ -472,9 +472,9 @@ ], "support": { "issues": "https://github.com/akaunting/laravel-money/issues", - "source": "https://github.com/akaunting/laravel-money/tree/5.0.0" + "source": "https://github.com/akaunting/laravel-money/tree/5.1.0" }, - "time": "2023-07-10T09:34:33+00:00" + "time": "2023-07-11T08:35:47+00:00" }, { "name": "akaunting/laravel-mutable-observer", @@ -7867,16 +7867,16 @@ }, { "name": "php-http/discovery", - "version": "1.19.0", + "version": "1.19.1", "source": { "type": "git", "url": "https://github.com/php-http/discovery.git", - "reference": "1856a119a0b0ba8da8b5c33c080aa7af8fac25b4" + "reference": "57f3de01d32085fea20865f9b16fb0e69347c39e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-http/discovery/zipball/1856a119a0b0ba8da8b5c33c080aa7af8fac25b4", - "reference": "1856a119a0b0ba8da8b5c33c080aa7af8fac25b4", + "url": "https://api.github.com/repos/php-http/discovery/zipball/57f3de01d32085fea20865f9b16fb0e69347c39e", + "reference": "57f3de01d32085fea20865f9b16fb0e69347c39e", "shasum": "" }, "require": { @@ -7939,9 +7939,9 @@ ], "support": { "issues": "https://github.com/php-http/discovery/issues", - "source": "https://github.com/php-http/discovery/tree/1.19.0" + "source": "https://github.com/php-http/discovery/tree/1.19.1" }, - "time": "2023-06-19T08:45:36+00:00" + "time": "2023-07-11T07:02:26+00:00" }, { "name": "php-http/guzzle7-adapter", diff --git a/config/money.php b/config/money.php index 543f6ea9d..90ff5c3a1 100644 --- a/config/money.php +++ b/config/money.php @@ -4,7 +4,9 @@ return [ 'defaults' => [ - 'currency' => env('MONEY_DEFAULTS_CURRENCY', 'USD'), + 'currency' => env('MONEY_DEFAULTS_CURRENCY', 'USD'), + + 'convert' => env('MONEY_DEFAULTS_CONVERT', true), ], diff --git a/resources/views/banking/accounts/show.blade.php b/resources/views/banking/accounts/show.blade.php index ba7c86f6c..59c7377d3 100644 --- a/resources/views/banking/accounts/show.blade.php +++ b/resources/views/banking/accounts/show.blade.php @@ -391,7 +391,7 @@ $item->name = trans('transfers.messages.delete', [ 'from' => $item->expense_transaction->account->name, 'to' => $item->income_transaction->account->name, - 'amount' => money($item->expense_transaction->amount, $item->expense_transaction->currency_code, true) + 'amount' => money($item->expense_transaction->amount, $item->expense_transaction->currency_code) ]); @endphp diff --git a/resources/views/banking/transfers/index.blade.php b/resources/views/banking/transfers/index.blade.php index 88c1dba61..51efa9c73 100644 --- a/resources/views/banking/transfers/index.blade.php +++ b/resources/views/banking/transfers/index.blade.php @@ -94,7 +94,7 @@ $item->name = trans('transfers.messages.delete', [ 'from' => $item->expense_transaction->account->name, 'to' => $item->income_transaction->account->name, - 'amount' => money($item->expense_transaction->amount, $item->expense_transaction->currency_code, true) + 'amount' => money($item->expense_transaction->amount, $item->expense_transaction->currency_code) ]); @endphp diff --git a/resources/views/components/documents/show/get-paid.blade.php b/resources/views/components/documents/show/get-paid.blade.php index 01a720103..1556f5645 100644 --- a/resources/views/components/documents/show/get-paid.blade.php +++ b/resources/views/components/documents/show/get-paid.blade.php @@ -62,7 +62,7 @@ - {!! trans('documents.transaction', [ - 'amount' => '' . money($transaction->amount, $transaction->currency_code, true) . '', + 'amount' => '' . money($transaction->amount, $transaction->currency_code) . '', 'account' => '' . $transaction->account->name . '', ]) !!} @@ -103,7 +103,7 @@ @php $message = trans('general.delete_confirm', [ - 'name' => '' . Date::parse($transaction->paid_at)->format(company_date_format()) . ' - ' . money($transaction->amount, $transaction->currency_code, true) . ' - ' . $transaction->account->name . '', + 'name' => '' . Date::parse($transaction->paid_at)->format(company_date_format()) . ' - ' . money($transaction->amount, $transaction->currency_code) . ' - ' . $transaction->account->name . '', 'type' => strtolower(trans_choice('general.transactions', 1)) ]); @endphp diff --git a/resources/views/components/documents/show/make-payment.blade.php b/resources/views/components/documents/show/make-payment.blade.php index 5b4dd39d5..9f3d29dcf 100644 --- a/resources/views/components/documents/show/make-payment.blade.php +++ b/resources/views/components/documents/show/make-payment.blade.php @@ -45,7 +45,7 @@ - {!! trans('documents.transaction', [ - 'amount' => '' . money($transaction->amount, $transaction->currency_code, true) . '', + 'amount' => '' . money($transaction->amount, $transaction->currency_code) . '', 'account' => '' . $transaction->account->name . '', ]) !!} @@ -86,7 +86,7 @@ @php $message = trans('general.delete_confirm', [ - 'name' => '' . Date::parse($transaction->paid_at)->format(company_date_format()) . ' - ' . money($transaction->amount, $transaction->currency_code, true) . ' - ' . $transaction->account->name . '', + 'name' => '' . Date::parse($transaction->paid_at)->format(company_date_format()) . ' - ' . money($transaction->amount, $transaction->currency_code) . ' - ' . $transaction->account->name . '', 'type' => strtolower(trans_choice('general.transactions', 1)) ]); @endphp diff --git a/resources/views/components/reports/detail/table/footer.blade.php b/resources/views/components/reports/detail/table/footer.blade.php index 5ed8ddd2b..a63604617 100644 --- a/resources/views/components/reports/detail/table/footer.blade.php +++ b/resources/views/components/reports/detail/table/footer.blade.php @@ -4,8 +4,8 @@ {{ trans_choice('general.totals', 1) }} @foreach($class->footer_totals[$table_key] as $total) - {{ $class->has_money ? money($total, default_currency(), true) : $total }} + {{ $class->has_money ? money($total) : $total }} @endforeach - {{ $class->has_money ? money($grand_total, default_currency(), true) : $grand_total }} + {{ $class->has_money ? money($grand_total) : $grand_total }} diff --git a/resources/views/components/reports/detail/table/row.blade.php b/resources/views/components/reports/detail/table/row.blade.php index 56065c29c..f911de415 100644 --- a/resources/views/components/reports/detail/table/row.blade.php +++ b/resources/views/components/reports/detail/table/row.blade.php @@ -14,9 +14,9 @@ @endif @foreach($rows as $row) - {{ $class->has_money ? money($row, default_currency(), true) : $row }} + {{ $class->has_money ? money($row) : $row }} @endforeach - {{ $class->has_money ? money($row_total, default_currency(), true) : $row }} + {{ $class->has_money ? money($row_total) : $row }} @endif @endif @@ -57,9 +57,9 @@ @foreach($parent_row_values as $row) - {{ $class->has_money ? money($row, default_currency(), true) : $row }} + {{ $class->has_money ? money($row) : $row }} @endforeach - {{ $class->has_money ? money($row_total, default_currency(), true) : $row }} + {{ $class->has_money ? money($row_total) : $row }} @endif @@ -69,9 +69,9 @@ {{ $class->row_names[$table_key][$id] }} @foreach($rows as $row) - {{ $class->has_money ? money($row, default_currency(), true) : $row }} + {{ $class->has_money ? money($row) : $row }} @endforeach - {{ $class->has_money ? money($row_total, default_currency(), true) : $row }} + {{ $class->has_money ? money($row_total) : $row }} @endif diff --git a/resources/views/components/reports/summary/table/body.blade.php b/resources/views/components/reports/summary/table/body.blade.php index cee095c6a..25e552ae3 100644 --- a/resources/views/components/reports/summary/table/body.blade.php +++ b/resources/views/components/reports/summary/table/body.blade.php @@ -1,12 +1,12 @@
-
$is_print, 'flex items-center justify-between text-xl text-black-400 border-b pb-2' => !$is_print ]) >

{{ $table_name }}

- {{ $class->has_money ? money($grand_total, default_currency(), true) : $grand_total }} + {{ $class->has_money ? money($grand_total) : $grand_total }}
@if (!empty($class->row_values[$table_key]))
- {{ $class->has_money ? money($row_total, default_currency(), true) : $row_total }} + {{ $class->has_money ? money($row_total) : $row_total }} @endif @@ -73,7 +73,7 @@ @endif @endif - {{ $class->has_money ? money($row_total, default_currency(), true) : $row_total }} + {{ $class->has_money ? money($row_total) : $row_total }} @endif @@ -91,7 +91,7 @@
{{ $class->row_names[$table_key][$id] }}
- {{ $class->has_money ? money($row_total, default_currency(), true) : $row_total }} + {{ $class->has_money ? money($row_total) : $row_total }} @endif diff --git a/resources/views/components/widgets/payment_history.blade.php b/resources/views/components/widgets/payment_history.blade.php index 93d8c1c7a..5a054c520 100644 --- a/resources/views/components/widgets/payment_history.blade.php +++ b/resources/views/components/widgets/payment_history.blade.php @@ -7,9 +7,9 @@ @foreach ($payments as $item) @if (! $item->document) - {{ trans('portal.payment_history.description', ['date' => company_date($item->created_at), 'amount' => money($item->amount, $item->currency_code, true)]) }} + {{ trans('portal.payment_history.description', ['date' => company_date($item->created_at), 'amount' => money($item->amount, $item->currency_code)]) }} @else - {{ trans('portal.payment_history.invoice_description', ['date' => company_date($item->created_at), 'amount' => money($item->amount, $item->currency_code, true), 'invoice_nember' => $item->document->document_number]) }} + {{ trans('portal.payment_history.invoice_description', ['date' => company_date($item->created_at), 'amount' => money($item->amount, $item->currency_code), 'invoice_nember' => $item->document->document_number]) }} @endif @endforeach diff --git a/resources/views/portal/invoices/preview.blade.php b/resources/views/portal/invoices/preview.blade.php index 761c0124d..315b41932 100644 --- a/resources/views/portal/invoices/preview.blade.php +++ b/resources/views/portal/invoices/preview.blade.php @@ -111,7 +111,7 @@ - {!! trans('documents.transaction', [ - 'amount' => '' . money($transaction->amount, $transaction->currency_code, true) . '', + 'amount' => '' . money($transaction->amount, $transaction->currency_code) . '', 'account' => '' . $transaction->account->name . '', ]) !!} diff --git a/resources/views/portal/invoices/show.blade.php b/resources/views/portal/invoices/show.blade.php index 6e50408db..b7bdd5012 100644 --- a/resources/views/portal/invoices/show.blade.php +++ b/resources/views/portal/invoices/show.blade.php @@ -109,7 +109,7 @@ - {!! trans('documents.transaction', [ - 'amount' => '' . money($transaction->amount, $transaction->currency_code, true) . '', + 'amount' => '' . money($transaction->amount, $transaction->currency_code) . '', 'account' => '' . $transaction->account->name . '', ]) !!} diff --git a/resources/views/portal/invoices/signed.blade.php b/resources/views/portal/invoices/signed.blade.php index 9a7c339d0..d9ccd7314 100644 --- a/resources/views/portal/invoices/signed.blade.php +++ b/resources/views/portal/invoices/signed.blade.php @@ -118,7 +118,7 @@ - {!! trans('documents.transaction', [ - 'amount' => '' . money($transaction->amount, $transaction->currency_code, true) . '', + 'amount' => '' . money($transaction->amount, $transaction->currency_code) . '', 'account' => '' . $transaction->account->name . '', ]) !!} diff --git a/resources/views/portal/payments/preview.blade.php b/resources/views/portal/payments/preview.blade.php index 27eb94439..4f8f64ca2 100644 --- a/resources/views/portal/payments/preview.blade.php +++ b/resources/views/portal/payments/preview.blade.php @@ -46,7 +46,7 @@ - {{ trans('portal.payment_detail.description', ['date' => date($payment->paid_at), 'amount' => money($payment->amount, $payment->currency_code, true)]) }} + {{ trans('portal.payment_detail.description', ['date' => date($payment->paid_at), 'amount' => money($payment->amount, $payment->currency_code)]) }} @endif diff --git a/resources/views/portal/payments/show.blade.php b/resources/views/portal/payments/show.blade.php index e99d41985..2f15801e6 100644 --- a/resources/views/portal/payments/show.blade.php +++ b/resources/views/portal/payments/show.blade.php @@ -44,7 +44,7 @@ - {{ trans('portal.payment_detail.description', ['date' => date($payment->paid_at), 'amount' => money($payment->amount, $payment->currency_code, true)]) }} + {{ trans('portal.payment_detail.description', ['date' => date($payment->paid_at), 'amount' => money($payment->amount, $payment->currency_code)]) }} @endif diff --git a/resources/views/portal/payments/signed.blade.php b/resources/views/portal/payments/signed.blade.php index a75ebcc0f..6fd5319ed 100644 --- a/resources/views/portal/payments/signed.blade.php +++ b/resources/views/portal/payments/signed.blade.php @@ -17,7 +17,7 @@ @stack('button_print_end') - + @stack('button_dashboard_start') @if (! user()) @@ -54,7 +54,7 @@ - {{ trans('portal.payment_detail.description', ['date' => date($payment->paid_at), 'amount' => money($payment->amount, $payment->currency_code, true)]) }} + {{ trans('portal.payment_detail.description', ['date' => date($payment->paid_at), 'amount' => money($payment->amount, $payment->currency_code)]) }} @endif