1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 00:11:35 +02:00

Static Analysis + ACSS

This commit is contained in:
David Bomba 2024-06-17 16:08:06 +10:00
parent 11e082d443
commit 13405c1805
18 changed files with 19 additions and 204 deletions

View File

@ -693,7 +693,7 @@ class CompanyController extends BaseController
public function updateOriginTaxData(DefaultCompanyRequest $request, Company $company)
{
if($company->settings->country_id == "840" && !$company?->account->isFreeHostedClient()) {
if($company->settings->country_id == "840" && !$company->account->isFreeHostedClient()) {
try {
(new CompanyTaxRate($company))->handle();
} catch(\Exception $e) {

View File

@ -119,8 +119,6 @@ class CompanyUserController extends BaseController
if (! $company_user) {
throw new ModelNotFoundException(ctrans('texts.company_user_not_found'));
return;
}
if ($auth_user->isAdmin()) {
@ -152,7 +150,6 @@ class CompanyUserController extends BaseController
if (! $company_user) {
throw new ModelNotFoundException(ctrans('texts.company_user_not_found'));
return;
}
$this->entity_type = User::class;

View File

@ -594,13 +594,11 @@ class CreditController extends BaseController
$credit->service()->markPaid()->save();
return $this->itemResponse($credit);
break;
case 'clone_to_credit':
$credit = CloneCreditFactory::create($credit, auth()->user()->id);
return $this->itemResponse($credit);
break;
case 'history':
// code...
break;
@ -617,7 +615,7 @@ class CreditController extends BaseController
return response()->streamDownload(function () use ($file) {
echo $file;
}, $credit->numberFormatter() . '.pdf', ['Content-Type' => 'application/pdf']);
break;
case 'archive':
$this->credit_repository->archive($credit);
@ -655,7 +653,6 @@ class CreditController extends BaseController
default:
return response()->json(['message' => ctrans('texts.action_unavailable', ['action' => $action])], 400);
break;
}
}

View File

@ -139,19 +139,19 @@ class EmailController extends BaseController
return $this->itemResponse($entity_obj->fresh());
}
private function sendPurchaseOrder($entity_obj, $data, $template)
{
$this->entity_type = PurchaseOrder::class;
// private function sendPurchaseOrder($entity_obj, $data, $template)
// {
// $this->entity_type = PurchaseOrder::class;
$this->entity_transformer = PurchaseOrderTransformer::class;
// $this->entity_transformer = PurchaseOrderTransformer::class;
$data['template'] = $template;
// $data['template'] = $template;
PurchaseOrderEmail::dispatch($entity_obj, $entity_obj->company, $data);
$entity_obj->sendEvent(Webhook::EVENT_SENT_PURCHASE_ORDER, "vendor");
// PurchaseOrderEmail::dispatch($entity_obj, $entity_obj->company, $data);
// $entity_obj->sendEvent(Webhook::EVENT_SENT_PURCHASE_ORDER, "vendor");
return $this->itemResponse($entity_obj);
}
// return $this->itemResponse($entity_obj);
// }
private function resolveClass(string $entity): string
{

View File

@ -219,139 +219,6 @@ class PreviewPurchaseOrderController extends BaseController
}
public function livex(PreviewPurchaseOrderRequest $request)
{
/** @var \App\Models\User $user */
$user = auth()->user();
$company = $user->company();
$file_path = (new PreviewPdf('<html></html>', $company))->handle();
$response = Response::make($file_path, 200);
$response->header('Content-Type', 'application/pdf');
return $response;
MultiDB::setDb($company->db);
$repo = new PurchaseOrderRepository();
$entity_obj = PurchaseOrderFactory::create($company->id, $user->id);
$class = PurchaseOrder::class;
try {
DB::connection(config('database.default'))->beginTransaction();
if ($request->has('entity_id')) {
/** @var \App\Models\PurchaseOrder|\Illuminate\Contracts\Database\Eloquent\Builder $entity_obj **/
$entity_obj = \App\Models\PurchaseOrder::on(config('database.default'))
->with('vendor.company')
->where('id', $this->decodePrimaryKey($request->input('entity_id')))
->where('company_id', $company->id)
->withTrashed()
->first();
}
$entity_obj = $repo->save($request->all(), $entity_obj);
if (!$request->has('entity_id')) {
$entity_obj->service()->fillDefaults()->save();
}
App::forgetInstance('translator');
$t = app('translator');
App::setLocale($entity_obj->company->locale());
$t->replace(Ninja::transformTranslations($entity_obj->company->settings));
$html = new VendorHtmlEngine($entity_obj->invitations()->first());
/** @var \App\Models\Design $design */
$design = \App\Models\Design::withTrashed()->find($entity_obj->design_id);
/* Catch all in case migration doesn't pass back a valid design */
if (!$design) {
$design = \App\Models\Design::find(2);
}
if ($design->is_custom) {
$options = [
'custom_partials' => json_decode(json_encode($design->design), true)
];
$template = new PdfMakerDesign(PdfDesignModel::CUSTOM, $options);
} else {
$template = new PdfMakerDesign(strtolower($design->name));
}
$variables = $html->generateLabelsAndValues();
$state = [
'template' => $template->elements([
'client' => null,
'vendor' => $entity_obj->vendor,
'entity' => $entity_obj,
'pdf_variables' => (array) $entity_obj->company->settings->pdf_variables,
'variables' => $html->generateLabelsAndValues(),
'$product' => $design->design->product,
]),
'variables' => $html->generateLabelsAndValues(),
'options' => [
'client' => null,
'vendor' => $entity_obj->vendor,
'purchase_orders' => [$entity_obj],
'variables' => $html->generateLabelsAndValues(),
],
'process_markdown' => $entity_obj->company->markdown_enabled,
];
$maker = new PdfMaker($state);
$maker
->design($template)
->build();
DB::connection(config('database.default'))->rollBack();
if (request()->query('html') == 'true') {
return $maker->getCompiledHTML();
}
} catch(\Exception $e) {
DB::connection(config('database.default'))->rollBack();
return;
}
/** @var \App\Models\User $user */
$user = auth()->user();
//if phantom js...... inject here..
if (config('ninja.phantomjs_pdf_generation') || config('ninja.pdf_generator') == 'phantom') {
return (new Phantom())->convertHtmlToPdf($maker->getCompiledHTML(true));
}
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, $user->company());
if ($numbered_pdf) {
$pdf = $numbered_pdf;
}
return $pdf;
}
$file_path = (new PreviewPdf($maker->getCompiledHTML(true), $company))->handle();
if (Ninja::isHosted()) {
LightLogs::create(new LivePreview())
->increment()
->batch();
}
$response = Response::make($file_path, 200);
$response->header('Content-Type', 'application/pdf');
return $response;
}
private function blankEntity()
{
/** @var \App\Models\User $user */

View File

@ -25,7 +25,6 @@ class ProtectedDownloadController extends BaseController
if (!$hashed_path) {
throw new SystemError('File no longer available', 404);
abort(404, 'File no longer available');
}
return response()->streamDownload(function () use ($hashed_path) {

View File

@ -787,7 +787,6 @@ class QuoteController extends BaseController
break;
default:
return response()->json(['message' => ctrans('texts.action_unavailable', ['action' => $action])], 400);
break;
}
}

View File

@ -658,7 +658,6 @@ class BaseTransformer
public function getExpenseCategoryId($name)
{
/** @var \App\Models\ExpenseCategory $ec */
$ec = ExpenseCategory::query()->where('company_id', $this->company->id)
->where('is_deleted', false)
->whereRaw("LOWER(REPLACE(`name`, ' ' ,'')) = ?", [

View File

@ -1205,6 +1205,7 @@ class CompanyImport implements ShouldQueue
continue;
}
/** @var string $storage_url */
$storage_url = (object)$this->getObject('storage_url', true);
if (!Storage::exists($document->url) && is_string($storage_url)) {
@ -1351,45 +1352,31 @@ class CompanyImport implements ShouldQueue
switch ($type) {
case Company::class:
return $this->company->id;
break;
case Client::class:
return $this->transformId('clients', $id);
break;
case ClientContact::class:
return $this->transformId('client_contacts', $id);
break;
case Credit::class:
return $this->transformId('credits', $id);
break;
case Expense::class:
return $this->transformId('expenses', $id);
break;
case 'invoices':
return $this->transformId('invoices', $id);
break;
case Payment::class:
return $this->transformId('payments', $id);
break;
case Project::class:
return $this->transformId('projects', $id);
break;
case Product::class:
return $this->transformId('products', $id);
break;
case Quote::class:
return $this->transformId('quotes', $id);
break;
case RecurringInvoice::class:
return $this->transformId('recurring_invoices', $id);
break;
case Company::class:
return $this->transformId('clients', $id);
break;
default:
return false;
break;
}
}
@ -1420,10 +1407,10 @@ class CompanyImport implements ShouldQueue
switch ($type) {
case 'invoices':
return $this->transformId('invoices', $id);
break;
case Credit::class:
return $this->transformId('credits', $id);
break;
case Payment::class:
return $this->transformId('payments', $id);
default:

View File

@ -1455,30 +1455,23 @@ class Import implements ShouldQueue
switch ($status_id) {
case 1:
return $payment;
break;
case 2:
return $payment->service()->deletePayment();
break;
case 3:
return $payment->service()->deletePayment();
break;
case 4:
return $payment;
break;
case 5:
$payment->status_id = Payment::STATUS_PARTIALLY_REFUNDED;
$payment->save();
return $payment;
break;
case 6:
$payment->status_id = Payment::STATUS_REFUNDED;
$payment->save();
return $payment;
break;
default:
return $payment;
break;
}
}

View File

@ -100,18 +100,6 @@ class CreatePurchaseOrderPdf implements ShouldQueue
return $ps->boot()->getPdf();
$pdf = $this->rawPdf();
if ($pdf) {
try {
Storage::disk($this->disk)->put($this->file_path, $pdf);
} catch(\Exception $e) {
throw new FilePermissionsFailure($e->getMessage());
}
}
return $this->file_path;
}
public function rawPdf()

View File

@ -130,7 +130,6 @@ class OAuth
return $this;
default:
return null;
break;
}
}

View File

@ -516,14 +516,5 @@ class PaymentEmailEngine extends BaseEmailEngine
';
return '
<table border="0" cellspacing="0" cellpadding="0" align="center">
<tr style="border: 0 !important; ">
<td class="new_button" style="padding: 12px 18px 12px 18px; border-radius:5px;" align="center">
<a href="'. $link .'" target="_blank" style="border: 0 !important;font-size: 18px; font-family: Helvetica, Arial, sans-serif; color: #ffffff; text-decoration: none; display: inline-block;">'. $text .'</a>
</td>
</tr>
</table>
';
}
}

View File

@ -354,7 +354,6 @@ class BraintreePaymentDriver extends BaseDriver
return false;
}
return false;
}
private function findTokens(string $gateway_customer_reference)

View File

@ -450,11 +450,11 @@ class PayPalBasePaymentDriver extends BaseDriver
switch ($response['name']) {
case 'NOT_AUTHORIZED':
throw new PaymentFailed("There was a permissions issue processing this payment, please contact the merchant. ", 401);
break;
default:
throw new PaymentFailed("Unknown error occurred processing payment. Please contact merchant.", 500);
break;
}
}

View File

@ -225,7 +225,7 @@ class TaxProvider
{
throw new \Exception("No tax region defined for this country");
$this->provider = EuTax::class;
// $this->provider = EuTax::class;
return $this;
}

View File

@ -47,7 +47,7 @@ class ProjectTransformer extends EntityTransformer
{
$transformer = new DocumentTransformer($this->serializer);
if($project->documents) {
if($project->documents->count() > 0) {
return $this->includeCollection($project->documents, $transformer, Document::class);
}

View File

@ -34,7 +34,7 @@
<br>
<p>You have certain recourse rights if any debit does not comply with this agreement. For example, you have the right to receive reimbursement for any debit that is not authorized or is not consistent with this PAD Agreement. To obtain more information on your recourse rights, contact your financial institution.</p>
<br>
<p>You may amend or cancel this authorization at any time by providing the merchant with thirty (30) days notice at {{ $company->present()->email() }}. To obtain a sample cancellation form, or further information on cancelling a PAD agreement, please contact your financial institution.</p>
<p>You may amend or cancel this authorization at any time by providing the merchant with thirty (30) days notice at {{ $company->owner()->email }}. To obtain a sample cancellation form, or further information on cancelling a PAD agreement, please contact your financial institution.</p>
<br>
<p>{{ $company->present()->name() }} partners with Stripe to provide payment processing.</p>