Comments (6)
The answer seems to be quite simple:
The internal setter of trade line items prohibts creating them by the deserializer:
ZUGFeRD-csharp/ZUGFeRD/InvoiceDescriptor.cs
Line 175 in 01e3c9b
Working alone in my spare time on the project, I am happy to accept your sponsoring:
https://github.com/sponsors/stephanstapel
from zugferd-csharp.
Hi @springy76,
it is really hard to guess what might have gone wrong based on the exception. Can you please provide your unit test (working without any dependencies) and the file that is generated?
from zugferd-csharp.
Since the surrounding code goes through several layers of abstraction and transformation code I can't provide a simple sample, but I serialized the final InvoiceDescriptor
to json. Note that TradeLineItems
does not get deserialized, but I guess this is something you can fix easily since everything else looks good so far.
var jsonSerializerOptions = new JsonSerializerOptions { WriteIndented = true, Converters = { new JsonStringEnumConverter() { } } };
var json = JsonSerializer.Serialize(invoiceDescriptor, jsonSerializerOptions);
var rebuilt = JsonSerializer.Deserialize<InvoiceDescriptor>(json, jsonSerializerOptions);
var json2 = JsonSerializer.Serialize(rebuilt, jsonSerializerOptions);
Debug.Assert(json2 == json);
from zugferd-csharp.
I'm sorry, but generating the file from the data you provided works without any problem. Please try:
var jsonSerializerOptions = new JsonSerializerOptions { WriteIndented = true, Converters = { new JsonStringEnumConverter() { } } };
var json = File.ReadAllText("InvoiceDescriptorSerialized.json");
InvoiceDescriptor rebuilt = JsonSerializer.Deserialize<InvoiceDescriptor>(json, jsonSerializerOptions);
rebuilt.Save("output.xml", ZUGFeRDVersion.Version21, Profile.Basic);
from zugferd-csharp.
As said, currently all TradeLineItems get stripped/ignored during Deserialize - and they seem to be the error source when they exist. If you add those 2 lines to your code you'll see:
var json2 = JsonSerializer.Serialize(rebuilt, jsonSerializerOptions);
Debug.Assert(json2 == json); // not equal, entire TradLineItems-Subtree/-Array is empty
from zugferd-csharp.
The internal setter of trade line items prohibts creating them by the deserializer:
Klarer Fall von "Softwareproblem, kann man nichts machen" .
Irgendwie hatte ich die völlig irre Annahme, dass das auch in Bezug auf andere Bugreports - völlig losgelöst von diesem Issue - von Hilfe wäre, wenn man einen InvoiceDescriptor
nicht nur serialisieren, sondern auch verlustfrei deserialisieren kann.
from zugferd-csharp.
Related Issues (20)
- ZuGFeRD 2.2 HOT 5
- X-Rechnung 3.1 UBL for Deutsche Bahn HOT 7
- X-Rechnung 3.1 UBL for Deutsche Bahn - gross unit price decimals HOT 2
- X-Rechnung 3.1 UBL for Deutsche Bahn - line item gross unit price HOT 2
- X-Rechnung 3.1 UBL for Deutsche Bahn - charge percentage HOT 2
- X-Rechnung 3.1 UBL for Deutsche Bahn - net unit price rounding HOT 2
- X-Rechnung 3.1 UBL for Deutsche Bahn - unclear HOT 2
- X-Rechnung 3.1 UBL for Deutsche Bahn - line total amount HOT 4
- X-Rechnung 3.1 UBL for Deutsche Bahn - writing taxes HOT 12
- X-Rechnung 3.1 UBL for Deutsche Bahn - tax rounding HOT 4
- XML cardinality not correctly mapped HOT 7
- InvoiceValidator.Validate doesn HOT 3
- Wrong output formatting in _formatDecimal ind IINvoiceDescriptorWriter.cs HOT 4
- X-Rechnung 3.0.1 UBL warnings
- Unterschied v2 und v21+ erkennen HOT 2
- Doppelte Ausgabe von ChargePercentage HOT 1
- Link dead HOT 1
- TaxExemptionReasonCodes aren't upper-case
- TradeAllowenceCharge not read from xml file HOT 1
- Question about the XInvoice HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zugferd-csharp.