Exists transaction number issue fixed
This commit is contained in:
		@@ -5,19 +5,24 @@ namespace App\Jobs\Banking;
 | 
			
		||||
use App\Abstracts\Job;
 | 
			
		||||
use App\Interfaces\Job\ShouldUpdate;
 | 
			
		||||
use App\Models\Document\Document;
 | 
			
		||||
use App\Traits\Transactions;
 | 
			
		||||
use Illuminate\Support\Facades\DB;
 | 
			
		||||
use Illuminate\Support\Str;
 | 
			
		||||
 | 
			
		||||
class SplitTransaction extends Job implements ShouldUpdate
 | 
			
		||||
{
 | 
			
		||||
    use Transactions;
 | 
			
		||||
 | 
			
		||||
    public function handle(): array
 | 
			
		||||
    {
 | 
			
		||||
        $this->checkAmount();
 | 
			
		||||
 | 
			
		||||
        \DB::transaction(function () {
 | 
			
		||||
        DB::transaction(function () {
 | 
			
		||||
            foreach ($this->request->items as $item) {
 | 
			
		||||
                $transaction = $this->model->duplicate();
 | 
			
		||||
                $transaction->split_id = $this->model->id;
 | 
			
		||||
                $transaction->amount = $item['amount'];
 | 
			
		||||
                $transaction            = $this->model->duplicate();
 | 
			
		||||
                $transaction->number    = $this->getNextTransactionNumber();
 | 
			
		||||
                $transaction->split_id  = $this->model->id;
 | 
			
		||||
                $transaction->amount    = $item['amount'];
 | 
			
		||||
                $transaction->save();
 | 
			
		||||
 | 
			
		||||
                $item['split'] = $transaction;
 | 
			
		||||
@@ -58,7 +63,10 @@ class SplitTransaction extends Job implements ShouldUpdate
 | 
			
		||||
        if ($compare !== 0) {
 | 
			
		||||
            $error_amount = $this->model->amount;
 | 
			
		||||
 | 
			
		||||
            $message = trans('messages.error.same_amount', ['transaction' => ucfirst(trans_choice('general.' . Str::plural($this->model->type), 1)), 'amount' => money($error_amount, $this->model->currency_code, true)]);
 | 
			
		||||
            $message = trans('messages.error.same_amount', [
 | 
			
		||||
                'transaction' => ucfirst(trans_choice('general.' . Str::plural($this->model->type), 1)),
 | 
			
		||||
                'amount' => money($error_amount, $this->model->currency_code, true)
 | 
			
		||||
            ]);
 | 
			
		||||
 | 
			
		||||
            throw new \Exception($message);
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user