invoice: increase number, customer specific counter (#1836)

This commit is contained in:
Kevin Papst
2020-07-21 16:11:52 +02:00
committed by GitHub
parent 4b8f743fa6
commit 12e348544d
3 changed files with 82 additions and 22 deletions

View File

@@ -10,6 +10,7 @@
namespace App\Tests\Invoice\NumberGenerator;
use App\Configuration\SystemConfiguration;
use App\Entity\Customer;
use App\Invoice\InvoiceModel;
use App\Invoice\NumberGenerator\ConfigurableNumberGenerator;
use App\Repository\InvoiceRepository;
@@ -55,6 +56,7 @@ class ConfigurableNumberGeneratorTest extends TestCase
return [
// simple tests for single calls
['my-{date} is+cool,really', 'my-' . $invoiceDate->format('ymd') . ' is+cool,really', $invoiceDate],
['{date}', $invoiceDate->format('ymd'), $invoiceDate],
['{Y}', $invoiceDate->format('Y'), $invoiceDate],
['{y}', $invoiceDate->format('y'), $invoiceDate],
@@ -73,10 +75,27 @@ class ConfigurableNumberGeneratorTest extends TestCase
['{M,3}', '0' . $invoiceDate->format('m'), $invoiceDate],
['{M,#}', $invoiceDate->format('m'), $invoiceDate], // invalid formatter length
['{D,3}', '0' . $invoiceDate->format('d'), $invoiceDate],
// counter across all invoices
['{c,2}', '02', $invoiceDate],
['{cy,2}', '02', $invoiceDate],
['{cm,2}', '02', $invoiceDate],
['{cd,2}', '02', $invoiceDate],
// customer specific
['{cc,2}', '02', $invoiceDate],
['{ccy,2}', '02', $invoiceDate],
['{ccm,2}', '02', $invoiceDate],
['{ccd,2}', '02', $invoiceDate],
// with incrementing counter
['{c+13,2}', '14', $invoiceDate],
['{ccy+1,2}', '02', $invoiceDate],
['{cm+-1,2}', '02', $invoiceDate], // negative is not allowed and set to 1
['{cm+0,2}', '02', $invoiceDate], // zero is not allowed and set to 1
['{cd+111,2}', '112', $invoiceDate],
['{c+13}', '14', $invoiceDate],
['{cy+1}', '2', $invoiceDate],
['{cm+-1}', '2', $invoiceDate], // negative is not allowed and set to 1
['{cm+0}', '2', $invoiceDate], // zero is not allowed and set to 1
['{cd+111}', '112', $invoiceDate],
// mixing identifiers
['{Y}{cy}', $invoiceDate->format('Y') . '2', $invoiceDate],
['{Y}{cy}{m}', $invoiceDate->format('Y') . '2' . $invoiceDate->format('n'), $invoiceDate],
@@ -95,6 +114,7 @@ class ConfigurableNumberGeneratorTest extends TestCase
$sut = $this->getSut($format);
$model = new InvoiceModel(new DebugFormatter());
$model->setInvoiceDate($invoiceDate);
$model->setCustomer(new Customer());
$sut->setModel($model);
$this->assertEquals($expectedInvoiceNumber, $sut->getInvoiceNumber());