UnitDescription muss vorhanden sein + Validierung
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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";
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using BS.Shared.Interface;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
||||
@@ -11,5 +11,6 @@ namespace BS.Shared.Interface
|
||||
string SenderStreet { get; }
|
||||
string SenderTown { get; }
|
||||
string SenderPostCode { get; }
|
||||
IList<IInvoiceItem> IInvoiceItems { get; }
|
||||
}
|
||||
}
|
||||
|
||||
14
Shared/Interface/IInvoiceItem.cs
Normal file
14
Shared/Interface/IInvoiceItem.cs
Normal 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; }
|
||||
}
|
||||
}
|
||||
@@ -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" />
|
||||
|
||||
Reference in New Issue
Block a user