1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00

Merge pull request #5829 from turbo124/v5-develop

Fixes for import
This commit is contained in:
David Bomba 2021-05-26 19:51:19 +10:00 committed by GitHub
commit b80007e831
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 28 deletions

View File

@ -11,8 +11,9 @@
namespace App\Console;
use App\Jobs\Cron\SubscriptionCron;
use App\Jobs\Cron\AutoBillCron;
use App\Jobs\Cron\RecurringInvoicesCron;
use App\Jobs\Cron\SubscriptionCron;
use App\Jobs\Ninja\AdjustEmailQuota;
use App\Jobs\Ninja\CompanySizeCheck;
use App\Jobs\Util\ReminderJob;
@ -58,6 +59,8 @@ class Kernel extends ConsoleKernel
$schedule->job(new RecurringInvoicesCron)->hourly()->withoutOverlapping();
$schedule->job(new AutoBillCron)->daily()->withoutOverlapping();
$schedule->job(new SchedulerCheck)->everyFiveMinutes();
/* Run hosted specific jobs */

View File

@ -52,22 +52,18 @@ class AutoBillCron
->where('auto_bill_enabled', true)
->where('balance', '>', 0)
->with('company')
->cursor();
$auto_bill_partial_invoices->each(function ($invoice){
$this->runAutoBiller($invoice);
});
->cursor()->each(function ($invoice){
$this->runAutoBiller($invoice);
});
$auto_bill_invoices = Invoice::whereDate('due_date', '<=', now())
->whereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL])
->where('auto_bill_enabled', true)
->where('balance', '>', 0)
->with('company')
->cursor();
$auto_bill_invoices->each(function ($invoice){
$this->runAutoBiller($invoice);
});
->cursor()->each(function ($invoice){
$this->runAutoBiller($invoice);
});
} else {
@ -80,22 +76,18 @@ class AutoBillCron
->where('auto_bill_enabled', true)
->where('balance', '>', 0)
->with('company')
->cursor();
$auto_bill_partial_invoices->each(function ($invoice){
$this->runAutoBiller($invoice);
});
->cursor()->each(function ($invoice){
$this->runAutoBiller($invoice);
});
$auto_bill_invoices = Invoice::whereDate('due_date', '<=', now())
->whereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL])
->where('auto_bill_enabled', true)
->where('balance', '>', 0)
->with('company')
->cursor();
$auto_bill_invoices->each(function ($invoice){
$this->runAutoBiller($invoice);
});
->cursor()->each(function ($invoice){
$this->runAutoBiller($invoice);
});
}
}

View File

@ -1655,17 +1655,16 @@ class Import implements ShouldQueue
$current_db = config('database.default');
$local_company = Company::where('company_key', $this->company->company_key)->first();
$owner = $local_company->owner();
MultiDB::setDb('db-ninja-01');
$ninja_company = Company::find(config('ninja.ninja_default_company_id'));
/* If we already have a record of this user - move along. */
if($client_contact = ClientContact::where(['email' => $owner->email, 'company_id' => $ninja_company->id])->first())
if($client_contact = ClientContact::where(['email' => $this->user->email, 'company_id' => $ninja_company->id])->first())
return $client_contact->client;
$ninja_client = ClientFactory::create($ninja_company->id, $ninja_company->owner()->id);
$ninja_client->name = $owner->present()->name();
$ninja_client->name = $this->user->present()->name();
$ninja_client->address1 = $local_company->settings->address1;
$ninja_client->address2 = $local_company->settings->address2;
$ninja_client->city = $local_company->settings->city;
@ -1677,11 +1676,11 @@ class Import implements ShouldQueue
$ninja_client->save();
$ninja_client_contact = ClientContactFactory::create($ninja_company->id, $ninja_company->owner()->id);
$ninja_client_contact->first_name = $owner->first_name;
$ninja_client_contact->last_name = $owner->last_name;
$ninja_client_contact->first_name = $this->user->first_name;
$ninja_client_contact->last_name = $this->user->last_name;
$ninja_client_contact->client_id = $ninja_client->id;
$ninja_client_contact->email = $owner->email;
$ninja_client_contact->phone = $owner->phone;
$ninja_client_contact->email = $this->user->email;
$ninja_client_contact->phone = $this->user->phone;
$ninja_client_contact->save();