fixed #62
This commit is contained in:
parent
b7f9e8bf63
commit
beb78d21ee
@ -14,8 +14,13 @@ class Transactions extends ModelFilter
|
|||||||
*/
|
*/
|
||||||
public $relations = [];
|
public $relations = [];
|
||||||
|
|
||||||
public function search($query)
|
public function account($account_id)
|
||||||
{
|
{
|
||||||
return $this->whereLike('payment.name', $query)->whereLike('revenue.name', $query);
|
return $this->where('account_id', $account_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function category($category_id)
|
||||||
|
{
|
||||||
|
return $this->where('category_id', $category_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -3,9 +3,11 @@
|
|||||||
namespace App\Http\Controllers\Banking;
|
namespace App\Http\Controllers\Banking;
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\Banking\Account;
|
||||||
use App\Models\Banking\Transaction;
|
use App\Models\Banking\Transaction;
|
||||||
use App\Models\Expense\Payment;
|
use App\Models\Expense\Payment;
|
||||||
use App\Models\Income\Revenue;
|
use App\Models\Income\Revenue;
|
||||||
|
use App\Models\Setting\Category;
|
||||||
|
|
||||||
class Transactions extends Controller
|
class Transactions extends Controller
|
||||||
{
|
{
|
||||||
@ -17,37 +19,51 @@ class Transactions extends Controller
|
|||||||
*/
|
*/
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
//$transactions = Transaction::index();
|
|
||||||
$request = request();
|
$request = request();
|
||||||
|
|
||||||
$payments = Payment::collect('paid_at');
|
|
||||||
|
|
||||||
$transactions = array();
|
$transactions = array();
|
||||||
|
|
||||||
foreach ($payments as $payment) {
|
$accounts = collect(Account::enabled()->pluck('name', 'id'))
|
||||||
$transactions[] = (object)[
|
->prepend(trans('general.all_type', ['type' => trans_choice('general.accounts', 2)]), '');
|
||||||
'paid_at' => $payment->paid_at,
|
|
||||||
'account_name' => $payment->account->name,
|
$types = collect(['expense' => 'Expense', 'income' => 'Income'])
|
||||||
'type' => trans_choice('general.expenses', 1),
|
->prepend(trans('general.all_type', ['type' => trans_choice('general.types', 2)]), '');
|
||||||
'category_name' => $payment->category->name,
|
|
||||||
'description' => $payment->description,
|
$categories = collect(Category::enabled()->type('income')->pluck('name', 'id'))
|
||||||
'amount' => $payment->amount,
|
->prepend(trans('general.all_type', ['type' => trans_choice('general.categories', 2)]), '');
|
||||||
'currency_code' => $payment->currency_code,
|
|
||||||
];
|
$type = $request->get('type');
|
||||||
|
|
||||||
|
if ($type != 'income') {
|
||||||
|
$payments = Payment::collect('paid_at');
|
||||||
|
|
||||||
|
foreach ($payments as $payment) {
|
||||||
|
$transactions[] = (object)[
|
||||||
|
'paid_at' => $payment->paid_at,
|
||||||
|
'account_name' => $payment->account->name,
|
||||||
|
'type' => trans_choice('general.expenses', 1),
|
||||||
|
'category_name' => $payment->category->name,
|
||||||
|
'description' => $payment->description,
|
||||||
|
'amount' => $payment->amount,
|
||||||
|
'currency_code' => $payment->currency_code,
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$revenues = Revenue::collect('paid_at');
|
if ($type != 'expense') {
|
||||||
|
$revenues = Revenue::collect('paid_at');
|
||||||
|
|
||||||
foreach ($revenues as $revenue) {
|
foreach ($revenues as $revenue) {
|
||||||
$transactions[] = (object)[
|
$transactions[] = (object)[
|
||||||
'paid_at' => $revenue->paid_at,
|
'paid_at' => $revenue->paid_at,
|
||||||
'account_name' => $revenue->account->name,
|
'account_name' => $revenue->account->name,
|
||||||
'type' => trans_choice('general.incomes', 1),
|
'type' => trans_choice('general.incomes', 1),
|
||||||
'category_name' => $revenue->category->name,
|
'category_name' => $revenue->category->name,
|
||||||
'description' => $revenue->description,
|
'description' => $revenue->description,
|
||||||
'amount' => $revenue->amount,
|
'amount' => $revenue->amount,
|
||||||
'currency_code' => $revenue->currency_code,
|
'currency_code' => $revenue->currency_code,
|
||||||
];
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$special_key = array(
|
$special_key = array(
|
||||||
@ -75,6 +91,6 @@ class Transactions extends Controller
|
|||||||
|
|
||||||
$transactions = (object) $transactions;
|
$transactions = (object) $transactions;
|
||||||
|
|
||||||
return view('banking.transactions.index', compact('transactions'));
|
return view('banking.transactions.index', compact('transactions', 'accounts', 'types', 'categories'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,9 @@
|
|||||||
{!! Form::open(['url' => 'banking/transactions', 'role' => 'form', 'method' => 'GET']) !!}
|
{!! Form::open(['url' => 'banking/transactions', 'role' => 'form', 'method' => 'GET']) !!}
|
||||||
<div class="pull-left">
|
<div class="pull-left">
|
||||||
<span class="title-filter hidden-xs">{{ trans('general.search') }}:</span>
|
<span class="title-filter hidden-xs">{{ trans('general.search') }}:</span>
|
||||||
{!! Form::text('search', request('search'), ['class' => 'form-control input-filter input-sm', 'placeholder' => trans('general.search_placeholder')]) !!}
|
{!! Form::select('account', $accounts, request('account'), ['class' => 'form-control input-filter input-sm']) !!}
|
||||||
|
{!! Form::select('type', $types, request('type'), ['class' => 'form-control input-filter input-sm']) !!}
|
||||||
|
{!! Form::select('category', $categories, request('category'), ['class' => 'form-control input-filter input-sm']) !!}
|
||||||
{!! Form::button('<span class="fa fa-filter"></span> ' . trans('general.filter'), ['type' => 'submit', 'class' => 'btn btn-sm btn-default btn-filter']) !!}
|
{!! Form::button('<span class="fa fa-filter"></span> ' . trans('general.filter'), ['type' => 'submit', 'class' => 'btn btn-sm btn-default btn-filter']) !!}
|
||||||
</div>
|
</div>
|
||||||
<div class="pull-right">
|
<div class="pull-right">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user