[2.3][Feature] Add support for configurable invoice sequence scopes #435
Open
tomkalon wants to merge 7 commits into
Open
[2.3][Feature] Add support for configurable invoice sequence scopes #435tomkalon wants to merge 7 commits into
tomkalon wants to merge 7 commits into
Conversation
tomkalon
marked this pull request as draft
July 17, 2026 13:34
tomkalon
force-pushed
the
feature/sequence-number
branch
2 times, most recently
from
July 20, 2026 07:23
153dc69 to
9431981
Compare
tomkalon
force-pushed
the
feature/sequence-number
branch
from
July 20, 2026 07:43
9431981 to
1d6ed4c
Compare
tomkalon
marked this pull request as ready for review
July 20, 2026 07:47
tomkalon
force-pushed
the
feature/sequence-number
branch
from
July 20, 2026 07:51
1d6ed4c to
fb2712a
Compare
tomkalon
marked this pull request as draft
July 20, 2026 10:19
… PostgreSQL migrations
tomkalon
marked this pull request as ready for review
July 20, 2026 10:49
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds configurable invoice number sequence scoping (
global/monthly/annually, defaulting toglobalfor full backward compatibility) and closes a race condition that could produce duplicated invoice numbers.SequenceScopeResolverInterfacewithGlobal/Monthly/Annuallyresolvers, pluggable viasylius_invoicing.sequence_scope_resolvertag.InvoiceCreatornow persists the invoice before writing its PDF, so a duplicate number fails on the DB constraint instead of silently overwriting a file.Config
New
sequence.scopeoption undersylius_invoicing, defaults toglobal:global— one ever-increasing counter for the whole store, never reset (previous behavior).monthly— a counter per year/month, reset on the 1st of every month.annually— a counter per year, reset on the 1st of January.All three share the same
Y/m/indexnumber format — only the reset behavior differs.Custom scopes can be added by registering a service implementing
SequenceScopeResolverInterface,tagged with
sylius_invoicing.sequence_scope_resolver, and setting its name asscope.BC breaks
Full details in
UPGRADE-2.3.md.InvoiceSequenceInterfacegainedgetType()/setType(),getYear()/setYear(),getMonth()/setMonth()and the
SCOPE_GLOBAL/SCOPE_MONTHLY/SCOPE_ANNUALLYconstants. Any custom class implementing this interfacedirectly (rather than extending the provided
InvoiceSequence) will fail to compile until it adds these methods.InvoiceCreatornow persists the invoice before writing its PDF file (previously the other way round), andno longer catches
ORMExceptionaround the persist call. A duplicated invoice number now fails loudly with a DBconstraint violation propagated to the caller, instead of being silently swallowed while the PDF file was removed.
Callers relying on
createInvoice()never throwing must be updated to handle the exception.SequentialInvoiceNumberGeneratorconstructor gained two new optional arguments ($scopeResolvers,$scope).Not a breaking change — omitting
$scopeResolverstriggers a deprecation and falls back to the built-in resolvers.Add support for configurable invoice sequence scopes #429