예제 #1
0
 public function createPaymentFromProformaInvoice(ProformaInvoiceEvent $event, $type)
 {
     $proformaInvoiceEntries = $event->getProformaInvoiceEntries();
     $proformaInvoice = $event->getProformaInvoice();
     $payments = ProformaInvoicePaymentTermQuery::create()->whereAdd(ProformaInvoicePaymentTerm::ID_EVENT, $type)->whereAdd(ProformaInvoicePaymentTerm::ID_PROFORMA_INVOICE_ENTRY, $proformaInvoiceEntries->getPrimaryKeys())->find();
     if (!$payments->isEmpty()) {
         try {
             $this->getProformaInvoiceProgrammedPaymentCatalog()->beginTransaction();
             while ($paymentEvent = $payments->read()) {
                 $proformaInvoiceProgrammendPayment = ProformaInvoiceProgrammedPaymentFactory::createFromArray(array(ProformaInvoiceProgrammedPayment::ID_PROFORMA_INVOICE_PAYMENT_TERM => $paymentEvent->getIdProformaInvoicePayment(), ProformaInvoiceProgrammedPayment::AMMOUNT => $paymentEvent->getPayment(), ProformaInvoiceProgrammedPayment::PIECES => $paymentEvent->getPieces(), ProformaInvoiceProgrammedPayment::ID_CURRENCY => $paymentEvent->getCurrency(), ProformaInvoiceProgrammedPayment::ID_PROFORMA_INVOICE => $paymentEvent->getIdProformaInvoice(), ProformaInvoiceProgrammedPayment::ID_PROFORMA_INVOICE_ENTRY => $paymentEvent->getIdProformaInvoiceEntry(), ProformaInvoiceProgrammedPayment::LINE => $paymentEvent->getLine(), ProformaInvoiceProgrammedPayment::TYPE => ProgrammedPayment::$TypePayment['ProformaInvoice'], ProformaInvoiceProgrammedPayment::ID_COMPANY => $proformaInvoice->getIdSupplier(), ProformaInvoiceProgrammedPayment::DUE_DATE => \Zend_Date::now()->addDay(15)->get("YYYY-MM-dd"), ProformaInvoiceProgrammedPayment::STATUS => ProgrammedPayment::$TypeStatus['Pending'], ProformaInvoiceProgrammedPayment::FOLIO => $proformaInvoice->getFolio()));
                 $this->getProformaInvoiceProgrammedPaymentCatalog()->create($proformaInvoiceProgrammendPayment);
             }
             $this->getProformaInvoiceProgrammedPaymentCatalog()->commit();
         } catch (Exception $e) {
             $this->getProformaInvoiceProgrammedPaymentCatalog()->rollBack();
             $this->setFlash('error', $this->i18n->_($e->getMessage()));
         }
     }
 }
예제 #2
0
 /**
  * 
  * @param ProformaInvoiceEvent $proformaInvoiceEvent
  */
 public function createProformaInvoiceProductionEndNotification(ProformaInvoiceEvent $proformaInvoiceEvent)
 {
     $proformaInvoice = $proformaInvoiceEvent->getProformaInvoice();
     $proformaInvoiceEntries = $proformaInvoiceEvent->getProformaInvoiceEntries();
     $products = ProductQuery::create()->whereAdd(Product::ITEM_CODE, $proformaInvoiceEntries->getIdProducts(), ProductQuery::IN)->find();
     $vars = array('subject' => 'A Proforma Invoice Entry has finished its production', 'proforma_invoice' => $proformaInvoice->toArray());
     $i = 0;
     $entries = array();
     while ($proformaInvoiceEntry = $proformaInvoiceEntries->read()) {
         $entries[$i] = $proformaInvoiceEntry->toArray();
         $entries[$i]['product'] = $products->getByPK($proformaInvoiceEntry->getIdProduct())->toArray();
         $i++;
     }
     $vars['proforma_invoice_entries'] = $entries;
     $this->createNotification(NotificationType::$id['PROFORMA_INVOICE_END_PRODUCTION'], $vars);
 }