From 4921eadc891db6e60d3e18f2e12565a95acc1d92 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 23 Apr 2024 12:45:43 +1000 Subject: [PATCH] Updates for client reports --- app/Export/CSV/ClientExport.php | 13 ++++- app/Http/Controllers/EmailController.php | 2 +- .../PayPalRestPaymentDriver.php | 2 +- app/PaymentDrivers/Stripe/BankTransfer.php | 26 ++++++++- app/PaymentDrivers/StripePaymentDriver.php | 3 +- .../bank_transfer/bank_details.blade.php | 54 ++++++++++++++++++- 6 files changed, 93 insertions(+), 7 deletions(-) diff --git a/app/Export/CSV/ClientExport.php b/app/Export/CSV/ClientExport.php index c579b34eea..dda304bc99 100644 --- a/app/Export/CSV/ClientExport.php +++ b/app/Export/CSV/ClientExport.php @@ -41,7 +41,6 @@ class ClientExport extends BaseExport 'balance' => 'client.balance', 'city' => 'client.city', 'country' => 'client.country_id', - 'credit_balance' => 'client.credit_balance', 'custom_value1' => 'client.custom_value1', 'custom_value2' => 'client.custom_value2', 'custom_value3' => 'client.custom_value3', @@ -229,6 +228,18 @@ class ClientExport extends BaseExport $entity['client.classification'] = ctrans("texts.{$client->classification}") ?? ''; } + if (in_array('client.industry_id', $this->input['report_keys']) && isset($client->industry_id)) { + $entity['client.industry_id'] = ctrans("texts.industry_{$client->industry->name}") ?? ''; + } + + if (in_array('client.country_id', $this->input['report_keys']) && isset($client->country_id)) { + $entity['client.country_id'] = $client->country->full_name; + } + + if (in_array('client.shipping_country_id', $this->input['report_keys']) && isset($client->shipping_country_id)) { + $entity['client.shipping_country_id'] = $client->shipping_country->full_name; + } + return $entity; } diff --git a/app/Http/Controllers/EmailController.php b/app/Http/Controllers/EmailController.php index e6a837ec64..06cda32333 100644 --- a/app/Http/Controllers/EmailController.php +++ b/app/Http/Controllers/EmailController.php @@ -70,7 +70,7 @@ class EmailController extends BaseController /** @var \App\Models\User $user */ $user = auth()->user(); - if ($request->cc_email && (Ninja::isSelfHost() || $user->account->isPaidHostedClient())) { + if ($request->cc_email && (Ninja::isSelfHost() || $user->account->isPremium())) { foreach($request->cc_email as $email) { $mo->cc[] = new Address($email); diff --git a/app/PaymentDrivers/PayPalRestPaymentDriver.php b/app/PaymentDrivers/PayPalRestPaymentDriver.php index 247d586843..15846cbcc9 100644 --- a/app/PaymentDrivers/PayPalRestPaymentDriver.php +++ b/app/PaymentDrivers/PayPalRestPaymentDriver.php @@ -251,7 +251,7 @@ return render('gateways.paypal.ppcp.card', $data); nlog($response); $data = [ - 'payment_type' => $this->getPaymentMethod($this->gateway_type_id), + 'payment_type' => $this->getPaymentMethod($request->gateway_type_id), 'amount' => $response['purchase_units'][0]['payments']['captures'][0]['amount']['value'], 'transaction_reference' => $response['purchase_units'][0]['payments']['captures'][0]['id'], 'gateway_type_id' => $this->gateway_type_id, diff --git a/app/PaymentDrivers/Stripe/BankTransfer.php b/app/PaymentDrivers/Stripe/BankTransfer.php index acea334a01..d5f02d0858 100644 --- a/app/PaymentDrivers/Stripe/BankTransfer.php +++ b/app/PaymentDrivers/Stripe/BankTransfer.php @@ -76,7 +76,7 @@ class BankTransfer /** * Resolve the bank type based on the currency * - * @return void + * @return array */ private function resolveBankType() { @@ -85,6 +85,7 @@ class BankTransfer 'EUR' => ['type' => 'eu_bank_transfer', 'eu_bank_transfer' => ['country' => $this->stripe->client->country->iso_3166_2]], 'JPY' => ['type' => 'jp_bank_transfer'], 'MXN' => ['type' => 'mx_bank_transfer'], + 'USD' => ['type' => 'us_bank_transfer'], }; } @@ -133,6 +134,7 @@ class BankTransfer 'gbp' => $data['bank_details'] = $this->formatDataforUk($pi), 'eur' => $data['bank_details'] = $this->formatDataforEur($pi), 'jpy' => $data['bank_details'] = $this->formatDataforJp($pi), + 'usd' => $data['bank_details'] = $this->formatDataforUs($pi), }; $payment = $this->processSuccesfulRedirect($pi); @@ -233,6 +235,28 @@ class BankTransfer } + /** + * + * @param PaymentIntent $pi + * @return array + */ + public function formatDataforUs(PaymentIntent $pi): array + { + return [ + 'amount' => Number::formatMoney($this->stripe->convertFromStripeAmount($pi->next_action->display_bank_transfer_instructions->amount_remaining, $this->stripe->client->currency()->precision, $this->stripe->client->currency()), $this->stripe->client), + 'account_holder_name' => $pi->next_action->display_bank_transfer_instructions->financial_addresses[0]->aba->bank_name, + 'account_number' => $pi->next_action->display_bank_transfer_instructions->financial_addresses[0]->aba->account_number, + 'bank_name' => $pi->next_action->display_bank_transfer_instructions->financial_addresses[0]->aba->bank_name, + 'sort_code' => $pi->next_action->display_bank_transfer_instructions->financial_addresses[0]->aba->routing_number, + 'reference' => $pi->next_action->display_bank_transfer_instructions->reference, + 'description' => $pi->description, + 'gateway' => $this->stripe->company_gateway, + 'currency' => $pi->next_action->display_bank_transfer_instructions->currency, + + ]; + } + + /** * processSuccesfulRedirect * diff --git a/app/PaymentDrivers/StripePaymentDriver.php b/app/PaymentDrivers/StripePaymentDriver.php index c0d35cc59e..92f98bb5b6 100644 --- a/app/PaymentDrivers/StripePaymentDriver.php +++ b/app/PaymentDrivers/StripePaymentDriver.php @@ -271,7 +271,8 @@ class StripePaymentDriver extends BaseDriver (in_array($this->client->country->iso_3166_2, ['FR', 'IE', 'NL', 'DE', 'ES']) && $this->client->currency()->code == 'EUR') || ($this->client->country->iso_3166_2 == 'JP' && $this->client->currency()->code == 'JPY') || ($this->client->country->iso_3166_2 == 'MX' && $this->client->currency()->code == 'MXN') || - ($this->client->country->iso_3166_2 == 'GB' && $this->client->currency()->code == 'GBP') + ($this->client->country->iso_3166_2 == 'GB' && $this->client->currency()->code == 'GBP') || + ($this->client->country->iso_3166_2 == 'US' && $this->client->currency()->code == 'USD') ) ) { $types[] = GatewayType::DIRECT_DEBIT; diff --git a/resources/views/portal/ninja2020/gateways/stripe/bank_transfer/bank_details.blade.php b/resources/views/portal/ninja2020/gateways/stripe/bank_transfer/bank_details.blade.php index 82d1d4a2fd..21fd2d92f9 100644 --- a/resources/views/portal/ninja2020/gateways/stripe/bank_transfer/bank_details.blade.php +++ b/resources/views/portal/ninja2020/gateways/stripe/bank_transfer/bank_details.blade.php @@ -172,7 +172,7 @@ @elseif($bank_details['currency'] == 'eur') -
+
{{ ctrans('texts.account_name') }}
@@ -214,7 +214,57 @@ {{ ctrans('texts.stripe_direct_debit_details') }}
- @endif + @elseif($bank_details['currency'] == 'usd') + +
+ {{ ctrans('texts.bank_name') }} +
+
+ {{ $bank_details['bank_name'] }} +
+ +
+ {{ ctrans('texts.account_number') }} +
+
+ {{ $bank_details['account_number'] }} +
+ +
+ {{ ctrans('texts.routing_number') }} +
+
+ {{ $bank_details['sort_code'] }} +
+ +
+ {{ ctrans('texts.reference') }} +
+
+ {{ $bank_details['reference'] }} +
+ +
+ Network +
+
+ ACH / Domestic Wire US +
+ +
+ {{ ctrans('texts.balance_due') }} +
+
+ {{ $bank_details['amount'] }} +
+ +
+
+
+ {{ ctrans('texts.stripe_direct_debit_details') }} +
+ + @endif