/** * Add a product or calculated charge as a line to invoice * @throws Am_Exception_InvalidRequest if items is incompatible * @return Invoice provides fluent interface */ function add(IProduct $product, $qty = 1) { $item = $this->findItem($product->getType(), $product->getProductId()); if (null == $item) { $item = $this->createItem($product); $error = $this->isItemCompatible($item); if (null != $error) { throw new Am_Exception_InputError($error); } $this->_items[] = $item; } $item->add($qty); return $this; }
/** * Add a product or calculated charge as a line to invoice * @throws Am_Exception_InvalidRequest if items is incompatible * @return Invoice provides fluent interface */ function add(IProduct $product, $qty = 1) { $item = $this->findItem($product->getType(), $product->getProductId(), $product->getBillingPlanId()); if (null == $item) { $item = $this->createItem($product); $error = $this->isItemCompatible($item); if (null != $error) { throw new Am_Exception_InputError($error); } $this->addItem($item); } if (!$item->variable_qty) { $qty = $product->getQty(); } // get default qty $item->add($qty); return $this; }