Answers.Body: <p>There is a FinancialType API which returns the name with the ID, for example:</p>
  
  <pre><code>$financialTypeName = civicrm_api3('FinancialType', 'Getvalue', array('id' =&gt; $financialTypeId, 'return' =&gt; 'name'));
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-05T15:26:04.520Z
Answers.LastActivityDate: 2016-04-05T15:26:04.520Z
Answers.UserDisplayName: ErikH - CiviCooP
Answers.Body: <p>There is a function used in the Bookkeeping report to do this:</p>
  
  <pre><code>CRM_Contribute_PseudoConstant::financialType()
  </code></pre>
  
  <p>See e.g.</p>
  
  <pre><code>  public function alterDisplay(&amp;$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];
        }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-05T15:44:42.290Z
Answers.LastActivityDate: 2016-04-05T15:44:42.290Z
Answers.UserDisplayName: davejenx
Body: <p>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. </p>
  
  <p>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. </p>
  
  <p><a href="https://i.sstatic.net/IrF0n.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/IrF0n.png" alt="custom bookkeeping statistics"></a></p>
  
Tags: <civireport><custom-reports><financial-types>
Title: How to get name of Financial Type ID?
ThreadText: # How to get name of Financial Type ID?
  
  (Asked by: username_0 on 2016-04-05)
  
  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](https://i.sstatic.net/IrF0n.png)](https://i.sstatic.net/IrF0n.png)
  
  **Tags:** civireport, custom-reports, financial-types
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2016-04-05. Score: 2 | Accepted answer
  
  There is a FinancialType API which returns the name with the ID, for example:
  $financialTypeName = civicrm_api3('FinancialType', 'Getvalue', array('id' => $financialTypeId, 'return' => 'name'));
  
  
  ---
  
  ### Answer by username_2 on 2016-04-05. Score: 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];
        }
  
  
  ---
  
  