Working on custom invoice numbers

This commit is contained in:
Hillel Coren 2015-10-23 15:54:07 +03:00
parent 17f853f907
commit 971e538d0e
4 changed files with 5 additions and 9 deletions

View File

@ -251,7 +251,7 @@ class Account extends Eloquent
public function hasClientNumberPattern($invoice) public function hasClientNumberPattern($invoice)
{ {
$pattern = $invoice->is_quote ? $this->quote_number_pattern : $this->invoice_number_pattern; $pattern = $invoice->is_quote ? $this->quote_number_pattern : $this->invoice_number_pattern;
return strstr($pattern, '$custom'); return strstr($pattern, '$custom');
} }

View File

@ -31,8 +31,6 @@ class Invoice extends EntityModel
$this->invoice_date = Utils::today(); $this->invoice_date = Utils::today();
$this->start_date = Utils::today(); $this->start_date = Utils::today();
$this->invoice_design_id = $account->invoice_design_id; $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->invoice_number) {
if ($this->is_recurring) { if ($this->is_recurring) {

View File

@ -644,9 +644,7 @@
// we enable searching by contact but the selection must be the client // we enable searching by contact but the selection must be the client
$('.client-input').val(getClientDisplayName(selected)); $('.client-input').val(getClientDisplayName(selected));
// if there's an invoice number pattern we'll apply it now // if there's an invoice number pattern we'll apply it now
@if ($account->hasClientNumberPattern($invoice)) setInvoiceNumber(selected);
setInvoiceNumber(selected);
@endif
} else { } else {
model.loadClient($.parseJSON(ko.toJSON(new ClientModel()))); model.loadClient($.parseJSON(ko.toJSON(new ClientModel())));
model.invoice().client().country = false; model.invoice().client().country = false;
@ -1030,7 +1028,7 @@
} }
function setInvoiceNumber(client) { function setInvoiceNumber(client) {
@if ($invoice->id) @if ($invoice->id || !$account->hasClientNumberPattern($invoice))
return; return;
@endif @endif
var number = '{{ $account->getNumberPattern($invoice) }}'; var number = '{{ $account->getNumberPattern($invoice) }}';

View File

@ -16,7 +16,7 @@ class InvoiceCest
$this->faker = Factory::create(); $this->faker = Factory::create();
} }
/*
public function createInvoice(AcceptanceTester $I) public function createInvoice(AcceptanceTester $I)
{ {
$clientEmail = $this->faker->safeEmail; $clientEmail = $this->faker->safeEmail;
@ -75,7 +75,7 @@ class InvoiceCest
$I->click('#lastSent'); $I->click('#lastSent');
$I->see($invoiceNumber); $I->see($invoiceNumber);
} }
*/
public function editInvoice(AcceptanceTester $I) public function editInvoice(AcceptanceTester $I)
{ {
$I->wantTo('edit an invoice'); $I->wantTo('edit an invoice');