Fixes for creating faker data

This commit is contained in:
David Bomba 2023-10-25 19:04:27 +11:00
parent 99b3efda20
commit c116b48a25
7 changed files with 513 additions and 734 deletions

View File

@ -349,15 +349,17 @@ class CreateSingleAccount extends Command
});
Project::query()->cursor()->each(function ($p) {
Project::query()->with('client')->whereNotNull('client_id')->cursor()->each(function ($p) {
if(!isset($p->number)) {
if($p && $p->client && !isset($p->number)) {
$p->number = $this->getNextProjectNumber($p);
$p->save();
}
});
$this->info("finished");
}
private function createSubsData($company, $user)
@ -940,11 +942,11 @@ class CreateSingleAccount extends Command
}
}
private function createRecurringInvoice($client)
private function createRecurringInvoice(Client $client)
{
$faker = Factory::create();
$invoice = RecurringInvoiceFactory::create($client->company->id, $client->user->id); //stub the company and user_id
$invoice = RecurringInvoiceFactory::create($client->company_id, $client->user_id); //stub the company and user_id
$invoice->client_id = $client->id;
$dateable = Carbon::now()->subDays(rand(0, 90));
$invoice->date = $dateable;

View File

@ -11,31 +11,16 @@
namespace App\Http\Controllers;
<<<<<<< HEAD
=======
use App\Models\Task;
>>>>>>> support_for_custom_statement_designs
use App\Utils\Ninja;
use App\Models\Quote;
use App\Models\Client;
use App\Models\Credit;
<<<<<<< HEAD
use App\Models\Invoice;
=======
use App\Models\Vendor;
use App\Models\Invoice;
use App\Models\Payment;
use App\Models\Project;
>>>>>>> support_for_custom_statement_designs
use App\Utils\HtmlEngine;
use App\Libraries\MultiDB;
use App\Factory\QuoteFactory;
use App\Jobs\Util\PreviewPdf;
use App\Models\ClientContact;
<<<<<<< HEAD
=======
use App\Models\PurchaseOrder;
>>>>>>> support_for_custom_statement_designs
use App\Services\Pdf\PdfMock;
use App\Factory\CreditFactory;
use App\Factory\InvoiceFactory;
@ -49,10 +34,7 @@ use Illuminate\Support\Facades\DB;
use App\Services\PdfMaker\PdfMaker;
use Illuminate\Support\Facades\App;
use App\Repositories\QuoteRepository;
<<<<<<< HEAD
use Illuminate\Support\Facades\Cache;
=======
>>>>>>> support_for_custom_statement_designs
use App\Repositories\CreditRepository;
use App\Utils\Traits\MakesInvoiceHtml;
use Turbo124\Beacon\Facades\LightLogs;
@ -61,10 +43,7 @@ use App\Utils\Traits\Pdf\PageNumbering;
use App\Factory\RecurringInvoiceFactory;
use Illuminate\Support\Facades\Response;
use App\DataMapper\Analytics\LivePreview;
<<<<<<< HEAD
=======
use App\Services\Template\TemplateService;
>>>>>>> support_for_custom_statement_designs
use App\Repositories\RecurringInvoiceRepository;
use App\Http\Requests\Preview\DesignPreviewRequest;
use App\Services\PdfMaker\Design as PdfDesignModel;
@ -123,7 +102,7 @@ class PreviewController extends BaseController
if(!$entity_obj->id) {
$entity_obj->design_id = intval($this->decodePrimaryKey($settings->{$entity_prop."_design_id"}));
$entity_obj->footer = empty($entity_obj->footer) ? $settings->{$entity_prop."_footer"} : $entity_obj->footer;
$entity_obj->terms = empty($entity_obj->term) ? $settings->{$entity_prop."_terms"} : $entity_obj->terms;
$entity_obj->terms = empty($entity_obj->terms) ? $settings->{$entity_prop."_terms"} : $entity_obj->terms;
$entity_obj->public_notes = empty($entity_obj->public_notes) ? $request->getClient()->public_notes : $entity_obj->public_notes;
$invitation->{$request->entity} = $entity_obj;
}

View File

@ -66,7 +66,6 @@ class PdfService
public function boot(): self
{
$this->start_time = microtime(true);
$this->init();
@ -109,6 +108,7 @@ class PdfService
*/
public function getHtml(): string
{
$html = $this->builder->getCompiledHTML();
if (config('ninja.log_pdf_html')) {
@ -127,6 +127,8 @@ class PdfService
*/
public function init(): self
{
$this->start_time = microtime(true);
$this->config = (new PdfConfiguration($this))->init();

View File

@ -11,32 +11,27 @@
namespace App\Services\Template;
use App\Utils\Number;
use App\Models\Client;
use App\Models\Credit;
use App\Models\Design;
use App\Models\Company;
use App\Models\Design;
use App\Models\Invoice;
use App\Models\Payment;
use App\Models\Project;
use App\Models\Activity;
use App\Utils\HtmlEngine;
use League\Fractal\Manager;
use App\Models\PurchaseOrder;
use App\Utils\VendorHtmlEngine;
use App\Utils\PaymentHtmlEngine;
use App\Utils\Traits\MakesDates;
use App\Utils\HostedPDF\NinjaPdf;
use App\Utils\Traits\Pdf\PdfMaker;
use Twig\Extra\Intl\IntlExtension;
use App\Transformers\TaskTransformer;
use App\Transformers\QuoteTransformer;
use App\Services\Template\TemplateMock;
use App\Transformers\CreditTransformer;
use App\Transformers\InvoiceTransformer;
use App\Transformers\ProjectTransformer;
use App\Transformers\PurchaseOrderTransformer;
use App\Transformers\QuoteTransformer;
use App\Transformers\TaskTransformer;
use App\Utils\HostedPDF\NinjaPdf;
use App\Utils\HtmlEngine;
use App\Utils\Number;
use App\Utils\PaymentHtmlEngine;
use App\Utils\Traits\MakesDates;
use App\Utils\Traits\Pdf\PdfMaker;
use App\Utils\VendorHtmlEngine;
use League\Fractal\Manager;
use League\Fractal\Serializer\ArraySerializer;
use Twig\Extra\Intl\IntlExtension;
class TemplateService
{
@ -71,7 +66,7 @@ class TemplateService
$this->document->validateOnParse = true;
$loader = new \Twig\Loader\FilesystemLoader(storage_path());
$this->twig = new \Twig\Environment($loader,[
$this->twig = new \Twig\Environment($loader, [
'debug' => true,
]);
$string_extension = new \Twig\Extension\StringLoaderExtension();
@ -106,7 +101,7 @@ class TemplateService
->processData($data)
->parseNinjaBlocks()
->processVariables($data)
->parseVariables();
->parseVariables();
return $this;
}
@ -171,7 +166,7 @@ class TemplateService
/**
* Parses all Ninja tags in the document
*
*
* @return self
*/
private function parseNinjaBlocks(): self
@ -186,24 +181,19 @@ class TemplateService
try {
$template = $this->twig->createTemplate(html_entity_decode($template));
}
catch(\Twig\Error\SyntaxError $e) {
} catch(\Twig\Error\SyntaxError $e) {
nlog($e->getMessage());
throw ($e);
}
catch(\Twig\Error\Error $e) {
} catch(\Twig\Error\Error $e) {
nlog("error = " .$e->getMessage());
throw ($e);
}
catch(\Twig\Error\RuntimeError $e) {
} catch(\Twig\Error\RuntimeError $e) {
nlog("runtime = " .$e->getMessage());
throw ($e);
}
catch(\Twig\Error\LoaderError $e) {
} catch(\Twig\Error\LoaderError $e) {
nlog("loader = " . $e->getMessage());
throw ($e);
}
catch(\Twig\Error\SecurityError $e) {
} catch(\Twig\Error\SecurityError $e) {
nlog("security = " . $e->getMessage());
throw ($e);
}
@ -229,7 +219,7 @@ class TemplateService
/**
* Parses all variables in the document
*
*
* @return self
*/
private function parseVariables(): self
@ -239,8 +229,7 @@ class TemplateService
foreach($this->variables as $key => $variable) {
if(isset($variable['labels']) && isset($variable['values']))
{
if(isset($variable['labels']) && isset($variable['values'])) {
$html = strtr($html, $variable['labels']);
$html = strtr($html, $variable['values']);
}
@ -271,8 +260,9 @@ class TemplateService
*/
private function compose(): self
{
if(!$this->template)
if(!$this->template) {
return $this;
}
$html = '';
$html .= $this->template->design->includes;
@ -287,7 +277,7 @@ class TemplateService
}
/**
* Inject the template components
* Inject the template components
* manually
*
* @return self
@ -319,11 +309,12 @@ class TemplateService
$processed = [];
if(in_array($key, ['tasks','projects','aging']) || !$value->first() )
if(in_array($key, ['tasks','projects','aging']) || !$value->first()) {
return $processed;
}
match ($key) {
'variables' => $processed = $value->first() ?? [],
'variables' => $processed = $value->first() ?? [],
'invoices' => $processed = (new HtmlEngine($value->first()->invitations()->first()))->generateLabelsAndValues() ?? [],
'quotes' => $processed = (new HtmlEngine($value->first()->invitations()->first()))->generateLabelsAndValues() ?? [],
'credits' => $processed = (new HtmlEngine($value->first()->invitations()->first()))->generateLabelsAndValues() ?? [],
@ -343,7 +334,7 @@ class TemplateService
private function preProcessDataBlocks($data): array
{
return collect($data)->map(function ($value, $key){
return collect($data)->map(function ($value, $key) {
$processed = [];
@ -367,75 +358,75 @@ class TemplateService
public function processInvoices($invoices): array
{
$invoices = collect($invoices)
->map(function ($invoice){
->map(function ($invoice) {
$payments = [];
$payments = [];
if($invoice->payments ?? false) {
$payments = $invoice->payments->map(function ($payment) {
return $this->transformPayment($payment);
})->toArray();
}
if($invoice->payments ?? false) {
$payments = $invoice->payments->map(function ($payment) {
return $this->transformPayment($payment);
})->toArray();
}
return [
'amount' => Number::formatMoney($invoice->amount, $invoice->client),
'balance' => Number::formatMoney($invoice->balance, $invoice->client),
'balance_raw' => $invoice->balance,
'number' => $invoice->number ?: '',
'discount' => $invoice->discount,
'po_number' => $invoice->po_number ?: '',
'date' => $this->translateDate($invoice->date, $invoice->client->date_format(), $invoice->client->locale()),
'last_sent_date' => $this->translateDate($invoice->last_sent_date, $invoice->client->date_format(), $invoice->client->locale()),
'next_send_date' => $this->translateDate($invoice->next_send_date, $invoice->client->date_format(), $invoice->client->locale()),
'due_date' => $this->translateDate($invoice->due_date, $invoice->client->date_format(), $invoice->client->locale()),
'terms' => $invoice->terms ?: '',
'public_notes' => $invoice->public_notes ?: '',
'private_notes' => $invoice->private_notes ?: '',
'uses_inclusive_taxes' => (bool) $invoice->uses_inclusive_taxes,
'tax_name1' => $invoice->tax_name1 ?? '',
'tax_rate1' => (float) $invoice->tax_rate1,
'tax_name2' => $invoice->tax_name2 ?? '',
'tax_rate2' => (float) $invoice->tax_rate2,
'tax_name3' => $invoice->tax_name3 ?? '',
'tax_rate3' => (float) $invoice->tax_rate3,
'total_taxes' => Number::formatMoney($invoice->total_taxes, $invoice->client),
'total_taxes_raw' => $invoice->total_taxes,
'is_amount_discount' => (bool) $invoice->is_amount_discount ?? false,
'footer' => $invoice->footer ?? '',
'partial' => $invoice->partial ?? 0,
'partial_due_date' => $this->translateDate($invoice->partial_due_date, $invoice->client->date_format(), $invoice->client->locale()),
'custom_value1' => (string) $invoice->custom_value1 ?: '',
'custom_value2' => (string) $invoice->custom_value2 ?: '',
'custom_value3' => (string) $invoice->custom_value3 ?: '',
'custom_value4' => (string) $invoice->custom_value4 ?: '',
'custom_surcharge1' => (float) $invoice->custom_surcharge1,
'custom_surcharge2' => (float) $invoice->custom_surcharge2,
'custom_surcharge3' => (float) $invoice->custom_surcharge3,
'custom_surcharge4' => (float) $invoice->custom_surcharge4,
'exchange_rate' => (float) $invoice->exchange_rate,
'custom_surcharge_tax1' => (bool) $invoice->custom_surcharge_tax1,
'custom_surcharge_tax2' => (bool) $invoice->custom_surcharge_tax2,
'custom_surcharge_tax3' => (bool) $invoice->custom_surcharge_tax3,
'custom_surcharge_tax4' => (bool) $invoice->custom_surcharge_tax4,
'line_items' => $invoice->line_items ? $this->padLineItems($invoice->line_items, $invoice->client): (array) [],
'reminder1_sent' => $this->translateDate($invoice->reminder1_sent, $invoice->client->date_format(), $invoice->client->locale()),
'reminder2_sent' => $this->translateDate($invoice->reminder2_sent, $invoice->client->date_format(), $invoice->client->locale()),
'reminder3_sent' => $this->translateDate($invoice->reminder3_sent, $invoice->client->date_format(), $invoice->client->locale()),
'reminder_last_sent' => $this->translateDate($invoice->reminder_last_sent, $invoice->client->date_format(), $invoice->client->locale()),
'paid_to_date' => Number::formatMoney($invoice->paid_to_date, $invoice->client),
'auto_bill_enabled' => (bool) $invoice->auto_bill_enabled,
'client' => [
'name' => $invoice->client->present()->name(),
'balance' => $invoice->client->balance,
'payment_balance' => $invoice->client->payment_balance,
'credit_balance' => $invoice->client->credit_balance,
],
'payments' => $payments,
'total_tax_map' => $invoice->calc()->getTotalTaxMap(),
'line_tax_map' => $invoice->calc()->getTaxMap(),
];
return [
'amount' => Number::formatMoney($invoice->amount, $invoice->client),
'balance' => Number::formatMoney($invoice->balance, $invoice->client),
'balance_raw' => $invoice->balance,
'number' => $invoice->number ?: '',
'discount' => $invoice->discount,
'po_number' => $invoice->po_number ?: '',
'date' => $this->translateDate($invoice->date, $invoice->client->date_format(), $invoice->client->locale()),
'last_sent_date' => $this->translateDate($invoice->last_sent_date, $invoice->client->date_format(), $invoice->client->locale()),
'next_send_date' => $this->translateDate($invoice->next_send_date, $invoice->client->date_format(), $invoice->client->locale()),
'due_date' => $this->translateDate($invoice->due_date, $invoice->client->date_format(), $invoice->client->locale()),
'terms' => $invoice->terms ?: '',
'public_notes' => $invoice->public_notes ?: '',
'private_notes' => $invoice->private_notes ?: '',
'uses_inclusive_taxes' => (bool) $invoice->uses_inclusive_taxes,
'tax_name1' => $invoice->tax_name1 ?? '',
'tax_rate1' => (float) $invoice->tax_rate1,
'tax_name2' => $invoice->tax_name2 ?? '',
'tax_rate2' => (float) $invoice->tax_rate2,
'tax_name3' => $invoice->tax_name3 ?? '',
'tax_rate3' => (float) $invoice->tax_rate3,
'total_taxes' => Number::formatMoney($invoice->total_taxes, $invoice->client),
'total_taxes_raw' => $invoice->total_taxes,
'is_amount_discount' => (bool) $invoice->is_amount_discount ?? false,
'footer' => $invoice->footer ?? '',
'partial' => $invoice->partial ?? 0,
'partial_due_date' => $this->translateDate($invoice->partial_due_date, $invoice->client->date_format(), $invoice->client->locale()),
'custom_value1' => (string) $invoice->custom_value1 ?: '',
'custom_value2' => (string) $invoice->custom_value2 ?: '',
'custom_value3' => (string) $invoice->custom_value3 ?: '',
'custom_value4' => (string) $invoice->custom_value4 ?: '',
'custom_surcharge1' => (float) $invoice->custom_surcharge1,
'custom_surcharge2' => (float) $invoice->custom_surcharge2,
'custom_surcharge3' => (float) $invoice->custom_surcharge3,
'custom_surcharge4' => (float) $invoice->custom_surcharge4,
'exchange_rate' => (float) $invoice->exchange_rate,
'custom_surcharge_tax1' => (bool) $invoice->custom_surcharge_tax1,
'custom_surcharge_tax2' => (bool) $invoice->custom_surcharge_tax2,
'custom_surcharge_tax3' => (bool) $invoice->custom_surcharge_tax3,
'custom_surcharge_tax4' => (bool) $invoice->custom_surcharge_tax4,
'line_items' => $invoice->line_items ? $this->padLineItems($invoice->line_items, $invoice->client): (array) [],
'reminder1_sent' => $this->translateDate($invoice->reminder1_sent, $invoice->client->date_format(), $invoice->client->locale()),
'reminder2_sent' => $this->translateDate($invoice->reminder2_sent, $invoice->client->date_format(), $invoice->client->locale()),
'reminder3_sent' => $this->translateDate($invoice->reminder3_sent, $invoice->client->date_format(), $invoice->client->locale()),
'reminder_last_sent' => $this->translateDate($invoice->reminder_last_sent, $invoice->client->date_format(), $invoice->client->locale()),
'paid_to_date' => Number::formatMoney($invoice->paid_to_date, $invoice->client),
'auto_bill_enabled' => (bool) $invoice->auto_bill_enabled,
'client' => [
'name' => $invoice->client->present()->name(),
'balance' => $invoice->client->balance,
'payment_balance' => $invoice->client->payment_balance,
'credit_balance' => $invoice->client->credit_balance,
],
'payments' => $payments,
'total_tax_map' => $invoice->calc()->getTotalTaxMap(),
'line_tax_map' => $invoice->calc()->getTaxMap(),
];
});
});
return $invoices->toArray();
@ -443,7 +434,7 @@ class TemplateService
public function padLineItems(array $items, Client $client): array
{
return collect($items)->map(function ($item) use ($client){
return collect($items)->map(function ($item) use ($client) {
$item->cost_raw = $item->cost ?? 0;
$item->discount_raw = $item->discount ?? 0;
@ -454,8 +445,9 @@ class TemplateService
$item->cost = Number::formatMoney($item->cost_raw, $client);
if($item->is_amount_discount)
if($item->is_amount_discount) {
$item->discount = Number::formatMoney($item->discount_raw, $client);
}
$item->line_total = Number::formatMoney($item->line_total_raw, $client);
$item->gross_line_total = Number::formatMoney($item->gross_line_total_raw, $client);
@ -570,7 +562,7 @@ class TemplateService
{
return collect($payment->refund_meta ?? [])
->map(function ($refund) use($payment){
->map(function ($refund) use ($payment) {
$date = \Carbon\Carbon::parse($refund['date'])->addSeconds($payment->client->timezone_offset());
$date = $this->translateDate($date, $payment->client->date_format(), $payment->client->locale());
@ -579,7 +571,7 @@ class TemplateService
$map = [];
foreach($refund['invoices'] as $refunded_invoice) {
$invoice = Invoice::withTrashed()->find($refunded_invoice['invoice_id']);
$invoice = Invoice::withTrashed()->find($refunded_invoice['invoice_id']);
$amount = Number::formatMoney($refunded_invoice['amount'], $payment->client);
$notes = ctrans('texts.status_partially_refunded_amount', ['amount' => $amount]);
@ -623,67 +615,67 @@ class TemplateService
public function processCredits($credits): array
{
$credits = collect($credits)
->map(function ($credit){
->map(function ($credit) {
return [
'amount' => Number::formatMoney($credit->amount, $credit->client),
'balance' => Number::formatMoney($credit->balance, $credit->client),
'balance_raw' => $credit->balance,
'number' => $credit->number ?: '',
'discount' => $credit->discount,
'po_number' => $credit->po_number ?: '',
'date' => $this->translateDate($credit->date, $credit->client->date_format(), $credit->client->locale()),
'last_sent_date' => $this->translateDate($credit->last_sent_date, $credit->client->date_format(), $credit->client->locale()),
'next_send_date' => $this->translateDate($credit->next_send_date, $credit->client->date_format(), $credit->client->locale()),
'due_date' => $this->translateDate($credit->due_date, $credit->client->date_format(), $credit->client->locale()),
'terms' => $credit->terms ?: '',
'public_notes' => $credit->public_notes ?: '',
'private_notes' => $credit->private_notes ?: '',
'uses_inclusive_taxes' => (bool) $credit->uses_inclusive_taxes,
'tax_name1' => $credit->tax_name1 ?? '',
'tax_rate1' => (float) $credit->tax_rate1,
'tax_name2' => $credit->tax_name2 ?? '',
'tax_rate2' => (float) $credit->tax_rate2,
'tax_name3' => $credit->tax_name3 ?? '',
'tax_rate3' => (float) $credit->tax_rate3,
'total_taxes' => Number::formatMoney($credit->total_taxes, $credit->client),
'total_taxes_raw' => $credit->total_taxes,
'is_amount_discount' => (bool) $credit->is_amount_discount ?? false,
'footer' => $credit->footer ?? '',
'partial' => $credit->partial ?? 0,
'partial_due_date' => $this->translateDate($credit->partial_due_date, $credit->client->date_format(), $credit->client->locale()),
'custom_value1' => (string) $credit->custom_value1 ?: '',
'custom_value2' => (string) $credit->custom_value2 ?: '',
'custom_value3' => (string) $credit->custom_value3 ?: '',
'custom_value4' => (string) $credit->custom_value4 ?: '',
'custom_surcharge1' => (float) $credit->custom_surcharge1,
'custom_surcharge2' => (float) $credit->custom_surcharge2,
'custom_surcharge3' => (float) $credit->custom_surcharge3,
'custom_surcharge4' => (float) $credit->custom_surcharge4,
'exchange_rate' => (float) $credit->exchange_rate,
'custom_surcharge_tax1' => (bool) $credit->custom_surcharge_tax1,
'custom_surcharge_tax2' => (bool) $credit->custom_surcharge_tax2,
'custom_surcharge_tax3' => (bool) $credit->custom_surcharge_tax3,
'custom_surcharge_tax4' => (bool) $credit->custom_surcharge_tax4,
'line_items' => $credit->line_items ? $this->padLineItems($credit->line_items, $credit->client): (array) [],
'reminder1_sent' => $this->translateDate($credit->reminder1_sent, $credit->client->date_format(), $credit->client->locale()),
'reminder2_sent' => $this->translateDate($credit->reminder2_sent, $credit->client->date_format(), $credit->client->locale()),
'reminder3_sent' => $this->translateDate($credit->reminder3_sent, $credit->client->date_format(), $credit->client->locale()),
'reminder_last_sent' => $this->translateDate($credit->reminder_last_sent, $credit->client->date_format(), $credit->client->locale()),
'paid_to_date' => Number::formatMoney($credit->paid_to_date, $credit->client),
'auto_bill_enabled' => (bool) $credit->auto_bill_enabled,
'client' => [
'name' => $credit->client->present()->name(),
'balance' => $credit->client->balance,
'payment_balance' => $credit->client->payment_balance,
'credit_balance' => $credit->client->credit_balance,
],
'payments' => [],
'total_tax_map' => $credit->calc()->getTotalTaxMap(),
'line_tax_map' => $credit->calc()->getTaxMap(),
];
return [
'amount' => Number::formatMoney($credit->amount, $credit->client),
'balance' => Number::formatMoney($credit->balance, $credit->client),
'balance_raw' => $credit->balance,
'number' => $credit->number ?: '',
'discount' => $credit->discount,
'po_number' => $credit->po_number ?: '',
'date' => $this->translateDate($credit->date, $credit->client->date_format(), $credit->client->locale()),
'last_sent_date' => $this->translateDate($credit->last_sent_date, $credit->client->date_format(), $credit->client->locale()),
'next_send_date' => $this->translateDate($credit->next_send_date, $credit->client->date_format(), $credit->client->locale()),
'due_date' => $this->translateDate($credit->due_date, $credit->client->date_format(), $credit->client->locale()),
'terms' => $credit->terms ?: '',
'public_notes' => $credit->public_notes ?: '',
'private_notes' => $credit->private_notes ?: '',
'uses_inclusive_taxes' => (bool) $credit->uses_inclusive_taxes,
'tax_name1' => $credit->tax_name1 ?? '',
'tax_rate1' => (float) $credit->tax_rate1,
'tax_name2' => $credit->tax_name2 ?? '',
'tax_rate2' => (float) $credit->tax_rate2,
'tax_name3' => $credit->tax_name3 ?? '',
'tax_rate3' => (float) $credit->tax_rate3,
'total_taxes' => Number::formatMoney($credit->total_taxes, $credit->client),
'total_taxes_raw' => $credit->total_taxes,
'is_amount_discount' => (bool) $credit->is_amount_discount ?? false,
'footer' => $credit->footer ?? '',
'partial' => $credit->partial ?? 0,
'partial_due_date' => $this->translateDate($credit->partial_due_date, $credit->client->date_format(), $credit->client->locale()),
'custom_value1' => (string) $credit->custom_value1 ?: '',
'custom_value2' => (string) $credit->custom_value2 ?: '',
'custom_value3' => (string) $credit->custom_value3 ?: '',
'custom_value4' => (string) $credit->custom_value4 ?: '',
'custom_surcharge1' => (float) $credit->custom_surcharge1,
'custom_surcharge2' => (float) $credit->custom_surcharge2,
'custom_surcharge3' => (float) $credit->custom_surcharge3,
'custom_surcharge4' => (float) $credit->custom_surcharge4,
'exchange_rate' => (float) $credit->exchange_rate,
'custom_surcharge_tax1' => (bool) $credit->custom_surcharge_tax1,
'custom_surcharge_tax2' => (bool) $credit->custom_surcharge_tax2,
'custom_surcharge_tax3' => (bool) $credit->custom_surcharge_tax3,
'custom_surcharge_tax4' => (bool) $credit->custom_surcharge_tax4,
'line_items' => $credit->line_items ? $this->padLineItems($credit->line_items, $credit->client): (array) [],
'reminder1_sent' => $this->translateDate($credit->reminder1_sent, $credit->client->date_format(), $credit->client->locale()),
'reminder2_sent' => $this->translateDate($credit->reminder2_sent, $credit->client->date_format(), $credit->client->locale()),
'reminder3_sent' => $this->translateDate($credit->reminder3_sent, $credit->client->date_format(), $credit->client->locale()),
'reminder_last_sent' => $this->translateDate($credit->reminder_last_sent, $credit->client->date_format(), $credit->client->locale()),
'paid_to_date' => Number::formatMoney($credit->paid_to_date, $credit->client),
'auto_bill_enabled' => (bool) $credit->auto_bill_enabled,
'client' => [
'name' => $credit->client->present()->name(),
'balance' => $credit->client->balance,
'payment_balance' => $credit->client->payment_balance,
'credit_balance' => $credit->client->credit_balance,
],
'payments' => [],
'total_tax_map' => $credit->calc()->getTotalTaxMap(),
'line_tax_map' => $credit->calc()->getTaxMap(),
];
});
});
return $credits->toArray();
@ -776,4 +768,4 @@ class TemplateService
return $this;
}
}
}

View File

@ -794,16 +794,16 @@ trait GeneratesCounter
$replace = [];
$search[] = '{$user_custom1}';
$replace[] = $entity->user->custom_value1;
$replace[] = $entity->user->custom_value1 ?? '';
$search[] = '{$user_custom2}';
$replace[] = $entity->user->custom_value2;
$replace[] = $entity->user->custom_value2 ?? '';
$search[] = '{$user_custom3}';
$replace[] = $entity->user->custom_value3;
$replace[] = $entity->user->custom_value3 ?? '';
$search[] = '{$user_custom4}';
$replace[] = $entity->user->custom_value4;
$replace[] = $entity->user->custom_value4 ?? '';
return str_replace($search, $replace, $pattern);
}

849
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,27 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('clients', function (Blueprint $table) {
$table->string('classification')->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
//
}
};