Example #1
0
 public function load()
 {
     $this->initErrorMessages();
     $this->initSuccessMessages();
     $partnerId = intval(NGS()->args()->id);
     $partner = PartnerManager::getInstance()->getPartnerFull($partnerId);
     if ($partner) {
         $this->addParam('partner', $partner);
         $partnerSaleOrders = SaleOrderManager::getInstance()->getPartnerSaleOrders($partnerId);
         $partnerPurchaseOrders = PurchaseOrderManager::getInstance()->getPartnerPurchaseOrders($partnerId);
         $partnerPaymentTransactions = PaymentTransactionManager::getInstance()->getPartnerPaymentTransactions($partnerId);
         $partnerBillingTransactions = PaymentTransactionManager::getInstance()->getPartnerBillingTransactions($partnerId);
         $partnerInitialDept = PartnerInitialDeptManager::getInstance()->getPartnerInitialDept($partnerId);
         $this->addParam('partnerSaleOrders', $partnerSaleOrders);
         $this->addParam('partnerPurchaseOrders', $partnerPurchaseOrders);
         $this->addParam('partnerPaymentTransactions', $partnerPaymentTransactions);
         $this->addParam('partnerBillingTransactions', $partnerBillingTransactions);
         $dept = CalculationManager::getInstance()->calculatePartnerDeptBySalePurchaseAndPaymentTransations($partnerSaleOrders, $partnerPurchaseOrders, $partnerPaymentTransactions, $partnerBillingTransactions, $partnerInitialDept);
         $this->addParam('partnerDept', $dept);
         $currencyManager = CurrencyManager::getInstance();
         $this->addParam('currencies', $currencyManager->mapDtosById($currencyManager->selectAdvance('*', ['active', '=', 1], ['name'])));
     }
 }
Example #2
0
 public function load()
 {
     $this->initErrorMessages();
     $this->initSuccessMessages();
     $limit = 100;
     list($offset, $sortByFieldName, $selectedFilterSortByAscDesc) = $this->initFilters($limit);
     $partnerManager = PartnerManager::getInstance();
     $partners = $partnerManager->selectAdvance('*', [], $sortByFieldName, $selectedFilterSortByAscDesc, $offset, $limit);
     $partnerIds = $partnerManager->getDtosIdsArray($partners);
     $partnersSaleOrdersMappedByPartnerId = [];
     $partnersPurchaseOrdersMappedByPartnerId = [];
     $partnersTransactionsMappedByPartnerId = [];
     $partnersInitialDept = [];
     if (!empty($partnerIds)) {
         $partnersSaleOrdersMappedByPartnerId = SaleOrderManager::getInstance()->getPartnersSaleOrders($partnerIds);
         $partnersPurchaseOrdersMappedByPartnerId = PurchaseOrderManager::getInstance()->getPartnersPurchaseOrders($partnerIds);
         $partnersPaymentTransactionsMappedByPartnerId = PaymentTransactionManager::getInstance()->getPartnersPaymentTransactions($partnerIds);
         $partnersBillingTransactionsMappedByPartnerId = PaymentTransactionManager::getInstance()->getPartnersBillingTransactions($partnerIds);
         $partnersInitialDept = PartnerInitialDeptManager::getInstance()->getPartnersInitialDept($partnerIds);
     }
     $partnersDept = CalculationManager::getInstance()->calculatePartnersDeptBySalePurchaseAndPaymentTransations($partnersSaleOrdersMappedByPartnerId, $partnersPurchaseOrdersMappedByPartnerId, $partnersPaymentTransactionsMappedByPartnerId, $partnersBillingTransactionsMappedByPartnerId, $partnersInitialDept);
     $this->addParam('partnersSaleOrdersMappedByPartnerId', $partnersSaleOrdersMappedByPartnerId);
     $this->addParam('partnersPurchaseOrdersMappedByPartnerId', $partnersPurchaseOrdersMappedByPartnerId);
     $this->addParam('partnersPaymentTransactionsMappedByPartnerId', $partnersPaymentTransactionsMappedByPartnerId);
     $this->addParam('partnersBillingTransactionsMappedByPartnerId', $partnersBillingTransactionsMappedByPartnerId);
     $this->addParam('partnersDept', $partnersDept);
     $this->addParam('partners', $partners);
     $count = PartnerManager::getInstance()->getLastSelectAdvanceRowsCount();
     if (count($partners) == 0 && $count > 0) {
         $this->redirectIncludedParamsExeptPaging();
     }
     $pagesCount = ceil($count / $limit);
     $this->addParam('pagesCount', $pagesCount);
     $currencyManager = CurrencyManager::getInstance();
     $this->addParam('currencies', $currencyManager->mapDtosById($currencyManager->selectAdvance('*', ['active', '=', 1], ['name'])));
 }
Example #3
0
 public function calculatePartnerDeptBySalePurchaseAndPaymentTransations($id)
 {
     $partnerSaleOrders = SaleOrderManager::getInstance()->getPartnerSaleOrders($id);
     $partnerPurchaseOrders = PurchaseOrderManager::getInstance()->getPartnerPurchaseOrders($id);
     $partnerPaymentTransactions = PaymentTransactionManager::getInstance()->getPartnerPaymentTransactions($id);
     $partnerBillingTransactions = PaymentTransactionManager::getInstance()->getPartnerBillingTransactions($id);
     $partnerInitialDept = PartnerInitialDeptManager::getInstance()->getPartnerInitialDept($id);
     return CalculationManager::getInstance()->calculatePartnerDeptBySalePurchaseAndPaymentTransations($partnerSaleOrders, $partnerPurchaseOrders, $partnerPaymentTransactions, $partnerBillingTransactions, $partnerInitialDept);
 }