From 10a6f7755b28bef6a227fe58460c02ba8c73e004 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 4 Nov 2023 09:53:20 +1100 Subject: [PATCH] Minor fixes for validation --- app/Filters/ExpenseFilters.php | 3 +++ .../RecurringInvoice/StoreRecurringInvoiceRequest.php | 2 ++ app/PaymentDrivers/GoCardlessPaymentDriver.php | 4 +++- app/Repositories/BaseRepository.php | 2 +- app/Services/Template/TemplateService.php | 2 +- config/ninja.php | 2 +- 6 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/Filters/ExpenseFilters.php b/app/Filters/ExpenseFilters.php index 264be55d037e..c9cddb8dc793 100644 --- a/app/Filters/ExpenseFilters.php +++ b/app/Filters/ExpenseFilters.php @@ -41,6 +41,9 @@ class ExpenseFilters extends QueryFilters ->orWhere('custom_value4', 'like', '%'.$filter.'%') ->orWhereHas('category', function ($q) use ($filter) { $q->where('name', 'like', '%'.$filter.'%'); + }) + ->orWhereHas('vendor', function ($q) use ($filter) { + $q->where('name', 'like', '%'.$filter.'%'); }); }); } diff --git a/app/Http/Requests/RecurringInvoice/StoreRecurringInvoiceRequest.php b/app/Http/Requests/RecurringInvoice/StoreRecurringInvoiceRequest.php index 1ad00da30ce2..9ad7e9ec79ea 100644 --- a/app/Http/Requests/RecurringInvoice/StoreRecurringInvoiceRequest.php +++ b/app/Http/Requests/RecurringInvoice/StoreRecurringInvoiceRequest.php @@ -82,6 +82,8 @@ class StoreRecurringInvoiceRequest extends Request public function prepareForValidation() { $input = $this->all(); + $input['amount'] = 0; + $input['balance'] = 0; if (array_key_exists('due_date_days', $input) && is_null($input['due_date_days'])) { $input['due_date_days'] = 'terms'; diff --git a/app/PaymentDrivers/GoCardlessPaymentDriver.php b/app/PaymentDrivers/GoCardlessPaymentDriver.php index c91cd68d1fea..6ab26b96fe1c 100644 --- a/app/PaymentDrivers/GoCardlessPaymentDriver.php +++ b/app/PaymentDrivers/GoCardlessPaymentDriver.php @@ -404,7 +404,9 @@ class GoCardlessPaymentDriver extends BaseDriver $this->init(); $mandate = $this->gateway->mandates()->get($token); - if ($mandate->status !== 'active') { + if(!in_array($mandate->status, ['pending_submission', 'submitted', 'active','pending_customer_approval'])) { + + // if ($mandate->status !== 'active') { throw new \Exception(ctrans('texts.gocardless_mandate_not_ready')); } } catch (\Exception $exception) { diff --git a/app/Repositories/BaseRepository.php b/app/Repositories/BaseRepository.php index 68ccb310cf9a..2fc13b4ff3db 100644 --- a/app/Repositories/BaseRepository.php +++ b/app/Repositories/BaseRepository.php @@ -199,7 +199,7 @@ class BaseRepository }); } } - +nlog($model->toArray()); $model->saveQuietly(); /* Model now persisted, now lets do some child tasks */ diff --git a/app/Services/Template/TemplateService.php b/app/Services/Template/TemplateService.php index e263ca11172b..c5b783b51399 100644 --- a/app/Services/Template/TemplateService.php +++ b/app/Services/Template/TemplateService.php @@ -522,7 +522,7 @@ class TemplateService 'balance_raw' => ($payment->amount - $payment->refunded - $payment->applied), 'date' => $this->translateDate($payment->date, $payment->client->date_format(), $payment->client->locale()), 'method' => $payment->translatedType(), - 'currency' => $payment->currency->code ?? $this->company->currency()->code, + 'currency' => $payment->currency->code ?? $payment->company->currency()->code, 'exchange_rate' => $payment->exchange_rate, 'transaction_reference' => $payment->transaction_reference, 'is_manual' => $payment->is_manual, diff --git a/config/ninja.php b/config/ninja.php index bdfb27ba161f..1ee99ea4d397 100644 --- a/config/ninja.php +++ b/config/ninja.php @@ -19,7 +19,7 @@ return [ 'app_tag' => env('APP_TAG','5.7.42'), 'minimum_client_version' => '5.0.16', 'terms_version' => '1.0.1', - 'api_secret' => env('API_SECRET', ''), + 'api_secret' => env('API_SECRET', false), 'google_maps_api_key' => env('GOOGLE_MAPS_API_KEY'), 'google_analytics_url' => env('GOOGLE_ANALYTICS_URL', 'https://www.google-analytics.com/collect'), 'key_length' => 32,