Patches for admin mailable

This commit is contained in:
David Bomba
2025-09-06 16:34:01 +10:00
parent 2c3ac4aad9
commit 331be9d309
3 changed files with 36 additions and 2 deletions

View File

@@ -16,8 +16,12 @@ use App\Utils\Ninja;
use App\Models\Account;
use App\Models\Company;
use App\Utils\TempFile;
use App\Services\Email\Email;
use Illuminate\Bus\Queueable;
use App\Services\Email\EmailObject;
use Illuminate\Support\Facades\App;
use App\Utils\Traits\SavesDocuments;
use Illuminate\Mail\Mailables\Address;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
@@ -36,6 +40,8 @@ class EInvoicePullDocs implements ShouldQueue
public $tries = 1;
private int $einvoice_received_count = 0;
public function __construct()
{
}
@@ -64,6 +70,8 @@ class EInvoicePullDocs implements ShouldQueue
})
->each(function ($company) {
$this->einvoice_received_count = 0;
$response = \Illuminate\Support\Facades\Http::baseUrl(config('ninja.hosted_ninja_url'))
->withHeaders([
'Content-Type' => 'application/json',
@@ -86,6 +94,24 @@ class EInvoicePullDocs implements ShouldQueue
nlog($response->body());
}
if($this->einvoice_received_count > 0) {
App::setLocale($company->getLocale());
$mo = new EmailObject();
$mo->subject = ctrans('texts.einvoice_received_subject');
$mo->body = ctrans('texts.einvoice_received_body', ['count' => $this->einvoice_received_count]);
$mo->text_body = ctrans('texts.einvoice_received_body', ['count' => $this->einvoice_received_count]);
$mo->company_key = $company->company_key;
$mo->html_template = 'email.template.admin';
$mo->to = [new Address($company->owner()->email, $company->owner()->present()->name())];
// $mo->email_template_body = 'einvoice_received_body';
// $mo->email_template_subject = 'einvoice_received_subject';
Email::dispatch($mo, $company);
}
});
});
@@ -96,6 +122,8 @@ class EInvoicePullDocs implements ShouldQueue
$storecove = new Storecove();
$mail_payload = [];
foreach ($received_documents as $document) {
nlog($document);
$storecove_invoice = $storecove->expense->getStorecoveInvoice(json_encode($document['document']['invoice']));
@@ -125,6 +153,7 @@ class EInvoicePullDocs implements ShouldQueue
}
$this->einvoice_received_count++;
}
@@ -145,6 +174,8 @@ class EInvoicePullDocs implements ShouldQueue
if ($response->successful()) {
}
}
public function failed(\Throwable $exception)

View File

@@ -62,7 +62,7 @@ class AdminEmailMailable extends Mailable
text: 'email.admin.generic_text',
with: [
'title' => $this->email_object->subject,
'message' => $this->email_object->body,
'content' => $this->email_object->body,
'url' => $this->email_object->url ?? null,
'button' => $this->email_object->button ?? null,
'signature' => $this->email_object->company->owner()->signature,

View File

@@ -5631,7 +5631,10 @@ $lang = array(
'replaced' => 'Replaced',
'ses_from_address' => 'SES From Address',
'ses_from_address_help' => 'The Sending Email Address, must be verified in AWS',
'unauthorized_action' => 'You are not authorized to perform this action',
'unauthorized_action' => 'You are not authorized to perform this action',
'einvoice_received_subject' => 'E-Invoice/s Received',
'einvoice_received_body' => 'You have received :count new E-Invoice/s.<br><br>Login to view.',
);
return $lang;