Skip to content

Commit

Permalink
prevent duplicating document transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
denisdulici committed Jun 4, 2020
1 parent ef8cd32 commit 466a81c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
5 changes: 5 additions & 0 deletions app/Models/Banking/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,11 @@ public function scopeIsNotReconciled($query)
return $query->where('reconciled', 0);
}

public function onCloning($src, $child = null)
{
$this->document_id = null;
}

/**
* Convert amount to double.
*
Expand Down
10 changes: 6 additions & 4 deletions resources/views/purchases/payments/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,17 @@
<a class="dropdown-item" href="{{ route('payments.edit', $item->id) }}">{{ trans('general.edit') }}</a>
<div class="dropdown-divider"></div>
@endif
@if (empty($item->document_id))
@permission('create-purchases-payments')
<a class="dropdown-item" href="{{ route('payments.duplicate', $item->id) }}">{{ trans('general.duplicate') }}</a>
<div class="dropdown-divider"></div>
@endpermission
@endif
@if (!$item->reconciled)
@permission('delete-purchases-payments')
@if (!$item->reconciled)
<div class="dropdown-divider"></div>
{!! Form::deleteLink($item, 'payments.destroy') !!}
@endif
{!! Form::deleteLink($item, 'payments.destroy') !!}
@endpermission
@endif
</div>
</div>
</td>
Expand Down
10 changes: 6 additions & 4 deletions resources/views/sales/revenues/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,17 @@
<a class="dropdown-item" href="{{ route('revenues.edit', $item->id) }}">{{ trans('general.edit') }}</a>
<div class="dropdown-divider"></div>
@endif
@if (empty($item->document_id))
@permission('create-sales-revenues')
<a class="dropdown-item" href="{{ route('revenues.duplicate', $item->id) }}">{{ trans('general.duplicate') }}</a>
<div class="dropdown-divider"></div>
@endpermission
@endif
@if (!$item->reconciled)
@permission('delete-sales-revenues')
@if (!$item->reconciled)
<div class="dropdown-divider"></div>
{!! Form::deleteLink($item, 'revenues.destroy') !!}
@endif
{!! Form::deleteLink($item, 'revenues.destroy') !!}
@endpermission
@endif
</div>
</div>
</td>
Expand Down

0 comments on commit 466a81c

Please sign in to comment.