'title' => ts('Last Year Total'),
'default' => TRUE,
'type' => CRM_Utils_Type::T_MONEY,
+ 'required' => TRUE,
),
'civicrm_life_time_total' => array(
'title' => ts('Lifetime Total'),
$this->sqlArray = array();
}
- /**
- * Are we ordering by the latest year total.
- *
- * If we are we need to drop the rollup to do the ordering.
- *
- * Without bigger changes we can't get the lifetime total and order by
- * the latest year total in the same query.
- *
- * @return bool
- */
- public function isOrderByLastYearTotal() {
- $this->storeOrderByArray();
- foreach ($this->_orderByArray as $orderBy) {
- if (stristr($orderBy, 'contribution_civireport.total_amount')) {
- return TRUE;
- }
- }
- return FALSE;
- }
-
/**
* @param $rows
*/
$this->assertEquals(2, $rows['count'], "Report failed - the sql used to generate the results was " . print_r($rows['metadata']['sql'], TRUE));
}
+ /**
+ * Test Lybunt report to check basic inclusion of a contact who gave in the year before the chosen year.
+ */
+ public function testLybuntReportWithFYDataOrderByLastYearAmount() {
+ $inInd = $this->individualCreate();
+ $outInd = $this->individualCreate();
+ $this->contributionCreate(array('contact_id' => $inInd, 'receive_date' => '2014-10-01'));
+ $this->contributionCreate(array('contact_id' => $outInd, 'receive_date' => '2015-03-01', 'trxn_id' => NULL, 'invoice_id' => NULL));
+ $this->callAPISuccess('Setting', 'create', array('fiscalYearStart' => array('M' => 7, 'd' => 1)));
+ $rows = $this->callAPISuccess('report_template', 'getrows', array(
+ 'report_id' => 'contribute/lybunt',
+ 'yid_value' => 2015,
+ 'yid_op' => 'fiscal',
+ 'options' => array('metadata' => array('sql')),
+ 'fields' => array('first_name'),
+ 'order_bys' => array(
+ array(
+ 'column' => 'last_year_total_amount',
+ 'order' => 'ASC',
+ ),
+ ),
+ ));
+
+ $this->assertEquals(2, $rows['count'], "Report failed - the sql used to generate the results was " . print_r($rows['metadata']['sql'], TRUE));
+ }
+
}