From e6141abde42a20849b58e314ed53f849b6fca5b9 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Mon, 22 Feb 2016 21:34:21 +0200 Subject: [PATCH] Enable auto renewing and updated Travis config --- .../Commands/ChargeRenewalInvoices.php | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 app/Console/Commands/ChargeRenewalInvoices.php 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), + ); + } +}