diff --git a/sites/all/civicrm_extensions/uk.co.compucorp.civicrm.giftaid/CRM/Civigiftaid/Report/Form/Contribute/GiftAid.php b/sites/all/civicrm_extensions/uk.co.compucorp.civicrm.giftaid/CRM/Civigiftaid/Report/Form/Contribute/GiftAid.php index 7ed132f46e22..c9484259ace2 100644 --- a/sites/all/civicrm_extensions/uk.co.compucorp.civicrm.giftaid/CRM/Civigiftaid/Report/Form/Contribute/GiftAid.php +++ b/sites/all/civicrm_extensions/uk.co.compucorp.civicrm.giftaid/CRM/Civigiftaid/Report/Form/Contribute/GiftAid.php @@ -110,6 +110,7 @@ public function __construct() { 'receive_date' => array( 'name' => 'receive_date', 'title' => ts('Donation Date'), + 'type' => CRM_Utils_Type::T_STRING, 'no_display' => FALSE, 'required' => TRUE, ), @@ -123,7 +124,7 @@ public function __construct() { 'name' => 'id', 'title' => ts('Financial Type No'), 'no_display' => TRUE, - 'required' => FALSE, + 'required' => TRUE, ), ), ), @@ -172,7 +173,8 @@ public function __construct() { 'title' => ts('Amount'), 'no_display' => FALSE, 'required' => TRUE, - 'type' => CRM_Utils_Type::T_MONEY + // HMRC requires only number + //'type' => CRM_Utils_Type::T_MONEY ), 'quantity' => array( 'name' => 'qty', @@ -279,7 +281,7 @@ public function select() { $this->_columnHeaders['civicrm_line_item_gift_aid_amount'] = array( 'title' => 'Gift Aid Amount', - 'type' => CRM_Utils_Type::T_MONEY + //'type' => CRM_Utils_Type::T_MONEY ); $this->reorderColumns(); @@ -327,6 +329,9 @@ public function statistics(&$rows) { $totalGiftAidAmount += $row['civicrm_line_item_gift_aid_amount']; } + $totalAmount = round($totalAmount, 2); + $totalGiftAidAmount = round($totalGiftAidAmount, 2); + $statistics['counts']['amount'] = array( 'value' => $totalAmount, 'title' => 'Total Amount', @@ -377,11 +382,11 @@ public function alterDisplay(&$rows) { } if (isset($row['civicrm_line_item_amount'])) { $batch = $this->getBatchById($row['civicrm_entity_batch_batch_id']); - $rows[$rowNum]['civicrm_line_item_gift_aid_amount'] = - CRM_Civigiftaid_Utils_Contribution::calculateGiftAidAmt( + $giftaidAmount = CRM_Civigiftaid_Utils_Contribution::calculateGiftAidAmt( $row['civicrm_line_item_amount'], $batch['basic_rate_tax'] - ); + ); + $rows[$rowNum]['civicrm_line_item_gift_aid_amount'] = number_format((float)$giftaidAmount, 2, '.', ''); } if (!empty($row['civicrm_line_item_entity_table'])) { $rows[$rowNum]['civicrm_line_item_entity_table'] = @@ -420,6 +425,14 @@ public function alterDisplay(&$rows) { $entryFound = TRUE; } + // handle donation date + if (array_key_exists('civicrm_contribution_receive_date', $row)) { + if ($value = $row['civicrm_contribution_receive_date']) { + $rows[$rowNum]['civicrm_contribution_receive_date'] = date("d/m/y", strtotime($value)); + } + $entryFound = TRUE; + } + // skip looking further in rows, if first row itself doesn't // have the column we need if (!$entryFound) { @@ -472,25 +485,25 @@ private function getBatchById($id) { private function reorderColumns() { $columnTitleOrder = array( - 'payment no', - 'line item no', 'title', 'first name', 'last name', - 'donor name', - 'item', - 'description', - 'donation date', 'street address', 'city', 'county', - 'country', 'postcode', - 'eligible for gift aid?', - 'quantity', + 'country', + 'donation date', 'amount', - 'gift aid amount', - 'batch name' + 'donor name', + 'item', + 'description', + 'quantity', + 'eligible for gift aid?', + 'batch name', + 'payment no', + 'line item no', + 'gift aid amount' ); $compare = function ($a, $b) use (&$columnTitleOrder) {