mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-01 06:04:35 -04:00
Fixes for PDFMock
This commit is contained in:
parent
505fafb147
commit
13881ac6e5
@ -197,7 +197,6 @@ class PreviewController extends BaseController
|
|||||||
return response()->json(['message' => 'This server cannot handle this request.'], 400);
|
return response()->json(['message' => 'This server cannot handle this request.'], 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$company = auth()->user()->company();
|
$company = auth()->user()->company();
|
||||||
|
|
||||||
MultiDB::setDb($company->db);
|
MultiDB::setDb($company->db);
|
||||||
|
@ -102,7 +102,12 @@ class PdfMock
|
|||||||
|
|
||||||
return $entity;
|
return $entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* getMergedSettings
|
||||||
|
*
|
||||||
|
* @return object
|
||||||
|
*/
|
||||||
public function getMergedSettings() :object
|
public function getMergedSettings() :object
|
||||||
{
|
{
|
||||||
match ($this->request['settings_type']) {
|
match ($this->request['settings_type']) {
|
||||||
@ -115,17 +120,32 @@ class PdfMock
|
|||||||
return $settings;
|
return $settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* getTaxMap
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
private function getTaxMap()
|
private function getTaxMap()
|
||||||
{
|
{
|
||||||
return collect([['name' => 'GST', 'total' => 10]]);
|
return collect([['name' => 'GST', 'total' => 10]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* getTotalTaxMap
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
private function getTotalTaxMap()
|
private function getTotalTaxMap()
|
||||||
{
|
{
|
||||||
return [['name' => 'GST', 'total' => 10]];
|
return [['name' => 'GST', 'total' => 10]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* getStubVariables
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function getStubVariables()
|
public function getStubVariables()
|
||||||
{
|
{
|
||||||
return ['values' =>
|
return ['values' =>
|
||||||
|
@ -61,18 +61,25 @@ class PdfService
|
|||||||
$this->options = $options;
|
$this->options = $options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function boot(): self
|
||||||
|
{
|
||||||
|
$this->init();
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resolves the PDF generation type and
|
* Resolves the PDF generation type and
|
||||||
* attempts to generate a PDF from the HTML
|
* attempts to generate a PDF from the HTML
|
||||||
* string.
|
* string.
|
||||||
*
|
*
|
||||||
* @return mixed | Exception
|
* @return mixed | Exception
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function getPdf()
|
public function getPdf()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$pdf = $this->init()->resolvePdfEngine($this->getHtml());
|
$pdf = $this->resolvePdfEngine($this->getHtml());
|
||||||
|
|
||||||
$numbered_pdf = $this->pageNumbering($pdf, $this->company);
|
$numbered_pdf = $this->pageNumbering($pdf, $this->company);
|
||||||
|
|
||||||
@ -95,7 +102,6 @@ class PdfService
|
|||||||
*/
|
*/
|
||||||
public function getHtml(): string
|
public function getHtml(): string
|
||||||
{
|
{
|
||||||
$this->init();
|
|
||||||
|
|
||||||
$html = $this->builder->getCompiledHTML();
|
$html = $this->builder->getCompiledHTML();
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ class PdfServiceTest extends TestCase
|
|||||||
|
|
||||||
$invitation = $this->invoice->invitations->first();
|
$invitation = $this->invoice->invitations->first();
|
||||||
|
|
||||||
$service = new PdfService($invitation);
|
$service = (new PdfService($invitation))->boot();
|
||||||
|
|
||||||
$this->assertNotNull($service->getPdf());
|
$this->assertNotNull($service->getPdf());
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ class PdfServiceTest extends TestCase
|
|||||||
|
|
||||||
$invitation = $this->invoice->invitations->first();
|
$invitation = $this->invoice->invitations->first();
|
||||||
|
|
||||||
$service = new PdfService($invitation);
|
$service = (new PdfService($invitation))->boot();
|
||||||
|
|
||||||
$this->assertIsString($service->getHtml());
|
$this->assertIsString($service->getHtml());
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ class PdfServiceTest extends TestCase
|
|||||||
|
|
||||||
$invitation = $this->invoice->invitations->first();
|
$invitation = $this->invoice->invitations->first();
|
||||||
|
|
||||||
$service = new PdfService($invitation);
|
$service = (new PdfService($invitation))->boot();
|
||||||
|
|
||||||
$this->assertInstanceOf(PdfService::class, $service);
|
$this->assertInstanceOf(PdfService::class, $service);
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ class PdfServiceTest extends TestCase
|
|||||||
|
|
||||||
$invitation = $this->invoice->invitations->first();
|
$invitation = $this->invoice->invitations->first();
|
||||||
|
|
||||||
$service = (new PdfService($invitation))->init();
|
$service = (new PdfService($invitation))->boot();
|
||||||
|
|
||||||
$this->assertInstanceOf(PdfConfiguration::class, $service->config);
|
$this->assertInstanceOf(PdfConfiguration::class, $service->config);
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ class PdfServiceTest extends TestCase
|
|||||||
{
|
{
|
||||||
$invitation = $this->invoice->invitations->first();
|
$invitation = $this->invoice->invitations->first();
|
||||||
|
|
||||||
$service = (new PdfService($invitation))->init();
|
$service = (new PdfService($invitation))->boot();
|
||||||
|
|
||||||
$this->assertEquals(2, $service->config->design->id);
|
$this->assertEquals(2, $service->config->design->id);
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ class PdfServiceTest extends TestCase
|
|||||||
{
|
{
|
||||||
$invitation = $this->invoice->invitations->first();
|
$invitation = $this->invoice->invitations->first();
|
||||||
|
|
||||||
$service = (new PdfService($invitation))->init();
|
$service = (new PdfService($invitation))->boot();
|
||||||
|
|
||||||
$this->assertIsArray($service->html_variables);
|
$this->assertIsArray($service->html_variables);
|
||||||
|
|
||||||
@ -102,7 +102,7 @@ class PdfServiceTest extends TestCase
|
|||||||
{
|
{
|
||||||
$invitation = $this->invoice->invitations->first();
|
$invitation = $this->invoice->invitations->first();
|
||||||
|
|
||||||
$service = (new PdfService($invitation))->init();
|
$service = (new PdfService($invitation))->boot();
|
||||||
|
|
||||||
$this->assertIsString($service->designer->template);
|
$this->assertIsString($service->designer->template);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user