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

17 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
    Replies
    1. Yeah... I even put in a suggestion about changing this.
      Of course, their canned response was "the invoice is a receipt."
      ?!?!? WTF ?!?!?
      They obviously have not looked up the definition of invoice. LOL

      Delete
  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
  8. CE version 1.8.1
    Fatal error: Multiple access type modifiers are not allowed in /home/arplanst/public_html/crm/includes/src/Mage_Payment_Model_Method_Checkmo.php on line 33

    ReplyDelete
  9. Fatal error: Multiple access type modifiers are not allowed in /home/arplanst/public_html/crm/includes/src/Mage_Payment_Model_Method_Checkmo.php on line 33

    Oops... I put a # instead of $

    ReplyDelete
  10. Yes i try this. and i think its work fine in fresh magento.

    I am using extension for one page checkout and because of this its not work for me.

    but i have update "protected $_canCapture = false; to "protected $_canCapture = true;" on /var/www/surpriseforu/public_html/app/code/core/Mage/Payment/Model/Method/Abstract.php path. and its work fine for me..

    Thanks,
    Rakesh Patel.

    ReplyDelete
  11. I know it is five years since this was posted, and it works great. But is it possible to only allow the Option "Not Capture" and remove the other options for the same payment method.

    Thanks Jethro

    ReplyDelete
  12. I have used code protected $_canCapture = true; in Cash on delivery payment method, in order to generate invoice with payment status pending to either capture payment when amount is paid or cancel invoice when payment is not done. When payment is not done, I am able to cancel invoice and then cancel order. Doing this, not increase stock Qty of the items in the order.

    ReplyDelete