diff --git a/app/Services/Client/Statement.php b/app/Services/Client/Statement.php index 163718ea6dbf..55e61356dbe7 100644 --- a/app/Services/Client/Statement.php +++ b/app/Services/Client/Statement.php @@ -63,8 +63,10 @@ class Statement $variables = []; $variables = $html->generateLabelsAndValues(); + + $option_template = &$this->options['template']; - if($this->client->getSetting('statement_design_id') != '') { + if($this->client->getSetting('statement_design_id') != '' || $option_template && $option_template != '') { $variables['values']['$start_date'] = $this->translateDate($this->options['start_date'], $this->client->date_format(), $this->client->locale()); $variables['values']['$end_date'] = $this->translateDate($this->options['end_date'], $this->client->date_format(), $this->client->locale()); diff --git a/app/Services/Template/TemplateAction.php b/app/Services/Template/TemplateAction.php index 919cbe4a0a9d..538320fa9564 100644 --- a/app/Services/Template/TemplateAction.php +++ b/app/Services/Template/TemplateAction.php @@ -11,33 +11,34 @@ namespace App\Services\Template; -use App\Libraries\MultiDB; +use App\Models\Task; +use App\Models\User; +use App\Models\Quote; use App\Models\Client; -use App\Models\Company; use App\Models\Credit; use App\Models\Design; +use App\Models\Vendor; +use App\Models\Company; use App\Models\Expense; use App\Models\Invoice; use App\Models\Payment; use App\Models\Product; use App\Models\Project; +use App\Libraries\MultiDB; use App\Models\PurchaseOrder; -use App\Models\Quote; +use Illuminate\Bus\Queueable; +use App\Utils\Traits\MakesHash; use App\Models\RecurringInvoice; -use App\Models\Task; -use App\Models\User; -use App\Models\Vendor; use App\Services\Email\AdminEmail; use App\Services\Email\EmailObject; -use App\Utils\Traits\MakesHash; -use Illuminate\Bus\Queueable; -use Illuminate\Contracts\Queue\ShouldQueue; -use Illuminate\Foundation\Bus\Dispatchable; +use App\Services\PdfMaker\PdfMerge; use Illuminate\Mail\Mailables\Address; -use Illuminate\Queue\InteractsWithQueue; -use Illuminate\Queue\Middleware\WithoutOverlapping; use Illuminate\Queue\SerializesModels; use Illuminate\Support\Facades\Storage; +use Illuminate\Queue\InteractsWithQueue; +use Illuminate\Contracts\Queue\ShouldQueue; +use Illuminate\Foundation\Bus\Dispatchable; +use Illuminate\Queue\Middleware\WithoutOverlapping; class TemplateAction implements ShouldQueue { @@ -111,6 +112,39 @@ class TemplateAction implements ShouldQueue /** Set a global currency_code */ $first_entity = $result->first(); + /** Lets be clever and sniff out Statements */ + if($first_entity instanceof Client && stripos(json_encode($template->design), '##statement##') !== false) { + + $options = [ + 'show_payments_table' => true, + 'show_aging_table' => true, + 'status' => 'all', + 'show_credits_table' => false, + 'template' => $this->template, + ]; + + $pdfs = []; + + foreach($result as $client) { + $pdfs[] = $client->service()->statement($options); + } + + if(count($pdfs) == 1) { + $pdf = $pdfs[0]; + } else { + $pdf = (new PdfMerge($pdfs))->run(); + } + + if($this->send_email) { + $this->sendEmail($pdf, $template); + } else { + $filename = "templates/{$this->hash}.pdf"; + Storage::disk(config('filesystems.default'))->put($filename, $pdf); + return $pdf; + } + + } + if($first_entity instanceof Client) $currency_code = $first_entity->currency()->code; elseif($first_entity->client) diff --git a/resources/views/templates/delivery_notes/td13.html b/resources/views/templates/delivery_notes/td13.html new file mode 100644 index 000000000000..f095de7a2073 --- /dev/null +++ b/resources/views/templates/delivery_notes/td13.html @@ -0,0 +1,205 @@ + + + + + + + + + + + + + + + + + + +
Delivery Note{{ img('$company.logo') }}
+
+ + + + + + + +
+
+
+

Bill To:

+
+
+

$client.name

+
+
+

$client.shipping_address

+
+
+
+
+
+

Ship To:

+
+
+

$client.name

+
+
+

$client.shipping_address

+
+
+
+ + + + + + +
+
+

Order # $invoice.po_number

+
+
+
+

Order Date: $invoice.date

+
+
+ + + {% set invoice = invoices|first %} + + + + + + + + + + {% for item in invoice.line_items|filter(item => item.type_id == 1) %} + + + + + + {% endfor %} + +
Item #DescriptionDelivered
{{ item.product_key }}{{ item.notes }}{{ item.quantity }}
+
+ + +
+

Notes:

+ + $invoice.public_notes +
+
+ + + + \ No newline at end of file diff --git a/resources/views/templates/statements/ts1.html b/resources/views/templates/statements/ts1.html index 86e0992ac07c..b5bbb8256ed9 100644 --- a/resources/views/templates/statements/ts1.html +++ b/resources/views/templates/statements/ts1.html @@ -1,5 +1,5 @@ - + @@ -13,7 +13,7 @@ } @page { - margin: 0 !important; //removes top and bottom default headers + margin: 0 !important; size: $page_size $page_layout; } diff --git a/resources/views/templates/statements/ts2.html b/resources/views/templates/statements/ts2.html index 1ccbd455678e..cbfd6ca5db82 100644 --- a/resources/views/templates/statements/ts2.html +++ b/resources/views/templates/statements/ts2.html @@ -1,5 +1,5 @@ - + diff --git a/resources/views/templates/statements/ts3.html b/resources/views/templates/statements/ts3.html index 943e32418faf..fd9f04962731 100644 --- a/resources/views/templates/statements/ts3.html +++ b/resources/views/templates/statements/ts3.html @@ -1,5 +1,5 @@ - + diff --git a/resources/views/templates/statements/ts4.html b/resources/views/templates/statements/ts4.html new file mode 100644 index 000000000000..d90f68d19c04 --- /dev/null +++ b/resources/views/templates/statements/ts4.html @@ -0,0 +1,216 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ +
+ +
+
+
+
+
+ +
+

$statement_label

+

$start_date - $end_date

+
+ +
+
+ + + + + + + + + + + + + + + + {% for invoice in invoices %} + + + + + + + + + + {% for payment in invoice.payments|filter(payment => payment.is_deleted == false) %} + + {% for pivot in payment.paymentables %} + + + + + + + + + + + {% endfor %} + {% endfor %} + {% endfor%} + +
Doc #DateDue DateTotalTransactionOutstanding
Invoice - {{ invoice.number }} + {{ invoice.date }}{{ invoice.due_date }}{{ + invoice.amount_raw|format_currency(invoice.client.currency) }}{{ + invoice.balance_raw|format_currency(invoice.client.currency) }}
Payment - {{ payment.number }} + {{ payment.date }} + {% if pivot.amount > 0 %} + {{ pivot.amount_raw|format_currency(payment.currency) }} - {{ payment.type.name + }} + {% else %} + ({{ pivot.refunded_raw|format_currency(payment.currency) }}) + {% endif %} + {{ payment.transaction_reference + }}
+ +
+ + + {% if aging and show_aging %} +
+ + + + {% for key, age in aging %} + + {% endfor %} + + + + + {% for key, age in aging %} + + {% endfor %} + + +
{{ key }}
{{ age }}
+
+ {% endif %} +
+ + + + +
+ +
+ + + + \ No newline at end of file