1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-13 22:54:25 +01:00

Prevent converting a qoute from incrementing the counter

This commit is contained in:
Hillel Coren 2016-06-01 10:56:44 +03:00
parent e6a05509b1
commit 51d9b2b427
2 changed files with 33 additions and 31 deletions

View File

@ -652,9 +652,8 @@ class Account extends Eloquent
public function getNextInvoiceNumber($invoice) public function getNextInvoiceNumber($invoice)
{ {
if ($this->hasNumberPattern($invoice->invoice_type_id)) { if ($this->hasNumberPattern($invoice->invoice_type_id)) {
return $this->getNumberPattern($invoice); $number = $this->getNumberPattern($invoice);
} } else {
$counter = $this->getCounter($invoice->invoice_type_id); $counter = $this->getCounter($invoice->invoice_type_id);
$prefix = $this->getNumberPrefix($invoice->invoice_type_id); $prefix = $this->getNumberPrefix($invoice->invoice_type_id);
$counterOffset = 0; $counterOffset = 0;
@ -677,24 +676,27 @@ class Account extends Eloquent
$this->save(); $this->save();
} }
}
if ($invoice->recurring_invoice_id) {
$number = $this->recurring_invoice_number_prefix . $number;
}
return $number; return $number;
} }
public function incrementCounter($invoice) public function incrementCounter($invoice)
{ {
// if they didn't use the counter don't increment it
if ($invoice->invoice_number != $this->getNextInvoiceNumber($invoice)) {
return;
}
if ($invoice->isType(INVOICE_TYPE_QUOTE) && !$this->share_counter) { if ($invoice->isType(INVOICE_TYPE_QUOTE) && !$this->share_counter) {
$this->quote_number_counter += 1; $this->quote_number_counter += 1;
} else {
$default = $this->invoice_number_counter;
$actual = Utils::parseInt($invoice->invoice_number);
if ( ! $this->hasFeature(FEATURE_INVOICE_SETTINGS) && $default != $actual) {
$this->invoice_number_counter = $actual + 1;
} else { } else {
$this->invoice_number_counter += 1; $this->invoice_number_counter += 1;
} }
}
$this->save(); $this->save();
} }

View File

@ -741,7 +741,7 @@ class InvoiceRepository extends BaseRepository
$invoice = Invoice::createNew($recurInvoice); $invoice = Invoice::createNew($recurInvoice);
$invoice->client_id = $recurInvoice->client_id; $invoice->client_id = $recurInvoice->client_id;
$invoice->recurring_invoice_id = $recurInvoice->id; $invoice->recurring_invoice_id = $recurInvoice->id;
$invoice->invoice_number = $recurInvoice->account->recurring_invoice_number_prefix . $recurInvoice->account->getNextInvoiceNumber($recurInvoice); $invoice->invoice_number = $recurInvoice->account->getNextInvoiceNumber($invoice);
$invoice->amount = $recurInvoice->amount; $invoice->amount = $recurInvoice->amount;
$invoice->balance = $recurInvoice->amount; $invoice->balance = $recurInvoice->amount;
$invoice->invoice_date = date_create()->format('Y-m-d'); $invoice->invoice_date = date_create()->format('Y-m-d');