Merge remote-tracking branch 'upstream/4.3' into 4.3-master-2013-09-25-01-46-57
authorkurund <kurund@civicrm.org>
Wed, 25 Sep 2013 00:01:34 +0000 (02:01 +0200)
committerkurund <kurund@civicrm.org>
Wed, 25 Sep 2013 00:01:34 +0000 (02:01 +0200)
Conflicts:
CRM/Contribute/BAO/Contribution.php
CRM/Contribute/Form/Contribution.php
CRM/Upgrade/Incremental/sql/4.3.4.mysql.tpl
templates/CRM/Financial/Form/FinancialTypeAccount.tpl
tests/phpunit/WebTest/Contribute/OnlineContributionTest.php
tests/phpunit/WebTest/Profile/MultiRecordProfileAddTest.php

17 files changed:
1  2 
CRM/Contribute/BAO/Contribution.php
CRM/Contribute/Form/AdditionalInfo.php
CRM/Contribute/Form/Contribution.php
CRM/Contribute/Form/ContributionPage/Amount.php
CRM/Contribute/Form/ContributionPage/Settings.php
CRM/Contribute/Form/ManagePremiums.php
CRM/Core/BAO/SchemaHandler.php
CRM/Core/Block.php
CRM/Event/Form/Participant.php
CRM/Financial/BAO/FinancialTypeAccount.php
CRM/Logging/Schema.php
CRM/Upgrade/Incremental/php/FourThree.php
CRM/Upgrade/Incremental/sql/4.3.4.mysql.tpl
templates/CRM/Financial/Form/FinancialTypeAccount.tpl
tests/phpunit/WebTest/Contribute/OnlineContributionTest.php
tests/phpunit/WebTest/Member/OfflineMembershipAddPricesetTest.php
tests/phpunit/WebTest/Profile/MultiRecordProfileAddTest.php

index 72773a80c8cf86d79077af3ae85085baad83a9ce,fc21c4bff5e64b1842f7f81ef97d58e42c52d36a..6c1ab2825969a52fee633f4562b4889ea0180568
@@@ -2868,31 -3018,23 +2868,54 @@@ WHERE  contribution_id = %1 "
        self::deleteContribution($contribution->id);
      }
    }
-    * @param Array  $props: whatever is known about this dao object
 +
 +  /**
 +   * Get options for a given contribution field.
 +   * @see CRM_Core_DAO::buildOptions
 +   *
 +   * @param String $fieldName
 +   * @param String $context: @see CRM_Core_DAO::buildOptionsContext
-           $page = civicrm_api('contribution_page', 'getsingle', array('version' => 3, 'id' => ($props['contribution_page_id'])));
++   * @param Array $props: whatever is known about this dao object
 +   */
 +  public static function buildOptions($fieldName, $context = NULL, $props = array()) {
 +    $className = __CLASS__;
 +    $params = array();
 +    switch ($fieldName) {
 +      // This field is not part of this object but the api supports it
 +      case 'payment_processor':
 +        $className = 'CRM_Contribute_BAO_ContributionPage';
 +        // Filter results by contribution page
 +        if (!empty($props['contribution_page_id'])) {
 -   * @param integer $financialTypeId Financial Type id 
++          $page = civicrm_api('contribution_page', 'getsingle', array(
++            'version' => 3,
++            'id' => ($props['contribution_page_id'])
++          ));
 +          $types = (array) CRM_Utils_Array::value('payment_processor', $page, 0);
 +          $params['condition'] = 'id IN (' . implode(',', $types) . ')';
 +        }
 +    }
 +    return CRM_Core_PseudoConstant::get($className, $fieldName, $params, $context);
 +  }
++
+   /**
+    * Function to validate financial type
+    *
+    * CRM-13231
+    *
++   * @param integer $financialTypeId Financial Type id
+    *
+    * @access public
+    * @static
+    */
+   static function validateFinancialType($financialTypeId, $relationName = 'Expense Account is') {
+     $expenseTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE '{$relationName}' "));
+     $financialAccount = CRM_Contribute_PseudoConstant::financialAccountType($financialTypeId, $expenseTypeId);
+     if (!$financialAccount) {
+       return CRM_Contribute_PseudoConstant::financialType($financialTypeId);
+     }
+     return FALSE;
+   }
  }
 +
 +
index 7d567f715954e22d4c4790f95dd38c2037f2e344,fe7fb48905314123a9c83e1d1f82376e6b920287..fc31ea359b959ef7e1982375ff408fe42792f81e
@@@ -930,20 -976,10 +930,12 @@@ class CRM_Contribute_Form_Contribution 
      }
  
      //FIXME FOR NEW DATA FLOW http://wiki.civicrm.org/confluence/display/CRM/CiviAccounts+4.3+Data+Flow
-     if (CRM_Utils_Array::value('fee_amount', $fields)) {
-       $financialAccount = array();
-       CRM_Core_PseudoConstant::populate($financialAccount,
-         'CRM_Financial_DAO_EntityFinancialAccount',
-         $all = TRUE,
-         $retrieve = 'financial_account_id',
-         $filter = NULL,
-         " account_relationship = 5 AND entity_id = {$fields['financial_type_id']} ");
-       if (!current($financialAccount)) {
-         $errors['financial_type_id'] = ts("Financial Account of account relationship of 'Expense Account is' is not configured for this Financial Type");
-       }
+      if (CRM_Utils_Array::value('fee_amount', $fields) 
+       && $financialType = CRM_Contribute_BAO_Contribution::validateFinancialType($fields['financial_type_id'])) {
+       $errors['financial_type_id'] = ts("Financial Account of account relationship of 'Expense Account is' is not configured for Financial Type : ") . $financialType;  
      }
 +
 +    $errors = array_merge($errors, $softErrors);
      return $errors;
    }
  
Simple merge
Simple merge
Simple merge
index ec7024699d41e516abddec38335c05b2a4608f41,cc636ef15347af70bdeb3b7cbbd84a8c464e597d..9fa29dc750add1ceb0f4eee29a5f9d3f8871fa63
@@@ -152,16 -152,18 +152,18 @@@ class CRM_Financial_BAO_FinancialTypeAc
      //delete from financial Type table
      $financialType = new CRM_Financial_DAO_EntityFinancialAccount( );
      $financialType->id = $financialTypeAccountId;
+     $financialType->find(TRUE);
      $financialType->delete();
+     CRM_Core_Session::setStatus(ts('Unbalanced transactions may be created if you delete  %1 account.', array(1 => $relationValues[$financialType->account_relationship])));
    }
 -  
 +
    /**
 -   * Function to get Financial Account Name 
 -   * 
 +   * Function to get Financial Account Name
 +   *
     * @param int $entityId
 -   * 
 -   * @param string $entityTable 
 -   * 
 +   *
 +   * @param string $entityTable
 +   *
     * @param string $columnName Column to fetch
     * @static
     */
Simple merge
index 1c5b9352b6071541ff72aae552d3ef1b556816e2,dbca1af7d1908fb78974149cc4a7861f32e1fa9c..20464bc5087d68ec77a8d0c1fcde4fd61968ca63
@@@ -91,5 -105,5 +105,5 @@@ INSERT INTO civicrm_entity_financial_ac
  SELECT 'civicrm_financial_type', cft.id, @option_value_rel_id_exp, @financialAccountId
  FROM civicrm_financial_type cft
  LEFT JOIN civicrm_entity_financial_account ceft
- ON ceft.entity_id = cft.id AND ceft.account_relationship = 5 AND ceft.entity_table = 'civicrm_financial_type'
 -ON ceft.entity_id = cft.id AND ceft.account_relationship = @option_value_rel_id_exp AND ceft.entity_table = 'civicrm_financial_type' 
++ON ceft.entity_id = cft.id AND ceft.account_relationship = @option_value_rel_id_exp AND ceft.entity_table = 'civicrm_financial_type'
  WHERE ceft.entity_id IS NULL;
index bae57f0f5bc047baf5870ff13a34d0cc97b56ffe,480625b932a7ce53789474ff563129a49dc0ebbd..85d6ee0387a3c7130afecf50ba1c79aeb2d5f7e2
@@@ -205,13 -204,12 +205,12 @@@ class WebTest_Profile_MultiRecordProfil
      }
      $this->openCiviPage('profile/edit', "reset=1&id=$id&gid=$gid", NULL);
      if (!$checkMultiRecord) {
 -      $this->assertElementContainsText('crm-container', 'No multi-record entries found');
 +      $this->assertElementContainsText('crm-container', 'No records');
        return array($gid, $profileTitle);
      }
-     $this->waitForElementPresent("//div[@id='crm-profile-block']/../a");
-     $this->click("//div[@id='crm-profile-block']/../a");
-     sleep(1);
-     $record1 = $this->_addRecords('Edit', FALSE, "//div[@class='crm-container-snippet']/form/div[2]/");
+     $this->waitForElementPresent("//a/span[contains(text(), 'Add New Record')]");
+     $this->click("//a/span[contains(text(), 'Add New Record')]");
+     $record1 = $this->_addRecords();
      $this->waitForPageToLoad($this->getTimeoutMsec());
      $this->verifyText("//div[@id='browseValues']/div/div/table/thead/tr/th[1]", preg_quote($params['textFieldLabel']));
      $this->verifyText("//div[@id='browseValues']/div/div/table/tbody/tr[2]/td[1]", preg_quote($record1['text']));
      return $params;
    }
  
 -  function _addRecords($context = 'Edit') {
 -    $this->waitForPageToLoad($this->getTimeoutMsec());
 +  function _addRecords($context = 'Edit', $waitAtStart = TRUE, $parentElement = '//') {
 +    if ($waitAtStart) {
 +      $this->waitForPageToLoad($this->getTimeoutMsec());
 +    }
      $params['text'] = 'text' . substr(sha1(rand()), 0, 3);
-     $this->type("{$parentElement}div[@id='crm-profile-block']/div/div[2]/input[@type='text']", $params['text']);
+     $this->type("//div[@id='crm-profile-block']/div/div[2]/input[@type='text']", $params['text']);
      if ($context == 'Create') {
        $params['firstname'] = 'John' . substr(sha1(rand()), 0, 3);
        $this->type('first_name', $params['firstname']);