The fix for the invoice range is not to rely on any pattern but to rely on the transaction number and type directly. Hence, replace lines 39-40 of reporting/rep107.php:
." AND trans.reference>=".db_escape(get_reference(ST_SALESINVOICE, $from))
." AND trans.reference<=".db_escape(get_reference(ST_SALESINVOICE, $to))
with:
." AND trans.trans_no BETWEEN ".db_escape($from)." AND ".db_escape($to)
This will result in the $sql in the get range function to be like:
SELECT trans.trans_no, trans.reference
FROM &TB_PREF&debtor_trans trans
LEFT JOIN &TB_PREF&voided voided ON trans.type=voided.type AND trans.trans_no=voided.id
WHERE trans.type=10 AND ISNULL(voided.id)
AND trans.trans_no BETWEEN '1' AND '5'
ORDER BY trans.tran_date, trans.reference
@joe: see if fit to commit.