From 906c7498945b94f10f3ffab1801a1e0a276e6ad2 Mon Sep 17 00:00:00 2001 From: eileen Date: Fri, 14 Dec 2018 09:24:34 +1300 Subject: [PATCH] Fix broken api get filter on financial_type --- CRM/Contribute/Page/ManagePremiums.php | 2 +- CRM/Contribute/Page/Premium.php | 2 +- CRM/Financial/DAO/FinancialType.php | 7 +------ api/v3/FinancialType.php | 2 -- tests/phpunit/api/v3/FinancialTypeTest.php | 5 +++-- xml/schema/Financial/FinancialType.xml | 5 ----- 6 files changed, 6 insertions(+), 17 deletions(-) diff --git a/CRM/Contribute/Page/ManagePremiums.php b/CRM/Contribute/Page/ManagePremiums.php index 94859108a4..65fb595258 100644 --- a/CRM/Contribute/Page/ManagePremiums.php +++ b/CRM/Contribute/Page/ManagePremiums.php @@ -152,7 +152,7 @@ class CRM_Contribute_Page_ManagePremiums extends CRM_Core_Page_Basic { ); // Financial Type if (!empty($dao->financial_type_id)) { - $premiums[$dao->id]['financial_type'] = CRM_Core_PseudoConstant::getLabel('CRM_Financial_BAO_FinancialType', 'financial_type', $dao->financial_type_id); + $premiums[$dao->id]['financial_type'] = CRM_Core_PseudoConstant::getLabel('CRM_Contribute_BAO_Product', 'financial_type_id', $dao->financial_type_id); } } $this->assign('rows', $premiums); diff --git a/CRM/Contribute/Page/Premium.php b/CRM/Contribute/Page/Premium.php index 61d8cfb4f6..a24eb3960c 100644 --- a/CRM/Contribute/Page/Premium.php +++ b/CRM/Contribute/Page/Premium.php @@ -168,7 +168,7 @@ class CRM_Contribute_Page_Premium extends CRM_Core_Page_Basic { ); // Financial Type if (!empty($premiumsProductDao->financial_type_id)) { - $premiums[$productDAO->id]['financial_type'] = CRM_Core_PseudoConstant::getLabel('CRM_Financial_BAO_FinancialType', 'financial_type', $premiumsProductDao->financial_type_id); + $premiums[$productDAO->id]['financial_type'] = CRM_Core_PseudoConstant::getLabel('CRM_Contribute_BAO_Product', 'financial_type_id', $premiumsProductDao->financial_type_id); } } } diff --git a/CRM/Financial/DAO/FinancialType.php b/CRM/Financial/DAO/FinancialType.php index 0ba7aa946f..516fe493e8 100644 --- a/CRM/Financial/DAO/FinancialType.php +++ b/CRM/Financial/DAO/FinancialType.php @@ -6,7 +6,7 @@ * * Generated from xml/schema/CRM/Financial/FinancialType.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:2313c49e821b4a909bf3c54e72576e9b) + * (GenCodeChecksum:760550280aaa0da48232ebdfb11170f9) */ /** @@ -118,11 +118,6 @@ class CRM_Financial_DAO_FinancialType extends CRM_Core_DAO { 'type' => 'Text', 'label' => ts("Name"), ], - 'pseudoconstant' => [ - 'table' => 'civicrm_financial_type', - 'keyColumn' => 'id', - 'labelColumn' => 'name', - ] ], 'description' => [ 'name' => 'description', diff --git a/api/v3/FinancialType.php b/api/v3/FinancialType.php index dc438dbb46..ab13f47df4 100644 --- a/api/v3/FinancialType.php +++ b/api/v3/FinancialType.php @@ -44,8 +44,6 @@ function civicrm_api3_financial_type_create($params) { function _civicrm_api3_financial_type_create_spec(&$params) { $params['name']['api.required'] = 1; - $params['name']['type'] = CRM_Utils_Type::T_STRING; - unset($params['name']['pseudoconstant']); } /** diff --git a/tests/phpunit/api/v3/FinancialTypeTest.php b/tests/phpunit/api/v3/FinancialTypeTest.php index db5e35a5ce..58fe078929 100644 --- a/tests/phpunit/api/v3/FinancialTypeTest.php +++ b/tests/phpunit/api/v3/FinancialTypeTest.php @@ -73,12 +73,13 @@ class api_v3_FinancialTypeTest extends CiviUnitTestCase { // create financial type with custom field $financialType = $this->callAPISuccess('FinancialType', 'create', array_merge($params, $customFields)); + $this->callAPISuccessGetSingle('FinancialType', ['name' => $financialTypeName]); // get financial type to check custom field value $expectedResult = array_filter(array_merge($params, $customFields), function($var) { return (!is_null($var) && $var != ''); }); - $result = $this->callAPISuccessGetSingle('FinancialType', [ + $this->callAPISuccessGetSingle('FinancialType', [ 'id' => $financialType['id'], ], $expectedResult); @@ -98,7 +99,7 @@ class api_v3_FinancialTypeTest extends CiviUnitTestCase { $expectedResult = array_filter(array_merge($params, $customFields), function($var) { return (!is_null($var) && $var != ''); }); - $result = $this->callAPISuccessGetSingle('FinancialType', [ + $this->callAPISuccessGetSingle('FinancialType', [ 'id' => $financialType['id'], ], $expectedResult); } diff --git a/xml/schema/Financial/FinancialType.xml b/xml/schema/Financial/FinancialType.xml index 8e93b6c82e..bbdca886da 100644 --- a/xml/schema/Financial/FinancialType.xml +++ b/xml/schema/Financial/FinancialType.xml @@ -36,11 +36,6 @@ 1.3 - - civicrm_financial_type
- id - name -
accounting_code -- 2.25.1