SELECT t.* FROM ( SELECT '' TransactionID,cast(DATE_Format(InvoiceDate,'%d/%b/%y') as char) `BillDate`,'0' PrintHeader,InvoiceDate EntryDate, invoiceno,panelid,(SELECT CONCAT(Panel_Code,'-',Company_Name) FROM f_panel_master WHERE Panel_ID='956')panelname,'Credit Bill' TYPE,0 credit, `ShareAmt` debit , CONCAT(invoiceno,' : Testing Charges of Clinical Samples for the Month for ',fromdate,' to ', todate) period FROM invoicemaster WHERE iscancel=0 AND invoicedate>='2025-12-01' AND invoicedate<='2025-12-16' AND panelid='956' UNION ALL SELECT ivca.orderid TransactionID,cast(DATE_Format(ivca.`ReceivedDate`,'%d/%b/%y') as char) `BillDate`,'0' PrintHeader,ivca.`ReceivedDate` EntryDate, ivca.`receiptno` invoiceno,Panel_ID panelid,(SELECT CONCAT(Panel_Code,'-',Company_Name) FROM f_panel_master WHERE Panel_ID='956')panelname,'' TYPE, ROUND( IF(`CreditNote`<>2,ivca.receivedamt,0),0), IF(`CreditNote`<>2,0,ivca.receivedamt*-1) debit, CONCAT(Remarks,CASE WHEN PaymentModeID=12 THEN ' (WriteOff)' WHEN PaymentModeID=11 THEN ' (TDS)' WHEN CreditNote=1 THEN ' (Credit Note)' WHEN CreditNote=2 THEN ' (Debit Note)' ELSE '' END) AS period FROM invoicemaster_onaccount ivca WHERE ivca.iscancel=0 AND Panel_ID='956' AND `ReceivedDate`>='2025-12-01' AND ReceivedDate<='2025-12-16' )t order by EntryDate