mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-13 22:54:25 +01:00
Fixes for generating counters
This commit is contained in:
parent
2b07dd1066
commit
e951a44737
@ -33,6 +33,9 @@ use Illuminate\Support\Str;
|
||||
*/
|
||||
trait GeneratesConvertedQuoteCounter
|
||||
{
|
||||
|
||||
private int $update_counter;
|
||||
|
||||
private function harvestQuoteCounter($quote, $invoice, Client $client)
|
||||
{
|
||||
$settings = $client->getMergedSettings();
|
||||
|
@ -34,6 +34,9 @@ use Illuminate\Support\Str;
|
||||
*/
|
||||
trait GeneratesCounter
|
||||
{
|
||||
|
||||
private int $update_counter;
|
||||
|
||||
//todo in the form validation, we need to ensure that if a prefix and pattern is set we throw a validation error,
|
||||
//only one type is allow else this will cause confusion to the end user
|
||||
|
||||
@ -418,7 +421,8 @@ trait GeneratesCounter
|
||||
$check_counter = 1;
|
||||
|
||||
do {
|
||||
|
||||
nlog($counter);
|
||||
|
||||
$number = $this->padCounter($counter, $padding);
|
||||
|
||||
$number = $this->applyNumberPattern($entity, $number, $pattern);
|
||||
@ -432,12 +436,16 @@ trait GeneratesCounter
|
||||
|
||||
if ($check_counter > 100) {
|
||||
|
||||
$this->update_counter = $counter--;
|
||||
|
||||
return $number.'_'.Str::random(5);
|
||||
|
||||
}
|
||||
|
||||
} while ($check);
|
||||
|
||||
$this->update_counter = $counter--;
|
||||
|
||||
return $number;
|
||||
}
|
||||
|
||||
@ -469,7 +477,8 @@ trait GeneratesCounter
|
||||
$settings->{$counter_name} = 1;
|
||||
}
|
||||
|
||||
$settings->{$counter_name} = $settings->{$counter_name} + 1;
|
||||
// $settings->{$counter_name} = $settings->{$counter_name} + 1;
|
||||
$settings->{$counter_name} = $this->update_counter;
|
||||
|
||||
$entity->settings = $settings;
|
||||
|
||||
|
@ -179,7 +179,7 @@ class GeneratesCounterTest extends TestCase
|
||||
|
||||
$invoice_number = $this->getNextInvoiceNumber($this->client->fresh(), $this->invoice->fresh());
|
||||
|
||||
$this->assertEquals($invoice_number, '0002');
|
||||
$this->assertEquals($invoice_number, '0003');
|
||||
}
|
||||
|
||||
public function testQuoteNumberValue()
|
||||
@ -351,7 +351,7 @@ class GeneratesCounterTest extends TestCase
|
||||
|
||||
$invoice_number = $this->getNextInvoiceNumber($cliz->fresh(), $this->invoice);
|
||||
|
||||
$this->assertEquals($invoice_number, '0002');
|
||||
$this->assertEquals($invoice_number, '0003');
|
||||
}
|
||||
|
||||
public function testClientNumber()
|
||||
|
Loading…
Reference in New Issue
Block a user