I have a order with canceled order items in it.
As an example:
Item 1 = 10 euro
Item 2 = 20 euro
Item 3 = 30 euro
Now the items 2 and 3 are canceled.
The grand_total should now be 10 Euro.
But when I create an invoice programmatically the invoice is always 60 euro.
To create my invoice I create a new Mage_Sales_Model_Order $order and use this for my invoice. But inside that model there are also the canceled items and so my invoice is always wrong.
prepareInvoice
method in the Order model knows which items are canceled, seeMage_Sales_Model_Order_Item::getQtyToInvoice