Example #1
0
 /**
  * @ORM\PrePersist
  * @ORM\PreUpdate
  */
 public function preSave(LifecycleEventArgs $args)
 {
     $this->checkAmounts();
     parent::presave($args);
     $this->checkNumber($args);
 }
Example #2
0
 /**
  * @ORM\PrePersist
  * @ORM\PreUpdate
  */
 public function preSave(LifecycleEventArgs $args)
 {
     $this->checkAmounts();
     parent::presave($args);
     $this->checkMustOccurrences();
 }
 protected function addItemsAndTaxes(AbstractInvoice $invoice, array $row, \PDO $dbh)
 {
     $itemsSth = $dbh->prepare('SELECT * FROM item WHERE common_id=:id');
     $itemsSth->bindValue(':id', $row['id']);
     $itemsSth->execute();
     foreach ($itemsSth->fetchAll(\PDO::FETCH_ASSOC) as $itemRow) {
         $item = new Item();
         $item->setDescription($itemRow['description']);
         $item->setUnitaryCost($itemRow['unitary_cost']);
         $item->setQuantity($itemRow['quantity']);
         $item->setDiscount($itemRow['discount']);
         if ($itemRow['product_id']) {
             $item->setProduct($this->mapping['products'][$itemRow['product_id']]);
         }
         $itemTaxesSth = $dbh->prepare('SELECT * FROM item_tax WHERE item_id=:id');
         $itemTaxesSth->bindValue(':id', $itemRow['id']);
         $itemTaxesSth->execute();
         foreach ($itemTaxesSth->fetchAll(\PDO::FETCH_ASSOC) as $itemTaxRow) {
             $item->addTax($this->mapping['taxes'][$itemTaxRow['tax_id']]);
         }
         $invoice->addItem($item);
     }
 }