From f3fea3554b5bb8efa7cda25b0bef807c19141285 Mon Sep 17 00:00:00 2001 From: Alexandra Date: Wed, 29 Jan 2025 16:55:57 +0100 Subject: [PATCH] =?UTF-8?q?Queries=20-=20f=C3=BCr=20alle=20:-)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Queries/Aktive Hilfepläne zum Stichtag.txt | 16 +++++++++ Queries/Bewilligungen mit Sonderstunden.txt | 10 ++++++ ...ende Rechnungen im ausgewaehlten Monat.txt | 31 +++++++++++++++++ ...aller Rechnungen im ausgewählten Monat.txt | 34 +++++++++++++++++++ 4 files changed, 91 insertions(+) create mode 100644 Queries/Aktive Hilfepläne zum Stichtag.txt create mode 100644 Queries/Bewilligungen mit Sonderstunden.txt create mode 100644 Queries/Fehlende Rechnungen im ausgewaehlten Monat.txt create mode 100644 Queries/Liste aller Rechnungen im ausgewählten Monat.txt diff --git a/Queries/Aktive Hilfepläne zum Stichtag.txt b/Queries/Aktive Hilfepläne zum Stichtag.txt new file mode 100644 index 000000000..6b5216d38 --- /dev/null +++ b/Queries/Aktive Hilfepläne zum Stichtag.txt @@ -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; \ No newline at end of file diff --git a/Queries/Bewilligungen mit Sonderstunden.txt b/Queries/Bewilligungen mit Sonderstunden.txt new file mode 100644 index 000000000..5fbfd703f --- /dev/null +++ b/Queries/Bewilligungen mit Sonderstunden.txt @@ -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; \ No newline at end of file diff --git a/Queries/Fehlende Rechnungen im ausgewaehlten Monat.txt b/Queries/Fehlende Rechnungen im ausgewaehlten Monat.txt new file mode 100644 index 000000000..3c96b729d --- /dev/null +++ b/Queries/Fehlende Rechnungen im ausgewaehlten Monat.txt @@ -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 ) \ No newline at end of file diff --git a/Queries/Liste aller Rechnungen im ausgewählten Monat.txt b/Queries/Liste aller Rechnungen im ausgewählten Monat.txt new file mode 100644 index 000000000..0f1ed7590 --- /dev/null +++ b/Queries/Liste aller Rechnungen im ausgewählten Monat.txt @@ -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' \ No newline at end of file