Example #1
0
 public function load()
 {
     $this->initErrorMessages();
     $this->initSuccessMessages();
     $partnerId = intval(NGS()->args()->id);
     $partner = PartnerManager::getInstance()->selectbyPK($partnerId);
     if ($partner) {
         $this->addParam('currencies', CurrencyManager::getInstance()->selectAdvance('*', ['active', '=', 1], null, null, null, null, true));
         $this->addParam('partner', $partner);
         $partnerSaleOrders = SaleOrderManager::mapDtosById(SaleOrderManager::getInstance()->getPartnerSaleOrders($partnerId));
         $partnerPurchaseOrders = PurchaseOrderManager::mapDtosById(PurchaseOrderManager::getInstance()->getPartnerPurchaseOrders($partnerId));
         $partnerPaymentTransactions = PaymentTransactionManager::mapDtosById(PaymentTransactionManager::getInstance()->getPartnerPaymentTransactions($partnerId));
         $partnerBillingTransactions = PaymentTransactionManager::mapDtosById(PaymentTransactionManager::getInstance()->getPartnerBillingTransactions($partnerId));
         $sales = $this->mapByIdAndGivenField('sale_', 'order_date', $partnerSaleOrders);
         $purchases = $this->mapByIdAndGivenField('purchase_', 'order_date', $partnerPurchaseOrders);
         $paments = $this->mapByIdAndGivenField('payment_', 'date', $partnerPaymentTransactions);
         $billings = $this->mapByIdAndGivenField('billing_', 'date', $partnerBillingTransactions);
         $allDeals = $this->mergeAllDeals($sales, $purchases, $paments, $billings, $partnerSaleOrders, $partnerPurchaseOrders, $partnerPaymentTransactions, $partnerBillingTransactions);
         $this->addParam('allDeals', $allDeals);
         $this->addParam('partnerSaleOrders', $partnerSaleOrders);
         $this->addParam('partnerPurchaseOrders', $partnerPurchaseOrders);
         $this->addParam('partnerPaymentTransactions', $partnerPaymentTransactions);
         $this->addParam('partnerBillingTransactions', $partnerBillingTransactions);
     }
 }
Example #2
0
 public function load()
 {
     $this->initErrorMessages();
     $this->initSuccessMessages();
     $this->addParam('req', isset($_SESSION['action_request']) ? $_SESSION['action_request'] : []);
     unset($_SESSION['action_request']);
     $this->addParam('payment_methods', PaymentMethodManager::getInstance()->selectAdvance('*', ['active', '=', 1], ['name']));
     $this->addParam('partners', PartnerManager::getInstance()->selectAdvance('*', [], ['name']));
     $this->addParam('defaultPaymentMethodId', SettingManager::getInstance()->getSetting('default_payment_method_id'));
 }
Example #3
0
 public function service()
 {
     $startDate = NGS()->args()->startDate;
     $endDate = NGS()->args()->endDate;
     $partnerId = intval(NGS()->args()->partner_id);
     $where = ['cancelled', '=', 0, 'and', 'order_date', '>=', "'{$startDate}'", 'and', 'order_date', '<=', "'{$endDate} 23:59:59'"];
     $partnerDto = null;
     if ($partnerId > 0) {
         $partnerDto = \crm\managers\PartnerManager::getInstance()->selectByPK($partnerId);
         $where = array_merge($where, ['and', 'partner_id', '=', $partnerId]);
     }
     $rows = \crm\managers\SaleOrderManager::getInstance()->getSaleOrdersFull($where, 'order_date', "DESC");
     $this->exportCsv($rows, $startDate, $endDate, $partnerDto);
 }
 private function validateFormData()
 {
     if (empty(NGS()->args()->name)) {
         throw new RedirectException('partner/create', "Partner Name can not be empty.");
     }
     if (!filter_var(NGS()->args()->email, FILTER_VALIDATE_EMAIL)) {
         throw new RedirectException('partner/create', "Invalid email address.");
     }
     $email = NGS()->args()->email;
     $partnerDtos = PartnerManager::getInstance()->selectByField('email', $email);
     if (!empty($partnerDtos)) {
         throw new RedirectException('partner/create', "Partner already exists with given email address");
     }
 }
 public function getPurchaseOrdersFull($where = [], $orderByFieldsArray = null, $orderByAscDesc = "ASC", $offset = null, $limit = null)
 {
     $opDtos = $this->selectAdvance('*', $where, $orderByFieldsArray, $orderByAscDesc, $offset, $limit);
     $partnerIds = array();
     $purchaseOrderIds = array();
     foreach ($opDtos as $poDto) {
         $partnerIds[] = intval($poDto->getPartnerId());
         $purchaseOrderIds[] = intval($poDto->getId());
     }
     $partnerIds = array_unique($partnerIds);
     $purchaseOrderIds = array_unique($purchaseOrderIds);
     $partnerDtos = PartnerManager::getInstance()->selectByPKs($partnerIds, true);
     $purchaseOrderLinesDtos = [];
     if (!empty($purchaseOrderIds)) {
         $purchaseOrderLinesDtos = PurchaseOrderLineManager::getInstance()->getPurchaseOrderLinesFull(['purchase_order_id', 'in', '(' . implode(',', $purchaseOrderIds) . ')']);
         $amount = [];
         foreach ($purchaseOrderLinesDtos as $purchaseOrderLine) {
             $purchaseOrderId = intval($purchaseOrderLine->getPurchaseOrderId());
             $currencyId = intval($purchaseOrderLine->getCurrencyId());
             $unitPrice = floatval($purchaseOrderLine->getUnitPrice());
             $quantity = floatval($purchaseOrderLine->getQuantity());
             if (!array_key_exists($purchaseOrderId, $amount)) {
                 $amount[$purchaseOrderId] = [];
             }
             if (!array_key_exists($currencyId, $amount[$purchaseOrderId])) {
                 $amount[$purchaseOrderId][$currencyId] = 0;
             }
             $amount[$purchaseOrderId][$currencyId] += $unitPrice * $quantity;
         }
     }
     if (!empty($purchaseOrderIds)) {
         $purchaseOrderLinesDtosMappedByPurchaseOrderId = $this->mapPurchaseOrderLinesByPurchaseOrderId($purchaseOrderLinesDtos);
         foreach ($purchaseOrderIds as $purchaseOrderId) {
             if (!array_key_exists($purchaseOrderId, $purchaseOrderLinesDtosMappedByPurchaseOrderId)) {
                 $purchaseOrderLinesDtosMappedByPurchaseOrderId[$purchaseOrderId] = [];
             }
             if (!array_key_exists($purchaseOrderId, $amount)) {
                 $amount[$purchaseOrderId] = [];
             }
         }
     }
     foreach ($opDtos as $poDto) {
         $purchaseOrderId = intval($poDto->getId());
         $poDto->setPartnerDto($partnerDtos[intval($poDto->getPartnerId())]);
         $poDto->setPurchaseOrderLinesDtos($purchaseOrderLinesDtosMappedByPurchaseOrderId[$purchaseOrderId]);
         $poDto->setTotalAmount($amount[$purchaseOrderId]);
     }
     return $opDtos;
 }
Example #6
0
 public function load()
 {
     $this->initErrorMessages();
     $this->initSuccessMessages();
     $limit = 100;
     list($where, $offset, $sortByFieldName, $selectedFilterSortByAscDesc) = $this->initFilters($limit);
     $billing = PaymentTransactionManager::getInstance()->getPaymentListFull($where, $sortByFieldName, $selectedFilterSortByAscDesc, $offset, $limit);
     $this->addParam('billings', $billing);
     $count = PaymentTransactionManager::getInstance()->getLastSelectAdvanceRowsCount();
     if (count($billing) == 0 && $count > 0) {
         $this->redirectIncludedParamsExeptPaging();
     }
     $pagesCount = ceil($count / $limit);
     $this->addParam('pagesCount', $pagesCount);
     $this->addParam('partners', PartnerManager::getInstance()->selectAdvance('*', [], ['name']));
     $this->addParam('currencies', CurrencyManager::getInstance()->selectAdvance('*', ['active', '=', 1], ['name']));
 }
 public function service()
 {
     if (!isset(NGS()->args()->partner_id)) {
         new NgsErrorException('Missing Partner ID!');
     }
     $partner_id = intval(NGS()->args()->partner_id);
     $partnerDto = PartnerManager::getInstance()->selectByPK($partner_id);
     if (!isset($partnerDto)) {
         new NgsErrorException('Partner does not exist with given ID: ' . NGS()->args()->partner_id);
     }
     $dept = PartnerManager::getInstance()->calculatePartnerDeptBySalePurchaseAndPaymentTransations($partner_id);
     $currenciesMappedById = CurrencyManager::getInstance()->selectAdvance('*', ['active', '=', 1], null, null, null, null, true);
     foreach ($dept as $currencyId => $amount) {
         $currencyDto = $currenciesMappedById[$currencyId];
         $this->addParam($currencyDto->getIso(), [$amount, $currencyDto->getTemplateChar(), $currencyDto->getSymbolPosition()]);
     }
 }
Example #8
0
 public function load()
 {
     $this->initErrorMessages();
     $this->initSuccessMessages();
     $id = intval(NGS()->args()->id);
     $partners = PartnerManager::getInstance()->getPartnersFull(['id', '=', $id]);
     if (!empty($partners)) {
         $this->addParam('currencies', CurrencyManager::getInstance()->selectAdvance('*', ['active', '=', 1], ['name']));
         $partner = $partners[0];
         if (!isset($_SESSION['action_request'])) {
             $_SESSION['action_request'] = ['name' => $partner->getName(), 'email' => $partner->getEmail(), 'address' => $partner->getAddress(), 'phone' => $partner->getPhone(), 'initial_dept' => $partner->getPartnerInitialDeptDtos()];
         }
         $this->addParam("partner", $partner);
         $this->addParam('req', $_SESSION['action_request']);
         unset($_SESSION['action_request']);
     }
 }
 public function service()
 {
     if (isset(NGS()->args()->id)) {
         $partnerId = NGS()->args()->id;
     } else {
         $_SESSION['error_message'] = 'Partner ID is missing';
         $this->redirect('partner/list');
     }
     $partnerManager = PartnerManager::getInstance();
     $partnerDto = $partnerManager->selectByPK($partnerId);
     if (!isset($partnerDto)) {
         $_SESSION['error_message'] = 'Partner with ID ' . NGS()->args()->id . ' does not exists.';
         $this->redirect('partner/list');
     }
     $partnerManager->deletePartnerFull($partnerId);
     $_SESSION['success_message'] = 'Partner Successfully deleted!';
     $this->redirect('partner/list');
 }
Example #10
0
 public function load()
 {
     $this->initErrorMessages();
     $this->initSuccessMessages();
     $id = intval(NGS()->args()->id);
     $purchaseOrder = PurchaseOrderManager::getInstance()->selectByPK($id);
     if ($purchaseOrder) {
         if (!isset($_SESSION['action_request'])) {
             $_SESSION['action_request'] = ['order_date' => $this->cutSecondsFromDateTime($purchaseOrder->getOrderDate()), 'payment_deadline' => $purchaseOrder->getPaymentDeadline(), 'partnerId' => $purchaseOrder->getPartnerId(), 'note' => $purchaseOrder->getNote()];
         }
         $this->addParam("purchaseOrder", $purchaseOrder);
         $this->addParam('req', $_SESSION['action_request']);
         unset($_SESSION['action_request']);
         $this->addParam('payment_methods', PaymentMethodManager::getInstance()->selectAdvance('*', ['active', '=', 1], ['name']));
         $this->addParam('partners', PartnerManager::getInstance()->selectAdvance('*', [], ['name']));
         $this->addParam('defaultPaymentMethodId', SettingManager::getInstance()->getSetting('default_payment_method_id'));
     }
 }
Example #11
0
 public function deletePartnerFull($partnerId)
 {
     $saleOrderDtosMappedById = SaleOrderManager::getInstance()->selectAdvance('id', ['partner_id', '=', $partnerId], null, null, null, null, true);
     $purchaseOrderDtosMappedById = PurchaseOrderManager::getInstance()->selectAdvance('id', ['partner_id', '=', $partnerId], null, null, null, null, true);
     if (!empty($saleOrderDtosMappedById)) {
         $sqlSaleOrderIds = '(' . implode(',', array_keys($saleOrderDtosMappedById)) . ')';
         SaleOrderLineManager::getInstance()->deleteAdvance(['sale_order_id', 'in', $sqlSaleOrderIds]);
     }
     if (!empty($purchaseOrderDtosMappedById)) {
         $sqlPurchaseOrderIds = '(' . implode(',', array_keys($purchaseOrderDtosMappedById)) . ')';
         PurchaseOrderLineManager::getInstance()->deleteAdvance(['purchase_order_id', 'in', $sqlPurchaseOrderIds]);
     }
     SaleOrderManager::getInstance()->deleteByField('partner_id', $partnerId);
     PurchaseOrderManager::getInstance()->deleteByField('partner_id', $partnerId);
     PaymentTransactionManager::getInstance()->deleteByField('partner_id', $partnerId);
     PartnerManager::getInstance()->deleteByPK($partnerId);
     return true;
 }
Example #12
0
 public function load()
 {
     $this->initErrorMessages();
     $this->initSuccessMessages();
     $id = intval(NGS()->args()->id);
     $paymentOrder = PaymentTransactionManager::getInstance()->selectByPK($id);
     if ($paymentOrder) {
         if (!isset($_SESSION['action_request'])) {
             $_SESSION['action_request'] = ['date' => $this->cutSecondsFromDateTime($paymentOrder->getDate()), 'partnerId' => $paymentOrder->getPartnerId(), 'billingMethodId' => $paymentOrder->getPaymentMethodId(), 'currencyId' => $paymentOrder->getCurrencyId(), 'note' => $paymentOrder->getNote(), 'signature' => $paymentOrder->getSignature(), 'amount' => $paymentOrder->getAmount(), 'isExpense' => $paymentOrder->getIsExpense(), 'paid' => $paymentOrder->getPaid()];
         }
         $this->addParam("paymentOrder", $paymentOrder);
         $this->addParam('req', $_SESSION['action_request']);
         unset($_SESSION['action_request']);
         $this->addParam('payment_methods', PaymentMethodManager::getInstance()->selectAdvance('*', ['active', '=', 1], ['name']));
         $this->addParam('currencies', CurrencyManager::getInstance()->selectAdvance('*', ['active', '=', 1], ['name']));
         $this->addParam('partners', PartnerManager::getInstance()->selectAdvance('*', [], ['name']));
         $this->addParam('defaultCurrencyId', SettingManager::getInstance()->getSetting('default_currency_id'));
         $this->addParam('defaultPaymentMethodId', SettingManager::getInstance()->getSetting('default_payment_method_id'));
     }
 }
Example #13
0
 public function load()
 {
     $this->initErrorMessages();
     $this->initSuccessMessages();
     $this->addParam('payment_methods', PaymentMethodManager::getInstance()->selectAdvance('*', ['active', '=', 1], ['name']));
     $this->addParam('partners', PartnerManager::getInstance()->selectAdvance('*', [], ['name']));
     $this->addParam('products', ProductManager::getInstance()->selectAdvance('*', [], ['name']));
     $limit = 100;
     list($where, $offset, $sortByFieldName, $selectedFilterSortByAscDesc) = $this->initFilters($limit);
     $saleOrders = SaleOrderManager::getInstance()->getSaleOrdersFull($where, $sortByFieldName, $selectedFilterSortByAscDesc, $offset, $limit);
     $this->addParam('saleOrders', $saleOrders);
     $count = SaleOrderManager::getInstance()->getLastSelectAdvanceRowsCount();
     if (count($saleOrders) == 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])));
 }
Example #14
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 #15
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 #16
0
 public function getSaleOrdersFull($where = [], $orderByFieldsArray = null, $orderByAscDesc = "ASC", $offset = null, $limit = null)
 {
     $rows = $this->selectAdvance('*', $where, $orderByFieldsArray, $orderByAscDesc, $offset, $limit);
     $partnerIds = array();
     $saleOrderIds = array();
     foreach ($rows as $row) {
         $partnerIds[] = intval($row->getPartnerId());
         $saleOrderIds[] = intval($row->getId());
     }
     $partnerIds = array_unique($partnerIds);
     $saleOrderIds = array_unique($saleOrderIds);
     $partnerDtos = PartnerManager::getInstance()->selectByPKs($partnerIds, true);
     $saleOrderLinesDtos = [];
     if (!empty($saleOrderIds)) {
         $saleOrderLinesDtos = SaleOrderLineManager::getInstance()->getSaleOrderLinesFull(['sale_order_id', 'in', '(' . implode(',', $saleOrderIds) . ')']);
         $amount = [];
         $amountInMainCurrency = [];
         $profits = [];
         foreach ($saleOrderLinesDtos as $saleOrderLine) {
             $saleOrderId = intval($saleOrderLine->getSaleOrderId());
             $currencyId = intval($saleOrderLine->getCurrencyId());
             $currencyRate = floatval($saleOrderLine->getCurrencyRate());
             $unitPrice = floatval($saleOrderLine->getUnitPrice());
             $quantity = floatval($saleOrderLine->getQuantity());
             $profit = floatval($saleOrderLine->getTotalProfit());
             if (!array_key_exists($saleOrderId, $amount)) {
                 $amount[$saleOrderId] = [];
             }
             if (!array_key_exists($saleOrderId, $amountInMainCurrency)) {
                 $amountInMainCurrency[$saleOrderId] = 0;
             }
             if (!array_key_exists($currencyId, $amount[$saleOrderId])) {
                 $amount[$saleOrderId][$currencyId] = 0;
             }
             $amount[$saleOrderId][$currencyId] += $unitPrice * $quantity;
             $amountInMainCurrency[$saleOrderId] += $unitPrice * $quantity * $currencyRate;
             if (!array_key_exists($saleOrderId, $profits)) {
                 $profits[$saleOrderId] = 0;
             }
             $profits[$saleOrderId] += $profit;
         }
     }
     if (!empty($saleOrderIds)) {
         $saleOrderLinesDtosMappedBySaleOrderId = $this->mapSaleOrderLinesBySaleOrderId($saleOrderLinesDtos);
         foreach ($saleOrderIds as $saleOrderId) {
             if (!array_key_exists($saleOrderId, $saleOrderLinesDtosMappedBySaleOrderId)) {
                 $saleOrderLinesDtosMappedBySaleOrderId[$saleOrderId] = [];
             }
             if (!array_key_exists($saleOrderId, $amount)) {
                 $amount[$saleOrderId] = [];
             }
             if (!array_key_exists($saleOrderId, $amountInMainCurrency)) {
                 $amountInMainCurrency[$saleOrderId] = 0;
             }
             if (!array_key_exists($saleOrderId, $profits)) {
                 $profits[$saleOrderId] = 0;
             }
         }
     }
     foreach ($rows as $row) {
         $saleOrderId = intval($row->getId());
         $row->setPartnerDto($partnerDtos[intval($row->getPartnerId())]);
         $row->setSaleOrderLinesDtos($saleOrderLinesDtosMappedBySaleOrderId[$saleOrderId]);
         $row->setTotalAmount($amount[$saleOrderId]);
         $row->setTotalAmountInMainCurrency($amountInMainCurrency[$saleOrderId]);
         $row->setTotalProfit($profits[$saleOrderId]);
     }
     return $rows;
 }
 public function updatePaymentOrder($id, $partnerId, $paymentMethodId, $currencyId, $amount, $date, $note, $signature = "[]", $paid = true, $isExpense = false)
 {
     $partnerManager = PartnerManager::getInstance();
     $partner = $partnerManager->selectByPK($partnerId);
     if (empty($partner)) {
         throw new NgsErrorException("Partner does not exists with given id: " . $partnerId);
     }
     $paymentMethodManager = PaymentMethodManager::getInstance();
     $paymentMethod = $paymentMethodManager->selectByPK($paymentMethodId);
     if (empty($paymentMethod)) {
         throw new NgsErrorException("PaymentMethod does not exists with given id: " . $paymentMethodId);
     }
     $dto = $this->selectByPK($id);
     if ($dto) {
         $dto->setPartnerId($partnerId);
         $dto->setPaymentMethodId($paymentMethodId);
         $dto->setCurrencyId($currencyId);
         $rate = CurrencyRateManager::getInstance()->getCurrencyRateByDate($date, $currencyId);
         $dto->setCurrencyRate($rate);
         $dto->setAmount($amount);
         $dto->setDate($date);
         $dto->setNote($note);
         $dto->setIsExpense($isExpense);
         $dto->setPaid($paid);
         $dto->setSignature($signature);
         return $this->updateByPk($dto);
     }
     return false;
 }