FluiTec / FluiTec.DatevSharp

DATEV-Library in C#
Other
14 stars 5 forks source link

Value "Undefined" missing for non-mandatory enums #10

Open faiteanu opened 1 year ago

faiteanu commented 1 year ago

Hi, first of all: thanks for the nice library! I have one issue with the way enums are defined, in that some of them are missing a default "Undefined" value.

If you run your sample program, you will see that certain fields are filled unexpectedly in a Booking Row, e.g. "DifferentTaxType" (Abw. Versteuerungsart) is by default set to "I" (Ist-Versteuerung), which is probably wrong for most companies. The field is actually non-mandatory, but I cannot leave it blank, since one of the enum values must be assigend. Please add the value

[StringValue(null)]
Undefined = 0,

to all Enums where Format_Buchungsstapel.xml contains <Necessary>0</Necessary>. Currently I see the following non-empty fields in bookings:

Thanks!

IInvocation commented 1 year ago

Hi, you're welcome.

As can be seen in the merged PullRequest, i've added this in a couple of enums. Others should not be necessary as far as i can see. Coulkd you please test the changes and give me feedback if everything works as it should?

faiteanu commented 1 year ago

Hallo Achim, danke für die schnelle Korrektur, es funktioniert!

As a matter of personal taste, I would always write a concrete number assignment for an enum value explicitly, if the value is significant, e.g. Undefined = 0. This guards against programming errors, e.g. if someone else orders the enum values alphabetically, or something similar, and Undefined does not end up being assigned the value 0 as default. All other enum values marked with '[StringValue(...)]' don't depend on the order within the enum or the assigned numeric value, but Undefined does. Anyway, it works the way you implemented it, and the rest is Geschmackssache. :-)