mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-13 06:32:40 +01:00
Merge pull request #5817 from turbo124/v5-develop
Fixes for transformers + import
This commit is contained in:
commit
1eb0def0ca
@ -1653,7 +1653,7 @@ class Import implements ShouldQueue
|
||||
{
|
||||
$current_db = config('database.default');
|
||||
|
||||
$local_company = Company::find($this->company->id);
|
||||
$local_company = Company::where('company_key', $this->company->company_key)->first();
|
||||
$owner = $local_company->owner();
|
||||
|
||||
MultiDB::setDb('db-ninja-01');
|
||||
|
@ -16,6 +16,7 @@ use App\Jobs\Entity\EmailEntity;
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\Invoice;
|
||||
use App\Utils\Ninja;
|
||||
use App\Utils\Traits\MakesReminders;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
@ -25,7 +26,7 @@ use Illuminate\Support\Carbon;
|
||||
|
||||
class ReminderJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, MakesReminders;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@ -39,9 +40,6 @@ class ReminderJob implements ShouldQueue
|
||||
public function handle()
|
||||
{
|
||||
|
||||
//always make sure you have set the company as this command is being
|
||||
//run from the console so we have no awareness of the DB.
|
||||
|
||||
if (! config('ninja.db.multi_db_enabled')) {
|
||||
$this->processReminders();
|
||||
} else {
|
||||
@ -69,6 +67,9 @@ class ReminderJob implements ShouldQueue
|
||||
if ($invoice->invitations->count() > 0) {
|
||||
event(new InvoiceWasEmailed($invoice->invitations->first(), $invoice->company, Ninja::eventVars(), $reminder_template));
|
||||
}
|
||||
|
||||
$invoice->setReminder();
|
||||
|
||||
} else {
|
||||
$invoice->next_send_date = null;
|
||||
$invoice->save();
|
||||
|
@ -108,7 +108,7 @@ class CreditTransformer extends EntityTransformer
|
||||
'po_number' => $credit->po_number ?: '',
|
||||
'date' => $credit->date ?: '',
|
||||
'last_sent_date' => $credit->last_sent_date ?: '',
|
||||
'next_send_date' => $credit->date ?: '',
|
||||
'next_send_date' => $credit->next_send_date ?: '',
|
||||
'reminder1_sent' => $credit->reminder1_sent ?: '',
|
||||
'reminder2_sent' => $credit->reminder2_sent ?: '',
|
||||
'reminder3_sent' => $credit->reminder3_sent ?: '',
|
||||
|
@ -114,7 +114,7 @@ class InvoiceTransformer extends EntityTransformer
|
||||
'po_number' => $invoice->po_number ?: '',
|
||||
'date' => $invoice->date ?: '',
|
||||
'last_sent_date' => $invoice->last_sent_date ?: '',
|
||||
'next_send_date' => $invoice->date ?: '',
|
||||
'next_send_date' => $invoice->next_send_date ?: '',
|
||||
'due_date' => $invoice->due_date ?: '',
|
||||
'terms' => $invoice->terms ?: '',
|
||||
'public_notes' => $invoice->public_notes ?: '',
|
||||
|
@ -108,7 +108,7 @@ class QuoteTransformer extends EntityTransformer
|
||||
'po_number' => $quote->po_number ?: '',
|
||||
'date' => $quote->date ?: '',
|
||||
'last_sent_date' => $quote->last_sent_date ?: '',
|
||||
'next_send_date' => $quote->date ?: '',
|
||||
'next_send_date' => $quote->next_send_date ?: '',
|
||||
'reminder1_sent' => $quote->reminder1_sent ?: '',
|
||||
'reminder2_sent' => $quote->reminder2_sent ?: '',
|
||||
'reminder3_sent' => $quote->reminder3_sent ?: '',
|
||||
|
@ -79,6 +79,30 @@ class ReminderTest extends TestCase
|
||||
|
||||
$this->assertEquals($this->invoice->next_send_date, Carbon::now()->addDays(7)->format('Y-m-d'));
|
||||
|
||||
ReminderJob::dispatchNow();
|
||||
// ReminderJob::dispatchNow();
|
||||
}
|
||||
|
||||
public function testReminderNextSendRecalculation()
|
||||
{
|
||||
|
||||
$this->invoice->date = now()->subDays(1)->format('Y-m-d');
|
||||
$this->invoice->due_date = Carbon::now()->addDays(30)->format('Y-m-d');
|
||||
$this->invoice->reminder1_sent = now()->format('Y-m-d');
|
||||
|
||||
$settings = $this->company->settings;
|
||||
$settings->enable_reminder1 = true;
|
||||
$settings->schedule_reminder1 = 'after_invoice_date';
|
||||
$settings->num_days_reminder1 = 1;
|
||||
$settings->enable_reminder2 = true;
|
||||
$settings->schedule_reminder2 = 'before_due_date';
|
||||
$settings->num_days_reminder2 = 1;
|
||||
$settings->enable_reminder3 = true;
|
||||
$settings->schedule_reminder3 = 'after_due_date';
|
||||
$settings->num_days_reminder3 = 1;
|
||||
|
||||
$this->company->settings = $settings;
|
||||
$this->invoice->service()->markSent();
|
||||
$this->invoice->setReminder($settings);
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user