fixed invoice subtotal calculation failure

Hi,

I've found a problem with wrong subtotal on invoice when cod fee is charged.

The tax amount is added to product subtotals because of Magento's strange way to calculate subtotal in Mage_Sales_Model_Order_Invoice_Total_Subtotal .

The problem here is that for $allowedSubtotalInclTax the whole tax amount is calculated. Then the shipping tax amount is subtracted.
Now also the COD fee tax should be subtracted, else it will be added to subtotal.
Example:
Product costs (gross) 29,99
COD fee (gross): 5,00
COD fee tax: 0,80
Subtotal in order: 29,99
Subtotal on invoice: 30,79 = 29,99 + 0,80 .
The problem effects at least Magento 1.6.x and 1.7.x

For the fix I've added a class rewrite for Mage_Sales_Model_Order_Invoice_Total_Subtotal, where the COD tax amount is also subtracted from $allowedSubtotalInclTax .

Best regards,

schnere