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;
 }
Exemple #2
0
 public function setUomValues(Uom $uom = null)
 {
     if ($uom) {
         $this->get('code')->setValue($uom->getCode());
     }
 }
 public function saveUomWithParams(Uom $uom = null, User $user, array $data)
 {
     if (!$uom) {
         $uom = new Uom();
         $uom->setUser($user);
     }
     if (isset($data['code'])) {
         $uom->setCode($data['code']);
     }
     return $this->saveUom($uom);
 }