1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Fixes for Quotes not attaching to emails

This commit is contained in:
David Bomba 2021-02-28 13:12:55 +11:00
parent 5f14cc0c5d
commit e668e7fd5a
8 changed files with 23 additions and 17 deletions

View File

@ -26,7 +26,7 @@ class UserVerified
public function __construct(?User $user)
{
$this->user = $user ?: auth()->user();
$this->user = property_exists($user, 'id') ? $user : auth()->user();
}
/**
@ -44,6 +44,10 @@ class UserVerified
'errors' => new \stdClass,
];
// nlog(auth()->user()->toArray());
// nlog($this->user->toArray());
// nlog((bool)$this->user->isVerified());
if ($this->user && !$this->user->isVerified())
return response()->json($error, 403);

View File

@ -89,7 +89,9 @@ class CreditEmailEngine extends BaseEmailEngine
->setInvitation($this->invitation);
if ($this->client->getSetting('pdf_email_attachment') !== false) {
$this->setAttachments(['path' => $this->credit->pdf_file_path(), 'name' => basename($this->credit->pdf_file_path())]);
$this->setAttachments([$this->credit->pdf_file_path()]);
// $this->setAttachments(['path' => $this->credit->pdf_file_path(), 'name' => basename($this->credit->pdf_file_path())]);
}
//attach third party documents

View File

@ -90,8 +90,8 @@ class QuoteEmailEngine extends BaseEmailEngine
if ($this->client->getSetting('pdf_email_attachment') !== false) {
// $this->setAttachments([$this->quote->pdf_file_path()]);
$this->setAttachments(['path' => $this->quote->pdf_file_path(), 'name' => basename($this->quote->pdf_file_path())]);
$this->setAttachments([$this->quote->pdf_file_path()]);
//$this->setAttachments(['path' => $this->quote->pdf_file_path(), 'name' => basename($this->quote->pdf_file_path())]);
}

View File

@ -91,13 +91,13 @@ class CompanyPresenter extends EntityPresenter
}
}
public function getSpcQrCode($client_currency, $invoice_number, $balance)
public function getSpcQrCode($client_currency, $invoice_number, $balance_due_raw)
{
$settings = $this->entity->settings;
return
"SPC\n0200\n1\nCH860021421411198240K\nK\n{$this->name}\n{$settings->address1}\n{$settings->postal_code} {$settings->city}\n\n\nCH\n\n\n\n\n\n\n\n{$balance}\n{$client_currency}\n\n\n\n\n\n\n\nNON\n\n{$invoice_number}\nEPD\n";
"SPC\n0200\n1\nCH860021421411198240K\nK\n{$this->name}\n{$settings->address1}\n{$settings->postal_code} {$settings->city}\n\n\nCH\n\n\n\n\n\n\n\n{$balance_due_raw}\n{$client_currency}\n\n\n\n\n\n\n\nNON\n\n{$invoice_number}\nEPD\n";
}
}

View File

@ -200,25 +200,27 @@ class Quote extends BaseModel
return new QuoteService($this);
}
public function pdf_file_path($invitation = null, string $type = 'url')
{
if (! $invitation) {
$invitation = $this->invitations->where('client_contact_id', $this->client->primary_contact()->first()->id)->first();
$invitation = $this->invitations->first();
}
$storage_path = Storage::$type($this->client->quote_filepath().$this->number.'.pdf');
if (Storage::exists($this->client->quote_filepath().$this->number.'.pdf')) {
return $storage_path;
nlog($storage_path);
if (! Storage::exists($this->client->quote_filepath().$this->number.'.pdf')) {
event(new QuoteWasUpdated($this, $this->company, Ninja::eventVars()));
CreateEntityPdf::dispatchNow($invitation);
}
event(new QuoteWasUpdated($this, $this->company, Ninja::eventVars()));
CreateEntityPdf::dispatchNow($invitation);
return $storage_path;
}
/**
* @param int $status
* @return string

View File

@ -37,7 +37,7 @@ class CreditObserver
*/
public function updated(Credit $credit)
{
UnlinkFile::dispatchNow(config('filesystems.default'), $credit->client->credit_filepath() . $credit->number.'.pdf');
}
/**

View File

@ -51,8 +51,6 @@ class QuoteObserver
WebhookHandler::dispatch(Webhook::EVENT_UPDATE_QUOTE, $quote, $quote->company);
}
UnlinkFile::dispatchNow(config('filesystems.default'), $quote->client->quote_filepath() . $quote->number.'.pdf');
}
/**

View File

@ -45,7 +45,7 @@ class RangeDetectionTest extends TestCase
}
private function makeRanges(array $ranges)
private function makeRanges(array $range)
{
return range($range[0], $range[1]);