This problem happen because the Store procedure GETLATESTNUMBERSEQUENCE don't consider that the Sales and Return transaction have the same TYPE: TransactionType.Sales. Both types (Sales and Return) are differencitated by the sign of transaction amount.
For a transaction of TYPE Sale (2) or IncomeExpense(18), there are two different receipt types (ReceiptTransactionType.Return and ReceiptTransactionType.Sale). The business logic differentiate that by the sign on the transaction amount. Thus we need to return 2 records for those TYPES, the latest transaction for a positive amount (sales receipt) and the latest transaction for a negative amount (return receipt).