Hello Ashwin,
A bit unsure about what you mean by credit notes. However, some other tips that I hope will help.
Personally I prefer using the OACT.groupmask to indicate which accounts to take. The groupmask number indicates the drawer of the account. 1 = Assets, 2 Liabilities etc. If your balance sheet has three drawers then use:
where groupmask > 3 (that is to get all the P&L accounts)
Further, to avoid that NULL values in debit or credit column messes up the calculation you can use:
sum(debit) - sum(credit)
Using the acttype I would say is risky as a user easily can change this to type 'Other'.
I hope that is useful for you.
Jesper