I was testing various scenarios creating invoices and capturing them. I am using EE 184.108.40.206, and I noticed a strange behavior where if I do the following, the subtotal is doubled from the original ordered item list. [Update: I now know why this is happening. Please see the end of the post.]
- Submit an order through authorize.net in test mode with authorize-only mode.
Create an invoice using the API and nothing more.
$invoice = Mage::getModel('sales/order_invoice_api')->create($orderIncrementId, array());
Ship all of the order items.
- Go to the admin, and cancel the
- Create another invoice
- Check out the subtotal. My instance always doubles the subtotal, tax, etc, and it cannot be modified in the second time creating the invoice.
This is happening because when the API method is called to create the invoice and the process ends there, the
*_invoiced entries are not updated. When a non-capturing invoice is created,
*_invoiced are updated.
Subsequently, when canceling this pending invoice,
sales_flat_order is updated (subtracted) to reset values in
*_invoiced. This is causing the negative dollar amounts in this table and causing problems when I try to re-invoice the order. I'm gonna try a couple more things and post an update here.
I've resolved this problem, and it was due to a logic problem and not inherently related to the core functions. I'll update my answer later.