Skip to content

Commit ef5bd84

Browse files
minor fixes and add SellerTaxRepresentative to Descriptor20Reader/Writer
1 parent e2389af commit ef5bd84

5 files changed

+51
-5
lines changed

intf.ZUGFeRDInvoiceDescriptor1Writer.pas

+15-1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,20 @@ TZUGFeRDInvoiceDescriptor1Writer = class(TZUGFeRDInvoiceDescriptorWriter)
7272
procedure _writeElementWithAttribute(_writer: TZUGFeRDProfileAwareXmlTextWriter; tagName, attributeName,attributeValue, nodeValue: String);
7373
function _translateInvoiceType(type_ : TZUGFeRDInvoiceType) : String;
7474
function _encodeInvoiceType(type_ : TZUGFeRDInvoiceType) : Integer;
75+
private const
76+
ALL_PROFILES = [TZUGFeRDProfile.Minimum,
77+
TZUGFeRDProfile.BasicWL,
78+
TZUGFeRDProfile.Basic,
79+
TZUGFeRDProfile.Comfort,
80+
TZUGFeRDProfile.Extended,
81+
TZUGFeRDProfile.XRechnung1,
82+
TZUGFeRDProfile.XRechnung,
83+
TZUGFeRDProfile.EReporting];
84+
PROFILE_COMFORT_EXTENDED_XRECHNUNG =
85+
[TZUGFeRDProfile.Comfort,
86+
TZUGFeRDProfile.Extended,
87+
TZUGFeRDProfile.XRechnung1,
88+
TZUGFeRDProfile.XRechnung];
7589
public
7690
function Validate(_descriptor: TZUGFeRDInvoiceDescriptor; _throwExceptions: Boolean = True): Boolean; override;
7791
/// <summary>
@@ -866,7 +880,7 @@ procedure TZUGFeRDInvoiceDescriptor1Writer._writeOptionalParty(
866880
end;
867881

868882
_Writer.WriteOptionalElementString('ram:Name', Party.Name);
869-
_Writer.WriteOptionalElementString('ram:Description', Party.Description, [TZUGFeRDProfile.Comfort,TZUGFeRDProfile.Extended,TZUGFeRDProfile.XRechnung1, TZUGFeRDProfile.XRechnung]);
883+
_Writer.WriteOptionalElementString('ram:Description', Party.Description, PROFILE_COMFORT_EXTENDED_XRECHNUNG);
870884
_writeOptionalContact(_writer, 'ram:DefinedTradeContact', Contact);
871885
_writer.WriteStartElement('ram:PostalTradeAddress');
872886
_writer.WriteOptionalElementString('ram:PostcodeCode', Party.Postcode);

intf.ZUGFeRDInvoiceDescriptor20Reader.pas

+10
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,16 @@ function TZUGFeRDInvoiceDescriptor20Reader.Load(xmldocument : IXMLDocument): TZU
206206
);
207207
end;
208208

209+
// SellerTaxRepresentativeTradeParty STEUERBEVOLLMÄCHTIGTER DES VERKÄUFERS, BG-11
210+
Result.SellerTaxRepresentative := _nodeAsParty(doc.DocumentElement, '//ram:ApplicableHeaderTradeAgreement/ram:SellerTaxRepresentativeTradeParty');
211+
nodes := doc.selectNodes('//ram:ApplicableHeaderTradeAgreement/ram:SellerTaxRepresentativeTradeParty/ram:SpecifiedTaxRegistration');
212+
for i := 0 to nodes.length-1 do
213+
begin
214+
var id : String := TZUGFeRDXmlUtils.NodeAsString(nodes[i], './/ram:ID');
215+
var schemeID : String := TZUGFeRDXmlUtils.NodeAsString(nodes[i], './/ram:ID/@schemeID');
216+
Result.AddSellerTaxRepresentativeTaxRegistration(id, TZUGFeRDTaxRegistrationSchemeIDExtensions.FromString(schemeID));
217+
end;
218+
209219
//Get all referenced and embedded documents (BG-24)
210220
nodes := doc.SelectNodes('.//ram:ApplicableHeaderTradeAgreement/ram:AdditionalReferencedDocument');
211221
for i := 0 to nodes.length-1 do

intf.ZUGFeRDInvoiceDescriptor20Writer.pas

+23-2
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,20 @@ TZUGFeRDInvoiceDescriptor20Writer = class(TZUGFeRDInvoiceDescriptorWriter)
7575
procedure _writeElementWithAttribute(_writer: TZUGFeRDProfileAwareXmlTextWriter; tagName, attributeName,attributeValue, nodeValue: String);
7676
function _translateInvoiceType(type_ : TZUGFeRDInvoiceType) : String;
7777
function _encodeInvoiceType(type_ : TZUGFeRDInvoiceType) : Integer;
78+
private const
79+
ALL_PROFILES = [TZUGFeRDProfile.Minimum,
80+
TZUGFeRDProfile.BasicWL,
81+
TZUGFeRDProfile.Basic,
82+
TZUGFeRDProfile.Comfort,
83+
TZUGFeRDProfile.Extended,
84+
TZUGFeRDProfile.XRechnung1,
85+
TZUGFeRDProfile.XRechnung,
86+
TZUGFeRDProfile.EReporting];
87+
PROFILE_COMFORT_EXTENDED_XRECHNUNG =
88+
[TZUGFeRDProfile.Comfort,
89+
TZUGFeRDProfile.Extended,
90+
TZUGFeRDProfile.XRechnung1,
91+
TZUGFeRDProfile.XRechnung];
7892
public
7993
function Validate(_descriptor: TZUGFeRDInvoiceDescriptor; _throwExceptions: Boolean = True): Boolean; override;
8094
/// <summary>
@@ -469,6 +483,11 @@ procedure TZUGFeRDInvoiceDescriptor20Writer.Save(
469483
_writeOptionalParty(Writer, 'ram:SellerTradeParty', Descriptor.Seller, Descriptor.SellerContact, Descriptor.SellerTaxRegistration);
470484
_writeOptionalParty(Writer, 'ram:BuyerTradeParty', Descriptor.Buyer, Descriptor.BuyerContact, Descriptor.BuyerTaxRegistration);
471485

486+
//#region SellerTaxRepresentativeTradeParty
487+
// BT-63: the tax registration of the SellerTaxRepresentativeTradeParty
488+
_writeOptionalParty(Writer, 'ram:SellerTaxRepresentativeTradeParty', Descriptor.SellerTaxRepresentative, Nil, Descriptor.SellerTaxRepresentativeTaxRegistration);
489+
//#endregion
490+
472491
//#region SellerOrderReferencedDocument (BT-14: Comfort, Extended)
473492
if (Descriptor.SellerOrderReferencedDocument <> nil) then
474493
if (Descriptor.SellerOrderReferencedDocument.ID <> '') then
@@ -1058,7 +1077,9 @@ procedure TZUGFeRDInvoiceDescriptor20Writer._writeNotes(
10581077

10591078
procedure TZUGFeRDInvoiceDescriptor20Writer._writeOptionalParty(
10601079
_writer: TZUGFeRDProfileAwareXmlTextWriter;
1061-
PartyTag : String; Party : TZUGFeRDParty; Contact : TZUGFeRDContact = nil;
1080+
PartyTag : String;
1081+
Party : TZUGFeRDParty;
1082+
Contact : TZUGFeRDContact = nil;
10621083
TaxRegistrations : TObjectList<TZUGFeRDTaxRegistration> = nil);
10631084
begin
10641085
if Party = nil then
@@ -1091,7 +1112,7 @@ procedure TZUGFeRDInvoiceDescriptor20Writer._writeOptionalParty(
10911112
end;
10921113

10931114
_Writer.WriteOptionalElementString('ram:Name', Party.Name);
1094-
_Writer.WriteOptionalElementString('ram:Description', Party.Description, [TZUGFeRDProfile.Comfort,TZUGFeRDProfile.Extended,TZUGFeRDProfile.XRechnung1, TZUGFeRDProfile.XRechnung]);
1115+
_Writer.WriteOptionalElementString('ram:Description', Party.Description, PROFILE_COMFORT_EXTENDED_XRECHNUNG);
10951116
_writeOptionalContact(_writer, 'ram:DefinedTradeContact', Contact);
10961117
_writer.WriteStartElement('ram:PostalTradeAddress');
10971118
_writer.WriteOptionalElementString('ram:PostcodeCode', Party.Postcode);

intf.ZUGFeRDInvoiceDescriptor23CIIReader.pas

+1
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@ function TZUGFeRDInvoiceDescriptor23CIIReader.Load(xmldocument : IXMLDocument):
323323
);
324324
end;
325325

326+
// SellerTaxRepresentativeTradeParty STEUERBEVOLLMÄCHTIGTER DES VERKÄUFERS, BG-11
326327
Result.SellerTaxRepresentative := _nodeAsParty(doc.DocumentElement, '//ram:ApplicableHeaderTradeAgreement/ram:SellerTaxRepresentativeTradeParty');
327328
nodes := doc.selectNodes('//ram:ApplicableHeaderTradeAgreement/ram:SellerTaxRepresentativeTradeParty/ram:SpecifiedTaxRegistration');
328329
for i := 0 to nodes.length-1 do

intf.ZUGFeRDInvoiceDescriptor23CIIWriter.pas

+2-2
Original file line numberDiff line numberDiff line change
@@ -720,12 +720,12 @@ procedure TZUGFeRDInvoiceDescriptor23CIIWriter.Save(
720720
_writeOptionalParty(Writer, TZUGFeRDPartyTypes.SellerTradeParty, Descriptor.Seller, Descriptor.SellerContact, Descriptor.SellerElectronicAddress, Descriptor.SellerTaxRegistration);
721721
//#endregion
722722

723-
//region BuyerTradeParty
723+
//#region BuyerTradeParty
724724
// BT-48: Descriptor.BuyerTaxRegistration
725725
_writeOptionalParty(Writer, TZUGFeRDPartyTypes.BuyerTradeParty, Descriptor.Buyer, Descriptor.BuyerContact, Descriptor.BuyerElectronicAddress, Descriptor.BuyerTaxRegistration);
726726
//#endregion
727727

728-
//region SellerTaxRepresentativeTradeParty
728+
//#region SellerTaxRepresentativeTradeParty
729729
// BT-63: the tax registration of the SellerTaxRepresentativeTradeParty
730730
_writeOptionalParty(Writer, TZUGFeRDPartyTypes.SellerTaxRepresentativeTradeParty, Descriptor.SellerTaxRepresentative, Nil, Nil, Descriptor.SellerTaxRepresentativeTaxRegistration);
731731
//#endregion

0 commit comments

Comments
 (0)