Quote number is not generated with "When Sent" when Valid Until is the current date
Invoice Ninja version
5.13.43
Environment
Docker
Interface
Both
Can you reproduce the issue on one of our demo sites?
Yes, on both demos
Pre-flight checks
- I have reviewed the troubleshooting documentation.
- I have searched existing issues for duplicates.
Have you reported this issue on Slack or the forum?
No
Have you inspected the application logs?
Yes, but I found no relevant errors
Describe the bug
When Generated Numbers → Generate Number is set to When Sent, marking a draft quote as sent does not generate a quote number if the quote's Valid Until date is the current date.
This is not specific to the dates used in the example below. The relevant condition is:
Valid Until = current date
The dates below use September 19, 2026 as the current date because that is the date on which this behavior was reproduced.
Steps to reproduce
Assuming the current date is 2026-09-19:
- Set Generated Numbers → Generate Number to When Sent.
- Create a new quote.
- Set the quote date to
2026-09-18. - Set Valid Until to
2026-09-19— the current date. - Save the quote as a draft.
- Confirm that the quote number is empty, as expected with
When Sent. - Use Mark Sent.
- The quote is processed as sent/expired, but its
numberremains empty.
Expected behavior
Marking a quote as sent should generate its quote number when Generate Number = When Sent, even if the quote is considered expired based on its Valid Until date.
At minimum, number generation should not produce different results solely depending on whether the same quote is configured to receive its number When Saved versus When Sent.
Additional context
Control tests
Control 1 — Valid Until is tomorrow
Using the same configuration and workflow, create a quote with:
Quote Date: 2026-09-19Valid Until: 2026-09-20
Marking the quote as sent correctly generates the quote number.
Control 2 — Generate Number = When Saved
Change Generate Number to When Saved and create a quote with:
Quote Date: 2026-09-18Valid Until: 2026-09-19
The quote number is generated correctly when the draft is saved.
Therefore, the issue appears specifically when:
Generate Number = When Sent
and:
Valid Until = current date
Relevant code path
MarkSent::run() sets the quote status to STATUS_SENT and then calls applyNumber().
ApplyNumber::run() only generates the number for when_sent if:
quote->status_id == STATUS_SENT
However, Quote::getStatusIdAttribute() returns STATUS_EXPIRED when:
due_date <= now()->startOfDay()
As a result, when Valid Until is the current date, the quote is evaluated as expired before ApplyNumber checks for STATUS_SENT, and the number is not generated.
Screenshots or screen recordings
No response
Relevant log output
Source: invoiceninja/invoiceninja