From 019cd5187b59839ca4dc8124118cb2837cc560d6 Mon Sep 17 00:00:00 2001 From: eileen Date: Mon, 29 Jul 2019 10:14:17 +1200 Subject: [PATCH] [NFC] reformat class --- CRM/Financial/BAO/FinancialAccount.php | 84 +++++++++++++------------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/CRM/Financial/BAO/FinancialAccount.php b/CRM/Financial/BAO/FinancialAccount.php index c8f3357370..8e29b57f7e 100644 --- a/CRM/Financial/BAO/FinancialAccount.php +++ b/CRM/Financial/BAO/FinancialAccount.php @@ -101,7 +101,7 @@ class CRM_Financial_BAO_FinancialAccount extends CRM_Financial_DAO_FinancialAcco } if (!empty($params['is_default'])) { $query = 'UPDATE civicrm_financial_account SET is_default = 0 WHERE financial_account_type_id = %1'; - $queryParams = array(1 => array($params['financial_account_type_id'], 'Integer')); + $queryParams = [1 => [$params['financial_account_type_id'], 'Integer']]; CRM_Core_DAO::executeQuery($query, $queryParams); } @@ -143,11 +143,11 @@ class CRM_Financial_BAO_FinancialAccount extends CRM_Financial_DAO_FinancialAcco $check = FALSE; //check dependencies - $dependency = array( - array('Core', 'FinancialTrxn', 'to_financial_account_id'), - array('Financial', 'FinancialTypeAccount', 'financial_account_id'), - array('Financial', 'FinancialItem', 'financial_account_id'), - ); + $dependency = [ + ['Core', 'FinancialTrxn', 'to_financial_account_id'], + ['Financial', 'FinancialTypeAccount', 'financial_account_id'], + ['Financial', 'FinancialItem', 'financial_account_id'], + ]; foreach ($dependency as $name) { require_once str_replace('_', DIRECTORY_SEPARATOR, "CRM_" . $name[0] . "_BAO_" . $name[1]) . ".php"; $className = "CRM_{$name[0]}_BAO_{$name[1]}"; @@ -186,10 +186,10 @@ LEFT JOIN civicrm_entity_financial_account cefa ON cefa.entity_id = cft.id AND c LEFT JOIN civicrm_financial_account cfa ON cefa.financial_account_id = cfa.id WHERE cft.id = %1 AND account_relationship = %2"; - $params = array( - 1 => array($financialTypeId, 'Integer'), - 2 => array($relationTypeId, 'Integer'), - ); + $params = [ + 1 => [$financialTypeId, 'Integer'], + 2 => [$relationTypeId, 'Integer'], + ]; return CRM_Core_DAO::singleValueQuery($query, $params); } @@ -214,11 +214,11 @@ WHERE cft.id = %1 } $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;"; - $params = array( - 1 => array($financialAccountTypeId, 'Integer'), - 2 => array(strtolower($accountTypeCode), 'String'), - 3 => array($financialAccountId, 'Integer'), - ); + $params = [ + 1 => [$financialAccountTypeId, 'Integer'], + 2 => [strtolower($accountTypeCode), 'String'], + 3 => [$financialAccountId, 'Integer'], + ]; return CRM_Core_DAO::singleValueQuery($query, $params); } @@ -242,10 +242,10 @@ WHERE cft.id = %1 $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE '{$relationshipType}' ")); if (!isset(Civi::$statics[__CLASS__]['entity_financial_account'][$financialTypeID][$relationTypeId])) { - $accounts = civicrm_api3('EntityFinancialAccount', 'get', array( + $accounts = civicrm_api3('EntityFinancialAccount', 'get', [ 'entity_id' => $financialTypeID, 'entity_table' => 'civicrm_financial_type', - )); + ]); foreach ($accounts['values'] as $account) { Civi::$statics[__CLASS__]['entity_financial_account'][$financialTypeID][$account['account_relationship']] = $account['financial_account_id']; @@ -256,7 +256,7 @@ WHERE cft.id = %1 $incomeAccountRelationshipID = array_search('Income Account is', $accountRelationships); $incomeAccountFinancialAccountID = Civi::$statics[__CLASS__]['entity_financial_account'][$financialTypeID][$incomeAccountRelationshipID]; - foreach (array('Chargeback Account is', 'Credit/Contra Revenue Account is') as $optionalAccountRelationship) { + foreach (['Chargeback Account is', 'Credit/Contra Revenue Account is'] as $optionalAccountRelationship) { $accountRelationshipID = array_search($optionalAccountRelationship, $accountRelationships); if (empty(Civi::$statics[__CLASS__]['entity_financial_account'][$financialTypeID][$accountRelationshipID])) { @@ -279,10 +279,10 @@ WHERE cft.id = %1 * */ public static function getfinancialAccountRelations($flip = FALSE) { - $params = array('labelColumn' => 'name'); + $params = ['labelColumn' => 'name']; $financialAccountType = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_FinancialAccount', 'financial_account_type_id', $params); $accountRelationships = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_EntityFinancialAccount', 'account_relationship', $params); - $Links = array( + $Links = [ 'Expense Account is' => 'Expenses', 'Accounts Receivable Account is' => 'Asset', 'Income Account is' => 'Revenue', @@ -292,7 +292,7 @@ WHERE cft.id = %1 'Discounts Account is' => 'Revenue', 'Sales Tax Account is' => 'Liability', 'Deferred Revenue Account is' => 'Liability', - ); + ]; if (!$flip) { foreach ($Links as $accountRelation => $accountType) { $financialAccountLinks[array_search($accountRelation, $accountRelationships)] = array_search($accountType, $financialAccountType); @@ -313,12 +313,12 @@ WHERE cft.id = %1 * */ public static function getDeferredFinancialType() { - $deferredFinancialType = array(); + $deferredFinancialType = []; $query = "SELECT ce.entity_id, cft.name FROM civicrm_entity_financial_account ce INNER JOIN civicrm_financial_type cft ON ce.entity_id = cft.id WHERE ce.entity_table = 'civicrm_financial_type' AND ce.account_relationship = %1 AND cft.is_active = 1"; $deferredAccountRel = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Deferred Revenue Account is' ")); - $queryParams = array(1 => array($deferredAccountRel, 'Integer')); + $queryParams = [1 => [$deferredAccountRel, 'Integer']]; $dao = CRM_Core_DAO::executeQuery($query, $queryParams); while ($dao->fetch()) { $deferredFinancialType[$dao->entity_id] = $dao->name; @@ -341,20 +341,20 @@ WHERE ce.entity_table = 'civicrm_financial_type' AND ce.account_relationship = % INNER JOIN civicrm_financial_item fi ON fi.financial_account_id = f.id WHERE f.id = %1 AND f.financial_account_type_id IN (%2) LIMIT 1"; - $params = array('labelColumn' => 'name'); + $params = ['labelColumn' => 'name']; $financialAccountType = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_FinancialAccount', 'financial_account_type_id', $params); - $params = array( - 1 => array($financialAccountId, 'Integer'), - 2 => array( + $params = [ + 1 => [$financialAccountId, 'Integer'], + 2 => [ implode(',', - array( + [ array_search('Revenue', $financialAccountType), array_search('Liability', $financialAccountType), - ) + ] ), 'Text', - ), - ); + ], + ]; $result = CRM_Core_DAO::singleValueQuery($sql, $params); if ($result && $result != $financialAccountTypeID) { return TRUE; @@ -385,7 +385,7 @@ LIMIT 1"; $recognitionDate = CRM_Utils_Array::value('revenue_recognition_date', $params); if (!(!CRM_Utils_System::isNull($recognitionDate) || ($contributionID && isset($params['prevContribution']) - && !CRM_Utils_System::isNull($params['prevContribution']->revenue_recognition_date))) + && !CRM_Utils_System::isNull($params['prevContribution']->revenue_recognition_date))) ) { return FALSE; } @@ -398,7 +398,7 @@ LIMIT 1"; if (($contributionID || !empty($params['price_set_id'])) && empty($lineItems)) { if (!$contributionID) { CRM_Price_BAO_PriceSet::processAmount($priceSetFields, - $params, $items); + $params, $items); } else { $items = CRM_Price_BAO_LineItem::getLineItems($contributionID, 'contribution', TRUE, TRUE, TRUE); @@ -437,13 +437,13 @@ LIMIT 1"; * */ public static function getAllDeferredFinancialAccount() { - $financialAccount = array(); - $result = civicrm_api3('EntityFinancialAccount', 'get', array( + $financialAccount = []; + $result = civicrm_api3('EntityFinancialAccount', 'get', [ 'sequential' => 1, - 'return' => array("financial_account_id.id", "financial_account_id.name", "financial_account_id.accounting_code"), + 'return' => ["financial_account_id.id", "financial_account_id.name", "financial_account_id.accounting_code"], 'entity_table' => "civicrm_financial_type", 'account_relationship' => "Deferred Revenue Account is", - )); + ]); if ($result['count'] > 0) { foreach ($result['values'] as $key => $value) { $financialAccount[$value['financial_account_id.id']] = $value['financial_account_id.name'] . ' (' . $value['financial_account_id.accounting_code'] . ')'; @@ -461,13 +461,13 @@ LIMIT 1"; * */ public static function getOrganizationNames($checkPermissions = TRUE) { - $result = civicrm_api3('FinancialAccount', 'get', array( - 'return' => array("contact_id.organization_name", "contact_id"), + $result = civicrm_api3('FinancialAccount', 'get', [ + 'return' => ["contact_id.organization_name", "contact_id"], 'contact_id.is_deleted' => 0, - 'options' => array('limit' => 0), + 'options' => ['limit' => 0], 'check_permissions' => $checkPermissions, - )); - $organizationNames = array(); + ]); + $organizationNames = []; foreach ($result['values'] as $values) { $organizationNames[$values['contact_id']] = $values['contact_id.organization_name']; } -- 2.25.1