Bernd Wurst commited on 2019-01-23 07:34:54
Zeige 1 geänderte Dateien mit 15 Einfügungen und 2 Löschungen.
... | ... |
@@ -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 |
+ |
|
117 | 130 |