Ejemplo n.º 1
0
 /**
  * Deletes a contact note
  * @param Service $service
  * @param Contact $contact
  */
 public function delete(ServiceInterface $service, Contact $contact = null)
 {
     if ($contact === null) {
         throw new Exception('$contact must be instance of Contact');
     }
     $service->deleteNote($this, $contact);
 }
Ejemplo n.º 2
0
 /**
  * Inserts history note
  * @param ServiceInterface $service
  * @param Invoice $invoice
  * @return self
  * @throws NotValidException
  * @todo throw more specific exception on invalid parent
  */
 public function save(ServiceInterface $service, Invoice $invoice = null)
 {
     if (!$this->validate()) {
         throw new NotValidException('Unable to validate invoice history');
     }
     if ($invoice === null) {
         throw new Exception('$invoice must be instance of Invoice');
     }
     $newInvoice = $service->saveHistory($this, $invoice);
     $invoice->setData($newInvoice->toArray(), false);
     return $this->reload(end($invoice->history));
 }
Ejemplo n.º 3
0
 /**
  * Settle the payments
  *
  * @param Service $service
  * @param Payable $invoice
  * @param bool $sendEmail
  * @throws InvalidStateException
  * @throws UnableToSettleException
  */
 public function settle(Service $service, Payable $invoice, $sendEmail = false)
 {
     return $service->settle($this, $invoice, $sendEmail);
 }
Ejemplo n.º 4
0
 /**
  * Updates or inserts an estimate
  * @param Service $service
  * @return self
  * @throws NotValidException
  */
 public function save(Service $service)
 {
     if (!$this->validate()) {
         throw new NotValidException('Unable to validate estimate');
     }
     return $this->reload($service->save($this));
 }
Ejemplo n.º 5
0
 /**
  * Updates or inserts a contact
  * @param Service $service
  * @return self
  * @throws NotValidException
  */
 public function save(Service $service)
 {
     if (!$this->sepaActive) {
         $valid = $this->validate();
     } else {
         $oldRequired = $this->_requiredAttr;
         $this->_requiredAttr[] = 'sepaIban';
         $this->_requiredAttr[] = 'sepaIbanAccountName';
         $this->_requiredAttr[] = 'sepaBic';
         $this->_requiredAttr[] = 'sepaMandateId';
         $this->_requiredAttr[] = 'sepaMandateDate';
         $this->_requiredAttr[] = 'sepaSequenceType';
         $valid = $this->validate();
         $this->_requiredAttr = $oldRequired;
     }
     if (!$valid) {
         throw new NotValidException('Unable to validate contact');
     }
     return $this->reload($service->save($this));
 }