Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,9 @@ public static InvoiceBaseDto GetInvoiceBaseDto()
GlobalTaxScheme = "VAT",
GlobalTax = 19.0,
Id = "1",
IssueDate = DateTime.UtcNow,
IssueDate = new DateTime(2025, 05, 01),
InvoiceTypeCode = "380",
DocumentCurrencyCode = "EUR",
BuyerReference = "04011000-12345-34",
SellerParty = new PartyBaseDto()
{
Name = "Seller Name",
Expand All @@ -69,15 +68,16 @@ public static InvoiceBaseDto GetInvoiceBaseDto()
Telefone = "1234/54321",
Email = "buyer@example.com",
RegistrationName = "Buyer Name",
BuyerReference = "04011000-12345-34",
},
PaymentMeans = new PaymentMeansBaseDto()
{
Iban = "DE12 1234 1234 1234 1234 12",
Bic = "BICABCDE",
Name = "Bank Name"
Name = "Bank Name",
PaymentMeansTypeCode = "30",
},
PaymentMeansTypeCode = "30",
PaymentTermsNote = "Zahlbar innerhalb 14 Tagen nach Erhalt der Rechnung.",
PaymentTermsNote = "Zahlbar innerhalb von 14 Tagen nach Erhalt der Rechnung.",
PayableAmount = 119.0,
InvoiceLines = [
new InvoiceLineBaseDto()
Expand Down Expand Up @@ -121,7 +121,17 @@ Server start:

# ChangeLog

<details open="open"><summary>v0.3.0</summary>
<details open="open"><summary>v0.3.1</summary>

>- **Breaking Changes**
>- Code Lists fix to receive meta information
>- DTO rework to be more flexible and robust:
>- PaymentMeansTypeCode to PaymentMeans
>- BuyerReference to BuyerParty

</details>

<details><summary>v0.3.0</summary>

>- **Breaking Changes**
>- DTO rework to be more flexible and robust.
Expand Down
6 changes: 3 additions & 3 deletions src/pax.XRechnung.NET.tests/AnnotationDtoTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public static InvoiceAnnotationDto GetInvoiceAnnDto()
IssueDate = DateTime.UtcNow,
InvoiceTypeCode = "380",
DocumentCurrencyCode = "EUR",
BuyerReference = "04011000-12345-34",
SellerParty = new SellerAnnotationDto()
{
Name = "Seller Name",
Expand All @@ -42,14 +41,15 @@ public static InvoiceAnnotationDto GetInvoiceAnnDto()
Telefone = "1234/54321",
Email = "buyer@example.com",
RegistrationName = "Buyer Name",
BuyerReference = "04011000-12345-34",
},
PaymentMeans = new PaymentAnnotationDto()
{
Iban = "DE12 1234 1234 1234 1234 12",
Bic = "BICABCDE",
Name = "Bank Name"
Name = "Bank Name",
PaymentMeansTypeCode = "30",
},
PaymentMeansTypeCode = "30",
PaymentTermsNote = "Zahlbar innerhalb 14 Tagen nach Erhalt der Rechnung.",
PayableAmount = 119.0,
InvoiceLines = [
Expand Down
8 changes: 3 additions & 5 deletions src/pax.XRechnung.NET.tests/BaseDtoExtensionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public static InvoiceExtendedDto GetInvoiceBaseDto()
IssueDate = DateTime.UtcNow,
InvoiceTypeCode = "380",
DocumentCurrencyCode = "EUR",
BuyerReference = "04011000-12345-34",
SellerParty = new PartyBaseDto()
{
Name = "Seller Name",
Expand All @@ -41,14 +40,15 @@ public static InvoiceExtendedDto GetInvoiceBaseDto()
Telefone = "1234/54321",
Email = "buyer@example.com",
RegistrationName = "Buyer Name",
BuyerReference = "04011000-12345-34",
},
PaymentMeans = new PaymentMeansBaseDto()
{
Iban = "DE12 1234 1234 1234 1234 12",
Bic = "BICABCDE",
Name = "Bank Name"
Name = "Bank Name",
PaymentMeansTypeCode = "30",
},
PaymentMeansTypeCode = "30",
PaymentTermsNote = "Zahlbar innerhalb 14 Tagen nach Erhalt der Rechnung.",
PayableAmount = 119.0,
InvoiceLines = [
Expand Down Expand Up @@ -164,12 +164,10 @@ public class InvoiceExtendedDto : IInvoiceBaseDto
public string InvoiceTypeCode { get; set; } = "380";
public string? Note { get; set; }
public string DocumentCurrencyCode { get; set; } = "EUR";
public string BuyerReference { get; set; } = string.Empty;
public List<DocumentReferenceBaseDto> AdditionalDocumentReferences { get; set; } = [];
public PartyBaseDto SellerParty { get; set; } = new PartyBaseDto();
public PartyBaseDto BuyerParty { get; set; } = new PartyBaseDto();
public PaymentMeansBaseDto PaymentMeans { get; set; } = new PaymentMeansBaseDto();
public string PaymentMeansTypeCode { get; set; } = "30";
public string PaymentTermsNote { get; set; } = string.Empty;
public double PayableAmount { get; set; }
public List<InvoiceLineExtendedDto> InvoiceLines { get; set; } = [];
Expand Down
6 changes: 3 additions & 3 deletions src/pax.XRechnung.NET.tests/BaseDtoTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public static InvoiceBaseDto GetInvoiceBaseDto()
IssueDate = new DateTime(2025, 05, 01),
InvoiceTypeCode = "380",
DocumentCurrencyCode = "EUR",
BuyerReference = "04011000-12345-34",
SellerParty = new PartyBaseDto()
{
Name = "Seller Name",
Expand All @@ -40,14 +39,15 @@ public static InvoiceBaseDto GetInvoiceBaseDto()
Telefone = "1234/54321",
Email = "buyer@example.com",
RegistrationName = "Buyer Name",
BuyerReference = "04011000-12345-34",
},
PaymentMeans = new PaymentMeansBaseDto()
{
Iban = "DE12 1234 1234 1234 1234 12",
Bic = "BICABCDE",
Name = "Bank Name"
Name = "Bank Name",
PaymentMeansTypeCode = "30",
},
PaymentMeansTypeCode = "30",
PaymentTermsNote = "Zahlbar innerhalb 14 Tagen nach Erhalt der Rechnung.",
PayableAmount = 119.0,
InvoiceLines = [
Expand Down
13 changes: 13 additions & 0 deletions src/pax.XRechnung.NET.tests/CodeListTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@

using pax.XRechnung.NET.CodeListModel;

namespace pax.XRechnung.NET.tests;

[TestClass]
public class CodeListTests
{
Expand All @@ -11,4 +14,14 @@ public void CanValidateCode()
var isValid = CodeListRepository.IsValidCode(listId, code);
Assert.IsTrue(isValid);
}

[TestMethod]
public void CanSerializeDescription()
{
CodeList? codeList = CodeListRepository.GetCodeList("UNTDID_1001");
Assert.IsNotNull(codeList);
var desc = "Die Codeliste basiert auf der Codeliste 1001 (Document name code) des United Trade Data Interchange Directory (UNTDID). Die vorliegende Version der Codeliste entspricht in Umfang und Inhalt der Einträge (Codes, Namen und Beschreibung) der zugrundeliegenden Codeliste 1001 (Document name code) des United Trade Data Interchange Directory (UNTDID). Die Codeliste kann im Zusammenhang mit EN16931-1:2017 und der darauf basierenden XRechnung (Standard und Extension) verwendeten werden. EN16931 Annex A definiert eine Untermenge dieser Liste zur Verwendung. Des Weiteren enthält diese Codeliste alle Einträge, die für die Nutzung im Kontext des Standards XBestellung benötigt werden.";
var current = codeList.Metadaten.Beschreibung.FirstOrDefault()?.Value;
Assert.AreEqual(desc, current);
}
}
6 changes: 3 additions & 3 deletions src/pax.XRechnung.NET.tests/CustomDtoTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public static MyCustomInvoiceDto GetInvoiceDto()
IssueDate = DateTime.UtcNow,
InvoiceTypeCode = "380",
DocumentCurrencyCode = "EUR",
BuyerReference = "04011000-12345-34",
SellerParty = new SellerAnnotationDto()
{
Name = "Seller Name",
Expand All @@ -41,14 +40,15 @@ public static MyCustomInvoiceDto GetInvoiceDto()
Telefone = "1234/54321",
Email = "buyer@example.com",
RegistrationName = "Buyer Name",
BuyerReference = "04011000-12345-34",
},
PaymentMeans = new PaymentAnnotationDto()
{
Iban = "DE12 1234 1234 1234 1234 12",
Bic = "BICABCDE",
Name = "Bank Name"
Name = "Bank Name",
PaymentMeansTypeCode = "30",
},
PaymentMeansTypeCode = "30",
PaymentTermsNote = "Zahlbar innerhalb 14 Tagen nach Erhalt der Rechnung.",
PayableAmount = 119.0,
InvoiceLines = [
Expand Down
7 changes: 5 additions & 2 deletions src/pax.XRechnung.NET/AnnotatedDtos/BuyerAnnotationDto.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.ComponentModel.DataAnnotations;
using pax.XRechnung.NET.BaseDtos;
using System.ComponentModel.DataAnnotations;

namespace pax.XRechnung.NET.AnnotatedDtos;
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
Expand All @@ -21,9 +21,12 @@ public class BuyerAnnotationDto : IPartyBaseDto
public string Telefone { get; set; } = string.Empty;
[Required]
public string Email { get; set; } = string.Empty;
[Required]
[Required]
public string RegistrationName { get; set; } = string.Empty;
public string TaxId { get; set; } = string.Empty;
public string? CompanyId { get; set; }
[Required]
public string BuyerReference { get; set; } = string.Empty;
}

#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.ComponentModel.DataAnnotations;
using pax.XRechnung.NET.BaseDtos;
using System.ComponentModel.DataAnnotations;

namespace pax.XRechnung.NET.AnnotatedDtos;

Expand Down
8 changes: 2 additions & 6 deletions src/pax.XRechnung.NET/AnnotatedDtos/InvoiceAnnotationDto.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.ComponentModel.DataAnnotations;
using pax.XRechnung.NET.BaseDtos;
using System.ComponentModel.DataAnnotations;

namespace pax.XRechnung.NET.AnnotatedDtos;

Expand Down Expand Up @@ -29,15 +29,11 @@ public class InvoiceAnnotationDto : IInvoiceBaseDto
[Required]
[ValidCode(CodeListType.Currency_Codes_3)]
public string DocumentCurrencyCode { get; set; } = "EUR";
[Required]
public string BuyerReference { get; set; } = string.Empty;
public List<DocumentReferenceAnnotationDto> AdditionalDocumentReferences { get; set; } = [];
public SellerAnnotationDto SellerParty { get; set; } = new SellerAnnotationDto();
public BuyerAnnotationDto BuyerParty { get; set; } = new BuyerAnnotationDto();
public PaymentAnnotationDto PaymentMeans { get; set; } = new PaymentAnnotationDto();
[Required]
[ValidCode(CodeListType.UNTDID_4461_3)]
public string PaymentMeansTypeCode { get; set; } = "30";

public string PaymentTermsNote { get; set; } = string.Empty;
public double PayableAmount { get; set; }
public List<InvoiceLineAnnotationDto> InvoiceLines { get; set; } = [];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.ComponentModel.DataAnnotations;
using pax.XRechnung.NET.BaseDtos;
using System.ComponentModel.DataAnnotations;

namespace pax.XRechnung.NET.AnnotatedDtos;
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
Expand All @@ -19,7 +19,7 @@ public class InvoiceLineAnnotationDto : IInvoiceLineBaseDto
public string? Description { get; set; } = string.Empty;
[Required]
public string Name { get; set; } = string.Empty;
public double LineTotal => Math.Round(Math.Round(Quantity, 2) * Math.Round(UnitPrice, 2), 2);
public double LineTotal => Math.Round(Quantity * UnitPrice, 2);
}

#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
5 changes: 4 additions & 1 deletion src/pax.XRechnung.NET/AnnotatedDtos/PaymentAnnotationDto.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.ComponentModel.DataAnnotations;
using pax.XRechnung.NET.BaseDtos;
using System.ComponentModel.DataAnnotations;

namespace pax.XRechnung.NET.AnnotatedDtos;
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
Expand All @@ -10,6 +10,9 @@ public class PaymentAnnotationDto : IPaymentMeansBaseDto
[Required]
public string Bic { get; set; } = string.Empty;
public string Name { get; set; } = string.Empty;
[Required]
[ValidCode(CodeListType.UNTDID_4461_3)]
public string PaymentMeansTypeCode { get; set; } = "30";
}

#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
4 changes: 3 additions & 1 deletion src/pax.XRechnung.NET/AnnotatedDtos/SellerAnnotationDto.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.ComponentModel.DataAnnotations;
using pax.XRechnung.NET.BaseDtos;
using System.ComponentModel.DataAnnotations;

namespace pax.XRechnung.NET.AnnotatedDtos;

Expand All @@ -26,6 +26,8 @@ public class SellerAnnotationDto : IPartyBaseDto
public string RegistrationName { get; set; } = string.Empty;
[Required]
public string TaxId { get; set; } = string.Empty;
public string? CompanyId { get; set; }
public string BuyerReference { get; set; } = string.Empty;
}

#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
10 changes: 0 additions & 10 deletions src/pax.XRechnung.NET/BaseDtos/InvoiceBaseDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@ public interface IInvoiceBaseDto
string InvoiceTypeCode { get; set; }
string? Note { get; set; }
string DocumentCurrencyCode { get; set; }
string BuyerReference { get; set; }
List<IDocumentReferenceBaseDto> AdditionalDocumentReferences { get; set; }
IPartyBaseDto SellerParty { get; set; }
IPartyBaseDto BuyerParty { get; set; }
IPaymentMeansBaseDto PaymentMeans { get; set; }
string PaymentMeansTypeCode { get; set; }
string PaymentTermsNote { get; set; }
double PayableAmount { get; set; }
List<IInvoiceLineBaseDto> InvoiceLines { get; set; }
Expand Down Expand Up @@ -84,10 +82,6 @@ public partial class InvoiceBaseDto : IInvoiceBaseDto
/// </summary>
public string DocumentCurrencyCode { get; set; } = "EUR";
/// <summary>
/// Ein vom Erwerber zugewiesener und für interne Lenkungszwecke benutzter Bezeichner
/// </summary>
public string BuyerReference { get; set; } = string.Empty;
/// <summary>
/// Additional documents attached to the invoice (e.g., contract, timesheet)
/// </summary>
public List<DocumentReferenceBaseDto> AdditionalDocumentReferences { get; set; } = [];
Expand All @@ -104,10 +98,6 @@ public partial class InvoiceBaseDto : IInvoiceBaseDto
/// </summary>
public PaymentMeansBaseDto PaymentMeans { get; set; } = new PaymentMeansBaseDto();
/// <summary>
/// Payment type code, e.g. "30"
/// </summary>
public string PaymentMeansTypeCode { get; set; } = "30";
/// <summary>
/// Payment terms note
/// </summary>
public string PaymentTermsNote { get; set; } = string.Empty;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public virtual IPartyBaseDto FromXml(XmlParty xmlParty)
TaxId = xmlParty.PartyTaxScheme?.CompanyId ?? string.Empty,
Telefone = xmlParty.Contact?.Telephone ?? string.Empty,
Email = xmlParty.Contact?.Email ?? string.Empty,
CompanyId = xmlParty.PartyLegalEntity.CompanyId,
};
return dto;
}
Expand All @@ -49,7 +50,11 @@ public virtual XmlParty ToXml(IPartyBaseDto partyBaseDto)
PostCode = partyBaseDto.PostCode,
Country = new() { IdentificationCode = partyBaseDto.CountryCode },
},
PartyLegalEntity = new() { RegistrationName = partyBaseDto.RegistrationName },
PartyLegalEntity = new()
{
RegistrationName = partyBaseDto.RegistrationName,
CompanyId = partyBaseDto.CompanyId,
},
Contact = new()
{
Name = InvoiceMapperUtils.GetNullableString(partyBaseDto.Name),
Expand Down
Loading