mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Static analysis cleanup
This commit is contained in:
parent
eff80b0187
commit
f00a89dd8b
@ -57,5 +57,6 @@ class RecurringInvoiceFactory
|
||||
$invoice->auto_bill = 'off';
|
||||
|
||||
return $invoice;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,6 @@ use App\DataMapper\BaseSettings;
|
||||
use App\Models\RecurringInvoice;
|
||||
use App\DataMapper\Tax\RuleInterface;
|
||||
use App\Utils\Traits\NumberFormatter;
|
||||
use App\DataMapper\Tax\ZipTax\Response;
|
||||
|
||||
class InvoiceItemSum
|
||||
{
|
||||
|
@ -11,7 +11,12 @@
|
||||
|
||||
namespace App\Helpers\Invoice;
|
||||
|
||||
use App\Models\Quote;
|
||||
use App\Models\Credit;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\PurchaseOrder;
|
||||
use App\Models\RecurringQuote;
|
||||
use App\Models\RecurringInvoice;
|
||||
use App\Utils\Traits\NumberFormatter;
|
||||
|
||||
class InvoiceItemSumInclusive
|
||||
@ -20,11 +25,7 @@ class InvoiceItemSumInclusive
|
||||
use Discounter;
|
||||
use Taxer;
|
||||
|
||||
protected $invoice;
|
||||
|
||||
private $items;
|
||||
|
||||
private $line_total;
|
||||
protected RecurringInvoice | Invoice | Quote | Credit | PurchaseOrder | RecurringQuote $invoice;
|
||||
|
||||
private $currency;
|
||||
|
||||
@ -36,13 +37,9 @@ class InvoiceItemSumInclusive
|
||||
|
||||
private $sub_total;
|
||||
|
||||
private $total_discount;
|
||||
|
||||
private $tax_collection;
|
||||
|
||||
private $tax_amount;
|
||||
|
||||
public function __construct($invoice)
|
||||
public function __construct(RecurringInvoice | Invoice | Quote | Credit | PurchaseOrder | RecurringQuote $invoice)
|
||||
{
|
||||
$this->tax_collection = collect([]);
|
||||
|
||||
@ -60,7 +57,6 @@ class InvoiceItemSumInclusive
|
||||
public function process()
|
||||
{
|
||||
if (! $this->invoice->line_items || ! is_array($this->invoice->line_items) || count($this->invoice->line_items) == 0) {
|
||||
$this->items = [];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@ -62,35 +62,9 @@ class PreviewController extends BaseController
|
||||
/**
|
||||
* Returns a template filled with entity variables.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*
|
||||
* @OA\Post(
|
||||
* path="/api/v1/preview",
|
||||
* operationId="getPreview",
|
||||
* tags={"preview"},
|
||||
* summary="Returns a pdf preview",
|
||||
* description="Returns a pdf preview.",
|
||||
* @OA\Parameter(ref="#/components/parameters/X-Requested-With"),
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="The pdf response",
|
||||
* @OA\Header(header="X-MINIMUM-CLIENT-VERSION", ref="#/components/headers/X-MINIMUM-CLIENT-VERSION"),
|
||||
* @OA\Header(header="X-RateLimit-Remaining", ref="#/components/headers/X-RateLimit-Remaining"),
|
||||
* @OA\Header(header="X-RateLimit-Limit", ref="#/components/headers/X-RateLimit-Limit"),
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=422,
|
||||
* description="Validation error",
|
||||
* @OA\JsonContent(ref="#/components/schemas/ValidationError"),
|
||||
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response="default",
|
||||
* description="Unexpected Error",
|
||||
* @OA\JsonContent(ref="#/components/schemas/Error"),
|
||||
* ),
|
||||
* )
|
||||
* @return mixed
|
||||
*/
|
||||
|
||||
public function show()
|
||||
{
|
||||
if (request()->has('entity') &&
|
||||
@ -177,8 +151,10 @@ class PreviewController extends BaseController
|
||||
|
||||
public function design(DesignPreviewRequest $request)
|
||||
{
|
||||
|
||||
$pdf = (new PdfMock($request->all(), auth()->user()->company()))->build()->getPdf();
|
||||
/** @var \App\Models\Company $company */
|
||||
$company = auth()->user()->company();
|
||||
|
||||
$pdf = (new PdfMock($request->all(), $company))->build()->getPdf();
|
||||
|
||||
$response = Response::make($pdf, 200);
|
||||
$response->header('Content-Type', 'application/pdf');
|
||||
@ -192,6 +168,7 @@ class PreviewController extends BaseController
|
||||
return response()->json(['message' => 'This server cannot handle this request.'], 400);
|
||||
}
|
||||
|
||||
/** @var \App\Models\Company $company */
|
||||
$company = auth()->user()->company();
|
||||
|
||||
MultiDB::setDb($company->db);
|
||||
@ -403,40 +380,47 @@ class PreviewController extends BaseController
|
||||
|
||||
private function mockEntity()
|
||||
{
|
||||
DB::connection(auth()->user()->company()->db)->beginTransaction();
|
||||
/** @var \App\Models\Company $company */
|
||||
$company = auth()->user()->company();
|
||||
|
||||
DB::connection($company->db)->beginTransaction();
|
||||
|
||||
/** @var \App\Models\Client $client */
|
||||
$client = Client::factory()->create([
|
||||
'user_id' => auth()->user()->id,
|
||||
'company_id' => auth()->user()->company()->id,
|
||||
'company_id' => $company->id,
|
||||
]);
|
||||
|
||||
/** @var \App\Models\ClientContact $contact */
|
||||
$contact = ClientContact::factory()->create([
|
||||
'user_id' => auth()->user()->id,
|
||||
'company_id' => auth()->user()->company()->id,
|
||||
'company_id' => $company->id,
|
||||
'client_id' => $client->id,
|
||||
'is_primary' => 1,
|
||||
'send_email' => true,
|
||||
]);
|
||||
|
||||
/** @var \App\Models\Invoice $invoice */
|
||||
|
||||
$invoice = Invoice::factory()->create([
|
||||
'user_id' => auth()->user()->id,
|
||||
'company_id' => auth()->user()->company()->id,
|
||||
'company_id' => $company->id,
|
||||
'client_id' => $client->id,
|
||||
'terms' => auth()->user()->company()->settings->invoice_terms,
|
||||
'footer' => auth()->user()->company()->settings->invoice_footer,
|
||||
'terms' => $company->settings->invoice_terms,
|
||||
'footer' => $company->settings->invoice_footer,
|
||||
'public_notes' => 'Sample Public Notes',
|
||||
]);
|
||||
|
||||
$invitation = InvoiceInvitation::factory()->create([
|
||||
'user_id' => auth()->user()->id,
|
||||
'company_id' => auth()->user()->company()->id,
|
||||
'company_id' => $company->id,
|
||||
'invoice_id' => $invoice->id,
|
||||
'client_contact_id' => $contact->id,
|
||||
]);
|
||||
|
||||
$invoice->setRelation('invitations', $invitation);
|
||||
$invoice->setRelation('client', $client);
|
||||
$invoice->setRelation('company', auth()->user()->company());
|
||||
$invoice->setRelation('company', $company);
|
||||
$invoice->load('client.company');
|
||||
|
||||
$design_object = json_decode(json_encode(request()->input('design')));
|
||||
@ -466,7 +450,7 @@ class PreviewController extends BaseController
|
||||
->design($design)
|
||||
->build();
|
||||
|
||||
DB::connection(auth()->user()->company()->db)->rollBack();
|
||||
DB::connection($company->db)->rollBack();
|
||||
|
||||
if (request()->query('html') == 'true') {
|
||||
return $maker->getCompiledHTML();
|
||||
@ -479,7 +463,7 @@ class PreviewController extends BaseController
|
||||
if (config('ninja.invoiceninja_hosted_pdf_generation') || config('ninja.pdf_generator') == 'hosted_ninja') {
|
||||
$pdf = (new NinjaPdf())->build($maker->getCompiledHTML(true));
|
||||
|
||||
$numbered_pdf = $this->pageNumbering($pdf, auth()->user()->company());
|
||||
$numbered_pdf = $this->pageNumbering($pdf, $company);
|
||||
|
||||
if ($numbered_pdf) {
|
||||
$pdf = $numbered_pdf;
|
||||
@ -488,8 +472,7 @@ class PreviewController extends BaseController
|
||||
return $pdf;
|
||||
}
|
||||
|
||||
|
||||
$file_path = (new PreviewPdf($maker->getCompiledHTML(true), auth()->user()->company()))->handle();
|
||||
$file_path = (new PreviewPdf($maker->getCompiledHTML(true), $company))->handle();
|
||||
|
||||
$response = Response::make($file_path, 200);
|
||||
$response->header('Content-Type', 'application/pdf');
|
||||
|
@ -51,20 +51,20 @@ use Laracasts\Presenter\PresentableTrait;
|
||||
* @property string|null $last_sent_date
|
||||
* @property string|null $due_date
|
||||
* @property bool $is_deleted
|
||||
* @property object|null $line_items
|
||||
* @property object|array $line_items
|
||||
* @property object|null $backup
|
||||
* @property string|null $footer
|
||||
* @property string|null $public_notes
|
||||
* @property string|null $private_notes
|
||||
* @property string|null $terms
|
||||
* @property string|null $tax_name1
|
||||
* @property string $tax_rate1
|
||||
* @property float $tax_rate1
|
||||
* @property string|null $tax_name2
|
||||
* @property string $tax_rate2
|
||||
* @property float $tax_rate2
|
||||
* @property string|null $tax_name3
|
||||
* @property string $tax_rate3
|
||||
* @property string $total_taxes
|
||||
* @property int $uses_inclusive_taxes
|
||||
* @property float $tax_rate3
|
||||
* @property float $total_taxes
|
||||
* @property bool $uses_inclusive_taxes
|
||||
* @property string|null $custom_value1
|
||||
* @property string|null $custom_value2
|
||||
* @property string|null $custom_value3
|
||||
@ -74,10 +74,10 @@ use Laracasts\Presenter\PresentableTrait;
|
||||
* @property string|null $custom_surcharge2
|
||||
* @property string|null $custom_surcharge3
|
||||
* @property string|null $custom_surcharge4
|
||||
* @property int $custom_surcharge_tax1
|
||||
* @property int $custom_surcharge_tax2
|
||||
* @property int $custom_surcharge_tax3
|
||||
* @property int $custom_surcharge_tax4
|
||||
* @property bool $custom_surcharge_tax1
|
||||
* @property bool $custom_surcharge_tax2
|
||||
* @property bool $custom_surcharge_tax3
|
||||
* @property bool $custom_surcharge_tax4
|
||||
* @property float $exchange_rate
|
||||
* @property float $amount
|
||||
* @property float $balance
|
||||
@ -91,11 +91,11 @@ use Laracasts\Presenter\PresentableTrait;
|
||||
* @property string|null $reminder2_sent
|
||||
* @property string|null $reminder3_sent
|
||||
* @property string|null $reminder_last_sent
|
||||
* @property int $auto_bill_enabled
|
||||
* @property string $paid_to_date
|
||||
* @property bool $auto_bill_enabled
|
||||
* @property float $paid_to_date
|
||||
* @property int|null $subscription_id
|
||||
* @property int $auto_bill_tries
|
||||
* @property int $is_proforma
|
||||
* @property bool $is_proforma
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Activity> $activities
|
||||
* @property-read int|null $activities_count
|
||||
* @property-read \App\Models\User|null $assigned_user
|
||||
|
@ -40,7 +40,7 @@ use Laracasts\Presenter\PresentableTrait;
|
||||
* @property string|null $date
|
||||
* @property string|null $due_date
|
||||
* @property bool $is_deleted
|
||||
* @property array|null $line_items
|
||||
* @property mixed $line_items
|
||||
* @property object|null $backup
|
||||
* @property string|null $footer
|
||||
* @property string|null $public_notes
|
||||
@ -83,7 +83,7 @@ use Laracasts\Presenter\PresentableTrait;
|
||||
* @property string|null $due_date_days
|
||||
* @property string|null $partial_due_date
|
||||
* @property string $exchange_rate
|
||||
* @property string $paid_to_date
|
||||
* @property float $paid_to_date
|
||||
* @property int|null $subscription_id
|
||||
* @property string|null $next_send_date_client
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Activity> $activities
|
||||
@ -182,7 +182,7 @@ use Laracasts\Presenter\PresentableTrait;
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Backup> $history
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\RecurringInvoiceInvitation> $invitations
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Invoice> $invoices
|
||||
* @property int $is_proforma
|
||||
* @property bool $is_proforma
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Activity> $activities
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Document> $documents
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Backup> $history
|
||||
|
@ -46,7 +46,7 @@ use Illuminate\Support\Carbon;
|
||||
* @property int|null $status_order
|
||||
* @property-read \App\Models\User|null $assigned_user
|
||||
* @property-read \App\Models\Client|null $client
|
||||
* @property-read \App\Models\Company $company
|
||||
* @property-read \App\Models\Company|null $company
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Document> $documents
|
||||
* @property-read int|null $documents_count
|
||||
* @property-read mixed $hashed_id
|
||||
@ -54,7 +54,6 @@ use Illuminate\Support\Carbon;
|
||||
* @property-read \App\Models\Project|null $project
|
||||
* @property-read \App\Models\TaskStatus|null $status
|
||||
* @property-read \App\Models\User $user
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel company()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel exclude($columns)
|
||||
* @method static \Database\Factories\TaskFactory factory($count = null, $state = [])
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Task filter(\App\Filters\QueryFilters $filters)
|
||||
@ -92,17 +91,6 @@ use Illuminate\Support\Carbon;
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Task withTrashed()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Task withoutTrashed()
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Document> $documents
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Document> $documents
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Document> $documents
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Document> $documents
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Document> $documents
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Document> $documents
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Document> $documents
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Document> $documents
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Document> $documents
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Document> $documents
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Document> $documents
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Document> $documents
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class Task extends BaseModel
|
||||
@ -139,7 +127,12 @@ class Task extends BaseModel
|
||||
return self::class;
|
||||
}
|
||||
|
||||
public function company()
|
||||
/**
|
||||
* Get all of the users that belong to the team.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function company(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Company::class);
|
||||
}
|
||||
|
@ -396,7 +396,7 @@ class InvoiceService
|
||||
})->toArray();
|
||||
|
||||
$this->invoice = $this->invoice->calc()->getInvoice();
|
||||
$this->invoice->service()->touchPdf();
|
||||
$this->touchPdf();
|
||||
|
||||
/* 24-03-2022 */
|
||||
$new_balance = $this->invoice->balance;
|
||||
@ -541,7 +541,7 @@ class InvoiceService
|
||||
$settings = $this->invoice->client->getMergedSettings();
|
||||
|
||||
if (! $this->invoice->design_id) {
|
||||
$this->invoice->design_id = $this->decodePrimaryKey($settings->invoice_design_id);
|
||||
$this->invoice->design_id = intval($this->decodePrimaryKey($settings->invoice_design_id));
|
||||
}
|
||||
|
||||
if (! isset($this->invoice->footer) || empty($this->invoice->footer)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user