From 4bee89263a7569a688d979b3170df18c493af09d Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 21 Jul 2020 20:35:43 +1000 Subject: [PATCH] Fixes for credit payments --- app/Exceptions/Handler.php | 1 + app/Http/ValidationRules/Credit/ValidCreditsRules.php | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 4ce8322d45fd..79e78569714b 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -118,6 +118,7 @@ class Handler extends ExceptionHandler } elseif ($exception instanceof MethodNotAllowedHttpException && $request->expectsJson()) { return response()->json(['message'=>'Method not support for this route'], 404); } elseif ($exception instanceof ValidationException && $request->expectsJson()) { +// info(print_r($exception->validator->getMessageBag(),1)); return response()->json(['message' => 'The given data was invalid.', 'errors' => $exception->validator->getMessageBag()], 422); } elseif ($exception instanceof RelationNotFoundException && $request->expectsJson()) { return response()->json(['message' => $exception->getMessage()], 400); diff --git a/app/Http/ValidationRules/Credit/ValidCreditsRules.php b/app/Http/ValidationRules/Credit/ValidCreditsRules.php index 1cdaf11eca44..5e7a51d4522c 100644 --- a/app/Http/ValidationRules/Credit/ValidCreditsRules.php +++ b/app/Http/ValidationRules/Credit/ValidCreditsRules.php @@ -78,6 +78,10 @@ class ValidCreditsRules implements Rule } + if(count($this->input['credits']) >=1 && count($this->input['invoices']) == 0) + $this->error_msg = "You must have an invoice set when using a credit"; + return false; + return true; }