1

I am adding some custom code to the Bookkeeping Report so that each Financial Type's sub total is added to the bottom in the statistics. I have successfully done so, but I can't figure out how to list the name of the Financial Type ID instead of the ID itself.

For instance it is currently listed as 6: $300, 17: $540, etc. I would rather have it listed as: Event Income: $300, Fundraisers: $540, etc. I know this is listed in the table civicrm_financial_type and I can manually build it into the function; however, I did not know if there was an API or a function already built that returned the name of the ID.

custom bookkeeping statistics

2 Answers 2

2

There is a FinancialType API which returns the name with the ID, for example:

$financialTypeName = civicrm_api3('FinancialType', 'Getvalue', array('id' => $financialTypeId, 'return' => 'name'));
1

There is a function used in the Bookkeeping report to do this:

CRM_Contribute_PseudoConstant::financialType()

See e.g.

  public function alterDisplay(&$rows) {
    $contributionTypes = CRM_Contribute_PseudoConstant::financialType();
...
      // handle financial type id
      if ($value = CRM_Utils_Array::value('civicrm_line_item_financial_type_id', $row)) {
        $rows[$rowNum]['civicrm_line_item_financial_type_id'] = $contributionTypes[$value];
      }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.