示例#1
0
 protected function genericPurchaseOrderNotification(PurchaseOrderEvent $event, $notificationTypeId)
 {
     $purchaseOrder = $event->getPurchaseOrder();
     $purchaseOrderEntries = PurchaseOrderEntryQuery::create()->whereAdd(PurchaseOrderEntry::ID_PURCHASE_ORDER, $purchaseOrder->getIdPurchaseOrder(), BaseQuery::EQUAL)->find();
     $products = array();
     if ($purchaseOrderEntries->count() > 0) {
         $products = ProductQuery::create()->whereAdd(Product::ITEM_CODE, $purchaseOrderEntries->getProducts(), BaseQuery::IN)->find()->toArray();
     }
     $vars = array('id_purchase_order' => $purchaseOrder->getIdPurchaseOrder(), 'reference' => $purchaseOrder->getReference(), 'created_on' => $purchaseOrder->getPurchaseOrderDateAsZendDate()->get("dd-MM-yyyy HH:mm"), 'total_products' => count($products), 'products' => $products);
     $this->createNotification($notificationTypeId, $vars);
 }
示例#2
0
 public function createGenericPayment(PurchaseOrderEvent $event, $type)
 {
     $purchaseOrder = $event->getPurchaseOrder();
     //TODO: agregar arreglo de eventos a PurchaseOrderPaymentTerm
     $paymentTerms = PurchaseOrderPaymentTermQuery::create()->whereAdd(PurchaseOrderPaymentTerm::ID_EVENT, $type)->whereAdd(PurchaseOrderPaymentTerm::ID_PURCHASE_ORDER, $purchaseOrder->getIdPurchaseOrder())->find();
     try {
         $this->getPurchaseOrderProgrammedPaymentCatalog()->beginTransaction();
         while ($paymentTerms->valid()) {
             $paymentTerm = $paymentTerms->read();
             if (PurchaseOrderProgrammedPaymentQuery::create()->whereAdd(PurchaseOrderProgrammedPayment::ID_PURCHASE_ORDER_PAYMENT_TERM, $paymentTerm->getIdPurchaseOrderPaymentTerm())->find()->count() > 0) {
                 continue;
             }
             $payment = new PurchaseOrderProgrammedPayment();
             $payment->setIdPurchaseOrderPaymentTerm($paymentTerm->getIdPurchaseOrderPaymentTerm());
             $payment->setAmmount($paymentTerm->getAmount());
             $payment->setDueDate(\Zend_Date::now()->addDay(15)->get("YYYY-MM-dd"));
             //TODO: dias del cat�logo
             $payment->setIdCompany(SupplierQuery::create()->findByPK($purchaseOrder->getIdSupplier())->getIdCompany());
             $payment->setIdCurrency($purchaseOrder->getIdCurrency());
             $payment->setIdPurchaseOrder($purchaseOrder->getIdPurchaseOrder());
             $payment->setStatus(PurchaseOrderProgrammedPayment::$TypeStatus['Pending']);
             $payment->setType(PurchaseOrderProgrammedPayment::$TypePayment['PurchaseOrder']);
             $this->getPurchaseOrderProgrammedPaymentCatalog()->create($payment);
         }
         $this->getPurchaseOrderProgrammedPaymentCatalog()->commit();
     } catch (Exception $e) {
         $this->getPurchaseOrderProgrammedPaymentCatalog()->rollBack();
         throw $e;
     }
 }