mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Fixes for Quote PDF servicE
This commit is contained in:
parent
d6b58fe5b8
commit
1deb503929
51
app/Services/Quote/GetQuotePdf.php
Normal file
51
app/Services/Quote/GetQuotePdf.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com)
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
|
||||
namespace App\Services\Quote;
|
||||
|
||||
use App\Jobs\Quote\CreateQuotePdf;
|
||||
use App\Models\ClientContact;
|
||||
use App\Models\Quote;
|
||||
use App\Services\AbstractService;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class GetQuotePdf extends AbstractService
|
||||
{
|
||||
public function __construct(Quote $quote, ClientContact $contact = null)
|
||||
{
|
||||
$this->quote = $quote;
|
||||
|
||||
$this->contact = $contact;
|
||||
}
|
||||
|
||||
public function run()
|
||||
{
|
||||
if (!$this->contact) {
|
||||
$this->contact = $this->quote->client->primary_contact()->first();
|
||||
}
|
||||
|
||||
$invitation = $this->quote->invitations->where('client_contact_id', $this->contact->id)->first();
|
||||
|
||||
$path = $this->quote->client->invoice_filepath();
|
||||
|
||||
$file_path = $path . $this->quote->number . '.pdf';
|
||||
|
||||
$disk = config('filesystems.default');
|
||||
|
||||
$file = Storage::disk($disk)->exists($file_path);
|
||||
|
||||
if (!$file) {
|
||||
$file_path = CreateQuotePdf::dispatchNow($invitation);
|
||||
}
|
||||
|
||||
return Storage::disk($disk)->path($file_path);
|
||||
}
|
||||
}
|
@ -16,6 +16,7 @@ use App\Models\Invoice;
|
||||
use App\Models\Quote;
|
||||
use App\Repositories\QuoteRepository;
|
||||
use App\Services\Quote\CreateInvitations;
|
||||
use App\Services\Quote\GetQuotePdf;
|
||||
|
||||
class QuoteService
|
||||
{
|
||||
@ -65,9 +66,7 @@ class QuoteService
|
||||
|
||||
public function getQuotePdf($contact = null)
|
||||
{
|
||||
$get_invoice_pdf = new GetQuotePdf();
|
||||
|
||||
return $get_invoice_pdf($this->quote, $contact);
|
||||
return (new GetQuotePdf($this->quote, $contact))->run();
|
||||
}
|
||||
|
||||
public function sendEmail($contact = null) :QuoteService
|
||||
|
Loading…
x
Reference in New Issue
Block a user