Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot create all invoices. #1

Open
giancarloap opened this issue Mar 17, 2014 · 4 comments
Open

Cannot create all invoices. #1

giancarloap opened this issue Mar 17, 2014 · 4 comments

Comments

@giancarloap
Copy link

I can ship orders but i cannot create invoice. The same happens on both options, ship, mail and invoice;ship and involce(no email).
I get that message.

"Sent 1 shipments of 1 requested. Cannot create all invoices."

I debugged and after this attribution, the if returns false, it doesn't invoice, and order doesn't get complete because it didn't invoice.
$invoices = Mage::getResourceModel('sales/order_invoice_collection')->setOrderFilter($orderId)->load();
try {
if ($invoices->getSize() > 0) {

I'm using magento ce 1.7.0.2. Is the module compatible? Any idea on what the problem is?

@giancarloap
Copy link
Author

I changed the invoice code for now. I replaced the invoice part, It worked for me like this:

$incrementId = $order->getIncrementId();
$order = Mage::getModel('sales/order')->loadByIncrementId($incrementId);
try {
if(!$order->canInvoice())
{
Mage::throwException(Mage::helper('core')->__('Cannot create an invoice.'));
}

                        $invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();

                        if (!$invoice->getTotalQty()) {
                            Mage::throwException(Mage::helper('core')->__('Cannot create an invoice without products.'));
                        }

                        $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
                        //Or you can use
                        //$invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_OFFLINE);
                        $invoice->register();
                        $transactionSave = Mage::getModel('core/resource_transaction')
                        ->addObject($invoice)
                        ->addObject($invoice->getOrder());

                        $transactionSave->save();
                        $invoiced++;
                    }
                    catch (Mage_Core_Exception $e) {

                    }

@seansan
Copy link
Owner

seansan commented Mar 17, 2014

I had a look in the code. Actually what it does now is ship, mail and create pdf (it does not create the invoice). We have set the settings in backend related to "auto invoice" ...

@giancarloap
Copy link
Author

Ok. I forgot to answer. It's been a while. The changes I made worked, and creates the invoice. If you want, you can add the code I made to the library to add the invoice creation, or fork to a version with invoice creation. I'm new on github, i dont know if closing the issue removes all the comments I made. I think it would be good if any person can see this code that I made in case someone has the same situation or necessity that I had(to create invoice too). Thanks a lot, this lib helped me. Now my company is starting to grow.

@giancarloap
Copy link
Author

I have a question, do you accept donation? If so, how to proceed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants