convert setting('default.currency') to default_currency() helper function..

This commit is contained in:
Cüneyt Şentürk
2022-10-05 10:35:19 +03:00
parent e683a0d171
commit d29859f65b
45 changed files with 84 additions and 84 deletions

View File

@ -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(),
];
}

View File

@ -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;
}

View File

@ -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,

View File

@ -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();

View File

@ -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(),

View File

@ -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(),

View File

@ -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();

View File

@ -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([

View File

@ -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();

View File

@ -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();

View File

@ -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',

View File

@ -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]);

View File

@ -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');

View File

@ -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,

View File

@ -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,

View File

@ -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));
}

View File

@ -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));
}

View File

@ -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) {

View File

@ -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)

View File

@ -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'],

View File

@ -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);

View File

@ -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(),

View File

@ -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);

View File

@ -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');

View File

@ -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');

View File

@ -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);
});

View File

@ -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]);

View File

@ -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');

View File

@ -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);

View File

@ -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');