@@ -591,7 +591,7 @@ procedure TZUGFeRDInvoiceDescriptor23CIIWriter.Save(
591
591
// #endregion
592
592
593
593
// #region ChargePercentage
594
- if (specifiedTradeAllowanceCharge.ChargePercentage <> 0.0 ) then
594
+ if (specifiedTradeAllowanceCharge.ChargePercentage.HasValue ) then
595
595
begin
596
596
Writer.WriteStartElement(' ram:CalculationPercent' );
597
597
Writer.WriteValue(_formatDecimal(specifiedTradeAllowanceCharge.ChargePercentage, 2 ));
@@ -600,7 +600,7 @@ procedure TZUGFeRDInvoiceDescriptor23CIIWriter.Save(
600
600
// #endregion
601
601
602
602
// #region BasisAmount
603
- if (specifiedTradeAllowanceCharge.BasisAmount <> 0.0 ) then
603
+ if (specifiedTradeAllowanceCharge.BasisAmount.HasValue ) then
604
604
begin
605
605
// according to CII-SR-123 not in XRechnung for *Applied*TradeAllowanceCharge but valid for *Specified*TradeAllowanceCharge!
606
606
Writer.WriteStartElement(' ram:BasisAmount' , ALL_PROFILES-[TZUGFeRDProfile.Basic]); // BT-137, BT-142
@@ -725,8 +725,10 @@ procedure TZUGFeRDInvoiceDescriptor23CIIWriter.Save(
725
725
_writeOptionalParty(Writer, TZUGFeRDPartyTypes.BuyerTradeParty, Descriptor.Buyer, Descriptor.BuyerContact, Descriptor.BuyerElectronicAddress, Descriptor.BuyerTaxRegistration);
726
726
// #endregion
727
727
728
- // TODO: implement SellerTaxRepresentativeTradeParty
728
+ // region SellerTaxRepresentativeTradeParty
729
729
// BT-63: the tax registration of the SellerTaxRepresentativeTradeParty
730
+ _writeOptionalParty(Writer, TZUGFeRDPartyTypes.SellerTaxRepresentativeTradeParty, Descriptor.SellerTaxRepresentative, Nil , Nil , Descriptor.SellerTaxRepresentativeTaxRegistration);
731
+ // #endregion
730
732
731
733
// #region SellerOrderReferencedDocument (BT-14: Comfort, Extended)
732
734
if (Descriptor.SellerOrderReferencedDocument <> nil ) then
@@ -1048,14 +1050,14 @@ procedure TZUGFeRDInvoiceDescriptor23CIIWriter.Save(
1048
1050
Writer.WriteElementString(' udt:Indicator' , ifthen(tradeAllowanceCharge.ChargeIndicator,' true' ,' false' ));
1049
1051
Writer.WriteEndElement(); // !ram:ChargeIndicator
1050
1052
1051
- if (tradeAllowanceCharge.ChargePercentage <> 0.0 ) then
1053
+ if (tradeAllowanceCharge.ChargePercentage.HasValue ) then
1052
1054
begin
1053
1055
Writer.WriteStartElement(' ram:CalculationPercent' );
1054
1056
Writer.WriteValue(_formatDecimal(tradeAllowanceCharge.ChargePercentage, 2 ));
1055
1057
Writer.WriteEndElement();
1056
1058
end ;
1057
1059
1058
- if (tradeAllowanceCharge.BasisAmount <> 0.0 ) then
1060
+ if (tradeAllowanceCharge.BasisAmount.HasValue ) then
1059
1061
begin
1060
1062
Writer.WriteStartElement(' ram:BasisAmount' ); // BT-100
1061
1063
Writer.WriteValue(_formatDecimal(tradeAllowanceCharge.BasisAmount));
@@ -1131,7 +1133,7 @@ procedure TZUGFeRDInvoiceDescriptor23CIIWriter.Save(
1131
1133
PaymentNote:= System.StrUtils.ReplaceText(Trim(PaymentTerms.Description),' #' ,' ' ); // make sure no # is present
1132
1134
if PaymentNote<>' ' then
1133
1135
PaymentNote:= PaymentNote+#13 #10 ;
1134
- if PaymentTerms.PaymentTermsType.HasValue then
1136
+ if PaymentTerms.PaymentTermsType.HasValue and PaymentTerms.DueDays.HasValue and PaymentTerms.Percentage.HasValue then
1135
1137
begin
1136
1138
var formatSettings: TFormatSettings;
1137
1139
formatSettings.DecimalSeparator := ' .' ;
@@ -1516,6 +1518,8 @@ procedure TZUGFeRDInvoiceDescriptor23CIIWriter._writeOptionalParty(
1516
1518
writer.WriteStartElement(' ram:InvoiceeTradeParty' , [Descriptor.Profile]);
1517
1519
TZUGFeRDPartyTypes.PayeeTradeParty:
1518
1520
writer.WriteStartElement(' ram:PayeeTradeParty' , [Descriptor.Profile]);
1521
+ TZUGFeRDPartyTypes.PayerTradeParty:
1522
+ writer.WriteStartElement(' ram:PayerTradeParty' , [Descriptor.Profile]);
1519
1523
TZUGFeRDPartyTypes.SalesAgentTradeParty:
1520
1524
writer.WriteStartElement(' ram:SalesAgentTradeParty' , [Descriptor.Profile]);
1521
1525
TZUGFeRDPartyTypes.BuyerTaxRepresentativeTradeParty:
@@ -1526,8 +1530,8 @@ procedure TZUGFeRDInvoiceDescriptor23CIIWriter._writeOptionalParty(
1526
1530
writer.WriteStartElement(' ram:BuyerAgentTradeParty' , [Descriptor.Profile]);
1527
1531
TZUGFeRDPartyTypes.InvoicerTradeParty:
1528
1532
writer.WriteStartElement(' ram:InvoicerTradeParty' , [Descriptor.Profile]);
1529
- TZUGFeRDPartyTypes.PayerTradeParty :
1530
- writer.WriteStartElement(' ram:PayerTradeParty ' , [Descriptor.Profile]);
1533
+ TZUGFeRDPartyTypes.SellerTaxRepresentativeTradeParty :
1534
+ writer.WriteStartElement(' ram:SellerTaxRepresentativeTradeParty ' , [Descriptor.Profile]);
1531
1535
else
1532
1536
exit;
1533
1537
end ;
@@ -1563,19 +1567,22 @@ procedure TZUGFeRDInvoiceDescriptor23CIIWriter._writeOptionalParty(
1563
1567
_writeOptionalLegalOrganization(writer, ' ram:SpecifiedLegalOrganization' , party.SpecifiedLegalOrganization, partyType);
1564
1568
_writeOptionalContact(writer, ' ram:DefinedTradeContact' , contact, [TZUGFeRDProfile.Comfort,TZUGFeRDProfile.Extended,TZUGFeRDProfile.XRechnung1,TZUGFeRDProfile.XRechnung]);
1565
1569
1566
- writer.WriteStartElement(' ram:PostalTradeAddress' );
1567
- writer.WriteOptionalElementString(' ram:PostcodeCode' , party.Postcode); // buyer: BT-53
1568
- writer.WriteOptionalElementString(' ram:LineOne' , ifthen(party.ContactName=' ' ,party.Street,party.ContactName)); // buyer: BT-50
1569
- if (party.ContactName<>' ' )then
1570
+ // spec 2.3 says: Minimum/BuyerTradeParty does not include PostalTradeAddress
1571
+ if (Descriptor.Profile = TZUGFeRDProfile.Extended) or (partyType In [TZUGFeRDPartyTypes.BuyerTradeParty, TZUGFeRDPartyTypes.SellerTradeParty, TZUGFeRDPartyTypes.SellerTaxRepresentativeTradeParty, TZUGFeRDPartyTypes.BuyerTaxRepresentativeTradeParty, TZUGFeRDPartyTypes.ShipToTradeParty, TZUGFeRDPartyTypes.ShipToTradeParty, TZUGFeRDPartyTypes.UltimateShipToTradeParty, TZUGFeRDPartyTypes.SalesAgentTradeParty]) then
1570
1572
begin
1573
+ writer.WriteStartElement(' ram:PostalTradeAddress' );
1574
+ writer.WriteOptionalElementString(' ram:PostcodeCode' , party.Postcode); // buyer: BT-53
1575
+ writer.WriteOptionalElementString(' ram:LineOne' , ifthen(party.ContactName=' ' ,party.Street,party.ContactName)); // buyer: BT-50
1576
+ if (party.ContactName<>' ' ) then
1571
1577
writer.WriteOptionalElementString(' ram:LineTwo' , party.Street); // buyer: BT-51
1572
- end ;
1573
1578
1574
- writer.WriteOptionalElementString(' ram:LineThree' , party.AddressLine3); // buyer: BT-163
1575
- writer.WriteOptionalElementString(' ram:CityName' , party.City); // buyer: BT-52
1576
- writer.WriteElementString(' ram:CountryID' , TZUGFeRDCountryCodesExtensions.EnumToString(party.Country)); // buyer: BT-55
1577
- writer.WriteOptionalElementString(' ram:CountrySubDivisionName' , party.CountrySubdivisionName); // BT-79
1578
- writer.WriteEndElement(); // !PostalTradeAddress
1579
+ writer.WriteOptionalElementString(' ram:LineThree' , party.AddressLine3); // buyer: BT-163
1580
+ writer.WriteOptionalElementString(' ram:CityName' , party.City); // buyer: BT-52
1581
+ if party.Country<>TZUGFeRDCountryCodes.Unknown then
1582
+ writer.WriteElementString(' ram:CountryID' , TZUGFeRDCountryCodesExtensions.EnumToString(party.Country)); // buyer: BT-55
1583
+ writer.WriteOptionalElementString(' ram:CountrySubDivisionName' , party.CountrySubdivisionName); // BT-79
1584
+ writer.WriteEndElement(); // !PostalTradeAddress
1585
+ end ;
1579
1586
1580
1587
if (electronicAddress <> nil ) then
1581
1588
begin
0 commit comments