コード例 #1
0
ファイル: PaymentListener.php プロジェクト: Eximagen/sochi
 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 CondensedProgrammedPaymentCollection $condensedPayments
  * @param ProformaInvoiceProgrammedPaymentCollection $proformaInvoiceProgrammedPayments
  * @param PurchaseOrderProgrammedPaymentCollection $purchaseOrderProgrammedPayments
  * @return CondensedProgrammedPaymentCollection
  */
 private function generateMissingProformaInvoiceProgrammedPayments(CondensedProgrammedPaymentCollection $condensedPayments, ProformaInvoiceProgrammedPaymentCollection $proformaInvoiceProgrammedPayments, PurchaseOrderProgrammedPaymentCollection $purchaseOrderProgrammedPayments)
 {
     $proformaInvoices = $this->getProformaInvoiceCollection();
     $proformaInvoicePaymentTerms = ProformaInvoicePaymentTermQuery::create()->whereAdd(ProformaInvoicePaymentTerm::ID_PROFORMA_INVOICE_PAYMENT, $proformaInvoiceProgrammedPayments->getProformaInvoicePaymentTermIds() + $purchaseOrderProgrammedPayments->getProformaInvoicePaymentTermIds(), ProformaInvoicePaymentTermQuery::NOT_IN)->actives()->whereAdd(ProformaInvoicePaymentTerm::ID_PROFORMA_INVOICE, $proformaInvoices->getPrimaryKeys());
     $proformaInvoicePaymentTerms = $proformaInvoicePaymentTerms->find();
     $proformaInvoiceMissingProgrammedPaymentCollection = new ProformaInvoiceProgrammedPaymentCollection();
     $i = 0;
     while ($proformaInvoicePaymentTerm = $proformaInvoicePaymentTerms->read()) {
         $proformaInvoice = $proformaInvoices->getByPK($proformaInvoicePaymentTerm->getIdProformaInvoice());
         $programmedPayment = ProgrammedPaymentFactory::createFromArray(array('id_programmed_payment' => 'VPP' . $proformaInvoicePaymentTerm->getIdProformaInvoicePayment(), 'id_currency' => $proformaInvoicePaymentTerm->getCurrency(), 'id_company' => $proformaInvoice->getIdSupplier(), 'type' => ProgrammedPayment::$TypePayment['ProformaInvoice'], 'ammount' => $proformaInvoicePaymentTerm->getPayment(), 'folio' => 'Not Available', 'due_date' => 'Not Available', 'status' => ProgrammedPayment::$TypeStatus['Virtual']));
         $this->getVirtualProgrammedPaymentCollection()->append($programmedPayment);
         $proformaInvoiceMissingProgrammedPayment = ProformaInvoiceProgrammedPaymentFactory::createFromArray(array('id_proforma_invoice_programmed_payment' => 'VPIPP' . $proformaInvoicePaymentTerm->getIdProformaInvoicePayment(), 'id_proforma_invoice_payment_term' => $proformaInvoicePaymentTerm->getIdProformaInvoicePayment(), 'id_programmed_payment' => $programmedPayment->getIdProgrammedPayment(), 'pieces' => $proformaInvoicePaymentTerm->getPieces(), 'id_proforma_invoice' => $proformaInvoicePaymentTerm->getIdProformaInvoice(), 'line' => $proformaInvoicePaymentTerm->getLine()) + $programmedPayment->toArray());
         $proformaInvoiceMissingProgrammedPayment->setIdProgrammedPayment($programmedPayment->getIdProgrammedPayment());
         $proformaInvoiceMissingProgrammedPaymentCollection->append($proformaInvoiceMissingProgrammedPayment);
         $i++;
     }
     $condensedPayments = $condensedPayments->merge($this->condenseProformaPayments($proformaInvoiceMissingProgrammedPaymentCollection, $proformaInvoicePaymentTerms));
     return $condensedPayments;
 }
コード例 #3
0
 /**
  *
  * @param int $idProformaInvoice
  * @param int $idEvent
  */
 private function getMissingProformaInformation($idProformaInvoice, $idEvent)
 {
     $event = EventQuery::create()->findByPKOrThrow($idEvent, $this->i18n->_("Event with id {$idEvent} not found."));
     $proformaInvoice = ProformaInvoiceQuery::create()->findByPKOrThrow($idProformaInvoice, $this->i18n->_("ProformaInvoice with id {$idProformaInvoice} not found."));
     $supplier = SapSupplierQuery::create()->findByPKOrThrow($proformaInvoice->getIdSupplier(), $this->i18n->_("SapSupplier with id {$proformaInvoice->getIdSupplier()} not found."));
     $proformaInvoiceEntries = ProformaInvoiceEntryQuery::create()->whereAdd(ProformaInvoiceEntry::ID_PROFORMA_INVOICE, $proformaInvoice->getIdProformaInvoice())->find();
     if (count($proformaInvoiceEntries->getDistinctRequisitionEntryIdsToArray()) > 0) {
         $requisitionEntries = RequisitionEntryQuery::create()->whereAdd(RequisitionEntry::ID_REQUISITION_ENTRY, $proformaInvoiceEntries->getDistinctRequisitionEntryIdsToArray())->find();
     }
     $paymentTerms = ProformaInvoicePaymentTermQuery::create()->whereAdd(ProformaInvoicePaymentTerm::ID_PROFORMA_INVOICE, $proformaInvoice->getIdProformaInvoice())->whereAdd(ProformaInvoicePaymentTerm::ID_EVENT, $event->getIdEvent())->find();
     $programmedPayments = new ProformaInvoiceProgrammedPaymentCollection();
     while ($paymentTerm = $paymentTerms->valid()) {
         $proformaInvoicePaymentTerm = $paymentTerms->read();
         $proformaInvoiceMissingProgrammedPayment = ProformaInvoiceProgrammedPaymentFactory::createFromArray(array('id_proforma_invoice_programmed_payment' => 'VPIPP' . $proformaInvoicePaymentTerm->getIdProformaInvoicePayment(), 'id_proforma_invoice_payment_term' => $proformaInvoicePaymentTerm->getIdProformaInvoicePayment(), 'pieces' => $proformaInvoicePaymentTerm->getPieces(), 'id_proforma_invoice' => $proformaInvoicePaymentTerm->getIdProformaInvoice(), 'line' => $proformaInvoicePaymentTerm->getLine(), 'id_programmed_payment' => 'VPP' . $proformaInvoicePaymentTerm->getIdProformaInvoicePayment(), 'id_currency' => $proformaInvoicePaymentTerm->getCurrency(), 'id_company' => $proformaInvoice->getIdSupplier(), 'type' => ProgrammedPayment::$TypePayment['ProformaInvoice'], 'ammount' => $proformaInvoicePaymentTerm->getPayment(), 'folio' => 'Not Available', 'due_date' => 'Not Available', 'status' => ProgrammedPayment::$TypeStatus['Virtual']));
         $programmedPayments->append($proformaInvoiceMissingProgrammedPayment);
     }
     $response = array("docNum" => $proformaInvoice->getSapDocumentNumber(), "docEntry" => $proformaInvoice->getIdProformaInvoice(), "createDate" => $proformaInvoice->getDocDate(), "supplier" => $supplier->getCardCode(), "supplierName" => $supplier->getCardname(), "event" => $event->getName());
     while ($proformaInvoiceEntries->valid()) {
         $proformaInvoiceEntry = $proformaInvoiceEntries->read();
         $paymentTerm = $paymentTerms->filterByProformaInvoiceEntry($proformaInvoiceEntry)->getOne();
         $programmedPayment = $programmedPayments->filterByPaymentTerm($paymentTerm)->getOne();
         $entryIds = $proformaInvoiceEntry->getRequisitionIdsToArray();
         if (count($entryIds) > 0) {
             $entries = $requisitionEntries->filter(function (RequisitionEntry $entry) use($entryIds) {
                 return in_array($entry->getIdRequisitionEntry(), $entryIds);
             });
         } else {
             $entries = new RequisitionEntryCollection();
         }
         $response["entries"][] = array("line" => $proformaInvoiceEntry->getLine(), "product" => $proformaInvoiceEntry->getIdProduct(), "quantity" => $proformaInvoiceEntry->getQuantity(), "price" => $proformaInvoiceEntry->getPrice(), "currency" => $proformaInvoiceEntry->getCurrency(), "requisitions" => $entries->isEmpty() ? "-" : implode($entries->getDistinctRequisitions()), "ammount" => $programmedPayment->getAmmount(), "credits" => 0, "pendingBalance" => $programmedPayment->getAmmount());
     }
     return $response;
 }
コード例 #4
0
 /**
  *
  * makeBean
  * @param array $resultset
  * @return \Application\Model\Bean\ProformaInvoiceProgrammedPayment
  */
 protected function makeBean($resultset)
 {
     return ProformaInvoiceProgrammedPaymentFactory::createFromArray($resultset);
 }