Merge branch 'master' of ssh://float.ownsoft.de/git/beyondSoft/BeWo

This commit is contained in:
2025-05-15 08:43:42 +02:00
12 changed files with 131 additions and 91 deletions

View File

@@ -921,6 +921,8 @@ namespace BeWo.ViewModel
public string SenderTown => DataContract.SenderTown;
public string SenderPostCode => DataContract.SenderPostCode;
public IList<IInvoiceItem> IInvoiceItems => throw new NotImplementedException();
protected override void InitByDataContract(InvoiceBaseDC pDataContract)
{
_SupportConceptOid = pDataContract.SupportConceptOid;

View File

@@ -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<string, DakotaFile> DakotaFileDict { get; set; }
public Dictionary<string, DakotaFile> DakotaFileDict { get; set; }
public Dictionary<string, InfoDateiNutzdaten> DakotaInfoNutzDict { get; set; }
public Dictionary<string, InfoDateiAuftrags> DakotaInfoAufDict { get; set; }
public Dictionary<string, InfoDateiNutzdaten> DakotaInfoNutzDict { get; set; }
public Dictionary<string, InfoDateiAuftrags> 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<string, DakotaFile>();
DakotaFileDict = new Dictionary<string, DakotaFile>();
DakotaInfoNutzDict = new Dictionary<string, InfoDateiNutzdaten>();
DakotaInfoAufDict = new Dictionary<string, InfoDateiAuftrags>();
DakotaInfoNutzDict = new Dictionary<string, InfoDateiNutzdaten>();
DakotaInfoAufDict = new Dictionary<string, InfoDateiAuftrags>();
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");
}
}
}

View File

@@ -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);
}
}
}

View File

@@ -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<IInvoiceItem> IInvoiceItems => InvoiceItems.Select(x => x as IInvoiceItem).ToList();
}
}

View File

@@ -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";

View File

@@ -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);
}

View File

@@ -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<IInvoiceBase> invoiceBases)
=> invoiceBases.Select(x => x.SenderAddressToString()).AreAllTheSame();
public static IInvoiceItem GetInvalidUnitDescription(IEnumerable<IInvoiceBase> 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;
}
}
}

View File

@@ -123,6 +123,8 @@ namespace BS.Shared.DataContracts
}
}
public IList<IInvoiceItem> IInvoiceItems => throw new NotImplementedException();
public bool ContainsRecipientAddressData()
{
return !Utils.AreAllNullOrEmpty(this.RecipientStreet, this.RecipientPostCode, this.RecipientTown);

View File

@@ -1,3 +1,4 @@
using BS.Shared.Interface;
using System;
using System.Collections.Generic;
using System.Diagnostics;

View File

@@ -11,5 +11,6 @@ namespace BS.Shared.Interface
string SenderStreet { get; }
string SenderTown { get; }
string SenderPostCode { get; }
IList<IInvoiceItem> IInvoiceItems { get; }
}
}

View File

@@ -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; }
}
}

View File

@@ -385,6 +385,7 @@
<Compile Include="Interface\IGkvAbrechnung.cs" />
<Compile Include="Interface\IGkvTransferProtokoll.cs" />
<Compile Include="Interface\IInvoiceBase.cs" />
<Compile Include="Interface\IInvoiceItem.cs" />
<Compile Include="Packet.cs" />
<Compile Include="ReportRequests\AbstractReportRequest.cs" />
<Compile Include="ReportRequests\GkvAbrechnungReportRequest.cs" />