public function setVatValues(Vat $vat = null) { if ($vat) { $this->get('code')->setValue($vat->getCode()); $this->get('comment')->setValue($vat->getComment()); $this->get('value')->setValue($vat->getValue()); } }
public function saveVatWithParams(Vat $vat = null, User $user, array $data) { if (!$vat) { $vat = new Vat(); $vat->setUser($user); } if (isset($data['code'])) { $vat->setCode($data['code']); } if (isset($data['value'])) { $vat->setValue($data['value']); } if (isset($data['comment'])) { $vat->setComment($data['comment']); } return $this->saveVat($vat); }
public function saveRow(Document\Row $row = null, Document $document, Parameters $parameters) { if ($row == null) { $row = new Document\Row(); } if (!$row->getDocument()) { $row->setDocument($document); } if (isset($parameters->description) && $parameters->description != null) { $row->setDescription($parameters->description); } if (isset($parameters->code)) { if ($parameters->code != null) { $row->setCode($parameters->code); } else { $row->setCode(null); } } if (isset($parameters->uomId)) { $uom = $this->getOneObjectByField(Uom::getClass(), 'id', $parameters->uomId); $row->setUom($uom ? $uom : null); } if (isset($parameters->articleId)) { $article = $this->getOneObjectByField(Article::getClass(), 'id', $parameters->articleId); $row->setArticle($article ? $article : null); } if (isset($parameters->warehouse)) { $warehouse = $this->getOneObjectByField(Warehouse::getClass(), 'id', $parameters->warehouse); $row->setWarehouse($warehouse ? $warehouse : null); } if (isset($parameters->vatId)) { $vat = $this->getOneObjectByField(Vat::getClass(), 'id', $parameters->vatId); $row->setVat($vat ? $vat : null); } if (isset($parameters->quantity)) { $row->setQuantity($parameters->quantity); } if (isset($parameters->price) && $parameters->price != null) { $row->setPrice($parameters->price); } if (isset($parameters->quantity) && isset($parameters->price)) { $row->setAmount($parameters->quantity * $parameters->price); } if (isset($parameters->name) && $parameters->name != null) { $row->setName($parameters->name); } if ($document->getRows() && !$document->getRows()->contains($row)) { $document->addRow($row); } $this->entityManager->persist($row); $this->entityManager->flush($row); return $row; }