mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 05:02:36 +01:00
remove redundant code paths
This commit is contained in:
parent
60766a7510
commit
e98a12a50a
@ -11,13 +11,10 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
// use App\Jobs\Entity\CreateEntityPdf;
|
||||
use App\Utils\Traits\Inviteable;
|
||||
use App\Utils\Traits\MakesDates;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
/**
|
||||
* App\Models\CreditInvitation
|
||||
@ -155,15 +152,4 @@ class CreditInvitation extends BaseModel
|
||||
$this->save();
|
||||
}
|
||||
|
||||
/** @deprecated 5.7 */
|
||||
public function pdf_file_path()
|
||||
{
|
||||
$storage_path = Storage::url($this->credit->client->quote_filepath($this).$this->credit->numberFormatter().'.pdf');
|
||||
|
||||
if (! Storage::exists($this->credit->client->credit_filepath($this).$this->credit->numberFormatter().'.pdf')) {
|
||||
// (new CreateEntityPdf($this))->handle();
|
||||
}
|
||||
|
||||
return $storage_path;
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,6 @@ use App\Utils\Ninja;
|
||||
use Illuminate\Support\Carbon;
|
||||
use App\Utils\Traits\MakesDates;
|
||||
use App\Helpers\Invoice\InvoiceSum;
|
||||
// use App\Jobs\Entity\CreateEntityPdf;
|
||||
use App\Utils\Traits\MakesReminders;
|
||||
use App\Utils\Traits\NumberFormatter;
|
||||
use App\Services\Ledger\LedgerService;
|
||||
@ -526,67 +525,6 @@ class Invoice extends BaseModel
|
||||
return $invoice_calc->build();
|
||||
}
|
||||
|
||||
/** @deprecated 5.7 */
|
||||
public function pdf_file_path($invitation = null, string $type = 'path', bool $portal = false)
|
||||
{
|
||||
|
||||
if (! $invitation) {
|
||||
if ($this->invitations()->exists()) {
|
||||
$invitation = $this->invitations()->first();
|
||||
} else {
|
||||
$this->service()->createInvitations();
|
||||
$invitation = $this->invitations()->first();
|
||||
}
|
||||
}
|
||||
|
||||
if (! $invitation) {
|
||||
throw new \Exception('Hard fail, could not create an invitation - is there a valid contact?');
|
||||
}
|
||||
|
||||
$file_path = $this->client->invoice_filepath($invitation).$this->numberFormatter().'.pdf';
|
||||
|
||||
$file_exists = false;
|
||||
|
||||
/* Flysystem throws an exception if the path is "corrupted" so lets wrap it in a try catch and return a bool 06/01/2022*/
|
||||
try {
|
||||
$file_exists = Storage::disk(config('filesystems.default'))->exists($file_path);
|
||||
} catch (\Exception $e) {
|
||||
nlog($e->getMessage());
|
||||
}
|
||||
|
||||
if (Ninja::isHosted() && $portal && $file_exists) {
|
||||
return Storage::disk(config('filesystems.default'))->{$type}($file_path);
|
||||
} elseif (Ninja::isHosted()) {
|
||||
// $file_path = (new CreateEntityPdf($invitation, config('filesystems.default')))->handle();
|
||||
|
||||
return Storage::disk(config('filesystems.default'))->{$type}($file_path);
|
||||
}
|
||||
|
||||
try {
|
||||
$file_exists = Storage::disk(config('filesystems.default'))->exists($file_path);
|
||||
} catch (\Exception $e) {
|
||||
nlog($e->getMessage());
|
||||
}
|
||||
|
||||
if ($file_exists) {
|
||||
return Storage::disk(config('filesystems.default'))->{$type}($file_path);
|
||||
}
|
||||
|
||||
try {
|
||||
$file_exists = Storage::disk('public')->exists($file_path);
|
||||
} catch (\Exception $e) {
|
||||
nlog($e->getMessage());
|
||||
}
|
||||
|
||||
if ($file_exists) {
|
||||
return Storage::disk('public')->{$type}($file_path);
|
||||
}
|
||||
|
||||
// $file_path = (new CreateEntityPdf($invitation))->handle();
|
||||
|
||||
return Storage::disk('public')->{$type}($file_path);
|
||||
}
|
||||
|
||||
public function markInvitationsSent()
|
||||
{
|
||||
$this->invitations->each(function ($invitation) {
|
||||
|
@ -12,7 +12,6 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Events\Invoice\InvoiceWasUpdated;
|
||||
// use App\Jobs\Entity\CreateEntityPdf;
|
||||
use App\Utils\Ninja;
|
||||
use App\Utils\Traits\Inviteable;
|
||||
use App\Utils\Traits\MakesDates;
|
||||
@ -157,16 +156,4 @@ class InvoiceInvitation extends BaseModel
|
||||
$this->save();
|
||||
}
|
||||
|
||||
/** @deprecated 5.7 */
|
||||
public function pdf_file_path(): string
|
||||
{
|
||||
$storage_path = Storage::url($this->invoice->client->invoice_filepath($this).$this->invoice->numberFormatter().'.pdf');
|
||||
|
||||
if (! Storage::exists($this->invoice->client->invoice_filepath($this).$this->invoice->numberFormatter().'.pdf')) {
|
||||
event(new InvoiceWasUpdated($this->invoice, $this->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
|
||||
// (new CreateEntityPdf($this))->handle();
|
||||
}
|
||||
|
||||
return $storage_path;
|
||||
}
|
||||
}
|
||||
|
@ -281,39 +281,6 @@ class PurchaseOrder extends BaseModel
|
||||
});
|
||||
}
|
||||
|
||||
/** @deprecated 5.7 */
|
||||
public function pdf_file_path($invitation = null, string $type = 'path', bool $portal = false)
|
||||
{
|
||||
if (! $invitation) {
|
||||
if ($this->invitations()->exists()) {
|
||||
$invitation = $this->invitations()->first();
|
||||
} else {
|
||||
$this->service()->createInvitations();
|
||||
$invitation = $this->invitations()->first();
|
||||
}
|
||||
}
|
||||
|
||||
if (!$invitation) {
|
||||
throw new \Exception('Hard fail, could not create an invitation - is there a valid contact?');
|
||||
}
|
||||
|
||||
$file_path = $this->vendor->purchase_order_filepath($invitation).$this->numberFormatter().'.pdf';
|
||||
|
||||
if (Ninja::isHosted() && $portal && Storage::disk(config('filesystems.default'))->exists($file_path)) {
|
||||
return Storage::disk(config('filesystems.default'))->{$type}($file_path);
|
||||
} elseif (Ninja::isHosted() && $portal) {
|
||||
$file_path = (new CreatePurchaseOrderPdf($invitation, config('filesystems.default')))->handle();
|
||||
return Storage::disk(config('filesystems.default'))->{$type}($file_path);
|
||||
}
|
||||
|
||||
if (Storage::disk('public')->exists($file_path)) {
|
||||
return Storage::disk('public')->{$type}($file_path);
|
||||
}
|
||||
|
||||
$file_path = (new CreatePurchaseOrderPdf($invitation))->handle();
|
||||
return Storage::disk('public')->{$type}($file_path);
|
||||
}
|
||||
|
||||
public function invitations(): \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
{
|
||||
return $this->hasMany(PurchaseOrderInvitation::class);
|
||||
|
@ -13,7 +13,6 @@ namespace App\Models;
|
||||
|
||||
use App\Helpers\Invoice\InvoiceSum;
|
||||
use App\Helpers\Invoice\InvoiceSumInclusive;
|
||||
// use App\Jobs\Entity\CreateEntityPdf;
|
||||
use App\Models\Presenters\QuotePresenter;
|
||||
use App\Services\Quote\QuoteService;
|
||||
use App\Utils\Ninja;
|
||||
@ -314,52 +313,6 @@ class Quote extends BaseModel
|
||||
return new QuoteService($this);
|
||||
}
|
||||
|
||||
/** @deprecated 5.7 */
|
||||
public function pdf_file_path($invitation = null, string $type = 'path', bool $portal = false)
|
||||
{
|
||||
if (! $invitation) {
|
||||
if ($this->invitations()->exists()) {
|
||||
$invitation = $this->invitations()->first();
|
||||
} else {
|
||||
$this->service()->createInvitations();
|
||||
$invitation = $this->invitations()->first();
|
||||
}
|
||||
}
|
||||
|
||||
if (! $invitation) {
|
||||
throw new \Exception('Hard fail, could not create an invitation - is there a valid contact?');
|
||||
}
|
||||
|
||||
$file_path = $this->client->quote_filepath($invitation).$this->numberFormatter().'.pdf';
|
||||
|
||||
if (Ninja::isHosted() && $portal && Storage::disk(config('filesystems.default'))->exists($file_path)) {
|
||||
return Storage::disk(config('filesystems.default'))->{$type}($file_path);
|
||||
} elseif (Ninja::isHosted() && $portal) {
|
||||
// $file_path = (new CreateEntityPdf($invitation, config('filesystems.default')))->handle();
|
||||
return Storage::disk(config('filesystems.default'))->{$type}($file_path);
|
||||
}
|
||||
|
||||
$file_exists = false;
|
||||
|
||||
try {
|
||||
$file_exists = Storage::disk(config('filesystems.default'))->exists($file_path);
|
||||
} catch (\Exception $e) {
|
||||
nlog($e->getMessage());
|
||||
}
|
||||
|
||||
if ($file_exists) {
|
||||
return Storage::disk(config('filesystems.default'))->{$type}($file_path);
|
||||
}
|
||||
|
||||
if (Storage::disk('public')->exists($file_path)) {
|
||||
return Storage::disk('public')->{$type}($file_path);
|
||||
}
|
||||
|
||||
// $file_path = (new CreateEntityPdf($invitation))->handle();
|
||||
|
||||
return Storage::disk('public')->{$type}($file_path);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $status
|
||||
* @return string
|
||||
|
@ -139,16 +139,4 @@ class QuoteInvitation extends BaseModel
|
||||
$this->save();
|
||||
}
|
||||
|
||||
/** @deprecated 5.7 */
|
||||
|
||||
public function pdf_file_path()
|
||||
{
|
||||
$storage_path = Storage::url($this->quote->client->quote_filepath($this).$this->quote->numberFormatter().'.pdf');
|
||||
|
||||
if (! Storage::exists($this->quote->client->quote_filepath($this).$this->quote->numberFormatter().'.pdf')) {
|
||||
// (new CreateEntityPdf($this))->handle();
|
||||
}
|
||||
|
||||
return $storage_path;
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,6 @@ use App\Models\Payment;
|
||||
use App\Models\PaymentType;
|
||||
use App\Factory\PaymentFactory;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
// use App\Jobs\Entity\CreateEntityPdf;
|
||||
use App\Repositories\CreditRepository;
|
||||
use App\Repositories\PaymentRepository;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
@ -11,8 +11,8 @@
|
||||
|
||||
namespace App\Services\Credit;
|
||||
|
||||
use App\Models\CreditInvitation;
|
||||
use App\Jobs\Entity\CreateRawPdf;
|
||||
use App\Models\CreditInvitation;
|
||||
use App\Services\AbstractService;
|
||||
|
||||
class GetCreditPdf extends AbstractService
|
||||
|
@ -38,7 +38,6 @@ class TriggeredActions extends AbstractService
|
||||
$this->purchase_order
|
||||
->service()
|
||||
->markSent()
|
||||
// ->touchPdf()
|
||||
->save();
|
||||
|
||||
$this->sendEmail();
|
||||
@ -48,7 +47,6 @@ class TriggeredActions extends AbstractService
|
||||
$this->purchase_order = $this->purchase_order
|
||||
->service()
|
||||
->markSent()
|
||||
// ->touchPdf()
|
||||
->save();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user