diff --git a/app/Models/Account.php b/app/Models/Account.php index 90bfff497d0c..ea0ac297d897 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -251,7 +251,7 @@ class Account extends Eloquent public function hasClientNumberPattern($invoice) { $pattern = $invoice->is_quote ? $this->quote_number_pattern : $this->invoice_number_pattern; - + return strstr($pattern, '$custom'); } diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index bfad62ebb8c8..824b90b3a5c4 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -31,8 +31,6 @@ class Invoice extends EntityModel $this->invoice_date = Utils::today(); $this->start_date = Utils::today(); $this->invoice_design_id = $account->invoice_design_id; - $this->terms = $account->invoice_terms; - $this->invoice_footer = $account->invoice_footer; if (!$this->invoice_number) { if ($this->is_recurring) { diff --git a/resources/views/invoices/edit.blade.php b/resources/views/invoices/edit.blade.php index 0e22f32453cb..cf80c3aed3ae 100644 --- a/resources/views/invoices/edit.blade.php +++ b/resources/views/invoices/edit.blade.php @@ -644,9 +644,7 @@ // we enable searching by contact but the selection must be the client $('.client-input').val(getClientDisplayName(selected)); // if there's an invoice number pattern we'll apply it now - @if ($account->hasClientNumberPattern($invoice)) - setInvoiceNumber(selected); - @endif + setInvoiceNumber(selected); } else { model.loadClient($.parseJSON(ko.toJSON(new ClientModel()))); model.invoice().client().country = false; @@ -1030,7 +1028,7 @@ } function setInvoiceNumber(client) { - @if ($invoice->id) + @if ($invoice->id || !$account->hasClientNumberPattern($invoice)) return; @endif var number = '{{ $account->getNumberPattern($invoice) }}'; diff --git a/tests/acceptance/InvoiceCest.php b/tests/acceptance/InvoiceCest.php index 263146d30ab7..cd8238b097f6 100644 --- a/tests/acceptance/InvoiceCest.php +++ b/tests/acceptance/InvoiceCest.php @@ -16,7 +16,7 @@ class InvoiceCest $this->faker = Factory::create(); } - /* + public function createInvoice(AcceptanceTester $I) { $clientEmail = $this->faker->safeEmail; @@ -75,7 +75,7 @@ class InvoiceCest $I->click('#lastSent'); $I->see($invoiceNumber); } - */ + public function editInvoice(AcceptanceTester $I) { $I->wantTo('edit an invoice');