/**
  * @param \Generated\Shared\Transfer\InvoiceTransfer $invoiceTransfer
  * @throws \Pav\Zed\Invoice\Business\Exception\InvoiceDoesNotExistException
  * @throws \Propel\Runtime\Exception\PropelException
  * @return void
  */
 public function writeInvoiceVersion(InvoiceTransfer $invoiceTransfer)
 {
     $invoiceEntity = $this->queryContainer->queryInvoiceById($invoiceTransfer->getIdInvoice())->findOne();
     if ($invoiceEntity === null) {
         throw new InvoiceDoesNotExistException(sprintf('Invoice: %s does not exist.', $invoiceTransfer->getIdInvoice()));
     }
     $invoiceEntity->setTemplateVersion($invoiceTransfer->getTemplateVersion());
     $invoiceEntity->setFileName($invoiceTransfer->getFileName());
     $invoiceEntity->save();
 }
 /**
  * @param \Generated\Shared\Transfer\InvoiceTransfer $invoiceTransfer
  *
  * @throws \Pav\Zed\InvoiceDocument\Business\Exception\InvoiceTypeHasNoVersionException
  * @return \Generated\Shared\Transfer\InvoiceTransfer
  */
 protected function addTemplateVersion(InvoiceTransfer $invoiceTransfer)
 {
     $invoiceType = $invoiceTransfer->getInvoiceType();
     $templateVersion = $invoiceTransfer->getTemplateVersion();
     if ($templateVersion === null) {
         $templateVersion = $this->invoiceDocumentConfig->getTemplateVersionByType($invoiceType);
         $invoiceTransfer->setTemplateVersion($templateVersion);
         $this->invoiceVersionWriter->writeInvoiceVersion($invoiceTransfer);
     }
     return $invoiceTransfer;
 }
 /**
  * @param \Generated\Shared\Transfer\InvoiceTransfer $invoiceTransfer
  *
  * @return string
  */
 public function createRelativePath(InvoiceTransfer $invoiceTransfer)
 {
     return '/' . $invoiceTransfer->getCustomerReference();
 }
 /**
  * @param \Generated\Shared\Transfer\InvoiceTransfer $invoiceTransfer
  * @throws \Propel\Runtime\Exception\PropelException
  *
  * @return void
  */
 protected function writeInvoiceTaxItems(InvoiceTransfer $invoiceTransfer)
 {
     foreach ($invoiceTransfer->getTaxes() as $tax) {
         $invoiceTax = $this->queryContainer->createInvoiceTaxEntity();
         $invoiceTax->fromArray($tax->toArray());
         $invoiceTax->setFkInvoice($invoiceTransfer->getIdInvoice());
         $invoiceTax->save();
     }
 }
 /**
  * @param \Orm\Zed\Invoice\Persistence\PavInvoice $invoiceEntity
  * @param \Generated\Shared\Transfer\InvoiceTransfer $invoiceTransfer
  *
  * @return void
  */
 protected function setTaxItems(PavInvoice $invoiceEntity, InvoiceTransfer $invoiceTransfer)
 {
     $taxItems = $invoiceEntity->getInvoiceTaxes();
     foreach ($taxItems as $taxItem) {
         $taxItemTransfer = new InvoiceTaxTransfer();
         $taxItemTransfer->fromArray($taxItem->toArray(), true);
         $invoiceTransfer->addTax($taxItemTransfer);
     }
 }