From ade5472d9ea853735f9b8e74e06e0a5f5298d274 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 3 May 2021 21:23:39 +1000 Subject: [PATCH 1/2] Code of Conduct --- CODE_OF_CONDUCT.md | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 CODE_OF_CONDUCT.md diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 000000000000..8aab1edc58db --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,4 @@ +# Invoice Ninja Code of Conduct + +The development team has invested a tremendous amount of time and energy into this project. While we appreciate that bugs can be frustrating we ask that our community refrain from insults and snide remarks. We're happy to provide support to both our hosted and selfhosted communities but ask that feedback is always polite. + From 5510993d133b9caa5fd383df1fef76b328afab6f Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 3 May 2021 21:51:00 +1000 Subject: [PATCH 2/2] Fixes for gateway fees --- app/Http/Controllers/BaseController.php | 3 ++- app/Http/Controllers/ClientPortal/InvoiceController.php | 2 ++ app/Http/Controllers/ClientPortal/PaymentController.php | 4 ++++ app/Services/Invoice/InvoiceService.php | 1 + 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/BaseController.php b/app/Http/Controllers/BaseController.php index aec442c9c184..9b03936b5722 100644 --- a/app/Http/Controllers/BaseController.php +++ b/app/Http/Controllers/BaseController.php @@ -395,7 +395,8 @@ class BaseController extends Controller 'company' => function ($query) use ($created_at, $user) { $query->whereNotNull('created_at')->with('documents'); }, - 'company.clients' => function ($query) use ($user) { + 'company.clients' => function ($query) use ($created_at, $user) { + $query->where('clients.created_at', '>=', $created_at)->with('contacts.company', 'gateway_tokens', 'documents'); if(!$user->hasPermission('view_client')) $query->where('clients.user_id', $user->id)->orWhere('clients.assigned_user_id', $user->id); diff --git a/app/Http/Controllers/ClientPortal/InvoiceController.php b/app/Http/Controllers/ClientPortal/InvoiceController.php index 2300600714c0..9746863da046 100644 --- a/app/Http/Controllers/ClientPortal/InvoiceController.php +++ b/app/Http/Controllers/ClientPortal/InvoiceController.php @@ -50,6 +50,8 @@ class InvoiceController extends Controller { set_time_limit(0); + $invoice->service()->removeUnpaidGatewayFees()->save(); + $data = [ 'invoice' => $invoice, ]; diff --git a/app/Http/Controllers/ClientPortal/PaymentController.php b/app/Http/Controllers/ClientPortal/PaymentController.php index 6d17c3daff54..8531c36fefb1 100644 --- a/app/Http/Controllers/ClientPortal/PaymentController.php +++ b/app/Http/Controllers/ClientPortal/PaymentController.php @@ -97,6 +97,10 @@ class PaymentController extends Controller $payable_invoices = collect($request->payable_invoices); $invoices = Invoice::whereIn('id', $this->transformKeys($payable_invoices->pluck('invoice_id')->toArray()))->get(); + $invoices->each(function($invoice){ + $invoice->service()->removeUnpaidGatewayFees()->save(); + }); + /* pop non payable invoice from the $payable_invoices array */ $payable_invoices = $payable_invoices->filter(function ($payable_invoice) use ($invoices) { diff --git a/app/Services/Invoice/InvoiceService.php b/app/Services/Invoice/InvoiceService.php index 4ae0787809df..3531e0d266f5 100644 --- a/app/Services/Invoice/InvoiceService.php +++ b/app/Services/Invoice/InvoiceService.php @@ -110,6 +110,7 @@ class InvoiceService public function addGatewayFee(CompanyGateway $company_gateway, $gateway_type_id, float $amount) { + $this->invoice = (new AddGatewayFee($company_gateway, $gateway_type_id, $this->invoice, $amount))->run(); return $this;