-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
intf.ZUGFeRDInvoiceDescriptor.pas
1776 lines (1589 loc) · 75.9 KB
/
intf.ZUGFeRDInvoiceDescriptor.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.}
unit intf.ZUGFeRDInvoiceDescriptor;
interface
uses
System.SysUtils,System.Classes,System.Generics.Collections,
System.Generics.Defaults, System.Contnrs, Xml.XMLIntf,
intf.ZUGFeRDAdditionalReferencedDocument,
intf.ZUGFeRDDeliveryNoteReferencedDocument,
intf.ZUGFeRDAccountingAccountTypeCodes,
intf.ZUGFeRDAssociatedDocument,
intf.ZUGFeRDContractReferencedDocument,
intf.ZUGFeRDSpecifiedProcuringProject,
intf.ZUGFeRDParty,
intf.ZUGFeRDQuantityCodes,
intf.ZUGFeRDPaymentMeansTypeCodes,
intf.ZUGFeRDAdditionalReferencedDocumentTypeCodes,
intf.ZUGFeRDReferenceTypeCodes,
intf.ZUGFeRDGlobalID,intf.ZUGFeRDGlobalIDSchemeIdentifiers,
intf.ZUGFeRDTaxRegistration,
intf.ZUGFeRDTaxRegistrationSchemeID,
intf.ZUGFeRDTaxTypes,
intf.ZUGFeRDTaxCategoryCodes,
intf.ZUGFeRDTaxExemptionReasonCodes,
intf.ZUGFeRDContact,
intf.ZUGFeRDNote,
intf.ZUGFeRDCurrencyCodes,
intf.ZUGFeRDProfile,
intf.ZUGFeRDInvoiceTypes,
intf.ZUGFeRDTradeLineItem,
intf.ZUGFeRDTax,
intf.ZUGFeRDServiceCharge,
intf.ZUGFeRDTradeAllowanceCharge,
intf.ZUGFeRDPaymentTerms,
intf.ZUGFeRDInvoiceReferencedDocument,
intf.ZUGFeRDBankAccount,
intf.ZUGFeRDReceivableSpecifiedTradeAccountingAccount,
intf.ZUGFeRDPaymentMeans,
intf.ZUGFeRDSellerOrderReferencedDocument,
intf.ZUGFeRDHelper,
intf.ZUGFeRDVersion,
intf.ZUGFeRDExceptions,
intf.ZUGFeRDSubjectCodes,
intf.ZUGFeRDContentCodes,
intf.ZUGFeRDCountryCodes,
intf.ZUGFeRDLegalOrganization,
intf.ZUGFeRDElectronicAddress,
intf.ZUGFeRDElectronicAddressSchemeIdentifiers,
intf.ZUGFeRDDespatchAdviceReferencedDocument,
intf.ZUGFeRDSpecialServiceDescriptionCodes,
intf.ZUGFeRDAllowanceOrChargeIdentificationCodes,
intf.ZUGFeRDFormats
;
type
/// <summary>
/// Represents a ZUGFeRD/ Factur-X invoice
/// </summary>
TZUGFeRDInvoiceDescriptor = class
private
FInvoiceNo: string;
FInvoiceDate: TDateTime;
FPaymentReference: string;
FOrderNo: string;
FOrderDate: ZUGFeRDNullable<TDateTime>;
FAdditionalReferencedDocuments: TObjectList<TZUGFeRDAdditionalReferencedDocument>;
FDeliveryNoteReferencedDocument: TZUGFeRDDeliveryNoteReferencedDocument;
FActualDeliveryDate: ZUGFeRDNullable<TDateTime>;
FContractReferencedDocument: TZUGFeRDContractReferencedDocument;
FSpecifiedProcuringProject: TZUGFeRDSpecifiedProcuringProject;
FCurrency: TZUGFeRDCurrencyCodes;
FTaxCurrency: TZUGFeRDCurrencyCodes;
FBuyer: TZUGFeRDParty;
FBuyerContact: TZUGFeRDContact;
FBuyerTaxRegistration: TObjectList<TZUGFeRDTaxRegistration>;
FBuyerElectronicAddress: TZUGFeRDElectronicAddress;
FSeller: TZUGFeRDParty;
FSellerContact: TZUGFeRDContact;
FSellerTaxRegistration: TObjectList<TZUGFeRDTaxRegistration>;
FSellerElectronicAddress: TZUGFeRDElectronicAddress;
FInvoicee: TZUGFeRDParty;
FShipTo: TZUGFeRDParty;
FPayee: TZUGFeRDParty;
FShipFrom: TZUGFeRDParty;
FNotes: TObjectList<TZUGFeRDNote>;
FBusinessProcess: string;
FIsTest: Boolean;
FProfile: TZUGFeRDProfile;
FName: string;
FType: TZUGFeRDInvoiceType;
FReferenceOrderNo: string;
FTradeLineItems: TObjectList<TZUGFeRDTradeLineItem>;
FLineTotalAmount: ZUGFeRDNullable<Currency>;
FChargeTotalAmount: ZUGFeRDNullable<Currency>;
FAllowanceTotalAmount: ZUGFeRDNullable<Currency>;
FTaxBasisAmount: ZUGFeRDNullable<Currency>;
FTaxTotalAmount: ZUGFeRDNullable<Currency>;
FGrandTotalAmount: ZUGFeRDNullable<Currency>;
FTotalPrepaidAmount: ZUGFeRDNullable<Currency>;
FRoundingAmount: ZUGFeRDNullable<Currency>;
FDuePayableAmount: ZUGFeRDNullable<Currency>;
FTaxes: TObjectList<TZUGFeRDTax>;
FServiceCharges: TObjectList<TZUGFeRDServiceCharge>;
FTradeAllowanceCharges: TObjectList<TZUGFeRDTradeAllowanceCharge>;
// FPaymentTerms: TZUGFeRDPaymentTerms;
FPaymentTermsList: TObjectList<TZUGFeRDPaymentTerms>;
FInvoiceReferencedDocuments: TZUGFeRDInvoiceReferencedDocumentObjectList;
FReceivableSpecifiedTradeAccountingAccounts: TObjectList<TZUGFeRDReceivableSpecifiedTradeAccountingAccount>;
FCreditorBankAccounts: TObjectList<TZUGFeRDBankAccount>;
FDebitorBankAccounts: TObjectList<TZUGFeRDBankAccount>;
FPaymentMeans: TZUGFeRDPaymentMeans;
FBillingPeriodStart: TDateTime;
FBillingPeriodEnd: TDateTime;
FSellerOrderReferencedDocument: TZUGFeRDSellerOrderReferencedDocument;
FDespatchAdviceReferencedDocument: TZUGFeRDDespatchAdviceReferencedDocument;
FInvoicer: TZUGFeRDParty;
FSellerReferenceNo: String;
public
/// <summary>
/// Invoice Number
/// </summary>
property InvoiceNo: string read FInvoiceNo write FInvoiceNo;
/// <summary>
/// Invoice date
/// </summary>
property InvoiceDate: TDateTime read FInvoiceDate write FInvoiceDate;
/// <summary>
/// A textual value used to establish a link between the payment and the invoice, issued by the seller.
/// </summary>
property PaymentReference: string read FPaymentReference write FPaymentReference;
/// <summary>
/// Order Id
/// </summary>
property OrderNo: string read FOrderNo write FOrderNo;
/// <summary>
/// Order date
/// </summary>
property OrderDate: ZUGFeRDNullable<TDateTime> read FOrderDate write FOrderDate;
/// <summary>
/// Details of an additional document reference
///
/// A new reference document is added by AddAdditionalReferenceDocument()
/// </summary>
property AdditionalReferencedDocuments: TObjectList<TZUGFeRDAdditionalReferencedDocument> read FAdditionalReferencedDocuments;
/// <summary>
/// Detailed information about the corresponding despatch advice
/// </summary>
property DespatchAdviceReferencedDocument : TZUGFeRDDespatchAdviceReferencedDocument read FDespatchAdviceReferencedDocument write FDespatchAdviceReferencedDocument;
/// <summary>
/// Detailed information about the corresponding delivery note
/// </summary>
property DeliveryNoteReferencedDocument: TZUGFeRDDeliveryNoteReferencedDocument read FDeliveryNoteReferencedDocument write FDeliveryNoteReferencedDocument;
/// <summary>
/// Actual delivery date
/// </summary>
property ActualDeliveryDate: ZUGFeRDNullable<TDateTime> read FActualDeliveryDate write FActualDeliveryDate;
/// <summary>
/// Detailed information on the associated contract
///
/// BT-12
/// </summary>
property ContractReferencedDocument: TZUGFeRDContractReferencedDocument read FContractReferencedDocument write FContractReferencedDocument;
/// <summary>
/// Details about a project reference
/// </summary>
property SpecifiedProcuringProject: TZUGFeRDSpecifiedProcuringProject read FSpecifiedProcuringProject write FSpecifiedProcuringProject;
/// <summary>
/// Currency of the invoice
/// </summary>
property Currency: TZUGFeRDCurrencyCodes read FCurrency write FCurrency;
/// <summary>
/// The VAT total amount expressed in the accounting currency accepted or
/// required in the country of the seller.
///
/// Note: Shall be used in combination with the invoice total VAT amount
/// in accounting currency (BT-111), if the VAT accounting currency code
/// differs from the invoice currency code.
///
/// In normal invoicing scenarios, leave this property empty!
///
/// The lists of valid currencies are
/// registered with the ISO 4217 Maintenance Agency „Codes for the
/// representation of currencies and funds”. Please refer to Article 230
/// of the Council Directive 2006/112/EC [2] for further information.
///
/// BT-6
/// </summary>
property TaxCurrency : TZUGFeRDCurrencyCodes read FTaxCurrency write FTaxCurrency;
/// <summary>
/// Information about the buyer
/// </summary>
property Buyer: TZUGFeRDParty read FBuyer write FBuyer;
/// <summary>
/// Buyer contact information
///
/// A group of business terms providing contact information relevant for the buyer.
/// </summary>
property BuyerContact: TZUGFeRDContact read FBuyerContact write FBuyerContact;
property BuyerTaxRegistration: TObjectList<TZUGFeRDTaxRegistration> read FBuyerTaxRegistration;
property BuyerElectronicAddress : TZUGFeRDElectronicAddress read FBuyerElectronicAddress;
property Seller: TZUGFeRDParty read FSeller write FSeller;
property SellerContact: TZUGFeRDContact read FSellerContact write FSellerContact;
property SellerTaxRegistration: TObjectList<TZUGFeRDTaxRegistration> read FSellerTaxRegistration;
property SellerElectronicAddress : TZUGFeRDElectronicAddress read FSellerElectronicAddress;
/// <summary>
/// Given seller reference number for routing purposes after biliteral agreement
///
/// This field seems not to be used in common scenarios.
/// </summary>
property SellerReferenceNo : String read FSellerReferenceNo write FSellerReferenceNo;
/// <summary>
/// This party is optional and only relevant for Extended profile
/// </summary>
property Invoicee: TZUGFeRDParty read FInvoicee write FInvoicee;
/// <summary>
/// This party is optional and only relevant for Extended profile.
///
/// It seems to be used under rate condition only.
/// </summary>
property Invoicer: TZUGFeRDParty read FInvoicer write FInvoicer;
/// <summary>
/// This party is optional and only relevant for Extended profile
/// </summary>
property ShipTo: TZUGFeRDParty read FShipTo write FShipTo;
/// <summary>
/// This party is optional and only relevant for Extended profile
/// </summary>
property Payee: TZUGFeRDParty read FPayee write FPayee;
/// <summary>
/// This party is optional and only relevant for Extended profile
/// </summary>
property ShipFrom: TZUGFeRDParty read FShipFrom write FShipFrom;
/// <summary>
/// Free text on header level
/// </summary>
property Notes: TObjectList<TZUGFeRDNote> read FNotes;
/// <summary>
/// Description: Identifies the context of a business process where the transaction is taking place,
/// thus allowing the buyer to process the invoice in an appropriate manner.
///
/// Note: These data make it possible to define the purpose of the settlement(invoice of the authorised person,
/// contractual partner, subcontractor, settlement document for a building contract etc.).
///
/// BT-23
/// </summary>
property BusinessProcess: string read FBusinessProcess write FBusinessProcess;
/// <summary>
/// The Indicator type may be used when implementing a new system in order to mark the invoice as „trial invoice“.
/// </summary>
property IsTest: Boolean read FIsTest write FIsTest;
/// <summary>
/// Representation of information that should be used for the document.
///
/// As the library can be used to both write ZUGFeRD files and read ZUGFeRD files, the profile serves two purposes:
/// It indicates the profile that was used to write the ZUGFeRD file that was loaded or the profile that is to be used when
/// the document is saved.
/// </summary>
property Profile: TZUGFeRDProfile read FProfile write FProfile default TZUGFeRDProfile.Basic;
/// <summary>
/// Document name (free text)
/// </summary>
property Name: string read FName write FName;
/// <summary>
/// Indicates the type of the document, if it represents an invoice, a credit note or one of the available 'sub types'
/// </summary>
property Type_: TZUGFeRDInvoiceType read FType write FType default TZUGFeRDInvoiceType.Invoice;
/// <summary>
/// The identifier is defined by the buyer (e.g. contact ID, department, office ID, project code), but provided by the seller in the invoice.
/// In France it needs to be filled with 999, if not available.
///
/// BT-10
/// </summary>
property ReferenceOrderNo: string read FReferenceOrderNo write FReferenceOrderNo;
/// <summary>
/// An aggregation of business terms containing information about individual invoice positions
/// </summary>
property TradeLineItems: TObjectList<TZUGFeRDTradeLineItem> read FTradeLineItems;
/// <summary>
/// Sum of all invoice line net amounts in the invoice
/// </summary>
property LineTotalAmount: ZUGFeRDNullable<Currency> read FLineTotalAmount write FLineTotalAmount;
/// <summary>
/// Sum of all surcharges on document level in the invoice
///
/// Surcharges on line level are included in the invoice line net amount which is summed up into the sum of invoice line net amount.
/// </summary>
property ChargeTotalAmount: ZUGFeRDNullable<Currency> read FChargeTotalAmount write FChargeTotalAmount;
/// <summary>
/// Sum of discounts on document level in the invoice
///
/// Discounts on line level are included in the invoice line net amount which is summed up into the sum of invoice line net amount.
/// </summary>
property AllowanceTotalAmount: ZUGFeRDNullable<Currency> read FAllowanceTotalAmount write FAllowanceTotalAmount;
/// <summary>
/// The total amount of the invoice without VAT.
///
/// The invoice total amount without VAT is the sum of invoice line net amount minus sum of discounts on document level plus sum of surcharges on document level.
/// </summary>
property TaxBasisAmount: ZUGFeRDNullable<Currency> read FTaxBasisAmount write FTaxBasisAmount;
/// <summary>
/// The total VAT amount for the invoice.
/// The VAT total amount expressed in the accounting currency accepted or required in the country of the seller
///
/// To be used when the VAT accounting currency (BT-6) differs from the Invoice currency code (BT-5) in accordance
/// with article 230 of Directive 2006/112 / EC on VAT. The VAT amount in accounting currency is not used
/// in the calculation of the Invoice totals..
/// </summary>
property TaxTotalAmount: ZUGFeRDNullable<Currency> read FTaxTotalAmount write FTaxTotalAmount;
/// <summary>
/// Invoice total amount with VAT
///
/// The invoice total amount with VAT is the invoice without VAT plus the invoice total VAT amount.
/// </summary>
property GrandTotalAmount: ZUGFeRDNullable<Currency> read FGrandTotalAmount write FGrandTotalAmount;
/// <summary>
/// Sum of amount paid in advance
///
/// This amount is subtracted from the invoice total amount with VAT to calculate the amount due for payment.
/// </summary>
property TotalPrepaidAmount: ZUGFeRDNullable<Currency> read FTotalPrepaidAmount write FTotalPrepaidAmount;
/// <summary>
/// The amount to be added to the invoice total to round the amount to be paid.
/// </summary>
property RoundingAmount: ZUGFeRDNullable<Currency> read FRoundingAmount write FRoundingAmount;
/// <summary>
/// The outstanding amount that is requested to be paid.
///
/// This amount is the invoice total amount with VAT minus the paid amount that has
/// been paid in advance. The amount is zero in case of a fully paid invoice.
/// The amount may be negative; in that case the seller owes the amount to the buyer.
/// </summary>
property DuePayableAmount: ZUGFeRDNullable<Currency> read FDuePayableAmount write FDuePayableAmount;
/// <summary>
/// A group of business terms providing information about VAT breakdown by different categories, rates and exemption reasons
/// </summary>
property Taxes: TObjectList<TZUGFeRDTax> read FTaxes;
/// <summary>
/// Transport and packaging costs
/// </summary>
property ServiceCharges: TObjectList<TZUGFeRDServiceCharge> read FServiceCharges;
/// <summary>
/// Detailed information on discounts and charges.
/// This field is marked as private now, please use GetTradeAllowanceCharges() to retrieve all trade allowance charges
/// </summary>
property TradeAllowanceCharges: TObjectList<TZUGFeRDTradeAllowanceCharge> read FTradeAllowanceCharges;
/// <summary>
/// Detailed information about payment terms
/// </summary>
///
// property PaymentTerms: TZUGFeRDPaymentTerms read FPaymentTerms write FPaymentTerms;
property PaymentTermsList: TObjectList<TZUGFeRDPaymentTerms> read FPaymentTermsList;
/// <summary>
/// A group of business terms providing information about a preceding invoices.
///
/// To be used in case:
/// — a preceding invoice is corrected;
/// — preceding partial invoices are referred to from a final invoice;
/// — preceding pre-payment invoices are referred to from a final invoice.
/// </summary>
property InvoiceReferencedDocuments: TZUGFeRDInvoiceReferencedDocumentObjectList read FInvoiceReferencedDocuments write FInvoiceReferencedDocuments;
/// <summary>
/// Detailed information about the accounting reference
/// </summary>
property ReceivableSpecifiedTradeAccountingAccounts: TObjectList<TZUGFeRDReceivableSpecifiedTradeAccountingAccount> read FReceivableSpecifiedTradeAccountingAccounts;
/// <summary>
/// Credit Transfer
///
/// A group of business terms to specify credit transfer payments
/// </summary>
property CreditorBankAccounts: TObjectList<TZUGFeRDBankAccount> read FCreditorBankAccounts;
/// <summary>
/// Buyer bank information
/// </summary>
property DebitorBankAccounts: TObjectList<TZUGFeRDBankAccount> read FDebitorBankAccounts;
/// <summary>
/// Payment instructions
///
/// /// If various accounts for credit transfers shall be transferred, the element
/// SpecifiedTradeSettlementPaymentMeans can be repeated for each account. The code
/// for the type of payment within the element typecode (BT-81) should therefore not
/// differ within the repetitions.
/// </summary>
property PaymentMeans: TZUGFeRDPaymentMeans read FPaymentMeans write FPaymentMeans;
/// <summary>
/// Detailed information about the invoicing period, start date
/// </summary>
property BillingPeriodStart: TDateTime read FBillingPeriodStart write FBillingPeriodStart;
/// <summary>
/// Detailed information about the invoicing period, end date
/// </summary>
property BillingPeriodEnd: TDateTime read FBillingPeriodEnd write FBillingPeriodEnd;
/// <summary>
/// Details about the associated order confirmation (BT-14).
/// This is optional and can be used in Profiles Comfort and Extended.
/// If you add a SellerOrderReferencedDocument you must set the property "ID".
/// The property "IssueDateTime" is optional an only used in profile "Extended"
/// </summary>
property SellerOrderReferencedDocument: TZUGFeRDSellerOrderReferencedDocument read FSellerOrderReferencedDocument write FSellerOrderReferencedDocument;
public
constructor Create;
destructor Destroy; override;
/// <summary>
/// Gets the ZUGFeRD version of a ZUGFeRD invoice that is passed via filename
/// </summary>
/// <param name="filename">Stream where to read the ZUGFeRD invoice</param>
/// <returns>ZUGFeRD version of the invoice that was passed to the function</returns>
class function GetVersion(const filename: string): TZUGFeRDVersion; overload;
/// <summary>
/// Gets the ZUGFeRD version of a ZUGFeRD invoice that is passed via stream
///
/// </summary>
/// <param name="stream">Stream where to read the ZUGFeRD invoice</param>
/// <returns>ZUGFeRD version of the invoice that was passed to the function</returns>
class function GetVersion(const stream: TStream): TZUGFeRDVersion; overload;
/// <summary>
/// Tests if the stream is readable by one of the readers, without actually reading
///
/// Please make sure that the stream is open, otherwise this call will raise an IllegalStreamException.
///
/// Important: the stream will not be closed by this function, make sure to close it by yourself!
///
/// </summary>
/// <param name="stream">Stream where to read the ZUGFeRD invoice</param>
/// <returns>true if the stream can be interpreted by one of the readers</returns>
class function IsReadable(stream: TStream): boolean;
/// <summary>
/// Loads a ZUGFeRD invoice from a stream.
///
/// Please make sure that the stream is open, otherwise this call will raise an IllegalStreamException.
///
/// Important: the stream will not be closed by this function, make sure to close it by yourself!
///
/// </summary>
/// <param name="stream">Stream where to read the ZUGFeRD invoice</param>
/// <returns></returns>
class function Load(stream: TStream): TZUGFeRDInvoiceDescriptor; overload;
/// <summary>
/// Loads a ZUGFeRD invoice from a file.
///
/// Please make sure that the file is exists, otherwise this call will raise a FileNotFoundException.
/// </summary>
/// <param name="filename">Name of the ZUGFeRD invoice file</param>
/// <returns></returns>
class function Load(filename: String): TZUGFeRDInvoiceDescriptor; overload;
class function Load(xmldocument : IXMLDocument): TZUGFeRDInvoiceDescriptor; overload;
/// <summary>
/// Initializes a new invoice object and returns it.
/// </summary>
/// <param name="invoiceNo">Invoice number</param>
/// <param name="invoiceDate">Invoice date</param>
/// <param name="currency">Currency</param>
/// <param name="invoiceNoAsReference">Remittance information</param>
/// <returns></returns>
class function CreateInvoice(const invoiceNo: string; invoiceDate: TDateTime;
currency: TZUGFeRDCurrencyCodes;
const invoiceNoAsReference: string = ''): TZUGFeRDInvoiceDescriptor;
procedure AddNote(const note: string; subjectCode: TZUGFeRDSubjectCodes = TZUGFeRDSubjectCodes.Unknown; contentCode: TZUGFeRDContentCodes = TZUGFeRDContentCodes.Unknown);
procedure SetBuyer(const name, postcode, city, street: string; country: TZUGFeRDCountryCodes; const id: string = '';
globalID: TZUGFeRDGlobalID = nil; const receiver: string = ''; legalOrganization: TZUGFeRDLegalOrganization = nil);
procedure SetSeller(const name, postcode, city, street: string; country: TZUGFeRDCountryCodes; const id: string = '';
globalID: TZUGFeRDGlobalID = nil; legalOrganization: TZUGFeRDLegalOrganization = nil; description : String = '');
procedure SetSellerContact(const name: string = ''; const orgunit: string = '';
const emailAddress: string = ''; const phoneno: string = ''; const faxno: string = '');
procedure SetBuyerContact(const name: string; const orgunit: string = '';
const emailAddress: string = ''; const phoneno: string = ''; const faxno: string = '');
/// <summary>
/// Sets the SpecifiedProcuringProject
/// </summary>
/// <param name="id">ProjectId</param>
/// <param name="name">ProjectName</param>
procedure SetSpecifiedProcuringProject(const id, name: string);
procedure AddBuyerTaxRegistration(const no: string; const schemeID: TZUGFeRDTaxRegistrationSchemeID);
procedure AddSellerTaxRegistration(const no: string; const schemeID: TZUGFeRDTaxRegistrationSchemeID);
/// <summary>
/// Sets the Buyer Electronic Address for Peppol
/// </summary>
/// <param name="address">Peppol Address</param>
/// <param name="electronicAddressSchemeID">ElectronicAddressSchemeIdentifier</param>
procedure SetBuyerElectronicAddress(address : string; electronicAddressSchemeID : TZUGFeRDElectronicAddressSchemeIdentifiers);
/// <summary>
/// Sets the Seller Electronic Address for Peppol
/// </summary>
/// <param name="address">Peppol Address</param>
/// <param name="electronicAddressSchemeID">ElectronicAddressSchemeIdentifier</param>
procedure SetSellerElectronicAddress(address : string; electronicAddressSchemeID : TZUGFeRDElectronicAddressSchemeIdentifiers);
/// <summary>
/// Add an additional reference document
/// </summary>
/// <param name="id">Document number such as delivery note no or credit memo no</param>
/// <param name="typeCode"></param>
/// <param name="issueDateTime">Document Date</param>
/// <param name="name"></param>
/// <param name="referenceTypeCode">Type of the referenced document</param>
/// <param name="attachmentBinaryObject"></param>
/// <param name="filename"></param>
procedure AddAdditionalReferencedDocument(const id: string; const typeCode: TZUGFeRDAdditionalReferencedDocumentTypeCode;
const issueDateTime: TDateTime = 0; const name: string = ''; const referenceTypeCode: TZUGFeRDReferenceTypeCodes = TZUGFeRDReferenceTypeCodes.Unknown;
const attachmentBinaryObject: TMemoryStream = nil; const filename: string = '');
/// <summary>
/// Sets details of the associated order
/// </summary>
/// <param name="orderNo"></param>
/// <param name="orderDate"></param>
procedure SetBuyerOrderReferenceDocument(const orderNo: string; const orderDate: TDateTime = 0);
/// <summary>
/// Sets detailed information about the corresponding despatch advice
/// </summary>
/// <param name="deliveryNoteNo"></param>
/// <param name="deliveryNoteDate"></param>
procedure SetDespatchAdviceReferencedDocument(despatchAdviceNo : String; despatchAdviceDate: TDateTime = 0);
/// <summary>
/// Sets detailed information about the corresponding delivery note
/// </summary>
/// <param name="deliveryNoteNo"></param>
/// <param name="deliveryNoteDate"></param>
procedure SetDeliveryNoteReferenceDocument(const deliveryNoteNo: string; const deliveryNoteDate: TDateTime = 0);
/// <summary>
/// Sets detailed information about the corresponding contract
/// </summary>
/// <param name="contractNo">Contract number</param>
/// <param name="contractDate">Date of the contract</param>
procedure SetContractReferencedDocument(const contractNo: string; const contractDate: TDateTime);
/// <summary>
/// The logistics service charge (ram:SpecifiedLogisticsServiceCharge) is part of the ZUGFeRD specification.
/// Please note that it is not part of the XRechnung specification, thus, everything passed to this function will not
/// be written when writing XRechnung format.
///
/// You might use AddTradeAllowanceCharge() instead.
/// </summary>
procedure AddLogisticsServiceCharge(const amount: Currency; const description: string; const taxTypeCode: TZUGFeRDTaxTypes; const taxCategoryCode: TZUGFeRDTaxCategoryCodes; const taxPercent: Currency);
/// <summary>
/// Adds an allowance or charge on document level.
///
/// Allowance represents a discount whereas charge represents a surcharge.
/// </summary>
/// <param name="isDiscount">Marks if the allowance charge is a discount. Please note that in contrary to this function, the xml file indicated a surcharge, not a discount (value will be inverted)</param>
/// <param name="basisAmount">Base amount (basis of allowance)</param>
/// <param name="currency">Curency of the allowance</param>
/// <param name="actualAmount">Actual allowance charge amount</param>
/// <param name="reason">Reason for the allowance</param>
/// <param name="reasonCodeCharge"></param>
/// <param name="reasonCodeAllowance"></param>
/// <param name="taxTypeCode">VAT type code for document level allowance/ charge</param>
/// <param name="taxCategoryCode">VAT type code for document level allowance/ charge</param>
/// <param name="taxPercent">VAT rate for the allowance</param>
procedure AddTradeAllowanceCharge(const isDiscount: Boolean;
const basisAmount: Currency; const currency: TZUGFeRDCurrencyCodes;
const actualAmount: Currency; const reason: string;
const reasonCodeCharge : TZUGFeRDSpecialServiceDescriptionCodes;
const reasonCodeAllowance : TZUGFeRDAllowanceOrChargeIdentificationCodes;
const taxTypeCode: TZUGFeRDTaxTypes;
const taxCategoryCode: TZUGFeRDTaxCategoryCodes;
const taxPercent: Currency); overload;
/// <summary>
/// Adds an allowance or charge on document level.
///
/// Allowance represents a discount whereas charge represents a surcharge.
/// </summary>
/// <param name="isDiscount">Marks if the allowance charge is a discount. Please note that in contrary to this function, the xml file indicated a surcharge, not a discount (value will be inverted)</param>
/// <param name="basisAmount">Base amount (basis of allowance)</param>
/// <param name="currency">Curency of the allowance</param>
/// <param name="actualAmount">Actual allowance charge amount</param>
/// <param name="chargePercentage">Actual allowance charge percentage</param>
/// <param name="reason">Reason for the allowance</param>
/// <param name="reasonCodeCharge"></param>
/// <param name="reasonCodeAllowance"></param>
/// <param name="taxTypeCode">VAT type code for document level allowance/ charge</param>
/// <param name="taxCategoryCode">VAT type code for document level allowance/ charge</param>
/// <param name="taxPercent">VAT rate for the allowance</param>
procedure AddTradeAllowanceCharge(const isDiscount: Boolean;
const basisAmount: Currency; const currency: TZUGFeRDCurrencyCodes;
const actualAmount: Currency; const chargePercentage : Currency;
const reason: string;
const reasonCodeCharge : TZUGFeRDSpecialServiceDescriptionCodes;
const reasonCodeAllowance : TZUGFeRDAllowanceOrChargeIdentificationCodes;
const taxTypeCode: TZUGFeRDTaxTypes;
const taxCategoryCode: TZUGFeRDTaxCategoryCodes;
const taxPercent: Currency); overload;
/// <summary>
/// Set Information about Preceding Invoice. Please note that all versions prior ZUGFeRD 2.3 and UBL only
/// allow one of such reference.
/// </summary>
/// <param name="id">Preceding InvoiceNo</param>
/// <param name="IssueDateTime">Preceding Invoice Date</param>
procedure AddInvoiceReferencedDocument(const id: string; const IssueDateTime: TDateTime = 0);
/// <summary>
/// Detailinformationen zu Belegsummen
/// </summary>
/// <param name="lineTotalAmount">Gesamtbetrag der Positionen</param>
/// <param name="chargeTotalAmount">Gesamtbetrag der Zuschläge</param>
/// <param name="allowanceTotalAmount">Gesamtbetrag der Abschläge</param>
/// <param name="taxBasisAmount">Basisbetrag der Steuerberechnung</param>
/// <param name="taxTotalAmount">Steuergesamtbetrag</param>
/// <param name="grandTotalAmount">Bruttosumme</param>
/// <param name="totalPrepaidAmount">Anzahlungsbetrag</param>
/// <param name="duePayableAmount">Zahlbetrag</param>
/// <param name="roundingAmount">RoundingAmount / Rundungsbetrag, profile COMFORT and EXTENDED</param>
procedure SetTotals(const aLineTotalAmount: Currency = 0; const aChargeTotalAmount: Currency = 0;
const aAllowanceTotalAmount: Currency = 0; const aTaxBasisAmount: Currency = 0; const aTaxTotalAmount: Currency = 0;
const aGrandTotalAmount: Currency = 0; const aTotalPrepaidAmount: Currency = 0; const aDuePayableAmount: Currency = 0;
const aRoundingAmount: Currency = 0);
/// <summary>
/// Add information about VAT and apply to the invoice line items for goods and services on the invoice.
///
/// This tax is added per VAT/ tax rate.
/// </summary>
/// <param name="calculatedAmount"></param>
/// <param name="basisAmount"></param>
/// <param name="percent">Tax rate where the tax belongs to</param>
/// <param name="typeCode"></param>
/// <param name="categoryCode"></param>
/// <param name="allowanceChargeBasisAmount"></param>
/// <param name="exemptionReasonCode"></param>
/// <param name="exemptionReason"></param>
procedure AddApplicableTradeTax(const calculatedAmount, basisAmount: Currency; const percent: Double; const typeCode: TZUGFeRDTaxTypes; const categoryCode: TZUGFeRDTaxCategoryCodes = TZUGFeRDTaxCategoryCodes.Unknown; const allowanceChargeBasisAmount: Currency = 0; const exemptionReasonCode: TZUGFeRDTaxExemptionReasonCodes = TZUGFeRDTaxExemptionReasonCodes.Unknown; const exemptionReason: string = '');
/// <summary>
/// Saves the descriptor object into a stream.
///
/// The stream position will be reset to the original position after writing is finished.
/// This allows easy further processing of the stream.
/// </summary>
/// <param name="stream">The stream where the data should be saved to.</param>
/// <param name="version">The ZUGFeRD version you want to use. Defaults to version 1.</param>
/// <param name="profile">The ZUGFeRD profile you want to use. Defaults to Basic.</param>
/// <param name="format">The format of the target file that may be CII or UBL</param>
procedure Save(const stream: TStream; const version: TZUGFeRDVersion = TZUGFeRDVersion.Version1; const profile: TZUGFeRDProfile = TZUGFeRDProfile.Basic; format : TZUGFeRDFormats = TZUGFeRDFormats.CII); overload;
/// <summary>
/// Saves the descriptor object into a file with given name.
/// </summary>
/// <param name="filename">The filename where the data should be saved to.</param>
/// <param name="version">The ZUGFeRD version you want to use. Defaults to version 1.</param>
/// <param name="profile">The ZUGFeRD profile you want to use. Defaults to Basic.</param>
/// <param name="format">The format of the target file that may be CII or UBL</param>
procedure Save(const filename: string; const version: TZUGFeRDVersion = TZUGFeRDVersion.Version1; const profile: TZUGFeRDProfile = TZUGFeRDProfile.Basic; format : TZUGFeRDFormats = TZUGFeRDFormats.CII); overload;
/// <summary>
/// Adds a new comment as a dedicated line of the invoice.
///
/// The line id is generated automatically
/// </summary>
/// <param name="comment"></param>
procedure AddTradeLineCommentItem(const comment: string); overload;
/// <summary>
/// Adds a new comment as a dedicated line of the invoice.
///
/// The line id is passed as a parameter
/// </summary>
/// <param name="lineID"></param>
/// <param name="comment"></param>
procedure AddTradeLineCommentItem(const lineID: string; const comment: string); overload;
/// <summary>
/// Adds a new line to the invoice. The line id is generated automatically.
///
/// Please note that this function returns the new trade line item object that you might use
/// in your code to add more detailed information to the trade line item.
/// </summary>
/// <param name="name"></param>
/// <param name="description"></param>
/// <param name="unitCode"></param>
/// <param name="unitQuantity"></param>
/// <param name="grossUnitPrice"></param>
/// <param name="netUnitPrice"></param>
/// <param name="billedQuantity"></param>
/// <param name="lineTotalAmount">net total including discounts and surcharges. This parameter is optional. If it is not filled, the line total amount is automatically calculated based on netUnitPrice and billedQuantity</param>
/// <param name="taxType"></param>
/// <param name="categoryCode"></param>
/// <param name="taxPercent"></param>
/// <param name="comment"></param>
/// <param name="id"></param>
/// <param name="sellerAssignedID"></param>
/// <param name="buyerAssignedID"></param>
/// <param name="deliveryNoteID"></param>
/// <param name="deliveryNoteDate"></param>
/// <param name="buyerOrderID"></param>
/// <param name="buyerOrderDate"></param>
/// <param name="billingPeriodStart"></param>
/// <param name="billingPeriodEnd"></param>
/// <returns>Returns the instance of the trade line item. You might use this object to add details such as trade allowance charges</returns>
/// <returns></returns>
function AddTradeLineItem(const name: string; const description: string;
const unitCode: TZUGFeRDQuantityCodes = TZUGFeRDQuantityCodes.Unknown; const unitQuantity: IZUGFeRDNullableParam<Double> = nil;
const grossUnitPrice: IZUGFeRDNullableParam<Currency> = nil; const netUnitPrice: IZUGFeRDNullableParam<Currency> = nil; const billedQuantity: Double = 0; const lineTotalAmount : Currency = 0;
const taxType: TZUGFeRDTaxTypes = TZUGFeRDTaxTypes.Unknown; const categoryCode: TZUGFeRDTaxCategoryCodes = TZUGFeRDTaxCategoryCodes.Unknown; const taxPercent: Double = 0;
const comment: string = ''; const id: TZUGFeRDGlobalID = nil; const sellerAssignedID: string = '';
const buyerAssignedID: string = ''; const deliveryNoteID: string = ''; const deliveryNoteDate: IZUGFeRDNullableParam<TDateTime> = nil;
const buyerOrderID: string = ''; const buyerOrderDate: IZUGFeRDNullableParam<TDateTime> = nil; const billingPeriodStart: IZUGFeRDNullableParam<TDateTime> = nil;
const billingPeriodEnd: IZUGFeRDNullableParam<TDateTime> = nil): TZUGFeRDTradeLineItem; overload;
/// <summary>
/// Adds a new line to the invoice. The line id is passed as a parameter.
/// </summary>
function AddTradeLineItem(const lineID: string; const name: string; const description: string;
const unitCode: TZUGFeRDQuantityCodes = TZUGFeRDQuantityCodes.Unknown; const unitQuantity: IZUGFeRDNullableParam<Double> = nil;
const grossUnitPrice: IZUGFeRDNullableParam<Currency> = nil; const netUnitPrice: IZUGFeRDNullableParam<Currency> = nil; const billedQuantity: Double = 0; const lineTotalAmount : Currency = 0;
const taxType: TZUGFeRDTaxTypes = TZUGFeRDTaxTypes.Unknown; const categoryCode: TZUGFeRDTaxCategoryCodes = TZUGFeRDTaxCategoryCodes.Unknown; const taxPercent: Double = 0;
const comment: string = ''; const id: TZUGFeRDGlobalID = nil; const sellerAssignedID: string = ''; const buyerAssignedID: string = '';
const deliveryNoteID: string = ''; const deliveryNoteDate: IZUGFeRDNullableParam<TDateTime> = nil; const buyerOrderID: string = '';
const buyerOrderDate: IZUGFeRDNullableParam<TDateTime> = nil; const billingPeriodStart: IZUGFeRDNullableParam<TDateTime> = nil;
const billingPeriodEnd: IZUGFeRDNullableParam<TDateTime> = nil): TZUGFeRDTradeLineItem; overload;
procedure SetPaymentMeans(paymentCode: TZUGFeRDPaymentMeansTypeCodes; const information: string = '';
const identifikationsnummer: string = '');
/// <summary>
/// Sets up the payment means for SEPA direct debit.
/// </summary>
procedure SetPaymentMeansSepaDirectDebit(const sepaCreditorIdentifier: string;
const information: string = '');
/// <summary>
/// Sets up the payment means for payment via financial card.
/// </summary>
procedure SetPaymentMeansFinancialCard(const financialCardId: string;
const financialCardCardholder: string; const information: string = '');
/// <summary>
/// Adds a group of business terms to specify credit transfer payments
/// </summary>
/// <param name="iban">IBAN</param>
/// <param name="bic">BIC</param>
/// <param name="id">Optional: old German bank account no</param>
/// <param name="bankleitzahl">Optional: old German Bankleitzahl</param>
/// <param name="bankName">Optional: old German bank name</param>
/// <param name="name">Optional: bank account name</param>
procedure AddCreditorFinancialAccount(const iban: string; const bic: string; const id: string = '';
const bankleitzahl: string = ''; const bankName: string = ''; const name: string = '');
procedure AddDebitorFinancialAccount(const iban: string; const bic: string; const id: string = '';
const bankleitzahl: string = ''; const bankName: string = '');
procedure AddReceivableSpecifiedTradeAccountingAccount(const AccountID: string); overload;
procedure AddReceivableSpecifiedTradeAccountingAccount(const AccountID: string;
const AccountTypeCode: TZUGFeRDAccountingAccountTypeCodes); overload;
private
function _getNextLineId: string;
end;
implementation
uses
intf.ZUGFeRDInvoiceDescriptorReader,intf.ZUGFeRDInvoiceDescriptorWriter,
intf.ZUGFeRDInvoiceDescriptor1Reader,intf.ZUGFeRDInvoiceDescriptor1Writer,
intf.ZUGFeRDInvoiceDescriptor20Reader,intf.ZUGFeRDInvoiceDescriptor20Writer,
intf.ZUGFeRDInvoiceDescriptor23CIIReader,intf.ZUGFeRDInvoiceDescriptor22UBLReader,
intf.ZUGFeRDInvoiceDescriptor23Writer,
intf.ZUGFeRDInvoiceDescriptor23CIIWriter,intf.ZUGFeRDInvoiceDescriptor22UBLWriter
;
{ TZUGFeRDInvoiceDescriptor }
constructor TZUGFeRDInvoiceDescriptor.Create;
begin
FAdditionalReferencedDocuments := TObjectList<TZUGFeRDAdditionalReferencedDocument>.Create;
FDespatchAdviceReferencedDocument := nil;
FDeliveryNoteReferencedDocument:= nil;//TZUGFeRDDeliveryNoteReferencedDocument.Create;
FContractReferencedDocument := nil;//TZUGFeRDContractReferencedDocument.Create;
FSpecifiedProcuringProject := nil;//TZUGFeRDSpecifiedProcuringProject.Create;
FBuyer := nil;//TZUGFeRDParty.Create;
FBuyerContact := nil;//TZUGFeRDContact.Create;
FBuyerTaxRegistration := TObjectList<TZUGFeRDTaxRegistration>.Create;
FBuyerElectronicAddress := TZUGFeRDElectronicAddress.Create;
FSeller := nil;//TZUGFeRDParty.Create;
FSellerContact := nil;//TZUGFeRDContact.Create;
FSellerTaxRegistration := TObjectList<TZUGFeRDTaxRegistration>.Create;
FSellerElectronicAddress := TZUGFeRDElectronicAddress.Create;
FInvoicee := nil;//TZUGFeRDParty.Create;
FInvoicer := nil;//TZUGFeRDParty.Create;
FShipTo := nil;//TZUGFeRDParty.Create;
FPayee := nil;//TZUGFeRDParty.Create;
FShipFrom := nil;//TZUGFeRDParty.Create;
FNotes := TObjectList<TZUGFeRDNote>.Create;
FTradeLineItems := TObjectList<TZUGFeRDTradeLineItem>.Create;
FTaxes := TObjectList<TZUGFeRDTax>.Create;
FServiceCharges := TObjectList<TZUGFeRDServiceCharge>.Create;
FTradeAllowanceCharges := TObjectList<TZUGFeRDTradeAllowanceCharge>.Create;
// FPaymentTerms := nil;//TZUGFeRDPaymentTerms.Create;
FPaymentTermsList := TObjectList<TZUGFeRDPaymentTerms>.Create;
FInvoiceReferencedDocuments := TZUGFeRDInvoiceReferencedDocumentObjectList.Create;
FReceivableSpecifiedTradeAccountingAccounts:= TObjectList<TZUGFeRDReceivableSpecifiedTradeAccountingAccount>.Create;
FCreditorBankAccounts := TObjectList<TZUGFeRDBankAccount>.Create;
FDebitorBankAccounts := TObjectList<TZUGFeRDBankAccount>.Create;
FPaymentMeans := nil;//TZUGFeRDPaymentMeans.Create;
FSellerOrderReferencedDocument := nil;//TZUGFeRDSellerOrderReferencedDocument.Create;
FTaxCurrency := TZUGFeRDCurrencyCodes.Unknown;
end;
destructor TZUGFeRDInvoiceDescriptor.Destroy;
begin
if Assigned(FAdditionalReferencedDocuments ) then begin FAdditionalReferencedDocuments.Free; FAdditionalReferencedDocuments := nil; end;
if Assigned(FDespatchAdviceReferencedDocument) then begin FDespatchAdviceReferencedDocument.Free; FDespatchAdviceReferencedDocument := nil; end;
if Assigned(FDeliveryNoteReferencedDocument) then begin FDeliveryNoteReferencedDocument.Free; FDeliveryNoteReferencedDocument := nil; end;
if Assigned(FContractReferencedDocument ) then begin FContractReferencedDocument.Free; FContractReferencedDocument := nil; end;
if Assigned(FSpecifiedProcuringProject ) then begin FSpecifiedProcuringProject.Free; FSpecifiedProcuringProject := nil; end;
if Assigned(FBuyer ) then begin FBuyer.Free; FBuyer := nil; end;
if Assigned(FBuyerContact ) then begin FBuyerContact.Free; FBuyerContact := nil; end;
if Assigned(FBuyerTaxRegistration ) then begin FBuyerTaxRegistration.Free; FBuyerTaxRegistration := nil; end;
if Assigned(FBuyerElectronicAddress ) then begin FBuyerElectronicAddress.Free; FBuyerElectronicAddress := nil; end;
if Assigned(FSeller ) then begin FSeller.Free; FSeller := nil; end;
if Assigned(FSellerContact ) then begin FSellerContact.Free; FSellerContact := nil; end;
if Assigned(FSellerTaxRegistration ) then begin FSellerTaxRegistration.Free; FSellerTaxRegistration := nil; end;
if Assigned(FSellerElectronicAddress ) then begin FSellerElectronicAddress.Free; FSellerElectronicAddress := nil; end;
if Assigned(FInvoicee ) then begin FInvoicee.Free; FInvoicee := nil; end;
if Assigned(FInvoicer ) then begin FInvoicer.Free; FInvoicer := nil; end;
if Assigned(FShipTo ) then begin FShipTo.Free; FShipTo := nil; end;
if Assigned(FPayee ) then begin FPayee.Free; FPayee := nil; end;
if Assigned(FShipFrom ) then begin FShipFrom.Free; FShipFrom := nil; end;
if Assigned(FNotes ) then begin FNotes.Free; FNotes := nil; end;
if Assigned(FTradeLineItems ) then begin FTradeLineItems.Free; FTradeLineItems := nil; end;
if Assigned(FTaxes ) then begin FTaxes.Free; FTaxes := nil; end;
if Assigned(FServiceCharges ) then begin FServiceCharges.Free; FServiceCharges := nil; end;
if Assigned(FTradeAllowanceCharges ) then begin FTradeAllowanceCharges.Free; FTradeAllowanceCharges := nil; end;
if Assigned(FPaymentTermsList ) then begin FPaymentTermsList.Free; FPaymentTermsList := nil; end;
if Assigned(FInvoiceReferencedDocuments ) then begin FInvoiceReferencedDocuments.Free; FInvoiceReferencedDocuments := nil; end;
if Assigned(FReceivableSpecifiedTradeAccountingAccounts) then begin FReceivableSpecifiedTradeAccountingAccounts.Free; FReceivableSpecifiedTradeAccountingAccounts := nil; end;
if Assigned(FCreditorBankAccounts ) then begin FCreditorBankAccounts.Free; FCreditorBankAccounts := nil; end;
if Assigned(FDebitorBankAccounts ) then begin FDebitorBankAccounts.Free; FDebitorBankAccounts := nil; end;
if Assigned(FPaymentMeans ) then begin FPaymentMeans.Free; FPaymentMeans := nil; end;
if Assigned(FSellerOrderReferencedDocument) then begin FSellerOrderReferencedDocument.Free; FSellerOrderReferencedDocument := nil; end;
inherited;
end;
class function TZUGFeRDInvoiceDescriptor.GetVersion(const filename: string): TZUGFeRDVersion;
var
reader: TZUGFeRDInvoiceDescriptorReader;
begin
reader := TZUGFeRDInvoiceDescriptor1Reader.Create;
try
if reader.IsReadableByThisReaderVersion(filename) then
begin
Result := TZUGFeRDVersion.Version1;
Exit;
end;
finally
reader.Free;
end;
reader := TZUGFeRDInvoiceDescriptor22UBLReader.Create;
try
if reader.IsReadableByThisReaderVersion(filename) then
begin
Result := TZUGFeRDVersion.Version23;
Exit;
end;
finally
reader.Free;
end;
reader := TZUGFeRDInvoiceDescriptor23CIIReader.Create;
try
if reader.IsReadableByThisReaderVersion(filename) then
begin
Result := TZUGFeRDVersion.Version23;
Exit;
end;
finally
reader.Free;
end;
reader := TZUGFeRDInvoiceDescriptor20Reader.Create;
try
if reader.IsReadableByThisReaderVersion(filename) then
begin
Result := TZUGFeRDVersion.Version20;
Exit;
end;
finally
reader.Free;
end;
raise TZUGFeRDUnsupportedException.Create('No ZUGFeRD invoice reader was able to parse this file "' + filename + '"!');
end;
class function TZUGFeRDInvoiceDescriptor.GetVersion(
const stream: TStream): TZUGFeRDVersion;
var
reader: TZUGFeRDInvoiceDescriptorReader;
begin
reader := TZUGFeRDInvoiceDescriptor1Reader.Create;
try
if reader.IsReadableByThisReaderVersion(stream) then
begin
Result := TZUGFeRDVersion.Version1;
Exit;
end;
finally
reader.Free;
end;
reader := TZUGFeRDInvoiceDescriptor22UBLReader.Create;
try
if reader.IsReadableByThisReaderVersion(stream) then
begin
Result := TZUGFeRDVersion.Version23;
Exit;
end;
finally
reader.Free;
end;