From 6a2fc8996201de47890c9f1992bd6120be1e1614 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Sun, 25 Oct 2015 09:49:10 +0200 Subject: [PATCH] Bug fixes --- app/Models/Account.php | 10 ++++---- app/Ninja/Repositories/InvoiceRepository.php | 4 ++-- resources/views/invoices/edit.blade.php | 24 +++++++++++--------- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/app/Models/Account.php b/app/Models/Account.php index 743fc166b760..c768f0bc6fd1 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -251,7 +251,7 @@ class Account extends Eloquent $invoice->start_date = Utils::today(); $invoice->invoice_design_id = $this->invoice_design_id; $invoice->client_id = $clientId; - + if ($entityType === ENTITY_RECURRING_INVOICE) { $invoice->invoice_number = microtime(true); $invoice->is_recurring = true; @@ -346,13 +346,13 @@ class Account extends Eloquent // if we're using a pattern we don't know the next number until a client // is selected, to support this the default value is blank - public function getDefaultInvoiceNumber($invoice = false, $prefix = '') + public function getDefaultInvoiceNumber($invoice = false) { if ($this->hasClientNumberPattern($invoice)) { return false; } - return $this->getNextInvoiceNumber($invoice, $prefix = ''); + return $this->getNextInvoiceNumber($invoice); } public function getCounter($isQuote) @@ -360,14 +360,14 @@ class Account extends Eloquent return $isQuote && !$this->share_counter ? $this->quote_number_counter : $this->invoice_number_counter; } - public function getNextInvoiceNumber($invoice, $prefix = '') + public function getNextInvoiceNumber($invoice) { if ($this->hasNumberPattern($invoice->is_quote)) { return $this->getNumberPattern($invoice); } $counter = $this->getCounter($invoice->is_quote); - $prefix .= $invoice->is_quote ? $this->quote_number_prefix : $this->invoice_number_prefix; + $prefix = $invoice->is_quote ? $this->quote_number_prefix : $this->invoice_number_prefix; $counterOffset = 0; // confirm the invoice number isn't already taken diff --git a/app/Ninja/Repositories/InvoiceRepository.php b/app/Ninja/Repositories/InvoiceRepository.php index 412ea14faa22..912310c766c6 100644 --- a/app/Ninja/Repositories/InvoiceRepository.php +++ b/app/Ninja/Repositories/InvoiceRepository.php @@ -272,7 +272,7 @@ class InvoiceRepository $account->save(); } - if (isset($data['invoice_number'])) { + if (isset($data['invoice_number']) && !$invoice->is_recurring) { $invoice->invoice_number = trim($data['invoice_number']); } @@ -625,7 +625,7 @@ class InvoiceRepository $invoice = Invoice::createNew($recurInvoice); $invoice->client_id = $recurInvoice->client_id; $invoice->recurring_invoice_id = $recurInvoice->id; - $invoice->invoice_number = $recurInvoice->account->getNextInvoiceNumber($recurInvoice, 'R'); + $invoice->invoice_number = 'R' . $recurInvoice->account->getNextInvoiceNumber($recurInvoice); $invoice->amount = $recurInvoice->amount; $invoice->balance = $recurInvoice->amount; $invoice->invoice_date = date_create()->format('Y-m-d'); diff --git a/resources/views/invoices/edit.blade.php b/resources/views/invoices/edit.blade.php index 9b0b56ecddbb..b9094cc6511d 100644 --- a/resources/views/invoices/edit.blade.php +++ b/resources/views/invoices/edit.blade.php @@ -413,18 +413,20 @@ {!! Former::text('website')->data_bind("value: website, valueUpdate: 'afterkeydown'") !!} {!! Former::text('work_phone')->data_bind("value: work_phone, valueUpdate: 'afterkeydown'") !!} + - @if (Auth::user()->isPro()) - @if ($account->custom_client_label1) - {!! Former::text('custom_value1')->label($account->custom_client_label1) - ->data_bind("value: custom_value1, valueUpdate: 'afterkeydown'") !!} - @endif - @if ($account->custom_client_label2) - {!! Former::text('custom_value2')->label($account->custom_client_label2) - ->data_bind("value: custom_value2, valueUpdate: 'afterkeydown'") !!} - @endif - @endif + @if (Auth::user()->isPro()) + @if ($account->custom_client_label1) + {!! Former::text('custom_value1')->label($account->custom_client_label1) + ->data_bind("value: custom_value1, valueUpdate: 'afterkeydown'") !!} + @endif + @if ($account->custom_client_label2) + {!! Former::text('custom_value2')->label($account->custom_client_label2) + ->data_bind("value: custom_value2, valueUpdate: 'afterkeydown'") !!} + @endif + @endif +   {!! Former::text('address1')->data_bind("value: address1, valueUpdate: 'afterkeydown'") !!} @@ -459,7 +461,7 @@ - +