Static analysis cleanup

This commit is contained in:
David Bomba 2025-08-28 07:48:30 +10:00
parent 39483d7c63
commit 2d30499b48
10 changed files with 83 additions and 70 deletions

View File

@ -69,21 +69,21 @@ class ReportExportController extends BaseController
}
private function isXlsxData($fileData)
{
// Check minimum size (XLSX files are typically > 1KB)
if (strlen($fileData) < 1024) {
return false;
}
// private function isXlsxData($fileData)
// {
// // Check minimum size (XLSX files are typically > 1KB)
// if (strlen($fileData) < 1024) {
// return false;
// }
// Check ZIP signature
$header = substr($fileData, 0, 4);
if ($header !== 'PK' . chr(3) . chr(4)) {
return false;
}
// // Check ZIP signature
// $header = substr($fileData, 0, 4);
// if ($header !== 'PK' . chr(3) . chr(4)) {
// return false;
// }
// Check for XLSX-specific content
return strpos($fileData, '[Content_Types].xml') !== false;
}
// // Check for XLSX-specific content
// return strpos($fileData, '[Content_Types].xml') !== false;
// }
}

View File

@ -93,80 +93,80 @@ class InvoiceTransactionEventEntryCash
*
* @param mixed $invoice
*/
private function getCancelledMetaData($invoice)
{
// private function getCancelledMetaData($invoice)
// {
$calc = $invoice->calc();
// $calc = $invoice->calc();
$details = [];
// $details = [];
$taxes = array_merge($calc->getTaxMap()->merge($calc->getTotalTaxMap())->toArray());
// $taxes = array_merge($calc->getTaxMap()->merge($calc->getTotalTaxMap())->toArray());
foreach ($taxes as $tax) {
$tax_detail = [
'tax_name' => $tax['name'],
'tax_rate' => $tax['tax_rate'],
'taxable_amount' => $tax['base_amount'] ?? $calc->getNetSubtotal(),
'tax_amount' => $this->calculateRatio($tax['total']),
'tax_amount_paid' => $this->calculateRatio($tax['total']),
'tax_amount_remaining' => 0,
];
$details[] = $tax_detail;
}
// foreach ($taxes as $tax) {
// $tax_detail = [
// 'tax_name' => $tax['name'],
// 'tax_rate' => $tax['tax_rate'],
// 'taxable_amount' => $tax['base_amount'] ?? $calc->getNetSubtotal(),
// 'tax_amount' => $this->calculateRatio($tax['total']),
// 'tax_amount_paid' => $this->calculateRatio($tax['total']),
// 'tax_amount_remaining' => 0,
// ];
// $details[] = $tax_detail;
// }
return new TransactionEventMetadata([
'tax_report' => [
'tax_details' => $details,
'payment_history' => $this->payments->toArray(),
'tax_summary' => [
'total_taxes' => $invoice->total_taxes,
'total_paid' => $this->getTotalTaxPaid($invoice),
'status' => 'cancelled',
],
],
]);
// return new TransactionEventMetadata([
// 'tax_report' => [
// 'tax_details' => $details,
// 'payment_history' => $this->payments->toArray(),
// 'tax_summary' => [
// 'total_taxes' => $invoice->total_taxes,
// 'total_paid' => $this->getTotalTaxPaid($invoice),
// 'status' => 'cancelled',
// ],
// ],
// ]);
}
// }
/**
* Set all tax details to 0
*
* @param mixed $invoice
*/
private function getDeletedMetaData($invoice)
{
// private function getDeletedMetaData($invoice)
// {
$calc = $invoice->calc();
// $calc = $invoice->calc();
$details = [];
// $details = [];
$taxes = array_merge($calc->getTaxMap()->merge($calc->getTotalTaxMap())->toArray());
// $taxes = array_merge($calc->getTaxMap()->merge($calc->getTotalTaxMap())->toArray());
foreach ($taxes as $tax) {
$tax_detail = [
'tax_name' => $tax['name'],
'tax_rate' => $tax['tax_rate'],
'taxable_amount' => $tax['base_amount'] ?? $calc->getNetSubtotal(),
'tax_amount' => $tax['total'],
'tax_amount_paid' => $this->calculateRatio($tax['total']),
'tax_amount_remaining' => 0,
];
$details[] = $tax_detail;
}
// foreach ($taxes as $tax) {
// $tax_detail = [
// 'tax_name' => $tax['name'],
// 'tax_rate' => $tax['tax_rate'],
// 'taxable_amount' => $tax['base_amount'] ?? $calc->getNetSubtotal(),
// 'tax_amount' => $tax['total'],
// 'tax_amount_paid' => $this->calculateRatio($tax['total']),
// 'tax_amount_remaining' => 0,
// ];
// $details[] = $tax_detail;
// }
return new TransactionEventMetadata([
'tax_report' => [
'tax_details' => $details,
'payment_history' => $this->payments->toArray(),
'tax_summary' => [
'total_taxes' => $invoice->total_taxes,
'total_paid' => $this->getTotalTaxPaid($invoice),0,
'status' => 'deleted',
],
],
]);
// return new TransactionEventMetadata([
// 'tax_report' => [
// 'tax_details' => $details,
// 'payment_history' => $this->payments->toArray(),
// 'tax_summary' => [
// 'total_taxes' => $invoice->total_taxes,
// 'total_paid' => $this->getTotalTaxPaid($invoice),0,
// 'status' => 'deleted',
// ],
// ],
// ]);
}
// }
private function getMetadata($invoice)
{

View File

@ -108,6 +108,7 @@ use Illuminate\Contracts\Translation\HasLocalePreference;
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\SystemLog> $system_logs
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Task> $tasks
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\RecurringInvoice> $recurring_invoices
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Location> $locations
* @method static \Illuminate\Database\Eloquent\Builder|Client exclude($columns)
* @method static \Database\Factories\ClientFactory factory($count = null, $state = [])
* @method static \Illuminate\Database\Eloquent\Builder|Client filter(\App\Filters\QueryFilters $filters)

View File

@ -93,6 +93,9 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* @property string|null $reminder3_sent
* @property string|null $reminder_last_sent
* @property float $paid_to_date
* @property int|null $location_id
* @property object|null $e_invoice
* @property object|null $tax_data
* @property int|null $subscription_id
* @property \Illuminate\Database\Eloquent\Collection<int, \App\Models\Activity> $activities
* @property int|null $activities_count

View File

@ -45,6 +45,7 @@ use App\Utils\Number;
* @property int $status_id
* @property int|null $project_id
* @property int|null $vendor_id
* @property int|null $location_id
* @property int|null $recurring_id
* @property int|null $design_id
* @property string|null $number

View File

@ -22,6 +22,8 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* @property int $id
* @property int $company_id
* @property int $user_id
* @property int|null $vendor_id
* @property int|null $client_id
* @property int|null $assigned_user_id
* @property string|null $name
* @property string|null $website

View File

@ -93,6 +93,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Document> $documents
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Invoice> $invoices
* @property \Illuminate\Database\Eloquent\Collection<int, \App\Models\Payment>|\Illuminate\Support\Collection $paymentables
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Activity> $activities
* @mixin \Eloquent
*/
class Payment extends BaseModel

View File

@ -57,6 +57,9 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
* @method static \Illuminate\Database\Eloquent\Builder|Project withoutTrashed()
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Document> $documents
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Task> $tasks
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Expense> $expenses
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Invoice> $invoices
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Quote> $quotes
* @mixin \Eloquent
*/
class Project extends BaseModel

View File

@ -42,6 +42,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* @property int $status_id
* @property int|null $project_id
* @property int|null $vendor_id
* @property int|null $location_id
* @property int|null $recurring_id
* @property int|null $design_id
* @property int|null $invoice_id

View File

@ -36,6 +36,7 @@ use App\Models\Presenters\RecurringInvoicePresenter;
* @property int|null $project_id
* @property int|null $vendor_id
* @property int $status_id
* @property int|null $location_id
* @property string|null $number
* @property float $discount
* @property bool $is_amount_discount