mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-31 07:24:35 -04:00
Updates for migration vendors
This commit is contained in:
parent
6cd7235b41
commit
aae986333a
@ -811,6 +811,10 @@ class Import implements ShouldQueue
|
|||||||
$modified['updated_at'] = Carbon::parse($modified['updated_at']);
|
$modified['updated_at'] = Carbon::parse($modified['updated_at']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!array_key_exists('currency_id', $modified) || !$modified['currency_id']) {
|
||||||
|
$modified['currency_id'] = $this->company->settings->currency_id;
|
||||||
|
}
|
||||||
|
|
||||||
$vendor = $vendor_repository->save(
|
$vendor = $vendor_repository->save(
|
||||||
$modified,
|
$modified,
|
||||||
VendorFactory::create(
|
VendorFactory::create(
|
||||||
|
@ -362,10 +362,10 @@ class PaymentEmailEngine extends BaseEmailEngine
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* generateLabelsAndValues
|
* generateLabelsAndValues
|
||||||
*
|
*
|
||||||
* @return void
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function generateLabelsAndValues()
|
public function generateLabelsAndValues(): array
|
||||||
{
|
{
|
||||||
$data = [];
|
$data = [];
|
||||||
|
|
||||||
|
@ -683,8 +683,6 @@ class HtmlEngine
|
|||||||
$data['labels'][$key.'_label'] = $value['label'];
|
$data['labels'][$key.'_label'] = $value['label'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// nlog($data);
|
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,27 +12,28 @@
|
|||||||
|
|
||||||
namespace App\Utils;
|
namespace App\Utils;
|
||||||
|
|
||||||
use App\DataMapper\EmailTemplateDefaults;
|
|
||||||
use App\Mail\Engine\PaymentEmailEngine;
|
|
||||||
use App\Models\Client;
|
|
||||||
use App\Models\ClientContact;
|
|
||||||
use App\Models\Invoice;
|
|
||||||
use App\Models\InvoiceInvitation;
|
|
||||||
use App\Models\Payment;
|
|
||||||
use App\Models\PurchaseOrder;
|
|
||||||
use App\Models\PurchaseOrderInvitation;
|
|
||||||
use App\Models\Quote;
|
|
||||||
use App\Models\QuoteInvitation;
|
|
||||||
use App\Models\Vendor;
|
|
||||||
use App\Models\VendorContact;
|
|
||||||
use App\Services\PdfMaker\Designs\Utilities\DesignHelpers;
|
|
||||||
use App\Utils\Traits\MakesHash;
|
|
||||||
use App\Utils\Traits\MakesInvoiceHtml;
|
|
||||||
use App\Utils\Traits\MakesTemplateData;
|
|
||||||
use DB;
|
use DB;
|
||||||
use Illuminate\Support\Facades\App;
|
use App\Models\Quote;
|
||||||
|
use App\Models\Client;
|
||||||
|
use App\Models\Vendor;
|
||||||
|
use App\Models\Invoice;
|
||||||
|
use App\Models\Payment;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
use App\Models\ClientContact;
|
||||||
|
use App\Models\PurchaseOrder;
|
||||||
|
use App\Models\VendorContact;
|
||||||
|
use App\Services\Pdf\PdfMock;
|
||||||
|
use App\Models\QuoteInvitation;
|
||||||
|
use App\Utils\Traits\MakesHash;
|
||||||
|
use App\Models\InvoiceInvitation;
|
||||||
|
use Illuminate\Support\Facades\App;
|
||||||
|
use App\Utils\Traits\MakesInvoiceHtml;
|
||||||
|
use App\Mail\Engine\PaymentEmailEngine;
|
||||||
|
use App\Models\PurchaseOrderInvitation;
|
||||||
|
use App\Utils\Traits\MakesTemplateData;
|
||||||
|
use App\DataMapper\EmailTemplateDefaults;
|
||||||
use League\CommonMark\CommonMarkConverter;
|
use League\CommonMark\CommonMarkConverter;
|
||||||
|
use App\Services\PdfMaker\Designs\Utilities\DesignHelpers;
|
||||||
|
|
||||||
class TemplateEngine
|
class TemplateEngine
|
||||||
{
|
{
|
||||||
@ -96,7 +97,19 @@ class TemplateEngine
|
|||||||
if (strlen($this->entity) > 1 && strlen($this->entity_id) > 1) {
|
if (strlen($this->entity) > 1 && strlen($this->entity_id) > 1) {
|
||||||
$class = 'App\Models\\' . ucfirst(Str::camel($this->entity));
|
$class = 'App\Models\\' . ucfirst(Str::camel($this->entity));
|
||||||
$this->entity_obj = $class::withTrashed()->where('id', $this->decodePrimaryKey($this->entity_id))->company()->first();
|
$this->entity_obj = $class::withTrashed()->where('id', $this->decodePrimaryKey($this->entity_id))->company()->first();
|
||||||
} else {
|
}
|
||||||
|
elseif(stripos($this->template, 'quote') !== false && $quote = Quote::whereHas('invitations')->withTrashed()->company()->first()){
|
||||||
|
$this->entity = 'quote';
|
||||||
|
$this->entity_obj = $quote;
|
||||||
|
}
|
||||||
|
elseif(stripos($this->template, 'purchase') !== false && $purchase_order = PurchaseOrder::whereHas('invitations')->withTrashed()->company()->first()){
|
||||||
|
$this->entity = 'purchase_order';
|
||||||
|
$this->entity_obj = $purchase_order;
|
||||||
|
}
|
||||||
|
elseif ($invoice = Invoice::whereHas('invitations')->withTrashed()->company()->first()){
|
||||||
|
$this->entity_obj = $invoice;
|
||||||
|
}
|
||||||
|
else {
|
||||||
$this->mockEntity();
|
$this->mockEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,6 +196,7 @@ class TemplateEngine
|
|||||||
|
|
||||||
private function entityValues($contact)
|
private function entityValues($contact)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (in_array($this->entity, ['purchaseOrder', 'purchase_order'])) {
|
if (in_array($this->entity, ['purchaseOrder', 'purchase_order'])) {
|
||||||
$this->labels_and_values = (new VendorHtmlEngine($this->entity_obj->invitations->first()))->generateLabelsAndValues();
|
$this->labels_and_values = (new VendorHtmlEngine($this->entity_obj->invitations->first()))->generateLabelsAndValues();
|
||||||
} elseif ($this->entity == 'payment') {
|
} elseif ($this->entity == 'payment') {
|
||||||
@ -323,6 +337,8 @@ class TemplateEngine
|
|||||||
'user_id' => auth()->user()->id,
|
'user_id' => auth()->user()->id,
|
||||||
'company_id' => auth()->user()->company()->id,
|
'company_id' => auth()->user()->company()->id,
|
||||||
'client_id' => $client->id,
|
'client_id' => $client->id,
|
||||||
|
'amount' => '10',
|
||||||
|
'balance' => '10',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$invitation = InvoiceInvitation::factory()->create([
|
$invitation = InvoiceInvitation::factory()->create([
|
||||||
@ -391,6 +407,7 @@ class TemplateEngine
|
|||||||
$this->entity_obj->load('client');
|
$this->entity_obj->load('client');
|
||||||
$client->setRelation('company', auth()->user()->company());
|
$client->setRelation('company', auth()->user()->company());
|
||||||
$client->load('company');
|
$client->load('company');
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -511,7 +511,7 @@ class VendorHtmlEngine
|
|||||||
$data['values'][$key] = $value['value'];
|
$data['values'][$key] = $value['value'];
|
||||||
$data['labels'][$key.'_label'] = $value['label'];
|
$data['labels'][$key.'_label'] = $value['label'];
|
||||||
}
|
}
|
||||||
nlog($data);
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user