1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-12 14:12:44 +01:00

Use queues in recurring command

This commit is contained in:
Hillel Coren 2018-03-27 15:59:48 +03:00
parent 497154becb
commit 512badb9cf

View File

@ -5,10 +5,10 @@ namespace App\Console\Commands;
use App\Models\Account; use App\Models\Account;
use App\Models\Invoice; use App\Models\Invoice;
use App\Models\RecurringExpense; use App\Models\RecurringExpense;
use App\Ninja\Mailers\ContactMailer as Mailer;
use App\Ninja\Repositories\InvoiceRepository; use App\Ninja\Repositories\InvoiceRepository;
use App\Ninja\Repositories\RecurringExpenseRepository; use App\Ninja\Repositories\RecurringExpenseRepository;
use App\Services\PaymentService; use App\Services\PaymentService;
use App\Jobs\SendInvoiceEmail;
use DateTime; use DateTime;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputOption;
@ -31,11 +31,6 @@ class SendRecurringInvoices extends Command
*/ */
protected $description = 'Send recurring invoices'; protected $description = 'Send recurring invoices';
/**
* @var Mailer
*/
protected $mailer;
/** /**
* @var InvoiceRepository * @var InvoiceRepository
*/ */
@ -49,15 +44,13 @@ class SendRecurringInvoices extends Command
/** /**
* SendRecurringInvoices constructor. * SendRecurringInvoices constructor.
* *
* @param Mailer $mailer
* @param InvoiceRepository $invoiceRepo * @param InvoiceRepository $invoiceRepo
* @param PaymentService $paymentService * @param PaymentService $paymentService
*/ */
public function __construct(Mailer $mailer, InvoiceRepository $invoiceRepo, PaymentService $paymentService, RecurringExpenseRepository $recurringExpenseRepo) public function __construct(InvoiceRepository $invoiceRepo, PaymentService $paymentService, RecurringExpenseRepository $recurringExpenseRepo)
{ {
parent::__construct(); parent::__construct();
$this->mailer = $mailer;
$this->invoiceRepo = $invoiceRepo; $this->invoiceRepo = $invoiceRepo;
$this->paymentService = $paymentService; $this->paymentService = $paymentService;
$this->recurringExpenseRepo = $recurringExpenseRepo; $this->recurringExpenseRepo = $recurringExpenseRepo;
@ -117,7 +110,7 @@ class SendRecurringInvoices extends Command
$invoice = $this->invoiceRepo->createRecurringInvoice($recurInvoice); $invoice = $this->invoiceRepo->createRecurringInvoice($recurInvoice);
if ($invoice && ! $invoice->isPaid() && $account->auto_email_invoice) { if ($invoice && ! $invoice->isPaid() && $account->auto_email_invoice) {
$this->info('Not billed - Sending Invoice'); $this->info('Not billed - Sending Invoice');
$this->mailer->sendInvoice($invoice); dispatch(new SendInvoiceEmail($invoice, $invoice->user_id));
} elseif ($invoice) { } elseif ($invoice) {
$this->info('Successfully billed invoice'); $this->info('Successfully billed invoice');
} }