Queries - für alle :-)
This commit is contained in:
16
Queries/Aktive Hilfepläne zum Stichtag.txt
Normal file
16
Queries/Aktive Hilfepläne zum Stichtag.txt
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
-- Ursprünglich für Club 74
|
||||||
|
|
||||||
|
select p.LastName as Nachname, p.FirstName as Vorname,
|
||||||
|
cb2sc.`ApprovedStartDate` as 'Bewilligt von', cb2sc.`ApprovedEndDate` as 'Bewilligt bis',
|
||||||
|
o.`Name` as 'Kostentraeger',
|
||||||
|
cust.TerminationDate as 'Betreuungsende'
|
||||||
|
from `person` p join `customer` cust on p.Oid = cust.PersonOid
|
||||||
|
join `supportconcept` sc on cust.Oid = sc.CustomerOid
|
||||||
|
join `costbearer2supportconcept` cb2sc on sc.Oid = cb2sc.SupportConceptOid
|
||||||
|
join `costbearer` cb on cb2sc.`CostBearerOid` = cb.`Oid`
|
||||||
|
join `organisation` o on cb.`Oid` = o.`CostBearerOid`
|
||||||
|
WHERE cust.IsActive <> 0 and sc.IsActive <> 0 and cb2sc.`ApprovedStartDate` is not null and cb2sc.`ApprovedEndDate` is not null
|
||||||
|
and ((cb2sc.`ApprovedStartDate` < ':Monat_End' and cb2sc.`ApprovedEndDate` >= DATE_ADD(':Monat_End', INTERVAL -1 DAY) and cust.TerminationDate is null)
|
||||||
|
or (cust.TerminationDate is not null and cb2sc.`ApprovedStartDate` < ':Monat_End' and cust.TerminationDate >= DATE_ADD(':Monat_End', INTERVAL -1 DAY) and cust.TerminationDate < cb2sc.`ApprovedEndDate`)
|
||||||
|
or (cust.TerminationDate is not null and cb2sc.`ApprovedStartDate` < ':Monat_End' and cb2sc.ApprovedEndDate >= DATE_ADD(':Monat_End', INTERVAL -1 DAY) and cust.TerminationDate >= cb2sc.`ApprovedEndDate`))
|
||||||
|
order by p.LastName, p.FirstName;
|
||||||
10
Queries/Bewilligungen mit Sonderstunden.txt
Normal file
10
Queries/Bewilligungen mit Sonderstunden.txt
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
-- Urspünglich für Club 74
|
||||||
|
|
||||||
|
select p.LastName as Nachname, p.FirstName as Vorname, Round(scap.ApprovedBETotal, 2) as 'Anzahl Sonderstunden', cb2sc.ApprovedStartDate as 'HP Bewilligt von', cb2sc.ApprovedEndDate as 'HP Bewilligt bis',
|
||||||
|
o.`Name` as 'Kostentraeger', scap.Start AS BewilligungStart, scap.EndDate AS BewilligungEnde
|
||||||
|
from `person` p join `customer` cust on p.Oid = cust.PersonOid join `supportconcept` sc on cust.Oid = sc.CustomerOid
|
||||||
|
join `costbearer2supportconcept` cb2sc on sc.Oid = cb2sc.SupportConceptOid join `costbearer` cb on cb2sc.`CostBearerOid` = cb.`Oid`
|
||||||
|
join `supportconceptapprovalperiod` scap on cb2sc.`Oid` = scap.`CostBearer2SupportConceptOid`
|
||||||
|
join `organisation` o on cb.`Oid` = o.`CostBearerOid`
|
||||||
|
WHERE cust.IsActive = 1 and sc.IsActive = 1 AND scap.ApprovedBETotal > 0 AND lower(scap.Notice) LIKE '%sonderstunde%'
|
||||||
|
order by p.LastName;
|
||||||
31
Queries/Fehlende Rechnungen im ausgewaehlten Monat.txt
Normal file
31
Queries/Fehlende Rechnungen im ausgewaehlten Monat.txt
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
-- Ursprünglich bei Input Ostalb,
|
||||||
|
-- auch HPH Bersenbrück Wohnassistenz, ChristopherusHausMID
|
||||||
|
|
||||||
|
-- funktioniert nur für monatliche Einzel-ServiceInvoice
|
||||||
|
|
||||||
|
select
|
||||||
|
p.LastName as Nachname,
|
||||||
|
p.FirstName as Vorname,
|
||||||
|
cb2sc.ApprovedStartDate as 'Bewilligt von',
|
||||||
|
cb2sc.ApprovedEndDate as 'Bewilligt bis',
|
||||||
|
o.`Name` as 'Kostentraeger'
|
||||||
|
from `person` p
|
||||||
|
join `customer` cust on p.Oid = cust.PersonOid
|
||||||
|
join `supportconcept` sc on cust.Oid = sc.CustomerOid
|
||||||
|
join `costbearer2supportconcept` cb2sc on sc.Oid = cb2sc.SupportConceptOid
|
||||||
|
join `costbearer` cb on cb2sc.`CostBearerOid` = cb.`Oid`
|
||||||
|
join `organisation` o on cb.`Oid` = o.`CostBearerOid`
|
||||||
|
WHERE cb2sc.ApprovedEndDate is not null and cust.IsActive = 1 and sc.IsActive = 1
|
||||||
|
and cb2sc.oid not in
|
||||||
|
(select
|
||||||
|
c2s.oid
|
||||||
|
from
|
||||||
|
person p
|
||||||
|
inner join customer c on c.personoid = p.oid
|
||||||
|
inner join supportconcept sc on sc.customeroid = c.oid
|
||||||
|
inner join costbearer2supportconcept c2s on c2s.supportconceptoid = sc.oid
|
||||||
|
inner join invoicebase ib on ib.costbearer2supportconceptoid = c2s.oid
|
||||||
|
inner join serviceinvoice si on si.invoicebaseoid = ib.oid
|
||||||
|
inner join serviceinvoiceperiod sip on sip.serviceinvoiceoid = si.oid
|
||||||
|
where ib.AccountingPeriodStart >= ':Monat_Start' and ib.AccountingPeriodStart < ':Monat_End' and ib.IsActive = 1
|
||||||
|
order by p.Lastname, p.Firstname )
|
||||||
34
Queries/Liste aller Rechnungen im ausgewählten Monat.txt
Normal file
34
Queries/Liste aller Rechnungen im ausgewählten Monat.txt
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
-- Ursprünglich bei Input Ostalb
|
||||||
|
-- Monatliche Einzelrechnungen und Allgemeine Rechnungen
|
||||||
|
|
||||||
|
select
|
||||||
|
sip.SupportConceptApprovalPeriodOid as 'ID',
|
||||||
|
CONCAT(p.LastName, ', ', p.FirstName) as 'Klient:in / Posten',
|
||||||
|
CONCAT(date_format(ib.AccountingPeriodStart, '%d.%m.%Y'), ' - ', date_format(ib.AccountingPeriodEnd, '%d.%m.%Y')) as 'Zeitraum',
|
||||||
|
ib.invoicenumber as 'Rechnungsnummer',
|
||||||
|
date_format(ib.InvoiceDate, '%d.%m.%Y') as Rechnungsdatum,
|
||||||
|
ib.RecipientOrganisation,
|
||||||
|
ROUND(sip.Claim, 2) as 'Betrag'
|
||||||
|
from
|
||||||
|
person p
|
||||||
|
inner join customer c on c.personoid = p.oid
|
||||||
|
inner join supportconcept sc on sc.customeroid = c.oid
|
||||||
|
inner join costbearer2supportconcept c2s on c2s.supportconceptoid = sc.oid
|
||||||
|
inner join invoicebase ib on ib.costbearer2supportconceptoid = c2s.oid
|
||||||
|
inner join serviceinvoice si on si.invoicebaseoid = ib.oid
|
||||||
|
inner join serviceinvoiceperiod sip on sip.serviceinvoiceoid = si.oid
|
||||||
|
where ib.AccountingPeriodStart >= ':Monat_Start' and ib.AccountingPeriodStart < ':Monat_End' and ib.IsActive = 1
|
||||||
|
UNION SELECT
|
||||||
|
'ALG' as 'ID',
|
||||||
|
ii.ItemDescription as 'Klient:in / Posten',
|
||||||
|
CONCAT(date_format(ib.AccountingPeriodStart, '%d.%m.%Y'), ' - ', date_format(ib.AccountingPeriodEnd, '%d.%m.%Y')) as 'Zeitraum',
|
||||||
|
ib.invoicenumber as 'Rechnungsnummer',
|
||||||
|
date_format(ib.InvoiceDate, '%d.%m.%Y') as Rechnungsdatum,
|
||||||
|
ib.RecipientOrganisation,
|
||||||
|
ROUND(sum(ii.AmountTotal), 2) as 'Betrag'
|
||||||
|
from
|
||||||
|
invoicebase ib
|
||||||
|
join invoiceitem ii on ib.oid = ii.InvoiceBaseOid
|
||||||
|
where ib.AccountingPeriodStart >= ':Monat_Start' and ib.AccountingPeriodStart < ':Monat_End' and ib.IsActive = 1
|
||||||
|
GROUP BY ib.OID
|
||||||
|
ORDER BY 'Klient:in / Posten'
|
||||||
Reference in New Issue
Block a user