/** * @covers Moneybird\IncomingInvoice::save */ public function testSave() { $details = new IncomingInvoice\Detail\ArrayObject(); $details->append(new IncomingInvoice\Detail(array('amount' => 5, 'description' => 'My invoice line', 'price' => 20, 'taxRateId' => self::$taxRateId))); $details->append(new IncomingInvoice\Detail(array('amount' => 1, 'description' => 'My second invoice line', 'price' => 12, 'taxRateId' => self::$taxRateId))); $invoice = new IncomingInvoice(array('invoiceId' => '2012-' . time(), 'invoiceDate' => new \DateTime(), 'details' => $details, 'currency' => 'EUR'), self::$contact); $invoice->save($this->service); $this->assertInstanceOf('Moneybird\\IncomingInvoice', $invoice); self::$invoiceId = $invoice->id; $this->assertNotNull(self::$invoiceId); $this->assertGreaterThan(0, self::$invoiceId); $invoice->details[0]->setDeleted(); $invoice->save($this->service); $this->assertEquals(1, count($invoice->details)); }
/** * @covers Moneybird\Contact::createIncomingInvoice */ public function testCreateIncomingInvoice() { $details = new IncomingInvoice\Detail\ArrayObject(); $details->append(new IncomingInvoice\Detail(array('amount' => 5, 'description' => 'My invoice line', 'price' => 20, 'tax' => 0.19))); $details->append(new IncomingInvoice\Detail(array('amount' => 1, 'description' => 'My second invoice line', 'price' => 12, 'tax' => 0.19))); $template = $this->object->createIncomingInvoice(array('invoiceId' => '2012-' . time(), 'invoiceDate' => new \DateTime(), 'details' => $details, 'currency' => 'EUR')); $template->save($this->apiConnector->getService('IncomingInvoice')); }