$year."-01-01", ":to" => $year."-12-31"));
$types = array();
$data = array();
while ($t = $typeresult->fetch()) {
$types[$t['id']] = $t['description'];
}
while ($line = $dataresult->fetch()) {
$data[] = $line;
}
output("Journal für $year (01.01.$year-31.12.$year, sortiert nach Datum)");
output("
$t
");
output("");
foreach ($data as $line) {
$net = $line['amount'];
if ($line['gross'] == 1 && $line['tax_rate'] > 0) {
$net = $net / (1.0+($line['tax_rate']/100));
}
if ($line['direction'] == 'out') {
$net = -$net;
}
$ust = $net * ($line['tax_rate']/100);
$gross = $net + $ust;
$net = str_replace('.', ',', sprintf('%.2f €', $net));
$ust = str_replace('.', ',', sprintf('%.2f €', $ust));
$gross = str_replace('.', ',', sprintf('%.2f €', $gross));
$typetext = $types[$line['type']];
output("".$line['date']." | ".$typetext." | ".$line['description']." | ".$net." | ".$ust." | ".$gross." |
\n");
}
output('
');