当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Financial_BAO_FinancialItem::retrieve方法代码示例

本文整理汇总了PHP中CRM_Financial_BAO_FinancialItem::retrieve方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Financial_BAO_FinancialItem::retrieve方法的具体用法?PHP CRM_Financial_BAO_FinancialItem::retrieve怎么用?PHP CRM_Financial_BAO_FinancialItem::retrieve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Financial_BAO_FinancialItem的用法示例。


在下文中一共展示了CRM_Financial_BAO_FinancialItem::retrieve方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testRetrieve

 /**
  * check method retrive()
  */
 function testRetrieve()
 {
     $firstName = 'Shane';
     $lastName = 'Whatson';
     $params = array('first_name' => $firstName, 'last_name' => $lastName, 'contact_type' => 'Individual');
     $contact = CRM_Contact_BAO_Contact::add($params);
     $price = 100.0;
     $cParams = array('contact_id' => $contact->id, 'total_amount' => $price, 'financial_type_id' => 1, 'is_active' => 1, 'skipLineItem' => 1);
     $defaults = array();
     $contribution = CRM_Contribute_BAO_Contribution::add($cParams, $defaults);
     $lParams = array('entity_id' => $contribution->id, 'entity_table' => 'civicrm_contribution', 'price_field_id' => 1, 'qty' => 1, 'label' => 'Contribution Amount', 'unit_price' => $price, 'line_total' => $price, 'price_field_value_id' => 1, 'financial_type_id' => 1);
     $lineItem = CRM_Price_BAO_LineItem::create($lParams);
     CRM_Financial_BAO_FinancialItem::add($lineItem, $contribution);
     $values = array();
     $fParams = array('entity_id' => $lineItem->id, 'entity_table' => 'civicrm_line_item');
     $financialItem = CRM_Financial_BAO_FinancialItem::retrieve($fParams, $values);
     $this->assertEquals($financialItem->amount, $price, 'Verify financial item amount.');
 }
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:21,代码来源:FinancialItemTest.php

示例2: updateFinancialAccounts

 /**
  * Update all financial accounts entry.
  *
  * @param array $params
  *   Contribution object, line item array and params for trxn.
  *
  * @param string $context
  *   Update scenarios.
  *
  * @param null $skipTrxn
  *
  */
 public static function updateFinancialAccounts(&$params, $context = NULL, $skipTrxn = NULL)
 {
     $itemAmount = $trxnID = NULL;
     //get all the statuses
     $contributionStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
     if (($params['prevContribution']->contribution_status_id == array_search('Pending', $contributionStatus) || $params['prevContribution']->contribution_status_id == array_search('In Progress', $contributionStatus)) && $params['contribution']->contribution_status_id == array_search('Completed', $contributionStatus) && $context == 'changePaymentInstrument') {
         return;
     }
     if ($params['prevContribution']->contribution_status_id == array_search('Partially paid', $contributionStatus) && $params['contribution']->contribution_status_id == array_search('Completed', $contributionStatus) && $context == 'changedStatus') {
         return;
     }
     if ($context == 'changedAmount' || $context == 'changeFinancialType') {
         $itemAmount = $params['trxnParams']['total_amount'] = $params['trxnParams']['net_amount'] = $params['total_amount'] - $params['prevContribution']->total_amount;
     }
     if ($context == 'changedStatus') {
         //get all the statuses
         $contributionStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
         if ($params['prevContribution']->contribution_status_id == array_search('Completed', $contributionStatus) && ($params['contribution']->contribution_status_id == array_search('Refunded', $contributionStatus) || $params['contribution']->contribution_status_id == array_search('Cancelled', $contributionStatus))) {
             $params['trxnParams']['total_amount'] = -$params['total_amount'];
         } elseif ($params['prevContribution']->contribution_status_id == array_search('Pending', $contributionStatus) && $params['prevContribution']->is_pay_later || $params['prevContribution']->contribution_status_id == array_search('In Progress', $contributionStatus)) {
             $financialTypeID = CRM_Utils_Array::value('financial_type_id', $params) ? $params['financial_type_id'] : $params['prevContribution']->financial_type_id;
             if ($params['contribution']->contribution_status_id == array_search('Cancelled', $contributionStatus)) {
                 $params['trxnParams']['to_financial_account_id'] = NULL;
                 $params['trxnParams']['total_amount'] = -$params['total_amount'];
             }
             $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Accounts Receivable Account is' "));
             $params['trxnParams']['from_financial_account_id'] = CRM_Contribute_PseudoConstant::financialAccountType($financialTypeID, $relationTypeId);
         }
         $itemAmount = $params['trxnParams']['total_amount'];
     } elseif ($context == 'changePaymentInstrument') {
         if ($params['trxnParams']['total_amount'] < 0) {
             $lastFinancialTrxnId = CRM_Core_BAO_FinancialTrxn::getFinancialTrxnId($params['prevContribution']->id, 'DESC');
             if (!empty($lastFinancialTrxnId['financialTrxnId'])) {
                 $params['trxnParams']['to_financial_account_id'] = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialTrxn', $lastFinancialTrxnId['financialTrxnId'], 'to_financial_account_id');
                 $params['trxnParams']['payment_instrument_id'] = $params['prevContribution']->payment_instrument_id;
             }
         } else {
             $params['trxnParams']['to_financial_account_id'] = $params['to_financial_account_id'];
             $params['trxnParams']['payment_instrument_id'] = $params['contribution']->payment_instrument_id;
         }
     }
     $trxn = CRM_Core_BAO_FinancialTrxn::create($params['trxnParams']);
     $params['entity_id'] = $trxn->id;
     if ($context == 'changedStatus') {
         if (($params['prevContribution']->contribution_status_id == array_search('Pending', $contributionStatus) || $params['prevContribution']->contribution_status_id == array_search('In Progress', $contributionStatus)) && $params['contribution']->contribution_status_id == array_search('Completed', $contributionStatus)) {
             $query = "UPDATE civicrm_financial_item SET status_id = %1 WHERE entity_id = %2 and entity_table = 'civicrm_line_item'";
             $sql = "SELECT id, amount FROM civicrm_financial_item WHERE entity_id = %1 and entity_table = 'civicrm_line_item'";
             $entityParams = array('entity_table' => 'civicrm_financial_item', 'financial_trxn_id' => $trxn->id);
             if (empty($params['line_item'])) {
                 //CRM-15296
                 //@todo - check with Joe regarding this situation - payment processors create pending transactions with no line items
                 // when creating recurring membership payment - there are 2 lines to comment out in contributonPageTest if fixed
                 // & this can be removed
                 return;
             }
             foreach ($params['line_item'] as $fieldId => $fields) {
                 foreach ($fields as $fieldValueId => $fieldValues) {
                     $fparams = array(1 => array(CRM_Core_OptionGroup::getValue('financial_item_status', 'Paid', 'name'), 'Integer'), 2 => array($fieldValues['id'], 'Integer'));
                     CRM_Core_DAO::executeQuery($query, $fparams);
                     $fparams = array(1 => array($fieldValues['id'], 'Integer'));
                     $financialItem = CRM_Core_DAO::executeQuery($sql, $fparams);
                     while ($financialItem->fetch()) {
                         $entityParams['entity_id'] = $financialItem->id;
                         $entityParams['amount'] = $financialItem->amount;
                         CRM_Financial_BAO_FinancialItem::createEntityTrxn($entityParams);
                     }
                 }
             }
             return;
         }
     }
     if ($context != 'changePaymentInstrument') {
         $itemParams['entity_table'] = 'civicrm_line_item';
         $trxnIds['id'] = $params['entity_id'];
         foreach ($params['line_item'] as $fieldId => $fields) {
             foreach ($fields as $fieldValueId => $fieldValues) {
                 $prevParams['entity_id'] = $fieldValues['id'];
                 $prevfinancialItem = CRM_Financial_BAO_FinancialItem::retrieve($prevParams, CRM_Core_DAO::$_nullArray);
                 $receiveDate = CRM_Utils_Date::isoToMysql($params['prevContribution']->receive_date);
                 if ($params['contribution']->receive_date) {
                     $receiveDate = CRM_Utils_Date::isoToMysql($params['contribution']->receive_date);
                 }
                 $financialAccount = $prevfinancialItem->financial_account_id;
                 if (!empty($params['financial_account_id'])) {
                     $financialAccount = $params['financial_account_id'];
                 }
                 $currency = $params['prevContribution']->currency;
                 if ($params['contribution']->currency) {
//.........这里部分代码省略.........
开发者ID:nganivet,项目名称:civicrm-core,代码行数:101,代码来源:Contribution.php

示例3: updateFinancialAccounts

 /**
  * Function to update all financial accounts entry
  *
  * @param array $params contribution object, line item array and params for trxn
  *
  * @param string $context update scenarios
  *
  * @access public
  * @static
  */
 static function updateFinancialAccounts(&$params, $context = NULL, $skipTrxn = NULL)
 {
     $itemAmount = $trxnID = NULL;
     //get all the statuses
     $contributionStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
     if (($params['prevContribution']->contribution_status_id == array_search('Pending', $contributionStatus) || $params['prevContribution']->contribution_status_id == array_search('In Progress', $contributionStatus)) && $params['contribution']->contribution_status_id == array_search('Completed', $contributionStatus) && $context == 'changePaymentInstrument') {
         return;
     }
     if ($context == 'changedAmount' || $context == 'changeFinancialType') {
         $itemAmount = $params['trxnParams']['total_amount'] = $params['total_amount'] - $params['prevContribution']->total_amount;
     }
     if ($context == 'changedStatus') {
         //get all the statuses
         $contributionStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
         if ($params['prevContribution']->contribution_status_id == array_search('Completed', $contributionStatus) && ($params['contribution']->contribution_status_id == array_search('Refunded', $contributionStatus) || $params['contribution']->contribution_status_id == array_search('Cancelled', $contributionStatus))) {
             $params['trxnParams']['total_amount'] = -$params['total_amount'];
         } elseif ($params['prevContribution']->contribution_status_id == array_search('Pending', $contributionStatus) && $params['prevContribution']->is_pay_later || $params['prevContribution']->contribution_status_id == array_search('In Progress', $contributionStatus)) {
             $financialTypeID = CRM_Utils_Array::value('financial_type_id', $params) ? $params['financial_type_id'] : $params['prevContribution']->financial_type_id;
             if ($params['contribution']->contribution_status_id == array_search('Cancelled', $contributionStatus)) {
                 $params['trxnParams']['to_financial_account_id'] = NULL;
                 $params['trxnParams']['total_amount'] = -$params['total_amount'];
             }
             $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Accounts Receivable Account is' "));
             $params['trxnParams']['from_financial_account_id'] = CRM_Contribute_PseudoConstant::financialAccountType($financialTypeID, $relationTypeId);
         }
         $itemAmount = $params['trxnParams']['total_amount'];
     } elseif ($context == 'changePaymentInstrument') {
         if ($params['trxnParams']['total_amount'] < 0) {
             $lastFinancialTrxnId = CRM_Core_BAO_FinancialTrxn::getFinancialTrxnId($params['prevContribution']->id, 'DESC');
             if (CRM_Utils_Array::value('financialTrxnId', $lastFinancialTrxnId)) {
                 $params['trxnParams']['to_financial_account_id'] = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialTrxn', $lastFinancialTrxnId['financialTrxnId'], 'to_financial_account_id');
                 $params['trxnParams']['payment_instrument_id'] = $params['prevContribution']->payment_instrument_id;
             }
         } else {
             $params['trxnParams']['to_financial_account_id'] = $params['to_financial_account_id'];
             $params['trxnParams']['payment_instrument_id'] = $params['contribution']->payment_instrument_id;
         }
     }
     $trxn = CRM_Core_BAO_FinancialTrxn::create($params['trxnParams']);
     $params['entity_id'] = $trxn->id;
     if ($context == 'changedStatus') {
         if (($params['prevContribution']->contribution_status_id == array_search('Pending', $contributionStatus) || $params['prevContribution']->contribution_status_id == array_search('In Progress', $contributionStatus)) && $params['contribution']->contribution_status_id == array_search('Completed', $contributionStatus)) {
             $query = "UPDATE civicrm_financial_item SET status_id = %1 WHERE entity_id = %2 and entity_table = 'civicrm_line_item'";
             $sql = "SELECT id, amount FROM civicrm_financial_item WHERE entity_id = %1 and entity_table = 'civicrm_line_item'";
             $entityParams = array('entity_table' => 'civicrm_financial_item', 'financial_trxn_id' => $trxn->id);
             foreach ($params['line_item'] as $fieldId => $fields) {
                 foreach ($fields as $fieldValueId => $fieldValues) {
                     $fparams = array(1 => array(CRM_Core_OptionGroup::getValue('financial_item_status', 'Paid', 'name'), 'Integer'), 2 => array($fieldValues['id'], 'Integer'));
                     CRM_Core_DAO::executeQuery($query, $fparams);
                     $fparams = array(1 => array($fieldValues['id'], 'Integer'));
                     $financialItem = CRM_Core_DAO::executeQuery($sql, $fparams);
                     while ($financialItem->fetch()) {
                         $entityParams['entity_id'] = $financialItem->id;
                         $entityParams['amount'] = $financialItem->amount;
                         CRM_Financial_BAO_FinancialItem::createEntityTrxn($entityParams);
                     }
                 }
             }
             return;
         }
     }
     if ($context != 'changePaymentInstrument') {
         $itemParams['entity_table'] = 'civicrm_line_item';
         $trxnIds['id'] = $params['entity_id'];
         foreach ($params['line_item'] as $fieldId => $fields) {
             foreach ($fields as $fieldValueId => $fieldValues) {
                 $prevParams['entity_id'] = $fieldValues['id'];
                 $prevfinancialItem = CRM_Financial_BAO_FinancialItem::retrieve($prevParams, CRM_Core_DAO::$_nullArray);
                 $receiveDate = CRM_Utils_Date::isoToMysql($params['prevContribution']->receive_date);
                 if ($params['contribution']->receive_date) {
                     $receiveDate = CRM_Utils_Date::isoToMysql($params['contribution']->receive_date);
                 }
                 $financialAccount = $prevfinancialItem->financial_account_id;
                 if (CRM_Utils_Array::value('financial_account_id', $params)) {
                     $financialAccount = $params['financial_account_id'];
                 }
                 $currency = $params['prevContribution']->currency;
                 if ($params['contribution']->currency) {
                     $currency = $params['contribution']->currency;
                 }
                 if (CRM_Utils_Array::value('is_quick_config', $params)) {
                     $amount = $itemAmount;
                     if (!$amount) {
                         $amount = $params['total_amount'];
                     }
                 } else {
                     $diff = 1;
                     if ($context == 'changeFinancialType' || $params['contribution']->contribution_status_id == array_search('Cancelled', $contributionStatus)) {
                         $diff = -1;
                     }
//.........这里部分代码省略.........
开发者ID:TheCraftyCanvas,项目名称:aegir-platforms,代码行数:101,代码来源:Contribution.php

示例4: testChangeFinancialType

 public function testChangeFinancialType()
 {
     $this->webtestLogin();
     $amount = 100.0;
     $this->_testOfflineContribution($amount);
     $this->waitForElementPresent("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']");
     $this->clickLink("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']", '_qf_Contribution_cancel-bottom', FALSE);
     //Contribution status
     $this->select("financial_type_id", "value=3");
     $contId = explode('&id=', $this->getAttribute("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']@href"));
     $contId = explode('&', $contId[1]);
     $contId = $contId[0];
     $this->clickLink("_qf_Contribution_upload", "xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']", FALSE);
     $this->waitForText('crm-notification-container', "The contribution record has been saved.");
     //Assertions
     $search = array('id' => $contId);
     $compare = array('financial_type_id' => 3);
     $this->assertDBCompareValues('CRM_Contribute_DAO_Contribution', $search, $compare);
     $lineItem = key(CRM_Price_BAO_LineItem::getLineItems($contId, 'contribution'));
     $itemParams = array('amount' => '-100.00', 'entity_id' => $lineItem);
     $item1 = $item2 = array();
     CRM_Financial_BAO_FinancialItem::retrieve($itemParams, $item1);
     $this->assertEquals($item1['amount'], "-100.00", "Verify Amount for New Financial Item");
     $itemParams['amount'] = '100.00';
     CRM_Financial_BAO_FinancialItem::retrieve($itemParams, $item2);
     $this->assertEquals($item2['amount'], "100.00", "Verify Amount for New Financial Item");
     $cValue1 = $this->_getPremiumActualCost($contId, NULL, NULL, "-100.00", "'civicrm_contribution'");
     $fValue1 = $this->_getPremiumActualCost($item1['id'], NULL, NULL, "-100.00", "'civicrm_financial_item'");
     $this->assertEquals($cValue1, "-100.00", "Verify Amount");
     $this->assertEquals($fValue1, "-100.00", "Verify Amount");
     $cValue2 = $this->_getPremiumActualCost($contId, NULL, NULL, "100.00", "'civicrm_contribution'");
     $fValue2 = $this->_getPremiumActualCost($item2['id'], NULL, NULL, "100.00", "'civicrm_financial_item'");
     $this->assertEquals($cValue2, "100.00", "Verify Amount");
     $this->assertEquals($fValue2, "100.00", "Verify Amount");
 }
开发者ID:scardinius,项目名称:civicrm-core,代码行数:35,代码来源:UpdateContributionTest.php

示例5: testChangeFinancialType

 function testChangeFinancialType()
 {
     $this->webtestLogin();
     $firstName = substr(sha1(rand()), 0, 7);
     $lastName = 'Contributor';
     $email = $firstName . "@example.com";
     $label = 'TEST' . substr(sha1(rand()), 0, 7);
     $amount = 100.0;
     $this->_testOfflineContribution($firstName, $lastName, $email, $amount);
     $this->clickLink("xpath=//div[@id='Contributions']//table/tbody/tr[1]/td[8]/span/a[text()='Edit']");
     //Contribution status
     $this->select("financial_type_id", "value=3");
     $contId = $this->urlArg('id');
     $this->clickLink("_qf_Contribution_upload");
     //Assertions
     $search = array('id' => $contId);
     $compare = array('financial_type_id' => 3);
     $this->assertDBCompareValues('CRM_Contribute_DAO_Contribution', $search, $compare);
     $lineItem = key(CRM_Price_BAO_LineItem::getLineItems($contId, 'contribution'));
     $itemParams = array('amount' => '-100.00', 'entity_id' => $lineItem);
     $item1 = $item2 = array();
     CRM_Financial_BAO_FinancialItem::retrieve($itemParams, $item1);
     $this->assertEquals($item1['amount'], "-100.00", "Verify Amount for New Financial Item");
     $itemParams['amount'] = '100.00';
     CRM_Financial_BAO_FinancialItem::retrieve($itemParams, $item2);
     $this->assertEquals($item2['amount'], "100.00", "Verify Amount for New Financial Item");
     $cValue1 = $this->_getPremiumActualCost($contId, NULL, NULL, "-100.00", "'civicrm_contribution'");
     $fValue1 = $this->_getPremiumActualCost($item1['id'], NULL, NULL, "-100.00", "'civicrm_financial_item'");
     $this->assertEquals($cValue1, "-100.00", "Verify Amount");
     $this->assertEquals($fValue1, "-100.00", "Verify Amount");
     $cValue2 = $this->_getPremiumActualCost($contId, NULL, NULL, "100.00", "'civicrm_contribution'");
     $fValue2 = $this->_getPremiumActualCost($item2['id'], NULL, NULL, "100.00", "'civicrm_financial_item'");
     $this->assertEquals($cValue2, "100.00", "Verify Amount");
     $this->assertEquals($fValue2, "100.00", "Verify Amount");
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:35,代码来源:UpdateContributionTest.php


注:本文中的CRM_Financial_BAO_FinancialItem::retrieve方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。