diff --git a/BeWoPlanerMobil/Controllers/MainController.cs b/BeWoPlanerMobil/Controllers/MainController.cs index f7d959929..935236d14 100644 --- a/BeWoPlanerMobil/Controllers/MainController.cs +++ b/BeWoPlanerMobil/Controllers/MainController.cs @@ -679,7 +679,7 @@ namespace BeWoPlanerMobil.Controllers if(Model.IsInGroupBookingMode) { var list = GetSelectedGroupBookingSupportConcepts(); - + LoadSupportConceptThings(null, false); list.DoForEach(sc => { allGoals.AddRangeIfElementsNotIn(sc.Goals); }); } else if(!Model.IsInGroupBookingMode) @@ -3525,30 +3525,53 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public ActionResult AddScCbRelsToGroupBooking(string[] relOids, string[] groupOids) { - SkipModelInitialization = true; + if(!IsUserLoggedIn()) { TempData[TempDataConstants.DoLogoutKey] = true; return PartialView("GroupBookingScCbRelList"); } + AddScCbRelsToGroupOrMultiBooking(relOids, groupOids); + + return PartialView("GroupBookingScCbRelList", Model); + } + + [Authorize] + public ActionResult AddScCbRelsToMultiBooking(string[] relOids, string[] groupOids) + { + if (!IsUserLoggedIn()) + { + TempData[TempDataConstants.DoLogoutKey] = true; + return PartialView("MultiBookingScCbRelList"); + } + AddScCbRelsToGroupOrMultiBooking(relOids, groupOids); + + return PartialView("MultiBookingScCbRelList", Model); + } + + private void AddScCbRelsToGroupOrMultiBooking(string[] relOids, string[] groupOids) + { + + SkipModelInitialization = true; + var singleRels = new List(); var groupRels = new List(); var groups = new List(); - if(groupOids is null) + if (groupOids is null) { groupOids = Array.Empty(); } - if(relOids is null) + if (relOids is null) { relOids = Array.Empty(); } relOids.DoForEach(relOid => { - if(long.TryParse(relOid, out var singleRelOid)) + if (long.TryParse(relOid, out var singleRelOid)) { singleRels.AddIfNotIn(singleRelOid); } @@ -3556,19 +3579,21 @@ namespace BeWoPlanerMobil.Controllers groupOids.DoForEach(groupOid => { - if(long.TryParse(groupOid, out var g)) + if (long.TryParse(groupOid, out var g)) { groupRels.AddIfNotIn(g); } }); + Model.GroupsOfPeople = EmployeeService.GetAllGroups(LoggedInEmployee.EmployeeOid).OrderBy(gop => gop.Name).ToList(); + Model.GroupBookingSelectedGroupOfPeopleOids.Clear(); groupRels.DoForEach(groupOid => { var group = Model.GroupsOfPeople.FirstOrDefault(f => f.GroupOfPeopleOid.HasValue && f.GroupOfPeopleOid.Value.Equals(groupOid)); - if(group is null) + if (group is null) { return; } @@ -3578,7 +3603,7 @@ namespace BeWoPlanerMobil.Controllers }); Model.GroupBookingSelectedCostBearerSupportConcepts.Clear(); - + Model.GroupBookingSelectedCostBearerSupportConceptOids.Clear(); Model.GroupBookingSelectedCostBearerSupportConceptOids.AddRangeIfElementsNotIn(singleRels); @@ -3587,24 +3612,24 @@ namespace BeWoPlanerMobil.Controllers //var groupCostBearerRelations = CustomerService.GetSupportConceptCostBearerRelationsById(singleRels); - - foreach(var gruppe in groups.Where(g => g.GroupOfPeopleOid.HasValue)) + + foreach (var gruppe in groups.Where(g => g.GroupOfPeopleOid.HasValue)) { var groupRelOids = new List(); gruppe.SupportConceptList.ForEach(f => groupRelOids.AddRange(f.CostBearerRelOids)); - if(!gruppe.GroupOfPeopleOid.HasValue) + if (!gruppe.GroupOfPeopleOid.HasValue) { continue; } var groupOid = gruppe.GroupOfPeopleOid.Value; - if(singleRels.ContainsItems(groupRelOids)) + if (singleRels.ContainsItems(groupRelOids)) { Model.GroupBookingSelectedGroupOfPeopleOids.AddIfNotIn(groupOid); } - else if(Model.GroupBookingSelectedGroupOfPeopleOids.Contains(groupOid)) + else if (Model.GroupBookingSelectedGroupOfPeopleOids.Contains(groupOid)) { Model.GroupBookingSelectedGroupOfPeopleOids.Remove(groupOid); } @@ -3615,8 +3640,6 @@ namespace BeWoPlanerMobil.Controllers CreateModelSupportConceptListObjects(false); LoadSupportConceptThings(null, true); - - return PartialView("GroupBookingScCbRelList", Model); } [Authorize] @@ -4274,102 +4297,7 @@ namespace BeWoPlanerMobil.Controllers return PartialView("MultiBookingSelectionPartial", Model); } - [Authorize] - public ActionResult AddScCbRelsToMultiBooking(string[] relOids, string[] groupOids) - { - if(Model is null) - { - TempData[TempDataConstants.DoLogoutKey] = true; - return PartialView("MultiBookingScCbRelList"); - } - - var singleRels = new List(); - var groupRels = new List(); - var groups = new List(); - - if(groupOids is null) - { - groupOids = Array.Empty(); - } - - if(relOids is null) - { - relOids = Array.Empty(); - } - - relOids.DoForEach(relOid => - { - if(long.TryParse(relOid, out var singleRelOid)) - { - singleRels.AddIfNotIn(singleRelOid); - } - }); - - groupOids.DoForEach(groupOid => - { - if(long.TryParse(groupOid, out var g)) - { - groupRels.AddIfNotIn(g); - } - }); - - Model.GroupBookingSelectedGroupOfPeopleOids.Clear(); - - groupRels.DoForEach(groupOid => - { - var group = Model.GroupsOfPeople.FirstOrDefault(f => f.GroupOfPeopleOid.HasValue && f.GroupOfPeopleOid.Value.Equals(groupOid)); - - if(group is null) - { - return; - } - - groups.AddIfNotIn(group); - group.SupportConceptList.DoForEach(f => singleRels.AddRangeIfElementsNotIn(f.CostBearerRelOids)); - }); - - //Model.MultiBookingSelectedSupportConcepts.Clear(); - - Model.GroupBookingSelectedCostBearerSupportConceptOids.Clear(); - Model.GroupBookingSelectedCostBearerSupportConceptOids.AddRangeIfElementsNotIn(singleRels); - - //var selectedSupportConcepts = CustomerService.GetSupportConceptsByCostbearer2SupportConceptRelOids(singleRels); - - //var groupCostBearerRelations = CustomerService.GetSupportConceptCostBearerRelationsById(singleRels); - - - //Model.MultiBookingSelectedSupportConcepts.AddRangeIfElementsNotIn(selectedSupportConcepts); - - foreach(var gruppe in groups.Where(g => g.GroupOfPeopleOid.HasValue)) - { - var groupRelOids = new List(); - gruppe.SupportConceptList.ForEach(f => groupRelOids.AddRange(f.CostBearerRelOids)); - - if(!gruppe.GroupOfPeopleOid.HasValue) - { - continue; - } - - var groupOid = gruppe.GroupOfPeopleOid.Value; - - if(singleRels.ContainsItems(groupRelOids)) - { - Model.GroupBookingSelectedGroupOfPeopleOids.AddIfNotIn(groupOid); - } - else if(Model.GroupBookingSelectedGroupOfPeopleOids.Contains(groupOid)) - { - Model.GroupBookingSelectedGroupOfPeopleOids.Remove(groupOid); - } - } - - CreateModelSupportConceptListObjects(false); - LoadSupportConceptThings(null, true); - - //Model.SelectedConceptCostBearerRelationOids = Model.SelectedConceptCostBearerRelations.Select(s => s.CostBearer2SupportConceptOid.Value).ToList(); - //Model.MultiBookingSelectedSupportConceptOids = Model.MultiBookingSelectedSupportConcepts.Select(s => s.SupportConceptOid.Value).ToList(); - - return PartialView("MultiBookingScCbRelList", Model); - } + [Authorize] public ActionResult RemoveSupportConceptCostbearerRelFromMultiBooking(string relOid) diff --git a/ReportImp/CaritasverbandKelheim/Invoicing/CustomInvoiceNumberGenerator.cs b/ReportImp/CaritasverbandKelheim/Invoicing/CustomInvoiceNumberGenerator.cs index d763d3d0d..dfce01756 100644 --- a/ReportImp/CaritasverbandKelheim/Invoicing/CustomInvoiceNumberGenerator.cs +++ b/ReportImp/CaritasverbandKelheim/Invoicing/CustomInvoiceNumberGenerator.cs @@ -39,7 +39,7 @@ namespace CaritasverbandKelheim.Invoicing var team = c.Team2CustomerList != null && c.Team2CustomerList.Count > 0 ? c.Team2CustomerList[0].Team : null; if (team != null) { - if (team.Name.ToLower().Contains("ambulant betreutes wohnen")) + if (team.Name.ToLower().Contains("ambulant betreutes wohnen") || team.Name.Contains("ABW")) oid_ = 1; } } @@ -47,7 +47,7 @@ namespace CaritasverbandKelheim.Invoicing // Es wird also beim KT mit Textinhalt "ambulant betreutes wohnen" die Nummer für oid 1 geladen und bei "wohnen plus" die oid 2 else { - if (invoiceBase.RecipientOrganisation.ToLower().Contains("ambulant betreutes wohnen")) + if (invoiceBase.RecipientOrganisation.ToLower().Contains("ambulant betreutes wohnen") || invoiceBase.RecipientOrganisation.ToLower().Contains("ABW")) oid_ = 1; } 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/SHKServiceSBD/Reports/KalkulationReport.Designer.cs b/ReportImp/SHKServiceSBD/Reports/KalkulationReport.Designer.cs index 24706f7e5..df3fc6c67 100644 --- a/ReportImp/SHKServiceSBD/Reports/KalkulationReport.Designer.cs +++ b/ReportImp/SHKServiceSBD/Reports/KalkulationReport.Designer.cs @@ -30,6 +30,7 @@ namespace SHKServiceSBD.Reports private void InitializeComponent() { this.components = new System.ComponentModel.Container(); + DevExpress.XtraReports.UI.XRWatermark xrWatermark1 = new DevExpress.XtraReports.UI.XRWatermark(); this.Detail = new DevExpress.XtraReports.UI.DetailBand(); this.lblKlient = new DevExpress.XtraReports.UI.XRLabel(); this.xrLabel5 = new DevExpress.XtraReports.UI.XRLabel(); @@ -66,8 +67,12 @@ namespace SHKServiceSBD.Reports this.xrTableCell6 = new DevExpress.XtraReports.UI.XRTableCell(); this.xrTableCell7 = new DevExpress.XtraReports.UI.XRTableCell(); this.xrTableCell8 = new DevExpress.XtraReports.UI.XRTableCell(); + this.xrTableRow5 = new DevExpress.XtraReports.UI.XRTableRow(); + this.xrTableCell20 = new DevExpress.XtraReports.UI.XRTableCell(); + this.cellKostenAssiWoche = new DevExpress.XtraReports.UI.XRTableCell(); + this.cellKostenAssiMonat = new DevExpress.XtraReports.UI.XRTableCell(); + this.cellKostenAssiJahr = new DevExpress.XtraReports.UI.XRTableCell(); this.GroupHeader3 = new DevExpress.XtraReports.UI.GroupHeaderBand(); - this.xrLabel2 = new DevExpress.XtraReports.UI.XRLabel(); this.xrTable1 = new DevExpress.XtraReports.UI.XRTable(); this.xrTableRow2 = new DevExpress.XtraReports.UI.XRTableRow(); this.xrTableCell1 = new DevExpress.XtraReports.UI.XRTableCell(); @@ -75,7 +80,12 @@ namespace SHKServiceSBD.Reports this.xrTableCell3 = new DevExpress.XtraReports.UI.XRTableCell(); this.xrTableCell4 = new DevExpress.XtraReports.UI.XRTableCell(); this.xrTableCell19 = new DevExpress.XtraReports.UI.XRTableCell(); - this.bindingSource1 = new System.Windows.Forms.BindingSource(this.components); + this.xrTableRow6 = new DevExpress.XtraReports.UI.XRTableRow(); + this.xrTableCell24 = new DevExpress.XtraReports.UI.XRTableCell(); + this.cellKostenBefTag = new DevExpress.XtraReports.UI.XRTableCell(); + this.cellKostenBefWoche = new DevExpress.XtraReports.UI.XRTableCell(); + this.cellKostenBefMonat = new DevExpress.XtraReports.UI.XRTableCell(); + this.cellKostenBefJahr = new DevExpress.XtraReports.UI.XRTableCell(); this.GroupHeader2 = new DevExpress.XtraReports.UI.GroupHeaderBand(); this.tableBetreuungszeiten = new DevExpress.XtraReports.UI.XRTable(); this.xrTableRow3 = new DevExpress.XtraReports.UI.XRTableRow(); @@ -84,29 +94,24 @@ namespace SHKServiceSBD.Reports this.xrTableCell11 = new DevExpress.XtraReports.UI.XRTableCell(); this.xrTableCell12 = new DevExpress.XtraReports.UI.XRTableCell(); this.xrTableCell13 = new DevExpress.XtraReports.UI.XRTableCell(); - this.xrTableRow5 = new DevExpress.XtraReports.UI.XRTableRow(); - this.xrTableCell20 = new DevExpress.XtraReports.UI.XRTableCell(); - this.xrTableCell21 = new DevExpress.XtraReports.UI.XRTableCell(); - this.xrTableCell22 = new DevExpress.XtraReports.UI.XRTableCell(); - this.xrTableCell23 = new DevExpress.XtraReports.UI.XRTableCell(); - this.xrTableRow6 = new DevExpress.XtraReports.UI.XRTableRow(); - this.xrTableCell24 = new DevExpress.XtraReports.UI.XRTableCell(); - this.xrTableCell25 = new DevExpress.XtraReports.UI.XRTableCell(); - this.xrTableCell26 = new DevExpress.XtraReports.UI.XRTableCell(); - this.xrTableCell27 = new DevExpress.XtraReports.UI.XRTableCell(); - this.xrTableCell28 = new DevExpress.XtraReports.UI.XRTableCell(); this.GroupFooter1 = new DevExpress.XtraReports.UI.GroupFooterBand(); + this.lblAngebotGesamt = new DevExpress.XtraReports.UI.XRLabel(); + this.lblAngebotBefProMonat = new DevExpress.XtraReports.UI.XRLabel(); + this.lblAngebotAssProMonat = new DevExpress.XtraReports.UI.XRLabel(); this.xrLabel8 = new DevExpress.XtraReports.UI.XRLabel(); this.xrLabel12 = new DevExpress.XtraReports.UI.XRLabel(); this.xrLabel13 = new DevExpress.XtraReports.UI.XRLabel(); - this.lblAngebotAssProMonat = new DevExpress.XtraReports.UI.XRLabel(); - this.lblAngebotBefProMonat = new DevExpress.XtraReports.UI.XRLabel(); - this.lblAngebotGesamt = new DevExpress.XtraReports.UI.XRLabel(); + this.xrLabel15 = new DevExpress.XtraReports.UI.XRLabel(); + this.lblKmProTag = new DevExpress.XtraReports.UI.XRLabel(); + this.xrLabel16 = new DevExpress.XtraReports.UI.XRLabel(); + this.lblEuroProKm = new DevExpress.XtraReports.UI.XRLabel(); + this.xrLabel2 = new DevExpress.XtraReports.UI.XRLabel(); + this.bindingSource1 = new System.Windows.Forms.BindingSource(this.components); ((System.ComponentModel.ISupportInitialize)(this.xrTable3)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.xrTable2)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.xrTable1)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.bindingSource1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.tableBetreuungszeiten)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.bindingSource1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this)).BeginInit(); // // Detail @@ -153,6 +158,10 @@ namespace SHKServiceSBD.Reports // ReportHeader // this.ReportHeader.Controls.AddRange(new DevExpress.XtraReports.UI.XRControl[] { + this.xrLabel16, + this.lblEuroProKm, + this.xrLabel15, + this.lblKmProTag, this.xrTable3, this.lblStundenProWoche, this.lblDurchschnittStundenProTag, @@ -171,7 +180,7 @@ namespace SHKServiceSBD.Reports this.lblAlter2, this.xrLabel5, this.lblKlient}); - this.ReportHeader.HeightF = 409.0001F; + this.ReportHeader.HeightF = 470.3334F; this.ReportHeader.Name = "ReportHeader"; // // xrTable3 @@ -179,7 +188,7 @@ namespace SHKServiceSBD.Reports this.xrTable3.Borders = ((DevExpress.XtraPrinting.BorderSide)((((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Top) | DevExpress.XtraPrinting.BorderSide.Right) | DevExpress.XtraPrinting.BorderSide.Bottom))); - this.xrTable3.LocationFloat = new DevExpress.Utils.PointFloat(0F, 391.0001F); + this.xrTable3.LocationFloat = new DevExpress.Utils.PointFloat(0.0002034505F, 452.3334F); this.xrTable3.Name = "xrTable3"; this.xrTable3.Rows.AddRange(new DevExpress.XtraReports.UI.XRTableRow[] { this.xrTableRow4}); @@ -317,7 +326,7 @@ namespace SHKServiceSBD.Reports // // xrLabel14 // - this.xrLabel14.LocationFloat = new DevExpress.Utils.PointFloat(0F, 361.0001F); + this.xrLabel14.LocationFloat = new DevExpress.Utils.PointFloat(0.0002034505F, 422.3334F); this.xrLabel14.Name = "xrLabel14"; this.xrLabel14.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F); this.xrLabel14.SizeF = new System.Drawing.SizeF(155.41F, 30F); @@ -497,28 +506,74 @@ namespace SHKServiceSBD.Reports this.xrTableCell8.Text = "Jährlich"; this.xrTableCell8.Weight = 0.34190062050507453D; // + // xrTableRow5 + // + this.xrTableRow5.Cells.AddRange(new DevExpress.XtraReports.UI.XRTableCell[] { + this.xrTableCell20, + this.cellKostenAssiWoche, + this.cellKostenAssiMonat, + this.cellKostenAssiJahr}); + this.xrTableRow5.Name = "xrTableRow5"; + this.xrTableRow5.Weight = 1.125D; + // + // xrTableCell20 + // + this.xrTableCell20.Borders = ((DevExpress.XtraPrinting.BorderSide)(((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Right) + | DevExpress.XtraPrinting.BorderSide.Bottom))); + this.xrTableCell20.Multiline = true; + this.xrTableCell20.Name = "xrTableCell20"; + this.xrTableCell20.Padding = new DevExpress.XtraPrinting.PaddingInfo(5, 0, 0, 0, 100F); + this.xrTableCell20.StylePriority.UseBorders = false; + this.xrTableCell20.StylePriority.UseFont = false; + this.xrTableCell20.StylePriority.UsePadding = false; + this.xrTableCell20.Text = "Schulassistenz"; + this.xrTableCell20.Weight = 0.253114955818913D; + // + // cellKostenAssiWoche + // + this.cellKostenAssiWoche.Borders = ((DevExpress.XtraPrinting.BorderSide)((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Bottom))); + this.cellKostenAssiWoche.Multiline = true; + this.cellKostenAssiWoche.Name = "cellKostenAssiWoche"; + this.cellKostenAssiWoche.Padding = new DevExpress.XtraPrinting.PaddingInfo(5, 0, 0, 0, 100F); + this.cellKostenAssiWoche.StylePriority.UseBorders = false; + this.cellKostenAssiWoche.StylePriority.UseFont = false; + this.cellKostenAssiWoche.StylePriority.UsePadding = false; + this.cellKostenAssiWoche.Weight = 0.2024922118380062D; + // + // cellKostenAssiMonat + // + this.cellKostenAssiMonat.Borders = ((DevExpress.XtraPrinting.BorderSide)(((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Right) + | DevExpress.XtraPrinting.BorderSide.Bottom))); + this.cellKostenAssiMonat.Multiline = true; + this.cellKostenAssiMonat.Name = "cellKostenAssiMonat"; + this.cellKostenAssiMonat.Padding = new DevExpress.XtraPrinting.PaddingInfo(5, 0, 0, 0, 100F); + this.cellKostenAssiMonat.StylePriority.UseBorders = false; + this.cellKostenAssiMonat.StylePriority.UsePadding = false; + this.cellKostenAssiMonat.Weight = 0.20249221183800623D; + // + // cellKostenAssiJahr + // + this.cellKostenAssiJahr.Borders = ((DevExpress.XtraPrinting.BorderSide)(((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Right) + | DevExpress.XtraPrinting.BorderSide.Bottom))); + this.cellKostenAssiJahr.Multiline = true; + this.cellKostenAssiJahr.Name = "cellKostenAssiJahr"; + this.cellKostenAssiJahr.Padding = new DevExpress.XtraPrinting.PaddingInfo(5, 0, 0, 0, 100F); + this.cellKostenAssiJahr.StylePriority.UseBorders = false; + this.cellKostenAssiJahr.StylePriority.UseFont = false; + this.cellKostenAssiJahr.StylePriority.UsePadding = false; + this.cellKostenAssiJahr.Weight = 0.34190062050507453D; + // // GroupHeader3 // this.GroupHeader3.Controls.AddRange(new DevExpress.XtraReports.UI.XRControl[] { this.xrLabel2, this.xrTable1}); - this.GroupHeader3.HeightF = 106F; + this.GroupHeader3.HeightF = 91.99998F; this.GroupHeader3.Name = "GroupHeader3"; // - // xrLabel2 - // - this.xrLabel2.Borders = DevExpress.XtraPrinting.BorderSide.Bottom; - this.xrLabel2.LocationFloat = new DevExpress.Utils.PointFloat(0F, 24F); - this.xrLabel2.Name = "xrLabel2"; - this.xrLabel2.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F); - this.xrLabel2.SizeF = new System.Drawing.SizeF(642.0001F, 24F); - this.xrLabel2.StylePriority.UseBorders = false; - this.xrLabel2.StylePriority.UseFont = false; - this.xrLabel2.Text = "Fahrtkosten / Bef. "; - // // xrTable1 // - this.xrTable1.LocationFloat = new DevExpress.Utils.PointFloat(0.0002034505F, 47.99998F); + this.xrTable1.LocationFloat = new DevExpress.Utils.PointFloat(0.0002034505F, 33.99999F); this.xrTable1.Name = "xrTable1"; this.xrTable1.Rows.AddRange(new DevExpress.XtraReports.UI.XRTableRow[] { this.xrTableRow2, @@ -595,9 +650,75 @@ namespace SHKServiceSBD.Reports this.xrTableCell19.Text = "Jährlich"; this.xrTableCell19.Weight = 0.18613738062968507D; // - // bindingSource1 + // xrTableRow6 // - this.bindingSource1.DataSource = typeof(BeWo.Report.ReportObjects.CustomerDataRO); + this.xrTableRow6.Cells.AddRange(new DevExpress.XtraReports.UI.XRTableCell[] { + this.xrTableCell24, + this.cellKostenBefTag, + this.cellKostenBefWoche, + this.cellKostenBefMonat, + this.cellKostenBefJahr}); + this.xrTableRow6.Name = "xrTableRow6"; + this.xrTableRow6.Weight = 2.5D; + // + // xrTableCell24 + // + this.xrTableCell24.Borders = ((DevExpress.XtraPrinting.BorderSide)(((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Right) + | DevExpress.XtraPrinting.BorderSide.Bottom))); + this.xrTableCell24.Multiline = true; + this.xrTableCell24.Name = "xrTableCell24"; + this.xrTableCell24.Padding = new DevExpress.XtraPrinting.PaddingInfo(5, 0, 0, 0, 100F); + this.xrTableCell24.StylePriority.UseBorders = false; + this.xrTableCell24.StylePriority.UseFont = false; + this.xrTableCell24.StylePriority.UsePadding = false; + this.xrTableCell24.Text = "Kosten\r\nBeförderung"; + this.xrTableCell24.Weight = 0.25311495581891308D; + // + // cellKostenBefTag + // + this.cellKostenBefTag.Borders = ((DevExpress.XtraPrinting.BorderSide)((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Bottom))); + this.cellKostenBefTag.Multiline = true; + this.cellKostenBefTag.Name = "cellKostenBefTag"; + this.cellKostenBefTag.Padding = new DevExpress.XtraPrinting.PaddingInfo(5, 0, 0, 0, 100F); + this.cellKostenBefTag.StylePriority.UseBorders = false; + this.cellKostenBefTag.StylePriority.UseFont = false; + this.cellKostenBefTag.StylePriority.UsePadding = false; + this.cellKostenBefTag.Weight = 0.18691588785046726D; + // + // cellKostenBefWoche + // + this.cellKostenBefWoche.Borders = ((DevExpress.XtraPrinting.BorderSide)(((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Right) + | DevExpress.XtraPrinting.BorderSide.Bottom))); + this.cellKostenBefWoche.Multiline = true; + this.cellKostenBefWoche.Name = "cellKostenBefWoche"; + this.cellKostenBefWoche.Padding = new DevExpress.XtraPrinting.PaddingInfo(5, 0, 0, 0, 100F); + this.cellKostenBefWoche.StylePriority.UseBorders = false; + this.cellKostenBefWoche.StylePriority.UsePadding = false; + this.cellKostenBefWoche.Weight = 0.18691588785046726D; + // + // cellKostenBefMonat + // + this.cellKostenBefMonat.Borders = ((DevExpress.XtraPrinting.BorderSide)(((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Right) + | DevExpress.XtraPrinting.BorderSide.Bottom))); + this.cellKostenBefMonat.Multiline = true; + this.cellKostenBefMonat.Name = "cellKostenBefMonat"; + this.cellKostenBefMonat.Padding = new DevExpress.XtraPrinting.PaddingInfo(5, 0, 0, 0, 100F); + this.cellKostenBefMonat.StylePriority.UseBorders = false; + this.cellKostenBefMonat.StylePriority.UseFont = false; + this.cellKostenBefMonat.StylePriority.UsePadding = false; + this.cellKostenBefMonat.Weight = 0.18691588785046728D; + // + // cellKostenBefJahr + // + this.cellKostenBefJahr.Borders = ((DevExpress.XtraPrinting.BorderSide)(((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Right) + | DevExpress.XtraPrinting.BorderSide.Bottom))); + this.cellKostenBefJahr.Multiline = true; + this.cellKostenBefJahr.Name = "cellKostenBefJahr"; + this.cellKostenBefJahr.Padding = new DevExpress.XtraPrinting.PaddingInfo(5, 0, 0, 0, 100F); + this.cellKostenBefJahr.StylePriority.UseBorders = false; + this.cellKostenBefJahr.StylePriority.UseFont = false; + this.cellKostenBefJahr.StylePriority.UsePadding = false; + this.cellKostenBefJahr.Weight = 0.18613738062968507D; // // GroupHeader2 // @@ -683,133 +804,6 @@ namespace SHKServiceSBD.Reports this.xrTableCell13.StylePriority.UsePadding = false; this.xrTableCell13.Weight = 0.15498442367601245D; // - // xrTableRow5 - // - this.xrTableRow5.Cells.AddRange(new DevExpress.XtraReports.UI.XRTableCell[] { - this.xrTableCell20, - this.xrTableCell21, - this.xrTableCell22, - this.xrTableCell23}); - this.xrTableRow5.Name = "xrTableRow5"; - this.xrTableRow5.Weight = 1.125D; - // - // xrTableCell20 - // - this.xrTableCell20.Borders = ((DevExpress.XtraPrinting.BorderSide)(((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Right) - | DevExpress.XtraPrinting.BorderSide.Bottom))); - this.xrTableCell20.Multiline = true; - this.xrTableCell20.Name = "xrTableCell20"; - this.xrTableCell20.Padding = new DevExpress.XtraPrinting.PaddingInfo(5, 0, 0, 0, 100F); - this.xrTableCell20.StylePriority.UseBorders = false; - this.xrTableCell20.StylePriority.UseFont = false; - this.xrTableCell20.StylePriority.UsePadding = false; - this.xrTableCell20.Text = "Schulassistenz"; - this.xrTableCell20.Weight = 0.253114955818913D; - // - // xrTableCell21 - // - this.xrTableCell21.Borders = ((DevExpress.XtraPrinting.BorderSide)((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Bottom))); - this.xrTableCell21.Multiline = true; - this.xrTableCell21.Name = "xrTableCell21"; - this.xrTableCell21.Padding = new DevExpress.XtraPrinting.PaddingInfo(5, 0, 0, 0, 100F); - this.xrTableCell21.StylePriority.UseBorders = false; - this.xrTableCell21.StylePriority.UseFont = false; - this.xrTableCell21.StylePriority.UsePadding = false; - this.xrTableCell21.Weight = 0.2024922118380062D; - // - // xrTableCell22 - // - this.xrTableCell22.Borders = ((DevExpress.XtraPrinting.BorderSide)(((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Right) - | DevExpress.XtraPrinting.BorderSide.Bottom))); - this.xrTableCell22.Multiline = true; - this.xrTableCell22.Name = "xrTableCell22"; - this.xrTableCell22.Padding = new DevExpress.XtraPrinting.PaddingInfo(5, 0, 0, 0, 100F); - this.xrTableCell22.StylePriority.UseBorders = false; - this.xrTableCell22.StylePriority.UsePadding = false; - this.xrTableCell22.Weight = 0.20249221183800623D; - // - // xrTableCell23 - // - this.xrTableCell23.Borders = ((DevExpress.XtraPrinting.BorderSide)(((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Right) - | DevExpress.XtraPrinting.BorderSide.Bottom))); - this.xrTableCell23.Multiline = true; - this.xrTableCell23.Name = "xrTableCell23"; - this.xrTableCell23.Padding = new DevExpress.XtraPrinting.PaddingInfo(5, 0, 0, 0, 100F); - this.xrTableCell23.StylePriority.UseBorders = false; - this.xrTableCell23.StylePriority.UseFont = false; - this.xrTableCell23.StylePriority.UsePadding = false; - this.xrTableCell23.Weight = 0.34190062050507453D; - // - // xrTableRow6 - // - this.xrTableRow6.Cells.AddRange(new DevExpress.XtraReports.UI.XRTableCell[] { - this.xrTableCell24, - this.xrTableCell25, - this.xrTableCell26, - this.xrTableCell27, - this.xrTableCell28}); - this.xrTableRow6.Name = "xrTableRow6"; - this.xrTableRow6.Weight = 2.5D; - // - // xrTableCell24 - // - this.xrTableCell24.Borders = ((DevExpress.XtraPrinting.BorderSide)(((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Right) - | DevExpress.XtraPrinting.BorderSide.Bottom))); - this.xrTableCell24.Multiline = true; - this.xrTableCell24.Name = "xrTableCell24"; - this.xrTableCell24.Padding = new DevExpress.XtraPrinting.PaddingInfo(5, 0, 0, 0, 100F); - this.xrTableCell24.StylePriority.UseBorders = false; - this.xrTableCell24.StylePriority.UseFont = false; - this.xrTableCell24.StylePriority.UsePadding = false; - this.xrTableCell24.Text = "Kosten\r\nBeförderung"; - this.xrTableCell24.Weight = 0.25311495581891308D; - // - // xrTableCell25 - // - this.xrTableCell25.Borders = ((DevExpress.XtraPrinting.BorderSide)((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Bottom))); - this.xrTableCell25.Multiline = true; - this.xrTableCell25.Name = "xrTableCell25"; - this.xrTableCell25.Padding = new DevExpress.XtraPrinting.PaddingInfo(5, 0, 0, 0, 100F); - this.xrTableCell25.StylePriority.UseBorders = false; - this.xrTableCell25.StylePriority.UseFont = false; - this.xrTableCell25.StylePriority.UsePadding = false; - this.xrTableCell25.Weight = 0.18691588785046726D; - // - // xrTableCell26 - // - this.xrTableCell26.Borders = ((DevExpress.XtraPrinting.BorderSide)(((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Right) - | DevExpress.XtraPrinting.BorderSide.Bottom))); - this.xrTableCell26.Multiline = true; - this.xrTableCell26.Name = "xrTableCell26"; - this.xrTableCell26.Padding = new DevExpress.XtraPrinting.PaddingInfo(5, 0, 0, 0, 100F); - this.xrTableCell26.StylePriority.UseBorders = false; - this.xrTableCell26.StylePriority.UsePadding = false; - this.xrTableCell26.Weight = 0.18691588785046726D; - // - // xrTableCell27 - // - this.xrTableCell27.Borders = ((DevExpress.XtraPrinting.BorderSide)(((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Right) - | DevExpress.XtraPrinting.BorderSide.Bottom))); - this.xrTableCell27.Multiline = true; - this.xrTableCell27.Name = "xrTableCell27"; - this.xrTableCell27.Padding = new DevExpress.XtraPrinting.PaddingInfo(5, 0, 0, 0, 100F); - this.xrTableCell27.StylePriority.UseBorders = false; - this.xrTableCell27.StylePriority.UseFont = false; - this.xrTableCell27.StylePriority.UsePadding = false; - this.xrTableCell27.Weight = 0.18691588785046728D; - // - // xrTableCell28 - // - this.xrTableCell28.Borders = ((DevExpress.XtraPrinting.BorderSide)(((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Right) - | DevExpress.XtraPrinting.BorderSide.Bottom))); - this.xrTableCell28.Multiline = true; - this.xrTableCell28.Name = "xrTableCell28"; - this.xrTableCell28.Padding = new DevExpress.XtraPrinting.PaddingInfo(5, 0, 0, 0, 100F); - this.xrTableCell28.StylePriority.UseBorders = false; - this.xrTableCell28.StylePriority.UseFont = false; - this.xrTableCell28.StylePriority.UsePadding = false; - this.xrTableCell28.Weight = 0.18613738062968507D; - // // GroupFooter1 // this.GroupFooter1.Controls.AddRange(new DevExpress.XtraReports.UI.XRControl[] { @@ -821,6 +815,37 @@ namespace SHKServiceSBD.Reports this.xrLabel13}); this.GroupFooter1.Name = "GroupFooter1"; // + // lblAngebotGesamt + // + this.lblAngebotGesamt.LocationFloat = new DevExpress.Utils.PointFloat(214.1667F, 70F); + this.lblAngebotGesamt.Name = "lblAngebotGesamt"; + this.lblAngebotGesamt.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F); + this.lblAngebotGesamt.SizeF = new System.Drawing.SizeF(78.33333F, 30F); + this.lblAngebotGesamt.StylePriority.UseFont = false; + this.lblAngebotGesamt.StylePriority.UseTextAlignment = false; + this.lblAngebotGesamt.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopRight; + // + // lblAngebotBefProMonat + // + this.lblAngebotBefProMonat.LocationFloat = new DevExpress.Utils.PointFloat(214.1667F, 40F); + this.lblAngebotBefProMonat.Name = "lblAngebotBefProMonat"; + this.lblAngebotBefProMonat.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F); + this.lblAngebotBefProMonat.SizeF = new System.Drawing.SizeF(78.33333F, 30F); + this.lblAngebotBefProMonat.StylePriority.UseFont = false; + this.lblAngebotBefProMonat.StylePriority.UseTextAlignment = false; + this.lblAngebotBefProMonat.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopRight; + // + // lblAngebotAssProMonat + // + this.lblAngebotAssProMonat.LocationFloat = new DevExpress.Utils.PointFloat(214.1667F, 10F); + this.lblAngebotAssProMonat.Name = "lblAngebotAssProMonat"; + this.lblAngebotAssProMonat.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F); + this.lblAngebotAssProMonat.SizeF = new System.Drawing.SizeF(78.33333F, 30F); + this.lblAngebotAssProMonat.StylePriority.UseFont = false; + this.lblAngebotAssProMonat.StylePriority.UseTextAlignment = false; + this.lblAngebotAssProMonat.Text = "9.000,00 €"; + this.lblAngebotAssProMonat.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopRight; + // // xrLabel8 // this.xrLabel8.LocationFloat = new DevExpress.Utils.PointFloat(0F, 10F); @@ -848,35 +873,63 @@ namespace SHKServiceSBD.Reports this.xrLabel13.StylePriority.UseFont = false; this.xrLabel13.Text = "Gesamtbetrag:"; // - // lblAngebotAssProMonat + // xrLabel15 // - this.lblAngebotAssProMonat.LocationFloat = new DevExpress.Utils.PointFloat(214.1667F, 10F); - this.lblAngebotAssProMonat.Name = "lblAngebotAssProMonat"; - this.lblAngebotAssProMonat.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F); - this.lblAngebotAssProMonat.SizeF = new System.Drawing.SizeF(68.33333F, 30F); - this.lblAngebotAssProMonat.StylePriority.UseFont = false; - this.lblAngebotAssProMonat.StylePriority.UseTextAlignment = false; - this.lblAngebotAssProMonat.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopRight; + this.xrLabel15.LocationFloat = new DevExpress.Utils.PointFloat(0F, 340F); + this.xrLabel15.Name = "xrLabel15"; + this.xrLabel15.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F); + this.xrLabel15.SizeF = new System.Drawing.SizeF(155.41F, 30F); + this.xrLabel15.StylePriority.UseFont = false; + this.xrLabel15.Text = "Kilometer / Tag"; // - // lblAngebotBefProMonat + // lblKmProTag // - this.lblAngebotBefProMonat.LocationFloat = new DevExpress.Utils.PointFloat(214.1667F, 40F); - this.lblAngebotBefProMonat.Name = "lblAngebotBefProMonat"; - this.lblAngebotBefProMonat.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F); - this.lblAngebotBefProMonat.SizeF = new System.Drawing.SizeF(68.33333F, 30F); - this.lblAngebotBefProMonat.StylePriority.UseFont = false; - this.lblAngebotBefProMonat.StylePriority.UseTextAlignment = false; - this.lblAngebotBefProMonat.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopRight; + this.lblKmProTag.Borders = ((DevExpress.XtraPrinting.BorderSide)((((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Top) + | DevExpress.XtraPrinting.BorderSide.Right) + | DevExpress.XtraPrinting.BorderSide.Bottom))); + this.lblKmProTag.LocationFloat = new DevExpress.Utils.PointFloat(155.41F, 340F); + this.lblKmProTag.Multiline = true; + this.lblKmProTag.Name = "lblKmProTag"; + this.lblKmProTag.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F); + this.lblKmProTag.SizeF = new System.Drawing.SizeF(181.4193F, 24F); + this.lblKmProTag.StylePriority.UseBorders = false; + this.lblKmProTag.StylePriority.UseFont = false; // - // lblAngebotGesamt + // xrLabel16 // - this.lblAngebotGesamt.LocationFloat = new DevExpress.Utils.PointFloat(214.1667F, 70F); - this.lblAngebotGesamt.Name = "lblAngebotGesamt"; - this.lblAngebotGesamt.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F); - this.lblAngebotGesamt.SizeF = new System.Drawing.SizeF(68.33333F, 30F); - this.lblAngebotGesamt.StylePriority.UseFont = false; - this.lblAngebotGesamt.StylePriority.UseTextAlignment = false; - this.lblAngebotGesamt.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopRight; + this.xrLabel16.LocationFloat = new DevExpress.Utils.PointFloat(0.0002034505F, 370F); + this.xrLabel16.Name = "xrLabel16"; + this.xrLabel16.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F); + this.xrLabel16.SizeF = new System.Drawing.SizeF(155.41F, 30F); + this.xrLabel16.StylePriority.UseFont = false; + this.xrLabel16.Text = "€ / Kilometer"; + // + // lblEuroProKm + // + this.lblEuroProKm.Borders = ((DevExpress.XtraPrinting.BorderSide)((((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Top) + | DevExpress.XtraPrinting.BorderSide.Right) + | DevExpress.XtraPrinting.BorderSide.Bottom))); + this.lblEuroProKm.LocationFloat = new DevExpress.Utils.PointFloat(155.4102F, 370F); + this.lblEuroProKm.Multiline = true; + this.lblEuroProKm.Name = "lblEuroProKm"; + this.lblEuroProKm.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F); + this.lblEuroProKm.SizeF = new System.Drawing.SizeF(181.4193F, 24F); + this.lblEuroProKm.StylePriority.UseBorders = false; + this.lblEuroProKm.StylePriority.UseFont = false; + // + // xrLabel2 + // + this.xrLabel2.Borders = DevExpress.XtraPrinting.BorderSide.Bottom; + this.xrLabel2.LocationFloat = new DevExpress.Utils.PointFloat(0F, 10F); + this.xrLabel2.Name = "xrLabel2"; + this.xrLabel2.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F); + this.xrLabel2.SizeF = new System.Drawing.SizeF(642.0001F, 24F); + this.xrLabel2.StylePriority.UseBorders = false; + this.xrLabel2.StylePriority.UseFont = false; + // + // bindingSource1 + // + this.bindingSource1.DataSource = typeof(BeWo.Report.ReportObjects.CustomerDataRO); // // KalkulationReport // @@ -889,6 +942,8 @@ namespace SHKServiceSBD.Reports this.GroupHeader3, this.GroupHeader2, this.GroupFooter1}); + this.ComponentStorage.AddRange(new System.ComponentModel.IComponent[] { + this.bindingSource1}); this.DataSource = this.bindingSource1; this.Font = new DevExpress.Drawing.DXFont("Calibri", 11F, DevExpress.Drawing.DXFontStyle.Regular, DevExpress.Drawing.DXGraphicsUnit.Point, new DevExpress.Drawing.DXFontAdditionalProperty[] { new DevExpress.Drawing.DXFontAdditionalProperty("GdiCharSet", ((byte)(0)))}); @@ -897,11 +952,13 @@ namespace SHKServiceSBD.Reports this.PageWidth = 827; this.PaperKind = DevExpress.Drawing.Printing.DXPaperKind.A4; this.Version = "23.2"; + xrWatermark1.Id = "Watermark1"; + this.Watermarks.Add(xrWatermark1); ((System.ComponentModel.ISupportInitialize)(this.xrTable3)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.xrTable2)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.xrTable1)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.bindingSource1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.tableBetreuungszeiten)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.bindingSource1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this)).EndInit(); } @@ -939,7 +996,6 @@ namespace SHKServiceSBD.Reports private DevExpress.XtraReports.UI.XRTableCell xrTableCell6; private DevExpress.XtraReports.UI.XRTableCell xrTableCell7; private DevExpress.XtraReports.UI.XRTableCell xrTableCell8; - private DevExpress.XtraReports.UI.XRLabel xrLabel2; private DevExpress.XtraReports.UI.XRTable xrTable1; private DevExpress.XtraReports.UI.XRTableRow xrTableRow2; private DevExpress.XtraReports.UI.XRTableCell xrTableCell1; @@ -964,15 +1020,15 @@ namespace SHKServiceSBD.Reports private DevExpress.XtraReports.UI.XRTableCell xrTableCell19; private DevExpress.XtraReports.UI.XRTableRow xrTableRow5; private DevExpress.XtraReports.UI.XRTableCell xrTableCell20; - private DevExpress.XtraReports.UI.XRTableCell xrTableCell21; - private DevExpress.XtraReports.UI.XRTableCell xrTableCell22; - private DevExpress.XtraReports.UI.XRTableCell xrTableCell23; + private DevExpress.XtraReports.UI.XRTableCell cellKostenAssiWoche; + private DevExpress.XtraReports.UI.XRTableCell cellKostenAssiMonat; + private DevExpress.XtraReports.UI.XRTableCell cellKostenAssiJahr; private DevExpress.XtraReports.UI.XRTableRow xrTableRow6; private DevExpress.XtraReports.UI.XRTableCell xrTableCell24; - private DevExpress.XtraReports.UI.XRTableCell xrTableCell25; - private DevExpress.XtraReports.UI.XRTableCell xrTableCell26; - private DevExpress.XtraReports.UI.XRTableCell xrTableCell27; - private DevExpress.XtraReports.UI.XRTableCell xrTableCell28; + private DevExpress.XtraReports.UI.XRTableCell cellKostenBefTag; + private DevExpress.XtraReports.UI.XRTableCell cellKostenBefWoche; + private DevExpress.XtraReports.UI.XRTableCell cellKostenBefMonat; + private DevExpress.XtraReports.UI.XRTableCell cellKostenBefJahr; private DevExpress.XtraReports.UI.GroupFooterBand GroupFooter1; private DevExpress.XtraReports.UI.XRLabel lblAngebotGesamt; private DevExpress.XtraReports.UI.XRLabel lblAngebotBefProMonat; @@ -980,5 +1036,10 @@ namespace SHKServiceSBD.Reports private DevExpress.XtraReports.UI.XRLabel xrLabel8; private DevExpress.XtraReports.UI.XRLabel xrLabel12; private DevExpress.XtraReports.UI.XRLabel xrLabel13; + private DevExpress.XtraReports.UI.XRLabel xrLabel16; + private DevExpress.XtraReports.UI.XRLabel lblEuroProKm; + private DevExpress.XtraReports.UI.XRLabel xrLabel15; + private DevExpress.XtraReports.UI.XRLabel lblKmProTag; + private DevExpress.XtraReports.UI.XRLabel xrLabel2; } } diff --git a/ReportImp/SHKServiceSBD/Reports/KalkulationReport.cs b/ReportImp/SHKServiceSBD/Reports/KalkulationReport.cs index 65dfd7d1f..7b33c2464 100644 --- a/ReportImp/SHKServiceSBD/Reports/KalkulationReport.cs +++ b/ReportImp/SHKServiceSBD/Reports/KalkulationReport.cs @@ -11,6 +11,8 @@ using BeWo.Report; using BeWo.Service.ServiceImplementations; using BeWo.Service.DCEntityMapper; using BS.Shared.Core; +using System.Linq; +using BS.Shared; namespace SHKServiceSBD.Reports { @@ -28,13 +30,16 @@ namespace SHKServiceSBD.Reports DateTime monat = DateTime.Now; + decimal euroKm = GetPreis("Kilometerpauschale", DateTime.Now); + CostBearer2SupportConcept c2s = GetC2S(pRO); if (c2s != null) { - - Customer c = c2s.SupportConcept.Customer; - + decimal km = GetKilometer(pRO); + Customer c = c2s.SupportConcept.Customer; + + //foreach (var sc in c.SupportConcepts) //{ @@ -49,29 +54,67 @@ namespace SHKServiceSBD.Reports //} + decimal euroProStunde = 0; + var stunden = CreateArbeitszeitenTableAndCalculateStunden(c.Arbeitszeiten); lblKlient.Text = String.Format("{0}, geb. {1:dd.MM.yyyy}", c.Person.FirstNameLastName, c.Person.DateOfBirth); lblStundenProWoche.Text = String.Format("{0:0.00}", stunden); lblDurchschnittStundenProTag.Text = String.Format("{0:0.00}", stunden / 5); lblWochenProJahr.Text = "52"; lblMonateProJahr.Text = "12"; + lblKmProTag.Text = String.Format("{0:0.00}", km); + lblEuroProKm.Text = String.Format("{0:c}", euroKm); var crlist = MapperFactory.CostRatePeriodDC_CostRatePeriod.MapToNewDCs(c2s.CostBearer.CostRatePeriods); var crp = crlist.GetCostRatePeriodForDate(BS.Shared.CostRatePeriodType.HourlyRate, monat); if (crp != null && crp.CostRateValue.HasValue) { + euroProStunde = crp.CostRateValue.Value; lblEuroProStunde.Text = String.Format("{0:c}", crp.CostRateValue); } + decimal wochen = 365 / 7; // Schaltjahre beachten? + + cellKostenBefTag.Text = String.Format("{0:c}", euroKm * km); + cellKostenBefWoche.Text = String.Format("{0:c}", euroKm * km * 5); + cellKostenBefMonat.Text = String.Format("{0:c}", euroKm * km * 5 * (wochen / 12)); + cellKostenBefJahr.Text = String.Format("{0:c}", euroKm * km * 5 * wochen); + + + cellKostenAssiWoche.Text = String.Format("{0:c}", stunden * euroProStunde); + cellKostenAssiMonat.Text = String.Format("{0:c}", stunden * euroProStunde * (wochen / 12)); + cellKostenAssiJahr.Text = String.Format("{0:c}", stunden * euroProStunde * wochen); //Organisation schule = GetSchule(c); + lblAngebotAssProMonat.Text = String.Format("{0:c}", stunden * euroProStunde * (wochen / 12)); + lblAngebotBefProMonat.Text = String.Format("{0:c}", euroKm * km * 5 * (wochen / 12)); + lblAngebotGesamt.Text = String.Format("{0:c}", (stunden * euroProStunde * (wochen / 12)) + (euroKm * km * 5 * (wochen / 12))); } this.bindingSource1.DataSource = pRO; } + public virtual decimal GetPreis(String preisBezeichnung, DateTime datum) + { + + var preise = DAOFactory.GenericDAO.GetAllActive(); + + var preis = preise.Where(p => p.Name.Contains(preisBezeichnung)).FirstOrDefault(); + if (preis != null) + { + var crlist = MapperFactory.CostRatePeriodDC_CostRatePeriod.MapToNewDCs(preis.CostRatePeriods); + + var cr = crlist.GetCostRatePeriodForDate(CostRatePeriodType.AmountOfMoney, datum); + if (cr != null && cr.CostRateValue.HasValue) + { + return cr.CostRateValue.Value; + } + } + + return 0; + } private CostBearer2SupportConcept GetC2S(QueryRO ro) { @@ -90,6 +133,23 @@ namespace SHKServiceSBD.Reports return null; } + private decimal GetKilometer(QueryRO ro) + { + + if (ro.Rows != null && ro.Rows.Count > 0) + { + if (ro.Rows[0].Field2 != null) + { + if (Decimal.TryParse(ro.Rows[0].Field2.ToString(), out var d)) + { + return d; + } + } + } + + return 0; + } + private Customer GetCustomer(QueryRO ro) { 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); }