mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-23 20:00:33 -04:00
Refactor client invoice/quote counter
This commit is contained in:
parent
5791e2bc9f
commit
f40b72c014
@ -64,9 +64,8 @@ class Invoice extends EntityModel implements BalanceAffecting
|
|||||||
*/
|
*/
|
||||||
public static $patternFields = [
|
public static $patternFields = [
|
||||||
'counter',
|
'counter',
|
||||||
|
'clientCounter',
|
||||||
'clientIdNumber',
|
'clientIdNumber',
|
||||||
'clientInvoiceCounter',
|
|
||||||
'clientQuoteCounter',
|
|
||||||
'clientCustom1',
|
'clientCustom1',
|
||||||
'clientCustom2',
|
'clientCustom2',
|
||||||
'userId',
|
'userId',
|
||||||
|
@ -191,8 +191,7 @@ trait GeneratesNumbers
|
|||||||
'{$clientCustom1}',
|
'{$clientCustom1}',
|
||||||
'{$clientCustom2}',
|
'{$clientCustom2}',
|
||||||
'{$clientIdNumber}',
|
'{$clientIdNumber}',
|
||||||
'{$clientInvoiceCounter}',
|
'{$clientCounter}',
|
||||||
'{$clientQuoteCounter}',
|
|
||||||
];
|
];
|
||||||
|
|
||||||
$replace = [
|
$replace = [
|
||||||
@ -253,10 +252,11 @@ trait GeneratesNumbers
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($this->usesClientInvoiceCounter()) {
|
if ($this->usesClientInvoiceCounter()) {
|
||||||
$entity->client->invoice_number_counter += 1;
|
if ($entity->isType(INVOICE_TYPE_QUOTE) && ! $this->share_counter) {
|
||||||
$entity->client->save();
|
|
||||||
} elseif ($this->usesClientQuoteCounter()) {
|
|
||||||
$entity->client->quote_number_counter += 1;
|
$entity->client->quote_number_counter += 1;
|
||||||
|
} else {
|
||||||
|
$entity->client->invoice_number_counter += 1;
|
||||||
|
}
|
||||||
$entity->client->save();
|
$entity->client->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -277,12 +277,7 @@ trait GeneratesNumbers
|
|||||||
|
|
||||||
public function usesClientInvoiceCounter()
|
public function usesClientInvoiceCounter()
|
||||||
{
|
{
|
||||||
return strpos($this->invoice_number_pattern, '{$clientInvoiceCounter}') !== false;
|
return strpos($this->invoice_number_pattern, '{$clientCounter}') !== false;
|
||||||
}
|
|
||||||
|
|
||||||
public function usesClientQuoteCounter()
|
|
||||||
{
|
|
||||||
return strpos($this->invoice_number_pattern, '{$clientQuoteCounter}') !== false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function clientNumbersEnabled()
|
public function clientNumbersEnabled()
|
||||||
|
@ -183,7 +183,7 @@ class AppServiceProvider extends ServiceProvider
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ((strstr($value, '{$idNumber}') !== false || strstr($value, '{$clientIdNumber}') != false) && (strstr($value, '{$clientInvoiceCounter}') || strstr($value, '{$clientQuoteCounter}')));
|
return ((strstr($value, '{$idNumber}') !== false || strstr($value, '{$clientIdNumber}') != false) && (strstr($value, '{$clientCounter}')));
|
||||||
});
|
});
|
||||||
|
|
||||||
Validator::extend('valid_invoice_items', function ($attribute, $value, $parameters) {
|
Validator::extend('valid_invoice_items', function ($attribute, $value, $parameters) {
|
||||||
|
@ -73,7 +73,7 @@ return array(
|
|||||||
"has_credit" => "The client does not have enough credit.",
|
"has_credit" => "The client does not have enough credit.",
|
||||||
"notmasked" => "The values are masked",
|
"notmasked" => "The values are masked",
|
||||||
"less_than" => "The :attribute must be less than :value",
|
"less_than" => "The :attribute must be less than :value",
|
||||||
"has_counter" => "To enusre all invoice numbers are unique the pattern needs to contain either {\$counter} or {\$clientIdNumber} and {\$clientInvoiceCounter}",
|
"has_counter" => "To enusre all invoice numbers are unique the pattern needs to contain either {\$counter} or {\$clientIdNumber} and {\$clientCounter}",
|
||||||
"valid_contacts" => "The contact must have either an email or name",
|
"valid_contacts" => "The contact must have either an email or name",
|
||||||
"valid_invoice_items" => "The invoice exceeds the maximum amount",
|
"valid_invoice_items" => "The invoice exceeds the maximum amount",
|
||||||
"valid_subdomain" => "The subdomain is restricted",
|
"valid_subdomain" => "The subdomain is restricted",
|
||||||
|
@ -59,11 +59,11 @@
|
|||||||
|
|
||||||
@if ($account->usesClientInvoiceCounter())
|
@if ($account->usesClientInvoiceCounter())
|
||||||
{!! Former::text('invoice_number_counter')->label('invoice_counter') !!}
|
{!! Former::text('invoice_number_counter')->label('invoice_counter') !!}
|
||||||
@endif
|
|
||||||
|
|
||||||
@if ($account->usesClientQuoteCounter())
|
@if (! $account->share_counter)
|
||||||
{!! Former::text('quote_number_counter')->label('quote_counter') !!}
|
{!! Former::text('quote_number_counter')->label('quote_counter') !!}
|
||||||
@endif
|
@endif
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -1629,8 +1629,11 @@
|
|||||||
number = number.replace('{$clientCustom1}', client.custom_value1 ? client.custom_value1 : '');
|
number = number.replace('{$clientCustom1}', client.custom_value1 ? client.custom_value1 : '');
|
||||||
number = number.replace('{$clientCustom2}', client.custom_value2 ? client.custom_value1 : '');
|
number = number.replace('{$clientCustom2}', client.custom_value2 ? client.custom_value1 : '');
|
||||||
number = number.replace('{$clientIdNumber}', client.id_number ? client.id_number : '');
|
number = number.replace('{$clientIdNumber}', client.id_number ? client.id_number : '');
|
||||||
number = number.replace('{$clientInvoiceCounter}', pad(client.invoice_number_counter, {{ $account->invoice_number_padding }}));
|
@if ($invoice->isQuote() && ! $account->share_counter)
|
||||||
number = number.replace('{$clientQuoteCounter}', pad(client.quote_number_counter, {{ $account->invoice_number_padding }}));
|
number = number.replace('{$clientCounter}', pad(client.quote_number_counter, {{ $account->invoice_number_padding }}));
|
||||||
|
@else
|
||||||
|
number = number.replace('{$clientCounter}', pad(client.invoice_number_counter, {{ $account->invoice_number_padding }}));
|
||||||
|
@endif
|
||||||
// backwards compatibility
|
// backwards compatibility
|
||||||
number = number.replace('{$custom1}', client.custom_value1 ? client.custom_value1 : '');
|
number = number.replace('{$custom1}', client.custom_value1 ? client.custom_value1 : '');
|
||||||
number = number.replace('{$custom2}', client.custom_value2 ? client.custom_value1 : '');
|
number = number.replace('{$custom2}', client.custom_value2 ? client.custom_value1 : '');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user