Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REF] Replace deprecated function call with a more readable alternative #15489

Merged
merged 1 commit into from
Oct 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions CRM/Contribute/BAO/Contribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -3786,10 +3786,7 @@ public static function updateFinancialAccounts(&$params, $context = NULL) {
$itemParams['amount'] = self::getMultiplier($params['contribution']->contribution_status_id, $context) * $taxAmount;
$itemParams['description'] = $taxTerm;
if ($lineItemDetails['financial_type_id']) {
$itemParams['financial_account_id'] = CRM_Contribute_PseudoConstant::getRelationalFinancialAccount(
$lineItemDetails['financial_type_id'],
'Sales Tax Account is'
);
$itemParams['financial_account_id'] = CRM_Financial_BAO_FinancialAccount::getSalesTaxFinancialAccount($lineItemDetails['financial_type_id']);
}
CRM_Financial_BAO_FinancialItem::create($itemParams, NULL, $trxnIds);
}
Expand Down
13 changes: 13 additions & 0 deletions CRM/Financial/BAO/FinancialAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,19 @@ public static function getFinancialAccountForFinancialTypeByRelationship($financ
return Civi::$statics[__CLASS__]['entity_financial_account'][$financialTypeID][$relationTypeId];
}

/**
* Get the sales tax financial account id for the financial type id.
*
* This is a helper wrapper to make the function name more readable.
*
* @param int $financialAccountID
*
* @return int
*/
public static function getSalesTaxFinancialAccount($financialAccountID) {
return self::getFinancialAccountForFinancialTypeByRelationship($financialAccountID, 'Sales Tax Account is');
}

/**
* Get Financial Account type relations.
*
Expand Down
1 change: 1 addition & 0 deletions CRM/Financial/Form/FinancialAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ public static function formRule($values, $files, $self) {
}
if ($self->_action & CRM_Core_Action::UPDATE) {
if (!(isset($values['is_tax']))) {
// @todo replace with call to CRM_Financial_BAO_FinancialAccount getSalesTaxFinancialAccount
$relationshipId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Sales Tax Account is' "));
$params = [
'financial_account_id' => $self->_id,
Expand Down
1 change: 1 addition & 0 deletions CRM/Financial/Form/FinancialTypeAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ public static function formRule($values, $files, $self) {
];
$defaults = [];
if ($self->_action == CRM_Core_Action::ADD) {
// @todo replace with call to CRM_Financial_BAO_FinancialAccount getSalesTaxFinancialAccount
$relationshipId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Sales Tax Account is' "));
$isTax = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialAccount', $values['financial_account_id'], 'is_tax');
if ($values['account_relationship'] == $relationshipId) {
Expand Down