diff --git a/app/Designs/Bold.php b/app/Designs/Bold.php index badeaaf06a99..751dcca4ba31 100644 --- a/app/Designs/Bold.php +++ b/app/Designs/Bold.php @@ -25,21 +25,16 @@ class Bold extends AbstractDesign - $css_url + - + '; } @@ -91,7 +86,6 @@ class Bold extends AbstractDesign return ''; } - public function task_table() { return ' @@ -139,7 +133,7 @@ class Bold extends AbstractDesign - +

$terms_label

@@ -158,4 +152,4 @@ class Bold extends AbstractDesign } -} \ No newline at end of file +} diff --git a/app/Designs/Business.php b/app/Designs/Business.php index 23dacca25dcf..82689f67cc58 100644 --- a/app/Designs/Business.php +++ b/app/Designs/Business.php @@ -14,8 +14,9 @@ namespace App\Designs; class Business extends AbstractDesign { - public function __construct() { - } + public function __construct() + { + } public function includes() { @@ -25,32 +26,33 @@ class Business extends AbstractDesign - + '; } - public function header() { + public function header() + { return '
@@ -69,9 +71,10 @@ class Business extends AbstractDesign
'; - } + } - public function body() { + public function body() + { return '
@@ -94,9 +97,15 @@ class Business extends AbstractDesign
'; - } + } - public function task() { + public function task() + { + return ''; + } + + public function task_table() + { return '
@@ -108,11 +117,16 @@ class Business extends AbstractDesign $task_table_body
- '; + '; } - public function product() { + public function product() + { + return ''; + } + public function product_table() + { return ' @@ -124,11 +138,11 @@ class Business extends AbstractDesign $product_table_body
- '; - } + } - public function footer() { + public function footer() + { return '
@@ -169,6 +183,6 @@ class Business extends AbstractDesign '; - } + } -} \ No newline at end of file +} diff --git a/app/Designs/Clean.php b/app/Designs/Clean.php index d29b8352fbb0..a746c97421e7 100644 --- a/app/Designs/Clean.php +++ b/app/Designs/Clean.php @@ -21,38 +21,31 @@ class Clean extends AbstractDesign public function includes() { return ' - - $number - - + + - - - '; } - + public function header() { return ' - -
@@ -67,9 +60,7 @@ class Clean extends AbstractDesign
- '; - } public function body() { @@ -100,10 +91,33 @@ class Clean extends AbstractDesign } - public function task() { + public function task() + { + return ''; } - public function product() { + public function task_table() + { + return ' + + + + $task_table_header + + + + $task_table_body + +
+ '; + } + + public function product() + { + return ''; + } + + public function product_table() { return ' @@ -115,46 +129,46 @@ class Clean extends AbstractDesign $product_table_body
- -
-
- $entity.public_notes -
-
-
- $total_tax_labels - $line_tax_labels -
-
- $total_tax_values - $line_tax_values -
-
-
- -
-
-

$terms_label

- $terms -
-
-
- $balance_due_label -
-
- $balance_due -
-
-
'; + '; } public function footer() { return ' +
+
+ $entity.public_notes +
+
+
+ $total_tax_labels + $line_tax_labels +
+
+ $total_tax_values + $line_tax_values +
+
+
+ +
+
+

$terms_label

+ $terms +
+
+
+ $balance_due_label +
+
+ $balance_due +
+
+
'; } -} \ No newline at end of file +} diff --git a/app/Designs/Creative.php b/app/Designs/Creative.php index 03029fcbfa2d..a294cfca3c4d 100644 --- a/app/Designs/Creative.php +++ b/app/Designs/Creative.php @@ -31,29 +31,29 @@ class Creative extends AbstractDesign - + - '; } - + public function header() { return ' - +
@@ -98,8 +98,29 @@ class Creative extends AbstractDesign public function task() { } - public function product() { - + public function task_table() + { + return ' + + + + $task_table_header + + + + $task_table_body + +
+ '; + } + + public function product() + { + return ''; + } + + public function product_table() { + return ' @@ -110,8 +131,12 @@ class Creative extends AbstractDesign $product_table_body -
- + '; + } + + public function footer() { + + return '
@@ -142,12 +167,8 @@ class Creative extends AbstractDesign
-
'; - } +
- public function footer() { - - return '

Balance Due

$5,280.00

@@ -159,4 +180,4 @@ class Creative extends AbstractDesign } -} \ No newline at end of file +} diff --git a/app/Designs/Elegant.php b/app/Designs/Elegant.php index 6de6c1ffa0f6..d81992b914c7 100644 --- a/app/Designs/Elegant.php +++ b/app/Designs/Elegant.php @@ -21,39 +21,32 @@ class Elegant extends AbstractDesign public function includes() { return ' - - - - $number - - - - - - - + + $number + + + + - + '; } - + public function header() { return ' - +
@@ -91,9 +84,30 @@ class Elegant extends AbstractDesign } public function task() { + return ''; } - public function product() { + public function task_table() + { + return ' + + + + $product_table_header + + + + $product_table_body + +
'; + } + + public function product() + { + return ''; + } + + public function product_table() { return ' @@ -104,54 +118,51 @@ class Elegant extends AbstractDesign $product_table_body -
- -
-
-
-

$entity.public_notes

-
-
-
-
-
- $total_tax_labels - $line_tax_labels -
-
- $total_tax_values - $line_tax_values -
-
-
-
-
-
-
-

$terms_label

-

$terms

-
-
-
-
-

$balance_due_label

-

$balance

-
-
-
'; + '; } public function footer() { - return '
+ return ' +
+
+
+

$entity.public_notes

+
+
+
+
+
+ $total_tax_labels + $line_tax_labels +
+
+ $total_tax_values + $line_tax_values +
+
+
+
+
+
+
+

$terms_label

+

$terms

+
+
+
+
+

$balance_due_label

+

$balance

+
+
+
+

Thanks

-
- - - '; +
'; } -} \ No newline at end of file +} diff --git a/app/Designs/Hipster.php b/app/Designs/Hipster.php index fdb5188cfd62..993e207be2aa 100644 --- a/app/Designs/Hipster.php +++ b/app/Designs/Hipster.php @@ -21,39 +21,33 @@ class Hipster extends AbstractDesign public function includes() { return ' - - - - $number - - - - - - - - + + $number + + + + - - + '; } - + public function header() { return ' - +
@@ -105,9 +99,32 @@ class Hipster extends AbstractDesign } public function task() { + return ''; } - public function product() { + public function task_table() + { + return ' + + + + $task_table_header + + + + $task_table_body + +
+ '; + } + + public function product() + { + return ' + '; + } + + public function product_table() { return ' @@ -118,44 +135,43 @@ class Hipster extends AbstractDesign $product_table_body -
- -
-
-
-

$entity.public_notes

-
-

$terms_label

-

$terms

-
-
-
-
-
-
- $total_tax_labels - $line_tax_labels -
-
- $total_tax_values - $line_tax_values -
-
-
-

$balance_due_label

-

$balance_due

-
-
-
'; + '; } public function footer() { return ' +
+
+
+

$entity.public_notes

+
+

$terms_label

+

$terms

+
+
+
+
+
+
+ $total_tax_labels + $line_tax_labels +
+
+ $total_tax_values + $line_tax_values +
+
+
+

$balance_due_label

+

$balance_due

+
+
+
'; } -} \ No newline at end of file +} diff --git a/app/Designs/Modern.php b/app/Designs/Modern.php index b50370e35a04..3b479ba79ded 100644 --- a/app/Designs/Modern.php +++ b/app/Designs/Modern.php @@ -28,10 +28,9 @@ class Modern extends AbstractDesign - + - '; } - + public function header() { @@ -110,6 +103,7 @@ class Modern extends AbstractDesign
+
'; } @@ -117,21 +111,46 @@ class Modern extends AbstractDesign public function task() { } - public function product() { - return ' -
- - - - $product_table_header - - - - $product_table_body - -
+ public function task_table() + { + return ' + + + + $task_table_header + + + + $task_table_body + +
+ '; + } -
+ public function product() + { + return ''; + } + + public function product_table() { + return ' + + + + $product_table_header + + + + $product_table_body + +
+ '; + } + + public function footer() { + + return ' +
$entity.public_notes
@@ -165,13 +184,6 @@ class Modern extends AbstractDesign
- - '; - } - - public function footer() { - - return '
'; +
+
'; } public function task() { } - public function product() { + public function task_table() + { + return ' + + + + $task_table_header + + + + $task_table_body + +
'; + } + + public function product() + { + return ''; + } + + public function product_table() { return ' -
@@ -120,49 +130,51 @@ class Photo extends AbstractDesign $product_table_body
-
-
-
-

$entity.public_notes

-
-
-
-
-
- $total_tax_labels - $line_tax_labels -
-
- $total_tax_values - $line_tax_values -
-
-
-
-
-
-
-

$terms_label

-

$terms

-
-
-
-
-

$balance_due_label

-

$balance_due

-
-
-
-
'; + '; } public function footer() { return ' +
+
+
+

$entity.public_notes

+
+
+
+
+
+ $total_tax_labels + $line_tax_labels +
+
+ $total_tax_values + $line_tax_values +
+
+
+
+
+
+
+

$terms_label

+

$terms

+
+
+
+
+

$balance_due_label

+

$balance_due

+
+
+
+
+
'; } -} \ No newline at end of file +} diff --git a/app/Designs/Plain.php b/app/Designs/Plain.php index 3eecae3e28ff..1fb8bde147de 100644 --- a/app/Designs/Plain.php +++ b/app/Designs/Plain.php @@ -21,41 +21,31 @@ class Plain extends AbstractDesign public function includes() { return ' - - - - $number - - - - - - - + + $number + + + + - - - + '; } - + public function header() { return ' - +
$company_logo @@ -92,9 +82,30 @@ class Plain extends AbstractDesign } public function task() { + return ''; } - public function product() { + public function task_table() + { + return ' + + + + $task_table_header + + + + $task_table_body + +
'; + } + + public function product() + { + return ''; + } + + public function product_table() { return ' @@ -105,43 +116,43 @@ class Plain extends AbstractDesign $product_table_body -
- -
-
-
-

$entity.public_notes

-
-

$terms_label

-

$terms

-
-
-
-
-
-
- $total_tax_labels - $line_tax_labels -
-
- $total_tax_values - $line_tax_values -
-
-
-

$balance_due_label

-

$balance_due

-
-
'; + '; } public function footer() { return ' +
+
+
+

$entity.public_notes

+
+

$terms_label

+

$terms

+
+
+
+
+
+
+ $total_tax_labels + $line_tax_labels +
+
+ $total_tax_values + $line_tax_values +
+
+
+

$balance_due_label

+

$balance_due

+
+
+
'; } -} \ No newline at end of file +} diff --git a/app/Designs/Playful.php b/app/Designs/Playful.php index 7aa6f63750d5..1a9673b8e169 100644 --- a/app/Designs/Playful.php +++ b/app/Designs/Playful.php @@ -21,31 +21,27 @@ class Playful extends AbstractDesign public function includes() { return ' - - $number - - - + + '; } - + public function header() { @@ -100,7 +96,28 @@ class Playful extends AbstractDesign public function task() { } - public function product() { + public function task_table() + { + return ' + + + + $task_table_header + + + + $task_table_body + +
+ '; + } + + public function product() + { + return ''; + } + + public function product_table() { return ' @@ -111,51 +128,51 @@ class Playful extends AbstractDesign $product_table_body -
- -
-
-
-

$entity.public_notes

-
-
-
-
-
- $total_tax_labels - $line_tax_labels -
-
- $total_tax_values - $line_tax_values -
-
-
-
-
-
-
-

$terms_label

-

$terms

-
-
-
-
-

$balance_due_label

-

$balance_due

-
-
-
-
'; + '; } public function footer() { return ' +
+
+
+

$entity.public_notes

+
+
+
+
+
+ $total_tax_labels + $line_tax_labels +
+
+ $total_tax_values + $line_tax_values +
+
+
+
+
+
+
+

$terms_label

+

$terms

+
+
+
+
+

$balance_due_label

+

$balance_due

+
+
+
+
+
'; } -} \ No newline at end of file +} diff --git a/tests/Integration/DesignTest.php b/tests/Integration/DesignTest.php index 1af117e685c9..cc4ac9969d93 100644 --- a/tests/Integration/DesignTest.php +++ b/tests/Integration/DesignTest.php @@ -2,14 +2,21 @@ namespace Tests\Integration; +use App\Designs\Bold; +use App\Designs\Business; +use App\Designs\Clean; use App\Designs\Designer; use App\Designs\Modern; use App\Jobs\Credit\CreateCreditPdf; use App\Jobs\Invoice\CreateInvoicePdf; use App\Jobs\Quote\CreateQuotePdf; +use App\Models\ClientContact; use App\Models\Design; use App\Utils\Traits\GeneratesCounter; use App\Utils\Traits\MakesHash; +use App\Utils\Traits\MakesInvoiceHtml; +use App\Utils\Traits\Pdf\PdfMaker; +use Illuminate\Support\Facades\Storage; use Tests\MockAccountData; use Tests\TestCase; @@ -19,10 +26,18 @@ use Tests\TestCase; */ class DesignTest extends TestCase { + use MakesInvoiceHtml; + use PdfMaker; use MockAccountData; use GeneratesCounter; use MakesHash; - + + + /** + * @var ClientContact + */ + private $contact; + public function setUp() :void { parent::setUp(); @@ -32,6 +47,7 @@ class DesignTest extends TestCase public function testInvoiceDesignExists() { + $this->contact = $this->invoice->client->primary_contact()->first(); $design = Design::find(3); @@ -61,10 +77,18 @@ class DesignTest extends TestCase public function testQuoteDesignExists() { - - $design = Design::find(3); - - $designer = new Designer($this->quote, $design, $this->company->settings->pdf_variables, 'quote'); + $invoice_design = new Clean(); + $design_object = new \stdClass; + $design_object->includes = $invoice_design->includes() ?: ''; + $design_object->header = $invoice_design->header() ?: ''; + $design_object->body = $invoice_design->body() ?: ''; + $design_object->product = $invoice_design->product() ?: ''; + $design_object->task = $invoice_design->task() ?: ''; + $design_object->footer = $invoice_design->footer() ?: ''; + $design = new \stdClass; + $design->name = 'Dave Rocks'; + $design->design = $design_object; + $designer = new Designer($this->invoice, $design, $this->company->settings->pdf_variables, 'quote'); $html = $designer->build()->getHtml(); @@ -72,17 +96,12 @@ class DesignTest extends TestCase //\Log::error($html); - $settings = $this->invoice->client->settings; - $settings->quote_design_id = "VolejRejNm"; + $html = $this->generateEntityHtml($designer, $this->invoice, $this->contact); + $pdf = $this->makePdf(null, null, $html); - $this->quote->client_id = $this->client->id; - $this->quote->setRelation('client', $this->client); - $this->quote->save(); + $instance = Storage::disk('local')->put('invoice.pdf', $pdf); - $this->client->settings = $settings; - $this->client->save(); - - CreateQuotePdf::dispatchNow($this->quote, $this->quote->company, $this->quote->client->primary_contact()->first()); + exec('xdg-open ~/Code/invoiceninja/storage/app/invoice.pdf'); } // public function testQuoteDesignWithRepeatingHeader() @@ -184,7 +203,7 @@ class DesignTest extends TestCase $this->credit->client_id = $this->client->id; $this->credit->setRelation('client', $this->client); $this->credit->save(); - + $this->client->settings = $settings; $this->client->save(); @@ -199,7 +218,7 @@ class DesignTest extends TestCase $settings = $this->invoice->client->settings; $settings->quote_design_id = (string)$this->encodePrimaryKey($x); - + $this->quote->client_id = $this->client->id; $this->quote->setRelation('client', $this->client); $this->quote->save(); @@ -217,7 +236,6 @@ class DesignTest extends TestCase $this->assertTrue(true); } - + } - \ No newline at end of file