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