Skip to content

Commit ec6c9b4

Browse files
committed
fixed handling UnitQuantities (BasisQuantity)
1 parent f3db571 commit ec6c9b4

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

ZUGFeRD-Test/ZUGFeRD21Tests.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1760,9 +1760,9 @@ public void TestBasisQuantityMultiple()
17601760
billedQuantity: 50,
17611761
taxType: TaxTypes.VAT,
17621762
categoryCode: TaxCategoryCodes.S,
1763-
taxPercent: 7
1763+
taxPercent: 7,
1764+
unitQuantity: 10
17641765
);
1765-
tli.UnitQuantity = 10;
17661766
MemoryStream ms = new MemoryStream();
17671767

17681768
desc.Save(ms, ZUGFeRDVersion.Version21, Profile.XRechnung);

ZUGFeRD/InvoiceDescriptor1Writer.cs

+4
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,10 @@ public override void Save(InvoiceDescriptor descriptor, Stream stream)
574574
else if (tradeLineItem.NetUnitPrice.HasValue)
575575
{
576576
_total = tradeLineItem.NetUnitPrice.Value * tradeLineItem.BilledQuantity;
577+
if (tradeLineItem.UnitQuantity.HasValue && (tradeLineItem.UnitQuantity.Value != 0))
578+
{
579+
_total /= tradeLineItem.UnitQuantity.Value;
580+
}
577581
}
578582

579583
_writeElementWithAttribute(Writer, "ram:LineTotalAmount", "currencyID", this.Descriptor.Currency.EnumToString(), _formatDecimal(_total));

ZUGFeRD/InvoiceDescriptor20Writer.cs

+4
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,10 @@ public override void Save(InvoiceDescriptor descriptor, Stream stream)
351351
else if (tradeLineItem.NetUnitPrice.HasValue)
352352
{
353353
_total = tradeLineItem.NetUnitPrice.Value * tradeLineItem.BilledQuantity;
354+
if (tradeLineItem.UnitQuantity.HasValue && (tradeLineItem.UnitQuantity.Value != 0))
355+
{
356+
_total /= tradeLineItem.UnitQuantity.Value;
357+
}
354358
}
355359

356360
Writer.WriteElementString("ram:LineTotalAmount", _formatDecimal(_total));

ZUGFeRD/InvoiceDescriptor21Writer.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,11 @@ public override void Save(InvoiceDescriptor descriptor, Stream stream)
410410
}
411411
else if (tradeLineItem.NetUnitPrice.HasValue)
412412
{
413-
_total = tradeLineItem.NetUnitPrice.Value * tradeLineItem.BilledQuantity;
413+
_total = tradeLineItem.NetUnitPrice.Value * tradeLineItem.BilledQuantity;
414+
if (tradeLineItem.UnitQuantity.HasValue && (tradeLineItem.UnitQuantity.Value != 0))
415+
{
416+
_total /= tradeLineItem.UnitQuantity.Value;
417+
}
414418
}
415419

416420
Writer.WriteStartElement("ram:LineTotalAmount", Profile.Basic | Profile.Comfort | Profile.Extended | Profile.XRechnung1 | Profile.XRechnung);

0 commit comments

Comments
 (0)