diff --git a/app/Http/Middleware/QueryLogging.php b/app/Http/Middleware/QueryLogging.php index dc343832d86e..57cd4ccb96ea 100644 --- a/app/Http/Middleware/QueryLogging.php +++ b/app/Http/Middleware/QueryLogging.php @@ -53,7 +53,7 @@ class QueryLogging Log::info($request->method().' - '.$request->url().": $count queries - ".$time); // if($count > 50) - // Log::info($queries); + Log::info($queries); } } diff --git a/app/Jobs/Util/Import.php b/app/Jobs/Util/Import.php index fdbcfe897c09..10c7911a7059 100644 --- a/app/Jobs/Util/Import.php +++ b/app/Jobs/Util/Import.php @@ -99,14 +99,14 @@ class Import implements ShouldQueue 'payment_terms', 'tax_rates', 'clients', - // 'products', - // 'invoices', + 'products', + 'invoices', 'recurring_invoices', - // 'quotes', - // 'payments', - // 'credits', - // 'company_gateways', - // 'client_gateway_tokens', + 'quotes', + 'payments', + 'credits', + 'company_gateways', + 'client_gateway_tokens', // //'documents', ]; diff --git a/app/Repositories/Migration/InvoiceMigrationRepository.php b/app/Repositories/Migration/InvoiceMigrationRepository.php index 6c555f39568a..9230c9a80bfd 100644 --- a/app/Repositories/Migration/InvoiceMigrationRepository.php +++ b/app/Repositories/Migration/InvoiceMigrationRepository.php @@ -84,8 +84,6 @@ class InvoiceMigrationRepository extends BaseRepository $this->saveDocuments($data['documents'], $model); } - info(sprintf('App\\Factory\\%sInvitationFactory', $resource)); - $invitation_factory_class = sprintf('App\\Factory\\%sInvitationFactory', $resource); if (isset($data['client_contacts'])) { @@ -134,20 +132,16 @@ class InvoiceMigrationRepository extends BaseRepository $model->service()->createInvitations(); } -info("saving 3a"); - $model = $model->calc()->getInvoice(); -info("saving 3b"); $state['finished_amount'] = $model->amount; $model = $model->service()->applyNumber()->save(); -info("saving 3c"); if ($model->company->update_products !== false) { UpdateOrCreateProduct::dispatch($model->line_items, $model, $model->company); } -info("saving 4"); + if ($class->name == Invoice::class || $class->name == RecurringInvoice::class) { if (($state['finished_amount'] != $state['starting_amount']) && ($model->status_id != Invoice::STATUS_DRAFT)) { @@ -177,7 +171,7 @@ info("saving 4"); } $model->save(); -info("saving 5"); + return $model->fresh(); } } diff --git a/app/Services/Recurring/ApplyNumber.php b/app/Services/Recurring/ApplyNumber.php index e791921a5f5e..abef623d1362 100644 --- a/app/Services/Recurring/ApplyNumber.php +++ b/app/Services/Recurring/ApplyNumber.php @@ -44,7 +44,7 @@ class ApplyNumber extends AbstractService break; default: - // code... + $this->recurring_entity->number = $this->getNextRecurringInvoiceNumber($this->client); break; } diff --git a/app/Services/Recurring/CreateRecurringInvitations.php b/app/Services/Recurring/CreateRecurringInvitations.php index e3509864fe53..9e753e462696 100644 --- a/app/Services/Recurring/CreateRecurringInvitations.php +++ b/app/Services/Recurring/CreateRecurringInvitations.php @@ -43,38 +43,31 @@ class CreateRecurringInvitations extends AbstractService public function run() { - info($this->entity_name); - info($this->entity_id_name); - info($this->invitation_class); - info($this->invitation_factory); - - try { - $this->entity->client->contacts->each(function ($contact) { + try { + $this->entity->client->contacts->each(function ($contact) { - $invitation = $this->invitation_class::whereCompanyId($this->entity->company_id) - ->whereClientContactId($contact->id) - ->where($this->entity_id_name, $this->entity->id) - ->withTrashed() - ->first(); + $invitation = $this->invitation_class::whereCompanyId($this->entity->company_id) + ->whereClientContactId($contact->id) + ->where($this->entity_id_name, $this->entity->id) + ->withTrashed() + ->first(); - if (! $invitation && $contact->send_email) { - $ii = $this->invitation_factory::create($this->entity->company_id, $this->entity->user_id); - $ii->{$this->entity_id_name} = $this->entity->id; - $ii->client_contact_id = $contact->id; - $ii->save(); - } elseif ($invitation && ! $contact->send_email) { - $invitation->delete(); - } + if (! $invitation && $contact->send_email) { + $ii = $this->invitation_factory::create($this->entity->company_id, $this->entity->user_id); + $ii->{$this->entity_id_name} = $this->entity->id; + $ii->client_contact_id = $contact->id; + $ii->save(); + } elseif ($invitation && ! $contact->send_email) { + $invitation->delete(); + } - }); - } - catch(\Exception $e) - { - info($e->getMessage()); - } - - info("returning the entity"); + }); + } + catch(\Exception $e) + { + info($e->getMessage()); + } return $this->entity; } diff --git a/app/Utils/Traits/GeneratesCounter.php b/app/Utils/Traits/GeneratesCounter.php index bf801b7fd13a..ad0ee68a299d 100644 --- a/app/Utils/Traits/GeneratesCounter.php +++ b/app/Utils/Traits/GeneratesCounter.php @@ -167,7 +167,7 @@ trait GeneratesCounter //Return a valid counter $pattern = ''; $padding = $client->getSetting('counter_padding'); - $invoice_number = $this->checkEntityNumber(Invoice::class, $client, $counter, $padding, $pattern); + $invoice_number = $this->checkEntityNumber(RecurringInvoice::class, $client, $counter, $padding, $pattern); $invoice_number = $this->prefixCounter($invoice_number, $client->getSetting('recurring_number_prefix')); //increment the correct invoice_number Counter (company vs client)