diff --git a/app/Console/Commands/ChargeRenewalInvoices.php b/app/Console/Commands/ChargeRenewalInvoices.php new file mode 100644 index 000000000000..39d63ee44c06 --- /dev/null +++ b/app/Console/Commands/ChargeRenewalInvoices.php @@ -0,0 +1,63 @@ +mailer = $mailer; + $this->accountRepo = $repo; + $this->paymentService = $paymentService; + } + + public function fire() + { + $this->info(date('Y-m-d').' ChargeRenewalInvoices...'); + + $account = $this->accountRepo->getNinjaAccount(); + $invoices = Invoice::whereAccountId($account->id) + ->whereDueDate(date('Y-m-d')) + ->with('client') + ->orderBy('id') + ->get(); + + $this->info(count($invoices).' invoices found'); + + foreach ($invoices as $invoice) { + $this->info("Charging invoice {$invoice->invoice_number}"); + $this->paymentService->autoBillInvoice($invoice); + } + + $this->info('Done'); + } + + protected function getArguments() + { + return array( + //array('example', InputArgument::REQUIRED, 'An example argument.'), + ); + } + + protected function getOptions() + { + return array( + //array('example', null, InputOption::VALUE_OPTIONAL, 'An example option.', null), + ); + } +}