Skip to content

Commit

Permalink
Berechnung des Vormonats in die SQL-Query verlagert und so zuverlässi…
Browse files Browse the repository at this point in the history
…ger gestaltet
  • Loading branch information
wolfgang-wiedermann committed Jan 12, 2015
1 parent 4e3de36 commit 05c5a30
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 9 deletions.
6 changes: 2 additions & 4 deletions controller/VerlaufController.php
Expand Up @@ -143,13 +143,11 @@ function getIntraMonth($request) {
if(isset($request['month_id'])) {
if($this->is_number($request['month_id'])) {

$month_id1 = $request['month_id'];
$month_id2 = $request['month_id']+1;
$month_id = $request['month_id'];

$query = new QueryHandler("guv_intramonth_aufwand.sql");
$query->setParameterUnchecked("mandant_id", $this->mandant_id);
$query->setParameterUnchecked("month_id1", $month_id1);
$query->setParameterUnchecked("month_id2", $month_id2);
$query->setParameterUnchecked("month_id", $month_id);
$sql = $query->getSql();

$result = array();
Expand Down
15 changes: 14 additions & 1 deletion sql/create-tables-and-views.sql
Expand Up @@ -240,4 +240,17 @@ order by `buchungsnummer`,`buchungsart`;
insert into fi_mandant values(0, 'Standardmandant', 1, now());

-- Template für Schnellbuchungen anlegen
insert into fi_quick_config values(1, 1, 'Template', '0000', '0000', 'Template', 0);
insert into fi_quick_config values(1, 1, 'Template', '0000', '0000', 'Template', 0);

-- Hilfstabelle für Monatsdarstellungen generieren
create table fi_hlp_days (xday int not null primary key);

insert into fi_hlp_days
select xday from
(select (a.day*10)+b.day as xday
from (select 0 as day union select 1 union select 2 union select 3) as a,
(select 1 as day union select 2 union select 3 union select 4 union select 5 union select 6 union
select 7 union select 8 union select 9 union select 0) as b
) as days
where days.xday > 0 and days.xday < 32;

15 changes: 15 additions & 0 deletions sql/create_table_hlp_days.sql
@@ -0,0 +1,15 @@
/*
* Hilfstabelle für Monatsinterne Darstellung einzeln anlegen
*/
create table fi_hlp_days (xday int not null primary key);

insert into fi_hlp_days
select xday
from
(select (a.day*10)+b.day as xday
from (select 0 as day union select 1 union select 2 union select 3) as a,
(select 1 as day union select 2 union select 3 union select 4 union select 5 union select 6 union
select 7 union select 8 union select 9 union select 0) as b
) as days
where days.xday > 0 and days.xday < 32;

8 changes: 4 additions & 4 deletions sql/query/guv_intramonth_aufwand.sql
Expand Up @@ -18,7 +18,7 @@ and b.sollkonto = k.kontonummer
where
k.kontenart_id = 3
and b.mandant_id = #mandant_id#
and (year(b.datum)*100)+month(b.datum) = #month_id1#
and (year(b.datum)*100)+month(b.datum) = #month_id#
group by day(b.datum)

union
Expand All @@ -33,7 +33,7 @@ and b.habenkonto = k.kontonummer
where
k.kontenart_id = 3
and b.mandant_id = #mandant_id#
and (year(b.datum)*100)+month(b.datum) = #month_id1#
and (year(b.datum)*100)+month(b.datum) = #month_id#
group by day(b.datum)
) as a
on a.tag <= d.xday
Expand All @@ -59,7 +59,7 @@ and b.sollkonto = k.kontonummer
where
k.kontenart_id = 3
and b.mandant_id = #mandant_id#
and (year(b.datum)*100)+month(b.datum) = #month_id2#
and (year(date_add(b.datum, INTERVAL 1 MONTH))*100)+month(date_add(b.datum, INTERVAL 1 MONTH)) = #month_id#
group by day(b.datum)

union
Expand All @@ -74,7 +74,7 @@ and b.habenkonto = k.kontonummer
where
k.kontenart_id = 3
and b.mandant_id = #mandant_id#
and (year(b.datum)*100)+month(b.datum) = #month_id2#
and (year(date_add(b.datum, INTERVAL 1 MONTH))*100)+month(date_add(b.datum, INTERVAL 1 MONTH)) = #month_id#
group by day(b.datum)
) as a
on a.tag <= d.xday
Expand Down

0 comments on commit 05c5a30

Please sign in to comment.