In Progress

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();

}

$this->setState($invoiceState);

$this->getOrder()->getPayment()->pay($this);

// 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()) {

$this->getOrder()->setTotalPaid($this->getOrder()->getTotalPaid());

$this->getOrder()->setBaseTotalPaid($this->getOrder()->getBaseTotalPaid());

} else {

$this->getOrder()->setTotalPaid($this->getOrder()->getTotalPaid()+$this->getGrandTotal());

$this->getOrder()->setBaseTotalPaid($this->getOrder()->getBaseTotalPaid()+$this->getBaseGrandTotal());

}

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, community set, statistics community, make sales website, bug statistics, invoice works, the de, sales order app, php invoice, invoice, invoice app, code ed, bugfix, magento order date, order invoiced, save report, self registration, fix bug app, bug fixed, pending invoice

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

Project ID: #2559119

Awarded to:

blueforestsun

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

$50 USD in 1 day
(11 Reviews)
4.3

3 freelancers are bidding on average $43 for this job

therofree

Please check PM

$30 USD in 1 day
(29 Reviews)
4.4
pivn

let expert do it

$50 USD in 1 day
(11 Reviews)
3.9