Question

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.]

  1. Submit an order through authorize.net in test mode with authorize-only mode.
  2. Create an invoice using the API and nothing more.

    i.e. $invoice = Mage::getModel('sales/order_invoice_api')->create($orderIncrementId, array());

  3. Ship all of the order items.

  4. Go to the admin, and cancel the pending invoice.
  5. Create another invoice
  6. 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.

Was it helpful?

Solution

As I recall, this was a problem of a method processing invoices for the same order in different ways. It was creating two separate invoices and save them separately, causing inconsistencies.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top