public function findByOtherReference($number) { $this->client->connect(); try { $response = $this->client->Invoice_FindByOtherReference(array("otherReference" => $number)); if (!isset($response->CurrentInvoice_FindByOtherReferenceResult) || !isset($response->CurrentInvoice_FindByOtherReferenceResult->Number)) { throw new Api\Exception\InvoiceNotFoundException(sprintf("The Invoice with %s couldn't be found", $number)); } $invoice = new Invoice(); $invoice->setHandle((array) $response->Invoice_FindByOtherReferenceResult); return $invoice; } catch (\SoapFault $e) { throw new Api\Exception\EconomicException($e->getMessage()); } }
public function updateEntryFromInvoice(CashBookEntry $entry, Invoice $invoice, $amount) { $this->client->connect(); try { $this->client->CashBookEntry_SetAmount(array('cashBookEntryHandle' => $entry->getHandle(), 'value' => $amount)); $number = $invoice->getHandle(); if (is_array($number)) { $number = current($number); } $this->client->CashBookEntry_SetDebtorInvoiceNumber(array('cashBookEntryHandle' => $entry->getHandle(), 'value' => $number)); $this->client->CashBookEntry_SetText(array('cashBookEntryHandle' => $entry->getHandle(), 'value' => "Invoice: {$number}, Other Reference: {$invoice->getOtherReference()}")); return $entry; } catch (\SoapFault $e) { throw new EconomicException($e->getMessage()); } }