Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ codeunit 13916 "Export XRechnung Document"
PriceElement: XmlElement;
begin
PriceElement := XmlElement.Create('Price', XmlNamespaceCAC);
PriceElement.Add(XmlElement.Create('PriceAmount', XmlNamespaceCBC, XmlAttribute.Create('currencyID', CurrencyCode), FormatFourDecimal(UnitPrice)));
PriceElement.Add(XmlElement.Create('PriceAmount', XmlNamespaceCBC, XmlAttribute.Create('currencyID', CurrencyCode), FormatDecimalUnlimited(UnitPrice)));
RootElement.Add(PriceElement);
end;

Expand Down Expand Up @@ -836,7 +836,7 @@ codeunit 13916 "Export XRechnung Document"
begin
TaxCategoryElement := XmlElement.Create(TaxCategory, XmlNamespaceCAC);
TaxCategoryElement.Add(XmlElement.Create('ID', XmlNamespaceCBC, TaxCategoryID));
TaxCategoryElement.Add(XmlElement.Create('Percent', XmlNamespaceCBC, FormatDecimal(Percent)));
TaxCategoryElement.Add(XmlElement.Create('Percent', XmlNamespaceCBC, FormatFiveDecimal(Percent)));
if Percent = 0 then
TaxCategoryElement.Add(XmlElement.Create('TaxExemptionReasonCode', XmlNamespaceCBC, 'VATEX-EU-O'));
InsertTaxScheme(TaxCategoryElement);
Expand Down Expand Up @@ -1022,7 +1022,7 @@ codeunit 13916 "Export XRechnung Document"
if PricesIncVAT then
ExcludeVAT(SalesInvLine, Currency."Amount Rounding Precision");
InvoiceLineElement.Add(XmlElement.Create('ID', XmlNamespaceCBC, Format(SalesInvLine."Line No.")));
InvoiceLineElement.Add(XmlElement.Create('InvoicedQuantity', XmlNamespaceCBC, XmlAttribute.Create('unitCode', GetUoMCode(SalesInvLine."Unit of Measure Code")), FormatDecimal(SalesInvLine.Quantity)));
InvoiceLineElement.Add(XmlElement.Create('InvoicedQuantity', XmlNamespaceCBC, XmlAttribute.Create('unitCode', GetUoMCode(SalesInvLine."Unit of Measure Code")), FormatDecimalUnlimited(SalesInvLine.Quantity)));
InvoiceLineElement.Add(XmlElement.Create('LineExtensionAmount', XmlNamespaceCBC, XmlAttribute.Create('currencyID', CurrencyCode), FormatDecimal(SalesInvLine.Amount + SalesInvLine."Inv. Discount Amount")));
if SalesInvLine."Shipment Date" <> 0D then
InsertInvoicePeriod(InvoiceLineElement, SalesInvLine."Shipment Date", SalesInvLine."Shipment Date");
Expand Down Expand Up @@ -1061,7 +1061,7 @@ codeunit 13916 "Export XRechnung Document"
if PricesIncVAT then
ExcludeVAT(SalesCrMemoLine, Currency."Amount Rounding Precision");
CrMemoLineElement.Add(XmlElement.Create('ID', XmlNamespaceCBC, Format(SalesCrMemoLine."Line No.")));
CrMemoLineElement.Add(XmlElement.Create('CreditedQuantity', XmlNamespaceCBC, XmlAttribute.Create('unitCode', GetUoMCode(SalesCrMemoLine."Unit of Measure Code")), FormatDecimal(SalesCrMemoLine.Quantity)));
CrMemoLineElement.Add(XmlElement.Create('CreditedQuantity', XmlNamespaceCBC, XmlAttribute.Create('unitCode', GetUoMCode(SalesCrMemoLine."Unit of Measure Code")), FormatDecimalUnlimited(SalesCrMemoLine.Quantity)));
CrMemoLineElement.Add(XmlElement.Create('LineExtensionAmount', XmlNamespaceCBC, XmlAttribute.Create('currencyID', CurrencyCode), FormatDecimal(SalesCrMemoLine.Amount + SalesCrMemoLine."Inv. Discount Amount")));
InsertOrderLineReference(CrMemoLineElement, SalesCrMemoLine."Line No.");
if SalesCrMemoLine."Shipment Date" <> 0D then
Expand Down Expand Up @@ -1324,10 +1324,18 @@ codeunit 13916 "Export XRechnung Document"
exit(Format(Round(VarDecimal, 0.01), 0, 9));
end;

procedure FormatDecimalUnlimited(VarDecimal: Decimal): Text
begin
exit(Format(VarDecimal, 0, 9));
end;

#if not CLEAN29
[Obsolete('FormatFourDecimal is no longer used internally. Quantity and unit price fields are now exported with unlimited precision per EN 16931. For VAT percentages, use FormatFiveDecimal. For quantity and unit price, use FormatDecimalUnlimited.', '29.0')]
procedure FormatFourDecimal(VarDecimal: Decimal): Text[30];
begin
exit(Format(Round(VarDecimal, 0.0001), 0, 9));
end;
#endif

procedure FormatFiveDecimal(VarDecimal: Decimal): Text[30];
begin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ codeunit 13917 "Export ZUGFeRD Document"
repeat
if LineVATAmount.ContainsKey(SalesInvLine."VAT %") and LineAmount.ContainsKey(SalesInvLine."VAT %") then begin
InsertTaxElement(SettlementElement, FormatDecimal(LineVATAmount.Get(SalesInvLine."VAT %")), FormatDecimal(LineAmount.Get(SalesInvLine."VAT %")),
GetTaxCategoryID(SalesInvLine."Tax Category", SalesInvLine."VAT Bus. Posting Group", SalesInvLine."VAT Prod. Posting Group"), FormatFourDecimal(SalesInvLine."VAT %"),
GetTaxCategoryID(SalesInvLine."Tax Category", SalesInvLine."VAT Bus. Posting Group", SalesInvLine."VAT Prod. Posting Group"), FormatFiveDecimal(SalesInvLine."VAT %"),
SalesInvLine."VAT %" = 0);
LineAmount.Remove(SalesInvLine."VAT %");
LineVATAmount.Remove(SalesInvLine."VAT %");
Expand All @@ -799,7 +799,7 @@ codeunit 13917 "Export ZUGFeRD Document"
repeat
if LineVATAmount.ContainsKey(SalesCrMemoLine."VAT %") and LineAmount.ContainsKey(SalesCrMemoLine."VAT %") then begin
InsertTaxElement(SettlementElement, FormatDecimal(LineVATAmount.Get(SalesCrMemoLine."VAT %")), FormatDecimal(LineAmount.Get(SalesCrMemoLine."VAT %")),
GetTaxCategoryID(SalesCrMemoLine."Tax Category", SalesCrMemoLine."VAT Bus. Posting Group", SalesCrMemoLine."VAT Prod. Posting Group"), FormatFourDecimal(SalesCrMemoLine."VAT %"),
GetTaxCategoryID(SalesCrMemoLine."Tax Category", SalesCrMemoLine."VAT Bus. Posting Group", SalesCrMemoLine."VAT Prod. Posting Group"), FormatFiveDecimal(SalesCrMemoLine."VAT %"),
SalesCrMemoLine."VAT %" = 0);

LineAmount.Remove(SalesCrMemoLine."VAT %");
Expand Down Expand Up @@ -901,13 +901,13 @@ codeunit 13917 "Export ZUGFeRD Document"

SpecifiedLineTradeAgreementElement := XmlElement.Create('SpecifiedLineTradeAgreement', XmlNamespaceRAM);
NetPriceProductTradePriceElement := XmlElement.Create('NetPriceProductTradePrice', XmlNamespaceRAM);
ChargeAmountElement := XmlElement.Create('ChargeAmount', XmlNamespaceRAM, FormatFourDecimal(SalesInvoiceLine."Unit Price"));
ChargeAmountElement := XmlElement.Create('ChargeAmount', XmlNamespaceRAM, FormatDecimalUnlimited(SalesInvoiceLine."Unit Price"));
NetPriceProductTradePriceElement.Add(ChargeAmountElement);
SpecifiedLineTradeAgreementElement.Add(NetPriceProductTradePriceElement);
InvoiceLineElement.Add(SpecifiedLineTradeAgreementElement);

SpecifiedLineTradeDeliveryElement := XmlElement.Create('SpecifiedLineTradeDelivery', XmlNamespaceRAM);
BilledQuantityElement := XmlElement.Create('BilledQuantity', XmlNamespaceRAM, FormatFourDecimal(SalesInvoiceLine.Quantity));
BilledQuantityElement := XmlElement.Create('BilledQuantity', XmlNamespaceRAM, FormatDecimalUnlimited(SalesInvoiceLine.Quantity));
BilledQuantityElement.SetAttribute('unitCode', GetUoMCode(SalesInvoiceLine."Unit of Measure Code"));
SpecifiedLineTradeDeliveryElement.Add(BilledQuantityElement);
InvoiceLineElement.Add(SpecifiedLineTradeDeliveryElement);
Expand All @@ -918,7 +918,7 @@ codeunit 13917 "Export ZUGFeRD Document"
ApplicableTradeTaxElement := XmlElement.Create('ApplicableTradeTax', XmlNamespaceRAM);
ApplicableTradeTaxElement.Add(XmlElement.Create('TypeCode', XmlNamespaceRAM, 'VAT'));
ApplicableTradeTaxElement.Add(XmlElement.Create('CategoryCode', XmlNamespaceRAM, GetTaxCategoryID(SalesInvoiceLine."Tax Category", SalesInvoiceLine."VAT Bus. Posting Group", SalesInvoiceLine."VAT Prod. Posting Group")));
ApplicableTradeTaxElement.Add(XmlElement.Create('RateApplicablePercent', XmlNamespaceRAM, FormatFourDecimal(SalesInvoiceLine."VAT %")));
ApplicableTradeTaxElement.Add(XmlElement.Create('RateApplicablePercent', XmlNamespaceRAM, FormatFiveDecimal(SalesInvoiceLine."VAT %")));
SpecifiedLineTradeSettlementElement.Add(ApplicableTradeTaxElement);

if SalesInvoiceLine."Shipment Date" <> 0D then
Expand Down Expand Up @@ -986,13 +986,13 @@ codeunit 13917 "Export ZUGFeRD Document"

SpecifiedLineTradeAgreementElement := XmlElement.Create('SpecifiedLineTradeAgreement', XmlNamespaceRAM);
NetPriceProductTradePriceElement := XmlElement.Create('NetPriceProductTradePrice', XmlNamespaceRAM);
ChargeAmountElement := XmlElement.Create('ChargeAmount', XmlNamespaceRAM, FormatFourDecimal(SalesCrMemoLine."Unit Price"));
ChargeAmountElement := XmlElement.Create('ChargeAmount', XmlNamespaceRAM, FormatDecimalUnlimited(SalesCrMemoLine."Unit Price"));
NetPriceProductTradePriceElement.Add(ChargeAmountElement);
SpecifiedLineTradeAgreementElement.Add(NetPriceProductTradePriceElement);
CrMemoLineElement.Add(SpecifiedLineTradeAgreementElement);

SpecifiedLineTradeDeliveryElement := XmlElement.Create('SpecifiedLineTradeDelivery', XmlNamespaceRAM);
BilledQuantityElement := XmlElement.Create('BilledQuantity', XmlNamespaceRAM, FormatFourDecimal(SalesCrMemoLine.Quantity));
BilledQuantityElement := XmlElement.Create('BilledQuantity', XmlNamespaceRAM, FormatDecimalUnlimited(SalesCrMemoLine.Quantity));
BilledQuantityElement.SetAttribute('unitCode', GetUoMCode(SalesCrMemoLine."Unit of Measure Code"));
SpecifiedLineTradeDeliveryElement.Add(BilledQuantityElement);
CrMemoLineElement.Add(SpecifiedLineTradeDeliveryElement);
Expand All @@ -1003,7 +1003,7 @@ codeunit 13917 "Export ZUGFeRD Document"
ApplicableTradeTaxElement := XmlElement.Create('ApplicableTradeTax', XmlNamespaceRAM);
ApplicableTradeTaxElement.Add(XmlElement.Create('TypeCode', XmlNamespaceRAM, 'VAT'));
ApplicableTradeTaxElement.Add(XmlElement.Create('CategoryCode', XmlNamespaceRAM, GetTaxCategoryID(SalesCrMemoLine."Tax Category", SalesCrMemoLine."VAT Bus. Posting Group", SalesCrMemoLine."VAT Prod. Posting Group")));
ApplicableTradeTaxElement.Add(XmlElement.Create('RateApplicablePercent', XmlNamespaceRAM, FormatFourDecimal(SalesCrMemoLine."VAT %")));
ApplicableTradeTaxElement.Add(XmlElement.Create('RateApplicablePercent', XmlNamespaceRAM, FormatFiveDecimal(SalesCrMemoLine."VAT %")));
SpecifiedLineTradeSettlementElement.Add(ApplicableTradeTaxElement);

if SalesCrMemoLine."Shipment Date" <> 0D then
Expand Down Expand Up @@ -1111,7 +1111,7 @@ codeunit 13917 "Export ZUGFeRD Document"
AllowanceChargeElement.Add(XmlElement.Create('ActualAmount', XmlNamespaceRAM, FormatDecimal(Amount)));
AllowanceChargeElement.Add(XmlElement.Create('Reason', XmlNamespaceRAM, AllowanceChargeReason));
if InsertCategoryTax then
InsertCategoryTradeTax(AllowanceChargeElement, TaxCategory, FormatFourDecimal(Percent));
InsertCategoryTradeTax(AllowanceChargeElement, TaxCategory, FormatFiveDecimal(Percent));
RootXMLNode.Add(AllowanceChargeElement);
end;

Expand Down Expand Up @@ -1304,9 +1304,22 @@ codeunit 13917 "Export ZUGFeRD Document"
exit(Format(VarDecimal, 0, TypeHelper.GetXMLAmountFormatWithTwoDecimalPlaces()))
end;

procedure FormatDecimalUnlimited(VarDecimal: Decimal): Text
begin
exit(Format(VarDecimal, 0, 9));
end;

#if not CLEAN29
[Obsolete('FormatFourDecimal is no longer used internally. Quantity and unit price fields are now exported with unlimited precision per EN 16931. For VAT percentages, use FormatFiveDecimal. For quantity and unit price, use FormatDecimalUnlimited.', '29.0')]
procedure FormatFourDecimal(VarDecimal: Decimal): Text
begin
exit(Format(VarDecimal, 0, '<Precision,4:4><Standard Format,9>'))
exit(Format(VarDecimal, 0, '<Precision,4:4><Standard Format,9>'));
end;
#endif

procedure FormatFiveDecimal(VarDecimal: Decimal): Text
begin
exit(Format(Round(VarDecimal, 0.00001), 0, 9));
end;

procedure GetUoMCode(UoMCode: Code[10]): Text;
Expand Down
Loading
Loading