Unable to save the invoice bug fix

I did a change to the website like below founded on this forum:

Change the pay() function in app\\\\code\\\\core\\\\mage\\\\sales\\\\model\\\\order\\\\[url removed, login to view] like shown below.

It’s better to make a new [url removed, login to view] in your local or community environment of course


* Pay invoice


* @return Mage_Sales_Model_Order_Invoice


public function pay()


if ($this->_wasPayCalled) {

return $this;


$this->_wasPayCalled = true;

$invoiceState = self::STATE_PAID;

if ($this->getOrder()->getPayment()->hasForcedState()) {

$invoiceState = $this->getOrder()->getPayment()->getForcedState();




// Check if order is already paid for. If so, it was paid for with an external payment provider

// so do not add Grandtotal to TotalPaid. This is a bugfix for a bug in the payment registration in Magento imho

// Fixed by Ed de Tollenaer [url removed, login to view]

if ($this->getOrder()->getTotalPaid() == $this->getOrder()->getGrandTotal()) {



} else {




Mage::dispatchEvent(\\\’sales_order_invoice_pay\\\’, array($this->_eventObject=>$this));

return $this;


After this, run the following SQL statements on your database in PHPMyAdmin:

UPDATE sales_flat_order SET total_paid = total_invoiced WHERE total_paid > total_invoiced

UPDATE sales_flat_order SET base_total_paid = base_total_invoiced WHERE base_total_paid > base_total_invoiced

UPDATE sales_flat_order_grid SET base_total_paid = base_grand_total WHERE base_total_paid > base_grand_total

UPDATE sales_flat_order_grid SET total_paid = grand_total WHERE total_paid > grand_total

Then, go to Magento->Reports->Refresh statistics and refresh the lifetime statistics.

You can also reindex the database, but I am not sure if this is necessary.

When you go to the Reports->Sales->Total invoiced report you’ll see that the totals are up-to-date.

Everything works als planned but when i try to make the invoice it says: Unable to save the invoice.

What have i done wrong and how can i put it back in de database?

Skills: Magento, Website Design

See more: magento unable save invoice, unable save invoice magento, unable save invoice, magento unable order, save invoice magento, wrong invoice, where is community set, what was the, statistics community, how to make a sales website, how to do reports, how do you fix it, bug statistics, invoice works, how do i save, where is invoice?, the de, save the date, sales order app, php invoice, invoice, invoice app, design an invoice, code ed, bugfix

About the Employer:
( 1 review ) Den Haag, Netherlands

Project ID: #2559119

Awarded to:


Hi, I can fix it for you. Let me do it. Thanks.

$50 USD in 1 day
(11 Reviews)

3 freelancers are bidding on average $43 for this job


Please check PM

$30 USD in 1 day
(29 Reviews)

let expert do it

$50 USD in 1 day
(11 Reviews)