diff --git a/ReportImp/PerspektivenEV/Invoicing/CollectiveInvoiceCreationBthg.cs b/ReportImp/PerspektivenEV/Invoicing/CollectiveInvoiceCreationBthg.cs index 42d2e7c7a..7e9214e43 100644 --- a/ReportImp/PerspektivenEV/Invoicing/CollectiveInvoiceCreationBthg.cs +++ b/ReportImp/PerspektivenEV/Invoicing/CollectiveInvoiceCreationBthg.cs @@ -277,7 +277,7 @@ namespace PerspektivenEV.Invoicing if (eAnteil != null) { var app = eAnteil.ApprovalPeriodList.Where(a => a.StartDate <= start && a.EndDate >= end).FirstOrDefault(); - if (app.ServiceCategory.Name == cat.Name) + if (app != null && app.ServiceCategory.Name == cat.Name) { ii.UnitDescription = String.Format("{0:0.00} €", app.ApprovedFixedAmount); ii.AmountTotal = ii.AmountTotal - app.ApprovedFixedAmount; diff --git a/ReportImp/PerspektivenEV/Invoicing/CustomInvoiceCreation.cs b/ReportImp/PerspektivenEV/Invoicing/CustomInvoiceCreation.cs index 1541a2e8f..0b37e3c9c 100644 --- a/ReportImp/PerspektivenEV/Invoicing/CustomInvoiceCreation.cs +++ b/ReportImp/PerspektivenEV/Invoicing/CustomInvoiceCreation.cs @@ -23,6 +23,9 @@ namespace PerspektivenEV.Invoicing private DateTime? accountingPeriodStart = null; private DateTime? accountingPeriodEnd = null; private const decimal AMOUNT_PER_KM = 0.35m; + private decimal AMOUNT_PER_KMQA = 0.0231m; + private decimal AMOUNT_PER_KMKA = 0.0108m; + bool bthg = false; public override void SetInvoiceBaseData(int invoiceCounter, ServiceInvoice invoice, CostBearer costBearer, DateTimeSpan invoicePeriod, IList supportConceptList) @@ -32,6 +35,23 @@ namespace PerspektivenEV.Invoicing accountingPeriodStart = invoicePeriod.StartDate; accountingPeriodEnd = invoicePeriod.EndDate; } + if (costBearer.Organisation.Function.Value.ToLower().Contains("bthg")) + { + bthg = true; + //Einmaliges Laden der Preise um nicht bei jeder Bewilligung neu zu starten + var preise = DAOFactory.GenericDAO.GetAllActive(); + var pauschVar = GetPreis(preise, "BW FFM SZ QA Fahrzeit pro Minute", (DateTime)accountingPeriodStart); + if (pauschVar != 0) + { + AMOUNT_PER_KMQA = pauschVar; + } + pauschVar = 0; + pauschVar = GetPreis(preise, "BW FFM SZ KA Fahrzeit pro Minute", (DateTime)accountingPeriodStart); + if (pauschVar != 0) + { + AMOUNT_PER_KMKA = pauschVar; + } + } base.SetInvoiceBaseData(invoiceCounter, invoice, costBearer, invoicePeriod, supportConceptList); } @@ -80,7 +100,9 @@ namespace PerspektivenEV.Invoicing } } else + { base.SetRecipientInformation(serviceInvoice, costBearer); + } } public override void SetServiceInvoicePeriods(ServiceInvoice invoice, CostBearer2SupportConcept costBearer2SupportConcept, DateTimeSpan invoicePeriod, List serviceRecords) @@ -92,7 +114,6 @@ namespace PerspektivenEV.Invoicing base.SetServiceInvoicePeriods(invoice, costBearer2SupportConcept, invoicePeriod, serviceRecords); } - public override IList CreateSummaryInvoiceItems(IList itemList, DateTimeSpan invoicePeriod, SupportConceptApprovalPeriod scap, Calculations calc, bool summaryPerMonth, bool addRateFactorToUnitCount) { @@ -275,17 +296,19 @@ namespace PerspektivenEV.Invoicing { if (scap.CostBearer2SupportConcept.CostBearer.Organisation.Name == "SELBSTZAHLER") { - var fpauitem = CreateFahrtpauschaleInvoiceItem(list, scap); + var fpauitem = CreateFahrtpauschaleInvoiceItem(list, scap, serviceRecordsInPeriod); if (fpauitem != null) { list.Add(fpauitem); } } } - - var fitem = CreateFahrkostenInvoiceItem(serviceRecordsInPeriod, scap, calc); - if (fitem != null) - list.Add(fitem); + else + { + var fitem = CreateFahrkostenInvoiceItem(serviceRecordsInPeriod, scap, calc); + if (fitem != null) + list.Add(fitem); + } } return list; } @@ -319,7 +342,7 @@ namespace PerspektivenEV.Invoicing invoiceItem.AmountPerUnit = Math.Round((decimal)data[0].AmountTotal, 2, MidpointRounding.AwayFromZero); invoiceItem.AmountTotal = ((decimal)(end - start).TotalDays + 1) * price; invoiceItem.GrossAmountTotal = ((decimal)(end - start).TotalDays + 1) * price; - invoiceItem.ItemDescription = "Ges.vorgehaltene Flächen"; + invoiceItem.ItemDescription = "Ges. vorg. Flächen"; return invoiceItem; } @@ -413,21 +436,26 @@ namespace PerspektivenEV.Invoicing return null; } - private InvoiceItem CreateFahrtpauschaleInvoiceItem(IList list, SupportConceptApprovalPeriod scap) + private InvoiceItem CreateFahrtpauschaleInvoiceItem(IList list, SupportConceptApprovalPeriod scap, List serviceRecordsInPeriod) { decimal gesamt = 0; - foreach (var ii in list) + foreach (var sr in serviceRecordsInPeriod) { - if (!ii.ItemDescription.Contains("Anfahrt")) - { - gesamt += ii.GrossAmountTotal ?? 0; - } + if (!sr.ServiceDescription.Name.Contains("Anfahrt")) + gesamt += sr.RoundedDuration; } if (gesamt > 0) { var invoiceItem = new InvoiceItem(); - invoiceItem.AmountPerUnit = 0.1405m; + if (scap.ServiceCategory.Name.ToLower().Contains("qa")) + { + invoiceItem.AmountPerUnit = AMOUNT_PER_KMQA; + } + else + { + invoiceItem.AmountPerUnit = AMOUNT_PER_KMKA; + } invoiceItem.UnitCount = gesamt; invoiceItem.UnitDescription = "Prozent"; invoiceItem.AmountTotal = invoiceItem.UnitCount * invoiceItem.AmountPerUnit; @@ -435,7 +463,7 @@ namespace PerspektivenEV.Invoicing invoiceItem.ItemPeriodStart = accountingPeriodStart; invoiceItem.ItemPeriodEnd = accountingPeriodEnd; invoiceItem.GrossAmountTotal = invoiceItem.AmountTotal; - invoiceItem.ItemDescription = "Fahrtkostenpauschale"; + invoiceItem.ItemDescription = "Fahrtzeitenpauschale"; if (scap != null) invoiceItem.SupportConceptApprovalPeriodOid = scap.Oid; @@ -446,8 +474,7 @@ namespace PerspektivenEV.Invoicing public override void CheckMaxApprovedAmount(ServiceInvoice invoice, ServiceInvoicePeriod sip, SupportConceptApprovalPeriodDC scap, CostBearer2SupportConcept costBearer2SupportConcept, DateTimeSpan invoicePeriod, List serviceRecords) { - - if (sip.InvoiceItemList.Any(i => i.ItemDescription.Contains("Tagesstättentage") || i.ItemDescription.Contains("vorgehaltene"))) + if (bthg || sip.InvoiceItemList.Any(i => i.ItemDescription.Contains("Tagesstättentage") || i.ItemDescription.Contains("vorgehaltene"))) { // do nothing } @@ -478,5 +505,21 @@ namespace PerspektivenEV.Invoicing } } } + + private static decimal GetPreis(IList allePreise, String name, DateTime datum) + { + var pausch = allePreise.Where(p => p.Name.Contains(name)).FirstOrDefault(); + if (pausch != null) + { + var crlist = MapperFactory.CostRatePeriodDC_CostRatePeriod.MapToNewDCs(pausch.CostRatePeriods); + + var cr = crlist.GetCostRatePeriodForDate(CostRatePeriodType.AmountOfMoney, datum); + if (cr != null && cr.CostRateValue.HasValue) + { + return cr.CostRateValue.Value; + } + } + return 0; + } } } \ No newline at end of file diff --git a/ReportImp/PerspektivenEV/ServiceInvoiceReport.Designer.cs b/ReportImp/PerspektivenEV/ServiceInvoiceReport.Designer.cs index fadab09c7..31acaab11 100644 --- a/ReportImp/PerspektivenEV/ServiceInvoiceReport.Designer.cs +++ b/ReportImp/PerspektivenEV/ServiceInvoiceReport.Designer.cs @@ -73,8 +73,8 @@ namespace PerspektivenEV this.lblUeberweisung = new DevExpress.XtraReports.UI.XRLabel(); this.lblAnlage = new DevExpress.XtraReports.UI.XRLabel(); this.lblUeberweisungPfk = new DevExpress.XtraReports.UI.XRLabel(); - this.PageHeader = new DevExpress.XtraReports.UI.PageHeaderBand(); this.bindingSource1 = new System.Windows.Forms.BindingSource(this.components); + this.PageHeader = new DevExpress.XtraReports.UI.PageHeaderBand(); ((System.ComponentModel.ISupportInitialize)(this.xrTable1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.xrTable6)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.xrTable2)).BeginInit(); @@ -446,7 +446,7 @@ namespace PerspektivenEV this.xrTableCell46.BorderColor = System.Drawing.Color.DarkGray; this.xrTableCell46.Borders = DevExpress.XtraPrinting.BorderSide.None; this.xrTableCell46.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] { - new DevExpress.XtraReports.UI.XRBinding("Text", null, "ServiceInvoicePeriods.ServiceInvoiceItems.HourlyRate", "{0:c2}")}); + new DevExpress.XtraReports.UI.XRBinding("Text", null, "ServiceInvoicePeriods.ServiceInvoiceItems.HourlyRate", "{0:c4}")}); this.xrTableCell46.Font = new System.Drawing.Font("Calibri", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.xrTableCell46.Name = "xrTableCell46"; this.xrTableCell46.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 2, 2, 100F); @@ -662,15 +662,15 @@ namespace PerspektivenEV this.lblUeberweisungPfk.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleLeft; this.lblUeberweisungPfk.Visible = false; // + // bindingSource1 + // + this.bindingSource1.DataSource = typeof(BeWo.Report.ReportObjects.ServiceInvoiceRO); + // // PageHeader // this.PageHeader.HeightF = 168.75F; this.PageHeader.Name = "PageHeader"; // - // bindingSource1 - // - this.bindingSource1.DataSource = typeof(BeWo.Report.ReportObjects.ServiceInvoiceRO); - // // ServiceInvoiceReport // this.Bands.AddRange(new DevExpress.XtraReports.UI.Band[] { diff --git a/ReportImp/PerspektivenEV/ServiceInvoiceReport.cs b/ReportImp/PerspektivenEV/ServiceInvoiceReport.cs index 809f9bae4..0bf5d835c 100644 --- a/ReportImp/PerspektivenEV/ServiceInvoiceReport.cs +++ b/ReportImp/PerspektivenEV/ServiceInvoiceReport.cs @@ -22,6 +22,12 @@ namespace PerspektivenEV { DateTime start = pRO.AccountingPeriodStart; DateTime end = pRO.AccountingPeriodEnd; + bool bthg = false; + String f = GetFunction(pRO); + if (f.ToLower().Contains("bthg")) + { + bthg = true; + } string poBox = null; if (pRO.InvoiceBase.RecipientContactInformations.Count > 0) @@ -121,33 +127,68 @@ namespace PerspektivenEV { if (i.ServiceDescription != null) { - if (!i.ServiceDescription.Contains("Pauschale")) + if (bthg) // Stand ab Juli 2023 ohne PFK + { + lblUeberschrift.Text = "Angef. Einheiten"; i.Duration = String.Format("{0:0.00}", i.Hours); - else - { - lblUeberschrift.Text = "Zeitraum"; - lblAnlage.Text = ""; - if (start.Month == end.Month && start.Year == end.Year) - i.Duration = String.Format("{0:MMMM yyyy}", start); + + if (!i.ServiceDescription.Contains("Anfahrt") && !i.ServiceDescription.ToLower().Contains("pauschale") + && !i.ServiceDescription.Contains("Terminabsage") && !i.ServiceDescription.Contains("Eigenanteil") + && !i.ServiceDescription.Contains("Tagesstättentage") && !i.ServiceDescription.Contains("Flächen")) + { + if (start.Month == end.Month && start.Year == end.Year) + { + i.ServiceDescription = String.Format("{0:MMMM yyyy}", start); + } + else + { + i.ServiceDescription = String.Format("{0:MMMM yyyy} - {1:MMMM yyyy}", start, end); + } + } + else if (i.ServiceDescription.Contains("Anfahrt")) + { + if (start.Month == end.Month && start.Year == end.Year) + { + i.ServiceDescription = "Anfahrt(en)"; + } + } + else if (i.ServiceDescription.Contains("Terminabsage")) + { + if (start.Month == end.Month && start.Year == end.Year) + i.ServiceDescription = "Terminabsage"; + } } - if (!i.ServiceDescription.Contains("Anfahrt") && !i.ServiceDescription.Contains("Handgeld") && !i.ServiceDescription.ToLower().Contains("pauschale") - && !i.ServiceDescription.Contains("gefahren") && !i.ServiceDescription.Contains("Terminabsage") && !i.ServiceDescription.Contains("Eigenanteil") - && !i.ServiceDescription.Contains("Tagesstättentage") && !i.ServiceDescription.Contains("vorgehaltene")) + else //alte Bedingungen und PFK { - if (start.Month == end.Month && start.Year == end.Year) - i.ServiceDescription = String.Format("{0:MMMM yyyy}", start); + if (!i.ServiceDescription.Contains("Pauschale")) + { + i.Duration = String.Format("{0:0.00}", i.Hours); + } else - i.ServiceDescription = String.Format("{0:MMMM yyyy} - {1:MMMM yyyy}", start, end); - } - else if (i.ServiceDescription.Contains("Anfahrt")) - { - if (start.Month == end.Month && start.Year == end.Year) - i.ServiceDescription = "Anfahrt(en)"; - } - else if (i.ServiceDescription.Contains("Terminabsage")) - { - if (start.Month == end.Month && start.Year == end.Year) - i.ServiceDescription = "Terminabsage"; + { + lblUeberschrift.Text = "Zeitraum"; + lblAnlage.Text = ""; + if (start.Month == end.Month && start.Year == end.Year) + i.Duration = String.Format("{0:MMMM yyyy}", start); + } + if (!i.ServiceDescription.Contains("Anfahrt") && !i.ServiceDescription.Contains("Handgeld") && !i.ServiceDescription.ToLower().Contains("pauschale") + && !i.ServiceDescription.Contains("gefahren") && !i.ServiceDescription.Contains("Terminabsage") && !i.ServiceDescription.Contains("Eigenanteil")) + { + if (start.Month == end.Month && start.Year == end.Year) + i.ServiceDescription = String.Format("{0:MMMM yyyy}", start); + else + i.ServiceDescription = String.Format("{0:MMMM yyyy} - {1:MMMM yyyy}", start, end); + } + else if (i.ServiceDescription.Contains("Anfahrt")) + { + if (start.Month == end.Month && start.Year == end.Year) + i.ServiceDescription = "Anfahrt(en)"; + } + else if (i.ServiceDescription.Contains("Terminabsage")) + { + if (start.Month == end.Month && start.Year == end.Year) + i.ServiceDescription = "Terminabsage"; + } } } } @@ -225,5 +266,15 @@ namespace PerspektivenEV } } } + + private String GetFunction(ServiceInvoiceRO pRO) + { + if (pRO.InvoiceBase != null && pRO.InvoiceBase.SupportConceptCostBearerRelDc != null) + { + var c2s = pRO.InvoiceBase.SupportConceptCostBearerRelDc; + return c2s.CostBearer.Function; + } + return null; + } } } \ No newline at end of file