Sales Orders: Next Number Picks The Highest Sequence, Not The Newest
Sales order numbers could duplicate when an older order held a higher sequence than the most recently created one. The next-number lookup used the newest order by created-at; it now uses the maximum sequence across all matching orders, archived ones included — the same approach purchase orders already use.