Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines
Hi,
Please try this process to add the sub total, IVA12 and total rows to your table:
->pipe(new \koolreport\processes\Map([
'{value}' => function($row, $meta, $index, $mapState) {
$SubTotal = isset($mapState['SubTotal']) ?
$mapState['SubTotal'] : [];
if (! isset($SubTotal['Total'])) {
$SubTotal['Precio_Final'] = 'Sub Total';
$SubTotal['Total'] = 0;
}
$SubTotal['Total'] += 1*$row['Total'];
$mapState['SubTotal'] = $SubTotal;
return ['{rows}' => $row, '{state}' => $mapState];
},
'{end}' => function($count, $mapState) {
$SubTotal = $mapState['SubTotal'];
$IVA12 = [
'Precio_Final' => 'IVA12',
'Total' => $SubTotal['Total'] * 12/100,
];
$Total = [
'Precio_Final' => 'Total',
'Total' => $SubTotal['Total'] + $IVA12['Total'],
];
return [
$SubTotal,
$IVA12,
$Total
];
},
]))
->pipe($this->dataStore('myDataStore'));
Please let us know if there's any problem. Thanks!
Let KoolReport help you to make great reports. It's free & open-source released under MIT license.
Download KoolReport View demo