From ed85aa09469305bf00c4b38b5cbdde9bf142baa9 Mon Sep 17 00:00:00 2001 From: Alexandra Date: Wed, 2 Feb 2022 16:17:39 +0100 Subject: [PATCH] DiakonischesWerkPassau/Invoicing --- .../Invoicing/CustomInvoiceFactory.cs | 35 +++++++++ .../Invoicing/SelbstzahlerInvoiceCreation.cs | 71 +++++++++++++++++++ 2 files changed, 106 insertions(+) create mode 100644 ReportImp/DiakonischesWerkPassau/Invoicing/CustomInvoiceFactory.cs create mode 100644 ReportImp/DiakonischesWerkPassau/Invoicing/SelbstzahlerInvoiceCreation.cs diff --git a/ReportImp/DiakonischesWerkPassau/Invoicing/CustomInvoiceFactory.cs b/ReportImp/DiakonischesWerkPassau/Invoicing/CustomInvoiceFactory.cs new file mode 100644 index 000000000..6e23da6ba --- /dev/null +++ b/ReportImp/DiakonischesWerkPassau/Invoicing/CustomInvoiceFactory.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using BeWo.Data.Access; +using BeWo.Data.Entities; +using BeWo.Service.Invoicing; +using BS.Shared.DataContracts; +using BS.Shared.DataContracts.Compact; +using BS.Shared.Services; + +namespace DiakonischesWerkPassau.Invoicing +{ + public class CustomInvoiceFactory : InvoiceFactory + { + + public override InvoiceCreation CreateInvoiceCreator(string specificId, string tenant, Dictionary> supportConcepts2ServiceRecords) + { + foreach (var list in supportConcepts2ServiceRecords.Values) + { + + foreach (var sr in list) + { + if (sr.CostBearer != null) + { + if (sr.CostBearer.Name.ToLower().Contains("selbstzahler")) + { + return new SelbstzahlerInvoiceCreation(); + } + } + } + } + + return new InvoiceCreation(); + } + } +} diff --git a/ReportImp/DiakonischesWerkPassau/Invoicing/SelbstzahlerInvoiceCreation.cs b/ReportImp/DiakonischesWerkPassau/Invoicing/SelbstzahlerInvoiceCreation.cs new file mode 100644 index 000000000..d8b2fe614 --- /dev/null +++ b/ReportImp/DiakonischesWerkPassau/Invoicing/SelbstzahlerInvoiceCreation.cs @@ -0,0 +1,71 @@ +using BeWo.Data.Entities; +using BeWo.Service.Invoicing; +using BS.Shared.Core; +using BS.Shared.DataContracts.Compact; +using System; +using System.Collections.Generic; +using System.Linq; + +namespace DiakonischesWerkPassau.Invoicing +{ + + public class SelbstzahlerInvoiceCreation : InvoiceCreation + { + private DateTime? accountingPeriodStart = null; + private DateTime? accountingPeriodEnd = null; + + public override void SetInvoiceBaseData(int invoiceCounter, ServiceInvoice invoice, CostBearer costBearer, DateTimeSpan invoicePeriod, + IList supportConceptList) + { + if (invoicePeriod != null) + { + accountingPeriodStart = invoicePeriod.StartDate; + accountingPeriodEnd = invoicePeriod.EndDate; + } + base.SetInvoiceBaseData(invoiceCounter, invoice, costBearer, invoicePeriod, supportConceptList); + } + + public override void SetRecipientInformation(ServiceInvoice serviceInvoice, CostBearer costBearer) + { + 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.AddressLine1 != null) + { + 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(); + } + } + } +} \ No newline at end of file