mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-07 15:44:33 -04:00
Fixes for e-invoices
This commit is contained in:
parent
cf6cd98eec
commit
cd9c7d9237
@ -801,7 +801,6 @@ class Invoice extends BaseModel
|
|||||||
|
|
||||||
public function entityEmailEvent($invitation, $reminder_template, $template = '')
|
public function entityEmailEvent($invitation, $reminder_template, $template = '')
|
||||||
{
|
{
|
||||||
nlog($template);
|
|
||||||
|
|
||||||
switch ($reminder_template) {
|
switch ($reminder_template) {
|
||||||
case 'invoice':
|
case 'invoice':
|
||||||
|
@ -11,24 +11,25 @@
|
|||||||
|
|
||||||
namespace App\Services\Email;
|
namespace App\Services\Email;
|
||||||
|
|
||||||
use App\Jobs\Invoice\CreateEInvoice;
|
use App\Models\Task;
|
||||||
use App\Services\Invoice\GetInvoiceXInvoice;
|
use App\Utils\Ninja;
|
||||||
use App\DataMapper\EmailTemplateDefaults;
|
use App\Models\Quote;
|
||||||
use App\Jobs\Entity\CreateRawPdf;
|
|
||||||
use App\Jobs\Invoice\CreateUbl;
|
|
||||||
use App\Jobs\Vendor\CreatePurchaseOrderPdf;
|
|
||||||
use App\Models\Account;
|
|
||||||
use App\Models\Credit;
|
use App\Models\Credit;
|
||||||
|
use App\Models\Account;
|
||||||
use App\Models\Expense;
|
use App\Models\Expense;
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
use App\Models\PurchaseOrder;
|
use App\Models\PurchaseOrder;
|
||||||
use App\Models\Quote;
|
use App\Jobs\Invoice\CreateUbl;
|
||||||
use App\Models\Task;
|
|
||||||
use App\Utils\Ninja;
|
|
||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
use Illuminate\Mail\Mailables\Address;
|
use App\Jobs\Entity\CreateRawPdf;
|
||||||
use Illuminate\Support\Facades\App;
|
use Illuminate\Support\Facades\App;
|
||||||
|
use App\Jobs\Invoice\CreateEInvoice;
|
||||||
|
use Illuminate\Mail\Mailables\Address;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use App\DataMapper\EmailTemplateDefaults;
|
||||||
use League\CommonMark\CommonMarkConverter;
|
use League\CommonMark\CommonMarkConverter;
|
||||||
|
use App\Jobs\Vendor\CreatePurchaseOrderPdf;
|
||||||
|
use App\Services\Invoice\GetInvoiceXInvoice;
|
||||||
|
|
||||||
class EmailDefaults
|
class EmailDefaults
|
||||||
{
|
{
|
||||||
@ -299,11 +300,15 @@ class EmailDefaults
|
|||||||
$this->email->email_object->entity instanceof Credit)) {
|
$this->email->email_object->entity instanceof Credit)) {
|
||||||
$pdf = ((new CreateRawPdf($this->email->email_object->invitation, $this->email->company->db))->handle());
|
$pdf = ((new CreateRawPdf($this->email->email_object->invitation, $this->email->company->db))->handle());
|
||||||
if ($this->email->email_object->settings->enable_e_invoice && $this->email->email_object->entity instanceof Invoice) {
|
if ($this->email->email_object->settings->enable_e_invoice && $this->email->email_object->entity instanceof Invoice) {
|
||||||
$tempfile = tmpfile();
|
|
||||||
file_put_contents(stream_get_meta_data($tempfile)['uri'], $pdf);
|
$xinvoice_path = $this->email->email_object->entity->service()->getEInvoice();
|
||||||
$xinvoice_path = (new CreateEInvoice($this->email->email_object->entity, true, stream_get_meta_data($tempfile)['uri']))->handle();
|
|
||||||
$this->email->email_object->attachments = array_merge($this->email->email_object->attachments, [['file' => base64_encode(file_get_contents(stream_get_meta_data($tempfile)['uri'])), 'name' => $this->email->email_object->entity->numberFormatter().'.pdf']]);
|
// $xinvoice_path = (new CreateEInvoice($this->email->email_object->entity, true, stream_get_meta_data($tempfile)['uri']))->handle();
|
||||||
$this->email->email_object->attachments = array_merge($this->email->email_object->attachments, [['file' => base64_encode(file_get_contents($xinvoice_path)), 'name' => explode(".", $this->email->email_object->entity->getFileName('xml'))[0]."-xinvoice.xml"]]);
|
// $this->email->email_object->attachments = array_merge($this->email->email_object->attachments, [['file' => base64_encode($pdf), 'name' => $this->email->email_object->entity->numberFormatter().'.pdf']]);
|
||||||
|
|
||||||
|
if(Storage::disk(config('filesystems.default'))->exists($xinvoice_path))
|
||||||
|
$this->email->email_object->attachments = array_merge($this->email->email_object->attachments, [['file' => base64_encode(Storage::get($xinvoice_path)), 'name' => explode(".", $this->email->email_object->entity->getFileName('xml'))[0]."-xinvoice.xml"]]);
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$this->email->email_object->attachments = array_merge($this->email->email_object->attachments, [['file' => base64_encode($pdf), 'name' => $this->email->email_object->entity->numberFormatter().'.pdf']]);
|
$this->email->email_object->attachments = array_merge($this->email->email_object->attachments, [['file' => base64_encode($pdf), 'name' => $this->email->email_object->entity->numberFormatter().'.pdf']]);
|
||||||
@ -321,8 +326,10 @@ class EmailDefaults
|
|||||||
}
|
}
|
||||||
/** E-Invoice xml file */
|
/** E-Invoice xml file */
|
||||||
if ($this->email->email_object->settings->enable_e_invoice && $this->email->email_object->entity instanceof Invoice) {
|
if ($this->email->email_object->settings->enable_e_invoice && $this->email->email_object->entity instanceof Invoice) {
|
||||||
$xinvoice_path = (new GetInvoiceXInvoice($this->email->email_object->entity))->run();
|
$xinvoice_path = $this->email->email_object->entity->service()->getEInvoice();
|
||||||
$this->email->email_object->attachments = array_merge($this->email->email_object->attachments, [['file' => base64_encode(file_get_contents($xinvoice_path)), 'name' => explode(".", $this->email->email_object->entity->getFileName('xml'))[0]."-e_invoice.xml"]]);
|
|
||||||
|
if(Storage::disk(config('filesystems.default'))->exists($xinvoice_path))
|
||||||
|
$this->email->email_object->attachments = array_merge($this->email->email_object->attachments, [['file' => base64_encode(Storage::get($xinvoice_path)), 'name' => explode(".", $this->email->email_object->entity->getFileName('xml'))[0]."-e_invoice.xml"]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->email->email_object->settings->document_email_attachment || !$this->email->company->account->hasFeature(Account::FEATURE_DOCUMENTS)) {
|
if (!$this->email->email_object->settings->document_email_attachment || !$this->email->company->account->hasFeature(Account::FEATURE_DOCUMENTS)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user