mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Add in shipping details
This commit is contained in:
parent
dc95528d13
commit
010bcb8286
@ -14,7 +14,6 @@ namespace App\Services\Pdf;
|
|||||||
use App\Models\Credit;
|
use App\Models\Credit;
|
||||||
use App\Models\Quote;
|
use App\Models\Quote;
|
||||||
use App\Utils\Helpers;
|
use App\Utils\Helpers;
|
||||||
use App\Utils\Number;
|
|
||||||
use App\Utils\Traits\MakesDates;
|
use App\Utils\Traits\MakesDates;
|
||||||
use DOMDocument;
|
use DOMDocument;
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
@ -836,7 +835,7 @@ class PdfBuilder
|
|||||||
return [
|
return [
|
||||||
['element' => 'div', 'properties' => ['style' => 'display: flex; flex-direction: column;'], 'elements' => [
|
['element' => 'div', 'properties' => ['style' => 'display: flex; flex-direction: column;'], 'elements' => [
|
||||||
['element' => 'div', 'properties' => ['style' => 'margin-top: 1.5rem; display: block; align-items: flex-start; page-break-inside: avoid; visible !important;'], 'elements' => [
|
['element' => 'div', 'properties' => ['style' => 'margin-top: 1.5rem; display: block; align-items: flex-start; page-break-inside: avoid; visible !important;'], 'elements' => [
|
||||||
['element' => 'img', 'properties' => ['src' => '$invoiceninja.whitelabel', 'style' => 'height: 2.5rem;', 'hidden' => $this->service->account->isPaid() ? 'true' : 'false', 'id' => 'invoiceninja-whitelabel-logo']],
|
['element' => 'img', 'properties' => ['src' => '$invoiceninja.whitelabel', 'style' => 'height: 2.5rem;', 'hidden' => 'false', 'id' => 'invoiceninja-whitelabel-logo']],
|
||||||
]],
|
]],
|
||||||
]],
|
]],
|
||||||
];
|
];
|
||||||
@ -908,7 +907,7 @@ class PdfBuilder
|
|||||||
]],
|
]],
|
||||||
['element' => 'img', 'properties' => ['style' => 'max-width: 50%; height: auto;', 'src' => '$contact.signature', 'id' => 'contact-signature']],
|
['element' => 'img', 'properties' => ['style' => 'max-width: 50%; height: auto;', 'src' => '$contact.signature', 'id' => 'contact-signature']],
|
||||||
['element' => 'div', 'properties' => ['style' => 'margin-top: 1.5rem; display: flex; align-items: flex-start; page-break-inside: auto;'], 'elements' => [
|
['element' => 'div', 'properties' => ['style' => 'margin-top: 1.5rem; display: flex; align-items: flex-start; page-break-inside: auto;'], 'elements' => [
|
||||||
['element' => 'img', 'properties' => ['src' => '$invoiceninja.whitelabel', 'style' => 'height: 2.5rem;', 'hidden' => $this->service->account->isPaid() ? 'true' : 'false', 'id' => 'invoiceninja-whitelabel-logo']],
|
['element' => 'img', 'properties' => ['src' => '$invoiceninja.whitelabel', 'style' => 'height: 2.5rem;', 'hidden' => 'false', 'id' => 'invoiceninja-whitelabel-logo']],
|
||||||
]],
|
]],
|
||||||
]],
|
]],
|
||||||
['element' => 'div', 'properties' => ['class' => 'totals-table-right-side', 'dir' => '$dir'], 'elements' => []],
|
['element' => 'div', 'properties' => ['class' => 'totals-table-right-side', 'dir' => '$dir'], 'elements' => []],
|
||||||
|
@ -11,29 +11,29 @@
|
|||||||
|
|
||||||
namespace App\Services\Pdf;
|
namespace App\Services\Pdf;
|
||||||
|
|
||||||
use App\Utils\Ninja;
|
|
||||||
use App\Models\Quote;
|
|
||||||
use App\Models\Client;
|
|
||||||
use App\Models\Credit;
|
|
||||||
use App\Models\Design;
|
|
||||||
use App\Models\Vendor;
|
|
||||||
use App\Models\Country;
|
|
||||||
use App\Models\Invoice;
|
|
||||||
use App\Models\Currency;
|
|
||||||
use App\Models\ClientContact;
|
|
||||||
use App\Models\PurchaseOrder;
|
|
||||||
use App\Models\VendorContact;
|
|
||||||
use App\Utils\Traits\AppSetup;
|
|
||||||
use App\Models\QuoteInvitation;
|
|
||||||
use App\Utils\Traits\MakesHash;
|
|
||||||
use App\Models\CreditInvitation;
|
|
||||||
use App\Models\InvoiceInvitation;
|
|
||||||
use App\DataMapper\CompanySettings;
|
use App\DataMapper\CompanySettings;
|
||||||
|
use App\Models\Client;
|
||||||
|
use App\Models\ClientContact;
|
||||||
|
use App\Models\Country;
|
||||||
|
use App\Models\Credit;
|
||||||
|
use App\Models\CreditInvitation;
|
||||||
|
use App\Models\Currency;
|
||||||
|
use App\Models\Design;
|
||||||
|
use App\Models\Invoice;
|
||||||
|
use App\Models\InvoiceInvitation;
|
||||||
|
use App\Models\PurchaseOrder;
|
||||||
|
use App\Models\PurchaseOrderInvitation;
|
||||||
|
use App\Models\Quote;
|
||||||
|
use App\Models\QuoteInvitation;
|
||||||
|
use App\Models\RecurringInvoiceInvitation;
|
||||||
|
use App\Models\Vendor;
|
||||||
|
use App\Models\VendorContact;
|
||||||
|
use App\Utils\Ninja;
|
||||||
|
use App\Utils\Traits\AppSetup;
|
||||||
|
use App\Utils\Traits\MakesHash;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\Facades\App;
|
use Illuminate\Support\Facades\App;
|
||||||
use Illuminate\Support\Facades\Cache;
|
use Illuminate\Support\Facades\Cache;
|
||||||
use App\Models\PurchaseOrderInvitation;
|
|
||||||
use App\Models\RecurringInvoiceInvitation;
|
|
||||||
use Illuminate\Support\Collection;
|
|
||||||
|
|
||||||
class PdfConfiguration
|
class PdfConfiguration
|
||||||
{
|
{
|
||||||
@ -317,7 +317,6 @@ class PdfConfiguration
|
|||||||
} elseif ($this->settings->show_currency_code === false) {
|
} elseif ($this->settings->show_currency_code === false) {
|
||||||
return "{$symbol}{$value}";
|
return "{$symbol}{$value}";
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$value = floatval($value);
|
$value = floatval($value);
|
||||||
$thousand = $this->currency->thousand_separator;
|
$thousand = $this->currency->thousand_separator;
|
||||||
$decimal = $this->currency->decimal_separator;
|
$decimal = $this->currency->decimal_separator;
|
||||||
@ -325,7 +324,6 @@ class PdfConfiguration
|
|||||||
|
|
||||||
return number_format($value, $precision, $decimal, $thousand);
|
return number_format($value, $precision, $decimal, $thousand);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -342,11 +340,9 @@ class PdfConfiguration
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->date_format = $date_formats->filter(function ($item) {
|
$this->date_format = $date_formats->filter(function ($item) {
|
||||||
return $item->id == $this->settings->date_format_id;
|
return $item->id == $this->settings->date_format_id;
|
||||||
})->first()->format;
|
})->first()->format;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,22 +11,18 @@
|
|||||||
|
|
||||||
namespace App\Services\Pdf;
|
namespace App\Services\Pdf;
|
||||||
|
|
||||||
use App\Models\Quote;
|
use App\DataMapper\ClientSettings;
|
||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
use App\Models\Credit;
|
|
||||||
use App\Models\Design;
|
|
||||||
use App\Models\Vendor;
|
|
||||||
use App\Models\Company;
|
use App\Models\Company;
|
||||||
use App\Models\Country;
|
use App\Models\Country;
|
||||||
use App\Models\Invoice;
|
use App\Models\Credit;
|
||||||
use App\Models\Currency;
|
use App\Models\Currency;
|
||||||
use App\Models\PurchaseOrder;
|
use App\Models\Design;
|
||||||
use App\Services\Pdf\PdfBuilder;
|
use App\Models\Invoice;
|
||||||
use App\Services\Pdf\PdfService;
|
|
||||||
use App\Models\InvoiceInvitation;
|
use App\Models\InvoiceInvitation;
|
||||||
use App\Services\Pdf\PdfDesigner;
|
use App\Models\PurchaseOrder;
|
||||||
use App\DataMapper\ClientSettings;
|
use App\Models\Quote;
|
||||||
use App\Services\Pdf\PdfConfiguration;
|
use App\Models\Vendor;
|
||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
|
|
||||||
class PdfMock
|
class PdfMock
|
||||||
@ -35,14 +31,14 @@ class PdfMock
|
|||||||
|
|
||||||
private mixed $mock;
|
private mixed $mock;
|
||||||
|
|
||||||
private object $settings;
|
public object $settings;
|
||||||
|
|
||||||
public function __construct(public array $request, public Company $company)
|
public function __construct(public array $request, public Company $company)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public function getPdf(): mixed
|
public function getPdf(): mixed
|
||||||
{
|
{
|
||||||
|
|
||||||
$pdf_service = new PdfService($this->mock->invitation);
|
$pdf_service = new PdfService($this->mock->invitation);
|
||||||
|
|
||||||
$pdf_config = (new PdfConfiguration($pdf_service));
|
$pdf_config = (new PdfConfiguration($pdf_service));
|
||||||
@ -50,14 +46,14 @@ class PdfMock
|
|||||||
$pdf_config->entity_string = $this->request['entity_type'];
|
$pdf_config->entity_string = $this->request['entity_type'];
|
||||||
$pdf_config->setTaxMap($this->mock->tax_map);
|
$pdf_config->setTaxMap($this->mock->tax_map);
|
||||||
$pdf_config->setTotalTaxMap($this->mock->total_tax_map);
|
$pdf_config->setTotalTaxMap($this->mock->total_tax_map);
|
||||||
$pdf_config->setCurrency(Currency::find(1));
|
|
||||||
$pdf_config->setCountry(Country::find(840));
|
|
||||||
$pdf_config->client = $this->mock->client;
|
$pdf_config->client = $this->mock->client;
|
||||||
$pdf_config->settings_object = $this->mock->client;
|
$pdf_config->settings_object = $this->mock->client;
|
||||||
$pdf_config->settings = $this->getMergedSettings();
|
$pdf_config->settings = $this->getMergedSettings();
|
||||||
$this->settings = $pdf_config->settings;
|
$this->settings = $pdf_config->settings;
|
||||||
$pdf_config->entity_design_id = $pdf_config->settings->{"{$pdf_config->entity_string}_design_id"};
|
$pdf_config->entity_design_id = $pdf_config->settings->{"{$pdf_config->entity_string}_design_id"};
|
||||||
$pdf_config->setPdfVariables();
|
$pdf_config->setPdfVariables();
|
||||||
|
$pdf_config->setCurrency(Currency::find($this->settings->currency_id));
|
||||||
|
$pdf_config->setCountry(Country::find($this->settings->country_id));
|
||||||
$pdf_config->design = Design::find($this->decodePrimaryKey($pdf_config->entity_design_id));
|
$pdf_config->design = Design::find($this->decodePrimaryKey($pdf_config->entity_design_id));
|
||||||
$pdf_config->currency_entity = $this->mock->client;
|
$pdf_config->currency_entity = $this->mock->client;
|
||||||
|
|
||||||
@ -72,20 +68,18 @@ class PdfMock
|
|||||||
$pdf_service->builder = $pdf_builder;
|
$pdf_service->builder = $pdf_builder;
|
||||||
|
|
||||||
$html = $pdf_service->getHtml();
|
$html = $pdf_service->getHtml();
|
||||||
nlog($html);
|
|
||||||
return $pdf_service->resolvePdfEngine($html);
|
return $pdf_service->resolvePdfEngine($html);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function build(): self
|
public function build(): self
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->mock = $this->initEntity();
|
$this->mock = $this->initEntity();
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function initEntity(): mixed
|
public function initEntity(): mixed
|
||||||
{
|
{
|
||||||
match ($this->request['entity_type']) {
|
match ($this->request['entity_type']) {
|
||||||
'invoice' => $entity = Invoice::factory()->make(),
|
'invoice' => $entity = Invoice::factory()->make(),
|
||||||
@ -95,10 +89,9 @@ nlog($html);
|
|||||||
default => $entity = Invoice::factory()->make()
|
default => $entity = Invoice::factory()->make()
|
||||||
};
|
};
|
||||||
|
|
||||||
if($this->request['entity_type'] == PurchaseOrder::class){
|
if ($this->request['entity_type'] == PurchaseOrder::class) {
|
||||||
$entity->vendor = Vendor::factory()->make();
|
$entity->vendor = Vendor::factory()->make();
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
$entity->client = Client::factory()->make();
|
$entity->client = Client::factory()->make();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,30 +99,26 @@ nlog($html);
|
|||||||
$entity->total_tax_map = $this->getTotalTaxMap();
|
$entity->total_tax_map = $this->getTotalTaxMap();
|
||||||
$entity->invitation = InvoiceInvitation::factory()->make();
|
$entity->invitation = InvoiceInvitation::factory()->make();
|
||||||
$entity->invitation->company = $this->company;
|
$entity->invitation->company = $this->company;
|
||||||
// $entity->invitation->company->account = $this->company->account;
|
|
||||||
|
|
||||||
return $entity;
|
return $entity;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMergedSettings() :object
|
public function getMergedSettings() :object
|
||||||
{
|
{
|
||||||
match($this->request['settings_type']){
|
match ($this->request['settings_type']) {
|
||||||
'group' => $settings = ClientSettings::buildClientSettings($this->company->settings, $this->request['settings']),
|
'group' => $settings = ClientSettings::buildClientSettings($this->company->settings, $this->request['settings']),
|
||||||
'client' => $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'],
|
'company' => $settings = (object)$this->request['settings'],
|
||||||
default => $settings = $this->company->settings,
|
default => $settings = $this->company->settings,
|
||||||
};
|
};
|
||||||
|
|
||||||
nlog($settings);
|
|
||||||
|
|
||||||
return $settings;
|
return $settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private function getTaxMap()
|
private function getTaxMap()
|
||||||
{
|
{
|
||||||
return collect( [['name' => 'GST', 'total' => 10]]);
|
return collect([['name' => 'GST', 'total' => 10]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getTotalTaxMap()
|
private function getTotalTaxMap()
|
||||||
@ -139,8 +128,8 @@ nlog($html);
|
|||||||
|
|
||||||
public function getStubVariables()
|
public function getStubVariables()
|
||||||
{
|
{
|
||||||
return ['values' =>
|
return ['values' =>
|
||||||
[
|
[
|
||||||
'$client.shipping_postal_code' => '46420',
|
'$client.shipping_postal_code' => '46420',
|
||||||
'$client.billing_postal_code' => '11243',
|
'$client.billing_postal_code' => '11243',
|
||||||
'$company.city_state_postal' => '90210',
|
'$company.city_state_postal' => '90210',
|
||||||
@ -222,10 +211,10 @@ nlog($html);
|
|||||||
'$company.address1' => $this->settings->address1,
|
'$company.address1' => $this->settings->address1,
|
||||||
'$credit.credit_no' => '0029',
|
'$credit.credit_no' => '0029',
|
||||||
'$invoice.datetime' => '25/Feb/2023 1:10 am',
|
'$invoice.datetime' => '25/Feb/2023 1:10 am',
|
||||||
'$contact.custom1' => NULL,
|
'$contact.custom1' => null,
|
||||||
'$contact.custom2' => NULL,
|
'$contact.custom2' => null,
|
||||||
'$contact.custom3' => NULL,
|
'$contact.custom3' => null,
|
||||||
'$contact.custom4' => NULL,
|
'$contact.custom4' => null,
|
||||||
'$task.line_total' => '',
|
'$task.line_total' => '',
|
||||||
'$line_tax_labels' => '',
|
'$line_tax_labels' => '',
|
||||||
'$line_tax_values' => '',
|
'$line_tax_values' => '',
|
||||||
@ -324,7 +313,7 @@ nlog($html);
|
|||||||
'$contact.name' => 'Benedict Eichmann',
|
'$contact.name' => 'Benedict Eichmann',
|
||||||
'$entity.terms' => 'Default company invoice terms',
|
'$entity.terms' => 'Default company invoice terms',
|
||||||
'$client.state' => 'North Carolina',
|
'$client.state' => 'North Carolina',
|
||||||
'$company.logo' => $this->settings->company_logo,
|
'$company.logo' => $this->settings->company_logo,
|
||||||
'$company_logo' => $this->settings->company_logo,
|
'$company_logo' => $this->settings->company_logo,
|
||||||
'$payment_link' => 'http://ninja.test:8000/client/pay/UAUY8vIPuno72igmXbbpldwo5BDDKIqs',
|
'$payment_link' => 'http://ninja.test:8000/client/pay/UAUY8vIPuno72igmXbbpldwo5BDDKIqs',
|
||||||
'$status_logo' => '',
|
'$status_logo' => '',
|
||||||
@ -465,7 +454,7 @@ EPD
|
|||||||
'$show_shipping_address_block' => $this->settings->show_shipping_address ? 'block' : 'none',
|
'$show_shipping_address_block' => $this->settings->show_shipping_address ? 'block' : 'none',
|
||||||
'$show_shipping_address_visibility' => $this->settings->show_shipping_address ? 'visible' : 'hidden',
|
'$show_shipping_address_visibility' => $this->settings->show_shipping_address ? 'visible' : 'hidden',
|
||||||
],
|
],
|
||||||
'labels' =>
|
'labels' =>
|
||||||
[
|
[
|
||||||
'$client.shipping_postal_code_label' => 'Shipping Postal Code',
|
'$client.shipping_postal_code_label' => 'Shipping Postal Code',
|
||||||
'$client.billing_postal_code_label' => 'Postal Code',
|
'$client.billing_postal_code_label' => 'Postal Code',
|
||||||
|
@ -13,18 +13,17 @@ namespace App\Services\Pdf;
|
|||||||
|
|
||||||
use App\Models\Account;
|
use App\Models\Account;
|
||||||
use App\Models\Company;
|
use App\Models\Company;
|
||||||
use App\Utils\HtmlEngine;
|
|
||||||
use App\Models\QuoteInvitation;
|
|
||||||
use App\Utils\VendorHtmlEngine;
|
|
||||||
use App\Models\CreditInvitation;
|
use App\Models\CreditInvitation;
|
||||||
use App\Utils\PhantomJS\Phantom;
|
|
||||||
use App\Models\InvoiceInvitation;
|
use App\Models\InvoiceInvitation;
|
||||||
use App\Services\Pdf\PdfDesigner;
|
|
||||||
use App\Utils\HostedPDF\NinjaPdf;
|
|
||||||
use App\Utils\Traits\Pdf\PdfMaker;
|
|
||||||
use App\Models\PurchaseOrderInvitation;
|
use App\Models\PurchaseOrderInvitation;
|
||||||
use App\Utils\Traits\Pdf\PageNumbering;
|
use App\Models\QuoteInvitation;
|
||||||
use App\Models\RecurringInvoiceInvitation;
|
use App\Models\RecurringInvoiceInvitation;
|
||||||
|
use App\Utils\HostedPDF\NinjaPdf;
|
||||||
|
use App\Utils\HtmlEngine;
|
||||||
|
use App\Utils\PhantomJS\Phantom;
|
||||||
|
use App\Utils\Traits\Pdf\PageNumbering;
|
||||||
|
use App\Utils\Traits\Pdf\PdfMaker;
|
||||||
|
use App\Utils\VendorHtmlEngine;
|
||||||
|
|
||||||
class PdfService
|
class PdfService
|
||||||
{
|
{
|
||||||
@ -34,8 +33,6 @@ class PdfService
|
|||||||
|
|
||||||
public Company $company;
|
public Company $company;
|
||||||
|
|
||||||
public Account $account;
|
|
||||||
|
|
||||||
public PdfConfiguration $config;
|
public PdfConfiguration $config;
|
||||||
|
|
||||||
public PdfBuilder $builder;
|
public PdfBuilder $builder;
|
||||||
@ -59,12 +56,9 @@ class PdfService
|
|||||||
|
|
||||||
$this->company = $invitation->company;
|
$this->company = $invitation->company;
|
||||||
|
|
||||||
$this->account = $this->company->account;
|
|
||||||
|
|
||||||
$this->document_type = $document_type;
|
$this->document_type = $document_type;
|
||||||
|
|
||||||
$this->options = $options;
|
$this->options = $options;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -78,7 +72,6 @@ class PdfService
|
|||||||
public function getPdf()
|
public function getPdf()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
|
||||||
$pdf = $this->resolvePdfEngine($this->getHtml());
|
$pdf = $this->resolvePdfEngine($this->getHtml());
|
||||||
|
|
||||||
$numbered_pdf = $this->pageNumbering($pdf, $this->company);
|
$numbered_pdf = $this->pageNumbering($pdf, $this->company);
|
||||||
@ -86,7 +79,6 @@ class PdfService
|
|||||||
if ($numbered_pdf) {
|
if ($numbered_pdf) {
|
||||||
$pdf = $numbered_pdf;
|
$pdf = $numbered_pdf;
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
nlog(print_r($e->getMessage(), 1));
|
nlog(print_r($e->getMessage(), 1));
|
||||||
throw new \Exception($e->getMessage(), $e->getCode());
|
throw new \Exception($e->getMessage(), $e->getCode());
|
||||||
@ -119,7 +111,6 @@ class PdfService
|
|||||||
*/
|
*/
|
||||||
public function init(): self
|
public function init(): self
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->config = (new PdfConfiguration($this))->init();
|
$this->config = (new PdfConfiguration($this))->init();
|
||||||
|
|
||||||
|
|
||||||
@ -132,7 +123,6 @@ class PdfService
|
|||||||
$this->builder = (new PdfBuilder($this))->build();
|
$this->builder = (new PdfBuilder($this))->build();
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -142,7 +132,6 @@ class PdfService
|
|||||||
*/
|
*/
|
||||||
public function resolvePdfEngine(string $html): mixed
|
public function resolvePdfEngine(string $html): mixed
|
||||||
{
|
{
|
||||||
|
|
||||||
if (config('ninja.phantomjs_pdf_generation') || config('ninja.pdf_generator') == 'phantom') {
|
if (config('ninja.phantomjs_pdf_generation') || config('ninja.pdf_generator') == 'phantom') {
|
||||||
$pdf = (new Phantom)->convertHtmlToPdf($html);
|
$pdf = (new Phantom)->convertHtmlToPdf($html);
|
||||||
} elseif (config('ninja.invoiceninja_hosted_pdf_generation') || config('ninja.pdf_generator') == 'hosted_ninja') {
|
} elseif (config('ninja.invoiceninja_hosted_pdf_generation') || config('ninja.pdf_generator') == 'hosted_ninja') {
|
||||||
@ -153,5 +142,4 @@ class PdfService
|
|||||||
|
|
||||||
return $pdf;
|
return $pdf;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -12,15 +12,17 @@
|
|||||||
|
|
||||||
namespace Tests\Pdf;
|
namespace Tests\Pdf;
|
||||||
|
|
||||||
|
use App\DataMapper\CompanySettings;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
use App\Models\Design;
|
use App\Models\Design;
|
||||||
|
use App\Models\Company;
|
||||||
use App\Models\Country;
|
use App\Models\Country;
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
use App\Models\Currency;
|
use App\Models\Currency;
|
||||||
use App\Services\Pdf\PdfBuilder;
|
|
||||||
use Tests\MockAccountData;
|
use Tests\MockAccountData;
|
||||||
use App\Services\Pdf\PdfMock;
|
use App\Services\Pdf\PdfMock;
|
||||||
use Beganovich\Snappdf\Snappdf;
|
use Beganovich\Snappdf\Snappdf;
|
||||||
|
use App\Services\Pdf\PdfBuilder;
|
||||||
use App\Services\Pdf\PdfService;
|
use App\Services\Pdf\PdfService;
|
||||||
use App\Services\Pdf\PdfConfiguration;
|
use App\Services\Pdf\PdfConfiguration;
|
||||||
|
|
||||||
@ -39,13 +41,17 @@ class PdfmockTest extends TestCase
|
|||||||
|
|
||||||
public function testPdfInstance ()
|
public function testPdfInstance ()
|
||||||
{
|
{
|
||||||
|
$data = [
|
||||||
|
'settings' => CompanySettings::defaults(),
|
||||||
|
'settings_type' => 'company',
|
||||||
|
'entity_type' => 'invoice',
|
||||||
|
];
|
||||||
|
|
||||||
$entity = (new \App\Services\Pdf\PdfMock(Invoice::class))->build();
|
$entity = (new \App\Services\Pdf\PdfMock($data, Company::factory()->make()))->build()->initEntity();
|
||||||
|
|
||||||
$this->assertInstanceOf(Invoice::class, $entity);
|
$this->assertInstanceOf(Invoice::class, $entity);
|
||||||
$this->assertNotNull($entity->client);
|
$this->assertNotNull($entity->client);
|
||||||
|
|
||||||
|
|
||||||
$pdf_service = new PdfService($entity->invitation);
|
$pdf_service = new PdfService($entity->invitation);
|
||||||
|
|
||||||
$this->assertNotNull($pdf_service);
|
$this->assertNotNull($pdf_service);
|
||||||
@ -59,8 +65,14 @@ class PdfmockTest extends TestCase
|
|||||||
|
|
||||||
public function testHtmlGeneration()
|
public function testHtmlGeneration()
|
||||||
{
|
{
|
||||||
$pdf_mock = (new PdfMock(Invoice::class));
|
$data = [
|
||||||
$mock = $pdf_mock->build();
|
'settings' => CompanySettings::defaults(),
|
||||||
|
'settings_type' => 'company',
|
||||||
|
'entity_type' => 'invoice',
|
||||||
|
];
|
||||||
|
|
||||||
|
$pdf_mock = (new PdfMock($data, Company::factory()->make()))->build();
|
||||||
|
$mock = $pdf_mock->initEntity();
|
||||||
|
|
||||||
$pdf_service = new PdfService($mock->invitation);
|
$pdf_service = new PdfService($mock->invitation);
|
||||||
|
|
||||||
@ -74,7 +86,8 @@ class PdfmockTest extends TestCase
|
|||||||
$pdf_config->entity_design_id = 'invoice_design_id';
|
$pdf_config->entity_design_id = 'invoice_design_id';
|
||||||
$pdf_config->settings_object = $mock->client;
|
$pdf_config->settings_object = $mock->client;
|
||||||
$pdf_config->entity_string = 'invoice';
|
$pdf_config->entity_string = 'invoice';
|
||||||
$pdf_config->settings = (object)$pdf_config->service->company->settings;
|
$pdf_config->settings = $pdf_mock->getMergedSettings();
|
||||||
|
$pdf_mock->settings = $pdf_config->settings;
|
||||||
$pdf_config->setPdfVariables();
|
$pdf_config->setPdfVariables();
|
||||||
$pdf_config->design = Design::find(2);
|
$pdf_config->design = Design::find(2);
|
||||||
$pdf_config->currency_entity = $mock->client;
|
$pdf_config->currency_entity = $mock->client;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user