From 0c68bbe594f380833a7c87ff3796e89960f506c0 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 23 Apr 2025 13:27:03 +1000 Subject: [PATCH] Static analysis --- VERSION.txt | 2 +- app/Import/Transformer/BaseTransformer.php | 2 ++ .../Transformer/Csv/InvoiceTransformer.php | 4 --- app/Livewire/QuotesTable.php | 2 ++ .../BlockonomicsPaymentDriver.php | 33 ++++++++++--------- app/Services/Client/Statement.php | 6 ++-- .../EDocument/Gateway/Storecove/Mutator.php | 2 +- app/Services/Pdf/PdfBuilder.php | 2 +- app/Services/Report/ProjectReport.php | 8 +++-- config/ninja.php | 4 +-- 10 files changed, 33 insertions(+), 32 deletions(-) diff --git a/VERSION.txt b/VERSION.txt index 71b69c8d6a..ea9b7a6720 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -5.11.69 \ No newline at end of file +5.11.70 \ No newline at end of file diff --git a/app/Import/Transformer/BaseTransformer.php b/app/Import/Transformer/BaseTransformer.php index 2a2e0e04e0..e9a65d5bc1 100644 --- a/app/Import/Transformer/BaseTransformer.php +++ b/app/Import/Transformer/BaseTransformer.php @@ -40,6 +40,8 @@ class BaseTransformer { protected $company; + public array $error_array = []; + public function __construct($company) { $this->company = $company; diff --git a/app/Import/Transformer/Csv/InvoiceTransformer.php b/app/Import/Transformer/Csv/InvoiceTransformer.php index 9fa0974839..5142688bca 100644 --- a/app/Import/Transformer/Csv/InvoiceTransformer.php +++ b/app/Import/Transformer/Csv/InvoiceTransformer.php @@ -39,12 +39,8 @@ class InvoiceTransformer extends BaseTransformer 'sent' => Invoice::STATUS_SENT, 'draft' => Invoice::STATUS_DRAFT, 'paid' => Invoice::STATUS_PAID, - 1 => Invoice::STATUS_PAID, '1' => Invoice::STATUS_PAID, - 0 => Invoice::STATUS_SENT, '0' => Invoice::STATUS_SENT, - true => Invoice::STATUS_PAID, - false => Invoice::STATUS_SENT, 'true' => Invoice::STATUS_PAID, 'false' => Invoice::STATUS_SENT, '' => Invoice::STATUS_SENT, diff --git a/app/Livewire/QuotesTable.php b/app/Livewire/QuotesTable.php index 0c2d31ca29..da8ddf12ba 100644 --- a/app/Livewire/QuotesTable.php +++ b/app/Livewire/QuotesTable.php @@ -34,6 +34,8 @@ class QuotesTable extends Component public string $db; + public string $sort_field = 'date'; + public function mount() { MultiDB::setDb($this->db); diff --git a/app/PaymentDrivers/BlockonomicsPaymentDriver.php b/app/PaymentDrivers/BlockonomicsPaymentDriver.php index 832413249c..a774d2d12a 100644 --- a/app/PaymentDrivers/BlockonomicsPaymentDriver.php +++ b/app/PaymentDrivers/BlockonomicsPaymentDriver.php @@ -147,24 +147,25 @@ class BlockonomicsPaymentDriver extends BaseDriver return $this->payment_method->refund($payment, $amount); //this is your custom implementation from here } - public function testNewAddressGen($crypto = 'btc', $response): string - { - $api_key = $this->company_gateway->getConfigField('apiKey'); - $new_address_reset_url = $this->NEW_ADDRESS_URL . '?reset=1'; - $new_address_response = Http::withToken($api_key) - ->post($new_address_reset_url, []); - if ($new_address_response->response_code != 200) { - return isset($new_address_response->response_message) && $new_address_response->response_message - ? $new_address_response->response_message - : 'Could not generate new address'; - } + //dead code? //2025-04-23 + // public function testNewAddressGen($crypto = 'btc', $response): string + // { + // $api_key = $this->company_gateway->getConfigField('apiKey'); + // $new_address_reset_url = $this->NEW_ADDRESS_URL . '?reset=1'; + // $new_address_response = Http::withToken($api_key) + // ->post($new_address_reset_url, []); + // if ($new_address_response->response_code != 200) { + // return isset($new_address_response->response_message) && $new_address_response->response_message + // ? $new_address_response->response_message + // : 'Could not generate new address'; + // } - if (empty($new_address_response->address)) { - return 'No address returned from Blockonomics API'; - } + // if (empty($new_address_response->address)) { + // return 'No address returned from Blockonomics API'; + // } - return 'ok'; - } + // return 'ok'; + // } public function checkStores($stores): string { diff --git a/app/Services/Client/Statement.php b/app/Services/Client/Statement.php index 30677bbe7f..a11d730fd9 100644 --- a/app/Services/Client/Statement.php +++ b/app/Services/Client/Statement.php @@ -34,9 +34,7 @@ class Statement use MakesHash; use MakesDates; - /** - * @var ?Invoice - */ + /** @var Invoice|null */ protected $entity; private array $variables = []; @@ -216,7 +214,7 @@ class Statement $this->client->settings = $settings; $this->entity = \App\Models\Invoice::factory()->make(); //@phpstan-ignore-line - $this->entity->client =$this->client; + $this->entity->client =$this->client;//@phpstan-ignore-line $ii = \App\Models\InvoiceInvitation::factory()->make(); //@phpstan-ignore-line $ii->setRelation('invoice', $this->entity); //@phpstan-ignore-line $ii->setRelation('contact', $this->client->contacts->first()); //@phpstan-ignore-line diff --git a/app/Services/EDocument/Gateway/Storecove/Mutator.php b/app/Services/EDocument/Gateway/Storecove/Mutator.php index 51d47b0eee..84ee4f0ff8 100644 --- a/app/Services/EDocument/Gateway/Storecove/Mutator.php +++ b/app/Services/EDocument/Gateway/Storecove/Mutator.php @@ -595,7 +595,7 @@ class Mutator implements MutatorInterface //Regardless, always include the client email address as a route - Storecove will only use this as a fallback. $client_email = $this->getIndividualEmailRoute(); - if(strlen($client_email ?? '') > 2) + if(strlen($client_email) > 2) $this->setEmailRouting($client_email); $code = $this->getClientRoutingCode(); diff --git a/app/Services/Pdf/PdfBuilder.php b/app/Services/Pdf/PdfBuilder.php index 29b2ee4c4a..f4e3c00463 100644 --- a/app/Services/Pdf/PdfBuilder.php +++ b/app/Services/Pdf/PdfBuilder.php @@ -1651,7 +1651,7 @@ class PdfBuilder ]], ['element' => 'tr', 'properties' => [], 'elements' => [ ['element' => 'th', 'properties' => [], 'content' => ctrans('texts.statement_date')], - ['element' => 'th', 'properties' => [], 'content' => $s_date ?? ''], + ['element' => 'th', 'properties' => [], 'content' => $s_date], ]], ['element' => 'tr', 'properties' => [], 'elements' => [ ['element' => 'th', 'properties' => [], 'content' => '$balance_due_label'], diff --git a/app/Services/Report/ProjectReport.php b/app/Services/Report/ProjectReport.php index d605064617..e9de7277ce 100644 --- a/app/Services/Report/ProjectReport.php +++ b/app/Services/Report/ProjectReport.php @@ -64,7 +64,7 @@ class ProjectReport extends BaseExport $user_name = $user ? $user->present()->name() : ''; $query = \App\Models\Project::with(['invoices','expenses','tasks']) - ->where('company_id', $this->company->id); + ->where('company_id', $this->company->id); $projects = &$this->input['projects']; @@ -95,16 +95,18 @@ class ProjectReport extends BaseExport $ts = new TemplateService(); + /** @var Project $_project */ + $_project = $query->first(); + $ts_instance = $ts->setCompany($this->company) // ->setData($data) ->processData($data) ->setRawTemplate(file_get_contents(resource_path($this->template))) - ->addGlobal(['currency_code' => $query->first()->client->company->currency()->code]) + ->addGlobal(['currency_code' => $_project->client->company->currency()->code]) ->setGlobals() ->parseNinjaBlocks() ->save(); - nlog($ts_instance->getHtml()); return $ts_instance->getPdf(); } diff --git a/config/ninja.php b/config/ninja.php index 9c60c1e8d0..0d70f42c36 100644 --- a/config/ninja.php +++ b/config/ninja.php @@ -17,8 +17,8 @@ return [ 'require_https' => env('REQUIRE_HTTPS', true), 'app_url' => rtrim(env('APP_URL', ''), '/'), 'app_domain' => env('APP_DOMAIN', 'invoicing.co'), - 'app_version' => env('APP_VERSION', '5.11.69'), - 'app_tag' => env('APP_TAG', '5.11.69'), + 'app_version' => env('APP_VERSION', '5.11.70'), + 'app_tag' => env('APP_TAG', '5.11.70'), 'minimum_client_version' => '5.0.16', 'terms_version' => '1.0.1', 'api_secret' => env('API_SECRET', false),