Aggregations
This section describes column totals.
<aggregations>
<aggregation field="total_payment" type="custom" />
<aggregation field="commission" type="avg" />
<aggregation field="tax" />
</aggregations>
type - can have values avg
, sum
, custom
. If type
is not specified,
it defaults to sum
.
When using the custom
type, you need to add a listener to the Store::EVENT_ON_AGGREGATIONS
event:
<listener event="<?php echo Store::EVENT_ON_AGGREGATIONS; ?>"
plugin="Finance"
method="onMonthlyPaymentReportAggregationData" />
/**
* @event Store::EVENT_ON_AGGREGATIONS
* @param StoreAggregationEvent $event
* @throws SystemException
*/
public function onMonthlyPaymentReportAggregationData(StoreAggregationEvent &$event)
{
$values = &$event->getValues();
$data = &$event->getData();
$values['total_payment'] = 0;
foreach ($data as $row) {
$values['total_payment'] += (float) $row['total_payment'];
}
}