I had some problems with a payment module and some invoices were not created. But I'm generating the invoices need to create programmatically and the same with the dates of the requests not to lose the billing metrics from my reports.
$orderItems = $order->getAllItems();
$invoiceItems = array();
foreach ($orderItems as $_eachItem) {
$opid = $_eachItem->getId();
$opdtId = $_eachItem->getProductId();
$itemss = Mage::getModel('catalog/product')->load($opdtId);
$psku = $itemss->getSku();
$qty = $_eachItem->getQtyOrdered();
$itemsarray[$opid] = $qty;
}
if($order->canInvoice()) {
$invoiceId = Mage::getModel('sales/order_invoice_api')
->create($order->getIncrementId(), $itemsarray ,'Fatura Criada Manualmente via Script' ,0,0);
}
So, how create invoice with a custom date? Any Idea?