using System; using System.Collections.Generic; using System.Text; using BeWo.Data.Access; using BeWo.Data.Entities; using BeWo.Report; using BeWo.Report.ReportObjects; using BS.Shared; using DevExpress.XtraReports.UI; namespace Kimm { public partial class Rechnung : XtraReport, IBeWoReport { public Rechnung() { this.InitializeComponent(); } public void SetReportDataSource(ServiceInvoiceRO pRO) { StringBuilder sb = new StringBuilder(); if (!String.IsNullOrEmpty(pRO.RecipientOrganisation) && !String.IsNullOrEmpty(pRO.RecipientOrganisation.Trim())) { sb.AppendLine(pRO.RecipientOrganisation); } if (!String.IsNullOrEmpty(pRO.RecipientContactPerson) && !String.IsNullOrEmpty(pRO.RecipientContactPerson.Trim())) { sb.AppendLine(pRO.RecipientContactPerson); } if (!String.IsNullOrEmpty(pRO.RecipientDivision) && !String.IsNullOrEmpty(pRO.RecipientDivision.Trim())) { sb.AppendLine(pRO.RecipientDivision); } if (!String.IsNullOrEmpty(pRO.RecipientStreet) && !String.IsNullOrEmpty(pRO.RecipientStreet.Trim())) { sb.AppendLine(pRO.RecipientStreet); } if (!String.IsNullOrEmpty(pRO.RecipientPostCodeAndTown) && !String.IsNullOrEmpty(pRO.RecipientPostCodeAndTown.Trim())) { sb.Append(pRO.RecipientPostCodeAndTown); } lblAddress.Text = sb.ToString(); SetzeKundenInfos(pRO); bool bekommtHandgeld = false; bool hatFaktor = false; decimal handgeld = 0; decimal faktor = 0; String faktorText = ""; foreach (var sip in pRO.ServiceInvoicePeriods) { List newList = new List(); foreach (var ii in sip.ServiceInvoiceItems) { if (ii.ServiceDescription == "Handkasse") { bekommtHandgeld = true; handgeld = ii.NetAmount ?? 0; } else if (ii.ServiceDescription == "Faktor" && !String.IsNullOrEmpty(ii.RateFactor)) { decimal fac = 0; if (Decimal.TryParse(ii.RateFactor.Replace("%", ""), out fac)) { hatFaktor = true; faktor = ii.NetAmount ?? 0; faktorText = String.Format("x Faktor {0}", (100 + fac) / 100); } } else { if (ii.UnitDescription == "pauschal") { ii.UnitCountString = ""; ii.HourlyRateString = ""; } newList.Add(ii); } } sip.ServiceInvoiceItems = newList; } if (!bekommtHandgeld) { cellHandgeldText.Text = ""; } else { cellHandgeldBetrag.Text = String.Format("{0:c}", handgeld); } if (!hatFaktor) { cellFaktorText.Text = ""; cellFaktorBetrag.Text = ""; } else { cellFaktorText.Text = faktorText; cellFaktorBetrag.Text = String.Format("{0:c}", faktor); ; } DateTime start = pRO.AccountingPeriodStart; DateTime end = pRO.AccountingPeriodEnd; if (start.Month == end.Month && start.Year == end.Year) { cellAbrechnungszeitraum.Text = String.Format("{0:MMMM yyyy}", start); } else { cellAbrechnungszeitraum.Text = String.Format("{0:dd.MM.yyyy} bis {1:dd.MM.yyyy}", start, end); } //Warnhinweis auf neue Kontoverbindung nur bis 28.02.2022 sichtbar - kann danach weg if (pRO.InvoiceDateTime >= new DateTime(2021, 11, 8) && pRO.InvoiceDateTime < new DateTime(2022, 03, 01)) rtbNeueBank.Visible = true; else rtbNeueBank.Visible = false; this.bindingSource1.DataSource = pRO; } public void SetzeKundenInfos(ServiceInvoiceRO pRO) { if (pRO.InvoiceBase != null && pRO.InvoiceBase.SupportConceptCostBearerRelDc != null) { var c = DAOFactory.GenericDAO.LoadByID(pRO.InvoiceBase.SupportConceptCostBearerRelDc.SupportConcept.Customer.Oid.Value); foreach (var v2o in c.ValueList) { if (v2o.Entry.Type == ValueListEntryType.CustomerCareType) { lblBetreuungsart.Text = v2o.Entry.Value; } } String ap = ""; foreach (var c2o in c.Customer2OrganisationList) { if (c2o.Person != null) { foreach (var v2o in c2o.ValueList) { if (v2o.Entry.Value.Contains("Sachbearbeiter") && v2o.Entry.Value.Contains("ASD")) { ap = String.Format("{0} {1}", c2o.Person.FirstName, c2o.Person.LastName); } } } } lblASD.Text = String.Format("Fallführende/r Sozialarbeiter/in: {0}, {1}", pRO.RecipientOrganisation, ap); //cellBewilligungszeitraum.Text = String.Format("{0:dd.MM.yyyy} bis {1:dd.MM.yyyy}", // pRO.InvoiceBase.SupportConceptCostBearerRelDc.StartDate, // pRO.InvoiceBase.SupportConceptCostBearerRelDc.EndDate); } } } }