Exemplo n.º 1
0
 public function testCRUD()
 {
     midcom::get('auth')->request_sudo('org.openpsa.invoices');
     $data = new org_openpsa_invoices_billing_data_dba();
     $data->linkGuid = self::$_contact->guid;
     $data->useContactAddress = true;
     $stat = $data->create();
     $this->assertTrue($stat, midcom_connection::get_error_string());
     $this->register_object($data);
     $parent = $data->get_parent();
     $this->assertEquals($parent->guid, self::$_contact->guid);
     self::$_contact->refresh();
     $this->assertEquals(self::$_contact->street, $data->street);
     $data->vat = 12;
     $data->due = 12;
     $stat = $data->update();
     $this->assertTrue($stat);
     self::$_contact->refresh();
     $invoice = new org_openpsa_invoices_invoice_dba();
     $invoice->customerContact = self::$_contact->id;
     $invoice_data = $invoice->get_billing_data();
     $this->assertEquals($data->guid, $invoice_data->guid);
     $this->assertEquals($data->vat, $invoice->get_default('vat'));
     $this->assertEquals($data->due, $invoice->get_default('due'));
     $stat = $data->delete();
     $this->assertTrue($stat);
     midcom::get('auth')->drop_sudo();
 }
Exemplo n.º 2
0
 /**
  * Datamanager callback
  */
 public function &dm2_create_callback(&$datamanager)
 {
     $billing_data = new org_openpsa_invoices_billing_data_dba();
     $billing_data->linkGuid = $this->_linked_object->guid;
     if (!$billing_data->create()) {
         debug_print_r('We operated on this object:', $billing_data);
         throw new midcom_error("Failed to create a new billing_data. Error: " . midcom_connection::get_error_string());
     }
     return $billing_data;
 }