Add invoice model and validation rules
This commit is contained in:
commit
7128a93461
8 files changed
+588
No files matched your search
@@ -0,0 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ImportAssist.Core\ImportAssist.Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,24 @@
|
||||
using ImportAssist.Core;
|
||||
|
||||
InvoiceRow[] rows =
|
||||
[
|
||||
new("INV-001", "C-100", "125.50", "EUR"),
|
||||
new("INV-002", "", "89.00", "EUR"),
|
||||
new("INV-003", "C-300", "abc", "EUR"),
|
||||
new("INV-004", "C-400", "-10.00", "EUR"),
|
||||
new("", "", "0", "EUR")
|
||||
];
|
||||
|
||||
foreach (var row in rows)
|
||||
{
|
||||
var errors = InvoiceValidator.Validate(row);
|
||||
|
||||
var invoiceId = string.IsNullOrWhiteSpace(row.InvoiceId)
|
||||
? "(ohne Rechnungsnummer)"
|
||||
: row.InvoiceId;
|
||||
|
||||
Console.WriteLine(
|
||||
errors.Count == 0
|
||||
? $"{invoiceId}: Gültig"
|
||||
: $"{invoiceId}: {string.Join("; ", errors)}");
|
||||
}
|
||||
Reference in new issue
Block a user