print "\n" . "~" x 23 . "\n\n";
$sql = qq{
-SELECT date,description,tax_percent,tax_assigned,price
+SELECT date,billing_date AS billing,description,tax_percent,tax_assigned,price
FROM sales
-WHERE date >= '$opt_start' AND date < '$opt_end'
+WHERE billing_date >= '$opt_start' AND billing_date < '$opt_end'
AND price > 0.0 AND visible = 1
ORDER BY date,nr};
print_table $dbh, $sql;
$sql = qq{
SELECT tax_percent as percent,sum(price) AS brutto, sum(price) - sum(tax_assigned) AS netto, sum(tax_assigned) AS tax
FROM sales
-WHERE date >= '$opt_start' AND date < '$opt_end'
+WHERE billing_date >= '$opt_start' AND billing_date < '$opt_end'
AND price > 0.0 AND visible = 1
GROUP BY tax_percent
ORDER BY tax_percent};
$sql = qq{
SELECT sum(price) AS brutto, sum(price) - sum(tax_assigned) AS netto, sum(tax_assigned) AS tax
FROM sales
-WHERE date >= '$opt_start' AND date < '$opt_end'
+WHERE billing_date >= '$opt_start' AND billing_date < '$opt_end'
AND price > 0.0 AND visible = 1};
print_table $dbh, $sql;
}
print "\n" . "~" x 38 . "\n\n";
$sql = qq{
-SELECT date,description,tax_percent,tax_assigned * -1 as tax_assigned,price * -1 as price
+SELECT date,billing_date AS billing,description,tax_percent,tax_assigned * -1 as tax_assigned,price * -1 as price
FROM sales
-WHERE date >= '$opt_start' AND date < '$opt_end'
+WHERE billing_date >= '$opt_start' AND billing_date < '$opt_end'
AND price < 0.0 AND visible = 1
AND category <> 'privat'
AND category <> 'tax'
$sql = qq{
SELECT tax_percent AS percent,sum(price) * -1 AS brutto, sum(price) * -1 - sum(tax_assigned) * -1 AS netto, sum(tax_assigned) * -1 AS tax
FROM sales
-WHERE date >= '$opt_start' AND date < '$opt_end'
+WHERE billing_date >= '$opt_start' AND billing_date < '$opt_end'
AND price < 0.0 AND visible = 1
AND category <> 'privat'
AND category <> 'tax'
$sql = qq{
SELECT sum(price) * -1 AS brutto, sum(price) * -1 - sum(tax_assigned) * -1 AS netto, sum(tax_assigned) * -1 AS tax
FROM sales
-WHERE date >= '$opt_start' AND date < '$opt_end'
+WHERE billing_date >= '$opt_start' AND billing_date < '$opt_end'
AND price < 0.0 AND visible = 1
AND category <> 'privat'
AND category <> 'tax'};
$sql = qq{
SELECT '1 Einnahmen' AS type, sum(price) AS brutto, sum(price) - sum(tax_assigned) AS netto, sum(tax_assigned) AS tax
FROM sales
-WHERE date >= '$opt_start' AND date < '$opt_end'
+WHERE billing_date >= '$opt_start' AND billing_date < '$opt_end'
AND price > 0.0 AND visible = 1
UNION
SELECT '2 Ausgaben' AS type, sum(price) * -1 AS brutto, sum(price) * -1 - sum(tax_assigned) * -1 AS netto, sum(tax_assigned) * -1 AS tax
FROM sales
-WHERE date >= '$opt_start' AND date < '$opt_end'
+WHERE billing_date >= '$opt_start' AND billing_date < '$opt_end'
AND price < 0.0 AND visible = 1
AND category <> 'privat'
AND category <> 'tax'
UNION
SELECT '3 Summe' AS type, sum(price) AS brutto, sum(price) - sum(tax_assigned) AS netto, sum(tax_assigned) AS tax
FROM sales
-WHERE date >= '$opt_start' AND date < '$opt_end'
+WHERE billing_date >= '$opt_start' AND billing_date < '$opt_end'
AND visible = 1
AND category <> 'privat'
AND category <> 'tax'