mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-09-20 16:31:33 +02:00
Subscription Crons
This commit is contained in:
parent
38a648866c
commit
498d8e4efc
@ -12,6 +12,7 @@
|
||||
namespace App\Jobs\Cron;
|
||||
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\Invoice;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
@ -51,13 +52,21 @@ class SubscriptionCron
|
||||
|
||||
private function loopSubscriptions()
|
||||
{
|
||||
//looop recurring invoices with subscription id
|
||||
|
||||
// $client_subs = ClientSubscription::whereNull('deleted_at')
|
||||
// ->cursor()
|
||||
// ->each(function ($cs){
|
||||
// $this->processSubscription($cs);
|
||||
// });
|
||||
$invoices = Invoice::where('is_deleted', 0)
|
||||
->whereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL])
|
||||
->where('balance', '>', 0)
|
||||
->whereDate('due_date', '<=', now()->startOfDay())
|
||||
->whereNotNull('subscription_id')
|
||||
->cursor();
|
||||
|
||||
|
||||
$invoices->each(function ($invoice){
|
||||
|
||||
$subscription = $invoice->subscription;
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/* Our daily cron should check
|
||||
|
@ -181,6 +181,11 @@ class Invoice extends BaseModel
|
||||
return $this->belongsTo(Client::class)->withTrashed();
|
||||
}
|
||||
|
||||
public function subscription()
|
||||
{
|
||||
return $this->belongsTo(Subscription::class)->withTrashed();
|
||||
}
|
||||
|
||||
public function documents()
|
||||
{
|
||||
return $this->morphMany(Document::class, 'documentable');
|
||||
|
Loading…
Reference in New Issue
Block a user