From 0f5b75128cbd7c3600cba60ebf08b0ecc0ea0803 Mon Sep 17 00:00:00 2001 From: Rene Evertz Date: Wed, 14 May 2025 10:48:41 +0200 Subject: [PATCH 1/4] =?UTF-8?q?unn=C3=B6tiges=20try=20catch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dakota/Logic/DakotaManager.cs | 165 ++++++++++++++++------------------ 1 file changed, 79 insertions(+), 86 deletions(-) diff --git a/Dakota/Logic/DakotaManager.cs b/Dakota/Logic/DakotaManager.cs index f3e5d297f..be3cc901c 100644 --- a/Dakota/Logic/DakotaManager.cs +++ b/Dakota/Logic/DakotaManager.cs @@ -10,117 +10,110 @@ using System.Threading.Tasks; namespace Dakota.Logic { - public class DakotaManager - { - public int Month { get; set; } - public int Version { get; set; } + public class DakotaManager + { + public int Month { get; set; } + public int Version { get; set; } - public DakotaInfoCreator DakotaInfoCreator { get; set; } - public bool IsSammelrechnung { get; set; } + public DakotaInfoCreator DakotaInfoCreator { get; set; } + public bool IsSammelrechnung { get; set; } - public Dictionary DakotaFileDict { get; set; } + public Dictionary DakotaFileDict { get; set; } - public Dictionary DakotaInfoNutzDict { get; set; } - public Dictionary DakotaInfoAufDict { get; set; } + public Dictionary DakotaInfoNutzDict { get; set; } + public Dictionary DakotaInfoAufDict { get; set; } - public DakotaManager() : this(DateTime.Now.Month, DateTime.Now) - { + public DakotaManager() : this(DateTime.Now.Month, DateTime.Now) + { - } - public DakotaManager(int month, DateTime dateTime, bool isSammelrechnung = false) - { - Month = month; - Version = GetVersion(dateTime); + } + public DakotaManager(int month, DateTime dateTime, bool isSammelrechnung = false) + { + Month = month; + Version = GetVersion(dateTime); - DakotaFileDict = new Dictionary(); + DakotaFileDict = new Dictionary(); - DakotaInfoNutzDict = new Dictionary(); - DakotaInfoAufDict = new Dictionary(); + DakotaInfoNutzDict = new Dictionary(); + DakotaInfoAufDict = new Dictionary(); - DakotaInfoCreator = new DakotaInfoCreator(isSammelrechnung); - IsSammelrechnung = isSammelrechnung; - } + DakotaInfoCreator = new DakotaInfoCreator(isSammelrechnung); + IsSammelrechnung = isSammelrechnung; + } - public void Add(ServiceInvoiceDC serviceInvoice, OrganisationDC organisation, CustomerDC customer, AddressInformation address, int datenaustauschreferenz, int transfernummer) - { - try - { - var ik_datenannahmestelle = organisation.IKDatenannahmestelle; - var success = DakotaInfoNutzDict.TryGetValue(ik_datenannahmestelle, out InfoDateiNutzdaten nutzdaten); + public void Add(ServiceInvoiceDC serviceInvoice, OrganisationDC organisation, CustomerDC customer, AddressInformation address, int datenaustauschreferenz, int transfernummer) + { + var ik_datenannahmestelle = organisation.IKDatenannahmestelle; + var success = DakotaInfoNutzDict.TryGetValue(ik_datenannahmestelle, out InfoDateiNutzdaten nutzdaten); - if (!success) - { - var verfahrensstufe = organisation.Verfahrensstufe; + if (!success) + { + var verfahrensstufe = organisation.Verfahrensstufe; - // Verfahrenkennung - // Erste Stelle: - // "E" - Echtdaten - // "T" - Testdaten - // Annahme: "E" auch für Erprobungsverfahrenstufe - // Zusatz: "T" bei Erprobungsverfahrenstufe + // Verfahrenkennung + // Erste Stelle: + // "E" - Echtdaten + // "T" - Testdaten + // Annahme: "E" auch für Erprobungsverfahrenstufe + // Zusatz: "T" bei Erprobungsverfahrenstufe - var isTest = verfahrensstufe == BS.Shared.GkvVerfahrensstufe.Test || verfahrensstufe == BS.Shared.GkvVerfahrensstufe.Erprobung; - var verfahrenkennung = isTest ? "TSOL0" : "ESOL0"; - var logischer_dateiname = DakotaConfig.GetLogischerDateiname(Month).Trim(); + var isTest = verfahrensstufe == BS.Shared.GkvVerfahrensstufe.Test || verfahrensstufe == BS.Shared.GkvVerfahrensstufe.Erprobung; + var verfahrenkennung = isTest ? "TSOL0" : "ESOL0"; + var logischer_dateiname = DakotaConfig.GetLogischerDateiname(Month).Trim(); - var info_nutz_add = DakotaInfoCreator.GetEmptyInfoNutzdatendatei(DakotaConfig.IKAbsender, organisation.IKDatenannahmestelle, (int)verfahrensstufe, logischer_dateiname, datenaustauschreferenz); - var info_auf_add = DakotaInfoCreator.GetEmptyInfoAuftragsdatei(organisation.IKDatenannahmestelle, logischer_dateiname, verfahrenkennung, transfernummer); + var info_nutz_add = DakotaInfoCreator.GetEmptyInfoNutzdatendatei(DakotaConfig.IKAbsender, organisation.IKDatenannahmestelle, (int)verfahrensstufe, logischer_dateiname, datenaustauschreferenz); + var info_auf_add = DakotaInfoCreator.GetEmptyInfoAuftragsdatei(organisation.IKDatenannahmestelle, logischer_dateiname, verfahrenkennung, transfernummer); - DakotaInfoNutzDict.Add(ik_datenannahmestelle, info_nutz_add); - DakotaInfoAufDict.Add(ik_datenannahmestelle, info_auf_add); + DakotaInfoNutzDict.Add(ik_datenannahmestelle, info_nutz_add); + DakotaInfoAufDict.Add(ik_datenannahmestelle, info_auf_add); - nutzdaten = info_nutz_add; - } + nutzdaten = info_nutz_add; + } - foreach (var peroid in serviceInvoice.ServiceInvoicePeriods) - { - foreach (var invoice in peroid.InvoiceItems) - { - var info_nutz_item = new InfoParameterInvoiceItem(serviceInvoice, invoice, organisation, customer, address); + foreach (var peroid in serviceInvoice.ServiceInvoicePeriods) + { + foreach (var invoice in peroid.InvoiceItems) + { + var info_nutz_item = new InfoParameterInvoiceItem(serviceInvoice, invoice, organisation, customer, address); - DakotaInfoCreator.AddInfoParameter(nutzdaten, info_nutz_item, Version); - } - } - } - catch (Exception e) - { - throw e; - } - } + DakotaInfoCreator.AddInfoParameter(nutzdaten, info_nutz_item, Version); + } + } + } - public void Apply() - { - foreach (var ik_datenannahmestelle in DakotaInfoNutzDict.Keys) - { - var file = new DakotaFile(DateTime.Now); + public void Apply() + { + foreach (var ik_datenannahmestelle in DakotaInfoNutzDict.Keys) + { + var file = new DakotaFile(DateTime.Now); - var info_nutz = DakotaInfoNutzDict[ik_datenannahmestelle]; - var info_auf = DakotaInfoAufDict[ik_datenannahmestelle]; + var info_nutz = DakotaInfoNutzDict[ik_datenannahmestelle]; + var info_auf = DakotaInfoAufDict[ik_datenannahmestelle]; - file.Nutzdatendatei.Apply(info_nutz, DakotaInfoCreator.IsSammelrechnung); - file.Auftragsdatei.Apply(info_auf); + file.Nutzdatendatei.Apply(info_nutz, DakotaInfoCreator.IsSammelrechnung); + file.Auftragsdatei.Apply(info_auf); - DakotaFileDict.Add(ik_datenannahmestelle, file); - } - } + DakotaFileDict.Add(ik_datenannahmestelle, file); + } + } - private int GetVersion(DateTime create4month) - { - if (create4month < new DateTime(2023, 7, 1)) - throw new NotImplementedException("Keine Unterstützung von Version 17 oder niedriger"); + private int GetVersion(DateTime create4month) + { + if (create4month < new DateTime(2023, 7, 1)) + throw new NotImplementedException("Keine Unterstützung von Version 17 oder niedriger"); - if (create4month < new DateTime(2024, 1, 1)) - return 18; + if (create4month < new DateTime(2024, 1, 1)) + return 18; - if (create4month < new DateTime(2024, 7, 1)) - return 19; + if (create4month < new DateTime(2024, 7, 1)) + return 19; - return 20; + return 20; - //if (create4month < new DateTime(2025, 1, 1)) - // return 20; + //if (create4month < new DateTime(2025, 1, 1)) + // return 20; - //throw new NotImplementedException("Keine Unterstützung von Version 21 oder aufwärts"); - } - } + //throw new NotImplementedException("Keine Unterstützung von Version 21 oder aufwärts"); + } + } } From d2c6ff071e79b80dc654be4d1915704eb20bbf9a Mon Sep 17 00:00:00 2001 From: Rene Evertz Date: Wed, 14 May 2025 10:49:33 +0200 Subject: [PATCH 2/4] UnitDescription muss vorhanden sein + Validierung --- .../Models/Infos/InfoParameterInvoiceItem.cs | 3 ++- Data/Entities/InvoiceBase.cs | 5 +++-- Data/Entities/InvoiceItem.cs | 3 ++- Shared/Core/ValidatorExtended.cs | 18 ++++++++++++++++++ Shared/DataContracts/InvoiceItemDC.cs | 1 + Shared/Interface/IInvoiceBase.cs | 1 + Shared/Interface/IInvoiceItem.cs | 14 ++++++++++++++ Shared/Shared.csproj | 1 + 8 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 Shared/Interface/IInvoiceItem.cs diff --git a/Dakota/Models/Infos/InfoParameterInvoiceItem.cs b/Dakota/Models/Infos/InfoParameterInvoiceItem.cs index a21129002..9b96aa75d 100644 --- a/Dakota/Models/Infos/InfoParameterInvoiceItem.cs +++ b/Dakota/Models/Infos/InfoParameterInvoiceItem.cs @@ -1,5 +1,6 @@ using BeWo.Data.Models; using BS.Shared.DataContracts; +using BS.Shared.Exceptions; using Dakota.Models.Schlüssels; using System; using System.Collections.Generic; @@ -33,7 +34,7 @@ namespace Dakota.Models.Infos AddressInformation = addressInformation; // Todo: Valid prüfen - Abrechnungsposition = invoiceItem.UnitDescription?.Substring(6) ?? "TODO"; + Abrechnungsposition = invoiceItem.UnitDescription.Substring(6); } } } diff --git a/Data/Entities/InvoiceBase.cs b/Data/Entities/InvoiceBase.cs index 18cbf2f7f..cd108fc75 100644 --- a/Data/Entities/InvoiceBase.cs +++ b/Data/Entities/InvoiceBase.cs @@ -1,6 +1,6 @@ using System; using System.Collections.Generic; - +using System.Linq; using BS.Shared; using BS.Shared.Interface; @@ -830,5 +830,6 @@ namespace BeWo.Data.Entities public virtual string SenderStreet => SenderAddress?.Street; public virtual string SenderTown => SenderAddress?.Town; public virtual string SenderPostCode => SenderAddress?.PostalCode; - } + public virtual IList IInvoiceItems => InvoiceItems.Select(x => x as IInvoiceItem).ToList(); + } } \ No newline at end of file diff --git a/Data/Entities/InvoiceItem.cs b/Data/Entities/InvoiceItem.cs index eee763828..56bce4e01 100644 --- a/Data/Entities/InvoiceItem.cs +++ b/Data/Entities/InvoiceItem.cs @@ -2,11 +2,12 @@ using System.Collections.Generic; using System.Diagnostics; using BS.Shared; +using BS.Shared.Interface; namespace BeWo.Data.Entities { [DebuggerDisplay("{ItemDescription}: {AmountPerUnit} x {UnitCount} = {AmountTotal}")] - public class InvoiceItem : BeWoEntityBase + public class InvoiceItem : BeWoEntityBase, IInvoiceItem { public static string PropertyName_AmountPerUnit = "AmountPerUnit"; diff --git a/Shared/Core/ValidatorExtended.cs b/Shared/Core/ValidatorExtended.cs index 25f3f0ccd..7114fa30f 100644 --- a/Shared/Core/ValidatorExtended.cs +++ b/Shared/Core/ValidatorExtended.cs @@ -21,6 +21,8 @@ namespace BS.Shared.Core error = "Keine Rechnungen gefunden"; else if (!AreAllAddressSame(invoiceBases)) error = "Unterschiedliche Rechnungspositionen"; + else if (GetInvalidUnitDescription(invoiceBases) is IInvoiceItem invalid) + error = $"Ungültige Rechnungsposition: {invalid.ItemDescription}:{invalid.UnitDescription}"; if(error is string) throw new GkvException(error, "Validierung"); @@ -42,5 +44,21 @@ namespace BS.Shared.Core public static bool AreAllAddressSame(IEnumerable invoiceBases) => invoiceBases.Select(x => x.SenderAddressToString()).AreAllTheSame(); + + public static IInvoiceItem GetInvalidUnitDescription(IEnumerable invoiceBases){ + foreach(var invoiceBase in invoiceBases) + { + foreach (var invoiceitem in invoiceBase.IInvoiceItems) + { + // GPos. 123456 + // 0123456 + var desc = invoiceitem.UnitDescription; + if (desc.Length < 8) + return invoiceitem; + } + } + + return null; + } } } diff --git a/Shared/DataContracts/InvoiceItemDC.cs b/Shared/DataContracts/InvoiceItemDC.cs index 5b480256f..254c2123e 100644 --- a/Shared/DataContracts/InvoiceItemDC.cs +++ b/Shared/DataContracts/InvoiceItemDC.cs @@ -1,3 +1,4 @@ +using BS.Shared.Interface; using System; using System.Collections.Generic; using System.Diagnostics; diff --git a/Shared/Interface/IInvoiceBase.cs b/Shared/Interface/IInvoiceBase.cs index 01d69f634..251f24e39 100644 --- a/Shared/Interface/IInvoiceBase.cs +++ b/Shared/Interface/IInvoiceBase.cs @@ -11,5 +11,6 @@ namespace BS.Shared.Interface string SenderStreet { get; } string SenderTown { get; } string SenderPostCode { get; } + IList IInvoiceItems { get; } } } diff --git a/Shared/Interface/IInvoiceItem.cs b/Shared/Interface/IInvoiceItem.cs new file mode 100644 index 000000000..f9e150a90 --- /dev/null +++ b/Shared/Interface/IInvoiceItem.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BS.Shared.Interface +{ + public interface IInvoiceItem + { + string UnitDescription { get; } + string ItemDescription { get; } + } +} diff --git a/Shared/Shared.csproj b/Shared/Shared.csproj index b031cc5e9..d0fefee7c 100644 --- a/Shared/Shared.csproj +++ b/Shared/Shared.csproj @@ -385,6 +385,7 @@ + From af41f63db4fee98d5a354ec3cf2c886f5b3026a2 Mon Sep 17 00:00:00 2001 From: Rene Evertz Date: Wed, 14 May 2025 10:52:22 +0200 Subject: [PATCH 3/4] missed files --- BeWo/ViewModel/InvoiceBaseVM.cs | 2 ++ Shared/DataContracts/InvoiceBaseDC.cs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/BeWo/ViewModel/InvoiceBaseVM.cs b/BeWo/ViewModel/InvoiceBaseVM.cs index dda1041d1..5f82e70ef 100644 --- a/BeWo/ViewModel/InvoiceBaseVM.cs +++ b/BeWo/ViewModel/InvoiceBaseVM.cs @@ -921,6 +921,8 @@ namespace BeWo.ViewModel public string SenderTown => DataContract.SenderTown; public string SenderPostCode => DataContract.SenderPostCode; + public IList IInvoiceItems => throw new NotImplementedException(); + protected override void InitByDataContract(InvoiceBaseDC pDataContract) { _SupportConceptOid = pDataContract.SupportConceptOid; diff --git a/Shared/DataContracts/InvoiceBaseDC.cs b/Shared/DataContracts/InvoiceBaseDC.cs index ef00aa5b9..e74398c6c 100644 --- a/Shared/DataContracts/InvoiceBaseDC.cs +++ b/Shared/DataContracts/InvoiceBaseDC.cs @@ -123,6 +123,8 @@ namespace BS.Shared.DataContracts } } + public IList IInvoiceItems => throw new NotImplementedException(); + public bool ContainsRecipientAddressData() { return !Utils.AreAllNullOrEmpty(this.RecipientStreet, this.RecipientPostCode, this.RecipientTown); From 89cb7062d677f2503203c4960492add75cfce62c Mon Sep 17 00:00:00 2001 From: Rene Evertz Date: Wed, 14 May 2025 11:14:17 +0200 Subject: [PATCH 4/4] =?UTF-8?q?Module=20Fehler=20Meldung=20->=20Noch=20Ser?= =?UTF-8?q?ver=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Shared/Core/MailUtils.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Shared/Core/MailUtils.cs b/Shared/Core/MailUtils.cs index a5bc0166f..c39374dd3 100644 --- a/Shared/Core/MailUtils.cs +++ b/Shared/Core/MailUtils.cs @@ -1,4 +1,5 @@ -using System; +using BS.Shared.AppSender; +using System; using System.Collections.Generic; using System.Configuration; using System.Linq; @@ -46,6 +47,10 @@ namespace BS.Shared.Core string tenant_str = "Kunde: " + (tenant ?? "unknown"); body += "\n\n" + tenant_str; + string server = AppRequestSender.GetServerFromTenant(tenant); + string server_str = "Server: " + (server ?? "unkown"); + body += "\n" + server_str; + return SendEmail(subject, body, toAddress, senderName, senderEMail, smtpServer, smtpUser, smtpPassword, sendAsync); }