Skip to content

use AbstractFormattedNumberOutputHandler and introduce TotalAmountForExpense

This change completes the utilisation of the new superclass AbstractFormattedNumberOutputHandler that is introduced by my merge request for the dataprocessor extension so all the remarks made there apply to this change too. So after accepting this merge request, this extension will depend on a new version of dataprocessor that is yet to be published at the time of writing (current name 1.44-dev).

The merge request for dataprocessor introduces a change to the setting of $this->outputFieldSpec->type from 'String' to 'Float' in most cases. This also applies to TotalAmountPerCase, the class changed by this merge request. In there, the code in formatField produces the raw value from a call to CRM_Core_DAO::singleValueQuery which returns string or null. As the SQL query executes a sum, the result is guaranteed to be a numeric string or null. I introduced a cast to float in the non-null case.

Also, this merge request introduces a new output handler TotalAmountForExpense that simply adds up all the expense line amounts for an expense, given the expense’s ID. It, too, is a subclass of AbstractFormattedNumberOutputHandler and the handling of $this->outputFieldSpec->type is identical to TotalAmountPerCase.

Merge request reports