fixed reconciliation actions
This commit is contained in:
parent
9b0d5604ba
commit
95f5c8cd73
@ -11,14 +11,14 @@ class Reconciliations extends BulkAction
|
||||
public $model = Reconciliation::class;
|
||||
|
||||
public $actions = [
|
||||
'enable' => [
|
||||
'name' => 'general.enable',
|
||||
'message' => 'bulk_actions.message.enable',
|
||||
'reconcile' => [
|
||||
'name' => 'reconciliations.reconcile',
|
||||
'message' => 'bulk_actions.message.reconcile',
|
||||
'permission' => 'update-banking-reconciliations',
|
||||
],
|
||||
'disable' => [
|
||||
'name' => 'general.disable',
|
||||
'message' => 'bulk_actions.message.disable',
|
||||
'unreconcile' => [
|
||||
'name' => 'reconciliations.unreconcile',
|
||||
'message' => 'bulk_actions.message.unreconcile',
|
||||
'permission' => 'update-banking-reconciliations',
|
||||
],
|
||||
'delete' => [
|
||||
@ -28,37 +28,41 @@ class Reconciliations extends BulkAction
|
||||
],
|
||||
];
|
||||
|
||||
public function enable($request)
|
||||
public function reconcile($request)
|
||||
{
|
||||
$reconciliations = $this->getSelectedRecords($request);
|
||||
|
||||
foreach ($reconciliations as $reconciliation) {
|
||||
$reconciliation->enabled = 1;
|
||||
$reconciliation->save();
|
||||
\DB::transaction(function () use ($reconciliation) {
|
||||
$reconciliation->reconciled = 1;
|
||||
$reconciliation->save();
|
||||
|
||||
Transaction::where('account_id', $reconciliation->account_id)
|
||||
->reconciled()
|
||||
->whereBetween('paid_at', [$reconciliation->started_at, $reconciliation->ended_at])->each(function ($item) {
|
||||
$item->reconciled = 1;
|
||||
$item->save();
|
||||
});
|
||||
Transaction::where('account_id', $reconciliation->account_id)
|
||||
->isNotReconciled()
|
||||
->whereBetween('paid_at', [$reconciliation->started_at, $reconciliation->ended_at])->each(function ($item) {
|
||||
$item->reconciled = 1;
|
||||
$item->save();
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public function disable($request)
|
||||
public function unreconcile($request)
|
||||
{
|
||||
$reconciliations = $this->getSelectedRecords($request);
|
||||
|
||||
foreach ($reconciliations as $reconciliation) {
|
||||
$reconciliation->enabled = 0;
|
||||
$reconciliation->save();
|
||||
\DB::transaction(function () use ($reconciliation) {
|
||||
$reconciliation->reconciled = 0;
|
||||
$reconciliation->save();
|
||||
|
||||
Transaction::where('account_id', $reconciliation->account_id)
|
||||
->reconciled()
|
||||
->whereBetween('paid_at', [$reconciliation->started_at, $reconciliation->ended_at])->each(function ($item) {
|
||||
$item->reconciled = 0;
|
||||
$item->save();
|
||||
});
|
||||
Transaction::where('account_id', $reconciliation->account_id)
|
||||
->isReconciled()
|
||||
->whereBetween('paid_at', [$reconciliation->started_at, $reconciliation->ended_at])->each(function ($item) {
|
||||
$item->reconciled = 0;
|
||||
$item->save();
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -67,14 +71,16 @@ class Reconciliations extends BulkAction
|
||||
$reconciliations = $this->getSelectedRecords($request);
|
||||
|
||||
foreach ($reconciliations as $reconciliation) {
|
||||
$reconciliation->delete();
|
||||
\DB::transaction(function () use ($reconciliation) {
|
||||
$reconciliation->delete();
|
||||
|
||||
Transaction::where('account_id', $reconciliation->account_id)
|
||||
->reconciled()
|
||||
->whereBetween('paid_at', [$reconciliation->started_at, $reconciliation->ended_at])->each(function ($item) {
|
||||
$item->reconciled = 0;
|
||||
$item->save();
|
||||
});
|
||||
Transaction::where('account_id', $reconciliation->account_id)
|
||||
->isReconciled()
|
||||
->whereBetween('paid_at', [$reconciliation->started_at, $reconciliation->ended_at])->each(function ($item) {
|
||||
$item->reconciled = 0;
|
||||
$item->save();
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ class DeleteReconciliation extends Job
|
||||
$this->reconciliation->delete();
|
||||
|
||||
Transaction::where('account_id', $this->reconciliation->account_id)
|
||||
->reconciled()
|
||||
->isReconciled()
|
||||
->whereBetween('paid_at', [$this->reconciliation->started_at, $this->reconciliation->ended_at])->each(function ($transaction) {
|
||||
$transaction->reconciled = 0;
|
||||
$transaction->save();
|
||||
|
@ -4,7 +4,6 @@ namespace App\Models\Banking;
|
||||
|
||||
use App\Abstracts\Model;
|
||||
use App\Models\Setting\Category;
|
||||
use App\Models\Setting\Currency;
|
||||
use App\Traits\Currencies;
|
||||
use App\Traits\DateTime;
|
||||
use App\Traits\Media;
|
||||
|
@ -16,6 +16,8 @@ return [
|
||||
'sent' => 'Are you sure you want to mark selected invoice as <b>sent</b>?|Are you sure you want to mark selected invoices as <b>sent</b>?',
|
||||
'received' => 'Are you sure you want to mark selected bill as <b>received</b>?|Are you sure you want to mark selected bills as <b>received</b>?',
|
||||
'cancelled' => 'Are you sure you want to <b>cancel</b> selected invoice/bill?|Are you sure you want to <b>cancel</b> selected invoices/bills?',
|
||||
'reconcile' => 'Are you sure you want to <b>reconcile</b> selected record?|Are you sure you want to <b>reconcile</b> selected records?',
|
||||
'unreconcile' => 'Are you sure you want to <b>unreconcile</b> selected record?|Are you sure you want to <b>unreconcile</b> selected records?',
|
||||
],
|
||||
|
||||
];
|
||||
|
@ -3,6 +3,7 @@
|
||||
return [
|
||||
|
||||
'reconcile' => 'Reconcile',
|
||||
'unreconcile' => 'Unreconcile',
|
||||
'reconciled' => 'Reconciled',
|
||||
'opening_balance' => 'Opening Balance',
|
||||
'closing_balance' => 'Closing Balance',
|
||||
|
@ -35,11 +35,11 @@
|
||||
<tr class="row table-head-line">
|
||||
<th class="col-sm-2 col-md-1 col-lg-1 d-none d-sm-block">{{ Form::bulkActionAllGroup() }}</th>
|
||||
<th class="col-sm-3 col-md-2 col-lg-2 d-none d-sm-block">@sortablelink('created_at', trans('general.created_date'), ['filter' => 'active, visible'], ['class' => 'col-aka', 'rel' => 'nofollow'])</th>
|
||||
<th class="col-xs-4 col-sm-3 col-md-3 col-lg-3">@sortablelink('account_id', trans_choice('general.accounts', 1))</th>
|
||||
<th class="col-lg-2 d-none d-lg-block">{{ trans('general.period') }}</th>
|
||||
<th class="col-xs-3 col-sm-2 col-md-2 col-lg-2">@sortablelink('account_id', trans_choice('general.accounts', 1))</th>
|
||||
<th class="col-md-2 col-lg-2 d-none d-lg-block">{{ trans('general.period') }}</th>
|
||||
<th class="col-md-2 col-lg-2 d-none d-md-block text-right">@sortablelink('closing_balance', trans('reconciliations.closing_balance'))</th>
|
||||
<th class="col-xs-4 col-sm-2 col-md-2 col-lg-1">@sortablelink('status', trans_choice('general.statuses', 1))</th>
|
||||
<th class="col-xs-4 col-sm-2 col-md-2 col-lg-1 text-center">{{ trans('general.actions') }}</th>
|
||||
<th class="col-xs-4 col-sm-2 col-md-2 col-lg-2">@sortablelink('status', trans_choice('general.statuses', 1))</th>
|
||||
<th class="col-xs-4 col-sm-2 col-md-1 col-lg-1 text-center">{{ trans('general.actions') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
@ -48,17 +48,17 @@
|
||||
<tr class="row align-items-center border-top-1">
|
||||
<td class="col-sm-2 col-md-1 col-lg-1 d-none d-sm-block">{{ Form::bulkActionGroup($item->id, $item->account->name) }}</td>
|
||||
<td class="col-sm-3 col-md-2 col-lg-2 d-none d-sm-block"><a class="col-aka" href="{{ route('reconciliations.edit', $item->id) }}">@date($item->created_at)</a></td>
|
||||
<td class="col-xs-4 col-sm-3 col-md-3 col-lg-3">{{ $item->account->name }}</td>
|
||||
<td class="col-lg-2 d-none d-lg-block border-0">@date($item->started_at) - @date($item->ended_at)</td>
|
||||
<td class="col-xs-3 col-sm-2 col-md-2 col-lg-2">{{ $item->account->name }}</td>
|
||||
<td class="col-md-2 col-lg-2 d-none d-lg-block border-0">@date($item->started_at) - @date($item->ended_at)</td>
|
||||
<td class="col-md-2 col-lg-2 d-none d-md-block text-right">@money($item->closing_balance, $item->account->currency_code, true)</td>
|
||||
<td class="col-xs-4 col-sm-2 col-md-2 col-lg-1">
|
||||
<td class="col-xs-4 col-sm-2 col-md-2 col-lg-2">
|
||||
@if ($item->reconciled)
|
||||
<span class="badge badge-pill badge-success">{{ trans('reconciliations.reconciled') }}</span>
|
||||
@else
|
||||
<span class="badge badge-pill badge-danger">{{ trans('reconciliations.unreconciled') }}</span>
|
||||
@endif
|
||||
</td>
|
||||
<td class="col-xs-4 col-sm-2 col-md-2 col-lg-1 text-center">
|
||||
<td class="col-xs-4 col-sm-2 col-md-1 col-lg-1 text-center">
|
||||
<div class="dropdown">
|
||||
<a class="btn btn-neutral btn-sm text-light items-align-center py-2" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<i class="fa fa-ellipsis-h text-muted"></i>
|
||||
|
Loading…
x
Reference in New Issue
Block a user