I think the query is not returning all the data desired.
You need a zero value for each deduction/earning per employee in the query results.
To get the query to give all the necessary zeros I would do a union that is simply all the employees returned in the first part of the query matched up with the table(s) that have all the deduction and earnings fields.
Of course the amount of the earnings or deductions would simply be an expression - zero.
Then when the data is run against the xmlp template, it would have to sum the values.
This would make all the reports come out the same.
The way to think about the the xmlp template is that it does a loop/filter through your data.
If your loop is on employee - it is only going to return the rows with that employee.
If that employee does not have a certain deduction then it will not show up.
If your loop is on deduction or earnings - it is only going to return the rows with that employee.
Now if you have a fixed list of deductions/earnings then you can code this into the xmlp template - tedious, but it will work.
If your deductions/earnings ever change, you will have to perform maintenance on the report.