prevent change/delete for reconciled records

This commit is contained in:
denisdulici
2020-03-13 14:55:50 +03:00
parent 88a3159d68
commit d46e6c44ac
6 changed files with 78 additions and 0 deletions

View File

@@ -41,6 +41,12 @@ class DeleteTransaction extends Job
*/
public function authorize()
{
if ($this->transaction->reconciled) {
$message = trans('messages.warning.reconciled_tran');
throw new \Exception($message);
}
if ($this->transaction->category->id == Category::transfer()) {
throw new \Exception('Unauthorized');
}

View File

@@ -30,6 +30,8 @@ class UpdateTransaction extends Job
*/
public function handle()
{
$this->authorize();
$this->transaction->update($this->request->all());
// Upload attachment
@@ -44,4 +46,18 @@ class UpdateTransaction extends Job
return $this->transaction;
}
/**
* Determine if this action is applicable.
*
* @return void
*/
public function authorize()
{
if ($this->transaction->reconciled) {
$message = trans('messages.warning.reconciled_tran');
throw new \Exception($message);
}
}
}