diff --git a/ReportImp/AkkuratDienstleistungsgesellschaft/Export/AddisonExporter.cs b/ReportImp/AkkuratDienstleistungsgesellschaft/Export/AddisonExporter.cs index d855acb4f..87cbc549c 100644 --- a/ReportImp/AkkuratDienstleistungsgesellschaft/Export/AddisonExporter.cs +++ b/ReportImp/AkkuratDienstleistungsgesellschaft/Export/AddisonExporter.cs @@ -319,7 +319,7 @@ namespace Akkurat.Export INNER JOIN `servicecategory` sc ON sd.`ServiceCategoryOid` = sc.`Oid` WHERE sr2.`StartDate` >= ':Monat_Start' AND sr2.`StartDate` < ':Monat_End' AND sc.`Billable` = 1 and sd.Name = 'Fehlkontakt' GROUP BY sr2.`CostBearer2SupportConceptOid`) AS sr ON sr.`CostBearer2SupportConceptOid` = cb2sc.`Oid` - WHERE c.`IsActive` = 1 AND sc.`IsActive` = 1 and org.Name = 'LVR' and (sr.`GeleisteteFLM` is not null)))qry + WHERE c.`IsActive` <> 0 AND sc.`IsActive` <> 0 and org.Name = 'LVR' and (sr.`GeleisteteFLM` is not null)))qry GROUP BY qry.OID ORDER BY qry.Verwendung "; diff --git a/ReportImp/LebenshilfeBadKreuznachFUD/Export/SageExporter.cs b/ReportImp/LebenshilfeBadKreuznachFUD/Export/SageExporter.cs index e67c62218..ad928120c 100644 --- a/ReportImp/LebenshilfeBadKreuznachFUD/Export/SageExporter.cs +++ b/ReportImp/LebenshilfeBadKreuznachFUD/Export/SageExporter.cs @@ -77,10 +77,11 @@ ib.AccountingPeriodEnd, //sb.AppendLine("Buchungsdatum; Belegdatum; Belegnummer; Buchungstext; Sollkonto; Habenkonto; Umsatz; Währung; Steuerart; Steuercode; " + // "Kostenstelle Soll; Kostenstelle Haben; Kostenträger Soll; Kostenträger Haben; Kostenart; Buchungskreis"); var dt = ExecuteQuery(sql, date, teamname); - + String LastKonto = ""; StringBuilder sb = new StringBuilder(); - foreach (DataRow row in dt.Rows) + for (int i = 0; i < dt.Rows.Count; i++) { + var row = dt.Rows[i]; if (sb.Length > 0) { sb.AppendLine(); @@ -101,12 +102,23 @@ ib.AccountingPeriodEnd, { hbnKto = "S82025"; } + // Samstagszuschläge gehören immer auf das gleiche Konto wie die andere Buchung + else if (row[8].ToString() != null && (row[8].ToString().ToLower().Contains("zuschlag") || + !row[8].ToString().ToLower().Contains("q1") && !row[8].ToString().ToLower().Contains("q2")) && i > 0) + { + if (dt.Rows[i-1][1].ToString() == row[1].ToString() && LastKonto.IsNotNullOrEmpty()) + { + hbnKto = LastKonto; + } + } + LastKonto = hbnKto; sb.Append(String.Format("{0}", hbnKto)); // Habenkonto sb.Append(";"); sb.Append(String.Format("{0:0.00}", row[3])); sb.Append(";EUR;;;"); - sb.Append("T70400"); // Kostenstelle (String.Format("{0}", row[9])); - sb.Append(";;;;;12"); // Buchungskreis + sb.Append("T70400;"); // Kostenstelle (String.Format("{0}", row[9])); + sb.Append("T70400;"); // Kostenstelle Haben (String.Format("{0}", row[9])); + sb.Append(";;;12"); // Buchungskreis } return sb.ToString(); @@ -142,7 +154,7 @@ inner join serviceinvoice si on si.invoicebaseoid = ib.oid inner join serviceinvoiceperiod sip on sip.serviceinvoiceoid = si.oid inner join invoiceitem ii on ii.serviceinvoiceperiodoid = sip.oid WHERE ib.`AccountingPeriodEnd` >= ':Monat_Start' AND ib.`AccountingPeriodEnd` < ':Monat_End' and ib.IsActive = 1 -ORDER BY p.`LastName`, p.`FirstName`, cb2sc.`ApprovedStartDate`) AS sqry +ORDER BY p.`LastName`, p.`FirstName`, cb2sc.`ApprovedStartDate`, ii.GrossAmountTotal desc) AS sqry WHERE Team = ':teamname' "; diff --git a/ReportImp/LebenshilfeBadKreuznachFUD/Invoicing/CustomInvoiceCreation.cs b/ReportImp/LebenshilfeBadKreuznachFUD/Invoicing/CustomInvoiceCreation.cs index c5b017550..5260b6fc9 100644 --- a/ReportImp/LebenshilfeBadKreuznachFUD/Invoicing/CustomInvoiceCreation.cs +++ b/ReportImp/LebenshilfeBadKreuznachFUD/Invoicing/CustomInvoiceCreation.cs @@ -18,6 +18,12 @@ namespace LebenshilfeBadKreuznachFUD.Invoicing // weitgehend normal, für Entlastung kommt eine Hausbesuchspauschale und für Q1 KANN eine Wegevergütung hinzugefügt werden public class CustomInvoiceCreation : InvoiceCreation { + public override void SetInvoiceBaseData(int invoiceCounter, ServiceInvoice invoice, CostBearer costBearer, DateTimeSpan invoicePeriod, IList supportConceptList) + { + base.SetInvoiceBaseData(invoiceCounter, invoice, costBearer, invoicePeriod, supportConceptList); + invoice.InvoiceBase.InvoiceDate = invoice.InvoiceBase.AccountingPeriodEnd; + } + public override ServiceInvoicePeriod CreateServiceInvoicePeriod(SupportConceptApprovalPeriodDC approvalPeriodDC, DateTimeSpan invoiceAccountingPeriodSpan) { var sip = new ServiceInvoicePeriod diff --git a/ReportImp/MalteserJohanniterJohanneshaus/Import/CustomDataImporter.cs b/ReportImp/MalteserJohanniterJohanneshaus/Import/CustomDataImporter.cs new file mode 100644 index 000000000..a3398f7ad --- /dev/null +++ b/ReportImp/MalteserJohanniterJohanneshaus/Import/CustomDataImporter.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using BeWo.Data.Access; +using BeWo.Data.Entities; +using BeWo.Service.Core; +using BeWo.Service.Import.AvisImport; +using BeWo.Service.Plugins; +using BS.Shared.Core; +using BS.Shared.DataContracts; +using Utils = BS.Shared.Core.Utils; + +namespace MalteserJohanniterJohanneshaus.Import +{ + public class CustomLvrAviseImporter : LvrAviseImporter + { + public override List CreateHilfeplanInfos() + { + List liste = new List(); + var scList = DAOFactory.GenericDAO.GetAllActiveAndArchived(); + + foreach (var supportConcept in scList) + { + foreach (var cb2sc in supportConcept.CostBearer2SupportConceptList) + { + if (cb2sc.Notice == "60") + { + HilfeplanInfo hi = new HilfeplanInfo(); + hi.Start = cb2sc.StartDate; + hi.Ende = cb2sc.EndDate; + hi.Aktenzeichen = cb2sc.CustomerReferenceNumber; + hi.CostBearer2SupportConcept = cb2sc; + hi.CustomerFirstName = cb2sc.SupportConcept.Customer.Person.FirstName; + hi.CustomerLastName = cb2sc.SupportConcept.Customer.Person.LastName; + + if (hi.Start.HasValue && hi.Ende.HasValue && !String.IsNullOrEmpty(hi.Aktenzeichen)) + { + liste.Add(hi); + } + } + } + } + + return liste; + } + } +} diff --git a/ReportImp/MalteserJohanniterJohanneshaus/MalteserJohanniterJohanneshaus.csproj b/ReportImp/MalteserJohanniterJohanneshaus/MalteserJohanniterJohanneshaus.csproj index 903d997e4..56934256d 100644 --- a/ReportImp/MalteserJohanniterJohanneshaus/MalteserJohanniterJohanneshaus.csproj +++ b/ReportImp/MalteserJohanniterJohanneshaus/MalteserJohanniterJohanneshaus.csproj @@ -91,6 +91,7 @@ Finanzauswertung.cs + Component diff --git a/ReportImp/MuenchenerAidsHilfeEV/Invoicing/CustomInvoiceCreation.cs b/ReportImp/MuenchenerAidsHilfeEV/Invoicing/CustomInvoiceCreation.cs index d6e78121c..b087a34c8 100644 --- a/ReportImp/MuenchenerAidsHilfeEV/Invoicing/CustomInvoiceCreation.cs +++ b/ReportImp/MuenchenerAidsHilfeEV/Invoicing/CustomInvoiceCreation.cs @@ -62,19 +62,19 @@ namespace MuenchenerAidsHilfeEV.Invoicing IList ergebnis = new List(); var customer = scap.CostBearer2SupportConcept.SupportConcept.Customer; - // Alle Abwesenheiten raussuchen, die länger als 31 Tage gehen. Abwesenheiten werden normal mit abgerechnet bis zum 31. Tag. + // Alle Abwesenheiten raussuchen, die länger als 30 Tage gehen. Abwesenheiten werden normal mit abgerechnet bis zum 30. Tag. // Ab dann wird erst wieder abgerechnet, wenn der Klient wieder da ist, inkl. des letzten Abwesenheitstages. // Das gilt nur, wenn es für den Abwesenheitszeitraum keinen Pauschalbetrag in der Bewilligung gibt. Dieser wird nämlich ein paar // Monate später eingetragen, wenn mit dem KT ein Preis verhandelt wurde. Der wird dann als neue Bewilligung Pauschal eingetragen // und abgerechnet. - List laengerAls31 = new List(); + List laengerAls30 = new List(); if (customer.AbsenceTimes != null) { - laengerAls31 = customer.AbsenceTimes - .Where(at => at.Start.HasValue && at.End.HasValue && ((at.End - at.Start).Value.TotalDays + 1 > 31)).ToList(); + laengerAls30 = customer.AbsenceTimes + .Where(at => at.Start.HasValue && at.End.HasValue && ((at.End - at.Start).Value.TotalDays + 1 > 30)).ToList(); // Abwesenheit künstlich um 1 tag verkürzen, da der letzte Abwesenheitstag wieder als anwesend gilt - //foreach (var item in laengerAls31) + //foreach (var item in laengerAls30) // item.End = item.End.Value.AddDays(-1); } @@ -91,8 +91,8 @@ namespace MuenchenerAidsHilfeEV.Invoicing } - // Wenn eine Abwesenheit den aktuellen Tag enthält prüfen, ob er schon > 31 ist und wenn nein, ob es eine pauschale Bewilligung gibt - var abs = laengerAls31.FirstOrDefault(l => l.AbsenceSpan.ContainsDate(start)); + // Wenn eine Abwesenheit den aktuellen Tag enthält prüfen, ob er schon > 30 ist und wenn nein, ob es eine pauschale Bewilligung gibt + var abs = laengerAls30.FirstOrDefault(l => l.AbsenceSpan.ContainsDate(start)); bool abrechenbar = true; bool alsAbwesendAbrechnen = false; if (abs != null) @@ -101,13 +101,13 @@ namespace MuenchenerAidsHilfeEV.Invoicing int tage = 1; while (absStart < abs.End) { - if (absStart.Day == 30 && absStart.Month == 5) + if (absStart.Day == 1 && absStart.Month == 5) { } - // Wenn der abzurechnende Tag nach dem 31. einer Abwesenheit liegt prüfen, ob er abgerechnet werden soll oder nicht - if (absStart.Date == start.Date && tage > 31 || scap.ApprovedFixedAmount != null) + // Wenn der abzurechnende Tag nach dem 30. einer Abwesenheit liegt prüfen, ob er abgerechnet werden soll oder nicht + if (absStart.Date == start.Date && tage > 30 || scap.ApprovedFixedAmount != null) { alsAbwesendAbrechnen = true; // Wenn eine Bewilligung mit Tagessatz speziell für die Abwesenheit existiert, prüfen ob der Betrag > 0 ist diff --git a/ReportImp/MuenchenerAidsHilfeEV/MuenchenerAidsHilfeEV.csproj b/ReportImp/MuenchenerAidsHilfeEV/MuenchenerAidsHilfeEV.csproj index f37efa919..13e211a8b 100644 --- a/ReportImp/MuenchenerAidsHilfeEV/MuenchenerAidsHilfeEV.csproj +++ b/ReportImp/MuenchenerAidsHilfeEV/MuenchenerAidsHilfeEV.csproj @@ -61,6 +61,7 @@ + Component diff --git a/ReportImp/MuenchenerAidsHilfeEV/Service/CustomAccountingService.cs b/ReportImp/MuenchenerAidsHilfeEV/Service/CustomAccountingService.cs new file mode 100644 index 000000000..0b6f29f3e --- /dev/null +++ b/ReportImp/MuenchenerAidsHilfeEV/Service/CustomAccountingService.cs @@ -0,0 +1,294 @@ +using BeWo.Data.Access; +using BeWo.Data.Entities; +using BeWo.Service.DCEntityMapper; +using BeWo.Service.Plugins; +using BS.Shared.DataContracts; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MuenchenerAidsHilfeEV.Service +{ + public class CustomAccountingService : AccountingService + { + protected override List ErstelleNeueRechnungen(List differenzRechnungChecks) + { + var rechnungen = new List(); + foreach (var item in differenzRechnungChecks) + { + if (item.VorhandeneRechungen.Count == 0 || !item.VorhandeneRechungen.Any(r => item.NeueRechnung.InvoiceBase.CustomerLastName == r.InvoiceBase.CustomerLastName && + item.NeueRechnung.InvoiceBase.CustomerFirstName == r.InvoiceBase.CustomerFirstName)) + { + item.NeueRechnung.InvoiceBase.NeuErstellen = true; + rechnungen.Add(item.NeueRechnung); + } + else + { + var diffRechnung = ErstelleDifferenzRechnung(item); + if (diffRechnung != null) + { + diffRechnung.InvoiceBase.NeuErstellen = false; + rechnungen.Add(diffRechnung); + } + } + } + + return rechnungen; + } + protected override ServiceInvoiceDC ErstelleDifferenzRechnung(DifferenzRechnungCheck item) + { + ServiceInvoiceDC diffRechnung = null; + //var alterBetrag = item.VorhandeneRechungen.Sum(i => i.ClaimSum ?? 0); + var letzteRg = item.VorhandeneRechungen.OrderByDescending(r => r.ServiceInvoiceOid).FirstOrDefault(); + + letzteRg = item.VorhandeneRechungen.FirstOrDefault(r => item.NeueRechnung.InvoiceBase.CustomerOid == r.InvoiceBase.CustomerOid); + if (letzteRg != null) + { + if (item.NeueRechnung.ClaimSum == letzteRg.ClaimSum) + { + diffRechnung = item.NeueRechnung; + diffRechnung.InvoiceBase.NeuErstellen = false; + diffRechnung.InvoiceBase.Hinweise = String.Format("Rechnung wurde bereits erstellt"); + } + else + { + diffRechnung = new ServiceInvoiceDC(); + diffRechnung.OriginalZurDifferenz = item.NeueRechnung; + diffRechnung.InvoiceBase = new InvoiceBaseDC(); + CopyInvoiceBaseDC(item.NeueRechnung.InvoiceBase, diffRechnung); + + ServiceInvoice counterInvoice = new ServiceInvoice(); + var serviceInvoice = DAOFactory.SearchDAO.GetServiceInvoiceByInvoiceBaseOid(letzteRg.InvoiceBase.InvoiceBaseOid.Value); + + CopyServiceInvoice(serviceInvoice, counterInvoice); + SetzeStornoInfos(counterInvoice); + SetzeRechnungspositionenServiceInvoice(diffRechnung, counterInvoice, item); + + diffRechnung.InvoiceBase.NeuErstellen = true; + diffRechnung.InvoiceBase.Hinweise = String.Format("Rechnungsdifferenz zu Rechnung {0} in Höhe von {1:c}", letzteRg.InvoiceBase.InvoiceNumber, letzteRg.InvoiceBase.TotalAmount.Value); + } + } + + return diffRechnung; + } + // Standard, aber in der Basis private und dahar musste es hier mit rein da ich sonst nicht nicht SetzeRechnungspositionenServiceInvoice überschreiben konnte + private void CopyServiceInvoice(ServiceInvoice existingInvoice, ServiceInvoice copyInvoice) + { + copyInvoice.AmountAdvancePayments = existingInvoice.AmountAdvancePayments; + copyInvoice.AmountEquityContribution = existingInvoice.AmountEquityContribution; + copyInvoice.ServiceUnitOid = existingInvoice.ServiceUnitOid; + + CopyInvoiceBase(existingInvoice.InvoiceBase, copyInvoice.InvoiceBase); + + foreach (var sip in existingInvoice.ServiceInvoicePeriodList) + { + var copySip = new ServiceInvoicePeriod(); + copyInvoice.ServiceInvoicePeriodList.Add(copySip); + + CopyServiceInvoicePeriod(sip, copySip); + } + } + // Standard, aber in der Basis private und dahar musste es hier mit rein da ich sonst nicht nicht SetzeRechnungspositionenServiceInvoice überschreiben konnte + private void CopyInvoiceBase(InvoiceBase existing, InvoiceBase copy) + { + copy.AccountingPeriodEnd = existing.AccountingPeriodEnd; + copy.AccountingPeriodStart = existing.AccountingPeriodStart; + copy.CostBearer2SupportConcept = existing.CostBearer2SupportConcept; + copy.CreatorFirstName = existing.CreatorFirstName; + copy.CreatorLastName = existing.CreatorLastName; + copy.CustomerReferenceNumber = existing.CustomerReferenceNumber; + copy.DueDate = existing.DueDate; + copy.DunningLetterCount = existing.DunningLetterCount; + copy.InvoiceDate = existing.InvoiceDate; + copy.InvoiceId = existing.InvoiceId; + copy.InvoiceNumber = existing.InvoiceNumber; + copy.InvoiceTitle = existing.InvoiceTitle; + copy.InvoiceTypeText = existing.InvoiceTypeText; + copy.IsPaid = existing.IsPaid; + copy.IsPrinted = existing.IsPrinted; + copy.RecipientCostBearerOid = existing.RecipientCostBearerOid; + copy.RecipientCustomerOid = existing.RecipientCustomerOid; + copy.RecipientDivision = existing.RecipientDivision; + copy.RecipientOrganisation = existing.RecipientOrganisation; + copy.RecipientOrganisationOid = existing.RecipientOrganisationOid; + copy.RecipientPersonFirstName = existing.RecipientPersonFirstName; + copy.RecipientPersonLastName = existing.RecipientPersonLastName; + copy.RecipientPersonOid = existing.RecipientPersonOid; + copy.SenderDivision = existing.SenderDivision; + copy.SenderFirstName = existing.SenderFirstName; + copy.SenderLastName = existing.SenderLastName; + copy.SenderOrganisation = existing.SenderOrganisation; + copy.SupportConceptOid = existing.SupportConceptOid; + copy.Type = existing.Type; + copy.XMLData = existing.XMLData; + + foreach (var ii in existing.InvoiceItems) + { + var copyItem = new InvoiceItem(); + copy.InvoiceItems.Add(copyItem); + + CopyInvoiceItem(ii, copyItem); + + } + + if (existing.RecipientAddress != null) + { + copy.RecipientAddress = CreateCopyAddress(existing.RecipientAddress); + } + + if (existing.RecipientContacts != null) + { + copy.RecipientContacts = new List(); + foreach (var existingContact in existing.RecipientContacts) + { + copy.RecipientContacts.Add(CreateCopyContact(existingContact)); + } + } + + if (existing.SenderAddress != null) + { + copy.SenderAddress = existing.SenderAddress; + } + + if (existing.SenderContacts != null) + { + copy.SenderContacts = new List(); + foreach (var existingContact in existing.SenderContacts) + { + copy.SenderContacts.Add(CreateCopyContact(existingContact)); + } + } + + } + // Standard, aber in der Basis private und dahar musste es hier mit rein da ich sonst nicht nicht SetzeRechnungspositionenServiceInvoice überschreiben konnte + private void CopyInvoiceItem(InvoiceItem existingItem, InvoiceItem copyItem) + { + copyItem.AccountingInterval = existingItem.AccountingInterval; + copyItem.AmountPerUnit = existingItem.AmountPerUnit; + copyItem.AmountTotal = existingItem.AmountTotal; + copyItem.ApprovalUnit = existingItem.AccountingInterval; + copyItem.ApprovedPerUnit = existingItem.ApprovedPerUnit; + copyItem.GrossAmountTotal = existingItem.GrossAmountTotal; + copyItem.ItemDescription = existingItem.ItemDescription; + copyItem.ItemPeriodEnd = existingItem.ItemPeriodEnd; + copyItem.ItemPeriodStart = existingItem.ItemPeriodStart; + copyItem.MaxApprovedAmount = existingItem.MaxApprovedAmount; + copyItem.MaxApprovedUnitCount = existingItem.MaxApprovedUnitCount; + copyItem.RateFactor = existingItem.RateFactor; + copyItem.ReceivedAmount = existingItem.ReceivedAmount; + copyItem.SupportConceptApprovalPeriodOid = existingItem.SupportConceptApprovalPeriodOid; + copyItem.UnitCount = existingItem.UnitCount; + copyItem.UnitDescription = existingItem.UnitDescription; + copyItem.Notice = existingItem.Notice; + copyItem.ServiceRecord = existingItem.ServiceRecord; + } + // Standard, aber in der Basis private und dahar musste es hier mit rein da ich sonst nicht nicht SetzeRechnungspositionenServiceInvoice überschreiben konnte + private Address CreateCopyAddress(Address address) + { + Address newAddress = new Address(); + newAddress.AddressLine1 = address.AddressLine1; + newAddress.AddressLine2 = address.AddressLine2; + newAddress.Country = address.Country; + newAddress.PostalCode = address.PostalCode; + newAddress.State = address.State; + newAddress.Street = address.Street; + newAddress.Town = address.Town; + + return newAddress; + } + // Standard, aber in der Basis private und dahar musste es hier mit rein da ich sonst nicht nicht SetzeRechnungspositionenServiceInvoice überschreiben konnte + private Contact CreateCopyContact(Contact existingContact) + { + Contact newContact = new Contact(); + newContact.Value = existingContact.Value; + newContact.Type = existingContact.Type; + + return newContact; + } + + private void SetzeRechnungspositionenServiceInvoice(ServiceInvoiceDC diffRechnung, ServiceInvoice counterInvoice, DifferenzRechnungCheck item) + { + var siDCAlt = MapperFactory.ServiceInvoiceDC_ServiceInvoice.MapToNewDC(counterInvoice); + if (siDCAlt.ServiceInvoicePeriods != null && siDCAlt.ServiceInvoicePeriods.Count > 0) + { + diffRechnung.ServiceInvoicePeriods = siDCAlt.ServiceInvoicePeriods; + } + + if (item.NeueRechnung.ServiceInvoicePeriods != null && item.NeueRechnung.ServiceInvoicePeriods.Count > 0) + { + if (diffRechnung.ServiceInvoicePeriods == null) + { + diffRechnung.ServiceInvoicePeriods = item.NeueRechnung.ServiceInvoicePeriods; + } + else + { + foreach (var NewSip in item.NeueRechnung.ServiceInvoicePeriods) + { + if (NewSip.InvoiceItems != null && NewSip.InvoiceItems.Count > 0) + { + if (NewSip.Customer != null && diffRechnung.ServiceInvoicePeriods.Any(s => s.Customer.CustomerOid == NewSip.Customer.CustomerOid) && + NewSip.SupportConceptApprovalPeriod != null && NewSip.SupportConceptApprovalPeriod.SupportConceptApprovalPeriodOid.HasValue + && diffRechnung.ServiceInvoicePeriods.Any(s => s.SupportConceptApprovalPeriod.SupportConceptApprovalPeriodOid.HasValue + && s.SupportConceptApprovalPeriod.SupportConceptApprovalPeriodOid.Value == NewSip.SupportConceptApprovalPeriod.SupportConceptApprovalPeriodOid.Value)) + { + var ip = diffRechnung.ServiceInvoicePeriods.Where(s => s.SupportConceptApprovalPeriod.SupportConceptApprovalPeriodOid.Value == NewSip.SupportConceptApprovalPeriod.SupportConceptApprovalPeriodOid.Value).First(); + if (ip.InvoiceItems != null && ip.InvoiceItems.Count > 0) + { + ip.Claim += NewSip.Claim; + foreach (var ii in NewSip.InvoiceItems) + { + ip.InvoiceItems.Add(ii); + } + + // Bei Rechnungspositionen mit negativem Betrag auf alte Rechnung verweisen + foreach (var iitem in ip.InvoiceItems) + { + if (iitem.AmountTotal < 0) + { + var vorhandeneRechnung = item.VorhandeneRechungen.FirstOrDefault(r => r.InvoiceBase != null && r.InvoiceBase.CustomerOid == ip.Customer.CustomerOid); + if (vorhandeneRechnung != null) + iitem.ItemDescription += string.Format(" (am {0:dd.MM.yyyy} in Rechnung {1} berechnet)", vorhandeneRechnung.InvoiceBase.InvoiceDate, vorhandeneRechnung.InvoiceBase.InvoiceNumber); + } + } + } + } + else + { + diffRechnung.ServiceInvoicePeriods.Add(NewSip); + } + } + } + } + } + } + // Standard, aber in der Basis private und dahar musste es hier mit rein da ich sonst nicht nicht SetzeRechnungspositionenServiceInvoice überschreiben konnte + private void CopyServiceInvoicePeriod(ServiceInvoicePeriod existingSip, ServiceInvoicePeriod copySip) + { + copySip.AccountingInterval = existingSip.AccountingInterval; + copySip.ApprovedAmountDefaultHourlyRate = existingSip.ApprovedAmountDefaultHourlyRate; + copySip.ApprovedBE = existingSip.ApprovedBE; + copySip.ApprovedFixedAmount = existingSip.ApprovedFixedAmount; + copySip.ApprovedHours = existingSip.ApprovedHours; + copySip.Claim = existingSip.Claim; + copySip.End = existingSip.End; + copySip.HoursNotBillableAbsence = existingSip.HoursNotBillableAbsence; + copySip.HoursNotBillableNotApproved = existingSip.HoursNotBillableNotApproved; + copySip.ServiceUnitName = existingSip.ServiceUnitName; + copySip.Start = existingSip.Start; + copySip.Notice = existingSip.Notice; + copySip.Customer = existingSip.Customer; + copySip.SupportConceptApprovalPeriod = existingSip.SupportConceptApprovalPeriod; + + foreach (var ii in existingSip.InvoiceItemList) + { + var copyItem = new InvoiceItem(); + copySip.InvoiceItemList.Add(copyItem); + + CopyInvoiceItem(ii, copyItem); + } + + } + } +} diff --git a/ReportImp/SBBMainzReports/Invoicing/CustomInvoiceCreation.cs b/ReportImp/SBBMainzReports/Invoicing/CustomInvoiceCreation.cs index 712389764..ffccf0728 100644 --- a/ReportImp/SBBMainzReports/Invoicing/CustomInvoiceCreation.cs +++ b/ReportImp/SBBMainzReports/Invoicing/CustomInvoiceCreation.cs @@ -15,6 +15,30 @@ namespace SbbMainzReports.Invoicing { public class CustomInvoiceCreation : InvoiceCreation { + + public override ServiceInvoice CreateSingleInvoice(int invoiceCounter, CostBearer costBearer, DateTimeSpan invoicePeriod, CompactSupportConceptDC supportConcept, List serviceRecords) + { + // auch nicht bewilligte abrechnen + if (!supportConcept.IsDeleted && !supportConcept.IsArchived) + { + var invoice = new ServiceInvoice(); + var supportConceptList = new List { supportConcept }; + + SetSenderInformation(invoice); + SetInvoiceBaseData(invoiceCounter, invoice, costBearer, invoicePeriod, supportConceptList); + SetSingleInvoiceBaseData(invoiceCounter, invoice, costBearer, invoicePeriod, supportConcept); + SetRecipientInformation(invoice, costBearer); + SetServiceInvoicePeriods(invoice, invoice.InvoiceBase.CostBearer2SupportConcept, invoicePeriod, serviceRecords); + SetServiceInvoicePeriodAmounts(invoice); + SetAmountAdvancePayments(invoice); + SetAmountEquityContribution(invoice); + + return invoice; + } + + return null; + } + public override InvoiceItem CreateInvoiceItem(ServiceRecordDC iServiceRecord, SupportConceptApprovalPeriod scap, BS.Shared.Services.Calculations calc) { var ii = base.CreateInvoiceItem(iServiceRecord, scap, calc); diff --git a/ReportImp/SBBMainzReports/QuittierungsbelegJaMainz.cs b/ReportImp/SBBMainzReports/QuittierungsbelegJaMainz.cs index 4cc56b176..b9ef9cb8f 100644 --- a/ReportImp/SBBMainzReports/QuittierungsbelegJaMainz.cs +++ b/ReportImp/SBBMainzReports/QuittierungsbelegJaMainz.cs @@ -1,116 +1,116 @@ -using System; -using System.Collections; -using System.ComponentModel; -using BS.Shared.Core; -using DevExpress.XtraReports.UI; -using BeWo.Report.ReportObjects; -using BeWo.Report; -using System.Collections.Generic; -using System.Drawing; -using BeWo.Data.Access; -using BeWo.Data.Entities; -using BeWo.SBBMainzReports.Calculations; -using BeWo.Service.DCEntityMapper; -using BeWo.Service.Plugins; -using BS.Shared; -using BS.Shared.Services; -using DevExpress.XtraPrinting; -using BS.Shared.DataContracts; -using System.Text; -using System.Linq; - -namespace SBBMainzReports -{ - public partial class QuittierungsbelegJaMainz : DevExpress.XtraReports.UI.XtraReport, IBeWoReport - { - public QuittierungsbelegJaMainz() - { - InitializeComponent(); - } - - public void SetReportDataSource(ServicesOverviewRO pRO) - { - xrCheckBox1.Visible = false; - xrCheckBox2.Visible = false; - xrCheckBox3.Visible = false; - xrCheckBox4.Visible = false; - - decimal anteilBetreuungsstundenProzent = 100; - decimal anteilOverheadProzent = 0; - double TotalMin = 0.00; - - if (pRO.Services != null) - { - List servicesBillable = new List(); - - foreach (ServicesOverviewRO.ServiceDetail s in pRO.Services) - { - CreateGoalList(s); - var serviceRecord = DAOFactory.GenericDAO.LoadByID(s.ServiceRecordOid); - var srDc = MapperFactory.ServiceRecordDC_ServiceRecord.MapToNewDC(serviceRecord); - s.ServiceCategory = ""; - - if (s.IsBillable) - { - TotalMin += s.Minutes/60; - } - } - } - - SetKopfbereich(pRO); - - pRO.ApprovedFLSPerMonth = pRO.ApprovedFLSPerWeek * 4.33m; - DateTime start = pRO.StartDate; - DateTime end = pRO.EndDate; - - - var hp = GetCurrentC2S(pRO); - if (hp != null) - { - if (hp.StartDate > start) - start = hp.StartDate.Value; - if (hp.EndDate < end) - end = hp.EndDate.Value; - } - decimal days = (decimal)end.Subtract(start).TotalDays + 1; - - pRO.ApprovedFLSPerMonth *= days / DateTime.DaysInMonth(pRO.StartDate.Year, pRO.StartDate.Month); - - decimal gesamt = (decimal)TotalMin; - decimal mehrMinusStunden = gesamt - pRO.ApprovedFLSPerMonth; - decimal uebertragVormonat = BerechneUebertragVormonat(pRO, anteilBetreuungsstundenProzent, anteilOverheadProzent); - - bool uebertrag = MussUebertragBerechnen(pRO); - - cellMehrMinusStunden.Text = String.Format("{0:0.000}", mehrMinusStunden); - cellUebertragVormonat.Text = String.Format("{0:0.000}", uebertragVormonat); - if (uebertrag) - cellUebertragNaechsterMonat.Text = String.Format("{0:0.000}", mehrMinusStunden + uebertragVormonat); - else - cellUebertragNaechsterMonat.Text = String.Format("{0:0.000}", 0); - - // cellWoechentlichKlientenbezogen.Text = String.Format("{0:0.00}", (pRO.ApprovedFLSPerMonth - uebertragVormonat) * 0.7m / 4.33m); - // cellMonatlichKlientenbezogen.Text = String.Format("{0:0.00}", pRO.ApprovedFLSPerMonth * 0.7m); - - cellBetreuungstunden.Text = String.Format("{0:0.##}% Betreuungsstunden", anteilBetreuungsstundenProzent); - - var minutes = (decimal)Math.Round(pRO.TotalFLMBillable / 60, 3, MidpointRounding.AwayFromZero); - var pausch = Math.Round(((decimal)pRO.TotalFLMBillable / anteilBetreuungsstundenProzent * anteilOverheadProzent) / 60, 3, MidpointRounding.AwayFromZero); - - cellMinutes.Text = String.Format("{0:0.000}", minutes); - - this.bindingSource1.DataSource = pRO; - } - - private CostBearer2SupportConcept GetCurrentC2S(ServicesOverviewRO ro) - { - if (ro.CostBearer2SupportConceptList != null && ro.CostBearer2SupportConceptList.Count > 0) - { - foreach (var c2sc in ro.CostBearer2SupportConceptList) - { - var cbName = c2sc.CostBearer.Organisation.Name; - if ((cbName.ToLower().Contains("jugendamt der landeshauptstadt mainz") || - cbName.Equals("Landeshauptstadt Wiesbaden Amt für Soziale Arbeit und ambulante Erziehungshilfen")) +using System; +using System.Collections; +using System.ComponentModel; +using BS.Shared.Core; +using DevExpress.XtraReports.UI; +using BeWo.Report.ReportObjects; +using BeWo.Report; +using System.Collections.Generic; +using System.Drawing; +using BeWo.Data.Access; +using BeWo.Data.Entities; +using BeWo.SBBMainzReports.Calculations; +using BeWo.Service.DCEntityMapper; +using BeWo.Service.Plugins; +using BS.Shared; +using BS.Shared.Services; +using DevExpress.XtraPrinting; +using BS.Shared.DataContracts; +using System.Text; +using System.Linq; + +namespace SBBMainzReports +{ + public partial class QuittierungsbelegJaMainz : DevExpress.XtraReports.UI.XtraReport, IBeWoReport + { + public QuittierungsbelegJaMainz() + { + InitializeComponent(); + } + + public void SetReportDataSource(ServicesOverviewRO pRO) + { + xrCheckBox1.Visible = false; + xrCheckBox2.Visible = false; + xrCheckBox3.Visible = false; + xrCheckBox4.Visible = false; + + decimal anteilBetreuungsstundenProzent = 100; + decimal anteilOverheadProzent = 0; + double TotalMin = 0.00; + + if (pRO.Services != null) + { + List servicesBillable = new List(); + + foreach (ServicesOverviewRO.ServiceDetail s in pRO.Services) + { + CreateGoalList(s); + var serviceRecord = DAOFactory.GenericDAO.LoadByID(s.ServiceRecordOid); + var srDc = MapperFactory.ServiceRecordDC_ServiceRecord.MapToNewDC(serviceRecord); + s.ServiceCategory = ""; + + if (s.IsBillable) + { + TotalMin += s.Minutes/60; + } + } + } + + SetKopfbereich(pRO); + + pRO.ApprovedFLSPerMonth = pRO.ApprovedFLSPerWeek * 4.33m; + DateTime start = pRO.StartDate; + DateTime end = pRO.EndDate; + + + var hp = GetCurrentC2S(pRO); + if (hp != null) + { + if (hp.StartDate > start) + start = hp.StartDate.Value; + if (hp.EndDate < end) + end = hp.EndDate.Value; + } + decimal days = (decimal)end.Subtract(start).TotalDays + 1; + + pRO.ApprovedFLSPerMonth *= days / DateTime.DaysInMonth(pRO.StartDate.Year, pRO.StartDate.Month); + + decimal gesamt = (decimal)TotalMin; + decimal mehrMinusStunden = gesamt - pRO.ApprovedFLSPerMonth; + decimal uebertragVormonat = BerechneUebertragVormonat(pRO, anteilBetreuungsstundenProzent, anteilOverheadProzent); + + bool uebertrag = MussUebertragBerechnen(pRO); + + cellMehrMinusStunden.Text = String.Format("{0:0.000}", mehrMinusStunden); + cellUebertragVormonat.Text = String.Format("{0:0.000}", uebertragVormonat); + if (uebertrag) + cellUebertragNaechsterMonat.Text = String.Format("{0:0.000}", mehrMinusStunden + uebertragVormonat); + else + cellUebertragNaechsterMonat.Text = String.Format("{0:0.000}", 0); + + // cellWoechentlichKlientenbezogen.Text = String.Format("{0:0.00}", (pRO.ApprovedFLSPerMonth - uebertragVormonat) * 0.7m / 4.33m); + // cellMonatlichKlientenbezogen.Text = String.Format("{0:0.00}", pRO.ApprovedFLSPerMonth * 0.7m); + + cellBetreuungstunden.Text = String.Format("{0:0.##}% Betreuungsstunden", anteilBetreuungsstundenProzent); + + var minutes = (decimal)Math.Round(pRO.TotalFLMBillable / 60, 3, MidpointRounding.AwayFromZero); + var pausch = Math.Round(((decimal)pRO.TotalFLMBillable / anteilBetreuungsstundenProzent * anteilOverheadProzent) / 60, 3, MidpointRounding.AwayFromZero); + + cellMinutes.Text = String.Format("{0:0.000}", minutes); + + this.bindingSource1.DataSource = pRO; + } + + private CostBearer2SupportConcept GetCurrentC2S(ServicesOverviewRO ro) + { + if (ro.CostBearer2SupportConceptList != null && ro.CostBearer2SupportConceptList.Count > 0) + { + foreach (var c2sc in ro.CostBearer2SupportConceptList) + { + var cbName = c2sc.CostBearer.Organisation.Name; + if ((cbName.ToLower().Contains("jugendamt der landeshauptstadt mainz") || ro.Costbearer.ToLower().Contains("jugend und familie mainz – amt 51") || + cbName.Equals("Landeshauptstadt Wiesbaden Amt für Soziale Arbeit und ambulante Erziehungshilfen")) && c2sc.StartDate <= ro.StartDate && c2sc.EndDate >= ro.StartDate) { if (cbName.Equals("Landeshauptstadt Wiesbaden Amt für Soziale Arbeit und ambulante Erziehungshilfen")) @@ -118,292 +118,292 @@ namespace SBBMainzReports lblReceiver.Text = "Landeshauptstadt Wiesbaden"; } return c2sc; - } - } - } - - return null; - } - - private void SetKopfbereich(ServicesOverviewRO pRO) - { - String betreuer1 = ""; - long betreuer1EOid = 0; - String betreuer2 = ""; - long betreuer2EOid = 0; - int i = 0; - - var c2s = GetCurrentC2S(pRO); - if (c2s != null) - { - SupportConceptApprovalPeriod2Employee p2e; - foreach (var rating in c2s.SupportConcept.Ratings) - { - if (rating.StartDate >= pRO.StartDate && rating.StartDate < pRO.EndDate.AddDays(1)) - { - foreach (var item in rating.GoalRatingList) - { - ValueListEntry entry = null; - string ratingName = null; - string ratingErgebnis = null; - - if (item.ValueListEntryOid != null) - entry = DAOFactory.GenericDAO.LoadByID(item.ValueListEntryOid.Value); - if (entry != null) - ratingName = entry.Value; - if (item.RatingType != null) - ratingErgebnis = item.RatingType.DisplayName; - - switch (i) - { - case 0: - lblZiel1.Text = ratingName; - if (ratingErgebnis != null && ratingErgebnis.ToLower() == "erledigt") - { - xrCheckBox1.Checked = true; - xrCheckBox1.Visible = true; - } - else - lblBewertung1.Text = ratingErgebnis; break; - case 1: - lblZiel2.Text = ratingName; - if (ratingErgebnis != null && ratingErgebnis.ToLower() == "erledigt") - { - xrCheckBox2.Checked = true; - xrCheckBox2.Visible = true; - } - else - lblBewertung2.Text = ratingErgebnis; break; - case 2: - lblZiel3.Text = ratingName; - if (ratingErgebnis != null && ratingErgebnis.ToLower() == "erledigt") - { - xrCheckBox3.Checked = true; - xrCheckBox3.Visible = true; - } - else - lblBewertung3.Text = ratingErgebnis; break; - case 3: - lblZiel4.Text = ratingName; - if (ratingErgebnis != null && ratingErgebnis.ToLower() == "erledigt") - { - xrCheckBox4.Checked = true; - xrCheckBox4.Visible = true; - } - else - lblBewertung4.Text = ratingErgebnis; break; - } - i++; - } - } - } - - foreach (var scap in c2s.ApprovalPeriodList) - { - if (scap.SupportConceptApprovalPeriod2Employee != null) - { - var sortedScs = scap.SupportConceptApprovalPeriod2Employee.OrderByDescending(s => s.Betreuungsschluessel).ToList(); - if (sortedScs.Count > 0) - { - p2e = sortedScs[0]; - betreuer1 = p2e.Employee.Person.FirstNameLastName; - betreuer1EOid = (long)p2e.Employee.Oid; - } - - if (sortedScs.Count > 1) - { - p2e = sortedScs[1]; - betreuer2 = p2e.Employee.Person.FirstNameLastName; - betreuer2EOid = (long)p2e.Employee.Oid; - } - } - } - - lblBetreuer1.Text = betreuer1; - lblBetreuer2.Text = betreuer2; - - String qualifikation1 = ""; - String qualifikation2 = ""; - - if (betreuer1EOid != 0) - { - var employee = DAOFactory.GenericDAO.LoadByID(betreuer1EOid); - foreach (var valueEntry in employee.ValueList) - { - if (valueEntry.Entry.Type == ValueListEntryType.StaffQualificationsType) - if (valueEntry.Entry.Value.StartsWith("Q") && valueEntry.Entry.Value.Length < 4) - qualifikation1 = valueEntry.Entry.Value.ToString(); - } - - } - - if (betreuer2EOid != 0) - { - var employee = DAOFactory.GenericDAO.LoadByID(betreuer2EOid); - foreach (var valueEntry in employee.ValueList) - { - if (valueEntry.Entry.Type == ValueListEntryType.StaffQualificationsType) - if (valueEntry.Entry.Value.StartsWith("Q") && valueEntry.Entry.Value.Length < 4) - qualifikation2 = valueEntry.Entry.Value.ToString(); - } - - } - lblQualifikation1.Text = qualifikation1; - lblQualifikation2.Text = qualifikation2; - - if (c2s.CostBearerContactPerson != null) - { - if (c2s.CostBearerContactPerson.Sex.HasValue && - c2s.CostBearerContactPerson.Sex.Value == Sex.Female) - lblAnsprechpartner.Text = "Frau "; - else if (c2s.CostBearerContactPerson.Sex.HasValue && - c2s.CostBearerContactPerson.Sex.Value == Sex.Male) - lblAnsprechpartner.Text = "Herr "; - - lblAnsprechpartner.Text += c2s.CostBearerContactPerson.LastName; - } - } - } - - private decimal BerechneUebertragVormonat(ServicesOverviewRO pRO, decimal anteilBetreuungsstundenProzent, decimal anteilOverheadProzent) - { - var calc = new SBBMainzCalculations(); - - decimal uebertrag = 0; - if (pRO.CostBearer2SupportConceptList != null && pRO.CostBearer2SupportConceptList.Count > 0) - { - var c2s = pRO.CostBearer2SupportConceptList[0]; - - IList allServiceRecords = c2s.ServiceRecords; - - decimal flmSoll = 0; - - - DateTime start = c2s.StartDate.Value; - int months = 0; - while (start < pRO.StartDate) - { - var dc = MapperFactory.SupportConceptCostBearerRelDC_CostBearer2SupportConcept.MapToNewDC(c2s); - - var approvedPerWeek = calc.GetApprovedHoursPerWeek(dc, start, false) ?? 0; - - decimal soll = approvedPerWeek * 4.33m; - if (start.Day != 1) - { - DateTime end = new DateTime(start.AddMonths(1).Year, start.AddMonths(1).Month, 1); - - decimal days = (decimal)end.Subtract(start).TotalDays; - - soll *= days / DateTime.DaysInMonth(start.Year, start.Month); - } - flmSoll += soll; - decimal ist = GetIstImMonat(allServiceRecords, start); - ist += ist / anteilBetreuungsstundenProzent * anteilOverheadProzent; - ist /= 60; - var uebertragMonat = ist - soll; - - uebertrag += uebertragMonat; - start = start.AddMonths(1); - start = new DateTime(start.Year, start.Month, 1); - months++; - var mod = months % 3; - if (mod == 0) - uebertrag = 0; - } - - - } - return uebertrag; - } - - private decimal GetIstImMonat(IList allServiceRecords, DateTime start) - { - DateTime monatEnd = start.AddMonths(1); - monatEnd = new DateTime(monatEnd.Year, monatEnd.Month, 1); - - decimal ist = 0; - - Dictionary groupBookingDict = new Dictionary(); - foreach (var item in allServiceRecords) - { - if (!item.GroupOid.HasValue || !groupBookingDict.ContainsKey(item.GroupOid.Value)) - { - if (item.Start != null) - { - if (item.Start >= start && item.Start.Value < monatEnd) - { - if (item.ServiceDescription != null && item.ServiceDescription.ServiceCategory != null && item.ServiceDescription.ServiceCategory.IsBillable) - { - var p = item.ServiceDescription.ServiceCategory.ProzentAbrechnung; - if (item.ServiceDescription.ProzentAbrechnung.HasValue) - { - p = item.ServiceDescription.ProzentAbrechnung.Value; - - } - ist += (item.RoundedDuration * p) / 100; - - if (item.GroupOid.HasValue) - groupBookingDict.Add(item.GroupOid.Value, true); - } - } - } - } - } - - return ist; - } - - private bool MussUebertragBerechnen(ServicesOverviewRO pRO) - { - if (pRO.CostBearer2SupportConceptList != null && pRO.CostBearer2SupportConceptList.Count > 0) - { - var c2s = pRO.CostBearer2SupportConceptList[0]; - - int months = 0; - - DateTime start = c2s.StartDate.Value; - - while (start < pRO.EndDate) - { - months++; - start = start.AddMonths(1); - } - - var mod = months % 3; - if (mod == 0) - return false; - } - return true; - } - - public static void CreateGoalList(ServicesOverviewRO.ServiceDetail sd) - { - var serviceRecord = DAOFactory.GenericDAO.LoadByID(sd.ServiceRecordOid); - var srDc = MapperFactory.ServiceRecordDC_ServiceRecord.MapToNewDC(serviceRecord); - - sd.GoalList = String.Empty; - if (srDc.Goals != null && srDc.Goals.Count > 0) - { - foreach (var goal in srDc.Goals) - { - // Ohne diese Abfrage wird das selbe Ziel so oft eingefügt wie die Anzahl der Gruppenmitglieder ist - if (sd.CustomerCount > 1 && !string.IsNullOrEmpty(goal.TypeDescription) && sd.GoalList.Contains(goal.TypeDescription)) - continue; - - if (sd.GoalList.Length > 0) - { - sd.GoalList += ", "; - } - if (!string.IsNullOrEmpty(goal.Abbreviation)) - { - sd.GoalList += goal.Abbreviation; - } - //else // Das wird sonst tot hässlich - //{ - // sd.GoalList += goal.TypeDescription; - //} - } - } - } - } -} + } + } + } + + return null; + } + + private void SetKopfbereich(ServicesOverviewRO pRO) + { + String betreuer1 = ""; + long betreuer1EOid = 0; + String betreuer2 = ""; + long betreuer2EOid = 0; + int i = 0; + + var c2s = GetCurrentC2S(pRO); + if (c2s != null) + { + SupportConceptApprovalPeriod2Employee p2e; + foreach (var rating in c2s.SupportConcept.Ratings) + { + if (rating.StartDate >= pRO.StartDate && rating.StartDate < pRO.EndDate.AddDays(1)) + { + foreach (var item in rating.GoalRatingList) + { + ValueListEntry entry = null; + string ratingName = null; + string ratingErgebnis = null; + + if (item.ValueListEntryOid != null) + entry = DAOFactory.GenericDAO.LoadByID(item.ValueListEntryOid.Value); + if (entry != null) + ratingName = entry.Value; + if (item.RatingType != null) + ratingErgebnis = item.RatingType.DisplayName; + + switch (i) + { + case 0: + lblZiel1.Text = ratingName; + if (ratingErgebnis != null && ratingErgebnis.ToLower() == "erledigt") + { + xrCheckBox1.Checked = true; + xrCheckBox1.Visible = true; + } + else + lblBewertung1.Text = ratingErgebnis; break; + case 1: + lblZiel2.Text = ratingName; + if (ratingErgebnis != null && ratingErgebnis.ToLower() == "erledigt") + { + xrCheckBox2.Checked = true; + xrCheckBox2.Visible = true; + } + else + lblBewertung2.Text = ratingErgebnis; break; + case 2: + lblZiel3.Text = ratingName; + if (ratingErgebnis != null && ratingErgebnis.ToLower() == "erledigt") + { + xrCheckBox3.Checked = true; + xrCheckBox3.Visible = true; + } + else + lblBewertung3.Text = ratingErgebnis; break; + case 3: + lblZiel4.Text = ratingName; + if (ratingErgebnis != null && ratingErgebnis.ToLower() == "erledigt") + { + xrCheckBox4.Checked = true; + xrCheckBox4.Visible = true; + } + else + lblBewertung4.Text = ratingErgebnis; break; + } + i++; + } + } + } + + foreach (var scap in c2s.ApprovalPeriodList) + { + if (scap.SupportConceptApprovalPeriod2Employee != null) + { + var sortedScs = scap.SupportConceptApprovalPeriod2Employee.OrderByDescending(s => s.Betreuungsschluessel).ToList(); + if (sortedScs.Count > 0) + { + p2e = sortedScs[0]; + betreuer1 = p2e.Employee.Person.FirstNameLastName; + betreuer1EOid = (long)p2e.Employee.Oid; + } + + if (sortedScs.Count > 1) + { + p2e = sortedScs[1]; + betreuer2 = p2e.Employee.Person.FirstNameLastName; + betreuer2EOid = (long)p2e.Employee.Oid; + } + } + } + + lblBetreuer1.Text = betreuer1; + lblBetreuer2.Text = betreuer2; + + String qualifikation1 = ""; + String qualifikation2 = ""; + + if (betreuer1EOid != 0) + { + var employee = DAOFactory.GenericDAO.LoadByID(betreuer1EOid); + foreach (var valueEntry in employee.ValueList) + { + if (valueEntry.Entry.Type == ValueListEntryType.StaffQualificationsType) + if (valueEntry.Entry.Value.StartsWith("Q") && valueEntry.Entry.Value.Length < 4) + qualifikation1 = valueEntry.Entry.Value.ToString(); + } + + } + + if (betreuer2EOid != 0) + { + var employee = DAOFactory.GenericDAO.LoadByID(betreuer2EOid); + foreach (var valueEntry in employee.ValueList) + { + if (valueEntry.Entry.Type == ValueListEntryType.StaffQualificationsType) + if (valueEntry.Entry.Value.StartsWith("Q") && valueEntry.Entry.Value.Length < 4) + qualifikation2 = valueEntry.Entry.Value.ToString(); + } + + } + lblQualifikation1.Text = qualifikation1; + lblQualifikation2.Text = qualifikation2; + + if (c2s.CostBearerContactPerson != null) + { + if (c2s.CostBearerContactPerson.Sex.HasValue && + c2s.CostBearerContactPerson.Sex.Value == Sex.Female) + lblAnsprechpartner.Text = "Frau "; + else if (c2s.CostBearerContactPerson.Sex.HasValue && + c2s.CostBearerContactPerson.Sex.Value == Sex.Male) + lblAnsprechpartner.Text = "Herr "; + + lblAnsprechpartner.Text += c2s.CostBearerContactPerson.LastName; + } + } + } + + private decimal BerechneUebertragVormonat(ServicesOverviewRO pRO, decimal anteilBetreuungsstundenProzent, decimal anteilOverheadProzent) + { + var calc = new SBBMainzCalculations(); + + decimal uebertrag = 0; + if (pRO.CostBearer2SupportConceptList != null && pRO.CostBearer2SupportConceptList.Count > 0) + { + var c2s = pRO.CostBearer2SupportConceptList[0]; + + IList allServiceRecords = c2s.ServiceRecords; + + decimal flmSoll = 0; + + + DateTime start = c2s.StartDate.Value; + int months = 0; + while (start < pRO.StartDate) + { + var dc = MapperFactory.SupportConceptCostBearerRelDC_CostBearer2SupportConcept.MapToNewDC(c2s); + + var approvedPerWeek = calc.GetApprovedHoursPerWeek(dc, start, false) ?? 0; + + decimal soll = approvedPerWeek * 4.33m; + if (start.Day != 1) + { + DateTime end = new DateTime(start.AddMonths(1).Year, start.AddMonths(1).Month, 1); + + decimal days = (decimal)end.Subtract(start).TotalDays; + + soll *= days / DateTime.DaysInMonth(start.Year, start.Month); + } + flmSoll += soll; + decimal ist = GetIstImMonat(allServiceRecords, start); + ist += ist / anteilBetreuungsstundenProzent * anteilOverheadProzent; + ist /= 60; + var uebertragMonat = ist - soll; + + uebertrag += uebertragMonat; + start = start.AddMonths(1); + start = new DateTime(start.Year, start.Month, 1); + months++; + var mod = months % 3; + if (mod == 0) + uebertrag = 0; + } + + + } + return uebertrag; + } + + private decimal GetIstImMonat(IList allServiceRecords, DateTime start) + { + DateTime monatEnd = start.AddMonths(1); + monatEnd = new DateTime(monatEnd.Year, monatEnd.Month, 1); + + decimal ist = 0; + + Dictionary groupBookingDict = new Dictionary(); + foreach (var item in allServiceRecords) + { + if (!item.GroupOid.HasValue || !groupBookingDict.ContainsKey(item.GroupOid.Value)) + { + if (item.Start != null) + { + if (item.Start >= start && item.Start.Value < monatEnd) + { + if (item.ServiceDescription != null && item.ServiceDescription.ServiceCategory != null && item.ServiceDescription.ServiceCategory.IsBillable) + { + var p = item.ServiceDescription.ServiceCategory.ProzentAbrechnung; + if (item.ServiceDescription.ProzentAbrechnung.HasValue) + { + p = item.ServiceDescription.ProzentAbrechnung.Value; + + } + ist += (item.RoundedDuration * p) / 100; + + if (item.GroupOid.HasValue) + groupBookingDict.Add(item.GroupOid.Value, true); + } + } + } + } + } + + return ist; + } + + private bool MussUebertragBerechnen(ServicesOverviewRO pRO) + { + if (pRO.CostBearer2SupportConceptList != null && pRO.CostBearer2SupportConceptList.Count > 0) + { + var c2s = pRO.CostBearer2SupportConceptList[0]; + + int months = 0; + + DateTime start = c2s.StartDate.Value; + + while (start < pRO.EndDate) + { + months++; + start = start.AddMonths(1); + } + + var mod = months % 3; + if (mod == 0) + return false; + } + return true; + } + + public static void CreateGoalList(ServicesOverviewRO.ServiceDetail sd) + { + var serviceRecord = DAOFactory.GenericDAO.LoadByID(sd.ServiceRecordOid); + var srDc = MapperFactory.ServiceRecordDC_ServiceRecord.MapToNewDC(serviceRecord); + + sd.GoalList = String.Empty; + if (srDc.Goals != null && srDc.Goals.Count > 0) + { + foreach (var goal in srDc.Goals) + { + // Ohne diese Abfrage wird das selbe Ziel so oft eingefügt wie die Anzahl der Gruppenmitglieder ist + if (sd.CustomerCount > 1 && !string.IsNullOrEmpty(goal.TypeDescription) && sd.GoalList.Contains(goal.TypeDescription)) + continue; + + if (sd.GoalList.Length > 0) + { + sd.GoalList += ", "; + } + if (!string.IsNullOrEmpty(goal.Abbreviation)) + { + sd.GoalList += goal.Abbreviation; + } + //else // Das wird sonst tot hässlich + //{ + // sd.GoalList += goal.TypeDescription; + //} + } + } + } + } +} diff --git a/ReportImp/SBBMainzReports/QuittierungsbelegJaMainzWiJu.cs b/ReportImp/SBBMainzReports/QuittierungsbelegJaMainzWiJu.cs index 8e6616f5e..8c3306038 100644 --- a/ReportImp/SBBMainzReports/QuittierungsbelegJaMainzWiJu.cs +++ b/ReportImp/SBBMainzReports/QuittierungsbelegJaMainzWiJu.cs @@ -1,111 +1,111 @@ -using System; -using System.Collections; -using System.ComponentModel; -using BS.Shared.Core; -using DevExpress.XtraReports.UI; -using BeWo.Report.ReportObjects; -using BeWo.Report; -using System.Collections.Generic; -using System.Drawing; -using BeWo.Data.Access; -using BeWo.Data.Entities; -using BeWo.SBBMainzReports.Calculations; -using BeWo.Service.DCEntityMapper; -using BeWo.Service.Plugins; -using BS.Shared; -using BS.Shared.Services; -using DevExpress.XtraPrinting; -using BS.Shared.DataContracts; -using System.Text; -using System.Linq; - -namespace SBBMainzReports -{ - public partial class QuittierungsbelegJaMainzWiJu : DevExpress.XtraReports.UI.XtraReport, IBeWoReport - { - - public QuittierungsbelegJaMainzWiJu() - { - InitializeComponent(); - } - - public void SetReportDataSource(ServicesOverviewRO pRO) - { - decimal anteilBetreuungsstundenProzent = 100; - decimal anteilOverheadProzent = 0; - double TotalMin = 0.00; - - if (pRO.Services != null) - { - List servicesBillable = new List(); - - foreach (ServicesOverviewRO.ServiceDetail s in pRO.Services) - { - var serviceRecord = DAOFactory.GenericDAO.LoadByID(s.ServiceRecordOid); - var srDc = MapperFactory.ServiceRecordDC_ServiceRecord.MapToNewDC(serviceRecord); - s.ServiceCategory = ""; - - if (s.IsBillable) - { - TotalMin += s.Minutes/60; - } - } - } - - SetKopfbereich(pRO); - - pRO.ApprovedFLSPerMonth = pRO.ApprovedFLSPerWeek * 4.33m; - DateTime start = pRO.StartDate; - DateTime end = pRO.EndDate; - - - var hp = GetCurrentC2S(pRO); - if (hp != null) - { - if (hp.StartDate > start) - start = hp.StartDate.Value; - if (hp.EndDate < end) - end = hp.EndDate.Value; - } - decimal days = (decimal)end.Subtract(start).TotalDays + 1; - - pRO.ApprovedFLSPerMonth *= days / DateTime.DaysInMonth(pRO.StartDate.Year, pRO.StartDate.Month); - - decimal gesamt = (decimal)TotalMin; - decimal mehrMinusStunden = gesamt - pRO.ApprovedFLSPerMonth; - decimal uebertragVormonat = BerechneUebertragVormonat(pRO, anteilBetreuungsstundenProzent, anteilOverheadProzent); - - bool uebertrag = MussUebertragBerechnen(pRO); - - cellMehrMinusStunden.Text = String.Format("{0:0.000}", mehrMinusStunden); - cellUebertragVormonat.Text = String.Format("{0:0.000}", uebertragVormonat); - if (uebertrag) - cellUebertragNaechsterMonat.Text = String.Format("{0:0.000}", mehrMinusStunden + uebertragVormonat); - else - cellUebertragNaechsterMonat.Text = String.Format("{0:0.000}", 0); - - // cellWoechentlichKlientenbezogen.Text = String.Format("{0:0.00}", (pRO.ApprovedFLSPerMonth - uebertragVormonat) * 0.7m / 4.33m); - // cellMonatlichKlientenbezogen.Text = String.Format("{0:0.00}", pRO.ApprovedFLSPerMonth * 0.7m); - - cellBetreuungstunden.Text = String.Format("{0:0.##}% Betreuungsstunden", anteilBetreuungsstundenProzent); - - var minutes = (decimal)Math.Round(pRO.TotalFLMBillable / 60, 3, MidpointRounding.AwayFromZero); - var pausch = Math.Round(((decimal)pRO.TotalFLMBillable / anteilBetreuungsstundenProzent * anteilOverheadProzent) / 60, 3, MidpointRounding.AwayFromZero); - - cellMinutes.Text = String.Format("{0:0.000}", minutes); - - this.bindingSource1.DataSource = pRO; - } - - private CostBearer2SupportConcept GetCurrentC2S(ServicesOverviewRO ro) - { - if (ro.CostBearer2SupportConceptList != null && ro.CostBearer2SupportConceptList.Count > 0) - { - foreach (var c2sc in ro.CostBearer2SupportConceptList) - { - var cbName = c2sc.CostBearer.Organisation.Name; - if ((cbName.ToLower().Contains("jugendamt der landeshauptstadt mainz") || - cbName.Equals("Landeshauptstadt Wiesbaden Amt für Soziale Arbeit und ambulante Erziehungshilfen")) +using System; +using System.Collections; +using System.ComponentModel; +using BS.Shared.Core; +using DevExpress.XtraReports.UI; +using BeWo.Report.ReportObjects; +using BeWo.Report; +using System.Collections.Generic; +using System.Drawing; +using BeWo.Data.Access; +using BeWo.Data.Entities; +using BeWo.SBBMainzReports.Calculations; +using BeWo.Service.DCEntityMapper; +using BeWo.Service.Plugins; +using BS.Shared; +using BS.Shared.Services; +using DevExpress.XtraPrinting; +using BS.Shared.DataContracts; +using System.Text; +using System.Linq; + +namespace SBBMainzReports +{ + public partial class QuittierungsbelegJaMainzWiJu : DevExpress.XtraReports.UI.XtraReport, IBeWoReport + { + + public QuittierungsbelegJaMainzWiJu() + { + InitializeComponent(); + } + + public void SetReportDataSource(ServicesOverviewRO pRO) + { + decimal anteilBetreuungsstundenProzent = 100; + decimal anteilOverheadProzent = 0; + double TotalMin = 0.00; + + if (pRO.Services != null) + { + List servicesBillable = new List(); + + foreach (ServicesOverviewRO.ServiceDetail s in pRO.Services) + { + var serviceRecord = DAOFactory.GenericDAO.LoadByID(s.ServiceRecordOid); + var srDc = MapperFactory.ServiceRecordDC_ServiceRecord.MapToNewDC(serviceRecord); + s.ServiceCategory = ""; + + if (s.IsBillable) + { + TotalMin += s.Minutes/60; + } + } + } + + SetKopfbereich(pRO); + + pRO.ApprovedFLSPerMonth = pRO.ApprovedFLSPerWeek * 4.33m; + DateTime start = pRO.StartDate; + DateTime end = pRO.EndDate; + + + var hp = GetCurrentC2S(pRO); + if (hp != null) + { + if (hp.StartDate > start) + start = hp.StartDate.Value; + if (hp.EndDate < end) + end = hp.EndDate.Value; + } + decimal days = (decimal)end.Subtract(start).TotalDays + 1; + + pRO.ApprovedFLSPerMonth *= days / DateTime.DaysInMonth(pRO.StartDate.Year, pRO.StartDate.Month); + + decimal gesamt = (decimal)TotalMin; + decimal mehrMinusStunden = gesamt - pRO.ApprovedFLSPerMonth; + decimal uebertragVormonat = BerechneUebertragVormonat(pRO, anteilBetreuungsstundenProzent, anteilOverheadProzent); + + bool uebertrag = MussUebertragBerechnen(pRO); + + cellMehrMinusStunden.Text = String.Format("{0:0.000}", mehrMinusStunden); + cellUebertragVormonat.Text = String.Format("{0:0.000}", uebertragVormonat); + if (uebertrag) + cellUebertragNaechsterMonat.Text = String.Format("{0:0.000}", mehrMinusStunden + uebertragVormonat); + else + cellUebertragNaechsterMonat.Text = String.Format("{0:0.000}", 0); + + // cellWoechentlichKlientenbezogen.Text = String.Format("{0:0.00}", (pRO.ApprovedFLSPerMonth - uebertragVormonat) * 0.7m / 4.33m); + // cellMonatlichKlientenbezogen.Text = String.Format("{0:0.00}", pRO.ApprovedFLSPerMonth * 0.7m); + + cellBetreuungstunden.Text = String.Format("{0:0.##}% Betreuungsstunden", anteilBetreuungsstundenProzent); + + var minutes = (decimal)Math.Round(pRO.TotalFLMBillable / 60, 3, MidpointRounding.AwayFromZero); + var pausch = Math.Round(((decimal)pRO.TotalFLMBillable / anteilBetreuungsstundenProzent * anteilOverheadProzent) / 60, 3, MidpointRounding.AwayFromZero); + + cellMinutes.Text = String.Format("{0:0.000}", minutes); + + this.bindingSource1.DataSource = pRO; + } + + private CostBearer2SupportConcept GetCurrentC2S(ServicesOverviewRO ro) + { + if (ro.CostBearer2SupportConceptList != null && ro.CostBearer2SupportConceptList.Count > 0) + { + foreach (var c2sc in ro.CostBearer2SupportConceptList) + { + var cbName = c2sc.CostBearer.Organisation.Name; + if ((cbName.ToLower().Contains("jugendamt der landeshauptstadt mainz") || ro.Costbearer.ToLower().Contains("jugend und familie mainz – amt 51") || + cbName.Equals("Landeshauptstadt Wiesbaden Amt für Soziale Arbeit und ambulante Erziehungshilfen")) && c2sc.StartDate <= ro.StartDate && c2sc.EndDate >= ro.StartDate) { if (cbName.Equals("Landeshauptstadt Wiesbaden Amt für Soziale Arbeit und ambulante Erziehungshilfen")) @@ -113,201 +113,201 @@ namespace SBBMainzReports lblReceiver.Text = "Landeshauptstadt Wiesbaden"; } return c2sc; - } - } - } - - return null; - } - - private void SetKopfbereich(ServicesOverviewRO pRO) - { - String betreuer1 = ""; - long betreuer1EOid = 0; - String betreuer2 = ""; - long betreuer2EOid = 0; - - var c2s = GetCurrentC2S(pRO); - if (c2s != null) - { - SupportConceptApprovalPeriod2Employee p2e; - - foreach (var scap in c2s.ApprovalPeriodList) - { - if (scap.SupportConceptApprovalPeriod2Employee != null) - { - var sortedScs = scap.SupportConceptApprovalPeriod2Employee.OrderByDescending(s => s.Betreuungsschluessel).ToList(); - if (sortedScs.Count > 0) - { - p2e = sortedScs[0]; - betreuer1 = p2e.Employee.Person.FirstNameLastName; - betreuer1EOid = (long)p2e.Employee.Oid; - } - - if (sortedScs.Count > 1) - { - p2e = sortedScs[1]; - betreuer2 = p2e.Employee.Person.FirstNameLastName; - betreuer2EOid = (long)p2e.Employee.Oid; - } - } - } - - lblBetreuer1.Text = betreuer1; - lblBetreuer2.Text = betreuer2; - - String qualifikation1 = ""; - String qualifikation2 = ""; - - if (betreuer1EOid != 0) - { - var employee = DAOFactory.GenericDAO.LoadByID(betreuer1EOid); - foreach (var valueEntry in employee.ValueList) - { - if (valueEntry.Entry.Type == ValueListEntryType.StaffQualificationsType) - if (valueEntry.Entry.Value.StartsWith("Q") && valueEntry.Entry.Value.Length < 4) - qualifikation1 = valueEntry.Entry.Value.ToString(); - } - - } - - if (betreuer2EOid != 0) - { - var employee = DAOFactory.GenericDAO.LoadByID(betreuer2EOid); - foreach (var valueEntry in employee.ValueList) - { - if (valueEntry.Entry.Type == ValueListEntryType.StaffQualificationsType) - if (valueEntry.Entry.Value.StartsWith("Q") && valueEntry.Entry.Value.Length < 4) - qualifikation2 = valueEntry.Entry.Value.ToString(); - } - - } - lblQualifikation1.Text = qualifikation1; - lblQualifikation2.Text = qualifikation2; - - if (c2s.CostBearerContactPerson != null) - { - if (c2s.CostBearerContactPerson.Sex.HasValue && - c2s.CostBearerContactPerson.Sex.Value == Sex.Female) - lblAnsprechpartner.Text = "Frau "; - else if (c2s.CostBearerContactPerson.Sex.HasValue && - c2s.CostBearerContactPerson.Sex.Value == Sex.Male) - lblAnsprechpartner.Text = "Herr "; - - lblAnsprechpartner.Text += c2s.CostBearerContactPerson.LastName; - } - } - } - - private decimal BerechneUebertragVormonat(ServicesOverviewRO pRO, decimal anteilBetreuungsstundenProzent, decimal anteilOverheadProzent) - { - var calc = new SBBMainzCalculations(); - - decimal uebertrag = 0; - if (pRO.CostBearer2SupportConceptList != null && pRO.CostBearer2SupportConceptList.Count > 0) - { - var c2s = pRO.CostBearer2SupportConceptList[0]; - - IList allServiceRecords = c2s.ServiceRecords; - - decimal flmSoll = 0; - - - DateTime start = c2s.StartDate.Value; - int months = 0; - while (start < pRO.StartDate) - { - var dc = MapperFactory.SupportConceptCostBearerRelDC_CostBearer2SupportConcept.MapToNewDC(c2s); - - var approvedPerWeek = calc.GetApprovedHoursPerWeek(dc, start, false) ?? 0; - - decimal soll = approvedPerWeek * 4.33m; - if (start.Day != 1) - { - DateTime end = new DateTime(start.AddMonths(1).Year, start.AddMonths(1).Month, 1); - - decimal days = (decimal)end.Subtract(start).TotalDays; - - soll *= days / DateTime.DaysInMonth(start.Year, start.Month); - } - flmSoll += soll; - decimal ist = GetIstImMonat(allServiceRecords, start); - ist += ist / anteilBetreuungsstundenProzent * anteilOverheadProzent; - ist /= 60; - var uebertragMonat = ist - soll; - - uebertrag += uebertragMonat; - start = start.AddMonths(1); - start = new DateTime(start.Year, start.Month, 1); - months++; - var mod = months % 3; - if (mod == 0) - uebertrag = 0; - } - - - } - return uebertrag; - } - - private decimal GetIstImMonat(IList allServiceRecords, DateTime start) - { - DateTime monatEnd = start.AddMonths(1); - monatEnd = new DateTime(monatEnd.Year, monatEnd.Month, 1); - - decimal ist = 0; - - Dictionary groupBookingDict = new Dictionary(); - foreach (var item in allServiceRecords) - { - if (!item.GroupOid.HasValue || !groupBookingDict.ContainsKey(item.GroupOid.Value)) - { - if (item.Start != null) - { - if (item.Start >= start && item.Start.Value < monatEnd) - { - if (item.ServiceDescription != null && item.ServiceDescription.ServiceCategory != null && item.ServiceDescription.ServiceCategory.IsBillable) - { - var p = item.ServiceDescription.ServiceCategory.ProzentAbrechnung; - if (item.ServiceDescription.ProzentAbrechnung.HasValue) - { - p = item.ServiceDescription.ProzentAbrechnung.Value; - - } - ist += (item.RoundedDuration * p) / 100; - - if (item.GroupOid.HasValue) - groupBookingDict.Add(item.GroupOid.Value, true); - } - } - } - } - } - - return ist; - } - - private bool MussUebertragBerechnen(ServicesOverviewRO pRO) - { - if (pRO.CostBearer2SupportConceptList != null && pRO.CostBearer2SupportConceptList.Count > 0) - { - var c2s = pRO.CostBearer2SupportConceptList[0]; - - int months = 0; - - DateTime start = c2s.StartDate.Value; - - while (start < pRO.EndDate) - { - months++; - start = start.AddMonths(1); - } - - var mod = months % 3; - if (mod == 0) - return false; - } - return true; - } - } -} + } + } + } + + return null; + } + + private void SetKopfbereich(ServicesOverviewRO pRO) + { + String betreuer1 = ""; + long betreuer1EOid = 0; + String betreuer2 = ""; + long betreuer2EOid = 0; + + var c2s = GetCurrentC2S(pRO); + if (c2s != null) + { + SupportConceptApprovalPeriod2Employee p2e; + + foreach (var scap in c2s.ApprovalPeriodList) + { + if (scap.SupportConceptApprovalPeriod2Employee != null) + { + var sortedScs = scap.SupportConceptApprovalPeriod2Employee.OrderByDescending(s => s.Betreuungsschluessel).ToList(); + if (sortedScs.Count > 0) + { + p2e = sortedScs[0]; + betreuer1 = p2e.Employee.Person.FirstNameLastName; + betreuer1EOid = (long)p2e.Employee.Oid; + } + + if (sortedScs.Count > 1) + { + p2e = sortedScs[1]; + betreuer2 = p2e.Employee.Person.FirstNameLastName; + betreuer2EOid = (long)p2e.Employee.Oid; + } + } + } + + lblBetreuer1.Text = betreuer1; + lblBetreuer2.Text = betreuer2; + + String qualifikation1 = ""; + String qualifikation2 = ""; + + if (betreuer1EOid != 0) + { + var employee = DAOFactory.GenericDAO.LoadByID(betreuer1EOid); + foreach (var valueEntry in employee.ValueList) + { + if (valueEntry.Entry.Type == ValueListEntryType.StaffQualificationsType) + if (valueEntry.Entry.Value.StartsWith("Q") && valueEntry.Entry.Value.Length < 4) + qualifikation1 = valueEntry.Entry.Value.ToString(); + } + + } + + if (betreuer2EOid != 0) + { + var employee = DAOFactory.GenericDAO.LoadByID(betreuer2EOid); + foreach (var valueEntry in employee.ValueList) + { + if (valueEntry.Entry.Type == ValueListEntryType.StaffQualificationsType) + if (valueEntry.Entry.Value.StartsWith("Q") && valueEntry.Entry.Value.Length < 4) + qualifikation2 = valueEntry.Entry.Value.ToString(); + } + + } + lblQualifikation1.Text = qualifikation1; + lblQualifikation2.Text = qualifikation2; + + if (c2s.CostBearerContactPerson != null) + { + if (c2s.CostBearerContactPerson.Sex.HasValue && + c2s.CostBearerContactPerson.Sex.Value == Sex.Female) + lblAnsprechpartner.Text = "Frau "; + else if (c2s.CostBearerContactPerson.Sex.HasValue && + c2s.CostBearerContactPerson.Sex.Value == Sex.Male) + lblAnsprechpartner.Text = "Herr "; + + lblAnsprechpartner.Text += c2s.CostBearerContactPerson.LastName; + } + } + } + + private decimal BerechneUebertragVormonat(ServicesOverviewRO pRO, decimal anteilBetreuungsstundenProzent, decimal anteilOverheadProzent) + { + var calc = new SBBMainzCalculations(); + + decimal uebertrag = 0; + if (pRO.CostBearer2SupportConceptList != null && pRO.CostBearer2SupportConceptList.Count > 0) + { + var c2s = pRO.CostBearer2SupportConceptList[0]; + + IList allServiceRecords = c2s.ServiceRecords; + + decimal flmSoll = 0; + + + DateTime start = c2s.StartDate.Value; + int months = 0; + while (start < pRO.StartDate) + { + var dc = MapperFactory.SupportConceptCostBearerRelDC_CostBearer2SupportConcept.MapToNewDC(c2s); + + var approvedPerWeek = calc.GetApprovedHoursPerWeek(dc, start, false) ?? 0; + + decimal soll = approvedPerWeek * 4.33m; + if (start.Day != 1) + { + DateTime end = new DateTime(start.AddMonths(1).Year, start.AddMonths(1).Month, 1); + + decimal days = (decimal)end.Subtract(start).TotalDays; + + soll *= days / DateTime.DaysInMonth(start.Year, start.Month); + } + flmSoll += soll; + decimal ist = GetIstImMonat(allServiceRecords, start); + ist += ist / anteilBetreuungsstundenProzent * anteilOverheadProzent; + ist /= 60; + var uebertragMonat = ist - soll; + + uebertrag += uebertragMonat; + start = start.AddMonths(1); + start = new DateTime(start.Year, start.Month, 1); + months++; + var mod = months % 3; + if (mod == 0) + uebertrag = 0; + } + + + } + return uebertrag; + } + + private decimal GetIstImMonat(IList allServiceRecords, DateTime start) + { + DateTime monatEnd = start.AddMonths(1); + monatEnd = new DateTime(monatEnd.Year, monatEnd.Month, 1); + + decimal ist = 0; + + Dictionary groupBookingDict = new Dictionary(); + foreach (var item in allServiceRecords) + { + if (!item.GroupOid.HasValue || !groupBookingDict.ContainsKey(item.GroupOid.Value)) + { + if (item.Start != null) + { + if (item.Start >= start && item.Start.Value < monatEnd) + { + if (item.ServiceDescription != null && item.ServiceDescription.ServiceCategory != null && item.ServiceDescription.ServiceCategory.IsBillable) + { + var p = item.ServiceDescription.ServiceCategory.ProzentAbrechnung; + if (item.ServiceDescription.ProzentAbrechnung.HasValue) + { + p = item.ServiceDescription.ProzentAbrechnung.Value; + + } + ist += (item.RoundedDuration * p) / 100; + + if (item.GroupOid.HasValue) + groupBookingDict.Add(item.GroupOid.Value, true); + } + } + } + } + } + + return ist; + } + + private bool MussUebertragBerechnen(ServicesOverviewRO pRO) + { + if (pRO.CostBearer2SupportConceptList != null && pRO.CostBearer2SupportConceptList.Count > 0) + { + var c2s = pRO.CostBearer2SupportConceptList[0]; + + int months = 0; + + DateTime start = c2s.StartDate.Value; + + while (start < pRO.EndDate) + { + months++; + start = start.AddMonths(1); + } + + var mod = months % 3; + if (mod == 0) + return false; + } + return true; + } + } +} diff --git a/ReportImp/SBBMainzReports/QuittierungsbelegJugendamt.cs b/ReportImp/SBBMainzReports/QuittierungsbelegJugendamt.cs index 4bb450c15..13621c942 100644 --- a/ReportImp/SBBMainzReports/QuittierungsbelegJugendamt.cs +++ b/ReportImp/SBBMainzReports/QuittierungsbelegJugendamt.cs @@ -41,8 +41,8 @@ namespace SBBMainzReports anteilOverheadProzent = 35; } - if (!String.IsNullOrEmpty(pRO.Costbearer) && - pRO.Costbearer.Contains("Jugendamt der Landeshauptstadt Mainz")) + if (!String.IsNullOrEmpty(pRO.Costbearer) && + (pRO.Costbearer.Contains("Jugendamt der Landeshauptstadt Mainz") || pRO.Costbearer.ToLower().Contains("jugend und familie mainz – amt 51"))) { anteilBetreuungsstundenProzent = 70; anteilOverheadProzent = 30; diff --git a/ReportImp/SBBMainzReports/SBBMainzReportCreator.cs b/ReportImp/SBBMainzReports/SBBMainzReportCreator.cs index 7b0cdd711..ab577925c 100644 --- a/ReportImp/SBBMainzReports/SBBMainzReportCreator.cs +++ b/ReportImp/SBBMainzReports/SBBMainzReportCreator.cs @@ -70,7 +70,7 @@ namespace SBBMainzReports tsRo.TotalFLMBillable += s.Minutes; tsRo.TotalFLMBillable += s.Minutes / 60; } - else if (ro.Costbearer.ToLower().Contains("jugendamt der landeshauptstadt mainz") + else if (ro.Costbearer.ToLower().Contains("jugendamt der landeshauptstadt mainz") || ro.Costbearer.ToLower().Contains("jugend und familie mainz – amt 51") || ro.Costbearer.Equals("Landeshauptstadt Wiesbaden Amt für Soziale Arbeit und ambulante Erziehungshilfen")) //&& (s.ServiceCategory.ToLower().Contains("spfh") || s.ServiceCategory.ToLower().Contains("erziehungsbeistand"))) { diff --git a/ReportImp/SBBMainzReports/ServiceInvoiceReport.Designer.cs b/ReportImp/SBBMainzReports/ServiceInvoiceReport.Designer.cs index 7278515cf..b95f6b9c3 100644 --- a/ReportImp/SBBMainzReports/ServiceInvoiceReport.Designer.cs +++ b/ReportImp/SBBMainzReports/ServiceInvoiceReport.Designer.cs @@ -89,14 +89,14 @@ namespace SBBMainzReports this.xrTableCell44 = new DevExpress.XtraReports.UI.XRTableCell(); this.xrTableCell9 = new DevExpress.XtraReports.UI.XRTableCell(); this.xrTableCell47 = new DevExpress.XtraReports.UI.XRTableCell(); - this.PageFooter = new DevExpress.XtraReports.UI.PageFooterBand(); - this.xrLabel15 = new DevExpress.XtraReports.UI.XRLabel(); - this.xrPictureBox2 = new DevExpress.XtraReports.UI.XRPictureBox(); + this.bindingSource1 = new System.Windows.Forms.BindingSource(this.components); this.ReportFooter = new DevExpress.XtraReports.UI.ReportFooterBand(); this.xrLabel13 = new DevExpress.XtraReports.UI.XRLabel(); this.xrLabel18 = new DevExpress.XtraReports.UI.XRLabel(); this.xrLabel19 = new DevExpress.XtraReports.UI.XRLabel(); - this.bindingSource1 = new System.Windows.Forms.BindingSource(this.components); + this.PageFooter = new DevExpress.XtraReports.UI.PageFooterBand(); + this.xrLabel15 = new DevExpress.XtraReports.UI.XRLabel(); + this.xrPictureBox2 = new DevExpress.XtraReports.UI.XRPictureBox(); ((System.ComponentModel.ISupportInitialize)(this.xrTable1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.xrTable2)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.xrTable6)).BeginInit(); @@ -408,7 +408,7 @@ namespace SBBMainzReports // xrTableCell4 // this.xrTableCell4.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] { - new DevExpress.XtraReports.UI.XRBinding("Text", null, "DebitorNumber")}); + new DevExpress.XtraReports.UI.XRBinding("Text", null, "CustomerReferenceNumber")}); this.xrTableCell4.Multiline = true; this.xrTableCell4.Name = "xrTableCell4"; this.xrTableCell4.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F); @@ -787,34 +787,9 @@ namespace SBBMainzReports this.xrTableCell47.TextFormatString = "{0} Euro"; this.xrTableCell47.Weight = 0.53064018869841689D; // - // PageFooter + // bindingSource1 // - this.PageFooter.Controls.AddRange(new DevExpress.XtraReports.UI.XRControl[] { - this.xrLabel15, - this.xrPictureBox2}); - this.PageFooter.HeightF = 121.0002F; - this.PageFooter.Name = "PageFooter"; - // - // xrLabel15 - // - this.xrLabel15.Font = new DevExpress.Drawing.DXFont("Arial", 10F); - this.xrLabel15.LocationFloat = new DevExpress.Utils.PointFloat(91.24998F, 75.00006F); - this.xrLabel15.Multiline = true; - this.xrLabel15.Name = "xrLabel15"; - this.xrLabel15.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F); - this.xrLabel15.SizeF = new System.Drawing.SizeF(544.6247F, 36F); - this.xrLabel15.StylePriority.UseFont = false; - this.xrLabel15.Text = "Sozialtherapeutische Beratungsstelle/Betreuungsverein e. V., VR-Nr.: 2648, AG Mai" + - "nz\r\nBank: Mainzer Volksbank - BIC: MVBMDE55 – IBAN: DE02 5519 0000 0327 4870 13\r" + - "\n"; - // - // xrPictureBox2 - // - this.xrPictureBox2.ImageSource = new DevExpress.XtraPrinting.Drawing.ImageSource("img", resources.GetString("xrPictureBox2.ImageSource")); - this.xrPictureBox2.LocationFloat = new DevExpress.Utils.PointFloat(510.0831F, 10.00016F); - this.xrPictureBox2.Name = "xrPictureBox2"; - this.xrPictureBox2.SizeF = new System.Drawing.SizeF(159.7919F, 111F); - this.xrPictureBox2.Sizing = DevExpress.XtraPrinting.ImageSizeMode.ZoomImage; + this.bindingSource1.DataSource = typeof(BeWo.Report.ReportObjects.ServiceInvoiceRO); // // ReportFooter // @@ -871,9 +846,34 @@ namespace SBBMainzReports this.xrLabel19.Text = "Rechnungsbetrag Gesamt:"; this.xrLabel19.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleRight; // - // bindingSource1 + // PageFooter // - this.bindingSource1.DataSource = typeof(BeWo.Report.ReportObjects.ServiceInvoiceRO); + this.PageFooter.Controls.AddRange(new DevExpress.XtraReports.UI.XRControl[] { + this.xrLabel15, + this.xrPictureBox2}); + this.PageFooter.HeightF = 121.0002F; + this.PageFooter.Name = "PageFooter"; + // + // xrLabel15 + // + this.xrLabel15.Font = new DevExpress.Drawing.DXFont("Arial", 10F); + this.xrLabel15.LocationFloat = new DevExpress.Utils.PointFloat(91.24998F, 75.00006F); + this.xrLabel15.Multiline = true; + this.xrLabel15.Name = "xrLabel15"; + this.xrLabel15.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F); + this.xrLabel15.SizeF = new System.Drawing.SizeF(544.6247F, 36F); + this.xrLabel15.StylePriority.UseFont = false; + this.xrLabel15.Text = "Sozialtherapeutische Beratungsstelle/Betreuungsverein e. V., VR-Nr.: 2648, AG Mai" + + "nz\r\nBank: Mainzer Volksbank - BIC: MVBMDE55 – IBAN: DE02 5519 0000 0327 4870 13\r" + + "\n"; + // + // xrPictureBox2 + // + this.xrPictureBox2.ImageSource = new DevExpress.XtraPrinting.Drawing.ImageSource("img", resources.GetString("xrPictureBox2.ImageSource")); + this.xrPictureBox2.LocationFloat = new DevExpress.Utils.PointFloat(510.0831F, 10.00016F); + this.xrPictureBox2.Name = "xrPictureBox2"; + this.xrPictureBox2.SizeF = new System.Drawing.SizeF(159.7919F, 111F); + this.xrPictureBox2.Sizing = DevExpress.XtraPrinting.ImageSizeMode.ZoomImage; // // ServiceInvoiceReport // diff --git a/ReportImp/SBBMainzReports/ServiceInvoiceReport.cs b/ReportImp/SBBMainzReports/ServiceInvoiceReport.cs index 9d28eb127..add58face 100644 --- a/ReportImp/SBBMainzReports/ServiceInvoiceReport.cs +++ b/ReportImp/SBBMainzReports/ServiceInvoiceReport.cs @@ -54,7 +54,7 @@ namespace SBBMainzReports } foreach (var ii in sip.ServiceInvoiceItems) { - if (!ii.ServiceDescription.ToLower().Contains("handgeld")) + if (!ii.ServiceDescription.ToLower().Contains("handgeld") && !ii.ServiceDescription.ToLower().Contains("hangeld")) { ii.ServiceDescription = "Fachleistungstunden / Monat"; ii.HourlyRateString = String.Format("zu {0:0.00} €", ii.HourlyRate); diff --git a/Service/Import/AvisImport/AviseImporter.cs b/Service/Import/AvisImport/AviseImporter.cs index 880bbffdb..7de1c283f 100644 --- a/Service/Import/AvisImport/AviseImporter.cs +++ b/Service/Import/AvisImport/AviseImporter.cs @@ -11,15 +11,11 @@ namespace BeWo.Service.Import.AvisImport public class AviseImporter { //Der Rückgabewert wird beim Client in einer Messagebox angezeigt - public virtual String ImportAvise(List avise) + public virtual String ImportAvise(List avise, List hilfeplaene) { - var hilfeplaene = CreateHilfeplanInfos(); - var importresult = ImportAbschlagszahlungen(avise, hilfeplaene); - String importDaten = "1 Datensatz"; String vorhandenDaten = "1 Datensatz"; - int importiertCount = 0; int bereitsVorhandenCount = 0; var irFalseList = new List(); @@ -74,7 +70,6 @@ namespace BeWo.Service.Import.AvisImport { sb.AppendLine(ir.Message); } - } var text = sb.ToString(); @@ -93,7 +88,6 @@ namespace BeWo.Service.Import.AvisImport foreach (var avis in avise) { var ir = ImportAbschlagszahlung(avis, hilfeplaene); - result.Add(ir); } @@ -124,7 +118,6 @@ namespace BeWo.Service.Import.AvisImport else { result.Message = String.Format("Es wurde kein Hilfeplan mit passendem Zeitraum gefunden."); - DateTime monatStart = new DateTime(avis.GueltigkeitsDatum.Year, avis.GueltigkeitsDatum.Month, 1); DateTime monatEnde = monatStart.AddMonths(1); @@ -176,7 +169,6 @@ namespace BeWo.Service.Import.AvisImport //Prüfe ob Klientname vorkommt //var nameBuchung = avis.Verwendungszweck.ToLower(); - //var nachname = hp.CustomerLastName.ToLower(); //var vorname = hp.CustomerFirstName.ToLower(); //nachname = nachname.Replace("ö", "oe"); @@ -187,9 +179,7 @@ namespace BeWo.Service.Import.AvisImport //vorname = vorname.Replace("ü", "ue"); //vorname = vorname.Replace("ä", "ae"); //vorname = vorname.Replace("ß", "ss"); - //var name = String.Format("{0}{1}", nachname, vorname); - //if (nameBuchung.Contains(name)) //{ // return true; @@ -201,7 +191,6 @@ namespace BeWo.Service.Import.AvisImport public virtual AccountingTransaction CreateAbschlagszahlung(Avis avis, HilfeplanInfo hp) { var newAz = new AccountingTransaction(); - newAz.CostBearer2SupportConcept = hp.CostBearer2SupportConcept; newAz.Amount = avis.Betrag; newAz.BookingDate = avis.BuchungsDatum; @@ -220,39 +209,8 @@ namespace BeWo.Service.Import.AvisImport public virtual bool CheckObAbschlagszahlungBereitsImportiert(Avis avis, HilfeplanInfo hp) { var azAltList = DAOFactory.SearchDAO.FindAccountingTransactionsWithImportNotice(CreateImportNotice(avis)); - return azAltList != null && azAltList.Any(); } - - public virtual List CreateHilfeplanInfos() - { - List liste = new List(); - - var scList = DAOFactory.GenericDAO.GetAllActiveAndArchived(); - - foreach (var supportConcept in scList) - { - foreach (var cb2sc in supportConcept.CostBearer2SupportConceptList) - { - HilfeplanInfo hi = new HilfeplanInfo(); - - hi.Start = cb2sc.StartDate; - hi.Ende = cb2sc.EndDate; - - hi.Aktenzeichen = cb2sc.CustomerReferenceNumber; - hi.CostBearer2SupportConcept = cb2sc; - hi.CustomerFirstName = cb2sc.SupportConcept.Customer.Person.FirstName; - hi.CustomerLastName = cb2sc.SupportConcept.Customer.Person.LastName; - - if (hi.Start.HasValue && hi.Ende.HasValue && !String.IsNullOrEmpty(hi.Aktenzeichen)) - { - liste.Add(hi); - } - } - } - - return liste; - } } } diff --git a/Service/Import/AvisImport/LvrAviseImporter.cs b/Service/Import/AvisImport/LvrAviseImporter.cs index 1d069395c..73b18e9e6 100644 --- a/Service/Import/AvisImport/LvrAviseImporter.cs +++ b/Service/Import/AvisImport/LvrAviseImporter.cs @@ -32,25 +32,56 @@ namespace BeWo.Service.Import.AvisImport { var reader = new LvrAvisPdfReader(); var avise = reader.LeseAvise(daten); + var hilfeplaene = CreateHilfeplanInfos(); - return ImportAvise(avise); + return ImportAvise(avise, hilfeplaene); } public String ImportTextAvise(String text) { var reader = new LvrAvisTextReader(); var avise = reader.LeseAvise(text); + var hilfeplaene = CreateHilfeplanInfos(); - return ImportAvise(avise); + return ImportAvise(avise, hilfeplaene); } - public String ImportCsvAvise(String csv) + public virtual String ImportCsvAvise(String csv) { var reader = new LvrAvisCsvReader(); var avise = reader.LeseEinzelAvise(csv); - - return ImportAvise(avise); - } + var hilfeplaene = CreateHilfeplanInfos(); + + return ImportAvise(avise, hilfeplaene); + } + + // AB: verschoben um, die Hilfeplanauswahl ggf. spezifischer machen zu können + public virtual List CreateHilfeplanInfos() + { + List liste = new List(); + var scList = DAOFactory.GenericDAO.GetAllActiveAndArchived(); + + foreach (var supportConcept in scList) + { + foreach (var cb2sc in supportConcept.CostBearer2SupportConceptList) + { + HilfeplanInfo hi = new HilfeplanInfo(); + hi.Start = cb2sc.StartDate; + hi.Ende = cb2sc.EndDate; + hi.Aktenzeichen = cb2sc.CustomerReferenceNumber; + hi.CostBearer2SupportConcept = cb2sc; + hi.CustomerFirstName = cb2sc.SupportConcept.Customer.Person.FirstName; + hi.CustomerLastName = cb2sc.SupportConcept.Customer.Person.LastName; + + if (hi.Start.HasValue && hi.Ende.HasValue && !String.IsNullOrEmpty(hi.Aktenzeichen)) + { + liste.Add(hi); + } + } + } + + return liste; + } } } diff --git a/Service/Plugins/AccountingService.cs b/Service/Plugins/AccountingService.cs index 63c802fb9..1c9f2a534 100644 --- a/Service/Plugins/AccountingService.cs +++ b/Service/Plugins/AccountingService.cs @@ -80,14 +80,19 @@ namespace BeWo.Service.Plugins var rechnungen = new List(); foreach (var item in differenzRechnungChecks) { - if (item.VorhandeneRechungen.Count == 0) + if (item.VorhandeneRechungen.Count == 0 || !item.VorhandeneRechungen.Any(r => item.NeueRechnung.InvoiceBase.CustomerOid == r.InvoiceBase.CustomerOid)) { item.NeueRechnung.InvoiceBase.NeuErstellen = true; rechnungen.Add(item.NeueRechnung); } else { - rechnungen.Add(ErstelleDifferenzRechnung(item)); + var diffRechnung = ErstelleDifferenzRechnung(item); + if (diffRechnung != null) + { + diffRechnung.InvoiceBase.NeuErstellen = false; + rechnungen.Add(diffRechnung); + } } } @@ -100,29 +105,34 @@ namespace BeWo.Service.Plugins //var alterBetrag = item.VorhandeneRechungen.Sum(i => i.ClaimSum ?? 0); var letzteRg = item.VorhandeneRechungen.OrderByDescending(r => r.ServiceInvoiceOid).FirstOrDefault(); - if (item.NeueRechnung.ClaimSum == letzteRg.ClaimSum) + letzteRg = item.VorhandeneRechungen.FirstOrDefault(r => item.NeueRechnung.InvoiceBase.CustomerOid == r.InvoiceBase.CustomerOid); + if (letzteRg != null) { - diffRechnung = item.NeueRechnung; - diffRechnung.InvoiceBase.NeuErstellen = false; - diffRechnung.InvoiceBase.Hinweise = String.Format("Rechnung wurde bereits erstellt"); - } - else - { - diffRechnung = new ServiceInvoiceDC(); - diffRechnung.OriginalZurDifferenz = item.NeueRechnung; - diffRechnung.InvoiceBase = new InvoiceBaseDC(); - CopyInvoiceBaseDC(item.NeueRechnung.InvoiceBase, diffRechnung); + if (item.NeueRechnung.ClaimSum == letzteRg.ClaimSum) + { + diffRechnung = item.NeueRechnung; + diffRechnung.InvoiceBase.NeuErstellen = false; + diffRechnung.InvoiceBase.Hinweise = String.Format("Rechnung wurde bereits erstellt"); + } + else + { + diffRechnung = new ServiceInvoiceDC(); + diffRechnung.OriginalZurDifferenz = item.NeueRechnung; + diffRechnung.InvoiceBase = new InvoiceBaseDC(); + CopyInvoiceBaseDC(item.NeueRechnung.InvoiceBase, diffRechnung); - ServiceInvoice counterInvoice = new ServiceInvoice(); - var serviceInvoice = DAOFactory.SearchDAO.GetServiceInvoiceByInvoiceBaseOid(letzteRg.InvoiceBase.InvoiceBaseOid.Value); + ServiceInvoice counterInvoice = new ServiceInvoice(); + var serviceInvoice = DAOFactory.SearchDAO.GetServiceInvoiceByInvoiceBaseOid(letzteRg.InvoiceBase.InvoiceBaseOid.Value); - CopyServiceInvoice(serviceInvoice, counterInvoice); - SetzeStornoInfos(counterInvoice); - SetzeRechnungspositionenServiceInvoice(diffRechnung, counterInvoice, item); - - diffRechnung.InvoiceBase.NeuErstellen = true; - diffRechnung.InvoiceBase.Hinweise = String.Format("Rechnungsdifferenz zu Rechnung {0} in Höhe von {1:c}", letzteRg.InvoiceBase.InvoiceNumber, letzteRg.InvoiceBase.TotalAmount.Value); + CopyServiceInvoice(serviceInvoice, counterInvoice); + SetzeStornoInfos(counterInvoice); + SetzeRechnungspositionenServiceInvoice(diffRechnung, counterInvoice, item); + + diffRechnung.InvoiceBase.NeuErstellen = true; + diffRechnung.InvoiceBase.Hinweise = String.Format("Rechnungsdifferenz zu Rechnung {0} in Höhe von {1:c}", letzteRg.InvoiceBase.InvoiceNumber, letzteRg.InvoiceBase.TotalAmount.Value); + } } + return diffRechnung; } @@ -593,16 +603,27 @@ namespace BeWo.Service.Plugins && s.SupportConceptApprovalPeriod.SupportConceptApprovalPeriodOid.Value == NewSip.SupportConceptApprovalPeriod.SupportConceptApprovalPeriodOid.Value)) { var ip = diffRechnung.ServiceInvoicePeriods.Where(s => s.SupportConceptApprovalPeriod.SupportConceptApprovalPeriodOid.Value == NewSip.SupportConceptApprovalPeriod.SupportConceptApprovalPeriodOid.Value).First(); - if (ip.InvoiceItems != null && ip.InvoiceItems.Count > 0) - { - ip.Claim += NewSip.Claim; - foreach (var ii in NewSip.InvoiceItems) - { - ip.InvoiceItems.Add(ii); - } - } - } - else + if (ip.InvoiceItems != null && ip.InvoiceItems.Count > 0) + { + ip.Claim += NewSip.Claim; + foreach (var ii in NewSip.InvoiceItems) + { + ip.InvoiceItems.Add(ii); + } + + // Bei Rechnungspositionen mit negativem Betrag auf alte Rechnung verweisen + foreach (var iitem in ip.InvoiceItems) + { + if (iitem.AmountTotal < 0) + { + var vorhandeneRechnung = item.VorhandeneRechungen.FirstOrDefault(r => r.InvoiceBase != null && r.InvoiceBase.CustomerOid == ip.Customer.CustomerOid); + if (vorhandeneRechnung != null) + iitem.ItemDescription += string.Format(" (am {0:dd.MM.yyyy} in Rechnung {1} berechnet)", vorhandeneRechnung.InvoiceBase.InvoiceDate, vorhandeneRechnung.InvoiceBase.InvoiceNumber); + } + } + } + } + else { diffRechnung.ServiceInvoicePeriods.Add(NewSip); } diff --git a/Service/Plugins/DataImporter.cs b/Service/Plugins/DataImporter.cs index ca2917a88..655e455db 100644 --- a/Service/Plugins/DataImporter.cs +++ b/Service/Plugins/DataImporter.cs @@ -2,6 +2,7 @@ using BeWo.Service.MessageContracts; using BS.Shared.Core; + namespace BeWo.Service.Plugins { public class DataImporter : AbstractIDSpecificDefaultClass @@ -27,7 +28,7 @@ namespace BeWo.Service.Plugins public virtual UploadImportFileResult ImportLvrAvise(string filename, byte[] daten) { - var aviseImport = new LvrAviseImporter(); + var aviseImport = PluginLoader.FindClass(); var message = aviseImport.ImportAvise(filename, daten); var result = new UploadImportFileResult(); @@ -36,6 +37,5 @@ namespace BeWo.Service.Plugins return result; } - } }