From 8846f7537cd55a37ee4215f85b35c60f6586b432 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 2 Nov 2022 13:48:32 +1100 Subject: [PATCH] Fixes for WePay --- app/Import/Transformer/Csv/ExpenseTransformer.php | 2 +- app/Jobs/Mail/NinjaMailerJob.php | 5 ++++- app/PaymentDrivers/WePay/ACH.php | 2 +- app/PaymentDrivers/WePay/CreditCard.php | 4 ++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/Import/Transformer/Csv/ExpenseTransformer.php b/app/Import/Transformer/Csv/ExpenseTransformer.php index ef0167c61b4d..5bca96630429 100644 --- a/app/Import/Transformer/Csv/ExpenseTransformer.php +++ b/app/Import/Transformer/Csv/ExpenseTransformer.php @@ -31,7 +31,7 @@ class ExpenseTransformer extends BaseTransformer return [ 'company_id' => $this->company->id, - 'amount' => $this->getFloat($data, 'expense.amount'), + 'amount' => abs($this->getFloat($data, 'expense.amount')), 'currency_id' => $this->getCurrencyByCode( $data, 'expense.currency_id' diff --git a/app/Jobs/Mail/NinjaMailerJob.php b/app/Jobs/Mail/NinjaMailerJob.php index 523ded2a6954..4eef63382932 100644 --- a/app/Jobs/Mail/NinjaMailerJob.php +++ b/app/Jobs/Mail/NinjaMailerJob.php @@ -133,7 +133,10 @@ class NinjaMailerJob implements ShouldQueue $this->nmo = null; $this->company = null; - app('queue.worker')->shouldQuit = 1; + + $mem_usage = memory_get_usage(); + + nlog('The script is now using: ' . round($mem_usage / 1024) . 'KBof memory.'); } catch (\Exception | \RuntimeException | \Google\Service\Exception $e) { diff --git a/app/PaymentDrivers/WePay/ACH.php b/app/PaymentDrivers/WePay/ACH.php index a4703e47875e..6c0b8a263cc2 100644 --- a/app/PaymentDrivers/WePay/ACH.php +++ b/app/PaymentDrivers/WePay/ACH.php @@ -41,7 +41,7 @@ class ACH public function authorizeView($data) { $data['gateway'] = $this->wepay_payment_driver; - $data['country_code'] = $this->wepay_payment_driver->client ? $this->wepay_payment_driver->client->country->iso_3166_2 : $this->wepay_payment_driver->company_gateway->company()->iso_3166_2; + $data['country_code'] = $this->wepay_payment_driver?->client?->country ? $this->wepay_payment_driver->client->country->iso_3166_2 : $this->wepay_payment_driver->company_gateway->company()->iso_3166_2; return render('gateways.wepay.authorize.bank_transfer', $data); } diff --git a/app/PaymentDrivers/WePay/CreditCard.php b/app/PaymentDrivers/WePay/CreditCard.php index f95d2a7855ab..0d868093dd1b 100644 --- a/app/PaymentDrivers/WePay/CreditCard.php +++ b/app/PaymentDrivers/WePay/CreditCard.php @@ -37,7 +37,7 @@ class CreditCard public function authorizeView($data) { $data['gateway'] = $this->wepay_payment_driver; - $data['country_code'] = $this->wepay_payment_driver->client ? $this->wepay_payment_driver->client->country->iso_3166_2 : $this->wepay_payment_driver->company_gateway->company()->iso_3166_2; + $data['country_code'] = $this->wepay_payment_driver?->client?->country ? $this->wepay_payment_driver->client->country->iso_3166_2 : $this->wepay_payment_driver->company_gateway->company()->iso_3166_2; return render('gateways.wepay.authorize.authorize', $data); } @@ -102,7 +102,7 @@ class CreditCard { $data['gateway'] = $this->wepay_payment_driver; $data['description'] = ctrans('texts.invoices').': '.collect($data['invoices'])->pluck('invoice_number'); - $data['country_code'] = $this->wepay_payment_driver->client ? $this->wepay_payment_driver->client->country->iso_3166_2 : $this->wepay_payment_driver->company_gateway->company()->iso_3166_2; + $data['country_code'] = $this->wepay_payment_driver?->client?->country ? $this->wepay_payment_driver->client->country->iso_3166_2 : $this->wepay_payment_driver->company_gateway->company()->iso_3166_2; return render('gateways.wepay.credit_card.pay', $data); }