/**
  * 
  * @param int $folio
  * @param int $idEvent
  */
 private function getFolioInformation($folio)
 {
     $folioImport = FolioImportQuery::create()->whereAdd(FolioImport::FOLIO, $folio)->findOneOrThrow($this->i18n->_("Transit Document with folio {$folio} not found."));
     $programmedPayments = FolioImportProgrammedPaymentQuery::create()->whereAdd(FolioImportProgrammedPayment::FOLIO, $folioImport->getFolio())->find();
     $purchaseOrders = PurchaseOrderQuery::create()->whereAdd(PurchaseOrder::ID_PURCHASE_ORDER, $programmedPayments->getPurchaseOrderIds())->find();
     $purchaseOrderEntries = PurchaseOrderEntryQuery::create()->whereAdd(PurchaseOrderEntry::ID_PURCHASE_ORDER, $purchaseOrders->getPrimaryKeys())->find();
     $suppliers = SapSupplierQuery::create()->whereAdd(SapSupplier::CARDCODE, $purchaseOrders->getDistinctSuppliers())->find();
     $response = array("transitNumber" => $folioImport->getFolio(), "status" => $folioImport->getStatusName());
     while ($purchaseOrderEntries->valid()) {
         $purchaseOrderEntry = $purchaseOrderEntries->read();
         $purchaseOrder = $purchaseOrders->getByPK($purchaseOrderEntry->getIdPurchaseOrder());
         $supplier = $suppliers->getByPK($purchaseOrder->getIdSupplier());
         $response["entries"][] = array("PO" => $purchaseOrder->getIdPurchaseOrder(), "line" => $purchaseOrderEntry->getLine(), "product" => $purchaseOrderEntry->getIdProduct(), "price" => $purchaseOrderEntry->getPrice(), "currency" => $purchaseOrderEntry->getCurrency(), "supplier" => $supplier->getCardCode(), "supplierName" => $supplier->getCardname());
     }
     return $response;
 }
 /**
  *
  *
  * @author Erick Guevara Martínez
  * @param ProgrammedPaymentCollection $payments
  * @return CondensedProgrammedPaymentCollection
  */
 public function getCondensedProgrammedPayments(ProgrammedPaymentCollection $payments, $virtualPayments = true)
 {
     $this->setProformaInvoiceCollection();
     $this->setPurchaseOrderCollection();
     $condensedPayments = new CondensedProgrammedPaymentCollection();
     $proformaPaymentTerms = $this->getAvailablePaymentTerms($payments);
     $proformaProgrammedPayments = ProformaInvoiceProgrammedPaymentQuery::create()->whereAdd("ProformaInvoiceProgrammedPayment." . ProformaInvoiceProgrammedPayment::ID_PROFORMA_INVOICE_PAYMENT_TERM, $proformaPaymentTerms->getPrimaryKeys())->find();
     $condensedPayments = $condensedPayments->merge($this->condenseProformaPayments($proformaProgrammedPayments, $proformaPaymentTerms));
     $purchaseProgrammedPayments = PurchaseOrderProgrammedPaymentQuery::create()->whereAdd("PurchaseOrderProgrammedPayment." . PurchaseOrderProgrammedPayment::ID_PROFORMA_INVOICE_PAYMENT_TERM, $proformaPaymentTerms->getPrimaryKeys())->find();
     if ($virtualPayments) {
         $condensedPayments = $this->generateMissingProformaInvoiceProgrammedPayments($condensedPayments, $proformaProgrammedPayments, $purchaseProgrammedPayments);
     }
     $condensedPayments = $condensedPayments->merge($this->condensePurchasePayments($purchaseProgrammedPayments, $proformaPaymentTerms));
     if ($virtualPayments) {
         $condensedPayments = $this->generateMissingPurchaseOrderProgrammedPayments($condensedPayments, $purchaseProgrammedPayments, $proformaProgrammedPayments);
     }
     $folioProgrammedPayments = FolioImportProgrammedPaymentQuery::create()->whereAdd("FolioImportProgrammedPayment." . FolioImportProgrammedPayment::ID_PROGRAMMED_PAYMENT, $payments->getPrimaryKeys())->find();
     $condensedPayments = $condensedPayments->merge($this->condenseFolioPayments($folioProgrammedPayments));
     return $condensedPayments;
 }
Esempio n. 3
0
 /**
  *
  */
 public function programmedPaymentAction()
 {
     $landedCostCodes = LandedCostCodeQuery::create()->find();
     $products = ProductServiceQuery::create()->addColumn(Product::ITEM_CODE)->addColumn(Product::ITEM_NAME)->whereAdd(Product::ITEM_CODE, "TR%")->find();
     $warehouseEntry = WarehouseEntranceQuery::create()->whereAdd(WarehouseEntrance::ID_FOLIO_IMPORT, 102)->find();
     $id = $this->getRequest()->getParam('id');
     $onsubmit = $this->getBaseUrl() . '/' . $this->getRequest()->getParam('controller') . '/save-programmed-payment/id/' . $id;
     $columns = array(ProgrammedPayment::TABLENAME . '.' . ProgrammedPayment::AMMOUNT, ProgrammedPayment::TABLENAME . '.' . ProgrammedPayment::DUE_DATE, ProgrammedPayment::TABLENAME . '.' . ProgrammedPayment::ID_COMPANY, ProgrammedPayment::TABLENAME . '.' . ProgrammedPayment::ID_CURRENCY, ProgrammedPayment::TABLENAME . '.' . ProgrammedPayment::ID_PROGRAMMED_PAYMENT, FolioImportProgrammedPayment::TABLENAME . '.' . FolioImportProgrammedPayment::ID_FOLIO_IMPORT);
     $folioImportProgrammedPaymentsQuery = FolioImportProgrammedPaymentQuery::create()->whereAdd('FolioImportProgrammedPayment.' . FolioImportProgrammedPayment::ID_FOLIO_IMPORT, $id)->innerJoinProgrammedPayment()->find();
     if (!$folioImportProgrammedPaymentsQuery) {
         $folioImportProgrammedPayments = new FolioImportProgrammedPaymentCollection();
         $this->view->programmedPayments = $programmedPayments = $folioImportProgrammedPayments;
         $count = 0;
     } else {
         $this->view->programmedPayments = $programmedPayments = $folioImportProgrammedPaymentsQuery;
         $count = $folioImportProgrammedPaymentsQuery->count();
     }
     $concepts = ProductServiceQuery::create()->addColumn(Product::ITEM_CODE)->addColumn(Product::ITEM_NAME)->whereAdd(Product::ITEM_CODE, "TR%")->fetchPairs();
     $this->view->index = $count;
     $this->view->onsubmit = $onsubmit;
     $this->view->concepts = $concepts;
     //$landedCostCodes->toCombo($this->i18n->_('Select One'));
     $this->view->currencies = CurrencyQuery::create()->find()->toCombo('Currency');
     $this->view->idFolioImport = $id;
     $this->view->contentTitle = $this->i18n->_('Additional Payments');
     $this->view->statusPay = $status = ProgrammedPayment::$Status;
 }