Static analysis cleanup

This commit is contained in:
David Bomba 2025-05-01 10:26:02 +10:00
parent 11a7550578
commit 5338ee13a8
9 changed files with 61 additions and 21 deletions

View File

@ -1506,6 +1506,7 @@ class BaseExport
public function processMetaData(array $row, $resource): array public function processMetaData(array $row, $resource): array
{ {
nlog($row);
$class = get_class($resource); $class = get_class($resource);
$entity = ''; $entity = '';

View File

@ -199,11 +199,18 @@ class InvoiceExport extends BaseExport
$entity[$key] = $transformed_invoice[$parts[1]]; $entity[$key] = $transformed_invoice[$parts[1]];
} elseif ($decorated_value = $this->decorator->transform($key, $invoice)) { } elseif ($decorated_value = $this->decorator->transform($key, $invoice)) {
$entity[$key] = $decorated_value; $entity[$key] = $decorated_value;
} elseif (count($this->tax_names) > 0) { } else {
$entity[$key] = '';
}
}
if (count($this->tax_names) > 0) {
$calc = $invoice->calc(); $calc = $invoice->calc();
$taxes = $calc->getTaxMap()->merge($calc->getTotalTaxMap())->toArray(); $taxes = $calc->getTaxMap()->merge($calc->getTotalTaxMap())->toArray();
nlog($this->tax_names);
foreach ($this->tax_names as $tax_name) { foreach ($this->tax_names as $tax_name) {
$entity[$tax_name] = 0; $entity[$tax_name] = 0;
} }
@ -213,7 +220,6 @@ class InvoiceExport extends BaseExport
} }
} }
}
$entity = $this->decorateAdvancedFields($invoice, $entity); $entity = $this->decorateAdvancedFields($invoice, $entity);

View File

@ -18,6 +18,7 @@ class InvoiceDecorator extends Decorator implements DecoratorInterface
{ {
public function transform(string $key, mixed $entity): mixed public function transform(string $key, mixed $entity): mixed
{ {
$invoice = false; $invoice = false;
if ($entity instanceof Invoice) { if ($entity instanceof Invoice) {

View File

@ -101,8 +101,11 @@ class Nordigen
return Arr::first( return Arr::first(
$this->client->endUserAgreement->getEndUserAgreements()['results'], $this->client->endUserAgreement->getEndUserAgreements()['results'],
function (array $eua) use ($institutionId, $requiredScopes, $accessDays, $txDays): bool { function (array $eua) use ($institutionId, $requiredScopes, $accessDays, $txDays): bool {
$isNotExpired = !isset($eua['status']) || $eua['status'] !== 'EXPIRED';
return $eua['institution_id'] === $institutionId return $eua['institution_id'] === $institutionId
&& $eua['accepted'] === null && $eua['accepted'] === null
&& $isNotExpired
&& $eua['max_historical_days'] >= $txDays && $eua['max_historical_days'] >= $txDays
&& $eua['access_valid_for_days'] >= $accessDays && $eua['access_valid_for_days'] >= $accessDays
&& !array_diff($requiredScopes, $eua['access_scope'] ?? []); && !array_diff($requiredScopes, $eua['access_scope'] ?? []);

View File

@ -80,8 +80,12 @@ class NordigenController extends BaseController
try { try {
$txDays = $data['tx_days'] ?? 0; //@phpstan-ignore-line $txDays = $data['tx_days'] ?? 0; //@phpstan-ignore-line
$agreement = $nordigen->firstValidAgreement($institution['id'], $data['access_days'] ?? 0, $txDays)
?? $nordigen->createAgreement($institution, $data['access_days'] ?? 9999, $txDays); $agreement = $nordigen->createAgreement($institution, $data['access_days'] ?? 9999, $txDays);
//this does not work in a multi tenant environment, it simply grabs the first agreement, without differentiating between companies. we may need to store the current requistion...
// $agreement = $nordigen->firstValidAgreement($institution['id'], $data['access_days'] ?? 0, $txDays)
// ?? $nordigen->createAgreement($institution, $data['access_days'] ?? 9999, $txDays);
} catch (\Exception $e) { } catch (\Exception $e) {
$debug = "{$e->getMessage()} ({$e->getCode()})"; $debug = "{$e->getMessage()} ({$e->getCode()})";
@ -95,7 +99,7 @@ class NordigenController extends BaseController
$requisition = $nordigen->createRequisition( $requisition = $nordigen->createRequisition(
config('ninja.app_url') . '/nordigen/confirm', config('ninja.app_url') . '/nordigen/confirm',
$institution, $institution,
$agreement, $agreement, //@phpstan-ignore-line
$request->token, $request->token,
$lang, $lang,
); );

View File

@ -117,7 +117,7 @@ class StoreClientRequest extends Request
$settings = (array)ClientSettings::defaults(); $settings = (array)ClientSettings::defaults();
/* Stub settings if they don't exist */ /* Stub settings if they don't exist */
if (!array_key_exists('settings', $input)) { if (!array_key_exists('settings', $input) || is_null($input['settings'])) {
$input['settings'] = []; $input['settings'] = [];
} elseif (is_object($input['settings'])) { } elseif (is_object($input['settings'])) {
$input['settings'] = (array)$input['settings']; $input['settings'] = (array)$input['settings'];

View File

@ -29,6 +29,7 @@ class PreviewReport implements ShouldQueue
use Queueable; use Queueable;
use SerializesModels; use SerializesModels;
public $tries = 1;
/** /**
* Create a new job instance * Create a new job instance
*/ */
@ -52,8 +53,23 @@ class PreviewReport implements ShouldQueue
Cache::put($this->hash, $report, 60 * 60); Cache::put($this->hash, $report, 60 * 60);
} }
public function middleware() // public function middleware()
// {
// return [
// (new WithoutOverlapping("report-{$this->company->company_key}-{$this->report_class}"))
// ->releaseAfter(60)
// ->expireAfter(60) // 5 minutes
// ->dontRelease(), // This prevents the job from being marked as a "release" which counts towards attempts
// ];
// }
/**
* Handle a job failure.
*/
public function failed(\Throwable $exception = null)
{ {
return [new WithoutOverlapping("report-{$this->company->company_key}-{$this->report_class}")]; if($exception) {
nlog("EXCEPTION:: PreviewReport:: could not preview report for" . $exception->getMessage());
}
} }
} }

View File

@ -45,6 +45,8 @@ class SendToAdmin implements ShouldQueue
protected string $file_name; protected string $file_name;
public $tries = 1;
/** /**
* Create a new job instance. * Create a new job instance.
*/ */
@ -90,8 +92,15 @@ class SendToAdmin implements ShouldQueue
} }
public function middleware() // public function middleware()
// {
// return [(new WithoutOverlapping("report-{$this->company->company_key}-{$this->report_class}"))->expireAfter(60)];
// }
public function failed(\Throwable $exception = null)
{ {
return [new WithoutOverlapping("report-{$this->company->company_key}-{$this->report_class}")]; if($exception) {
nlog("EXCEPTION:: SendToAdmin:: could not email report for" . $exception->getMessage());
}
} }
} }

View File

@ -92,7 +92,7 @@ class PdfService
try { try {
$html = $this->getHtml(); $html = $this->getHtml();
nlog($html); // nlog($html);
$pdf = $this->resolvePdfEngine($html); $pdf = $this->resolvePdfEngine($html);
$numbered_pdf = $this->pageNumbering($pdf, $this->company); $numbered_pdf = $this->pageNumbering($pdf, $this->company);