Skip to content

ChargeAmount not written for EN16931 Comfort #864

@PeterSawatzki-MGGM

Description

@PeterSawatzki-MGGM

The following code does not write ChargeAmount if it is present obviously following PEPPOL rule PEPPOL-EN16931-R046.

#region GrossPriceProductTradePrice (Comfort, Extended, XRechnung)
bool needToWriteGrossUnitPrice = false;
bool hasGrossUnitPrice = tradeLineItem.GrossUnitPrice.HasValue;
bool hasAllowanceCharges = tradeLineItem.GetTradeAllowanceCharges().Count > 0;
if ((descriptor.Profile == Profile.XRechnung) || (descriptor.Profile == Profile.XRechnung1) || (descriptor.Profile == Profile.Comfort))
{
// PEPPOL-EN16931-R046: For XRechnung, both must be present
needToWriteGrossUnitPrice = hasGrossUnitPrice && hasAllowanceCharges;
}
else
{
// For other profiles, either is sufficient
needToWriteGrossUnitPrice = hasGrossUnitPrice || hasAllowanceCharges;
}
if (needToWriteGrossUnitPrice)
{
_Writer.WriteStartElement("ram", "GrossPriceProductTradePrice", PROFILE_COMFORT_EXTENDED_XRECHNUNG);
_writeOptionalAdaptiveAmount(_Writer, "ram", "ChargeAmount", tradeLineItem.GrossUnitPrice, 2, 4); // BT-148
if (tradeLineItem.GrossQuantity.HasValue)
{
_writeElementWithAttributeWithPrefix(_Writer, "ram", "BasisQuantity", "unitCode", tradeLineItem.UnitCode.EnumToString(), _formatDecimal(tradeLineItem.GrossQuantity.Value, 4));
}
foreach (AbstractTradeAllowanceCharge tradeAllowanceCharge in tradeLineItem.GetTradeAllowanceCharges()) // BT-147
{
_WriteItemLevelAppliedTradeAllowanceCharge(_Writer, tradeAllowanceCharge);
}
_Writer.WriteEndElement(); // ram:GrossPriceProductTradePrice(Comfort|Extended|XRechnung)
}
#endregion // !GrossPriceProductTradePrice(Comfort|Extended|XRechnung)

But is this really o.k. not to write ChargeAmount ? For example the official sample

https://github.com/stephanstapel/ZUGFeRD-csharp/blob/5c8bed75474550052b1cb0851c340c8044ebddde/documentation/zugferd240en/Examples/3.%20EN16931/EN16931_Einfach/EN16931_Einfach.xml#L117C2-L147

has a ChargeAmount but no TradeAllowanceCharges. If I read this document and write it ChargeAmount is missing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions