Example #1
0
 /**
  * @param ArrayCollection $rows
  */
 public function addRow(Row $row)
 {
     $this->rows[] = $row;
     $row->setDocument($this);
 }
 private function addInvoiceRowToView(ViewModel $view, Row $row = null)
 {
     $auth = $this->getServiceLocator()->get('zfcuser_auth_service');
     $user = $auth->getIdentity();
     $view->setTemplate('application/document/partial/row');
     $view->uoms = $this->settingsService->getAllUoms($user);
     $view->vats = $this->settingsService->getAllVats($user);
     if ($row != null) {
         $view->price = $row->getPrice();
         $view->code = $row->getCode();
         $view->name = $row->getName();
         $view->description = $row->getDescription();
         $view->quantity = $row->getQuantity();
         $view->rowId = $row->getId();
         $view->selectedUom = $row->getUom();
         $view->selectedVat = $row->getVat();
         $view->selectedArticle = $row->getArticle();
         $view->selectedWarehouse = $row->getWarehouse();
         $view->amount = $row->getAmount();
         $view->vatAmount = $row->getVatAmount();
         $view->vatValue = $row->getVatValue();
     }
     return $view;
 }
Example #3
0
 public function cloneDocument(Document $document)
 {
     $auth = $this->getServiceLocator()->get('zfcuser_auth_service');
     if ($auth->hasIdentity()) {
         $user = $auth->getIdentity();
     }
     if ($document instanceof Document\Invoice) {
         $newDocument = new Document\Invoice();
     }
     $newDocument->setDeadlineDays($document->getDeadlineDays());
     $newDocument->setCustomer($document->getCustomer());
     $newDocument->setPaymentType($document->getPaymentType());
     $newDocument->setCreatedBy($user);
     $newDocument->setAmountTax($document->getAmountTax());
     $newDocument->setTaxAmount($document->getAmountTax());
     $newDocument->setAmount($document->getAmount());
     $newDocument->setDocumentDate(new \DateTime());
     $newDocument->setComment($document->getComment());
     $newDocument->setDelayPercent($document->getDelayPercent());
     $newDocument->setPrefix($document->getPrefix());
     $newDocument->setVat($document->getVat());
     $newDocument = $this->saveObject($newDocument);
     foreach ($document->getRows() as $row) {
         /* @var $row \Application\Entity\Document\Row */
         if ($row) {
             $newRow = new Document\Row();
             $newRow->setVat($row->getVat());
             $newRow->setWarehouse($row->getWarehouse());
             $newRow->setAmount($row->getAmount());
             $newRow->setArticle($row->getArticle());
             $newRow->setBarCode($row->getBarCode());
             $newRow->setCode($row->getCode());
             $newRow->setDescription($row->getDescription());
             $newRow->setName($row->getName());
             $newRow->setPrice($row->getPrice());
             $newRow->setQuantity($row->getQuantity());
             $newRow->setUom($row->getUom());
             $newRow->setDocument($newDocument);
             $this->saveObject($newRow);
         }
     }
     return $newDocument;
 }
Example #4
0
 private function saveInvoiceRows(Document $invoice, array $data)
 {
     if (isset($data['names'])) {
         foreach ($data['names'] as $key => $value) {
             if ($data['rowIds'][$key] > 0) {
                 $row = $this->getRowById($data['rowIds'][$key]);
             } else {
                 $row = new Row();
             }
             if (!$row->getDocument()) {
                 $row->setDocument($invoice);
             }
             $row->setName($value);
             if (isset($data['articleIds'][$key])) {
                 $article = $this->articleService->getArticleById($data['articleIds'][$key]);
                 if ($article) {
                     $row->setArticle($article);
                 }
             }
             if (isset($data['uomIds'][$key])) {
                 $uom = $this->settingsService->getUomById($data['uomIds'][$key]);
                 if ($uom) {
                     $row->setUom($uom);
                 }
             }
             if (isset($data['vatIds'][$key])) {
                 $vat = $this->settingsService->getVatById($data['vatIds'][$key]);
                 if ($vat) {
                     $row->setVat($vat);
                 }
             }
             if (isset($data['quantities'][$key])) {
                 $row->setQuantity($data['quantities'][$key]);
             }
             if (isset($data['prices'][$key])) {
                 $row->setPrice($data['prices'][$key]);
             }
             if (isset($data['totals'][$key])) {
                 $row->setAmount($data['totals'][$key]);
             }
             if (isset($data['vatAmounts'][$key])) {
                 $row->setVatAmount($data['vatAmounts'][$key]);
             }
             if (isset($data['vatValues'][$key])) {
                 $row->setVatValue($data['vatValues'][$key]);
             }
             if (!$data['rowIds'][$key] > 0) {
                 $invoice->addRow($row);
             }
         }
     }
     return $this->saveInvoice($invoice);
 }