From bb3a7b9d1c43d90f1d8fe536574d9e40455930a6 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Thu, 9 Jan 2014 11:15:19 +0000 Subject: [PATCH] bug fixes --- app/commands/SendRecurringInvoices.php | 6 +++--- .../2013_11_05_180133_confide_setup_users_table.php | 2 +- app/models/Account.php | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/commands/SendRecurringInvoices.php b/app/commands/SendRecurringInvoices.php index cee314231dcb..9217077f81df 100755 --- a/app/commands/SendRecurringInvoices.php +++ b/app/commands/SendRecurringInvoices.php @@ -43,11 +43,11 @@ class SendRecurringInvoices extends Command { $invoice->amount = $recurInvoice->amount; $invoice->balance = $recurInvoice->amount; $invoice->currency_id = $recurInvoice->currency_id; - $invoice->invoice_date = date_create(); + $invoice->invoice_date = date_create()->format('Y-m-d'); if ($invoice->client->payment_terms) { - $invoice->due_date = date_create()->modify($invoice->client->payment_terms . ' day'); + $invoice->due_date = date_create()->modify($invoice->client->payment_terms . ' day')->format('Y-m-d'); } $invoice->save(); @@ -71,7 +71,7 @@ class SendRecurringInvoices extends Command { $invoice->invitations()->save($invitation); } - $recurInvoice->last_sent_date = new DateTime(); + $recurInvoice->last_sent_date = Carbon::now()->toDateTimeString(); $recurInvoice->save(); $this->mailer->sendInvoice($invoice); diff --git a/app/database/migrations/2013_11_05_180133_confide_setup_users_table.php b/app/database/migrations/2013_11_05_180133_confide_setup_users_table.php index 2f95866c4758..48e4863ff009 100755 --- a/app/database/migrations/2013_11_05_180133_confide_setup_users_table.php +++ b/app/database/migrations/2013_11_05_180133_confide_setup_users_table.php @@ -314,7 +314,7 @@ class ConfideSetupUsersTable extends Migration { $t->unsignedInteger('frequency_id'); $t->date('start_date')->nullable(); $t->date('end_date')->nullable(); - $t->timestamp('last_sent_date')->nullable(); + $t->timestamp('last_sent_date')->nullable(); $t->unsignedInteger('recurring_invoice_id')->index()->nullable(); $t->string('tax_name'); diff --git a/app/models/Account.php b/app/models/Account.php index 80ed5e6f5756..6f0058d63cff 100755 --- a/app/models/Account.php +++ b/app/models/Account.php @@ -105,16 +105,16 @@ class Account extends Eloquent public function getNextInvoiceNumber() { - $orders = Invoice::withTrashed()->scope(false, $this->id)->get(); + $invoices = Invoice::withTrashed()->scope(false, $this->id)->get(); $max = 0; - foreach ($orders as $order) + foreach ($invoices as $invoice) { - $number = intval(preg_replace("/[^0-9]/", "", $order->invoice_number)); + $number = intval(preg_replace("/[^0-9]/", "", $invoice->invoice_number)); $max = max($max, $number); } - + if ($max > 0) { return str_pad($max+1, 4, "0", STR_PAD_LEFT);