1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-08 20:22:42 +01:00

Auto increment invoice number counter

This commit is contained in:
Hillel Coren 2015-11-29 12:41:32 +02:00
parent 68bb3c8a82
commit 72d906d6d2
3 changed files with 16 additions and 2 deletions

View File

@ -34,7 +34,7 @@ class StartupCheck
// Ensure all request are over HTTPS in production
if (Utils::requireHTTPS() && !Request::secure()) {
return Redirect::secure(Request::getRequestUri());
//return Redirect::secure(Request::getRequestUri());
}
// If the database doens't yet exist we'll skip the rest

View File

@ -232,6 +232,13 @@ class Utils
return floatval($value);
}
public static function parseInt($value)
{
$value = preg_replace('/[^0-9]/', '', $value);
return intval($value);
}
public static function formatMoney($value, $currencyId = false, $showSymbol = true)
{
if (!$currencyId) {

View File

@ -443,7 +443,14 @@ class Account extends Eloquent
if ($invoice->is_quote && !$this->share_counter) {
$this->quote_number_counter += 1;
} else {
$this->invoice_number_counter += 1;
$default = $this->invoice_number_counter;
$actual = Utils::parseInt($invoice->invoice_number);
if ( ! $this->isPro() && $default != $actual) {
$this->invoice_number_counter = $actual + 1;
} else {
$this->invoice_number_counter += 1;
}
}
$this->save();