Example #1
0
 private function _create_invoice($cycle_number = null)
 {
     $salesproject = new org_openpsa_sales_salesproject_dba($this->_deliverable->salesproject);
     $invoice = new org_openpsa_invoices_invoice_dba();
     $invoice->customer = $salesproject->customer;
     $invoice->customerContact = $salesproject->customerContact;
     $invoice->number = $invoice->generate_invoice_number();
     $invoice->owner = $salesproject->owner;
     $invoice->vat = $invoice->get_default('vat');
     $invoice->description = $invoice->get_default('remarks');
     if ($invoice->create()) {
         // Register the cycle number for reporting purposes
         if (!is_null($cycle_number)) {
             $invoice->parameter('org.openpsa.sales', 'cycle_number', $cycle_number);
         }
         return $invoice;
     } else {
         throw new midcom_error('Failed to create invoice, ' . midcom_connection::get_error_string());
     }
 }