Permalink
Browse files

Berechnung des Vormonats in die SQL-Query verlagert und so zuverlässi…

…ger gestaltet
  • Loading branch information...
wolfgang-wiedermann committed Jan 12, 2015
1 parent 4e3de36 commit 05c5a3073c33f835ade0e5932f27a456b60f848d
@@ -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();
@@ -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;
@@ -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;
@@ -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
@@ -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
@@ -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
@@ -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

0 comments on commit 05c5a30

Please sign in to comment.