public function jsonGetVatAction() { if ($this->request->isPost() && $this->request->isXmlHttpRequest()) { $vat = $this->settingsService->getVatById($this->request->getPost()->vatId); if ($vat) { /* @var $vat \Application\Entity\Vat */ $result = array('value' => $vat->getValue(), 'code' => $vat->getCode(), 'comment' => $vat->getComment()); return new JsonModel($result); } } return $this->response; }
public function assembleInvoiceRowsArrayFromPost(array $data) { $invoiceRows = array(); foreach ($data['names'] as $key => $value) { $vat = $this->settingsService->getVatById($data['vatIds'][$key]); $uom = $this->settingsService->getUomById($data['uomIds'][$key]); $article = $this->articleService->getArticleById($data['articleIds'][$key]); $rowArray = array('rowId' => $data['rowIds'][$key], 'description' => $data['rowIds'][$key], 'name' => $value, 'price' => $data['prices'][$key], 'quantity' => $data['quantities'][$key], 'selectedVat' => $vat, 'selectedArticle' => $article, 'selectedUom' => $uom, 'total' => $data['totals'][$key], 'vatAmount' => $data['vatAmounts'][$key], 'vatValue' => $data['vatValues'][$key]); $invoiceRows[] = $rowArray; } return $invoiceRows; }
public function addRowAction() { if ($this->request->isPost() && $this->request->isXmlHttpRequest()) { $view = new ViewModel(); $view->setTerminal(true); $view->id = $this->request->getPost()->index + 1; $vat = $this->settingsService->getVatById($this->request->getPost()->vatId); if ($vat) { $view->selectedVat = $vat; $view->vatValue = $vat->getValue(); } return $this->addInvoiceRowToView($view); } return $this->response; }