mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 20:22:42 +01:00
Fixes for previews
This commit is contained in:
parent
4daa321ecf
commit
5731763071
@ -293,9 +293,11 @@ class PreviewController extends BaseController
|
||||
$ts = (new TemplateService());
|
||||
|
||||
try {
|
||||
|
||||
$ts->setCompany($company)
|
||||
->setTemplate($design_object)
|
||||
->mock();
|
||||
|
||||
} catch(SyntaxError $e) {
|
||||
} catch(\Exception $e) {
|
||||
return response()->json(['message' => 'invalid data access', 'errors' => ['design.design.body' => $e->getMessage()]], 422);
|
||||
|
@ -362,7 +362,7 @@ class ProcessMailgunWebhook implements ShouldQueue
|
||||
|
||||
$bounce = new EmailBounce(
|
||||
$this->request['event-data']['tags'][0],
|
||||
$this->request['event-data']['envelope']['sender'],
|
||||
$this->request['event-data']['envelope']['sender'] ?? $this->request['event-data']['envelope']['from'],
|
||||
$this->message_id
|
||||
);
|
||||
|
||||
|
@ -66,7 +66,7 @@ class PdfMock
|
||||
$pdf_config->setPdfVariables();
|
||||
$pdf_config->setCurrency(Currency::find($this->settings->currency_id));
|
||||
$pdf_config->setCountry(Country::find($this->settings->country_id ?: 840));
|
||||
$pdf_config->currency_entity = $this->mock->client;
|
||||
$pdf_config->currency_entity = $this->mock->client ?? $this->mock->vendor;
|
||||
|
||||
if(isset($this->request['design_id']) && $design = Design::withTrashed()->find($this->request['design_id'])) {
|
||||
$pdf_config->design = $design;
|
||||
@ -171,11 +171,11 @@ class PdfMock
|
||||
{
|
||||
$settings = $this->company->settings;
|
||||
|
||||
match ($this->request['settings_type']) {
|
||||
match ($this->request['settings_type'] ?? '') {
|
||||
'group' => $settings = ClientSettings::buildClientSettings($this->company->settings, $this->request['settings']),
|
||||
'client' => $settings = ClientSettings::buildClientSettings($this->company->settings, $this->request['settings']),
|
||||
'company' => $settings = (object)$this->request['settings'],
|
||||
default => $settings = (object)$this->request['settings'],
|
||||
default => $settings = (object)$this->company->settings,
|
||||
};
|
||||
|
||||
$settings = CompanySettings::setProperties($settings);
|
||||
|
@ -218,7 +218,7 @@ class TemplateService
|
||||
$tm = new TemplateMock($this->company);
|
||||
$tm->setSettings($this->getSettings())->init();
|
||||
|
||||
$this->entity = $this->company->invoices()->first() ?? $this->company->quotes()->first();
|
||||
$this->entity = $this->company->invoices()->first() ?? $this->company->quotes()->first() ?? (new \App\Services\Pdf\PdfMock(['entity_type' => 'invoice'], $this->company))->initEntity();
|
||||
|
||||
$this->data = $tm->engines;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user