pax.XRechnung.NET
0.0.1
dotnet add package pax.XRechnung.NET --version 0.0.1
NuGet\Install-Package pax.XRechnung.NET -Version 0.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="pax.XRechnung.NET" Version="0.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add pax.XRechnung.NET --version 0.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: pax.XRechnung.NET, 0.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install pax.XRechnung.NET as a Cake Addin #addin nuget:?package=pax.XRechnung.NET&version=0.0.1 // Install pax.XRechnung.NET as a Cake Tool #tool nuget:?package=pax.XRechnung.NET&version=0.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Introduction
pax.XRechnung.NET
is a .NET library for validating and mapping XRechnung XML invoices.
Features
- Validate XRechnung XML invoices
- Map XML invoices to DTOs for easier manipulation
- Generate compliant XML invoices from structured DTOs
Getting started
Installation
dotnet add package pax.XRechnung.NET
Usage
Handle Sample Invoice
InvoiceDto invoiceDto = new()
{
Id = "1",
IssueDate = DateTime.UtcNow,
DueDate = DateTime.UtcNow.AddDays(14),
InvoiceTypeCode = "380",
Note = "Test Note",
DocumentCurrencyCode = "EUR",
BuyerReference = "123",
AdditionalDocumentReference = new()
{
Id = "invoice 123",
DocumentDescription = "human readable pdf invoice",
MimeCode = "application/pdf",
FileName = "invoice.pdf",
Content = "ZWYNCjE0OTk0Nw0KJSVFT0Y=",
},
Seller = new()
{
Email = "seller@email.com",
Name = "Seller",
StreetName = "TestStreet",
City = "TestCity",
PostCode = "12345",
ContactName = "ContactName",
ContactTelephone = "12345",
ContactEmail = "contact@email.com",
TaxCompanyId = "DE1234567",
TaxSchemeId = "VAT",
RegistrationName = "Seller Name",
},
Buyer = new()
{
Email = "buyer@email.com",
Name = "Buyer",
StreetName = "TestStreet1",
City = "TestCity1",
PostCode = "54321",
ContactName = "ContactName1",
ContactTelephone = "54321",
ContactEmail = "contact1@email.com"
},
PaymentMeans = new()
{
PaymentMeansTypeCode = "30",
IBAN = "DE21081508151234123412",
BankName = "Test Bank"
},
TaxTotal = new()
{
TaxAmount = 4.27M,
TaxableAmount = 22.45M,
TaxCategoryId = "S",
Percent = 19.0M,
TaxScheme = "VAT"
},
LegalMonetaryTotal = new()
{
LineExtensionAmount = 22.45M,
TaxExclusiveAmount = 22.45M,
TaxInclusiveAmount = 26.72M,
PayableAmount = 26.72M,
},
InvoiceLines = [
new() {
Id = "1",
Note = "Test Note",
Name = "Test",
Description ="Test Desc",
TaxId = "S",
TaxPercent = 19.0M,
TaxScheme = "VAT",
InvoicedQuantity = 1,
InvoicedQuantityCode = "XPP",
LineExtensionAmount = 22.45M,
PriceAmount = 22.45M,
},
]
};
try
{
var validationResult = XmlInvoiceValidator.Validate(invoiceDto);
if (!validationResult.IsValid)
{
var error = valitationResult.Error ?? string.Join(", ", validationResult.Validations.Select(s => s.Message);
Console.WriteLine($"Validation errors: {error}");
}
else
{
var xmlText = XmlInvoiceWriter.Serialize(invoiceDto);
Console.WriteLine("Invoice serialized successfully.");
}
}
catch (Exception ex)
{
Console.WriteLine($"An error occurred: {ex.Message}");
}
Handle xml file
var filePath = "path/to/xml";
try
{
var serializer = new XmlSerializer(typeof(XmlInvoice));
using var stream = new FileStream(filePath, FileMode.Open, FileAccess.Read);
var xmlInvoice = (XmlInvoice?)serializer.Deserialize(stream);
var validationResult = XmlInvoiceValidator.Validate(xmlInvoice);
if (!validationResult.IsValid)
{
var error = valitationResult.Error ?? string.Join(", ", validationResult.Validations.Select(s => s.Message);
Console.WriteLine($"Validation errors: {error}");
}
else
{
var invoiceDto = XmlInvoiceMapper.MapToInvoiceDto(xmlInvoice);
Console.WriteLine("Invoice mapped successfully.");
}
}
catch (Exception ex)
{
Console.WriteLine($"An error occurred: {ex.Message}");
}
Known Limitations / ToDo
- Partial DTO Implementation: Currently, the DTOs only support a subset of XRechnung properties. Missing properties will need manual extension.
- Incomplete XML Validation: Not all XML element names or attributes are verified for strict compliance with XRechnung standards.
ChangeLog
<details open="open"><summary>v0.0.1</summary>
- Initial release
- Support for invoice validation and serialization
- Partial DTO implementation
</details>
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.0.1 | 77 | 12/22/2024 |