From 3982fcc2b054970f6f7089d0171bb6623b504f7b Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 20 Jun 2021 07:34:30 +1000 Subject: [PATCH 1/3] Bug fix for saving report/user notifications for non-admin users --- app/Http/Controllers/CompanyUserController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/CompanyUserController.php b/app/Http/Controllers/CompanyUserController.php index 88a56570c5eb..9e54ec6300c8 100644 --- a/app/Http/Controllers/CompanyUserController.php +++ b/app/Http/Controllers/CompanyUserController.php @@ -123,8 +123,8 @@ class CompanyUserController extends BaseController if (auth()->user()->isAdmin()) { $company_user->fill($request->input('company_user')); } else { - $company_user->fill($request->input('company_user')['settings']); - $company_user->fill($request->input('company_user')['notifications']); + $company_user->settings = $request->input('company_user')['settings']; + $company_user->notifications = $request->input('company_user')['notifications']; } $company_user->save(); From 0772c05e6699126ca732a986e5560e83637e0e99 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 20 Jun 2021 07:55:47 +1000 Subject: [PATCH 2/3] Fixes for address presentation for clients --- app/Models/Presenters/ClientPresenter.php | 39 +++++++++++++++++------ 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/app/Models/Presenters/ClientPresenter.php b/app/Models/Presenters/ClientPresenter.php index 07593304303f..be0fea30a6c3 100644 --- a/app/Models/Presenters/ClientPresenter.php +++ b/app/Models/Presenters/ClientPresenter.php @@ -136,21 +136,40 @@ class ClientPresenter extends EntityPresenter return $str; } + // public function getCityState() + // { + // $settings = $this->entity->getMergedSettings(); + + // $country = false; + + // if ($settings->country_id) { + // $country = Country::find($settings->country_id); + // } + + // $swap = $country && $country->swap_postal_code; + + // $city = e($settings->city ?: ''); + // $state = e($settings->state ?: ''); + // $postalCode = e($settings->postal_code ?: ''); + + // if ($city || $state || $postalCode) { + // return $this->cityStateZip($city, $state, $postalCode, $swap); + // } else { + // return false; + // } + // } + public function getCityState() { - $settings = $this->entity->getMergedSettings(); - - $country = false; - - if ($settings->country_id) { - $country = Country::find($settings->country_id); - } + $client = $this->entity; + + $country = $client->country ?: false; $swap = $country && $country->swap_postal_code; - $city = e($settings->city ?: ''); - $state = e($settings->state ?: ''); - $postalCode = e($settings->postal_code ?: ''); + $city = e($client->city ?: ''); + $state = e($client->state ?: ''); + $postalCode = e($client->postal_code ?: ''); if ($city || $state || $postalCode) { return $this->cityStateZip($city, $state, $postalCode, $swap); From 5535ce8faffa188caecde32bfd9ffc96a44f3254 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 20 Jun 2021 08:14:56 +1000 Subject: [PATCH 3/3] Allow archived invoices to be paid. --- app/Http/Controllers/ClientPortal/InvoiceController.php | 1 + app/Http/Controllers/ClientPortal/PaymentController.php | 2 +- app/PaymentDrivers/BaseDriver.php | 2 +- app/Services/Payment/UpdateInvoicePayment.php | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/ClientPortal/InvoiceController.php b/app/Http/Controllers/ClientPortal/InvoiceController.php index 804e4cd91ade..fd32045565c5 100644 --- a/app/Http/Controllers/ClientPortal/InvoiceController.php +++ b/app/Http/Controllers/ClientPortal/InvoiceController.php @@ -89,6 +89,7 @@ class InvoiceController extends Controller { $invoices = Invoice::whereIn('id', $ids) ->whereClientId(auth()->user()->client->id) + ->withTrashed() ->get(); //filter invoices which are payable diff --git a/app/Http/Controllers/ClientPortal/PaymentController.php b/app/Http/Controllers/ClientPortal/PaymentController.php index 9eeb98227bf5..adc7f4408cda 100644 --- a/app/Http/Controllers/ClientPortal/PaymentController.php +++ b/app/Http/Controllers/ClientPortal/PaymentController.php @@ -95,7 +95,7 @@ class PaymentController extends Controller */ $payable_invoices = collect($request->payable_invoices); - $invoices = Invoice::whereIn('id', $this->transformKeys($payable_invoices->pluck('invoice_id')->toArray()))->get(); + $invoices = Invoice::whereIn('id', $this->transformKeys($payable_invoices->pluck('invoice_id')->toArray()))->withTrashed()->get(); $invoices->each(function($invoice){ $invoice->service()->removeUnpaidGatewayFees()->save(); diff --git a/app/PaymentDrivers/BaseDriver.php b/app/PaymentDrivers/BaseDriver.php index f9b940e9f302..4404bb2d86e1 100644 --- a/app/PaymentDrivers/BaseDriver.php +++ b/app/PaymentDrivers/BaseDriver.php @@ -188,7 +188,7 @@ class BaseDriver extends AbstractPaymentDriver public function attachInvoices(Payment $payment, PaymentHash $payment_hash): Payment { $paid_invoices = $payment_hash->invoices(); - $invoices = Invoice::whereIn('id', $this->transformKeys(array_column($paid_invoices, 'invoice_id')))->get(); + $invoices = Invoice::whereIn('id', $this->transformKeys(array_column($paid_invoices, 'invoice_id')))->withTrashed()->get(); $payment->invoices()->sync($invoices); $invoices->each(function ($invoice) use ($payment) { diff --git a/app/Services/Payment/UpdateInvoicePayment.php b/app/Services/Payment/UpdateInvoicePayment.php index c5155f1bcf47..1d70921764ff 100644 --- a/app/Services/Payment/UpdateInvoicePayment.php +++ b/app/Services/Payment/UpdateInvoicePayment.php @@ -37,7 +37,7 @@ class UpdateInvoicePayment { $paid_invoices = $this->payment_hash->invoices(); - $invoices = Invoice::whereIn('id', $this->transformKeys(array_column($paid_invoices, 'invoice_id')))->get(); + $invoices = Invoice::whereIn('id', $this->transformKeys(array_column($paid_invoices, 'invoice_id')))->withTrashed()->get(); collect($paid_invoices)->each(function ($paid_invoice) use ($invoices) {