mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Working on reminders
This commit is contained in:
parent
d598aeeb03
commit
5c5102baeb
@ -205,6 +205,10 @@ class CompanySettings extends BaseSettings
|
|||||||
public $late_fee_amount2 = 0; //@TODO
|
public $late_fee_amount2 = 0; //@TODO
|
||||||
public $late_fee_amount3 = 0; //@TODO
|
public $late_fee_amount3 = 0; //@TODO
|
||||||
|
|
||||||
|
public $late_fee_percent1 = 0; //@TODO
|
||||||
|
public $late_fee_percent2 = 0; //@TODO
|
||||||
|
public $late_fee_percent3 = 0; //@TODO
|
||||||
|
|
||||||
public $endless_reminder_frequency_id = '0'; //@implemented
|
public $endless_reminder_frequency_id = '0'; //@implemented
|
||||||
public $late_fee_endless_amount = 0; //@TODO
|
public $late_fee_endless_amount = 0; //@TODO
|
||||||
public $late_fee_endless_percent = 0; //@TODO
|
public $late_fee_endless_percent = 0; //@TODO
|
||||||
@ -300,6 +304,9 @@ class CompanySettings extends BaseSettings
|
|||||||
'late_fee_amount1' => 'float',
|
'late_fee_amount1' => 'float',
|
||||||
'late_fee_amount2' => 'float',
|
'late_fee_amount2' => 'float',
|
||||||
'late_fee_amount3' => 'float',
|
'late_fee_amount3' => 'float',
|
||||||
|
'late_fee_percent1' => 'float',
|
||||||
|
'late_fee_percent2' => 'float',
|
||||||
|
'late_fee_percent3' => 'float',
|
||||||
'endless_reminder_frequency_id' => 'integer',
|
'endless_reminder_frequency_id' => 'integer',
|
||||||
'client_online_payment_notification' => 'bool',
|
'client_online_payment_notification' => 'bool',
|
||||||
'client_manual_payment_notification' => 'bool',
|
'client_manual_payment_notification' => 'bool',
|
||||||
|
@ -79,7 +79,7 @@ class EmailEntity extends BaseMailerJob implements ShouldQueue
|
|||||||
|
|
||||||
$this->entity = $invitation->{$this->entity_string};
|
$this->entity = $invitation->{$this->entity_string};
|
||||||
|
|
||||||
$this->reminder_template = $reminder_template ?: $this->findReminderTemplate();
|
$this->reminder_template = $reminder_template ?: $this->entity->calculateTemplate($this->entity_string);
|
||||||
|
|
||||||
$this->html_engine = new HtmlEngine($invitation);
|
$this->html_engine = new HtmlEngine($invitation);
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace App\Jobs\Ninja;
|
namespace App\Jobs\Ninja;
|
||||||
|
|
||||||
use App\Libraries\MultiDB;
|
use App\Libraries\MultiDB;
|
||||||
|
use App\Models\Invoice;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
@ -44,17 +45,68 @@ class SendReminders implements ShouldQueue
|
|||||||
|
|
||||||
if (! config('ninja.db.multi_db_enabled')) {
|
if (! config('ninja.db.multi_db_enabled')) {
|
||||||
|
|
||||||
|
$this->sendReminderEmails();
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
//multiDB environment, need to
|
//multiDB environment, need to
|
||||||
foreach (MultiDB::$dbs as $db) {
|
foreach (MultiDB::$dbs as $db)
|
||||||
|
{
|
||||||
|
|
||||||
MultiDB::setDB($db);
|
MultiDB::setDB($db);
|
||||||
|
|
||||||
|
$this->sendReminderEmails();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private function chargeLateFee()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private function sendReminderEmails()
|
||||||
|
{
|
||||||
|
$invoices = Invoice::where('is_deleted', 0)
|
||||||
|
->where('balance', '>', 0)
|
||||||
|
->whereDate('next_send_date', '<=', now()->startOfDay())
|
||||||
|
->cursor();
|
||||||
|
|
||||||
|
//we only need invoices that are payable
|
||||||
|
$invoices->filter(function ($invoice){
|
||||||
|
|
||||||
|
return $invoice->isPayable();
|
||||||
|
|
||||||
|
})->each(function ($invoice){
|
||||||
|
|
||||||
|
$reminder_template = $invoice->calculateTemplate('invoice');
|
||||||
|
|
||||||
|
if($reminder_template == 'reminder1'){
|
||||||
|
|
||||||
|
}
|
||||||
|
elseif($reminder_template == 'reminder2'){
|
||||||
|
|
||||||
|
}
|
||||||
|
elseif($reminder_template == 'reminder3'){
|
||||||
|
|
||||||
|
}
|
||||||
|
elseif($reminder_template == 'endless_reminder'){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//@todo
|
||||||
|
|
||||||
|
});
|
||||||
|
//iterate through all the reminder emails due today
|
||||||
|
//
|
||||||
|
//determine which reminder
|
||||||
|
//
|
||||||
|
//determine late fees
|
||||||
|
//
|
||||||
|
//send
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -23,6 +23,7 @@ use App\Utils\Ninja;
|
|||||||
use App\Utils\Traits\MakesDates;
|
use App\Utils\Traits\MakesDates;
|
||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
use App\Utils\Traits\MakesInvoiceValues;
|
use App\Utils\Traits\MakesInvoiceValues;
|
||||||
|
use App\Utils\Traits\MakesReminders;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
@ -37,6 +38,7 @@ class Credit extends BaseModel
|
|||||||
use SoftDeletes;
|
use SoftDeletes;
|
||||||
use PresentableTrait;
|
use PresentableTrait;
|
||||||
use MakesInvoiceValues;
|
use MakesInvoiceValues;
|
||||||
|
use MakesReminders;
|
||||||
|
|
||||||
protected $presenter = CreditPresenter::class;
|
protected $presenter = CreditPresenter::class;
|
||||||
|
|
||||||
|
@ -66,6 +66,8 @@ class MarkPaid extends AbstractService
|
|||||||
'amount' => $payment->amount,
|
'amount' => $payment->amount,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$this->invoice->next_send_date = null;
|
||||||
|
|
||||||
$this->invoice->service()
|
$this->invoice->service()
|
||||||
->updateBalance($payment->amount * -1)
|
->updateBalance($payment->amount * -1)
|
||||||
->setStatus(Invoice::STATUS_PAID)
|
->setStatus(Invoice::STATUS_PAID)
|
||||||
|
@ -186,6 +186,9 @@ trait MakesReminders
|
|||||||
//if invoice is currently a draft, or being marked as sent, this will be the initial email
|
//if invoice is currently a draft, or being marked as sent, this will be the initial email
|
||||||
$client = $this->client;
|
$client = $this->client;
|
||||||
|
|
||||||
|
if($entity_string != 'invoice')
|
||||||
|
return $entity_string;
|
||||||
|
|
||||||
//if the invoice
|
//if the invoice
|
||||||
if ($client->getSetting('enable_reminder1') !== false && $this->inReminderWindow(
|
if ($client->getSetting('enable_reminder1') !== false && $this->inReminderWindow(
|
||||||
$client->getSetting('schedule_reminder1'),
|
$client->getSetting('schedule_reminder1'),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user