Skip to content

Commit

Permalink
fixed #126
Browse files Browse the repository at this point in the history
  • Loading branch information
denisdulici committed Dec 5, 2017
1 parent a2bf5cc commit 3a6f51c
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 8 deletions.
9 changes: 8 additions & 1 deletion app/Http/Controllers/Expenses/Payments.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ public function index()
$accounts = collect(Account::enabled()->pluck('name', 'id'))
->prepend(trans('general.all_type', ['type' => trans_choice('general.accounts', 2)]), '');

return view('expenses.payments.index', compact('payments', 'vendors', 'categories', 'accounts'));
$transfer_cat_id = Category::transfer();

return view('expenses.payments.index', compact('payments', 'vendors', 'categories', 'accounts', 'transfer_cat_id'));
}

/**
Expand Down Expand Up @@ -197,6 +199,11 @@ public function update(Payment $payment, Request $request)
*/
public function destroy(Payment $payment)
{
// Can't delete transfer payment
if ($payment->category->id == Category::transfer()) {
return redirect('expenses/payments');
}

$payment->delete();

$message = trans('messages.success.deleted', ['type' => trans_choice('general.payments', 1)]);
Expand Down
9 changes: 8 additions & 1 deletion app/Http/Controllers/Incomes/Revenues.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ public function index()
$accounts = collect(Account::enabled()->pluck('name', 'id'))
->prepend(trans('general.all_type', ['type' => trans_choice('general.accounts', 2)]), '');

return view('incomes.revenues.index', compact('revenues', 'customers', 'categories', 'accounts'));
$transfer_cat_id = Category::transfer();

return view('incomes.revenues.index', compact('revenues', 'customers', 'categories', 'accounts', 'transfer_cat_id'));
}

/**
Expand Down Expand Up @@ -199,6 +201,11 @@ public function update(Revenue $revenue, Request $request)
*/
public function destroy(Revenue $revenue)
{
// Can't delete transfer revenue
if ($revenue->category->id == Category::transfer()) {
return redirect('incomes/revenues');
}

$revenue->delete();

$message = trans('messages.success.deleted', ['type' => trans_choice('general.revenues', 1)]);
Expand Down
6 changes: 4 additions & 2 deletions resources/views/expenses/payments/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,24 @@
<td class="hidden-xs">{{ $item->category->name }}</td>
<td class="hidden-xs">{{ $item->account->name }}</td>
<td class="text-center">
@if ($item->category->id != $transfer_cat_id)
<div class="btn-group">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" data-toggle-position="left" aria-expanded="false">
<i class="fa fa-ellipsis-h"></i>
</button>
<ul class="dropdown-menu dropdown-menu-right">
<li><a href="{{ url('expenses/payments/' . $item->id . '/edit') }}">{{ trans('general.edit') }}</a></li>
<li class="divider"></li>
@permission('create-expenses-payments')
<li><a href="{{ url('expenses/payments/' . $item->id . '/duplicate') }}">{{ trans('general.duplicate') }}</a></li>
<li class="divider"></li>
<li><a href="{{ url('expenses/payments/' . $item->id . '/duplicate') }}">{{ trans('general.duplicate') }}</a></li>
@endpermission
@permission('delete-expenses-payments')
<li class="divider"></li>
<li>{!! Form::deleteLink($item, 'expenses/payments') !!}</li>
@endpermission
</ul>
</div>
@endif
</td>
</tr>
@endforeach
Expand Down
6 changes: 4 additions & 2 deletions resources/views/incomes/revenues/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,24 @@
<td class="hidden-xs">{{ $item->category->name }}</td>
<td class="hidden-xs">{{ $item->account->name }}</td>
<td class="text-center">
@if ($item->category->id != $transfer_cat_id)
<div class="btn-group">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" data-toggle-position="left" aria-expanded="false">
<i class="fa fa-ellipsis-h"></i>
</button>
<ul class="dropdown-menu dropdown-menu-right">
<li><a href="{{ url('incomes/revenues/' . $item->id . '/edit') }}">{{ trans('general.edit') }}</a></li>
<li class="divider"></li>
@permission('create-incomes-revenues')
<li><a href="{{ url('incomes/revenues/' . $item->id . '/duplicate') }}">{{ trans('general.duplicate') }}</a></li>
<li class="divider"></li>
<li><a href="{{ url('incomes/revenues/' . $item->id . '/duplicate') }}">{{ trans('general.duplicate') }}</a></li>
@endpermission
@permission('delete-incomes-revenues')
<li class="divider"></li>
<li>{!! Form::deleteLink($item, 'incomes/revenues') !!}</li>
@endpermission
</ul>
</div>
@endif
</td>
</tr>
@endforeach
Expand Down
5 changes: 3 additions & 2 deletions resources/views/settings/categories/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,12 @@
</button>
<ul class="dropdown-menu dropdown-menu-right">
<li><a href="{{ url('settings/categories/' . $item->id . '/edit') }}">{{ trans('general.edit') }}</a></li>
@permission('delete-settings-categories')
@if ($item->id != $transfer_id)
@permission('delete-settings-categories')
<li class="divider"></li>
<li>{!! Form::deleteLink($item, 'settings/categories') !!}</li>
@endif
@endpermission
@endif
</ul>
</div>
</td>
Expand Down

0 comments on commit 3a6f51c

Please sign in to comment.