diff --git a/ReportImp/WhbRefrath/Invoicing/AssistenzInvoiceCreation.cs b/ReportImp/WhbRefrath/Invoicing/AssistenzInvoiceCreation.cs new file mode 100644 index 000000000..58c5d5111 --- /dev/null +++ b/ReportImp/WhbRefrath/Invoicing/AssistenzInvoiceCreation.cs @@ -0,0 +1,98 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using BeWo.Data.Access; +using BeWo.Data.Entities; +using BeWo.Service.DCEntityMapper; +using BeWo.Service.Invoicing; +using BeWo.Service.Plugins; +using BS.Shared; +using BS.Shared.Core; +using BS.Shared.DataContracts; +using BS.Shared.Extensions; +using BS.Shared.Services; + +namespace WhbRefrath.Invoicing +{ + + public class CustomAssistenzInvoiceCreation : InvoiceCreation + { + public override void SetInvoiceId(ServiceInvoice invoice) + { + invoice.InvoiceBase.InvoiceId = "Assistenz"; + invoice.InvoiceBase.InvoiceTypeText = "Assistenzleistung"; + } + + public override void SetAmountAdvancePayments(ServiceInvoice invoice) + { + //do nothing + } + + public override void SetAmountEquityContribution(ServiceInvoice invoice) + { + //do nothing + } + + public override InvoiceItem CreateInvoiceItem(ServiceRecordDC iServiceRecord, SupportConceptApprovalPeriod scap, Calculations calc) + { + if (!iServiceRecord.ServiceDescription.CategoryName.Contains("Assistenz")) + return null; + + var ii = base.CreateInvoiceItem(iServiceRecord, scap, calc); + ii.ItemDescription = "Assistenzleistung"; + return ii; + } + + public override void SetInvoiceItems(ServiceInvoice invoice, + ServiceInvoicePeriod serviceInvoicePeriod, + SupportConceptApprovalPeriodDC supportConceptApprovalPeriod, + CostBearer2SupportConcept cb2sc, + DateTimeSpan invoicePeriod, + List serviceRecords) + { + Calculations calc = PluginLoader.FindClass(_SpecificID) ?? Calculations.GetInstance(_SpecificID); + + if (ShouldCreateFixedAmounts(serviceInvoicePeriod, supportConceptApprovalPeriod, cb2sc)) + { + CreateFixedAmounts(serviceInvoicePeriod, supportConceptApprovalPeriod, cb2sc); + } + else + { + List serviceRecordsInPeriod = serviceRecords.Where( + i => + { + bool valid = i.Start.Value.InBetween(serviceInvoicePeriod.Start.Value, + serviceInvoicePeriod.End.Value, true); + + if (valid && serviceInvoicePeriod.SupportConceptApprovalPeriod != null && serviceInvoicePeriod.SupportConceptApprovalPeriod.ServiceCategory != null) + valid = serviceInvoicePeriod.SupportConceptApprovalPeriod.ServiceCategory.Oid == + i.ServiceDescription.Category.ServiceCategoryOid; + return valid; + }).ToList(); + + if (serviceRecordsInPeriod.Count > 0) + { + var absenceTimes = MapperFactory.AbsenceTimeDC_AbsenceTime.MapToNewDCs(cb2sc.SupportConcept.Customer.AbsenceTimes); + Dictionary span2Hours = calc.GetAbsencesTimesNotBillable(absenceTimes); + + // serviceInvoicePeriod.HoursNotBillableAbsence - eingeschränkte Anzahl bei Abwesenheit GILT laut LVR ausdrücklich nicht bei Assistenzleistungen + serviceInvoicePeriod.HoursNotBillableNotApproved += + calc.GetHoursNotBillableDueToMoreThanApproved(supportConceptApprovalPeriod, + cb2sc.CostBearer.CostRatePeriods.MapToNewDCs(), + serviceRecordsInPeriod, + true, true); + + var itemList = CreateInvoiceItems(serviceRecordsInPeriod, invoicePeriod, serviceInvoicePeriod.SupportConceptApprovalPeriod, calc); + serviceInvoicePeriod.InvoiceItemList.AddRange(itemList); + } + } + } + + public override IList CreateSummaryInvoiceItems(IList itemList, DateTimeSpan invoicePeriod, SupportConceptApprovalPeriod scap, + Calculations calc, bool summaryPerMonth, bool addRateFactorToUnitCount) + { + return base.CreateSummaryInvoiceItems(itemList, invoicePeriod, scap, calc, false, true); + } + } +} diff --git a/ReportImp/WhbRefrath/Invoicing/CustomInvoiceFactory.cs b/ReportImp/WhbRefrath/Invoicing/CustomInvoiceFactory.cs new file mode 100644 index 000000000..950fdd665 --- /dev/null +++ b/ReportImp/WhbRefrath/Invoicing/CustomInvoiceFactory.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using BeWo.Service.Invoicing; +using BS.Shared.DataContracts; +using BS.Shared.DataContracts.Compact; + +namespace WhbRefrath.Invoicing +{ + public class CustomInvoiceFactory : InvoiceFactory + { + public override InvoiceCreation CreateInvoiceCreator(string specificId, string tenant, Dictionary> supportConcepts2ServiceRecords) + { + foreach (var list in supportConcepts2ServiceRecords.Values) + { + foreach (var sr in list) + { + var sd = sr.ServiceDescription.Category; + var ic = GetInvoiceCreatorForCategory(sd); + if (ic != null) + return ic; + } + } + return base.CreateInvoiceCreator(specificId, tenant, supportConcepts2ServiceRecords); + } + + private InvoiceCreation GetInvoiceCreatorForCategory(ServiceCategoryDC sd) + { + if (sd != null && !String.IsNullOrEmpty(sd.Name)) + { + String cat = sd.Name.ToLower().Trim(); + if (cat.IndexOf("assistenz") >= 0) + return new CustomAssistenzInvoiceCreation(); + } + return null; + } + } +} diff --git a/ReportImp/WhbRefrath/Invoicing/SettlementInvoiceCreation.cs b/ReportImp/WhbRefrath/Invoicing/SettlementInvoiceCreation.cs new file mode 100644 index 000000000..2308ca4bc --- /dev/null +++ b/ReportImp/WhbRefrath/Invoicing/SettlementInvoiceCreation.cs @@ -0,0 +1,74 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using BeWo.Data.Entities; +using BeWo.Service.DCEntityMapper; +using BeWo.Service.Invoicing; +using BS.Shared; +using BS.Shared.Core; +using BS.Shared.DataContracts; +using BS.Shared.Extensions; +using BS.Shared.Services; + +namespace WhbRefrath.Invoicing +{ + + public class CustomSettlementInvoiceCreation : SettlementInvoiceCreation + { + public override bool CanCreateInvoiceTheOldWay(Settlement2DC si, CostBearer2SupportConcept c2s) + { + var relDC = c2s.MapToNewDC(); + + DateTime start = si.AccountingPeriodStart.Value.Date; + DateTime end = si.AccountingPeriodEnd.Value.Date; + if (c2s.SupportConcept.Customer.TerminationDate.HasValue && + c2s.SupportConcept.Customer.TerminationDate.Value < end) + end = c2s.SupportConcept.Customer.TerminationDate.Value; + if (end > DateTime.Now) + { + var srList = c2s.ServiceRecords; + var max = srList.Max(s => s.End); + + if (max.HasValue && max < end) + end = max.Value; + } + + var hourlyRatesInSpanList = relDC.CostBearer.CostRatePeriods.GetSpans(CostRatePeriodType.HourlyRate, start, end).ToList(); + if (hourlyRatesInSpanList.Count > 3) + return false; + + var factorInSpanList = relDC.CostBearer.CostRatePeriods.GetSpans(CostRatePeriodType.RateFactor, start, end).ToList(); + if (factorInSpanList.Count > 1) + return false; + + return true; + } + + public override bool IsServiceRecordBillable(ServiceRecord iRecord) + { + if (iRecord.ServiceDescription.ServiceCategory.Name.Contains("Assistenz")) + return false; + + return true; + } + + public override void CalculateSettlementInvoiceApprovedAmounts(Settlement2DC si, SupportConceptCostBearerRelDC relDC, Calculations calc) + { + si.ApprovedFLSWeekly = 0; + si.ApprovedFLS = 0; + foreach (var sp in relDC.ApprovalPeriodList) + { + if (sp.ServiceCategory == null || !sp.ServiceCategory.Name.Contains("Assistenz")) + { + si.ApprovedFLSWeekly += calc.GetApprovedHoursPerWeek(sp, relDC.CostBearer.CostRatePeriods) ?? 0m; + + decimal flsTotal = calc.GetApprovedHoursTotal(sp, relDC.CostBearer.CostRatePeriods) ?? 0m; + flsTotal = Math.Round(flsTotal, 2, MidpointRounding.AwayFromZero); + + si.ApprovedFLS += flsTotal; + } + } + } + } +} diff --git a/ReportImp/WhbRefrath/ServiceInvoiceReport.cs b/ReportImp/WhbRefrath/ServiceInvoiceReport.cs index 6f53a080d..aaaf5063f 100644 --- a/ReportImp/WhbRefrath/ServiceInvoiceReport.cs +++ b/ReportImp/WhbRefrath/ServiceInvoiceReport.cs @@ -69,6 +69,23 @@ namespace WhbRefrath lblBetreff.Visible = false; } + if (pRO.ServiceInvoicePeriods != null && pRO.ServiceInvoicePeriods.Count > 0) + { + foreach (var p in pRO.ServiceInvoicePeriods) + { + if (p.ServiceInvoiceItems != null && p.ServiceInvoiceItems.Count > 0) + { + foreach (var i in p.ServiceInvoiceItems) + { + if (i.ServiceDescription.ToLower().Contains("assistenz")) + { + lblBetreff.Text = lblBetreff.Text.Replace("Betreuungsleistungen", "Assistenzleistungen"); + } + } + } + } + } + SetzeAnrede(pRO); this.bindingSource1.DataSource = pRO; diff --git a/ReportImp/WhbRefrath/SettlementReport.cs b/ReportImp/WhbRefrath/SettlementReport.cs index 6f2f55790..361d46019 100644 --- a/ReportImp/WhbRefrath/SettlementReport.cs +++ b/ReportImp/WhbRefrath/SettlementReport.cs @@ -108,7 +108,7 @@ namespace WhbRefrath.Alt } } var cb2sc = DAOFactory.GenericDAO.LoadByID(pRO.CostBearer2SupportConceptOid); - if (!String.IsNullOrEmpty(pRO.RecipientContactPerson) && cb2sc.CostBearerContactPerson.Sex.HasValue) + if (!String.IsNullOrEmpty(pRO.RecipientContactPerson) && cb2sc.CostBearerContactPerson != null && cb2sc.CostBearerContactPerson.Sex.HasValue) { if (cb2sc.CostBearerContactPerson.Sex.Value == Sex.Female) lblAnrede.Text = "Sehr geehrte Frau " + cb2sc.CostBearerContactPerson.LastName.Trim() + ","; diff --git a/ReportImp/WhbRefrath/WhbRefrath.csproj b/ReportImp/WhbRefrath/WhbRefrath.csproj index 8d10a3ee9..2dcdbe2af 100644 --- a/ReportImp/WhbRefrath/WhbRefrath.csproj +++ b/ReportImp/WhbRefrath/WhbRefrath.csproj @@ -1,115 +1,119 @@ - - - - - Debug - AnyCPU - {375E3B1B-633A-477B-B0CF-C3A430B4A62D} - Library - Properties - WhbRefrath - 2976949196_Reports - v4.7.2 - 512 - - - - true - full - false - ..\..\Host\bin\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - ..\..\Host\bin\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - - - - - Component - - - Quittierungsbeleg.cs - - - Component - - - ServiceInvoiceReport.cs - - - Component - - - SettlementReport.cs - - - Component - - - SettlementReport2.cs - - - - - {B0D73E3D-4AE7-4024-93A6-DB1F46D7CCEE} - Data - - - {40d8b312-ea64-49e3-a31a-5e57ed4d5654} - Report - - - {094331c3-ecee-4c89-bbfd-4c9ded89f0ef} - Service - - - {2f50b83d-a3f0-4ec4-979a-3f9b7e3d8ed4} - Shared - - - - - - Quittierungsbeleg.cs - Designer - - - ServiceInvoiceReport.cs - Designer - - - SettlementReport.cs - Designer - - - SettlementReport2.cs - Designer - - - + + + + + Debug + AnyCPU + {375E3B1B-633A-477B-B0CF-C3A430B4A62D} + Library + Properties + WhbRefrath + 2976949196_Reports + v4.7.2 + 512 + + + + true + full + false + ..\..\Host\bin\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + ..\..\Host\bin\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + + + + Component + + + Quittierungsbeleg.cs + + + Component + + + ServiceInvoiceReport.cs + + + Component + + + SettlementReport.cs + + + Component + + + SettlementReport2.cs + + + + + {B0D73E3D-4AE7-4024-93A6-DB1F46D7CCEE} + Data + + + {40d8b312-ea64-49e3-a31a-5e57ed4d5654} + Report + + + {094331c3-ecee-4c89-bbfd-4c9ded89f0ef} + Service + + + {2f50b83d-a3f0-4ec4-979a-3f9b7e3d8ed4} + Shared + + + + + + Quittierungsbeleg.cs + Designer + + + ServiceInvoiceReport.cs + Designer + + + SettlementReport.cs + Designer + + + SettlementReport2.cs + Designer + + + + \ No newline at end of file