diff --git a/app/Abstracts/Report.php b/app/Abstracts/Report.php index e45e22a71..811d5f7eb 100644 --- a/app/Abstracts/Report.php +++ b/app/Abstracts/Report.php @@ -171,7 +171,7 @@ abstract class Report $sum += is_array($total) ? array_sum($total) : $total; } - $total = $this->has_money ? money($sum, setting('default.currency'), true)->format() : $sum; + $total = $this->has_money ? money($sum, default_currency(), true)->format() : $sum; } else { $total = trans('general.na'); } diff --git a/app/Abstracts/View/Components/Contacts/Index.php b/app/Abstracts/View/Components/Contacts/Index.php index bc55a201b..9f3b4e9e2 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, setting('default.currency'), true)->formatForHumans(), - 'tooltip' => money($total, setting('default.currency'), true)->format(), + 'amount' => money($total, default_currency(), true)->formatForHumans(), + 'tooltip' => money($total, default_currency(), true)->format(), ]; } diff --git a/app/Abstracts/View/Components/Documents/Form.php b/app/Abstracts/View/Components/Documents/Form.php index 2ffa97220..6158e12d1 100644 --- a/app/Abstracts/View/Components/Documents/Form.php +++ b/app/Abstracts/View/Components/Documents/Form.php @@ -291,7 +291,7 @@ abstract class Form extends Component $this->document = $this->model; $this->currencies = $this->getCurrencies($currencies); $this->currency = $this->getCurrency($document, $currency, $currency_code); - $this->currency_code = ! empty($this->currency) ? $this->currency->code : setting('default.currency'); + $this->currency_code = ! empty($this->currency) ? $this->currency->code : default_currency(); $this->taxes = Tax::enabled()->orderBy('name')->get()->pluck('title', 'id'); /* -- Content Start -- */ @@ -438,7 +438,7 @@ abstract class Form extends Component } if (empty($currency)) { - $currency = Currency::where('code', setting('default.currency'))->first(); + $currency = Currency::where('code', default_currency())->first(); } return $currency; @@ -1139,7 +1139,7 @@ abstract class Form extends Component if (! empty($notes)) { return $notes; } - + if (! empty($this->document)) { return $this->document->notes; } diff --git a/app/Abstracts/View/Components/Documents/Index.php b/app/Abstracts/View/Components/Documents/Index.php index e47840939..4a224c2ef 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, setting('default.currency'), true)->formatForHumans(); - $tooltip = money($total, setting('default.currency'), true)->format(); + $amount = money($total, default_currency(), true)->formatForHumans(); + $tooltip = money($total, default_currency(), true)->format(); $items[] = [ 'title' => $title, diff --git a/app/Http/Controllers/Banking/Accounts.php b/app/Http/Controllers/Banking/Accounts.php index 9ae9aa7d6..02b88d8d1 100644 --- a/app/Http/Controllers/Banking/Accounts.php +++ b/app/Http/Controllers/Banking/Accounts.php @@ -65,7 +65,7 @@ class Accounts extends Controller */ public function create() { - $currency = Currency::where('code', '=', setting('default.currency'))->first(); + $currency = Currency::where('code', '=', default_currency())->first(); return view('banking.accounts.create', compact('currency')); } @@ -279,7 +279,7 @@ class Accounts extends Controller return response()->json([]); } - $currency_code = setting('default.currency'); + $currency_code = default_currency(); if (isset($account->currency_code)) { $currencies = Currency::enabled()->pluck('name', 'code')->toArray(); diff --git a/app/Http/Controllers/Banking/Reconciliations.php b/app/Http/Controllers/Banking/Reconciliations.php index 80467a7fc..1bef98173 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'), setting('default.currency'), true); - $in_progress_amount = money($reconciliations->where('reconciled', 0)->sum('closing_balance'), setting('default.currency'), true); + $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); $summary_amounts = [ 'amount_exact' => $reconciled_amount->format(), diff --git a/app/Http/Controllers/Banking/Transactions.php b/app/Http/Controllers/Banking/Transactions.php index 56c317bae..b74a2fe8a 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'], setting('default.currency'), true); - $expense_amount = money($totals['expense'], setting('default.currency'), true); - $profit_amount = money($totals['profit'], setting('default.currency'), true); + $incoming_amount = money($totals['income'], default_currency(), true); + $expense_amount = money($totals['expense'], default_currency(), true); + $profit_amount = money($totals['profit'], default_currency(), true); $summary_amounts = [ 'incoming_exact' => $incoming_amount->format(), diff --git a/app/Http/Controllers/Banking/Transfers.php b/app/Http/Controllers/Banking/Transfers.php index 897eacdb4..5e2fb2ce2 100644 --- a/app/Http/Controllers/Banking/Transfers.php +++ b/app/Http/Controllers/Banking/Transfers.php @@ -50,7 +50,7 @@ class Transfers extends Controller { $accounts = Account::enabled()->orderBy('name')->get()->pluck('title', 'id'); - $currency = Currency::where('code', setting('default.currency'))->first(); + $currency = Currency::where('code', default_currency())->first(); return view('banking.transfers.create', compact('accounts', 'currency')); } @@ -136,7 +136,7 @@ class Transfers extends Controller { $accounts = Account::enabled()->orderBy('name')->get()->pluck('title', 'id'); - $currency_code = ($transfer->expense_transaction->account) ? $transfer->expense_transaction->account->currency_code : setting('default.currency'); + $currency_code = ($transfer->expense_transaction->account) ? $transfer->expense_transaction->account->currency_code : default_currency(); $currency = Currency::where('code', $currency_code)->first(); diff --git a/app/Http/Controllers/Common/Items.php b/app/Http/Controllers/Common/Items.php index 7a6a244d6..189af8093 100644 --- a/app/Http/Controllers/Common/Items.php +++ b/app/Http/Controllers/Common/Items.php @@ -242,7 +242,7 @@ class Items extends Controller $currency_code = request('currency_code'); if (empty($currency_code) || (strtolower($currency_code) == 'null')) { - $currency_code = setting('default.currency'); + $currency_code = default_currency(); } $autocomplete = Item::autocomplete([ diff --git a/app/Http/Controllers/Modals/Accounts.php b/app/Http/Controllers/Modals/Accounts.php index 8b31fb474..e7e18556d 100644 --- a/app/Http/Controllers/Modals/Accounts.php +++ b/app/Http/Controllers/Modals/Accounts.php @@ -28,7 +28,7 @@ class Accounts extends Controller */ public function create() { - $currency = Currency::where('code', '=', setting('default.currency'))->first(); + $currency = Currency::where('code', '=', default_currency())->first(); $html = view('modals.accounts.create', compact('currency'))->render(); diff --git a/app/Http/Controllers/Modals/Items.php b/app/Http/Controllers/Modals/Items.php index 53c6d71f8..31ebac806 100644 --- a/app/Http/Controllers/Modals/Items.php +++ b/app/Http/Controllers/Modals/Items.php @@ -31,7 +31,7 @@ class Items extends Controller { $taxes = Tax::enabled()->orderBy('name')->get()->pluck('title', 'id'); - $currency = Currency::where('code', setting('default.currency'))->first(); + $currency = Currency::where('code', default_currency())->first(); $html = view('modals.items.create', compact('taxes', 'currency'))->render(); diff --git a/app/Http/Controllers/Settings/Currencies.php b/app/Http/Controllers/Settings/Currencies.php index 2ed2bca45..c99c30ba7 100644 --- a/app/Http/Controllers/Settings/Currencies.php +++ b/app/Http/Controllers/Settings/Currencies.php @@ -122,7 +122,7 @@ class Currencies extends Controller } // Set default currency - $currency->default_currency = ($currency->code == setting('default.currency')) ? 1 : 0; + $currency->default_currency = ($currency->code == default_currency()) ? 1 : 0; $precisions = (object) [ '0' => '0', diff --git a/app/Http/Controllers/Wizard/Currencies.php b/app/Http/Controllers/Wizard/Currencies.php index 2a45f5200..bfc28af1f 100644 --- a/app/Http/Controllers/Wizard/Currencies.php +++ b/app/Http/Controllers/Wizard/Currencies.php @@ -91,7 +91,7 @@ class Currencies extends Controller { $response = $this->ajaxDispatch(new UpdateCurrency($currency, $request)); - $currency->default = setting('default.currency') == $currency->code; + $currency->default = default_currency() == $currency->code; if ($response['success']) { $message = trans('messages.success.updated', ['type' => $currency->name]); diff --git a/app/Http/Middleware/Money.php b/app/Http/Middleware/Money.php index df912998b..24f54f792 100644 --- a/app/Http/Middleware/Money.php +++ b/app/Http/Middleware/Money.php @@ -23,7 +23,7 @@ class Money return $next($request); } - $currency_code = setting('default.currency'); + $currency_code = default_currency(); if ($request->get('currency_code')) { $currency_code = $request->get('currency_code'); diff --git a/app/Http/Resources/Banking/Reconciliation.php b/app/Http/Resources/Banking/Reconciliation.php index fc5825411..7ab6889ba 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, setting('default.currency'), true)->format(), + 'closing_balance_formatted' => money($this->closing_balance, default_currency(), true)->format(), 'reconciled' => $this->reconciled, 'created_from' => $this->created_from, 'created_by' => $this->created_by, diff --git a/app/Http/Resources/Common/Item.php b/app/Http/Resources/Common/Item.php index 123e5a615..badcce3f2 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($this->sale_price, setting('default.currency'), true)->format(), + 'sale_price_formatted' => money($this->sale_price, default_currency(), true)->format(), 'purchase_price' => $this->purchase_price, - 'purchase_price_formatted' => money($this->purchase_price, setting('default.currency'), true)->format(), + 'purchase_price_formatted' => money($this->purchase_price, default_currency(), true)->format(), 'category_id' => $this->category_id, 'picture' => $this->picture, 'enabled' => $this->enabled, diff --git a/app/Jobs/Banking/CreateBankingDocumentTransaction.php b/app/Jobs/Banking/CreateBankingDocumentTransaction.php index f80959aef..711658dec 100644 --- a/app/Jobs/Banking/CreateBankingDocumentTransaction.php +++ b/app/Jobs/Banking/CreateBankingDocumentTransaction.php @@ -67,7 +67,7 @@ class CreateBankingDocumentTransaction extends Job implements ShouldCreate $currency_code = !empty($this->request['currency_code']) ? $this->request['currency_code'] : $this->model->currency_code; $this->request['company_id'] = $this->model->company_id; - $this->request['currency_code'] = isset($this->request['currency_code']) ? $this->request['currency_code'] : $this->model->currency_code; + $this->request['currency_code'] = $currency_code; $this->request['paid_at'] = isset($this->request['paid_at']) ? $this->request['paid_at'] : Date::now()->toDateTimeString(); $this->request['currency_rate'] = config('money.' . $currency_code . '.rate'); $this->request['account_id'] = isset($this->request['account_id']) ? $this->request['account_id'] : setting('default.account'); diff --git a/app/Jobs/Banking/UpdateBankingDocumentTransaction.php b/app/Jobs/Banking/UpdateBankingDocumentTransaction.php index da4613240..3f89a92b2 100644 --- a/app/Jobs/Banking/UpdateBankingDocumentTransaction.php +++ b/app/Jobs/Banking/UpdateBankingDocumentTransaction.php @@ -66,7 +66,7 @@ class UpdateBankingDocumentTransaction extends Job implements ShouldUpdate $currency_code = ! empty($this->request['currency_code']) ? $this->request['currency_code'] : $this->model->currency_code; $this->request['company_id'] = $this->model->company_id; - $this->request['currency_code'] = isset($this->request['currency_code']) ? $this->request['currency_code'] : $this->model->currency_code; + $this->request['currency_code'] = $currency_code; $this->request['paid_at'] = isset($this->request['paid_at']) ? $this->request['paid_at'] : Date::now()->toDateTimeString(); $this->request['currency_rate'] = config('money.' . $currency_code . '.rate'); $this->request['account_id'] = isset($this->request['account_id']) ? $this->request['account_id'] : setting('default.account'); diff --git a/app/Jobs/Document/CreateDocumentItem.php b/app/Jobs/Document/CreateDocumentItem.php index 92710d1f9..5ba45efbf 100644 --- a/app/Jobs/Document/CreateDocumentItem.php +++ b/app/Jobs/Document/CreateDocumentItem.php @@ -28,7 +28,7 @@ class CreateDocumentItem extends Job implements HasOwner, HasSource, ShouldCreat public function handle(): DocumentItem { - $item_id = !empty($this->request['item_id']) ? $this->request['item_id'] : 0; + $item_id = ! empty($this->request['item_id']) ? $this->request['item_id'] : 0; $precision = config('money.' . $this->document->currency_code . '.precision'); $item_amount = (double) $this->request['price'] * (double) $this->request['quantity']; @@ -36,7 +36,7 @@ class CreateDocumentItem extends Job implements HasOwner, HasSource, ShouldCreat $item_discounted_amount = $item_amount; // Apply line discount to amount - if (!empty($this->request['discount'])) { + if (! empty($this->request['discount'])) { if ($this->request['discount_type'] === 'percentage') { $item_discounted_amount -= ($item_amount * ($this->request['discount'] / 100)); } else { diff --git a/app/Jobs/Setting/DeleteCurrency.php b/app/Jobs/Setting/DeleteCurrency.php index c3e542712..6f7410561 100644 --- a/app/Jobs/Setting/DeleteCurrency.php +++ b/app/Jobs/Setting/DeleteCurrency.php @@ -42,7 +42,7 @@ class DeleteCurrency extends Job implements ShouldDelete $relationships = $this->countRelationships($this->model, $rels); - if ($this->model->code == setting('default.currency')) { + if ($this->model->code == default_currency()) { $relationships[] = strtolower(trans_choice('general.companies', 1)); } diff --git a/app/Jobs/Setting/UpdateCurrency.php b/app/Jobs/Setting/UpdateCurrency.php index ae0930844..29ce18d6c 100644 --- a/app/Jobs/Setting/UpdateCurrency.php +++ b/app/Jobs/Setting/UpdateCurrency.php @@ -64,7 +64,7 @@ class UpdateCurrency extends Job implements ShouldUpdate $relationships = $this->countRelationships($this->model, $rels); - if ($this->model->code == setting('default.currency')) { + if ($this->model->code == default_currency()) { $relationships[] = strtolower(trans_choice('general.companies', 1)); } diff --git a/app/Traits/Charts.php b/app/Traits/Charts.php index 78ad75787..31e69e8bd 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, setting('default.currency'), true)->formatForHumans(); + $label = money($amount, default_currency(), true)->formatForHumans(); if (!empty($description)) { $label .= ' - ' . $description; @@ -98,11 +98,11 @@ trait Charts public function getChartLabelFormatter($type = 'money', $position = null) { $label = ''; - $decimal_mark = str_replace("'", "\\'", config('money.' . setting('default.currency') . '.decimal_mark')); - $thousands_separator = str_replace("'", "\\'", config('money.' . setting('default.currency') . '.thousands_separator')); - $symbol = str_replace("'", "\\'", config('money.' . setting('default.currency') . '.symbol')); - $symbol_first = str_replace("'", "\\'", config('money.' . setting('default.currency') . '.symbol_first')); - $precision = str_replace("'", "\\'", config('money.' . setting('default.currency') . '.precision')); + $decimal_mark = str_replace("'", "\\'", config('money.' . default_currency() . '.decimal_mark')); + $thousands_separator = str_replace("'", "\\'", config('money.' . default_currency() . '.thousands_separator')); + $symbol = str_replace("'", "\\'", config('money.' . default_currency() . '.symbol')); + $symbol_first = str_replace("'", "\\'", config('money.' . default_currency() . '.symbol_first')); + $precision = str_replace("'", "\\'", config('money.' . default_currency() . '.precision')); $percent_position = $position ?: setting('localisation.percent_position'); switch ($type) { diff --git a/app/Traits/Currencies.php b/app/Traits/Currencies.php index 0f7fd7eb7..3345d55ac 100644 --- a/app/Traits/Currencies.php +++ b/app/Traits/Currencies.php @@ -44,7 +44,7 @@ trait Currencies { $default_amount = $amount; - if ($from_code != setting('default.currency')) { + if ($from_code != default_currency()) { $default_amount = $this->convertToDefault($amount, $from_code, $from_rate); } @@ -70,7 +70,7 @@ trait Currencies public function getDefaultCurrency() { - return !empty($this->default_currency_code) ? $this->default_currency_code : setting('default.currency'); + return !empty($this->default_currency_code) ? $this->default_currency_code : default_currency(); } public function setDefaultCurrency($code) diff --git a/app/Traits/Import.php b/app/Traits/Import.php index 2ddd79853..0a5c06167 100644 --- a/app/Traits/Import.php +++ b/app/Traits/Import.php @@ -195,7 +195,7 @@ trait Import 'company_id' => company_id(), 'name' => $row['account_name'], 'number' => !empty($row['account_number']) ? $row['account_number'] : (string) rand(1, 10000), - 'currency_code' => !empty($row['currency_code']) ? $row['currency_code'] : setting('default.currency'), + 'currency_code' => !empty($row['currency_code']) ? $row['currency_code'] : default_currency(), 'opening_balance' => !empty($row['opening_balance']) ? $row['opening_balance'] : 0, 'enabled' => 1, 'created_from' => $row['created_from'], @@ -221,7 +221,7 @@ trait Import 'company_id' => company_id(), 'number' => $row['account_number'], 'name' => !empty($row['account_name']) ? $row['account_name'] : $row['account_number'], - 'currency_code' => !empty($row['currency_code']) ? $row['currency_code'] : setting('default.currency'), + 'currency_code' => !empty($row['currency_code']) ? $row['currency_code'] : default_currency(), 'opening_balance' => !empty($row['opening_balance']) ? $row['opening_balance'] : 0, 'enabled' => 1, 'created_from' => $row['created_from'], @@ -273,7 +273,7 @@ trait Import 'email' => $row['contact_email'], 'type' => $type, 'name' => !empty($row['contact_name']) ? $row['contact_name'] : $row['contact_email'], - 'currency_code' => !empty($row['contact_currency']) ? $row['contact_currency'] : setting('default.currency'), + 'currency_code' => !empty($row['contact_currency']) ? $row['contact_currency'] : default_currency(), 'enabled' => 1, 'created_from' => $row['created_from'], 'created_by' => $row['created_by'], @@ -299,7 +299,7 @@ trait Import 'name' => $row['contact_name'], 'type' => $type, 'email' => !empty($row['contact_email']) ? $row['contact_email'] : null, - 'currency_code' => !empty($row['contact_currency']) ? $row['contact_currency'] : setting('default.currency'), + 'currency_code' => !empty($row['contact_currency']) ? $row['contact_currency'] : default_currency(), 'enabled' => 1, 'created_from' => $row['created_from'], 'created_by' => $row['created_by'], diff --git a/app/View/Components/Contacts/Script.php b/app/View/Components/Contacts/Script.php index 9de21b96d..f4c1bfb2a 100644 --- a/app/View/Components/Contacts/Script.php +++ b/app/View/Components/Contacts/Script.php @@ -44,7 +44,7 @@ class Script extends Component $this->type = $type; $this->contact = $contact; $this->currencies = $this->getCurrencies($currencies); - $this->currency_code = ($contact) ? $contact->currency_code : setting('default.currency'); + $this->currency_code = ($contact) ? $contact->currency_code : default_currency(); $this->alias = $this->getAlias($type, $alias); $this->folder = $this->getScriptFolder($type, $folder); diff --git a/app/View/Components/Contacts/Show/Content.php b/app/View/Components/Contacts/Show/Content.php index d5dca21f3..60679d25e 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'], setting('default.currency'), true); - $overdue_amount = money($totals['overdue'], setting('default.currency'), true); - $paid_amount = money($totals['paid'], setting('default.currency'), true); + $open_amount = money($totals['open'], default_currency(), true); + $overdue_amount = money($totals['overdue'], default_currency(), true); + $paid_amount = money($totals['paid'], default_currency(), true); $summary_amounts = [ 'open_exact' => $open_amount->format(), diff --git a/app/View/Components/Documents/Script.php b/app/View/Components/Documents/Script.php index 946c19edb..84839e98f 100644 --- a/app/View/Components/Documents/Script.php +++ b/app/View/Components/Documents/Script.php @@ -50,7 +50,7 @@ class Script extends Component $this->document = $document; $this->items = $items; $this->currencies = $this->getCurrencies($currencies); - $this->currency_code = ($document) ? $document->currency_code : setting('default.currency'); + $this->currency_code = ($document) ? $document->currency_code : default_currency(); $this->taxes = $this->getTaxes($taxes); $this->alias = $this->getAlias($type, $alias); diff --git a/app/View/Components/Form/Group/Currency.php b/app/View/Components/Form/Group/Currency.php index 2ffc0febd..3b9a58e6c 100644 --- a/app/View/Components/Form/Group/Currency.php +++ b/app/View/Components/Form/Group/Currency.php @@ -48,7 +48,7 @@ class Currency extends Form } if (empty($this->selected) && empty($this->getParentData('model'))) { - $this->selected = setting('default.currency'); + $this->selected = default_currency(); } return view('components.form.group.currency'); diff --git a/app/View/Components/Index/Currency.php b/app/View/Components/Index/Currency.php index f77370721..59c436873 100644 --- a/app/View/Components/Index/Currency.php +++ b/app/View/Components/Index/Currency.php @@ -36,7 +36,7 @@ class Currency extends Component */ public function render() { - $code = ($this->code) ? $this->code : setting('default.currency'); + $code = ($this->code) ? $this->code : default_currency(); $this->currency = config('money.' . $code . '.name'); diff --git a/app/View/Components/Layouts/Wizard/Scripts.php b/app/View/Components/Layouts/Wizard/Scripts.php index 14304ac4d..a2ec25253 100644 --- a/app/View/Components/Layouts/Wizard/Scripts.php +++ b/app/View/Components/Layouts/Wizard/Scripts.php @@ -166,7 +166,7 @@ class Scripts extends Component $currencies = collect(); Currency::all()->each(function ($currency) use (&$currencies) { - $currency->default = setting('default.currency') == $currency->code; + $currency->default = default_currency() == $currency->code; $currencies->push($currency); }); diff --git a/app/Widgets/CashFlow.php b/app/Widgets/CashFlow.php index 1f882cfce..5b8a37a55 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), 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); + $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); $totals = [ 'incoming_exact' => $incoming_amount->format(), @@ -191,7 +191,7 @@ class CashFlow extends Widget $totals[$i] += $item->getAmountConvertedToDefault(); } - $precision = config('money.' . setting('default.currency') . '.precision'); + $precision = config('money.' . default_currency() . '.precision'); foreach ($totals as $key => $value) { if ($type == 'expense') { @@ -206,7 +206,7 @@ class CashFlow extends Widget { $profit = []; - $precision = config('money.' . setting('default.currency') . '.precision'); + $precision = config('money.' . default_currency() . '.precision'); foreach ($incomes as $key => $income) { $value = $income - abs($expenses[$key]); diff --git a/app/Widgets/Payables.php b/app/Widgets/Payables.php index 3b0d86520..9ca30f082 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, setting('default.currency'), true); + $periods[$period_name] = money($period_amount, default_currency(), true); } $has_progress = !empty($open) || !empty($overdue); @@ -61,9 +61,9 @@ class Payables extends Widget $grand = $open + $overdue; $totals = [ - 'grand' => money($grand, setting('default.currency'), true), - 'open' => money($open, setting('default.currency'), true), - 'overdue' => money($overdue, setting('default.currency'), true), + 'grand' => money($grand, default_currency(), true), + 'open' => money($open, default_currency(), true), + 'overdue' => money($overdue, default_currency(), true), ]; $grand_total_text = trans('widgets.total_unpaid_bills'); diff --git a/app/Widgets/ProfitLoss.php b/app/Widgets/ProfitLoss.php index 1e65a6f70..1ca1242c3 100644 --- a/app/Widgets/ProfitLoss.php +++ b/app/Widgets/ProfitLoss.php @@ -195,7 +195,7 @@ class ProfitLoss extends Widget $totals[$i] += $item->getAmountConvertedToDefault(); } - $precision = config('money.' . setting('default.currency') . '.precision'); + $precision = config('money.' . default_currency() . '.precision'); foreach ($totals as $key => $value) { $totals[$key] = round($value, $precision); diff --git a/app/Widgets/Receivables.php b/app/Widgets/Receivables.php index 6e0cd80ab..532c012e7 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, setting('default.currency'), true); + $periods[$period_name] = money($period_amount, default_currency(), true); } $has_progress = !empty($open) || !empty($overdue); @@ -61,9 +61,9 @@ class Receivables extends Widget $grand = $open + $overdue; $totals = [ - 'grand' => money($grand, setting('default.currency'), true), - 'open' => money($open, setting('default.currency'), true), - 'overdue' => money($overdue, setting('default.currency'), true), + 'grand' => money($grand, default_currency(), true), + 'open' => money($open, default_currency(), true), + 'overdue' => money($overdue, default_currency(), true), ]; $grand_total_text = trans('widgets.total_unpaid_invoices'); diff --git a/database/factories/Account.php b/database/factories/Account.php index b7b3c30e6..451079a5c 100644 --- a/database/factories/Account.php +++ b/database/factories/Account.php @@ -70,7 +70,7 @@ class Account extends Factory public function default_currency() { return $this->state([ - 'currency_code' => setting('default.currency'), + 'currency_code' => default_currency(), ]); } } diff --git a/database/factories/Contact.php b/database/factories/Contact.php index 0631f1e53..301b57ad5 100644 --- a/database/factories/Contact.php +++ b/database/factories/Contact.php @@ -38,7 +38,7 @@ class Contact extends Factory 'address' => $this->faker->address, 'country' => $this->faker->randomElement($countries), 'website' => 'https://akaunting.com', - 'currency_code' => setting('default.currency'), + 'currency_code' => default_currency(), 'reference' => $this->faker->text(5), 'enabled' => $this->faker->boolean ? 1 : 0, 'created_from' => 'core::factory', diff --git a/database/factories/Document.php b/database/factories/Document.php index 504754ae3..37a48a5ff 100644 --- a/database/factories/Document.php +++ b/database/factories/Document.php @@ -44,7 +44,7 @@ class Document extends AbstractFactory 'company_id' => $this->company->id, 'issued_at' => $issued_at, 'due_at' => $due_at, - 'currency_code' => setting('default.currency'), + 'currency_code' => default_currency(), 'currency_rate' => '1', 'notes' => $this->faker->text(5), 'amount' => '0', @@ -247,7 +247,7 @@ class Document extends AbstractFactory 'tax_ids' => [$tax->id], 'quantity' => '1', 'price' => $amount, - 'currency' => setting('default.currency'), + 'currency' => default_currency(), ], ]; diff --git a/database/factories/Reconciliation.php b/database/factories/Reconciliation.php index e021b1d5c..1ba0badee 100644 --- a/database/factories/Reconciliation.php +++ b/database/factories/Reconciliation.php @@ -28,7 +28,7 @@ class Reconciliation extends Factory return [ 'company_id' => $this->company->id, 'account_id' => '1', - 'currency_code' => setting('default.currency'), + 'currency_code' => default_currency(), 'opening_balance' => '0', 'closing_balance' => '10', 'started_at' => $started_at, diff --git a/database/factories/Transaction.php b/database/factories/Transaction.php index d351708fd..d5ecffb05 100644 --- a/database/factories/Transaction.php +++ b/database/factories/Transaction.php @@ -44,7 +44,7 @@ class Transaction extends Factory 'account_id' => setting('default.account'), 'paid_at' => $this->faker->dateTimeBetween(now()->startOfYear(), now()->endOfYear())->format('Y-m-d H:i:s'), 'amount' => $this->faker->randomFloat(2, 1, 1000), - 'currency_code' => setting('default.currency'), + 'currency_code' => default_currency(), 'currency_rate' => '1.0', 'description' => $this->faker->text(5), 'category_id' => $this->company->categories()->$category_type()->get()->random(1)->pluck('id')->first(), diff --git a/database/seeds/TestCompany.php b/database/seeds/TestCompany.php index 995273a69..dbd4579e1 100644 --- a/database/seeds/TestCompany.php +++ b/database/seeds/TestCompany.php @@ -84,7 +84,7 @@ class TestCompany extends Seeder 'type' => 'customer', 'name' => 'Test Customer', 'email' => 'customer@company.com', - 'currency_code' => setting('default.currency'), + 'currency_code' => default_currency(), 'password' => '123456', 'password_confirmation' => '123456', 'company_id' => company_id(), diff --git a/public/css/app.css b/public/css/app.css index c6c334fb9..50bfd0b85 100644 --- a/public/css/app.css +++ b/public/css/app.css @@ -49715,14 +49715,18 @@ body{ left: 100%; } -[dir="ltr"] .ltr\:-left-80{ - left: -20rem; +[dir="ltr"] .ltr\:-right-1\.5{ + right: -0.375rem; } [dir="ltr"] .ltr\:-right-1{ right: -0.25rem; } +[dir="ltr"] .ltr\:-left-80{ + left: -20rem; +} + [dir="ltr"] .ltr\:-right-2{ right: -0.5rem; } @@ -50650,14 +50654,18 @@ body{ left: 100%; } -[dir="rtl"] .rtl\:-right-80{ - right: -20rem; +[dir="rtl"] .rtl\:-left-1\.5{ + left: -0.375rem; } [dir="rtl"] .rtl\:-left-1{ left: -0.25rem; } +[dir="rtl"] .rtl\:-right-80{ + right: -20rem; +} + [dir="rtl"] .rtl\:-left-2{ left: -0.5rem; } diff --git a/public/css/print.css b/public/css/print.css index 951b93bd5..8a9655a83 100644 --- a/public/css/print.css +++ b/public/css/print.css @@ -67,8 +67,8 @@ html[dir='rtl'] .right-column { margin-bottom: 8px; } -.margin-bottom-12 { - margin: 12px 0; +.margin-bottom-spacing { + margin: 24px 0; } .print-template .mt-1 @@ -348,6 +348,10 @@ html[dir='rtl'] .text-right text-align: left; } +.text-alignment-center { + text-align: center; +} + .text-center { text-align: center; @@ -424,6 +428,30 @@ html[dir='rtl'] .text-right vertical-align: top; } +.col-w-2 { + width: 16.6666666667%; +} + +.col-w-4 { + width: 33.3333333333%; +} + +.col-w-6 { + width: 50%; +} + +.col-w-8 { + width: 66.6666666667%; +} + +.col-w-10 { + width: 83.3333333333%; +} + +.col-w-12 { + width: 50%; +} + .w-image { width: 70px; } diff --git a/resources/assets/js/views/common/companies.js b/resources/assets/js/views/common/companies.js index c43366979..d7d831cc6 100644 --- a/resources/assets/js/views/common/companies.js +++ b/resources/assets/js/views/common/companies.js @@ -47,5 +47,41 @@ const app = new Vue({ this.form.submit(); }, + + // Change currency get money + onChangeCurrency(currency_code) { + if (! currency_code) { + return; + } + + if (! this.all_currencies.length) { + let currency_promise = Promise.resolve(window.axios.get((url + '/settings/currencies'))); + + currency_promise.then(response => { + if (response.data.success) { + this.all_currencies = response.data.data; + } + + this.all_currencies.forEach(function (currency, index) { + if (currency_code == currency.code) { + this.currency = currency; + + this.form.currency = currency.code; + } + }, this); + }) + .catch(error => { + this.onChangeCurrency(currency_code); + }); + } else { + this.all_currencies.forEach(function (currency, index) { + if (currency_code == currency.code) { + this.currency = currency; + + this.form.currency = currency.code; + } + }, this); + } + }, } }); diff --git a/resources/assets/js/views/settings/settings.js b/resources/assets/js/views/settings/settings.js index afbea3a8b..ba3ee7e75 100644 --- a/resources/assets/js/views/settings/settings.js +++ b/resources/assets/js/views/settings/settings.js @@ -159,6 +159,42 @@ const app = new Vue({ } else { this.quantity_name_input = false; } - } + }, + + // Change currency get money + onChangeCurrency(currency_code) { + if (! currency_code) { + return; + } + + if (! this.all_currencies.length) { + let currency_promise = Promise.resolve(window.axios.get((url + '/settings/currencies'))); + + currency_promise.then(response => { + if (response.data.success) { + this.all_currencies = response.data.data; + } + + this.all_currencies.forEach(function (currency, index) { + if (currency_code == currency.code) { + this.currency = currency; + + this.form.currency = currency.code; + } + }, this); + }) + .catch(error => { + this.onChangeCurrency(currency_code); + }); + } else { + this.all_currencies.forEach(function (currency, index) { + if (currency_code == currency.code) { + this.currency = currency; + + this.form.currency = currency.code; + } + }, this); + } + }, } }); diff --git a/resources/views/banking/transfers/create.blade.php b/resources/views/banking/transfers/create.blade.php index 4352cd051..070232586 100644 --- a/resources/views/banking/transfers/create.blade.php +++ b/resources/views/banking/transfers/create.blade.php @@ -25,13 +25,13 @@