mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-31 02:04:33 -04:00
Fixes for creating faker data
This commit is contained in:
parent
99b3efda20
commit
c116b48a25
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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();
|
||||
|
||||
|
||||
|
@ -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
|
||||
{
|
||||
@ -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);
|
||||
}
|
||||
@ -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;
|
||||
@ -319,8 +309,9 @@ 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() ?? [],
|
||||
@ -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);
|
||||
|
@ -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
849
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@ -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
|
||||
{
|
||||
//
|
||||
}
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user