Accounts show page
This commit is contained in:
parent
986522e813
commit
77d6618368
@ -9,6 +9,7 @@ use App\Jobs\Banking\DeleteAccount;
|
||||
use App\Jobs\Banking\UpdateAccount;
|
||||
use App\Models\Banking\Account;
|
||||
use App\Models\Banking\Transaction;
|
||||
use App\Models\Banking\Transfer;
|
||||
use App\Models\Setting\Currency;
|
||||
|
||||
class Accounts extends Controller
|
||||
@ -32,16 +33,25 @@ class Accounts extends Controller
|
||||
*/
|
||||
public function show(Account $account)
|
||||
{
|
||||
$amounts = [
|
||||
'incoming' => 0,
|
||||
'outgoing' => 0,
|
||||
'balance' => 0,
|
||||
];
|
||||
$limit = (int) request('limit', setting('default.list_limit', '25'));
|
||||
|
||||
$transactions = $account->transactions;
|
||||
// Handle transactions
|
||||
$transactions = Transaction::with('account', 'category')->where('account_id', $account->id)->collect('paid_at');
|
||||
|
||||
return view('banking.accounts.show', compact('account', 'amounts', 'transactions'));
|
||||
$transfers = Transfer::with('transaction')->all()->filter(function ($transfer) use($account) {
|
||||
if ($transfer->expense_account->id == $account->id || $transfer->income_account->id == $account->id) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
})->sortByDesc(function ($transfer) {
|
||||
return $transfer->expense_transaction->paid_at;
|
||||
});
|
||||
|
||||
$limit = (int) request('limit', setting('default.list_limit', '25'));
|
||||
$transfers = $this->paginate($transfers, $limit);
|
||||
|
||||
return view('banking.accounts.show', compact('account', 'transactions', 'transfers'));
|
||||
}
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
|
@ -93,6 +93,41 @@ class Account extends Model
|
||||
return $total;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current balance.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getIncomeBalanceAttribute()
|
||||
{
|
||||
// Opening Balance
|
||||
//$total = $this->opening_balance;
|
||||
$total = 0;
|
||||
|
||||
// Sum Incomes
|
||||
$total += $this->income_transactions->sum('amount');
|
||||
|
||||
return $total;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current balance.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getExpenseBalanceAttribute()
|
||||
{
|
||||
// Opening Balance
|
||||
//$total = $this->opening_balance;
|
||||
$total = 0;
|
||||
|
||||
// Subtract Expenses
|
||||
$total += $this->expense_transactions->sum('amount');
|
||||
|
||||
return $total;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a new factory instance for the model.
|
||||
*
|
||||
|
40
resources/assets/js/views/banking/accounts.js
vendored
40
resources/assets/js/views/banking/accounts.js
vendored
@ -29,46 +29,6 @@ const app = new Vue({
|
||||
return {
|
||||
form: new Form('account'),
|
||||
bulk_action: new BulkAction('accounts'),
|
||||
template: {
|
||||
modal: false,
|
||||
title: '',
|
||||
message: '',
|
||||
html: '',
|
||||
errors: new Error()
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
onTemplate() {
|
||||
this.template.modal = true;
|
||||
|
||||
this.transfer_form = new Form('template');
|
||||
|
||||
this.transfer_form.template = this.transfer_form._template;
|
||||
},
|
||||
|
||||
addTemplate() {
|
||||
if (this.transfer_form.template != 1) {
|
||||
|
||||
this.transfer_form.submit();
|
||||
|
||||
this.template.errors = this.transfer_form.errors;
|
||||
}
|
||||
|
||||
this.form.loading = true;
|
||||
|
||||
this.$emit("confirm");
|
||||
},
|
||||
|
||||
closeTemplate() {
|
||||
this.template = {
|
||||
modal: false,
|
||||
title: '',
|
||||
message: '',
|
||||
errors: this.transfer_form.errors
|
||||
};
|
||||
},
|
||||
},
|
||||
|
||||
});
|
||||
|
@ -21,26 +21,36 @@
|
||||
|
||||
<div class="dropdown-divider"></div>
|
||||
|
||||
@stack('transaction_button_start')
|
||||
@can('create-account-transactions')
|
||||
<a class="dropdown-item" href="{{ route('banking.create-transaction', $account->id) }}">
|
||||
CREATE TRANSACTION
|
||||
@stack('revenue_button_start')
|
||||
@can('create-sales-revenues')
|
||||
<a class="dropdown-item" href="{{ route('revenues.create') . '?account_id=' . $account->id }}">
|
||||
{{ trans('general.add_income')}}
|
||||
</a>
|
||||
@endcan
|
||||
@stack('transaction_button_end')
|
||||
@stack('revenue_button_end')
|
||||
|
||||
@stack('revenue_button_start')
|
||||
@can('create-sales-revenues')
|
||||
<a class="dropdown-item" href="{{ route('payments.create') . '?account_id=' . $account->id }}">
|
||||
{{ trans('general.add_expense') }}
|
||||
</a>
|
||||
@endcan
|
||||
@stack('revenue_button_end')
|
||||
|
||||
@stack('transfer_button_start')
|
||||
@can('show-performance')
|
||||
<a class="dropdown-item" href="{{ route('banking.create-transfer', $account->id) }}">
|
||||
create_transfer
|
||||
@can('create-banking-transfers')
|
||||
<a class="dropdown-item" href="{{ route('transfers.create') . '?from_account_id=' . $account->id }}">
|
||||
Add Transfer
|
||||
</a>
|
||||
@endcan
|
||||
@stack('transfer_button_end')
|
||||
|
||||
<div class="dropdown-divider"></div>
|
||||
|
||||
@stack('performance_button_start')
|
||||
@can('show-performance')
|
||||
<a class="dropdown-item" href="{{ route('accounts.show-performance', $account->id) }}">
|
||||
performance
|
||||
@can('read-banking-accounts')
|
||||
<a class="dropdown-item" href="#">
|
||||
See Performance
|
||||
</a>
|
||||
@endcan
|
||||
@stack('performance_button_end')
|
||||
@ -48,22 +58,21 @@
|
||||
<div class="dropdown-divider"></div>
|
||||
|
||||
@stack('delete_button_start')
|
||||
@can('delete-banking-accounts')
|
||||
@can('delete-sales-customers')
|
||||
{!! Form::deleteLink($account, 'accounts.destroy') !!}
|
||||
@endcan
|
||||
@stack('delete_button_end')
|
||||
|
||||
@stack('button_dropdown_end')
|
||||
</div>
|
||||
@stack('edit_button_start')
|
||||
@can('update-sales-customers')
|
||||
<a href="{{ route('accounts.edit', $account->id) }}" class="btn btn-white btn-sm">
|
||||
{{ trans('general.edit') }}
|
||||
</a>
|
||||
@endcan
|
||||
@stack('edit_button_end')
|
||||
</div>
|
||||
|
||||
@stack('account_edit_button_start')
|
||||
@can('update-banking-account')
|
||||
<a href="{{ route('accounts.edit', $account->id) }}" class="btn btn-white btn-sm">
|
||||
{{ trans('general.edit') }}
|
||||
</a>
|
||||
@endcan
|
||||
@stack('account_edit_button_end')
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
@ -71,23 +80,23 @@
|
||||
<div class="col-xl-3">
|
||||
<ul class="list-group mb-4">
|
||||
@stack('account_number_start')
|
||||
<li class="list-group-item d-flex justify-content-between align-items-center border-0">
|
||||
{{ trans_choice('general.account_number', 2) }}
|
||||
<span class="badge badge-primary badge-pill">{{ }}</span>
|
||||
<li class="list-group-item d-flex justify-content-between align-items-center border-0 font-weight-600">
|
||||
{{ trans_choice('general.accounts', 1) }} {{ trans_choice('accounts.number', 2) }}
|
||||
<small class="long-texts">{{ $account -> number}}</small>
|
||||
</li>
|
||||
@stack('account_number_end')
|
||||
|
||||
@stack('account_currency_start')
|
||||
<li class="list-group-item d-flex justify-content-between align-items-center border-0 border-top-1">
|
||||
{{ trans_choice('general.transactions', 2) }}
|
||||
<span class="badge badge-primary badge-pill">{{ $ }}</span>
|
||||
<li class="list-group-item d-flex justify-content-between align-items-center border-0 border-top-1 font-weight-600">
|
||||
{{ trans_choice('general.currencies', 2) }}
|
||||
<small class="long-texts"> {{ $account -> currency -> name}} </small>
|
||||
</li>
|
||||
@stack('account_currency_end')
|
||||
|
||||
@stack('account_starting_balance_start')
|
||||
<li class="list-group-item d-flex justify-content-between align-items-center border-0">
|
||||
{{ trans_choice('banking.starting_balance', 2) }}
|
||||
<span class="badge badge-primary badge-pill">{{ }}</span>
|
||||
<li class="list-group-item d-flex justify-content-between align-items-center border-0 border-top-1 font-weight-600">
|
||||
{{ trans_choice('accounts.opening_balance', 2) }}
|
||||
<small class="long-texts"> @money($account -> opening_balance, $account -> currency -> currency_code, true) </small>
|
||||
</li>
|
||||
@stack('account_starting_balance_end')
|
||||
</ul>
|
||||
@ -95,28 +104,25 @@
|
||||
<ul class="list-group mb-4">
|
||||
@stack('bank_name_start')
|
||||
<li class="list-group-item border-0">
|
||||
<div class="font-weight-600">{{ trans('') }}</div>
|
||||
<div><small class="long-texts" title="{{ $account->name }}">{{ $account->name }}</small></div>
|
||||
<div class="font-weight-600">{{ trans('accounts.bank_name') }}</div>
|
||||
<div><small class="long-texts" title="{{ $account->bank_name }}">{{ $account->bank_name }}</small></div>
|
||||
</li>
|
||||
@stack('bank_name_end')
|
||||
|
||||
@stack('account_phone_start')
|
||||
<li class="list-group-item border-0 border-top-1">
|
||||
<div class="font-weight-600">{{ trans('general.phone') }}</div>
|
||||
<div><small class="long-texts" title="{{ $account->phone }}">{{ $account->phone }}</small></div>
|
||||
<div class="font-weight-600">{{ trans('accounts.bank_phone') }}</div>
|
||||
<div><small class="long-texts" title="{{ $account->bank_phone }}">{{ $account->bank_phone }}</small></div>
|
||||
</li>
|
||||
@stack('account_phone_end')
|
||||
|
||||
@stack('account_address_start')
|
||||
<li class="list-group-item border-0 border-top-1">
|
||||
<div class="font-weight-600">{{ trans('general.address') }}</div>
|
||||
<div><small class="long-texts" title="{{ $account->address }}">{{ $account->address }}</small></div>
|
||||
<div class="font-weight-600">{{ trans('accounts.bank_address') }}</div>
|
||||
<div><small class="long-texts" title="{{ $account->bank_address }}">{{ $account->bank_address }}</small></div>
|
||||
</li>
|
||||
@stack('account_address_end')
|
||||
</ul>
|
||||
|
||||
@stack('account_edit_button_start')
|
||||
@stack('account_edit_button_end')
|
||||
</div>
|
||||
|
||||
<div class="col-xl-9">
|
||||
@ -129,7 +135,7 @@
|
||||
<div class="col">
|
||||
<h5 class="text-uppercase text-muted mb-0 text-white">{{ trans('general.incoming') }}</h5>
|
||||
<div class="dropdown-divider"></div>
|
||||
<span class="h2 font-weight-bold mb-0 text-white">@money($amounts['incoming'], setting('default.currency'), true)</span>
|
||||
<span class="h2 font-weight-bold mb-0 text-white">@money($account->income_balance, $account->currency_code, true)</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -145,7 +151,7 @@
|
||||
<div class="col">
|
||||
<h5 class="text-uppercase text-muted mb-0 text-white">{{ trans('widgets.outgoing') }}</h5>
|
||||
<div class="dropdown-divider"></div>
|
||||
<span class="h2 font-weight-bold mb-0 text-white">@money($amounts['outgoing'], setting('default.currency'), true)</span>
|
||||
<span class="h2 font-weight-bold mb-0 text-white">@money($account->expense_balance, $account->currency_code, true)</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -159,9 +165,9 @@
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h5 class="text-uppercase text-muted mb-0 text-white">{{ trans('widgets.balance') }}</h5>
|
||||
<h5 class="text-uppercase text-muted mb-0 text-white">{{ trans('widgets.account_balance') }}</h5>
|
||||
<div class="dropdown-divider"></div>
|
||||
<span class="h2 font-weight-bold mb-0 text-white">@money($amounts['balance'], setting('default.currency'), true)</span>
|
||||
<span class="h2 font-weight-bold mb-0 text-white">@money($account->balance, $account->currency_code, true)</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -176,16 +182,16 @@
|
||||
<ul class="nav nav-pills nav-fill flex-column flex-md-row" id="tabs-icons-text" role="tablist">
|
||||
@stack('account_transactions_tab_start')
|
||||
<li class="nav-item">
|
||||
<a class="nav-link mb-sm-3 mb-md-0 active" id="invoices-tab" data-toggle="tab" href="#invoices-content" role="tab" aria-controls="invoices-content" aria-selected="true">
|
||||
{{ trans_choice('general.invoices', 2) }}
|
||||
<a class="nav-link mb-sm-3 mb-md-0 active" id="transactions-tab" data-toggle="tab" href="#transactions-content" role="tab" aria-controls="transactions-content" aria-selected="true">
|
||||
{{ trans_choice('general.transactions', 2) }}
|
||||
</a>
|
||||
</li>
|
||||
@stack('account_transactions_tab_end')
|
||||
|
||||
@stack('account_transfers_tab_start')
|
||||
<li class="nav-item">
|
||||
<a class="nav-link mb-sm-3 mb-md-0" id="transactions-tab" data-toggle="tab" href="#transactions-content" role="tab" aria-controls="transactions-content" aria-selected="false">
|
||||
{{ trans_choice('general.transactions', 2) }}
|
||||
<a class="nav-link mb-sm-3 mb-md-0" id="transfers-tab" data-toggle="tab" href="#transfers-content" role="tab" aria-controls="transfers-content" aria-selected="false">
|
||||
{{ trans_choice('general.transfers', 2) }}
|
||||
</a>
|
||||
</li>
|
||||
@stack('account_transfers_tab_end')
|
||||
@ -197,23 +203,23 @@
|
||||
@stack('account_transactions_content_start')
|
||||
<div class="tab-pane fade show active" id="transactions-content" role="tabpanel" aria-labelledby="transactions-tab">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-flush table-hover" id="tbl-invoices">
|
||||
<table class="table table-flush table-hover" id="tbl-transactions">
|
||||
<thead class="thead-light">
|
||||
<tr class="row table-head-line">
|
||||
<th class="col-xs-4 col-sm-1">{{ trans_choice('general.date', 1) }}</th>
|
||||
<th class="col-xs-4 col-sm-3 text-right">{{ trans('general.amount') }}</th>
|
||||
<th class="col-sm-3 d-none d-sm-block text-left">{{ trans('general.type') }}</th>
|
||||
<th class="col-sm-3 d-none d-sm-block text-left">{{ trans('general.category') }}</th>
|
||||
<th class="col-sm-3">{{ trans_choice('general.date', 1) }}</th>
|
||||
<th class="col-sm-3">{{ trans('general.amount') }}</th>
|
||||
<th class="col-sm-3">{{ trans_choice('general.types', 1) }}</th>
|
||||
<th class="col-sm-3">{{ trans_choice('general.categories', 1) }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
@foreach($transactions as $item)
|
||||
<tr class="row align-items-center border-top-1 tr-py">
|
||||
<td class="col-xs-4 col-sm-1">@date($item->issued_at)</td>
|
||||
<td class="col-xs-4 col-sm-3 text-right">@money($item->amount, $item->currency_code, true)</td>
|
||||
<td class="col-sm-3 d-none d-sm-block text-left">{{ $item->type }}</td>
|
||||
<td class="col-sm-3 d-none d-sm-block text-left">$item->category </td>
|
||||
<td class="col-sm-3"><a href="{{ route($item->route_name, $item->route_id) }}">@date($item->issued_at)</a></td>
|
||||
<td class="col-sm-3">@money($item->amount, $item->currency_code, true)</td>
|
||||
<td class="col-sm-3">{{ $item->type_title }}</td>
|
||||
<td class="col-sm-3">{{ $item->category->name }}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
@ -228,26 +234,26 @@
|
||||
</div>
|
||||
@stack('account_transactions_content_end')
|
||||
|
||||
@stack('customer_transactions_content_start')
|
||||
<div class="tab-pane fade" id="transactions-content" role="tabpanel" aria-labelledby="transactions-tab">
|
||||
@stack('account_transfers_content_start')
|
||||
<div class="tab-pane fade" id="transfers-content" role="tabpanel" aria-labelledby="transfers-tab">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-flush table-hover" id="tbl-transactions">
|
||||
<table class="table table-flush table-hover" id="tbl-transfers">
|
||||
<thead class="thead-light">
|
||||
<tr class="row table-head-line">
|
||||
<th class="col-xs-6 col-sm-2">{{ trans('general.date') }}</th>
|
||||
<th class="col-xs-6 col-sm-2 text-right">{{ trans('general.amount') }}</th>
|
||||
<th class="col-sm-4 d-none d-sm-block">{{ trans_choice('general.categories', 1) }}</th>
|
||||
<th class="col-sm-4 d-none d-sm-block">{{ trans_choice('general.accounts', 1) }}</th>
|
||||
<th class="col-sm-3">{{ trans('general.date') }}</th>
|
||||
<th class="col-sm-3">{{ trans('general.amount') }}</th>
|
||||
<th class="col-sm-3">{{ trans_choice('transfers.from_account', 1) }}</th>
|
||||
<th class="col-sm-3">{{ trans_choice('transfers.to_account', 1) }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
@foreach($transactions as $item)
|
||||
@foreach($transfers as $item)
|
||||
<tr class="row align-items-center border-top-1 tr-py">
|
||||
<td class="col-xs-6 col-sm-2"><a href="{{ route('revenues.show', $item->id) }}">@date($item->paid_at)</a></td>
|
||||
<td class="col-xs-6 col-sm-2 text-right">@money($item->amount, $item->currency_code, true)</td>
|
||||
<td class="col-sm-4 d-none d-sm-block">{{ $item->category->name }}</td>
|
||||
<td class="col-sm-4 d-none d-sm-block">{{ $item->account->name }}</td>
|
||||
<td class="col-sm-3"><a href="{{ route('transfers.show', $item->id) }}">@date($item->expense_transaction->paid_at)</a></td>
|
||||
<td class="col-sm-3">@money($item->expense_transaction->amount, $item->expense_transaction->currency_code, true)</td>
|
||||
<td class="col-sm-3">{{ $item->expense_transaction->account->name }}</td>
|
||||
<td class="col-sm-3">{{ $item->income_transaction->account->name }}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
@ -256,11 +262,11 @@
|
||||
|
||||
<div class="card-footer py-4 table-action">
|
||||
<div class="row">
|
||||
@include('partials.admin.pagination', ['items' => $transactions, 'type' => 'transactions'])
|
||||
@include('partials.admin.pagination', ['items' => $transfers, 'type' => 'transfers'])
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@stack('customer_transactions_content_end')
|
||||
@stack('account_transfers_content_end')
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -271,5 +277,5 @@
|
||||
|
||||
|
||||
@push('scripts_start')
|
||||
<script src="{{ asset('public/js/sales/accounts.js?v=' . version('short')) }}"></script>
|
||||
<script src="{{ asset('public/js/banking/accounts.js?v=' . version('short')) }}"></script>
|
||||
@endpush
|
||||
|
@ -128,11 +128,9 @@ Route::group(['prefix' => 'purchases'], function () {
|
||||
|
||||
Route::group(['prefix' => 'banking'], function () {
|
||||
Route::get('accounts/currency', 'Banking\Accounts@currency')->name('accounts.currency');
|
||||
Route::get('accounts/{account}/create-transaction', 'Banking\Accounts@createTransaction')->name('accounts.create-transaction');
|
||||
Route::get('accounts/{account}/enable', 'Banking\Accounts@enable')->name('accounts.enable');
|
||||
Route::get('accounts/{account}/disable', 'Banking\Accounts@disable')->name('accounts.disable');
|
||||
Route::get('accounts/{account}/duplicate', 'Banking\Accounts@duplicate')->name('accounts.duplicate');
|
||||
Route::get('accounts/{account}/edit', 'Banking\Accounts@edit')->name('account.edit');
|
||||
Route::resource('accounts', 'Banking\Accounts', ['middleware' => ['date.format', 'money']]);
|
||||
|
||||
Route::post('transactions/import', 'Banking\Transactions@import')->name('transactions.import');
|
||||
@ -140,7 +138,6 @@ Route::group(['prefix' => 'banking'], function () {
|
||||
|
||||
Route::resource('transactions', 'Banking\Transactions');
|
||||
|
||||
|
||||
Route::get('transfers/{transfer}/print', 'Banking\Transfers@printTransfer')->name('transfers.print');
|
||||
Route::get('transfers/{transfer}/pdf', 'Banking\Transfers@pdfTransfer')->name('transfers.pdf');
|
||||
Route::get('transfers/{transfer}/duplicate', 'Banking\Transfers@duplicate')->name('transfers.duplicate');
|
||||
|
Loading…
x
Reference in New Issue
Block a user