Merge pull request #5591 from turbo124/v5-develop

Fixes for gateway fees
This commit is contained in:
David Bomba 2021-05-03 21:51:21 +10:00 committed by GitHub
commit 94a323b29b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 1 deletions

4
CODE_OF_CONDUCT.md Normal file
View File

@ -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.

View File

@ -395,7 +395,8 @@ class BaseController extends Controller
'company' => function ($query) use ($created_at, $user) { 'company' => function ($query) use ($created_at, $user) {
$query->whereNotNull('created_at')->with('documents'); $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')) if(!$user->hasPermission('view_client'))
$query->where('clients.user_id', $user->id)->orWhere('clients.assigned_user_id', $user->id); $query->where('clients.user_id', $user->id)->orWhere('clients.assigned_user_id', $user->id);

View File

@ -50,6 +50,8 @@ class InvoiceController extends Controller
{ {
set_time_limit(0); set_time_limit(0);
$invoice->service()->removeUnpaidGatewayFees()->save();
$data = [ $data = [
'invoice' => $invoice, 'invoice' => $invoice,
]; ];

View File

@ -97,6 +97,10 @@ class PaymentController extends Controller
$payable_invoices = collect($request->payable_invoices); $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()))->get();
$invoices->each(function($invoice){
$invoice->service()->removeUnpaidGatewayFees()->save();
});
/* pop non payable invoice from the $payable_invoices array */ /* pop non payable invoice from the $payable_invoices array */
$payable_invoices = $payable_invoices->filter(function ($payable_invoice) use ($invoices) { $payable_invoices = $payable_invoices->filter(function ($payable_invoice) use ($invoices) {

View File

@ -110,6 +110,7 @@ class InvoiceService
public function addGatewayFee(CompanyGateway $company_gateway, $gateway_type_id, float $amount) public function addGatewayFee(CompanyGateway $company_gateway, $gateway_type_id, float $amount)
{ {
$this->invoice = (new AddGatewayFee($company_gateway, $gateway_type_id, $this->invoice, $amount))->run(); $this->invoice = (new AddGatewayFee($company_gateway, $gateway_type_id, $this->invoice, $amount))->run();
return $this; return $this;