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

@@ -27,6 +27,8 @@ class DeleteBill extends Job
*/
public function handle()
{
$this->authorize();
Transaction::mute();
$this->deleteRelationships($this->bill, [
@@ -39,4 +41,18 @@ class DeleteBill extends Job
return true;
}
/**
* Determine if this action is applicable.
*
* @return void
*/
public function authorize()
{
if ($this->bill->transactions()->isReconciled()->count()) {
$message = trans('messages.warning.reconciled_doc', ['type' => trans_choice('general.bills', 1)]);
throw new \Exception($message);
}
}
}