diff --git a/ReportImp/PerspektivenEV/CustomReportCreator.cs b/ReportImp/PerspektivenEV/CustomReportCreator.cs index c37461104..cbbf6e4f4 100644 --- a/ReportImp/PerspektivenEV/CustomReportCreator.cs +++ b/ReportImp/PerspektivenEV/CustomReportCreator.cs @@ -22,44 +22,14 @@ namespace PerspektivenEV { public override XtraReport CreateQueryReport(long queryOid, string queryReportId) { - if (queryOid == 200 || queryOid == 201) - { - return CreateLWVRechnung(queryOid, queryReportId); - } - - if (queryOid == 205 || queryOid == 206 || queryOid == 207 || queryOid == 208) + if (queryOid == 207) { return CreateTestRechnungslauf(queryOid, queryReportId); } - //if (queryOid == 300) - //{ - // return CreateLwvSpitzabrechnung(queryOid, queryReportId); - //} - return base.CreateQueryReport(queryOid, queryReportId); } - private XtraReport CreateLwvSpitzabrechnung(long queryOid, string queryReportId) - { - // Parameter ergänzen - var qro = base.CreateQueryRO(queryOid, queryReportId); - if (qro != null && qro.Rows.Count > 0) - { - long c2sOid = Int64.Parse(qro.Rows[0].Field1.ToString()); - long? cat = Int64.Parse(qro.Rows[0].Field2.ToString()); - DateTime end = DateTime.Today; - var ro = LwvKASpitzabrechnungRO.Create(c2sOid, end, null, cat); - - var report = new LwvKASpitzabrechnung(); - report.SetReportDataSource(ro); - report.CreateDocument(); - - return (XtraReport)report; - } - return new XtraReport(); - } - private XtraReport CreateTestRechnungslauf(long queryOid, string queryReportId) { var query = DAOFactory.GenericDAO.LoadByID(queryOid); @@ -80,129 +50,77 @@ namespace PerspektivenEV DateTimeSpan span = new DateTimeSpan(); span.StartDate = start.Date; span.EndDate = end.Date; //.AddDays(1).AddTicks(-1); -# region LWV - if (queryOid == 205 || queryOid == 206) + var costBearers = DAOFactory.GenericDAO.GetAllActive(); + var cBBthg = costBearers.Where(c => c.Organisation.Function != null && c.Organisation.Function.Value.ToString().ToLower().Contains("bthg") && c.Organisation.Name != "SELBSTZAHLER").ToList(); + var anhang = new FinanzauswertungTabBthgIntern(); + List firstInv = new List(); + foreach (var cb in cBBthg) { - var firstInv = GenerateInitialServiceInvoices(198, span); - var anhang = new SammelrechnungTabBthgIntern(); - if (firstInv != null) + var invs = GenerateInitialServiceInvoices(cb.Oid.Value, span); + if (invs != null) { - var count = 0; - foreach (var i in firstInv) - { - count += 1; - if (count > 1 && i.ServiceInvoicePeriods != null && i.ServiceInvoicePeriods.Count > 0) + if (firstInv.Count == 0) + { + var count = 0; + foreach (var i in invs) { - foreach (var sip in i.ServiceInvoicePeriods) + count += 1; + if (count > 1 && i.ServiceInvoicePeriods != null && i.ServiceInvoicePeriods.Count > 0) { - firstInv[0].ServiceInvoicePeriods.Add(sip); + foreach (var sip in i.ServiceInvoicePeriods) + { + invs[0].ServiceInvoicePeriods.Add(sip); + } } } - } - ServiceInvoiceRO ro = ServiceInvoiceRO.Create(firstInv[0]); - anhang.SetReportDataSource(ro); - anhang.CreateDocument(); - if (queryOid == 205) // die wollen die Rechnungsvorschau nur in Excel sprich Trennung von Sammelrechnung Spitzabrechnungsreports - { - return (XtraReport)anhang; + ServiceInvoiceRO roSingle = ServiceInvoiceRO.Create(invs[0]); + if (roSingle.GrossClaim != "0,00 €") + { + firstInv.Add(invs[0]); + } } else { - var anhang2 = new LwvKASpitzabrechnung(); - if (ro.ServiceInvoicePeriods != null && ro.ServiceInvoicePeriods.Count > 0) + var count = 0; + foreach (var i in invs) { - foreach (var sip in ro.ServiceInvoicePeriods) + if (i.ServiceInvoicePeriods != null && i.ServiceInvoicePeriods.Count > 0) { - if (sip.ServiceInvoiceItems != null && sip.ServiceInvoiceItems.Count > 1 - && sip.SupportConceptApprovalPeriod.ServiceCategory.Abbreviation.Substring(sip.SupportConceptApprovalPeriod.ServiceCategory.Abbreviation.Length - 2) == "KA") + foreach (var sip in i.ServiceInvoicePeriods) { - var einzel = new LwvKASpitzabrechnung(); - var kaRo = LwvKASpitzabrechnungRO.Create(sip.CostBearer2SupportConcept.Oid.Value, ro.AccountingPeriodEnd, sip.SupportConceptApprovalPeriod.Oid.Value, null); - einzel.SetReportDataSource(kaRo); - einzel.CreateDocument(); - anhang2.Pages.AddRange((einzel).Pages); + firstInv[0].ServiceInvoicePeriods.Add(sip); } } } - return (XtraReport)anhang2; } } } - #endregion LWV + ServiceInvoiceRO ro = ServiceInvoiceRO.Create(firstInv[0]); + anhang.SetReportDataSource(ro); + anhang.CreateDocument(); + if (queryOid == 207) // die wollen die Rechnungsvorschau nur in Excel sprich Trennung von Sammelrechnung Spitzabrechnungsreports + { + return (XtraReport)anhang; + } else { - var costBearers = DAOFactory.GenericDAO.GetAllActive(); - var cBBthg = costBearers.Where(c => c.Organisation.Function != null && c.Organisation.Function.Value.ToString().ToLower().Contains("bthg") && c.Organisation.Name != "SELBSTZAHLER").ToList(); - var anhang = new FinanzauswertungTabBthgIntern(); - List firstInv = new List(); - foreach (var cb in cBBthg) - { - var invs = GenerateInitialServiceInvoices(cb.Oid.Value, span); - if (invs != null) - { - if (firstInv.Count == 0) - { - var count = 0; - foreach (var i in invs) - { - count += 1; - if (count > 1 && i.ServiceInvoicePeriods != null && i.ServiceInvoicePeriods.Count > 0) - { - foreach (var sip in i.ServiceInvoicePeriods) - { - invs[0].ServiceInvoicePeriods.Add(sip); - } - } - } - ServiceInvoiceRO roSingle = ServiceInvoiceRO.Create(invs[0]); - if (roSingle.GrossClaim != "0,00 €") - { - firstInv.Add(invs[0]); - } - } - else - { - var count = 0; - foreach (var i in invs) - { - if (i.ServiceInvoicePeriods != null && i.ServiceInvoicePeriods.Count > 0) - { - foreach (var sip in i.ServiceInvoicePeriods) - { - firstInv[0].ServiceInvoicePeriods.Add(sip); - } - } - } - } - } - } - ServiceInvoiceRO ro = ServiceInvoiceRO.Create(firstInv[0]); - anhang.SetReportDataSource(ro); - anhang.CreateDocument(); - if (queryOid == 207) // die wollen die Rechnungsvorschau nur in Excel sprich Trennung von Sammelrechnung Spitzabrechnungsreports - { - return (XtraReport)anhang; - } - else - { - var anhang2 = new LwvKASpitzabrechnung(); - //if (ro.ServiceInvoicePeriods != null && ro.ServiceInvoicePeriods.Count > 0) - //{ - // foreach (var sip in ro.ServiceInvoicePeriods) - // { - // if (sip.ServiceInvoiceItems != null && sip.ServiceInvoiceItems.Count > 1 - // && sip.SupportConceptApprovalPeriod.ServiceCategory.Abbreviation.Substring(sip.SupportConceptApprovalPeriod.ServiceCategory.Abbreviation.Length - 2) == "KA") - // { - // var einzel = new LwvKASpitzabrechnung(); - // var kaRo = LwvKASpitzabrechnungRO.Create(sip.CostBearer2SupportConcept.Oid.Value, ro.AccountingPeriodEnd, sip.SupportConceptApprovalPeriod.Oid.Value, null); - // einzel.SetReportDataSource(kaRo); - // einzel.CreateDocument(); - // anhang2.Pages.AddRange((einzel).Pages); - // } - // } - //} - return (XtraReport)anhang2; - } + var anhang2 = new LwvKASpitzabrechnung(); + //if (ro.ServiceInvoicePeriods != null && ro.ServiceInvoicePeriods.Count > 0) + //{ + // foreach (var sip in ro.ServiceInvoicePeriods) + // { + // if (sip.ServiceInvoiceItems != null && sip.ServiceInvoiceItems.Count > 1 + // && sip.SupportConceptApprovalPeriod.ServiceCategory.Abbreviation.Substring(sip.SupportConceptApprovalPeriod.ServiceCategory.Abbreviation.Length - 2) == "KA") + // { + // var einzel = new LwvKASpitzabrechnung(); + // var kaRo = LwvKASpitzabrechnungRO.Create(sip.CostBearer2SupportConcept.Oid.Value, ro.AccountingPeriodEnd, sip.SupportConceptApprovalPeriod.Oid.Value, null); + // einzel.SetReportDataSource(kaRo); + // einzel.CreateDocument(); + // anhang2.Pages.AddRange((einzel).Pages); + // } + // } + //} + return (XtraReport)anhang2; } } return new XtraReport(); @@ -236,98 +154,6 @@ namespace PerspektivenEV return newInvoices; } - private XtraReport CreateLWVRechnung(long queryOid, string queryReportId) - { - var query = DAOFactory.GenericDAO.LoadByID(queryOid); - - if (query == null) - return new XtraReport(); - - var path = Path.Combine(TempPath, queryReportId + ".xml"); - var table = Utils.XMLDeserialize(path); - var qro = QueryRO.Create(query, table); - - if (qro.Rows.Count > 0) - { - DateTime start = DateTime.Parse(qro.Rows[0].Field1.ToString()); - DateTime end = start.AddMonths(1).AddDays(-1); - DateTimeSpan span = new DateTimeSpan(); - span.StartDate = start; - span.EndDate = end.AddMinutes(-1); - - var invoices = DAOFactory.SearchDAO.GetServiceInvoices(null, span); - - if (invoices.Count > 0) - { - String ids = ""; - ServiceInvoice invoice = null; - if (queryOid == 201) - { - invoice = invoices.Where(i => i.InvoiceBase.RecipientOrganisation == "Landeswohlfahrtsverband Hessen" - && i.InvoiceBase.InvoiceId == "SammelrechnungBthg").OrderByDescending(b => b.InvoiceBase.Oid).FirstOrDefault(); - } - else - { - invoice = invoices.Where(i => i.InvoiceBase.RecipientOrganisation == "Landeswohlfahrtsverband Hessen" - && i.InvoiceBase.InvoiceId == "SammelrechnungBthg").OrderByDescending(b => b.InvoiceBase.Oid).Skip(1).FirstOrDefault(); - } - if (invoice != null) - { - try - { - if (invoice.InvoiceBase.RecipientOrganisation == "Landeswohlfahrtsverband Hessen" && invoice.InvoiceBase.InvoiceId == "SammelrechnungBthg") - { - ids += invoice.Oid; - } - } - catch (Exception e) - { - //Bei gelöschten Costbearer2SupportConcepts kann es zu einem Hibernate Fehler kommen, den ignorieren wir einfach - } - } - - if (!String.IsNullOrEmpty(ids)) - { - var report = CreateServiceInvoiceReportIntern(ids, null); - return (XtraReport)report; - } - } - } - return new XtraReport(); - } - - private object CreateServiceInvoiceReportIntern(string dcId, object p) - { - var oid = long.Parse(dcId); - var invoice = DAOFactory.GenericDAO.LoadByID(oid); - var idc = MapperFactory.ServiceInvoiceDC_ServiceInvoice.MapToNewDC(invoice); - - XtraReport invoiceReport = null; - var anhang = new SammelrechnungTabBthgIntern(); - var ro = ServiceInvoiceRO.Create(idc); - anhang.SetReportDataSource(ro); - anhang.CreateDocument(); - - if (ro.ServiceInvoicePeriods != null && ro.ServiceInvoicePeriods.Count > 0) - { - foreach (var sip in ro.ServiceInvoicePeriods) - { - if (sip.ServiceInvoiceItems != null && sip.ServiceInvoiceItems.Count > 1 - && sip.SupportConceptApprovalPeriod.ServiceCategory.Abbreviation.Substring(sip.SupportConceptApprovalPeriod.ServiceCategory.Abbreviation.Length - 2) == "KA") - { - var anhang2 = new LwvKASpitzabrechnung(); - var kaRo = LwvKASpitzabrechnungRO.Create(sip.CostBearer2SupportConcept.Oid.Value, ro.AccountingPeriodEnd, sip.SupportConceptApprovalPeriod.Oid.Value, null); - anhang2.SetReportDataSource(kaRo); - anhang2.CreateDocument(); - ((XtraReport)anhang).Pages.AddRange(((XtraReport)anhang2).Pages); - } - } - } - invoiceReport = anhang as XtraReport; - - return invoiceReport; - } - public override XtraReport CreateServiceInvoiceReport(string dcIds, long? invoiceBaseOid) { if (String.IsNullOrEmpty(dcIds) && invoiceBaseOid.HasValue)