... | ... |
@@ -11,15 +11,15 @@ if (isset($_GET['year'])) { |
11 | 11 |
} |
12 | 12 |
|
13 | 13 |
$typeresult = db_query("SELECT id, description, investment FROM buchhaltung.types"); |
14 |
-$dataresult = db_query("SELECT id, date, description, invoice_id, direction, type, amount, tax_rate, gross FROM buchhaltung.transactions WHERE date BETWEEN :from and :to ORDER BY date", array(":from" => $year."-01-01", ":to" => $year."-12-31")); |
|
14 |
+$dataresult = db_query("SELECT id, date, description, invoice_id, direction, type, amount, tax_rate, gross FROM buchhaltung.transactions WHERE date BETWEEN :from and :to ORDER BY date", [":from" => $year."-01-01", ":to" => $year."-12-31"]); |
|
15 | 15 |
|
16 |
-$types = array(); |
|
17 |
-$data_by_type = array(); |
|
18 |
-$sum_by_type = array(); |
|
19 |
-$investment_types = array(); |
|
16 |
+$types = []; |
|
17 |
+$data_by_type = []; |
|
18 |
+$sum_by_type = []; |
|
19 |
+$investment_types = []; |
|
20 | 20 |
while ($t = $typeresult->fetch()) { |
21 | 21 |
$types[$t['id']] = $t['description']; |
22 |
- $data_by_type[$t['id']] = array(); |
|
22 |
+ $data_by_type[$t['id']] = []; |
|
23 | 23 |
$sum_by_type[$t['id']] = 0.0; |
24 | 24 |
if ($t['investment'] == 1) { |
25 | 25 |
$investment_types[$t['id']] = $t; |
... | ... |
@@ -35,9 +35,9 @@ output("Journal für $year (01.01.$year-31.12.$year, gruppiert nach Buchungskont |
35 | 35 |
|
36 | 36 |
DEBUG($types); |
37 | 37 |
DEBUG($investment_types); |
38 |
-$net_by_type = array(0 => array(-1 => array(), 0 => array(), 19 => array())); |
|
38 |
+$net_by_type = [0 => [-1 => [], 0 => [], 19 => []]]; |
|
39 | 39 |
$umsatzsteuer = 0.0; |
40 |
-$ustbetraege = array(); |
|
40 |
+$ustbetraege = []; |
|
41 | 41 |
$vorsteuer = 0.0; |
42 | 42 |
foreach ($types as $id => $t) { |
43 | 43 |
if (count($data_by_type[$id]) == 0 || $t=='Privatentnahme') { |
... | ... |
@@ -40,7 +40,7 @@ $umsatzsteuer = 0.0; |
40 | 40 |
$ustbetraege = array(); |
41 | 41 |
$vorsteuer = 0.0; |
42 | 42 |
foreach ($types as $id => $t) { |
43 |
- if (count($data_by_type[$id]) == 0) { |
|
43 |
+ if (count($data_by_type[$id]) == 0 || $t=='Privatentnahme') { |
|
44 | 44 |
continue; |
45 | 45 |
} |
46 | 46 |
output("<h3>$t</h3>"); |
... | ... |
@@ -106,7 +106,7 @@ output("<tr><td>Einnahme Umsatzsteuer 19%</td><td style=\"text-align: right;\">" |
106 | 106 |
$einnahmensumme += $ustbetraege[19]; |
107 | 107 |
output("<tr><td>Einnahmen innergem. Lieferung (steuerfrei §4/1b UStG)</td><td style=\"text-align: right;\">".number_format($net_by_type[0][0], 2, ',', '.')." €</td></tr>"); |
108 | 108 |
$einnahmensumme += $net_by_type[0][0]; |
109 |
-output("<tr><td>Einnahmen EU-Ausland (VATMOSS)</td><td style=\"text-align: right;\">".number_format($net_by_type[0][-1], 2, ',', '.')." €</td></tr>"); |
|
109 |
+output("<tr><td>Einnahmen andere Steuersätze</td><td style=\"text-align: right;\">".number_format($net_by_type[0][-1], 2, ',', '.')." €</td></tr>"); |
|
110 | 110 |
$einnahmensumme += $net_by_type[0][-1]; |
111 | 111 |
$einzelust = ''; |
112 | 112 |
foreach ($ustbetraege as $satz => $ust) { |
... | ... |
@@ -37,6 +37,7 @@ DEBUG($types); |
37 | 37 |
DEBUG($investment_types); |
38 | 38 |
$net_by_type = array(0 => array(-1 => array(), 0 => array(), 19 => array())); |
39 | 39 |
$umsatzsteuer = 0.0; |
40 |
+$ustbetraege = array(); |
|
40 | 41 |
$vorsteuer = 0.0; |
41 | 42 |
foreach ($types as $id => $t) { |
42 | 43 |
if (count($data_by_type[$id]) == 0) { |
... | ... |
@@ -68,6 +69,10 @@ foreach ($types as $id => $t) { |
68 | 69 |
$netsum += $net; |
69 | 70 |
$ustsum += $ust; |
70 | 71 |
if ($id == 0) { |
72 |
+ if (!isset($ustbetraege[$line['tax_rate']])) { |
|
73 |
+ $ustbetraege[$line['tax_rate']] = 0; |
|
74 |
+ } |
|
75 |
+ $ustbetraege[$line['tax_rate']] += $ust; |
|
71 | 76 |
$umsatzsteuer += $ust; |
72 | 77 |
} else { |
73 | 78 |
$vorsteuer += $ust; |
... | ... |
@@ -76,7 +81,7 @@ foreach ($types as $id => $t) { |
76 | 81 |
$net = str_replace('.', ',', sprintf('%.2f €', $net)); |
77 | 82 |
$ust = str_replace('.', ',', sprintf('%.2f €', $ust)); |
78 | 83 |
$gross = str_replace('.', ',', sprintf('%.2f €', $gross)); |
79 |
- output("<tr><td>".$line['date']."</td><td>".$line['description']."</td><td style=\"text-align: right;\">".$net."</td><td style=\"text-align: right;\">".$ust."</td><td style=\"text-align: right;\">".$gross."</td></tr>\n"); |
|
84 |
+ output("<tr><td>".$line['date']."</td><td>".$line['description']."</td><td style=\"text-align: right;\">".$net."</td><td style=\"text-align: right;\">".$line['tax_rate']."%</td><td style=\"text-align: right;\">".$ust."</td><td style=\"text-align: right;\">".$gross."</td></tr>\n"); |
|
80 | 85 |
} |
81 | 86 |
if ($id == 0) { |
82 | 87 |
$net_by_type[0][-1] = $umsatzandereproz; |
... | ... |
@@ -87,7 +92,7 @@ foreach ($types as $id => $t) { |
87 | 92 |
} |
88 | 93 |
$netsum = str_replace('.', ',', sprintf('%.2f €', $netsum)); |
89 | 94 |
$ustsum = str_replace('.', ',', sprintf('%.2f €', $ustsum)); |
90 |
- output("<tr><td colspan=\"2\" style=\"font-weight: bold;text-align: right;\">Summe $t:</td><td style=\"font-weight: bold;text-align: right;\">$netsum</td><td style=\"font-weight: bold;text-align: right;\">$ustsum</td><td></td></tr>\n"); |
|
95 |
+ output("<tr><td colspan=\"2\" style=\"font-weight: bold;text-align: right;\">Summe $t:</td><td style=\"font-weight: bold;text-align: right;\">$netsum</td><td></td><td style=\"font-weight: bold;text-align: right;\">$ustsum</td><td></td></tr>\n"); |
|
91 | 96 |
output('</table>'); |
92 | 97 |
} |
93 | 98 |
|
... | ... |
@@ -97,12 +102,20 @@ output('<table>'); |
97 | 102 |
$einnahmensumme = 0.0; |
98 | 103 |
output("<tr><td>Einnahmen 19% USt netto</td><td style=\"text-align: right;\">".number_format($net_by_type[0][19], 2, ',', '.')." €</td></tr>"); |
99 | 104 |
$einnahmensumme += $net_by_type[0][19]; |
105 |
+output("<tr><td>Einnahme Umsatzsteuer 19%</td><td style=\"text-align: right;\">".number_format($ustbetraege[19], 2, ',', '.')." €</td></tr>"); |
|
106 |
+$einnahmensumme += $ustbetraege[19]; |
|
100 | 107 |
output("<tr><td>Einnahmen innergem. Lieferung (steuerfrei §4/1b UStG)</td><td style=\"text-align: right;\">".number_format($net_by_type[0][0], 2, ',', '.')." €</td></tr>"); |
101 | 108 |
$einnahmensumme += $net_by_type[0][0]; |
102 | 109 |
output("<tr><td>Einnahmen EU-Ausland (VATMOSS)</td><td style=\"text-align: right;\">".number_format($net_by_type[0][-1], 2, ',', '.')." €</td></tr>"); |
103 | 110 |
$einnahmensumme += $net_by_type[0][-1]; |
104 |
-output("<tr><td>Einnahme Umsatzsteuer</td><td style=\"text-align: right;\">".number_format($umsatzsteuer, 2, ',', '.')." €</td></tr>"); |
|
105 |
-$einnahmensumme += $umsatzsteuer; |
|
111 |
+$einzelust = ''; |
|
112 |
+foreach ($ustbetraege as $satz => $ust) { |
|
113 |
+ if ($satz == 0 || $satz == 19) { |
|
114 |
+ continue; |
|
115 |
+ } |
|
116 |
+ output("<tr><td>- Umsatzsteuer $satz%</td><td style=\"text-align: right;\">".number_format($ust, 2, ',', '.')." €</td></tr>"); |
|
117 |
+ $einnahmensumme += $ust; |
|
118 |
+} |
|
106 | 119 |
|
107 | 120 |
output("<tr><td><b>Summe Einnahmen:</b></td><td style=\"text-align: right;\"><b>".number_format($einnahmensumme, 2, ',', '.')." €</td></tr>"); |
108 | 121 |
output("<tr><td colspan=\"2\"></td></tr>"); |
... | ... |
@@ -6,6 +6,9 @@ $title = 'Report'; |
6 | 6 |
|
7 | 7 |
|
8 | 8 |
$year = date("Y")-1; |
9 |
+if (isset($_GET['year'])) { |
|
10 |
+ $year = (int) $_GET['year']; |
|
11 |
+} |
|
9 | 12 |
|
10 | 13 |
$typeresult = db_query("SELECT id, description, investment FROM buchhaltung.types"); |
11 | 14 |
$dataresult = db_query("SELECT id, date, description, invoice_id, direction, type, amount, tax_rate, gross FROM buchhaltung.transactions WHERE date BETWEEN :from and :to ORDER BY date", array(":from" => $year."-01-01", ":to" => $year."-12-31")); |
... | ... |
@@ -7,16 +7,20 @@ $title = 'Report'; |
7 | 7 |
|
8 | 8 |
$year = date("Y")-1; |
9 | 9 |
|
10 |
-$typeresult = db_query("SELECT id, description FROM buchhaltung.types"); |
|
10 |
+$typeresult = db_query("SELECT id, description, investment FROM buchhaltung.types"); |
|
11 | 11 |
$dataresult = db_query("SELECT id, date, description, invoice_id, direction, type, amount, tax_rate, gross FROM buchhaltung.transactions WHERE date BETWEEN :from and :to ORDER BY date", array(":from" => $year."-01-01", ":to" => $year."-12-31")); |
12 | 12 |
|
13 | 13 |
$types = array(); |
14 | 14 |
$data_by_type = array(); |
15 | 15 |
$sum_by_type = array(); |
16 |
+$investment_types = array(); |
|
16 | 17 |
while ($t = $typeresult->fetch()) { |
17 | 18 |
$types[$t['id']] = $t['description']; |
18 | 19 |
$data_by_type[$t['id']] = array(); |
19 | 20 |
$sum_by_type[$t['id']] = 0.0; |
21 |
+ if ($t['investment'] == 1) { |
|
22 |
+ $investment_types[$t['id']] = $t; |
|
23 |
+ } |
|
20 | 24 |
} |
21 | 25 |
|
22 | 26 |
while ($line = $dataresult->fetch()) { |
... | ... |
@@ -27,6 +31,7 @@ while ($line = $dataresult->fetch()) { |
27 | 31 |
output("Journal für $year (01.01.$year-31.12.$year, gruppiert nach Buchungskonten)"); |
28 | 32 |
|
29 | 33 |
DEBUG($types); |
34 |
+DEBUG($investment_types); |
|
30 | 35 |
$net_by_type = array(0 => array(-1 => array(), 0 => array(), 19 => array())); |
31 | 36 |
$umsatzsteuer = 0.0; |
32 | 37 |
$vorsteuer = 0.0; |
... | ... |
@@ -100,7 +105,7 @@ output("<tr><td><b>Summe Einnahmen:</b></td><td style=\"text-align: right;\"><b> |
100 | 105 |
output("<tr><td colspan=\"2\"></td></tr>"); |
101 | 106 |
$ausgabensumme = 0.0; |
102 | 107 |
foreach ($types as $id => $t) { |
103 |
- if ($id == 0 || !isset($net_by_type[$id])) { |
|
108 |
+ if ($id == 0 || !isset($net_by_type[$id]) || array_key_exists($id, $investment_types)) { |
|
104 | 109 |
continue; |
105 | 110 |
} |
106 | 111 |
$ausgabensumme -= $net_by_type[$id]; |
... | ... |
@@ -114,3 +119,11 @@ output("<tr><td colspan=\"2\"></td></tr>"); |
114 | 119 |
|
115 | 120 |
output("<tr><td><b>Überschuss aus laufendem Betrieb:</b></td><td style=\"text-align: right;\"><b>".number_format($einnahmensumme-$ausgabensumme, 2, ',', '.')." €</td></tr>"); |
116 | 121 |
output('</table>'); |
122 |
+ |
|
123 |
+foreach ($investment_types as $id => $type) { |
|
124 |
+ if (isset($net_by_type[$id])) { |
|
125 |
+ output('<p>Neue Anlagegüter <strong>'.$type['description'].'</strong>: '.number_format(-$net_by_type[$id], 2, ',', '.')." €</p>"); |
|
126 |
+ } |
|
127 |
+} |
|
128 |
+ |
|
129 |
+ |
... | ... |
@@ -8,7 +8,7 @@ $title = 'Report'; |
8 | 8 |
$year = date("Y")-1; |
9 | 9 |
|
10 | 10 |
$typeresult = db_query("SELECT id, description FROM buchhaltung.types"); |
11 |
-$dataresult = db_query("SELECT id, date, description, invoice_id, direction, type, amount, tax_rate, gross FROM buchhaltung.transactions WHERE date BETWEEN :from and :to", array(":from" => $year."-01-01", ":to" => $year."-12-31")); |
|
11 |
+$dataresult = db_query("SELECT id, date, description, invoice_id, direction, type, amount, tax_rate, gross FROM buchhaltung.transactions WHERE date BETWEEN :from and :to ORDER BY date", array(":from" => $year."-01-01", ":to" => $year."-12-31")); |
|
12 | 12 |
|
13 | 13 |
$types = array(); |
14 | 14 |
$data_by_type = array(); |
... | ... |
@@ -35,7 +35,7 @@ foreach ($types as $id => $t) { |
35 | 35 |
continue; |
36 | 36 |
} |
37 | 37 |
output("<h3>$t</h3>"); |
38 |
- output("<table>"); |
|
38 |
+ output('<table style="font-size: 10pt;">'); |
|
39 | 39 |
$umsatz19proz = 0.0; |
40 | 40 |
$umsatz0proz = 0.0; |
41 | 41 |
$umsatzandereproz = 0.0; |
... | ... |
@@ -79,7 +79,7 @@ foreach ($types as $id => $t) { |
79 | 79 |
} |
80 | 80 |
$netsum = str_replace('.', ',', sprintf('%.2f €', $netsum)); |
81 | 81 |
$ustsum = str_replace('.', ',', sprintf('%.2f €', $ustsum)); |
82 |
- output("<tr><td colspan=\"2\" style=\"font-weight: bold;text-align: right;\">Summe dieser Kategorie:</td><td style=\"font-weight: bold;text-align: right;\">$netsum</td><td style=\"font-weight: bold;text-align: right;\">$ustsum</td><td></td></tr>\n"); |
|
82 |
+ output("<tr><td colspan=\"2\" style=\"font-weight: bold;text-align: right;\">Summe $t:</td><td style=\"font-weight: bold;text-align: right;\">$netsum</td><td style=\"font-weight: bold;text-align: right;\">$ustsum</td><td></td></tr>\n"); |
|
83 | 83 |
output('</table>'); |
84 | 84 |
} |
85 | 85 |
|
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,117 @@ |
1 |
+<?php |
|
2 |
+ |
|
3 |
+require_role(ROLE_SYSADMIN); |
|
4 |
+ |
|
5 |
+$title = 'Report'; |
|
6 |
+ |
|
7 |
+ |
|
8 |
+$year = date("Y")-1; |
|
9 |
+ |
|
10 |
+$typeresult = db_query("SELECT id, description FROM buchhaltung.types"); |
|
11 |
+$dataresult = db_query("SELECT id, date, description, invoice_id, direction, type, amount, tax_rate, gross FROM buchhaltung.transactions WHERE date BETWEEN :from and :to", array(":from" => $year."-01-01", ":to" => $year."-12-31")); |
|
12 |
+ |
|
13 |
+$types = array(); |
|
14 |
+$data_by_type = array(); |
|
15 |
+$sum_by_type = array(); |
|
16 |
+while ($t = $typeresult->fetch()) { |
|
17 |
+ $types[$t['id']] = $t['description']; |
|
18 |
+ $data_by_type[$t['id']] = array(); |
|
19 |
+ $sum_by_type[$t['id']] = 0.0; |
|
20 |
+} |
|
21 |
+ |
|
22 |
+while ($line = $dataresult->fetch()) { |
|
23 |
+ $data_by_type[$line['type']][] = $line; |
|
24 |
+} |
|
25 |
+ |
|
26 |
+ |
|
27 |
+output("Journal für $year (01.01.$year-31.12.$year, gruppiert nach Buchungskonten)"); |
|
28 |
+ |
|
29 |
+DEBUG($types); |
|
30 |
+$net_by_type = array(0 => array(-1 => array(), 0 => array(), 19 => array())); |
|
31 |
+$umsatzsteuer = 0.0; |
|
32 |
+$vorsteuer = 0.0; |
|
33 |
+foreach ($types as $id => $t) { |
|
34 |
+ if (count($data_by_type[$id]) == 0) { |
|
35 |
+ continue; |
|
36 |
+ } |
|
37 |
+ output("<h3>$t</h3>"); |
|
38 |
+ output("<table>"); |
|
39 |
+ $umsatz19proz = 0.0; |
|
40 |
+ $umsatz0proz = 0.0; |
|
41 |
+ $umsatzandereproz = 0.0; |
|
42 |
+ $netsum = 0.0; |
|
43 |
+ $ustsum = 0.0; |
|
44 |
+ foreach ($data_by_type[$id] as $line) { |
|
45 |
+ $net = $line['amount']; |
|
46 |
+ if ($line['gross'] == 1 && $line['tax_rate'] > 0) { |
|
47 |
+ $net = $net / (1.0+($line['tax_rate']/100)); |
|
48 |
+ } |
|
49 |
+ if ($line['direction'] == 'out') { |
|
50 |
+ $net = -$net; |
|
51 |
+ } |
|
52 |
+ $ust = $net * ($line['tax_rate']/100); |
|
53 |
+ if ($line['tax_rate'] == 19.0) { |
|
54 |
+ $umsatz19proz += $net; |
|
55 |
+ } elseif ($line['tax_rate'] == 0.0) { |
|
56 |
+ $umsatz0proz += $net; |
|
57 |
+ } else { |
|
58 |
+ $umsatzandereproz += $net; |
|
59 |
+ } |
|
60 |
+ $netsum += $net; |
|
61 |
+ $ustsum += $ust; |
|
62 |
+ if ($id == 0) { |
|
63 |
+ $umsatzsteuer += $ust; |
|
64 |
+ } else { |
|
65 |
+ $vorsteuer += $ust; |
|
66 |
+ } |
|
67 |
+ $gross = $net + $ust; |
|
68 |
+ $net = str_replace('.', ',', sprintf('%.2f €', $net)); |
|
69 |
+ $ust = str_replace('.', ',', sprintf('%.2f €', $ust)); |
|
70 |
+ $gross = str_replace('.', ',', sprintf('%.2f €', $gross)); |
|
71 |
+ output("<tr><td>".$line['date']."</td><td>".$line['description']."</td><td style=\"text-align: right;\">".$net."</td><td style=\"text-align: right;\">".$ust."</td><td style=\"text-align: right;\">".$gross."</td></tr>\n"); |
|
72 |
+ } |
|
73 |
+ if ($id == 0) { |
|
74 |
+ $net_by_type[0][-1] = $umsatzandereproz; |
|
75 |
+ $net_by_type[0][0] = $umsatz0proz; |
|
76 |
+ $net_by_type[0][19] = $umsatz19proz; |
|
77 |
+ } else { |
|
78 |
+ $net_by_type[$id] = $netsum; |
|
79 |
+ } |
|
80 |
+ $netsum = str_replace('.', ',', sprintf('%.2f €', $netsum)); |
|
81 |
+ $ustsum = str_replace('.', ',', sprintf('%.2f €', $ustsum)); |
|
82 |
+ output("<tr><td colspan=\"2\" style=\"font-weight: bold;text-align: right;\">Summe dieser Kategorie:</td><td style=\"font-weight: bold;text-align: right;\">$netsum</td><td style=\"font-weight: bold;text-align: right;\">$ustsum</td><td></td></tr>\n"); |
|
83 |
+ output('</table>'); |
|
84 |
+} |
|
85 |
+ |
|
86 |
+output("<h3>Summen</h3>"); |
|
87 |
+ |
|
88 |
+output('<table>'); |
|
89 |
+$einnahmensumme = 0.0; |
|
90 |
+output("<tr><td>Einnahmen 19% USt netto</td><td style=\"text-align: right;\">".number_format($net_by_type[0][19], 2, ',', '.')." €</td></tr>"); |
|
91 |
+$einnahmensumme += $net_by_type[0][19]; |
|
92 |
+output("<tr><td>Einnahmen innergem. Lieferung (steuerfrei §4/1b UStG)</td><td style=\"text-align: right;\">".number_format($net_by_type[0][0], 2, ',', '.')." €</td></tr>"); |
|
93 |
+$einnahmensumme += $net_by_type[0][0]; |
|
94 |
+output("<tr><td>Einnahmen EU-Ausland (VATMOSS)</td><td style=\"text-align: right;\">".number_format($net_by_type[0][-1], 2, ',', '.')." €</td></tr>"); |
|
95 |
+$einnahmensumme += $net_by_type[0][-1]; |
|
96 |
+output("<tr><td>Einnahme Umsatzsteuer</td><td style=\"text-align: right;\">".number_format($umsatzsteuer, 2, ',', '.')." €</td></tr>"); |
|
97 |
+$einnahmensumme += $umsatzsteuer; |
|
98 |
+ |
|
99 |
+output("<tr><td><b>Summe Einnahmen:</b></td><td style=\"text-align: right;\"><b>".number_format($einnahmensumme, 2, ',', '.')." €</td></tr>"); |
|
100 |
+output("<tr><td colspan=\"2\"></td></tr>"); |
|
101 |
+$ausgabensumme = 0.0; |
|
102 |
+foreach ($types as $id => $t) { |
|
103 |
+ if ($id == 0 || !isset($net_by_type[$id])) { |
|
104 |
+ continue; |
|
105 |
+ } |
|
106 |
+ $ausgabensumme -= $net_by_type[$id]; |
|
107 |
+ output("<tr><td>".$t."</td><td style=\"text-align: right;\">".number_format(-$net_by_type[$id], 2, ',', '.')." €</td></tr>"); |
|
108 |
+} |
|
109 |
+ |
|
110 |
+output("<tr><td>Vorsteuer</td><td style=\"text-align: right;\">".number_format(-$vorsteuer, 2, ',', '.')." €</td></tr>"); |
|
111 |
+$ausgabensumme -= $vorsteuer; |
|
112 |
+output("<tr><td><b>Summe Ausgaben:</b></td><td style=\"text-align: right;\"><b>".number_format($ausgabensumme, 2, ',', '.')." €</td></tr>"); |
|
113 |
+output("<tr><td colspan=\"2\"></td></tr>"); |
|
114 |
+ |
|
115 |
+output("<tr><td><b>Überschuss aus laufendem Betrieb:</b></td><td style=\"text-align: right;\"><b>".number_format($einnahmensumme-$ausgabensumme, 2, ',', '.')." €</td></tr>"); |
|
116 |
+output('</table>'); |
|
117 |
+ |