diff --git a/Report/DefaultReports/ServiceInvoiceReport.Designer.cs b/Report/DefaultReports/ServiceInvoiceReport.Designer.cs index 3642e088a..0e81e006a 100644 --- a/Report/DefaultReports/ServiceInvoiceReport.Designer.cs +++ b/Report/DefaultReports/ServiceInvoiceReport.Designer.cs @@ -35,7 +35,7 @@ namespace BeWo.Report.DefaultReports this.topMarginBand1 = new DevExpress.XtraReports.UI.TopMarginBand(); this.bottomMarginBand1 = new DevExpress.XtraReports.UI.BottomMarginBand(); this.Page1 = new DevExpress.XtraReports.UI.GroupHeaderBand(); - this.xrLabel7 = new DevExpress.XtraReports.UI.XRLabel(); + this.lblAdresse = new DevExpress.XtraReports.UI.XRLabel(); this.xrLabel4 = new DevExpress.XtraReports.UI.XRLabel(); this.xrLabel3 = new DevExpress.XtraReports.UI.XRLabel(); this.xrLabel2 = new DevExpress.XtraReports.UI.XRLabel(); @@ -130,7 +130,7 @@ namespace BeWo.Report.DefaultReports // Page1 // this.Page1.Controls.AddRange(new DevExpress.XtraReports.UI.XRControl[] { - this.xrLabel7, + this.lblAdresse, this.xrLabel4, this.xrLabel3, this.xrLabel2, @@ -143,15 +143,15 @@ namespace BeWo.Report.DefaultReports this.Page1.Name = "Page1"; this.Page1.StylePriority.UseFont = false; // - // xrLabel7 + // lblAdresse // - this.xrLabel7.LocationFloat = new DevExpress.Utils.PointFloat(0F, 0F); - this.xrLabel7.Multiline = true; - this.xrLabel7.Name = "xrLabel7"; - this.xrLabel7.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F); - this.xrLabel7.SizeF = new System.Drawing.SizeF(317F, 111.5F); - this.xrLabel7.StylePriority.UseFont = false; - this.xrLabel7.Text = "[RecipientOrganisation]\r\n[RecipientContactPerson]\r\n[RecipientDivision]\r\n[Recipien" + + this.lblAdresse.LocationFloat = new DevExpress.Utils.PointFloat(0F, 0F); + this.lblAdresse.Multiline = true; + this.lblAdresse.Name = "lblAdresse"; + this.lblAdresse.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F); + this.lblAdresse.SizeF = new System.Drawing.SizeF(317F, 111.5F); + this.lblAdresse.StylePriority.UseFont = false; + this.lblAdresse.Text = "[RecipientOrganisation]\r\n[RecipientContactPerson]\r\n[RecipientDivision]\r\n[Recipien" + "tStreet]\r\n[RecipientPostCodeAndTown]"; // // xrLabel4 @@ -878,7 +878,7 @@ namespace BeWo.Report.DefaultReports private DevExpress.XtraReports.UI.XRTableCell xrTableCell45; private DevExpress.XtraReports.UI.XRTableCell xrTableCell46; private DevExpress.XtraReports.UI.XRTableCell xrTableCell47; - private DevExpress.XtraReports.UI.XRLabel xrLabel7; + private DevExpress.XtraReports.UI.XRLabel lblAdresse; private DevExpress.XtraReports.UI.GroupFooterBand GroupFooter1; private DevExpress.XtraReports.UI.XRLabel xrLabel1; } diff --git a/Report/DefaultReports/ServiceInvoiceReport.cs b/Report/DefaultReports/ServiceInvoiceReport.cs index 05f2b2d19..e96ed414e 100644 --- a/Report/DefaultReports/ServiceInvoiceReport.cs +++ b/Report/DefaultReports/ServiceInvoiceReport.cs @@ -1,4 +1,5 @@ using System; +using System.Text; using BeWo.Report.ReportObjects; using DevExpress.XtraReports.UI; @@ -25,7 +26,43 @@ namespace BeWo.Report.DefaultReports lblAbrechnungszeitraum.Text = String.Format("hiermit berechnen wir für den Zeitraum {0:MMMM yyyy} - {1:MMMM yyyy} folgende erbrachte Tätigkeiten:", start, end); } + SetzeAdresse(pRO); + this.bindingSource1.DataSource = pRO; } + + private void SetzeAdresse(ServiceInvoiceRO pRO) + { + StringBuilder sb = new StringBuilder(); + if (!String.IsNullOrEmpty(pRO.RecipientOrganisation) && pRO.RecipientOrganisation.ToLower() != "selbstzahler") + { + sb.AppendLine(pRO.RecipientOrganisation); + } + //if (!String.IsNullOrEmpty(pRO.RecipientAddressLine1)) + //{ + // sb.AppendLine(pRO.RecipientAddressLine1); + //} + if (!String.IsNullOrEmpty(pRO.RecipientContactPerson)) + { + sb.AppendLine(pRO.RecipientContactPerson); + } + if (!String.IsNullOrEmpty(pRO.RecipientDivision) && !String.IsNullOrEmpty(pRO.RecipientOrganisation) && pRO.RecipientOrganisation.ToLower() != "selbstzahler") + { + sb.AppendLine(pRO.RecipientDivision); + } + if (!String.IsNullOrEmpty(pRO.RecipientPoBox)) + { + sb.AppendLine(pRO.RecipientPoBox); + } + else if (!String.IsNullOrEmpty(pRO.RecipientStreet)) + { + sb.AppendLine(pRO.RecipientStreet); + } + if (!String.IsNullOrEmpty(pRO.RecipientPostCodeAndTown)) + { + sb.AppendLine(pRO.RecipientPostCodeAndTown); + } + lblAdresse.Text = sb.ToString(); + } } } \ No newline at end of file diff --git a/Service/Invoicing/InvoiceCreation.cs b/Service/Invoicing/InvoiceCreation.cs index 624fdabed..1bd3093b9 100644 --- a/Service/Invoicing/InvoiceCreation.cs +++ b/Service/Invoicing/InvoiceCreation.cs @@ -127,7 +127,6 @@ namespace BeWo.Service.Invoicing return invoice; } - public virtual void SetServiceInvoicePeriodAmounts(ServiceInvoice invoice) { foreach (ServiceInvoicePeriod iPeriod in invoice.ServiceInvoicePeriodList) @@ -390,28 +389,72 @@ namespace BeWo.Service.Invoicing public virtual void SetRecipientInformation(ServiceInvoice serviceInvoice, CostBearer costBearer) { - if (costBearer.Organisation.InvoiceAddress != null) + if (costBearer.Organisation.Name.ToLower() == "selbstzahler") { - serviceInvoice.InvoiceBase.RecipientAddress = costBearer.Organisation.InvoiceAddress.CopyToNew(); + serviceInvoice.InvoiceBase.RecipientDivision = costBearer.Organisation.Name2; + serviceInvoice.InvoiceBase.RecipientOrganisationOid = costBearer.Organisation.Oid; + serviceInvoice.InvoiceBase.RecipientOrganisation = costBearer.Organisation.Name; + serviceInvoice.InvoiceBase.RecipientContacts = costBearer.Organisation.Contacts.Select(i => i.CopyToNew()).ToList(); + serviceInvoice.InvoiceBase.RecipientCostBearerOid = costBearer.Oid; + + if (serviceInvoice.InvoiceBase.CostBearer2SupportConcept != null) + { + var cust = serviceInvoice.InvoiceBase.CostBearer2SupportConcept.SupportConcept.Customer; + + if (cust.Person.InvoiceAddress != null) + { + serviceInvoice.InvoiceBase.RecipientAddress = cust.Person.InvoiceAddress.CopyToNew(); + } + else if (cust.Person.Address != null) + { + serviceInvoice.InvoiceBase.RecipientAddress = cust.Person.Address.CopyToNew(); + } + if (cust.Person.InvoiceAddress != null && cust.Person.InvoiceAddress.AddressLine1 != null) // Anderer Rechnungsempfänger z.B. Vormund + { + serviceInvoice.InvoiceBase.RecipientPersonFirstName = cust.Person.InvoiceAddress.AddressLine1; + serviceInvoice.InvoiceBase.RecipientPersonLastName = ""; + } + else + { + serviceInvoice.InvoiceBase.RecipientPersonFirstName = cust.Person.FirstName; + serviceInvoice.InvoiceBase.RecipientPersonLastName = cust.Person.LastName; + } + return; + } + if (costBearer.Organisation.InvoiceAddress != null) + { + serviceInvoice.InvoiceBase.RecipientAddress = costBearer.Organisation.InvoiceAddress.CopyToNew(); + } + else if (costBearer.Organisation.Address != null) + { + serviceInvoice.InvoiceBase.RecipientAddress = costBearer.Organisation.Address.CopyToNew(); + } } - else if (costBearer.Organisation.Address != null) + else { - serviceInvoice.InvoiceBase.RecipientAddress = costBearer.Organisation.Address.CopyToNew(); - } + if (costBearer.Organisation.InvoiceAddress != null) + { + serviceInvoice.InvoiceBase.RecipientAddress = costBearer.Organisation.InvoiceAddress.CopyToNew(); + } + else if (costBearer.Organisation.Address != null) + { + serviceInvoice.InvoiceBase.RecipientAddress = costBearer.Organisation.Address.CopyToNew(); + } - serviceInvoice.InvoiceBase.RecipientDivision = costBearer.Organisation.Name2; - serviceInvoice.InvoiceBase.RecipientOrganisationOid = costBearer.Organisation.Oid; - serviceInvoice.InvoiceBase.RecipientOrganisation = costBearer.Organisation.Name; - serviceInvoice.InvoiceBase.RecipientContacts = costBearer.Organisation.Contacts.Select(i => i.CopyToNew()).ToList(); - serviceInvoice.InvoiceBase.RecipientCostBearerOid = costBearer.Oid; + serviceInvoice.InvoiceBase.RecipientDivision = costBearer.Organisation.Name2; + serviceInvoice.InvoiceBase.RecipientOrganisationOid = costBearer.Organisation.Oid; + serviceInvoice.InvoiceBase.RecipientOrganisation = costBearer.Organisation.Name; + serviceInvoice.InvoiceBase.RecipientContacts = costBearer.Organisation.Contacts.Select(i => i.CopyToNew()).ToList(); + serviceInvoice.InvoiceBase.RecipientCostBearerOid = costBearer.Oid; - //serviceInvoice.InvoiceBase. = c2s.CostBearer.Organisation.Contacts.FirstOrDefault(f => f.Type.Equals(ContactType.business_POBox)) != null ? c2s.CostBearer.Organisation.Contacts.FirstOrDefault(f => f.Type.Equals(ContactType.business_POBox)).Value : String.Empty; + //serviceInvoice.InvoiceBase. = c2s.CostBearer.Organisation.Contacts.FirstOrDefault(f => f.Type.Equals(ContactType.business_POBox)) != null ? c2s.CostBearer.Organisation.Contacts.FirstOrDefault(f => f.Type.Equals(ContactType.business_POBox)).Value : String.Empty; - if (serviceInvoice.InvoiceBase.CostBearer2SupportConcept != null && - serviceInvoice.InvoiceBase.CostBearer2SupportConcept.CostBearerContactPerson != null) - { - serviceInvoice.InvoiceBase.RecipientPersonFirstName = serviceInvoice.InvoiceBase.CostBearer2SupportConcept.CostBearerContactPerson.FirstName; - serviceInvoice.InvoiceBase.RecipientPersonLastName = serviceInvoice.InvoiceBase.CostBearer2SupportConcept.CostBearerContactPerson.LastName; + if (serviceInvoice.InvoiceBase.CostBearer2SupportConcept != null && + serviceInvoice.InvoiceBase.CostBearer2SupportConcept.CostBearerContactPerson != null) + { + serviceInvoice.InvoiceBase.RecipientPersonFirstName = serviceInvoice.InvoiceBase.CostBearer2SupportConcept.CostBearerContactPerson.FirstName; + serviceInvoice.InvoiceBase.RecipientPersonLastName = serviceInvoice.InvoiceBase.CostBearer2SupportConcept.CostBearerContactPerson.LastName; + } } }