# Conflicts: # BeWo/BeWo.csproj # BeWo/BeWoApp.xaml.cs # BeWo/ServiceProxy/GeneratedAiEnhancedService.cs # BeWo/Services/BeWoControlFactory.cs # BeWo/Services/BeWoWindowFactory.cs # BeWo/Services/BeWoWindowService.cs # BeWo/Services/IControlFactory.cs # BeWo/Services/IWindowFactory.cs # BeWo/Services/IWindowService.cs # BeWo/View/BeWoFileView.xaml # BeWo/View/Detail/Report/AbwesenheitsView.xaml # BeWo/View/Windows/AnimatedBeWoWindow.xaml.cs # BeWo/app.config # BeWoAllReports.sln # BeWoPlanerMobil.sln # BeWoPlanerMobil/.vs/BeWoPlanerMobil.csproj.dtbcache.json # BeWoTests.sln # Dakota/DakotaUtils.cs # Dakota/Logic/DakotaInfoCreator.cs # Dakota/Models/DakotaFile.cs # Data/Access/GenericDAO.cs # Data/Access/SearchDAO.cs # Data/Data.csproj # Host/Web.config # Server/Components/ServerUtils/ApiFacade/WebClientFacade.cs # Service/BeWoServiceEnums.cs # Service/Core/ServiceHelper.cs # Service/Core/ServiceValidator.cs # Service/Extensions/ServiceEnumExtension.cs # Service/Service.csproj # Service/ServiceContracts/Enhanced/IAiEnhancedService.cs # Service/ServiceContracts/Enhanced/IOperationsEnhancedService.cs # Service/ServiceImplementations/EmployeeServiceImp.cs # Service/ServiceImplementations/Enhanced/AiEnhancedServiceImp.cs # Service/ServiceImplementations/Enhanced/OperationsEnhancedServiceImp.cs # Service/ServiceProxy/OpenWebUIFacade.cs # Service/ServiceProxy/ServiceFacade.cs # Service/ServiceUtils/DistanceCalculator/GoogleDistanceMatrixAPI.cs # Shared/BeWoEntityEnums.cs # Shared/Core/AppError.cs # Shared/Core/Facade/WebClientFacade.cs # Shared/Core/WebClientFacade.cs # Shared/Shared.csproj
79 lines
2.0 KiB
C#
79 lines
2.0 KiB
C#
using BS.Shared.Exceptions;
|
|
using BS.Shared.Extensions;
|
|
using BS.Shared.Interface;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Text.RegularExpressions;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace BS.Shared.Core
|
|
{
|
|
public static class ValidatorExtended
|
|
{
|
|
public static void ValidateGkvAbrechnung(IGkvAbrechnung gkvAbrechnung, IEnumerable<IInvoiceBase> invoiceBases, bool testInvoicesEmpty = true)
|
|
{
|
|
string error = null;
|
|
|
|
if (testInvoicesEmpty && !invoiceBases.Any())
|
|
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}";
|
|
else if (GkvValidator.ValidateInvoiceBases(invoiceBases) is string rtn_error)
|
|
error = rtn_error;
|
|
|
|
if(error is string)
|
|
throw new GkvException(error, "Validierung");
|
|
}
|
|
|
|
public static bool TryValidateGkvAbrechnung(IGkvAbrechnung gkvAbrechnung, IEnumerable<IInvoiceBase> invoiceBases, out string error, bool testInvoicesEmpty = true)
|
|
{
|
|
error = "default";
|
|
|
|
try
|
|
{
|
|
ValidateGkvAbrechnung(gkvAbrechnung, invoiceBases, testInvoicesEmpty);
|
|
|
|
return true;
|
|
}
|
|
catch (GkvException gkv)
|
|
{
|
|
error = gkv.Message;
|
|
}
|
|
catch (Exception)
|
|
{
|
|
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
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)
|
|
{
|
|
if (invoiceBase.IInvoiceItems is null && !invoiceBase.IInvoiceItems.Any())
|
|
continue;
|
|
|
|
foreach (var invoiceitem in invoiceBase.IInvoiceItems)
|
|
{
|
|
// GPos. 123456
|
|
// 0123456
|
|
var desc = invoiceitem.UnitDescription;
|
|
if (desc.Length < 8)
|
|
return invoiceitem;
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
|
|
}
|
|
}
|