1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-30 21:27:11 +02:00
invoiceninja/app/Jobs/Cron/SubscriptionCron.php
David Bomba abd3a89bc9
Subscriptions (#5248)
* Fixes for converting quote to invoice

* Fixes for naming PDFs

* Refresh entity prior to sending

* Fixes for subscriptions

* Add in required use

* Fixes for notifications

* Fixes for notifications

* Add with trasheD

* Rename BillingSubscriptions to Subscriptions

* Refactoring subscriptions
2021-03-25 21:55:59 +11:00

74 lines
1.7 KiB
PHP

<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Jobs\Cron;
use App\Libraries\MultiDB;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Support\Carbon;
class SubscriptionCron
{
use Dispatchable;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct()
{
}
/**
* Execute the job.
*
* @return void
*/
public function handle() : void
{
if (! config('ninja.db.multi_db_enabled')) {
$this->loopSubscriptions();
} else {
//multiDB environment, need to
foreach (MultiDB::$dbs as $db) {
MultiDB::setDB($db);
$this->loopSubscriptions();
}
}
}
private function loopSubscriptions()
{
//looop recurring invoices with subscription id
// $client_subs = ClientSubscription::whereNull('deleted_at')
// ->cursor()
// ->each(function ($cs){
// $this->processSubscription($cs);
// });
}
/* Our daily cron should check
1. Is the subscription still in trial phase?
2. Check the recurring invoice and its remaining_cycles to see whether we need to cancel or perform any other function.
3. Any notifications that need to fire?
*/
private function processSubscription($client_subscription)
{
}
}