Thursday, April 22, 2010

How to change invoice status in Admin panel

Problem: When creating Invoice directly from Order in admin the invoice automatically gets marked as Paid. how can it be created with the status 'Pending' and marked as paid later. http://www.magentocommerce.com/boards/viewthread/54391/

Possible solution:
In order to create a 'pending' invoice, the payment method you use for the order must allow you to.
For that you need to add in the payment method's model this member:
protected $_canCapture = true;
You can add it right under
protected $_code  = 'PAYMENT CODE HERE';
For example if you want to do this for Check/money order you need to add the line above in app/code/core/Mage/Payment/Model/Method/Checkmo.php

After this when you create an invoice you will have an option near the save button to set the invoice status. (see picture attached). To create a pending invoice select 'Not capture'.
If you want to mark it later as paid edit the invoice and between the buttons on to one called 'Capture' (see picture). Well you get the idea....

11 comments:

  1. Thank you so much for sharing this info. It was a real lifesaver.

    ReplyDelete
  2. Hey. Great info. But can this be done without changing core stuff (so that you can still update)? Like overriding the model in /app/code/local?

    ReplyDelete
  3. Hello Dakira. Yes you can. You can override the payment method model just like any other model (or block or helper) and add the line I suggested in your class.

    ReplyDelete
  4. Can i also use it in magento 1.5?

    ReplyDelete
  5. Should this also work for pre-existing invoices, or only invoices created as 'pending' after applying this override?

    ReplyDelete
    Replies
    1. Hello.
      It works only for invoices created after applying the update.

      Marius.

      Delete
  6. You know, if real accountants had been consulted on purchase order processing by the geeks who wrote this sorry stuff, it would not be necessary to tweak it like this. Obviously, the programmers who wrote this do not have to deal with invoicing. Since when is an invoice 'paid' just because it was printed or emailed?? How is a store owner expected to know what is due if all invoices are marked 'paid'?? Another downside to Magento....

    ReplyDelete
  7. how can i do this programetically ? that is create invoice with pending staus.

    ReplyDelete
    Replies
    1. I didn't try this before, but you can try to simulate how the invoice is created in the controller. Add some debug lines in the 'Mage_Adminhtml_Sales_Order_InvoiceController::saveAction' method, see what data is sent by POST and how the invoice is created and do the same in your custom code.

      Delete