if (!empty($params['cost'])) {
$contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
$financialAccountType = CRM_Contribute_PseudoConstant::financialAccountType($params['financial_type_id']);
- $accountRelationship = CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND label IN ('Premiums Inventory Account is', 'Cost of Sales Account is')");
+ $accountRelationship = CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name IN ('Premiums Inventory Account is', 'Cost of Sales Account is')");
$toFinancialAccount = !empty($params['isDeleted']) ? 'Premiums Inventory Account is' : 'Cost of Sales Account is';
$fromFinancialAccount = !empty($params['isDeleted']) ? 'Cost of Sales Account is' : 'Premiums Inventory Account is';
$accountRelationship = array_flip($accountRelationship);
*/
public static function getARAccounts($financialAccountId, $financialAccountTypeId = NULL, $accountTypeCode = 'ar') {
if (!$financialAccountTypeId) {
- $financialAccountType = CRM_Core_PseudoConstant::accountOptionValues('financial_account_type');
- $financialAccountTypeId = array_search('Asset', $financialAccountType);
+ $financialAccountTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('financial_account_type', NULL, " AND v.name LIKE 'Asset' "));
}
$query = "SELECT count(id) FROM civicrm_financial_account WHERE financial_account_type_id = %1 AND LCASE(account_type_code) = %2
AND id != %3 AND is_active = 1;";
'id' => $this->_id,
);
$financialAccount = CRM_Financial_BAO_FinancialAccount::retrieve($params, CRM_Core_DAO::$_nullArray);
- $financialAccountType = CRM_Core_PseudoConstant::accountOptionValues('financial_account_type');
- if ($financialAccount->financial_account_type_id == array_search('Asset', $financialAccountType)
+ $financialAccountTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('financial_account_type', NULL, " AND v.name LIKE 'Asset' "));
+ if ($financialAccount->financial_account_type_id == $financialAccountTypeId
&& strtolower($financialAccount->account_type_code) == 'ar'
- && !CRM_Financial_BAO_FinancialAccount::getARAccounts($this->_id, array_search('Asset', $financialAccountType))
+ && !CRM_Financial_BAO_FinancialAccount::getARAccounts($this->_id, $financialAccountTypeId)
) {
$this->_isARFlag = TRUE;
if ($this->_action & CRM_Core_Action::DELETE) {