Skip to content

Commit 05c5a30

Browse files
author
Wolfgang Wiedermann
committed
Berechnung des Vormonats in die SQL-Query verlagert und so zuverlässiger gestaltet
1 parent 4e3de36 commit 05c5a30

File tree

4 files changed

+35
-9
lines changed

4 files changed

+35
-9
lines changed

controller/VerlaufController.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,11 @@ function getIntraMonth($request) {
143143
if(isset($request['month_id'])) {
144144
if($this->is_number($request['month_id'])) {
145145

146-
$month_id1 = $request['month_id'];
147-
$month_id2 = $request['month_id']+1;
146+
$month_id = $request['month_id'];
148147

149148
$query = new QueryHandler("guv_intramonth_aufwand.sql");
150149
$query->setParameterUnchecked("mandant_id", $this->mandant_id);
151-
$query->setParameterUnchecked("month_id1", $month_id1);
152-
$query->setParameterUnchecked("month_id2", $month_id2);
150+
$query->setParameterUnchecked("month_id", $month_id);
153151
$sql = $query->getSql();
154152

155153
$result = array();

sql/create-tables-and-views.sql

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,4 +240,17 @@ order by `buchungsnummer`,`buchungsart`;
240240
insert into fi_mandant values(0, 'Standardmandant', 1, now());
241241

242242
-- Template für Schnellbuchungen anlegen
243-
insert into fi_quick_config values(1, 1, 'Template', '0000', '0000', 'Template', 0);
243+
insert into fi_quick_config values(1, 1, 'Template', '0000', '0000', 'Template', 0);
244+
245+
-- Hilfstabelle für Monatsdarstellungen generieren
246+
create table fi_hlp_days (xday int not null primary key);
247+
248+
insert into fi_hlp_days
249+
select xday from
250+
(select (a.day*10)+b.day as xday
251+
from (select 0 as day union select 1 union select 2 union select 3) as a,
252+
(select 1 as day union select 2 union select 3 union select 4 union select 5 union select 6 union
253+
select 7 union select 8 union select 9 union select 0) as b
254+
) as days
255+
where days.xday > 0 and days.xday < 32;
256+

sql/create_table_hlp_days.sql

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
* Hilfstabelle für Monatsinterne Darstellung einzeln anlegen
3+
*/
4+
create table fi_hlp_days (xday int not null primary key);
5+
6+
insert into fi_hlp_days
7+
select xday
8+
from
9+
(select (a.day*10)+b.day as xday
10+
from (select 0 as day union select 1 union select 2 union select 3) as a,
11+
(select 1 as day union select 2 union select 3 union select 4 union select 5 union select 6 union
12+
select 7 union select 8 union select 9 union select 0) as b
13+
) as days
14+
where days.xday > 0 and days.xday < 32;
15+

sql/query/guv_intramonth_aufwand.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ and b.sollkonto = k.kontonummer
1818
where
1919
k.kontenart_id = 3
2020
and b.mandant_id = #mandant_id#
21-
and (year(b.datum)*100)+month(b.datum) = #month_id1#
21+
and (year(b.datum)*100)+month(b.datum) = #month_id#
2222
group by day(b.datum)
2323

2424
union
@@ -33,7 +33,7 @@ and b.habenkonto = k.kontonummer
3333
where
3434
k.kontenart_id = 3
3535
and b.mandant_id = #mandant_id#
36-
and (year(b.datum)*100)+month(b.datum) = #month_id1#
36+
and (year(b.datum)*100)+month(b.datum) = #month_id#
3737
group by day(b.datum)
3838
) as a
3939
on a.tag <= d.xday
@@ -59,7 +59,7 @@ and b.sollkonto = k.kontonummer
5959
where
6060
k.kontenart_id = 3
6161
and b.mandant_id = #mandant_id#
62-
and (year(b.datum)*100)+month(b.datum) = #month_id2#
62+
and (year(date_add(b.datum, INTERVAL 1 MONTH))*100)+month(date_add(b.datum, INTERVAL 1 MONTH)) = #month_id#
6363
group by day(b.datum)
6464

6565
union
@@ -74,7 +74,7 @@ and b.habenkonto = k.kontonummer
7474
where
7575
k.kontenart_id = 3
7676
and b.mandant_id = #mandant_id#
77-
and (year(b.datum)*100)+month(b.datum) = #month_id2#
77+
and (year(date_add(b.datum, INTERVAL 1 MONTH))*100)+month(date_add(b.datum, INTERVAL 1 MONTH)) = #month_id#
7878
group by day(b.datum)
7979
) as a
8080
on a.tag <= d.xday

0 commit comments

Comments
 (0)