diff --git a/Report/ReportObjects/GkvAbrechnungRO.cs b/Report/ReportObjects/GkvAbrechnungRO.cs index 3c8dca6e5..00deac181 100644 --- a/Report/ReportObjects/GkvAbrechnungRO.cs +++ b/Report/ReportObjects/GkvAbrechnungRO.cs @@ -75,15 +75,18 @@ namespace BeWo.Report.ReportObjects var receiver_last = invoicebase.RecipientPersonLastName; var receiver_first_last = receiver_first.ToFormatFollows(receiver_last); - var receiver_postcode = invoicebase.RecipientPostCode; - var receiver_town = invoicebase.RecipientTown; - var receiver_postcode_town = receiver_postcode.ToFormatFollows(receiver_town); - result.ReceiverDatenannahmestelle = invoicebase.RecipientOrganisation.ToNullIfEmpty(); result.ReceiverContactPerson = receiver_first_last; - result.ReceiverDivision = invoicebase.RecipientDivision.ToNullIfEmpty(); - result.ReceiverStreet = invoicebase.RecipientStreet.ToNullIfEmpty(); - result.ReceiverPostCodeAndTown = receiver_postcode_town; + + var datenannahmestelle = organisation.GetDatenannahmestelleAddress(); + + var datenannahme_postcode = datenannahmestelle.PostalCode; + var datenannahme_town = datenannahmestelle.Town; + var datenannahme_postcode_town = datenannahme_postcode.ToFormatFollows(datenannahme_town); + + //result.ReceiverDivision = datenannahmestelle.AddressLine1.ToNullIfEmpty(); + result.ReceiverStreet = datenannahmestelle.Street.ToNullIfEmpty(); + result.ReceiverPostCodeAndTown = datenannahme_postcode_town; result.KrankenkasseIK = organisation.IKKostentrager; result.KrankenkasseName = organisation.Name; diff --git a/Shared/Core/AppError.cs b/Shared/Core/AppError.cs new file mode 100644 index 000000000..d80944659 --- /dev/null +++ b/Shared/Core/AppError.cs @@ -0,0 +1,26 @@ +using BS.Shared.DataContracts; +using BS.Shared.Interface; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BS.Shared.Core +{ + public class AppError + { + public string Code { get; set; } + public string Message { get; set; } + public string Displayname => $"AppError {Code}: {Message}"; + + // Private damit zentral alle Er + private AppError(string code, string message) + { + Code = code; + Message = message; + } + + public static readonly Func GkvDatenannahmestelleAdresseNotFound = (dc) => new AppError("GKV.70001", $"Unbekannte Datenannahmestelle. Bitte neu in der Organisation {dc.Name} ermitteln"); + } +} diff --git a/Shared/DataContracts/OrganisationDC.cs b/Shared/DataContracts/OrganisationDC.cs index 7531cf4cb..bea0518ff 100644 --- a/Shared/DataContracts/OrganisationDC.cs +++ b/Shared/DataContracts/OrganisationDC.cs @@ -1,5 +1,7 @@  using BS.Shared.Core; +using BS.Shared.Exceptions; +using System; using System.Collections.Generic; using System.Runtime.Serialization; @@ -93,5 +95,23 @@ namespace BS.Shared.DataContracts this.InvoiceAddressTown, this.InvoiceAddressLine1); } + + public AddressDC GetDatenannahmestelleAddress() + { + var lst = new List() { + HausanschriftDatenannahmestelle, + PostfachanschriftDatenannahmestelle, + GroßkundenanschriftDatenannahmestelle}; + + foreach (var add in lst) + { + if (add is AddressDC) + return add; + } + + throw new BeWoInvalidOperationException(AppError.GkvDatenannahmestelleAdresseNotFound(this)); + + return null; + } } } \ No newline at end of file diff --git a/Shared/Exceptions/BeWoInvalidOperationException.cs b/Shared/Exceptions/BeWoInvalidOperationException.cs new file mode 100644 index 000000000..05a798132 --- /dev/null +++ b/Shared/Exceptions/BeWoInvalidOperationException.cs @@ -0,0 +1,27 @@ +using BS.Shared.Core; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BS.Shared.Exceptions +{ + public class BeWoInvalidOperationException : InvalidOperationException + { + public BeWoInvalidOperationException() : base() + { + + } + + public BeWoInvalidOperationException(AppError appError) : base(appError.Displayname) + { + + } + + public BeWoInvalidOperationException(AppError appError, Exception innerException) + { + + } + } +} diff --git a/Shared/Shared.csproj b/Shared/Shared.csproj index ad19decac..e0fac6865 100644 --- a/Shared/Shared.csproj +++ b/Shared/Shared.csproj @@ -138,6 +138,7 @@ + @@ -382,6 +383,7 @@ +