From 6a42f47c82c56bf5ec1dae7d8597e47334eaccd4 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 29 Mar 2022 11:35:17 +1100 Subject: [PATCH 1/5] Fixes for custom messages --- resources/views/portal/ninja2020/layout/app.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/portal/ninja2020/layout/app.blade.php b/resources/views/portal/ninja2020/layout/app.blade.php index fcda5464af1a..c94361b8b4e3 100644 --- a/resources/views/portal/ninja2020/layout/app.blade.php +++ b/resources/views/portal/ninja2020/layout/app.blade.php @@ -74,7 +74,7 @@ {{-- Feel free to push anything to header using @push('header') --}} @stack('head') - @if((isset($account) && $account->isPaid()) || ((bool) \App\Utils\Ninja::isSelfHost() && !empty($client->getSetting('portal_custom_head')))) + @if((isset($company) && $company->account->isPaid() && !empty($client->getSetting('portal_custom_head'))) || ((bool) \App\Utils\Ninja::isSelfHost() && !empty($client->getSetting('portal_custom_head'))))
{!! $client->getSetting('portal_custom_head') !!}
From 9c19d0094f90b3f043f1d34b5225e57f4ec76bf6 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 29 Mar 2022 11:35:45 +1100 Subject: [PATCH 2/5] Fixes for custom messages --- resources/views/portal/ninja2020/layout/app.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/portal/ninja2020/layout/app.blade.php b/resources/views/portal/ninja2020/layout/app.blade.php index c94361b8b4e3..2549dca38b7d 100644 --- a/resources/views/portal/ninja2020/layout/app.blade.php +++ b/resources/views/portal/ninja2020/layout/app.blade.php @@ -31,7 +31,7 @@ @endif - @if(isset($account) && !$account->isPaid()) + @if(isset($company->account) && !$company->account->isPaid()) @yield('meta_title', '') — Invoice Ninja @elseif(isset($company) && !is_null($company)) @yield('meta_title', '') — {{ $company->present()->name() }} From d4f2fcdffbb8d3644eff2dd5a24b2a3f3500a16c Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 29 Mar 2022 12:41:21 +1100 Subject: [PATCH 3/5] Remove domain verification for apple pay --- ...014025_reverse_apple_domain_for_hosted.php | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 database/migrations/2022_03_29_014025_reverse_apple_domain_for_hosted.php diff --git a/database/migrations/2022_03_29_014025_reverse_apple_domain_for_hosted.php b/database/migrations/2022_03_29_014025_reverse_apple_domain_for_hosted.php new file mode 100644 index 000000000000..a1174083a37d --- /dev/null +++ b/database/migrations/2022_03_29_014025_reverse_apple_domain_for_hosted.php @@ -0,0 +1,41 @@ +fields = '{"account_id":""}'; + $stripe_connect->save(); + } + } + + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + } +} From 77d5016de7c8caab2ad32cbbbe8138ecd2a7d4ba Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 29 Mar 2022 14:13:11 +1100 Subject: [PATCH 4/5] Improve client paid to date calc --- app/Services/Invoice/InvoiceService.php | 4 +++- app/Services/Invoice/MarkPaid.php | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/app/Services/Invoice/InvoiceService.php b/app/Services/Invoice/InvoiceService.php index 555432e87d49..f38e588fab3d 100644 --- a/app/Services/Invoice/InvoiceService.php +++ b/app/Services/Invoice/InvoiceService.php @@ -362,6 +362,8 @@ class InvoiceService if(!collect($this->invoice->line_items)->contains('type_id', 3)) return $this; + $pre_count = count($this->invoice->line_items); + $this->invoice->line_items = collect($this->invoice->line_items) ->reject(function ($item) { return $item->type_id == '3'; @@ -372,7 +374,7 @@ class InvoiceService /* 24-03-2022 */ $new_balance = $this->invoice->balance; - if(floatval($balance) - floatval($new_balance) != 0) + if($pre_count != count($this->invoice->line_items)) { $adjustment = $balance - $new_balance; diff --git a/app/Services/Invoice/MarkPaid.php b/app/Services/Invoice/MarkPaid.php index 5ea33b4b5cc9..4d14210d61a9 100644 --- a/app/Services/Invoice/MarkPaid.php +++ b/app/Services/Invoice/MarkPaid.php @@ -96,17 +96,17 @@ class MarkPaid extends AbstractService $payment->ledger() ->updatePaymentBalance($payment->amount * -1); - // $client = $this->invoice->client->fresh(); - // $client->paid_to_date += $payment->amount; - // $client->balance += $payment->amount * -1; - // $client->save(); + $client = $this->invoice->client->fresh(); + $client->paid_to_date += $payment->amount; + $client->balance += $payment->amount * -1; + $client->save(); - $this->invoice - ->client - ->service() - ->updateBalance($payment->amount * -1) - ->updatePaidToDate($payment->amount) - ->save(); + // $this->invoice + // ->client + // ->service() + // ->updateBalance($payment->amount * -1) + // ->updatePaidToDate($payment->amount) + // ->save(); $this->invoice = $this->invoice ->service() From 7e3f1f19ec166de580126c37d51a58075a4972a0 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 29 Mar 2022 16:07:40 +1100 Subject: [PATCH 5/5] Remove authorize method for SEPA --- app/Models/Client.php | 20 ++++++++++---------- app/PaymentDrivers/Stripe/SEPA.php | 6 ++++++ app/Services/Invoice/MarkPaid.php | 7 ------- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/app/Models/Client.php b/app/Models/Client.php index 0c7bbb3d84f9..48ce8d6c8c84 100644 --- a/app/Models/Client.php +++ b/app/Models/Client.php @@ -529,17 +529,17 @@ class Client extends BaseModel implements HasLocalePreference } - if ($this->currency()->code == 'EUR' && in_array(GatewayType::SEPA, array_column($pms, 'gateway_type_id'))) { - foreach ($pms as $pm) { - if ($pm['gateway_type_id'] == GatewayType::SEPA) { - $cg = CompanyGateway::find($pm['company_gateway_id']); + // if ($this->currency()->code == 'EUR' && in_array(GatewayType::SEPA, array_column($pms, 'gateway_type_id'))) { + // foreach ($pms as $pm) { + // if ($pm['gateway_type_id'] == GatewayType::SEPA) { + // $cg = CompanyGateway::find($pm['company_gateway_id']); - if ($cg && $cg->fees_and_limits->{GatewayType::SEPA}->is_enabled) { - return $cg; - } - } - } - } + // if ($cg && $cg->fees_and_limits->{GatewayType::SEPA}->is_enabled) { + // return $cg; + // } + // } + // } + // } if ($this->country && $this->country->iso_3166_3 == 'GBR' && in_array(GatewayType::DIRECT_DEBIT, array_column($pms, 'gateway_type_id'))) { foreach ($pms as $pm) { diff --git a/app/PaymentDrivers/Stripe/SEPA.php b/app/PaymentDrivers/Stripe/SEPA.php index afa218097f61..54578a039040 100644 --- a/app/PaymentDrivers/Stripe/SEPA.php +++ b/app/PaymentDrivers/Stripe/SEPA.php @@ -34,6 +34,12 @@ class SEPA public function authorizeView($data) { + $data['gateway'] = $this->stripe; + $data['payment_method_id'] = GatewayType::SEPA; + $data['client'] = $this->stripe->client; + $data['country'] = $this->stripe->client->country->iso_3166_2; + $data['currency'] = $this->stripe->client->currency(); + return render('gateways.stripe.sepa.authorize', $data); } diff --git a/app/Services/Invoice/MarkPaid.php b/app/Services/Invoice/MarkPaid.php index 4d14210d61a9..83cd30e3a8bd 100644 --- a/app/Services/Invoice/MarkPaid.php +++ b/app/Services/Invoice/MarkPaid.php @@ -101,13 +101,6 @@ class MarkPaid extends AbstractService $client->balance += $payment->amount * -1; $client->save(); - // $this->invoice - // ->client - // ->service() - // ->updateBalance($payment->amount * -1) - // ->updatePaidToDate($payment->amount) - // ->save(); - $this->invoice = $this->invoice ->service() ->workFlow()