I was testing various scenarios creating invoices and capturing them. I am using EE 1.13.1.0, 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.
i.e.
$invoice = Mage::getModel('sales/order_invoice_api')->create($orderIncrementId, array());
Ship all of the order items.
- Go to the admin, and cancel the
pending
invoice. - 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.
UPDATE 1:
This is happening because when the API method is called to create the invoice and the process ends there, the sales_flat_order
table's *_invoiced
entries are not updated. When a non-capturing invoice is created, sales_flat_order
's *_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.
Update 2:
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.