Skip to content

Commit 3404493

Browse files
committed
Add year and month support to invoice sequence configuration
1 parent d4636b4 commit 3404493

File tree

5 files changed

+55
-12
lines changed

5 files changed

+55
-12
lines changed

CHANGELOG-2.0.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# CHANGELOG
22

3+
### v2.0.3 (2025-10-21)
4+
5+
- [#373](https://github.com/Sylius/InvoicingPlugin/pull/373) Add configurable invoice sequence scope (`monthly`/`annually`/`global`)
6+
via SYLIUS_INVOICING_SEQUENCE_SCOPE ENV ([@tomkalon](https://github.com/tomkalon))
7+
38
### v2.0.2 (2025-07-03)
49

510
- [#373](https://github.com/Sylius/InvoicingPlugin/pull/373) Add sylius/test-application ([@Wojdylak](https://github.com/Wojdylak))

config/doctrine/InvoiceSequence.orm.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
</id>
1212
<field name="index" column="idx" type="integer" />
1313
<field name="version" type="integer" version="true" />
14+
<field name="year" type="integer" nullable="true"/>
15+
<field name="month" type="integer"/>
16+
1417
</mapped-superclass>
1518

1619
</doctrine-mapping>

src/Entity/InvoiceSequence.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ class InvoiceSequence implements InvoiceSequenceInterface
2323

2424
protected ?int $version = 1;
2525

26-
protected int $year;
26+
protected ?int $year;
2727

28-
protected int $month;
28+
protected ?int $month;
2929

3030
/** @return mixed */
3131
public function getId()
@@ -53,22 +53,22 @@ public function setVersion(?int $version): void
5353
$this->version = $version;
5454
}
5555

56-
public function getYear(): int
56+
public function getYear(): ?int
5757
{
5858
return $this->year;
5959
}
6060

61-
public function getMonth(): int
61+
public function setYear(?int $year): void
6262
{
63-
return $this->month;
63+
$this->year = $year;
6464
}
6565

66-
public function setYear(int $year): void
66+
public function getMonth(): ?int
6767
{
68-
$this->year = $year;
68+
return $this->month;
6969
}
7070

71-
public function setMonth(int $month): void
71+
public function setMonth(?int $month): void
7272
{
7373
$this->month = $month;
7474
}

src/Entity/InvoiceSequenceInterface.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ public function getIndex(): int;
2222

2323
public function incrementIndex(): void;
2424

25-
public function getYear(): int;
25+
public function getYear(): ?int;
2626

27-
public function getMonth(): int;
27+
public function getMonth(): ?int;
2828

29-
public function setYear(int $year): void;
29+
public function setYear(?int $year): void;
3030

31-
public function setMonth(int $month): void;
31+
public function setMonth(?int $month): void;
3232
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Sylius package.
5+
*
6+
* (c) Sylius Sp. z o.o.
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
declare(strict_types=1);
13+
14+
namespace Sylius\InvoicingPlugin\Migrations;
15+
16+
use Doctrine\DBAL\Schema\Schema;
17+
use Doctrine\Migrations\AbstractMigration;
18+
19+
final class Version20251021074051 extends AbstractMigration
20+
{
21+
public function getDescription(): string
22+
{
23+
return 'Add year and month columns to sylius_invoicing_plugin_sequence table';
24+
}
25+
26+
public function up(Schema $schema): void
27+
{
28+
$this->addSql('ALTER TABLE sylius_invoicing_plugin_sequence ADD year INT DEFAULT NULL, ADD month INT NOT NULL');
29+
}
30+
31+
public function down(Schema $schema): void
32+
{
33+
$this->addSql('ALTER TABLE sylius_invoicing_plugin_sequence DROP year, DROP month');
34+
}
35+
}

0 commit comments

Comments
 (0)