Product Requirements Document (PRD): Invoice Prefix
Objective
Enable Superadmins and Admins to configure custom invoice prefixes with a static prefix (e.g., "INV-", "Agency-") and a mandatory {{n}} counter variable with optional date variables ({{dd}}, {{mm}}, {{yyyy}}) by selecting from predefined formats. Incorporate logic to reset and resume the {{n}} counter based on prefix changes.
Business Need
Customization: Allow agencies to brand invoices with flexible prefixes and standardized formats using sequential numbers and optional date variables. Clarity: Simplify tracking and identification of invoices with date-based prefixes. Scalability: Ensure the {{n}} counter logic handles prefix changes seamlessly, including reverting to previously used prefixes. Default Format
If no custom configuration is provided, the system will use the default:
Prefix: INV-
Format: {{n}}-{{dd}}-{{mm}}-{{yyyy}}
Example Outputs:
User Stories
As a Superadmin/Admin, I want to configure a static prefix (e.g., "INV-", "Agency-") to customize my invoice numbering while maintaining consistency. Predefined Formats with Variables As a Superadmin/Admin, I want to select a predefined format that includes the {{n}} counter variable and optional date variables ({{dd}}, {{mm}}, {{yyyy}}) to structure my invoice numbering. Live Preview of Invoice Prefix As a user, I want to see a live preview of my configured prefix and format so I can confirm it’s set up correctly. As a user, I want the {{n}} counter to reset when I change the prefix, but resume its previous value if I revert back to an earlier prefix. Functional Requirements
1. Invoice Prefix Configuration
UX Design
Prefix Field (Static Text Only): A free-text field where users can enter static text for their prefix (e.g., "INV-", "Agency-", "Bill-"). Variables (e.g., {{n}}, {{dd}}, etc.) will be treated as string means if a user provide {n} then it will show as {n} Special characters and spaces are allowed and reflected in the final invoice ID. User can build his own custom format based on his preference. There should be a guide for the end user how to format this. Likely acceptable format are included below.
{{n}}/{{dd}}/{{mm}}/{{yyyy}} Default format: {{n}}-{{dd}}-{{mm}}-{{yyyy}} Duplicate variables are allowed in user defined format. {n} will reset if format is changed {n} will reset only when prefix is updated. {n} will not reset when only format is updated (updated 2-26-25)
Display a live preview of the resulting invoice prefix based on the entered prefix and selected format. Format: {{n}}/{{dd}}/{{mm}}/{{yyyy}} Preview: Agency-1/23/01/2025 2. Invoice Number Generation
Dynamic Replacement
Replace variables in the selected format when generating the invoice number: {{n}}: Auto-incremented counter starting from 1. {{dd}}, {{mm}}, {{yyyy}}: Date of invoice creation (or user-specified date via date picker). Counter Reset and Resume Logic
When a new prefix is entered, the {{n}} counter resets to 1. Invoice Numbers: Agency-1, Agency-2 Changed to Prefix: A- → Counter resets. Counter Resume for Previously Used Prefixes: If the prefix is changed back to a previously used one, the counter resumes from the last value associated with that prefix. Invoice Numbers: Agency-1, Agency-2 Changed back to Prefix: Agency- Behavior
Spaces or special characters in the prefix field are reflected in the final invoice number. Examples:
Prefix: Agency (trailing space) Format: {{n}}/{{yyyy}}/{{mm}}/{{dd}} Result: Agency 1/2025/01/23 Format: {{n}}/{{mm}}/{{yyyy}} 3. Edit Prefix and Format
Allow Superadmins/Admins to update both the prefix and the format at any time. The system will maintain a history of prefixes and their last-used counter values to support the counter resume functionality. 4. Display Prefix
The full invoice number (prefix + format with variables replaced) will appear in: Client-facing invoice PDFs/emails. Non-Functional Requirements
Performance: Ensure seamless invoice number generation, even under heavy concurrent requests. Security: Restrict prefix and format configuration to Superadmins and Admins only. Localization: Align date formats with agency settings (e.g., DD/MM/YYYY or MM/DD/YYYY). Acceptance Criteria
Users can configure the static prefix (no variables allowed). Users can select predefined formats containing {{n}} and optional date variables. A live preview reflects the configured prefix and format. The {{n}} counter resets when the prefix is changed. The {{n}} counter resumes its previous value if the prefix is reverted back to an earlier one. Spaces or special characters in the prefix field are reflected in invoice IDs. Default configuration is applied if no custom configuration is set: Format: {{n}}-{{dd}}-{{mm}}-{{yyyy}} Future Scope
Custom Date Formats: Allow users to define additional date formats (e.g., {{mm-dd-yyyy}}). Regional Date Settings: Automatically adjust date formats based on agency locale. Multiple Counters: Support different counters for specific prefixes. API Support: Enable prefixes and formats to be configured and retrieved via API. FAQ
Can variables like {{n}} be added in the prefix? No, the prefix is for static text only. Variables are exclusively configured in the format dropdown. What happens to the counter when I change the prefix? The counter resets to 1 for the new prefix. If you revert back to an earlier prefix, the counter resumes from where it left off. How is space in the prefix handled? Spaces or special charTo support the counter resume functionality, the system will maintain a history of prefixes and their last-used counter valuesacters in the prefix are reflected in the final invoice ID. For example: Format: {{n}}/{{yyyy}}/{{mm}}/{{dd}} Result: Agency 1/2025/01/23
1. Need a default format.
2. Is {{n}} has to be at the end of the string? feature name is invoice prefix, so that says {{n}} has to be at the end. confirm it. Not necessarily. {{N}} can be at the end or start or middle. But needs to be included in the string 3. Which date should be used when creating prefix? As you mentioned, it should be the date of the invoice opened/sent. in that case will the prefix be empty when creating the invoice? i.e draft invoice while creating invoice we have created date fixed we are going to allow users to change that. we are allowing users to change it using date picker because it allows our users to schedule invoice if needed.(for manual invoice creation) That date will reflect on the invoice {{dd}}-{{mm}}-{{yyyy}} variable 4.what is the max length of invoice prefix field? vai 5. If a wrong variable has been entered show an error “invalid variable”
6. Will value of {n} be reset if date format is changed? 7. When will the prefix will be set during invoice status?