VSOS
VSOS

Reputation: 574

Handle UBL 2.1 invoices - .net 6

I'm starting a research task for handling UBL 2.1 invoices in a .net 6 project.

From a quick research there seems to be a "popular" .net library , namely UblSharp.

Unfortunately, it seems it hasn't been updated from a long time, last release was on May 2019.I understand that UBL 2.1. is a standard from November 2013, so the current UblSharp should still work as expected.

But i'm not very enthusiastic of using a third party library, that isn't maintained anymore. Moreover, once we need to use UBL 2.2 or higher, we will need a different approach, as UblSharp only works up to 2.1.

Another approach could be to manually create the C# classes needed to handle UBL 2.1, for example, using something like XmlSchemaClassGenerator https://github.com/mganss/XmlSchemaClassGenerator

From a theorethical prespective (and please understand that i'm just starting the research, so i might be wrong), by creating specific .net classes to handle the UBL 2.1 specification should allow me to easily handle UBL 2.1 invoices.

I'm tempted in going with XmlSchemaClassGenerator approach.

Am i missing anything or being over simplistic?

Thank you!

Upvotes: 1

Views: 1916

Answers (1)

VSOS
VSOS

Reputation: 574

In the end, i opted to test all alternatives:

  1. Direct XSD to c# classes with LinqToXsdCore

  2. Third party libs: UblSharp and UblTr

Direct XSD to c# classes with LinqToXsdCore

I've used the UBL 2.1 specification available on the OASIS documents. When generating the Invoice classes from the UBL-Invoice-2.1.xsd specification i got some errors:

  • Generated code doesn't compile if an element is named Content: known error described in the LinqToXsdCore Github.
  • Some methods were failing due to the return type, but this was easily fixed.

Third party libs

Both UblSharp and UblTr were simple to use. UblSharp isn't maintained since 2019, but given that the UBL 2.1 specification is from 2013, it shouldn't matter.

UblTr was updated on Dec/2023, but seems to be specific for Turkey.

Both handled the UBL 2.1 Invoice example file perfectly.

I did a very crude benchmark, and direct c# classes from xsd, and UblSharp (around 70-90ms) are more or less equivalent, with UblTr with higher process times (around 400ms).

Upvotes: 5

Related Questions