Fixes for emails

This commit is contained in:
David Bomba 2023-03-08 17:56:34 +11:00
parent 3ef2591b38
commit 9874c1aee5
5 changed files with 13 additions and 8 deletions

View File

@ -25,7 +25,7 @@ class DocumentExport extends BaseExport
private $entity_transformer;
public $date_key = 'created_at';
public string $date_key = 'created_at';
public array $entity_keys = [
'record_type' => 'record_type',

View File

@ -25,7 +25,7 @@ class ExpenseExport extends BaseExport
private $expense_transformer;
public $date_key = 'date';
public string $date_key = 'date';
public array $entity_keys = [
'amount' => 'amount',

View File

@ -190,6 +190,12 @@ class EmailController extends BaseController
$this->entity_transformer = RecurringInvoiceTransformer::class;
}
if($entity_obj instanceof PurchaseOrder){
$this->entity_type = PurchaseOrder::class;
$this->entity_transformer = PurchaseOrderTransformer::class;
}
// @phpstan-ignore-next-line
return $this->itemResponse($entity_obj->fresh());
}

View File

@ -83,7 +83,7 @@ class SendEmailRequest extends Request
$input = $this->all();
if (Ninja::isHosted() && !auth()->user()->company()->account->account_sms_verified) {
if (Ninja::isHosted() && !auth()->user()->account->account_sms_verified) {
$this->error_message = ctrans('texts.authorization_sms_failure');
return false;

View File

@ -259,15 +259,14 @@ class EmailDefaults
*/
private function setAttachments(): self
{
$attachments = [];
$documents = [];
if ($this->email->email_object->settings->document_email_attachment && $this->email->company->account->hasFeature(Account::FEATURE_DOCUMENTS)) {
foreach ($this->email->company->documents as $document) {
$attachments[] = ['file' => base64_encode($document->getFile()), 'name' => $document->name];
}
$this->email->email_object->documents = array_merge($this->email->email_object->documents, $this->email->company->documents->pluck('id')->toArray());
}
$this->email->email_object->attachments = array_merge($this->email->email_object->attachments, $attachments);
return $this;
}