#13288·invoiceninja

Quote number is not generated with "When Sent" when Valid Until is the current date

Author: emorales2023Created Sep 19, 2026Updated Sep 20, 2026
Labelstriage

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:

  1. Set Generated Numbers → Generate Number to When Sent.
  2. Create a new quote.
  3. Set the quote date to 2026-09-18.
  4. Set Valid Until to 2026-09-19 — the current date.
  5. Save the quote as a draft.
  6. Confirm that the quote number is empty, as expected with When Sent.
  7. Use Mark Sent.
  8. The quote is processed as sent/expired, but its number remains 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-19
Valid 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-18
Valid 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

bash

Source: invoiceninja/invoiceninja