|
|
|
@ -60,7 +60,8 @@ select bm.contract_id,max(bm.id) as actual_bm_id from billing.billing_mappings b
|
|
|
|
|
(select bmm.contract_id, max(bmm.start_date) max_start_date
|
|
|
|
|
from billing.billing_mappings bmm
|
|
|
|
|
where ( bmm.`end_date` >= ? OR bmm.`end_date` IS NULL )
|
|
|
|
|
AND ( bmm.`start_date` <= ? OR bmm.`start_date` IS NULL )
|
|
|
|
|
AND ( bmm.`start_date` <= ? OR bmm.`start_date` IS NULL )
|
|
|
|
|
AND ( ? is null OR bmm.`contract_id` = ? )
|
|
|
|
|
group by bmm.contract_id
|
|
|
|
|
) bmm on bm.contract_id=bmm.contract_id and (bm.start_date=bmm.max_start_date or (bmm.max_start_date is null and bm.start_date is null))
|
|
|
|
|
group by bm.contract_id
|
|
|
|
|