VP-1382: Sequential unique number generator #158
Closed
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.
Functional requirements:
We want to have a flexible and customizable template creation mechanism that gives us the following functionality:
Unique increasing number sequence for orders on all platform instances. It means different platform instances connected to the same db should genereate increasing order numbers;
In template, besides constant values, we need to have an ability to use: {0} - next number in the sequence, {1} - current UTC date;
Optionally - {2} - store code;
Formatting is applied using regular c# number and date formatting, like {0:d5};
Ability to set up incrementing step and sequence start;
Ability to setup reset rule for the sequence - None, every day, every week, etc;
Ability to reset sequence manually;
This extension could be used as a functional example:
https://bsscommerce.com/blog/complete-tutorial-guide-change-order-number-magento-2/#Tip_2_Use_Magento_2_Custom_Order_Number_extension
Technical details:
As a possible solution, we could add custom template number generator to the core module, with an ability to change its settings and enable it for the orders, payments, and shipping. Thus custom generator will replace the current one.
We need to add an abstraction for this purpose. Implementation could use MSSQL sequence objects under the hood to guarantee a unique and increasing sequence.
Make sure these boxes are checked: