Skip to content

Commit

Permalink
refs #451 Add format files;
Browse files Browse the repository at this point in the history
Banking => Account,
Banking => Transfer,
Common => Items,
Expense => Payment,
Income => Revenue
  • Loading branch information
cuneytsenturk committed Aug 13, 2018
1 parent 784d2fd commit e9d6cec
Show file tree
Hide file tree
Showing 21 changed files with 1,099 additions and 25 deletions.
18 changes: 14 additions & 4 deletions app/Http/Controllers/Banking/Accounts.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ public function show()
public function create()
{
$currencies = Currency::enabled()->pluck('name', 'code');

return view('banking.accounts.create', compact('currencies'));

$currency = Currency::where('code', '=', setting('general.default_currency', 'USD'))->first();

return view('banking.accounts.create', compact('currencies', 'currency'));
}

/**
Expand Down Expand Up @@ -80,8 +82,10 @@ public function edit(Account $account)
$currencies = Currency::enabled()->pluck('name', 'code');

$account->default_account = ($account->id == setting('general.default_account')) ?: 1;

return view('banking.accounts.edit', compact('account', 'currencies'));

$currency = Currency::where('code', '=', setting('general.default_currency', 'USD'))->first();

return view('banking.accounts.edit', compact('account', 'currencies', 'currency'));
}

/**
Expand Down Expand Up @@ -239,6 +243,12 @@ public function currency()
$account->currency_code = $currency_code;
$account->currency_rate = $currency->rate;

$account->thousands_separator = $currency->thousands_separator;
$account->decimal_mark = $currency->decimal_mark;
$account->precision = (int) $currency->precision;
$account->symbol_first = $currency->symbol_first;
$account->symbol = $currency->symbol;

return response()->json($account);
}
}
8 changes: 6 additions & 2 deletions app/Http/Controllers/Banking/Transfers.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ public function create()

$payment_methods = Modules::getPaymentMethods();

return view('banking.transfers.create', compact('accounts', 'payment_methods'));
$currency = Currency::where('code', '=', setting('general.default_currency', 'USD'))->first();

return view('banking.transfers.create', compact('accounts', 'payment_methods', 'currency'));
}

/**
Expand Down Expand Up @@ -219,7 +221,9 @@ public function edit(Transfer $transfer)

$payment_methods = Modules::getPaymentMethods();

return view('banking.transfers.edit', compact('transfer', 'accounts', 'payment_methods'));
$currency = Currency::where('code', '=', setting('general.default_currency', 'USD'))->first();

return view('banking.transfers.edit', compact('transfer', 'accounts', 'payment_methods', 'currency'));
}

/**
Expand Down
14 changes: 9 additions & 5 deletions app/Http/Controllers/Common/Items.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ public function create()

$taxes = Tax::enabled()->orderBy('rate')->get()->pluck('title', 'id');

return view('common.items.create', compact('categories', 'taxes'));
$currency = Currency::where('code', '=', setting('general.default_currency', 'USD'))->first();

return view('common.items.create', compact('categories', 'taxes', 'currency'));
}

/**
Expand Down Expand Up @@ -131,7 +133,9 @@ public function edit(Item $item)

$taxes = Tax::enabled()->orderBy('rate')->get()->pluck('title', 'id');

return view('common.items.edit', compact('item', 'categories', 'taxes'));
$currency = Currency::where('code', '=', setting('general.default_currency', 'USD'))->first();

return view('common.items.edit', compact('item', 'categories', 'taxes', 'currency'));
}

/**
Expand Down Expand Up @@ -234,8 +238,8 @@ public function destroy(Item $item)
*/
public function export()
{
\Excel::create('items', function ($excel) {
$excel->sheet('items', function ($sheet) {
\Excel::create('items', function($excel) {
$excel->sheet('items', function($sheet) {
$sheet->fromModel(Item::filter(request()->input())->get()->makeHidden([
'id', 'company_id', 'item_id', 'created_at', 'updated_at', 'deleted_at'
]));
Expand Down Expand Up @@ -315,7 +319,7 @@ public function totalItem()

if ($input_items) {
foreach ($input_items as $key => $item) {
$price = money($item['price'], $currency_code)->getAmount();
$price = (double) $item['price'];
$quantity = (double) $item['quantity'];

$item_tax_total= 0;
Expand Down
8 changes: 6 additions & 2 deletions app/Http/Controllers/Expenses/Payments.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,15 @@ public function create()

$account_currency_code = Account::where('id', setting('general.default_account'))->pluck('currency_code')->first();

$currency = Currency::where('code', '=', $account_currency_code)->first();

$vendors = Vendor::enabled()->orderBy('name')->pluck('name', 'id');

$categories = Category::enabled()->type('expense')->orderBy('name')->pluck('name', 'id');

$payment_methods = Modules::getPaymentMethods();

return view('expenses.payments.create', compact('accounts', 'currencies', 'account_currency_code', 'vendors', 'categories', 'payment_methods'));
return view('expenses.payments.create', compact('accounts', 'currencies', 'account_currency_code', 'currency', 'vendors', 'categories', 'payment_methods'));
}

/**
Expand Down Expand Up @@ -154,13 +156,15 @@ public function edit(Payment $payment)

$account_currency_code = Account::where('id', $payment->account_id)->pluck('currency_code')->first();

$currency = Currency::where('code', '=', $account_currency_code)->first();

$vendors = Vendor::enabled()->orderBy('name')->pluck('name', 'id');

$categories = Category::enabled()->type('expense')->orderBy('name')->pluck('name', 'id');

$payment_methods = Modules::getPaymentMethods();

return view('expenses.payments.edit', compact('payment', 'accounts', 'currencies', 'account_currency_code', 'vendors', 'categories', 'payment_methods'));
return view('expenses.payments.edit', compact('payment', 'accounts', 'currencies', 'account_currency_code', 'currency', 'vendors', 'categories', 'payment_methods'));
}

/**
Expand Down
8 changes: 6 additions & 2 deletions app/Http/Controllers/Incomes/Revenues.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,15 @@ public function create()

$account_currency_code = Account::where('id', setting('general.default_account'))->pluck('currency_code')->first();

$currency = Currency::where('code', '=', $account_currency_code)->first();

$customers = Customer::enabled()->orderBy('name')->pluck('name', 'id');

$categories = Category::enabled()->type('income')->orderBy('name')->pluck('name', 'id');

$payment_methods = Modules::getPaymentMethods();

return view('incomes.revenues.create', compact('accounts', 'currencies', 'account_currency_code', 'customers', 'categories', 'payment_methods'));
return view('incomes.revenues.create', compact('accounts', 'currencies', 'account_currency_code', 'currency', 'customers', 'categories', 'payment_methods'));
}

/**
Expand Down Expand Up @@ -156,13 +158,15 @@ public function edit(Revenue $revenue)

$account_currency_code = Account::where('id', $revenue->account_id)->pluck('currency_code')->first();

$currency = Currency::where('code', '=', $account_currency_code)->first();

$customers = Customer::enabled()->orderBy('name')->pluck('name', 'id');

$categories = Category::enabled()->type('income')->orderBy('name')->pluck('name', 'id');

$payment_methods = Modules::getPaymentMethods();

return view('incomes.revenues.edit', compact('revenue', 'accounts', 'currencies', 'account_currency_code', 'customers', 'categories', 'payment_methods'));
return view('incomes.revenues.edit', compact('revenue', 'accounts', 'currencies', 'account_currency_code', 'currency', 'customers', 'categories', 'payment_methods'));
}

/**
Expand Down
10 changes: 3 additions & 7 deletions app/Http/Controllers/Settings/Currencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,13 +288,9 @@ public function config()

$code = request('code');

if ($code) {
$currency = config('money.' . $code);
$currency['symbol_first'] = $currency['symbol_first'] ? 1 : 0;
// Get currency object
$currency = Currency::where('code', $code)->first();

$json = (object) $currency;
}

return response()->json($json);
return response()->json($currency);
}
}

0 comments on commit e9d6cec

Please sign in to comment.