Invoice creation lead to get a property on a non-object
authorPaul Mehrer <p.mehrer@metaways.de>
Fri, 13 Mar 2015 14:00:24 +0000 (15:00 +0100)
committerPhilipp Schüle <p.schuele@metaways.de>
Mon, 16 Mar 2015 15:29:51 +0000 (16:29 +0100)
fixed that

Change-Id: Id4c4991b0122a00f06573aeacb69e38de4194085
Reviewed-on: http://gerrit.tine20.com/customers/1730
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tine20/Sales/Controller/Invoice.php

index ffd8763..2276070 100644 (file)
@@ -332,6 +332,13 @@ class Sales_Controller_Invoice extends Sales_Controller_NumberableAbstract
                 }
             }
             
+            $product = $this->_cachedProducts->getById($productAggregate->product_id);
+            
+            if (! $product) {
+                $product = Sales_Controller_Product::getInstance()->get($productAggregate->product_id);
+                $this->_cachedProducts->addRecord($product);
+            }
+            
             if (!$productEnded) {
                 if (NULL != $productAggregate->end_date && $nextBill->isLater($productAggregate->end_date)) {
                     $nextBill = clone $productAggregate->end_date;
@@ -343,13 +350,6 @@ class Sales_Controller_Invoice extends Sales_Controller_NumberableAbstract
                 }
                 
                 $nextBill->setTime(0,0,0);
-                
-                $product = $this->_cachedProducts->getById($productAggregate->product_id);
-                
-                if (! $product) {
-                    $product = Sales_Controller_Product::getInstance()->get($productAggregate->product_id);
-                    $this->_cachedProducts->addRecord($product);
-                }
             }
             
             // find out if this model has to be billed or skipped