From 02395dfe2b2c567f87296e0f0bef54d51f3a4bc9 Mon Sep 17 00:00:00 2001 From: filip Date: Thu, 12 Mar 2015 17:27:35 +0100 Subject: fix rounding errors + better init + var # fix --- en/about/reports/template_lib.php | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/en/about/reports/template_lib.php b/en/about/reports/template_lib.php index 419ff103c..12282650c 100644 --- a/en/about/reports/template_lib.php +++ b/en/about/reports/template_lib.php @@ -11,9 +11,9 @@ function get_expenses($v) $html .= sprintf('%s%s%s%s', $line[0], $line[1], - $line[2], $line[3], + $line[2], $line[3]/*, $line[4], - $line[5]); + $line[5]*/); foreach ($v as $line) { if (count($line) < 2) @@ -25,6 +25,12 @@ function get_expenses($v) _report_number_format($line[3])); $cat = explode(':', $line[1]); + if(!isset($sums[$cat[0]])) { + $sums[$cat[0]] = 0; + } + if(!isset($sums['total'])) { + $sums['total'] = 0; + } $sums[$cat[0]] += $line[3]; $sums['total'] += $line[3]; } @@ -114,12 +120,12 @@ function get_revenues($v, $_months) $line[1] > 0 ? _report_number_format($line[2] / $line[1]) : '' ); - $sums['count'] += $line[1]; - $sums['total'] += $line[2]; - $sums['check'] += $line[3]; - $sums['xfer'] += $line[4]; - $sums['paypal'] += $line[5]; - $sums['cash'] += $line[6]; + $sums['count'] += floatval(str_replace(',', '.', $line[1])); + $sums['total'] += floatval(str_replace(',', '.', $line[2])); + $sums['check'] += floatval(str_replace(',', '.', $line[3])); + $sums['xfer'] += floatval(str_replace(',', '.', $line[4])); + $sums['paypal'] += floatval(str_replace(',', '.', $line[5])); + $sums['cash'] += floatval(str_replace(',', '.', $line[6])); } $html .= ''; $html .= sprintf('Total -- cgit v1.2.1