-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
intf.Invoice.pas
1368 lines (1200 loc) · 69.3 KB
/
intf.Invoice.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
{
License XRechnung-for-Delphi
Copyright (C) 2024 Landrix Software GmbH & Co. KG
Sven Harazim, [email protected]
Version 3.0.2
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
}
unit intf.Invoice;
interface
uses
System.SysUtils,System.Classes,System.Types,System.Contnrs
,System.NetEncoding
;
type
TInvoiceEmptyLeitwegID = class
public const
NON_EXISTENT = 'non-existent';
end;
TInvoiceTypeCode = (
itc_None,
///TypeCode: 84
itc_DebitnoteRelatedToFinancialAdjustments, // 84 - nicht in XRechnung verwenden
///TypeCode: 261
itc_SelfBilledCreditNote, // 261 - nicht in XRechnung verwenden
///TypeCode: 326 Teilrechnung (eigentlich: Teilschlussrechnung)
///Die Teilrechnung ist eine normale Rechnung mit der eine oder
///mehrere erbrachte Leistungsposten abgerechnet werden. Dies ist
///meisten der Fall bei laengeren Projekten oder z.B. gestaffelten
///Warenlieferungen. Im Gegensatz zu einer Abschlagsrechnung, die
///unabhaengig von der bereits erbrachten Leistung ist, werden mit
///einer Teilrechnung nur tatsaechlich erbrachte Leistungen abgerechnet
///mit allen damit verbundenen Gewaehrleistungspflichten.
itc_PartialInvoice, //326
///TypeCode: 380 Rechnung
///Dieser Typ beschreibt den Normalfall einer Waren- oder
///Handelsrechnung und ist der gebraeuchlichste Typ fuer die meisten
///Rechnungen.
itc_CommercialInvoice, //380
itc_DebitNote, // 383 Belastungsanzeige - nicht in XRechnung verwenden
///TypeCode: 384 Rechnungskorrektur
///Eine Rechnungskorrektur (oder auch Stornorechnung) wird erstellt,
///wenn eine Rechnung falsch erstellt wurde oder die Leistung nicht
///vollstaendig oder mangelhaft erbracht wurde und damit der
///Rechnungsbetrag reduziert werden muss. Eine Rechnungskorrektur
///muss sich dabei immer auf eine bereits erstellte Rechnung beziehen.
itc_CorrectedInvoice, //384
itc_PrepaymentInvoice, // 386 Vorauszahlungsrechnung - nicht in XRechnung verwenden
itc_Cancellation, // 457 Storno - nicht in XRechnung verwenden
///TypeCode: 389 Selbstfakturierte Rechnung
///Eine selbstfakturierte Rechnung wird vom Kunden ausgestellt.
///Der Lieferant erhaelt eine Rechnungskopie und die Zahlung von
///dem Kunde.
///Fuer die Abrechnung von Bauleistungen muessen gemaess Paragraph 14 und 16 VOB/B
///folgende Rechnungstypen verwendet werden.
itc_SelfbilledInvoice,
///TypeCode: 381 Gutschrift
///Eine Gutschrift ist steuerrechtlich eine Rechnung, die -im Gegensatz
///zur Rechnung- vom Leistungsempfaenger ausgestellt wird. Nicht zu
///verwechseln ist die Gutschrift mit einer Rechnungskorrektur die
///landlaeufig auch als Gutschrift bezeichnet wird.
///Die Gutschrift weist immer einen positiven Betrag aus.
itc_CreditNote,
///TypeCode: 875 Abschlagsrechnung (Bauleistung)
///Eine Abschlagsrechnung fuer Bauleistung. Eine Abschlagsrechnung
///hat nicht dieselbe Verbindlichkeit wie eine Teilschluss- oder
///Schlussrechnung.
itc_PartialConstructionInvoice,
///Typecode: 876 Teilschlussrechnung (Bauleistung)
///Eine Teilschlussrechnung hat denselben Charakter wie eine
///Schlussrechnung. Mit einer Teilschlussrechnung werden bereits
///geleistet Arbeiten im Rahmen einer Teilabnahme abgerechnet.
itc_PartialFinalConstructionInvoice,
///TypeCode: 877 Schlussrechnung (Bauleistung)
///Grundlage fuer die Schlussrechnung ist die Fertigstellung und die
///Abnahme der vereinbarten Leistungen zzgl. etwaiger Nachforderungen.
itc_FinalConstructionInvoice
);
//TODO pruefen, ob es noch mehr gibt
//https://www.xrepository.de/details/urn:xoev-de:xrechnung:codeliste:untdid.4461_2
TInvoicePaymentMeansCode = (
ipmc_NotImplemented,
ipmc_InstrumentNotDefined, //1 Keine Angaben
ipmc_InCash, //10 Barzahlung
ipmc_Cheque, //20 Scheck
ipmc_CreditTransfer, //30 Ueberweisung nicht SEPA (nicht SEPA)
ipmc_CreditCard, //54 Kreditkarte
ipmc_SEPACreditTransfer, //58 Ueberweisung (SEPA)
ipmc_SEPADirectDebit, //59 Lastschrift (SEPA)
ipmc_OnlinePaymentService, //68 Online Payment Service PayPal, etc.
ipmc_MutuallyDefined //ZZZ Gegenseitig definiert (PayPal, etc.)
);
TInvoicePaymentTermsType = (iptt_None,
iptt_Net,
iptt_CashDiscount1,
iptt_CashDiscount2);
TInvoiceUnitCode = (iuc_None //https://www.xrepository.de/details/urn:xoev-de:kosit:codeliste:rec20_1
,iuc_one //C62 A unit of count defining the number of pieces
,iuc_piece //H87
,iuc_flaterate //Pauschale
,iuc_number_of_articles
,iuc_set
,iuc_week
,iuc_month
,iuc_day
,iuc_tonne_metric_ton
,iuc_square_metre
,iuc_cubic_metre
,iuc_metre
,iuc_square_millimetre
,iuc_cubic_millimetre
,iuc_millimetre
,iuc_minute_unit_of_time
,iuc_second_unit_of_time
,iuc_litre
,iuc_hour
,iuc_gram
,iuc_kilogram
,iuc_kilometre
,iuc_kilowatt_hour
,iuc_percent
,iuc_packaging //Verpackung
);
//mehr Einheiten in Res\intf.Invoice.unusedUnits.pas
TInvoiceAttachmentType = (iat_application_None,
iat_application_pdf,
iat_image_png,
iat_image_jpeg,
iat_text_csv,
iat_application_vnd_openxmlformats_officedocument_spreadsheetml_sheet,
iat_application_vnd_oasis_opendocument_spreadsheet,
iat_application_xml //ab XRechnung 2.0.0
);
TInvoiceAttachmentTypeHelper = class(TObject)
public
class function GetTypeFromFilename(const _Filename : String): TInvoiceAttachmentType;
end;
//Der Code 916 "Referenzpapier" wird benutzt, um die Kennung der rechnungsbegründenden Unterlage zu referenzieren. (BT-122)
//Der Code 50 "Price/sales catalogue response" wird benutzt, um die Ausschreibung oder das Los zu referenzieren. (BT-17)
//Der Code 130 "Rechnungsdatenblatt" wird benutzt, um eine vom Verkäufer angegebene Kennung für ein Objekt zu referenzieren. (BT-18)
//https://www.xrepository.de/details/urn:xoev-de:kosit:codeliste:untdid.1001_4#version
TInvoiceAttachmentTypeCode = (iatc_None,
iatc_50,
iatc_130,
iatc_916);//Default
//Entweder externe Referenz oder eingebettetes Objekt
//Ob man die Daten als Base64 integriert oder separat mitliefert,
//haengt wahrscheinlich vom Empfaenger ab
//https://portal3.gefeg.com/projectdata/invoice/deliverables/installed/publishingproject/zugferd%202.1%20-%20facturx%201.0.05/en%2016931%20%E2%80%93%20facturx%201.0.05%20%E2%80%93%20zugferd%202.1%20-%20extended.scm/html/de/021.htm?https://portal3.gefeg.com/projectdata/invoice/deliverables/installed/publishingproject/zugferd%202.1%20-%20facturx%201.0.05/en%2016931%20%E2%80%93%20facturx%201.0.05%20%E2%80%93%20zugferd%202.1%20-%20extended.scm/html/de/02412.htm
TInvoiceAttachment = class(TObject)
public
ID : String;
DocumentDescription : String;
Filename : String;
TypeCode : TInvoiceAttachmentTypeCode;
AttachmentType : TInvoiceAttachmentType;
Data : TMemoryStream; //https://docs.peppol.eu/poacc/billing/3.0/syntax/ubl-invoice/cac-AdditionalDocumentReference/cac-Attachment/cbc-EmbeddedDocumentBinaryObject/
ExternalReference : String; // Gemaesss BMF-Schreiben vom 15.10.2024 sollen Links auf rechnungsbegruendende Unterlagen nicht verwendet werden. Sie sollen stattdessen in die XML-Datei eingebettet werden. Dies gilt ab dem 01.01.2025.
public
constructor Create(_AttachmentType : TInvoiceAttachmentType);
destructor Destroy; override;
procedure EmbedDataFromStream(_Stream : TStream);
procedure EmbedDataFromFile(const _Filename : String);
function GetDataAsBase64 : String;
procedure SetDataFromBase64(const _Val : String);
function ContainsBinaryObject : Boolean;
end;
TInvoiceAttachmentList = class(TObjectList)
protected
function GetItem(Index: Integer): TInvoiceAttachment;
procedure SetItem(Index: Integer; AItem: TInvoiceAttachment);
public
function Extract(Item: TObject): TInvoiceAttachment;
function First: TInvoiceAttachment;
function Last: TInvoiceAttachment;
property Items[Index: Integer]: TInvoiceAttachment read GetItem write SetItem; default;
public
function AddAttachment(_AttachmentType : TInvoiceAttachmentType) : TInvoiceAttachment;
function TryAddAttachmentByExtension(const _Filename : String; out _Attachment : TInvoiceAttachment) : Boolean;
end;
TInvoiceUnitCodeHelper = class(TObject)
public
class function MapUnitOfMeasure(_UnitOfMeasure : String; out _Success : Boolean; _DefaultOnFailure : TInvoiceUnitCode = TInvoiceUnitCode.iuc_piece) : TInvoiceUnitCode;
end;
//cbc:ChargeIndicator = false dann sind folgende Code erlaubt 41 42 60 62 63 64 65 66 67 68 70 71 88 95 100 102 103 104 105
//Keine anderen Codes in XRechnung moeglich !!!
//https://www.xrepository.de/details/urn:xoev-de:kosit:codeliste:untdid.5189_3
TInvoiceAllowanceOrChargeIdentCode = (
iacic_None,
//iacic_HandlingCommission, // Fee for the processing of documentary credit, collection and payment which are charged to the customer. '1';
//iacic_AmendmentCommission, // Fee for amendments in documentary credit and collection business (not extensions and increases of documentary credits). '2';
//iacic_AcceptanceCommission, // Fee for the acceptance of draft in documentary credit and collection business which are drawn on us (also to be seen as a kind of 'guarantee commission'). '3';
//iacic_CommissionForObtainingAcceptance, // Fee for obtaining an acceptance under collections on the basis of 'documents against acceptance'. '4';
//iacic_CommissionOnDelivery, // Fee for delivery of documents without corresponding payment. '5';
//iacic_AdvisingCommission, // Fee for advising documentary credits (charged also in case of confirmed credits). '6';
//iacic_ConfirmationCommission, // Fee for confirmation of credit. '7';
//iacic_DeferredPaymentCommission, // Fee for the deferred payment period under documentary credits confirmed by bank. This fee are charges for the period from presentation of the document until due date of payment. '8';
//iacic_CommissionForTakingUpDocuments, // Fee charged to the foreign bank for the processing of documentary credit. '9';
//iacic_OpeningCommission, // Fee for opening revocable documentary credit. '10';
//iacic_FeeForPaymentUnderReserve, // Fee charged to the customer for discrepancies in credit documents in the case of which the bank have to stipulate payment under reserve. '11';
//iacic_DiscrepancyFee, // Fee charged to the foreign bank for discrepancies in credit documents. '12';
//iacic_DomicilationCommission, // Fee for the domicilation of bills with the bank. '13';
//iacic_CommissionForReleaseOfGoods, // Commission for the release of goods sent to the bank. '14';
//iacic_CollectionCommission, // Fee for settling collections on the basis of 'documents against payments'. '15';
//iacic_NegotiationCommission, // Fee for the purchase of documents under sight credit for the first ten days. '16';
//iacic_ReturnCommission, // Fee for cheques, bills and collections returned unpaid and/or recalled. '17';
//iacic_BLSplittingCharges, // Fee for the splitting of bills of lading. '18';
//iacic_TrustCommission, // Fee for the handling on a fiduciary basis of imported goods that have been warehoused. '19';
//iacic_TransferCommission, // Fee for the transfer of transferable documentary credits. '20';
//iacic_CommissionForOpeningIrrevocableDocumentaryCredits, // Fee for opening irrevocable documentary credits. '21';
//iacic_PreadviceCommission, // Fee for the pre-advice of a documentary credit. '22';
//iacic_SupervisoryCommission, // Fee for the supervising unconfirmed documentary credits with a deferred payment period. '23';
//iacic_ModelCharges, // Fee for decoding telex messages. '24';
//iacic_RiskCommission, // Commission in addition to the confirmation commission for documentary credits from sensitive countries. '25';
//iacic_GuaranteeCommission, // Commission for drawing up guaranties. '26';
//iacic_ReimbursementCommission, // Fee for reimbursement of, for example, documentary credits. '27';
//iacic_StampDuty, // Tax payable on bills in accordance with national bill of exchange legislation. '28';
//iacic_Brokerage, // Brokers commission arising, in trade with foreign currencies. '29';
//iacic_BankCharges, // Charges deducted/claimed by other banks involved in the transaction. '30';
//iacic_BankChargesInformation, // Charges not included in the total charge amount i.e. the charges are for information only. '31';
//iacic_CourierFee, // Fee for use of courier service. '32';
//iacic_PhoneFee, // Fee for use of phone. '33';
//iacic_PostageFee, // Fee for postage. '34';
//iacic_SWIFTFee, // Fee for use of S.W.I.F.T. '35';
//iacic_TelexFee, // Fee for telex. '36';
//iacic_PenaltyForLateDeliveryOfDocuments, // Penalty imposed when documents are delivered late. '37';
//iacic_PenaltyForLateDeliveryOfValuationOfWorks, // Penalty imposed when valuation of works is delivered late. '38';
//iacic_PenaltyForExecutionOfWorksBehindSchedule, // Penalty imposed when the execution of works is behind schedule. '39';
//iacic_OtherPenalties, // Penalty imposed for other reasons. '40';
iacic_BonusForWorksAheadOfSchedule, // Bonus for completing work ahead of schedule. '41';
iacic_OtherBonus, // Bonus earned for other reasons. '42';
//iacic_ProjectManagementCost, // Cost for project management. '44';
//iacic_ProRataRetention, // Proportional retention charge. '45';
//iacic_ContractualRetention, // Contractual retention charge. '46';
//iacic_OtherRetentions, // Retention charge not otherwise specified. '47';
//iacic_InterestOnArrears, // Interest for late payment. '48';
//iacic_Interest, // Cost of using money. '49';
//iacic_ChargePerCreditCover, // Unit charge per credit cover established. '50';
//iacic_ChargePerUnusedCreditCover, // Unit charge per unused credit cover. '51';
//iacic_MinimumCommission, // Minimum commission charge. '52';
//iacic_FactoringCommission, // Commission charged for factoring services. '53';
//iacic_ChamberOfCommerceCharge, // Identifies the charges from the chamber of commerce. '54';
//iacic_TransferCharges, // Charges for transfer. '55';
//iacic_RepatriationCharges, // Charges for repatriation. '56';
//iacic_MiscellaneousCharges, // Not specifically defined charges. '57';
//iacic_ForeignExchangeCharges, // Charges for foreign exchange. '58';
//iacic_AgreedDebitInterestCharge, // Charge for agreed debit interest '59';
iacic_ManufacturersConsumerDiscount, // A discount given by the manufacturer which should be passed on to the consumer. '60';
//iacic_FaxAdviceCharge, // Charge for fax advice. '61';
iacic_DueToMilitaryStatus, // Allowance granted because of the military status. '62';
iacic_DueToWorkAccident, // Allowance granted to a victim of a work accident. '63';
iacic_SpecialAgreement, // An allowance or charge as specified in a special agreement. '64';
iacic_ProductionErrorDiscount, // A discount given for the purchase of a product with a production error. '65';
iacic_NewOutletDiscount, // A discount given at the occasion of the opening of a new outlet. '66';
iacic_SampleDiscount, // A discount given for the purchase of a sample of a product. '67';
iacic_EndOfRangeDiscount, // A discount given for the purchase of an end-of-range product. '68';
//iacic_ChargeForACustomerSpecificFinish, // A charge for the addition of a customer specific finish to a product. '69';
iacic_IncotermDiscount, // A discount given for a specified Incoterm. '70';
iacic_PointOfSalesThresholdAllowance, // Allowance for reaching or exceeding an agreed sales threshold at the point of sales. '71';
//iacic_TechnicalModificationCosts, // Costs for technical modifications to a product. '72';
//iacic_JoborderProductionCosts, // Costs of job-order production. '73';
//iacic_OffpremisesCosts, // Expenses for non-local activities. '74';
//iacic_AdditionalProcessingCosts, // Costs of additional processing. '75';
//iacic_AttestingCharge, // Costs of official attestation. '76';
//iacic_RushDeliverySurcharge, // Charge for increased delivery speed. '77';
//iacic_SpecialConstructionCosts, // Charge for costs incurred as result of special constructions. '78';
//iacic_FreightCharges, // Amount to be paid for moving goods, by whatever means, from one place to another. '79';
//iacic_PackingCharge, // Charge for packing. '80';
//iacic_RepairCharge, // Charge for repair. '81';
//iacic_LoadingCharge, // Charge for loading. '82';
//iacic_SetupCharge, // Charge for setup. '83';
//iacic_TestingCharge, // Charge for testing. '84';
//iacic_WarehousingCharge, // Charge for storage and handling. '85';
//iacic_GoldSurcharge, // Difference between current price and basic value contained in product price in relation to gold content. '86';
//iacic_CopperSurcharge, // Difference between current price and basic value contained in product price in relation to copper content. '87';
iacic_MaterialSurchargeDeduction, // Surcharge/deduction, calculated for higher/ lower material's consumption. '88';
//iacic_LeadSurcharge, // Difference between current price and basic value contained in product price in relation to lead content. '89';
//iacic_PriceIndexSurcharge, // Higher/lower price, resulting from change in costs between the times of making offer and delivery. '90';
//iacic_PlatinumSurcharge, // Difference between current price and basic value contained in product price in relation to platinum content. '91';
//iacic_SilverSurcharge, // Difference between current price and basic value contained in product price in relation to silver content. '92';
//iacic_WolframSurcharge, // Difference between current price and basic value contained in product price in relation to wolfram content. '93';
//iacic_AluminumSurcharge, // Difference between current price and basic value contained in product price in relation to aluminum content. '94';
iacic_Discount, // A reduction from a usual or list price. '95';
//iacic_Insurance, // Charge for insurance. '96';
//iacic_MinimumOrderMinimumBillingCharge, // Charge for minimum order or minimum billing. '97';
//iacic_MaterialSurchargeSspecialMaterials, // Surcharge for (special) materials. '98';
//iacic_Surcharge, // An additional amount added to the usual charge. '99';
iacic_SpecialRebate, // A return of part of an amount paid for goods or services, serving as a reduction or discount. '100';
//iacic_CarbonFootprintCharge, // A monetary amount charged for carbon footprint related to a regulatory requirement. '101';
iacic_FixedLongTerm, // A fixed long term allowance or charge. '102';
iacic_Temporary, // A temporary allowance or charge. '103';
iacic_Standard, // The standard available allowance or charge. '104';
iacic_YearlyTurnover // An allowance or charge based on yearly turnover. '105';
//iacic_WithheldTaxesAndSocialSecurityContributions// The amount of taxes and contributions for social security, that is subtracted from the payable amount as it is to be paid separately. '106';
);
//cbc:ChargeIndicator = true
//https://www.xrepository.de/details/urn:xoev-de:kosit:codeliste:untdid.7161_3
TInvoiceSpecialServiceDescriptionCode = (issdc_None,
issdc_AA_Advertising, //The service of providing advertising.
issdc_AAA_Telecommunication, //The service of providing telecommunication activities and/or faclities.
issdc_ABK_Miscellaneous, //Miscellaneous services.
issdc_ABL_AdditionalPackaging, //The service of providing additional packaging.
issdc_ADR_OtherServices, //A code indicating that other non-specific services are in operation.
issdc_ADT_Pickup, //The service of picking up or collection of goods.
issdc_FC_FreightService, //The service of moving goods, by whatever means, from one place to another.
issdc_FI_Financing, //The service of providing financing.
issdc_LA_Labelling, //Labelling service.
issdc_PC_Packing //The service of packing.
);
//Nur ein Teil der Codes ist erlaubt
//Die Codes fuer die Umsatzsteuerkategorie sind Folgende:
//- S = Umsatzsteuer faellt mit Normalsatz an
//- Z = nach dem Nullsatz zu versteuernde Waren
//- E = Steuerbefreit
//- AE = Umkehrung der Steuerschuldnerschaft
//- K = Kein Ausweis der Umsatzsteuer bei innergemeinschaftlichen Lieferungen
//- G = Steuer nicht erhoben aufgrund von Export ausserhalb der EU
//Bei gewerblichen Endkunden im Reverse-Charge ist hier "AE" anzugeben.
TInvoiceDutyTaxFeeCategoryCode = (idtfcc_None, //https://www.xrepository.de/details/urn:xoev-de:kosit:codeliste:untdid.5305_2
//idtfcc_A_MixedTaxRate, // Code specifying that the rate is based on mixed tax.
//idtfcc_AA_LowerRate, // Tax rate is lower than standard rate.
//idtfcc_AB_ExemptForResale, // A tax category code indicating the item is tax exempt when the item is bought for future resale.
//idtfcc_AC_ValueAddedTaxVATNotNowDueForPayment, // A code to indicate that the Value Added Tax (VAT) amount which is due on the current invoice is to be paid on receipt of a separate VAT payment request.
//idtfcc_AD_ValueAddedTaxVATDueFromAPreviousInvoice, // A code to indicate that the Value Added Tax (VAT) amount of a previous invoice is to be paid.
idtfcc_AE_VATReverseCharge, // Code specifying that the standard VAT rate is levied from the invoicee.
//idtfcc_B_TransferredVAT, // VAT not to be paid to the issuer of the invoice but directly to relevant tax authority.
//idtfcc_C_DutyPaidBySupplier, // Duty associated with shipment of goods is paid by the supplier; customer receives goods with duty paid.
//idtfcc_D_ValueAddedTaxVATMmarginSchemeTravelAgents, // Indication that the VAT margin scheme for travel agents is applied.
idtfcc_E_ExemptFromTax, // Code specifying that taxes are not applicable.
//idtfcc_F_ValueAddedTaxVATMmarginSchemeSecondhandGoods, // Indication that the VAT margin scheme for second-hand goods is applied.
idtfcc_G_FreeExportItemTaxNotCharged, // Code specifying that the item is free export and taxes are not charged.
//idtfcc_H_HigherRate, // Code specifying a higher rate of duty or tax or fee.
//idtfcc_I_ValueAddedTaxVATMarginSchemeWorksOfArt, // Margin scheme - Works of art Indication that the VAT margin scheme for works of art is applied.
//idtfcc_J_ValueAddedTaxVATMarginSchemeCollectorsItemsAndAntiques, // Indication that the VAT margin scheme for collector s items and antiques is applied.
idtfcc_K_VATExemptForEEAIntracommunitySupplyOfGoodsAndServices, // A tax category code indicating the item is VAT exempt due to an intra-community supply in the European Economic Area. Der Code K steht in der Hashtag#XRechnung für VAT exempt for EEA intra-community supply of goods and services also für die Umsatzsteuerbefreiung bei grenzüberschreitenden Lieferungen und Dienstleistungen innerhalb des Europäischen Wirtschaftsraums (Hashtag#EWR).
idtfcc_L_CanaryIslandsGeneralIndirectTax, // Impuesto General Indirecto Canario (IGIC) is an indirect tax levied on goods and services supplied in the Canary Islands (Spain) by traders and professionals, as well as on import of goods.
idtfcc_M_TaxForProductionServicesAndImportationInCeutaAndMelilla, // Impuesto sobre la Produccion, los Servicios y la Importacion (IPSI) is an indirect municipal tax, levied on the production, processing and import of all kinds of movable tangible property, the supply of services and the transfer of immovable property located in the cities of Ceuta and Melilla.
idtfcc_O_ServicesOutsideScopeOfTax, // Code specifying that taxes are not applicable to the services.
idtfcc_S_StandardRate, // Code specifying the standard rate.
idtfcc_Z_ZeroRatedGoods);
TInvoiceAllowanceCharge = class(TOBject)
public
ChargeIndicator : Boolean;
ReasonCodeAllowance : TInvoiceAllowanceOrChargeIdentCode;
ReasonCodeCharge : TInvoiceSpecialServiceDescriptionCode;
Reason : String;
BaseAmount : Currency;
MultiplierFactorNumeric : double;
Amount : Currency;
TaxPercent : double;
TaxCategory : TInvoiceDutyTaxFeeCategoryCode;
end;
TInvoiceAllowanceCharges = class(TObjectList)
protected
function GetItem(Index: Integer): TInvoiceAllowanceCharge;
procedure SetItem(Index: Integer; AItem: TInvoiceAllowanceCharge);
public
function Extract(Item: TObject): TInvoiceAllowanceCharge;
function First: TInvoiceAllowanceCharge;
function Last: TInvoiceAllowanceCharge;
property Items[Index: Integer]: TInvoiceAllowanceCharge read GetItem write SetItem; default;
public
function AddAllowanceCharge : TInvoiceAllowanceCharge;
end;
TInvoiceLines = class;
TInvoiceLineItemAttribute = class(TObject)
public
Name : String; //BT-160
Value : String; //BT-161
end;
TInvoiceLineItemAttributes = class(TObjectList)
protected
function GetItem(Index: Integer): TInvoiceLineItemAttribute;
procedure SetItem(Index: Integer; AItem: TInvoiceLineItemAttribute);
public
function Extract(Item: TObject): TInvoiceLineItemAttribute;
function First: TInvoiceLineItemAttribute;
function Last: TInvoiceLineItemAttribute;
property Items[Index: Integer]: TInvoiceLineItemAttribute read GetItem write SetItem; default;
public
function AddItemAttribute : TInvoiceLineItemAttribute;
end;
TInvoiceLine = class(TObject)
public
ID : String; //Positionsnummer
GlobalID_EAN_GTIN: String; //BT-157 GTIN/EAN
Note : String; //Hinweis
Name : String; //Kurztext
Description : String; //Laengere Beschreibung
Quantity : double; //Menge
UnitCode : TInvoiceUnitCode; //Mengeneinheit
SellersItemIdentification : String; //Artikelnummer
TaxPercent : double; //MwSt
TaxCategory : TInvoiceDutyTaxFeeCategoryCode; //MwSt-Einordnung
GrossPriceAmount : Currency; //Brutto-Einzelpreis
DiscountOnTheGrossPrice : Currency; //Rabatt auf den Bruttopreis ergibt Nettopreis, nur ein Rabatt moeglich wegen UBL, obwohl CII mehrere erlaubt
NetPriceAmount : Currency; //Netto-Einzelpreis
BaseQuantity : double; //Preiseinheit
BaseQuantityUnitCode : TInvoiceUnitCode; //Preiseinheit Mengeneinheit
LineAmount : Currency;
AllowanceCharges : TInvoiceAllowanceCharges;
SubInvoiceLines : TInvoiceLines;
ItemAttributes : TInvoiceLineItemAttributes;
InvoiceLinePeriodStartDate : TDate; //Leistungszeitraum Beginn
InvoiceLinePeriodEndDate : TDate; //Leistungszeitraum Ende
public
constructor Create;
destructor Destroy; override;
end;
TInvoiceLines = class(TObjectList)
protected
function GetItem(Index: Integer): TInvoiceLine;
procedure SetItem(Index: Integer; AItem: TInvoiceLine);
public
function Extract(Item: TObject): TInvoiceLine;
function First: TInvoiceLine;
function Last: TInvoiceLine;
property Items[Index: Integer]: TInvoiceLine read GetItem write SetItem; default;
public
function AddInvoiceLine : TInvoiceLine;
end;
TInvoiceTaxAmount = class(TObject)
public
TaxableAmount : Currency;
TaxAmount : Currency;
TaxPercent : double;
TaxCategory : TInvoiceDutyTaxFeeCategoryCode;
TaxExemptionReason : String; //sollte gesetzt werden bei TaxCategory = AE,E,O,Z
public
constructor Create;
end;
TInvoiceTaxAmounts = class(TObjectList)
protected
function GetItem(Index: Integer): TInvoiceTaxAmount;
procedure SetItem(Index: Integer; AItem: TInvoiceTaxAmount);
public
function Extract(Item: TObject): TInvoiceTaxAmount;
function First: TInvoiceTaxAmount;
function Last: TInvoiceTaxAmount;
property Items[Index: Integer]: TInvoiceTaxAmount read GetItem write SetItem; default;
public
function AddTaxAmountIfTaxExists(_TaxPercent : double; _TaxableAmount,_TaxAmount : Currency) : Boolean;
function AddTaxAmount : TInvoiceTaxAmount;
end;
TInvoiceAddress = class(TObject)
public
StreetName : String;
AdditionalStreetName : String;
City : String;
PostalZone : String;
CountrySubentity : String;
AddressLine : String;
CountryCode : String;
end;
TInvoiceAccountingParty = class(TObject)
public
Name : String;
RegistrationName : String;
CompanyID : String; //BT-30
Address : TInvoiceAddress;
IdentifierSellerBuyer : String; //BT-29 Kreditor-Nr AccountingSupplierParty / Debitor-Nr AccountingCustomerParty
BankAssignedCreditorIdentifier : String; //Glaeubiger-ID (BT-90)
VATCompanyID : String; //BT-31 UStID
VATCompanyNumber: String;//BT-32 Steuernummer
ContactName : String;
ContactTelephone : String;
ContactElectronicMail : String;
AdditionalLegalInformationSeller : String; //BT-33 Weitere rechtliche Informationen zum Verkaeufer
ElectronicAddressSellerBuyer : String; //BT-34, BT-49 Pflicht
public
constructor Create;
destructor Destroy; override;
end;
TInvoiceDeliveryInformation = class(TObject)
public
Name : String;
//LocationIdentifier : String; //optional Ein Bezeichner fuer den Ort, an den die Waren geliefert oder an dem die Dienstleistungen erbracht werden.
Address : TInvoiceAddress;
ActualDeliveryDate : TDate; //Lieferdatum
public
constructor Create;
destructor Destroy; override;
end;
TInvoicePrecedingInvoiceReference = class(TObject)
public
ID : String;
IssueDate : TDate;
end;
TInvoicePrecedingInvoiceReferences = class(TObjectList)
protected
function GetItem(Index: Integer): TInvoicePrecedingInvoiceReference;
procedure SetItem(Index: Integer; AItem: TInvoicePrecedingInvoiceReference);
public
function Extract(Item: TObject): TInvoicePrecedingInvoiceReference;
function First: TInvoicePrecedingInvoiceReference;
function Last: TInvoicePrecedingInvoiceReference;
property Items[Index: Integer]: TInvoicePrecedingInvoiceReference read GetItem write SetItem; default;
public
function AddPrecedingInvoiceReference : TInvoicePrecedingInvoiceReference;
function IndexOfPrecedingInvoiceReference(const _ID : String) : Integer;
end;
//Auswahl aus https://www.xrepository.de/details/urn:xoev-de:kosit:codeliste:untdid.4451_4#version
TInvoiceNoteSubjectCode = (
insc_None, //Freitext
insc_AAI, //Allgemeine Informationen
insc_AAJ, //Zusaetzliche Konditionen zum Kauf - Der Verkaeufer bleibt Eigentuemer der Waren bis zur vollstaendigen Erfuellung der Kaufpreisforderung.
insc_AAK, //Preiskonditionen Informationen zu den erwarteten bzw. gegebenen Preiskonditionen. Es bestehen Rabatt- oder Bonusvereinbarungen.
insc_SUR, //Anmerkungen des Verkaeufers
insc_REG, //Regulatorische Informationen
insc_ABL, //Rechtliche Informationen
insc_TXD, //Informationen zur Steuer
insc_CUS, //Zollinformationen
insc_PMT //Payment Information Bürgschaften oder Sicherheitseinbehalte
);
TInvoiceNote = class(Tobject)
public
Content : String;
SubjectCode : TInvoiceNoteSubjectCode;
public
constructor Create;
end;
TInvoiceNotes = class(TObjectList)
protected
function GetItem(Index: Integer): TInvoiceNote;
procedure SetItem(Index: Integer; AItem: TInvoiceNote);
public
function Extract(Item: TObject): TInvoiceNote;
function First: TInvoiceNote;
function Last: TInvoiceNote;
property Items[Index: Integer]: TInvoiceNote read GetItem write SetItem; default;
public
function AddNote: TInvoiceNote;
function NodeContentsAsText : String;
procedure ReplaceContentWith(_Content : String);
end;
TInvoicePaymentType = class(TObject)
public
PaymentMeansCode : TInvoicePaymentMeansCode;
PaymentMeansInformation : String;
FinancialAccount : String; //sowohl Payee (Ueberweisung 58) als auch Payer (Lastschrift 59) oder CreditCard
FinancialAccountName : String; //sowohl Payee (Ueberweisung 58) als auch Payer (Lastschrift 59) oder CreditCard Holder
FinancialInstitutionBranch : String; //BIC sowohl Payee (Ueberweisung 58) als auch Payer (Lastschrift 59)
public
constructor Create;
end;
TInvoicePaymentTypeList = class(TObjectList)
protected
function GetItem(Index: Integer): TInvoicePaymentType;
procedure SetItem(Index: Integer; AItem: TInvoicePaymentType);
public
function Extract(Item: TObject): TInvoicePaymentType;
function First: TInvoicePaymentType;
function Last: TInvoicePaymentType;
function AddPaymentType : TInvoicePaymentType;
property Items[Index: Integer]: TInvoicePaymentType read GetItem write SetItem; default;
end;
TInvoice = class(TObject)
public
InvoiceNumber : String; //Rechnungsnummer
InvoiceIssueDate : TDate; //Rechnungsdatum
InvoiceDueDate : TDate; //Faelligkeitsdatum
InvoicePeriodStartDate : TDate; //Leistungszeitraum Beginn
InvoicePeriodEndDate : TDate; //Leistungszeitraum Ende
InvoiceTypeCode : TInvoiceTypeCode;
InvoiceCurrencyCode : String; //EUR
TaxCurrencyCode : String; //EUR
BuyerReference : String; //Pflicht - Leitweg-ID - https://leitweg-id.de/home/ wird vom Rechnungsempfaenger dem Rechnungsersteller zur Verfuegung gestellt
Notes : TInvoiceNotes; //Hinweise zur Rechnung allgemein
SellerOrderReference : String; //Auftragsnummer der Verkaeufers
PurchaseOrderReference : String; //Bestellnummer oder Vertragsnummer des Kaeufers
ProjectReference : String;
ContractDocumentReference : String;
DeliveryReceiptNumber : String; //Lieferscheinnummer (Lieferscheindatum fehlt und wuerde nur in ZUGFeRD unterstuetzt)
AccountingSupplierParty : TInvoiceAccountingParty;
AccountingCustomerParty : TInvoiceAccountingParty;
DeliveryInformation : TInvoiceDeliveryInformation;
PaymentID : String; //Verwendungszweck der Ueberweisung/Lastschrift
PaymentTypes : TInvoicePaymentTypeList; //Zahlungswege
PaymentMandateID : String; //Lastschrift (59) Mandatsreferenz BT-89 !!Nur eine pro Rechnung moeglich
//Infos unter
//https://www.e-rechnung-bund.de/wp-content/uploads/2023/04/Angabe-Skonto-Upload.pdf
PaymentTermsType : TInvoicePaymentTermsType;
PaymentTermNetNote : String;
PaymentTermCashDiscount1Days : Integer;
PaymentTermCashDiscount1Percent : double;
PaymentTermCashDiscount1Base : Currency; //Anderer Betrag als der Rechnungsbetrag
PaymentTermCashDiscount2Days : Integer;
PaymentTermCashDiscount2Percent : double;
PaymentTermCashDiscount2Base : Currency; //Anderer Betrag als der Rechnungsbetrag
InvoiceLines : TInvoiceLines;
Attachments : TInvoiceAttachmentList; //BG-24
AllowanceCharges : TInvoiceAllowanceCharges; //Nachlaesse, Zuschlaege
PrecedingInvoiceReferences : TInvoicePrecedingInvoiceReferences;
TaxAmountTotal : Currency;
TaxAmountSubtotals : TInvoiceTaxAmounts;
LineAmount : Currency;
TaxExclusiveAmount : Currency;
TaxInclusiveAmount : Currency;
AllowanceTotalAmount : Currency;
ChargeTotalAmount : Currency;
PrepaidAmount : Currency;
PayableRoundingAmount : Currency; //BT-114
PayableAmount : Currency;
public
constructor Create;
destructor Destroy; override;
procedure Clear;
end;
implementation
{ TInvoice }
constructor TInvoice.Create;
begin
PaymentTypes := TInvoicePaymentTypeList.Create;
InvoiceLines := TInvoiceLines.Create;
Attachments := TInvoiceAttachmentList.Create;
AllowanceCharges := TInvoiceAllowanceCharges.Create;
PrecedingInvoiceReferences := TInvoicePrecedingInvoiceReferences.Create;
TaxAmountSubtotals := TInvoiceTaxAmounts.Create;
Notes := TInvoiceNotes.Create;
AccountingSupplierParty := TInvoiceAccountingParty.Create;
AccountingCustomerParty := TInvoiceAccountingParty.Create;
DeliveryInformation := TInvoiceDeliveryInformation.Create;
PaymentTermsType := iptt_None;
Clear;
end;
destructor TInvoice.Destroy;
begin
if Assigned(PaymentTypes) then begin PaymentTypes.Free; PaymentTypes := nil; end;
if Assigned(InvoiceLines) then begin InvoiceLines.Free; InvoiceLines := nil; end;
if Assigned(Attachments) then begin Attachments.Free; Attachments := nil; end;
if Assigned(AllowanceCharges) then begin AllowanceCharges.Free; AllowanceCharges := nil; end;
if Assigned(PrecedingInvoiceReferences) then begin PrecedingInvoiceReferences.Free; PrecedingInvoiceReferences := nil; end;
if Assigned(TaxAmountSubtotals) then begin TaxAmountSubtotals.Free; TaxAmountSubtotals := nil; end;
if Assigned(Notes) then begin Notes.Free; Notes := nil; end;
if Assigned(AccountingSupplierParty) then begin AccountingSupplierParty.Free; AccountingSupplierParty := nil; end;
if Assigned(AccountingCustomerParty) then begin AccountingCustomerParty.Free; AccountingCustomerParty := nil; end;
if Assigned(DeliveryInformation) then begin DeliveryInformation.Free; DeliveryInformation := nil; end;
inherited;
end;
procedure TInvoice.Clear;
begin
InvoiceLines.Clear;
AllowanceCharges.Clear;
PrecedingInvoiceReferences.Clear;
Notes.Clear;
TaxAmountSubtotals.Clear;
PaymentTermsType := iptt_None;
LineAmount := 0;
TaxExclusiveAmount := 0;
TaxInclusiveAmount := 0;
AllowanceTotalAmount := 0;
ChargeTotalAmount := 0;
PrepaidAmount := 0;
PayableRoundingAmount := 0;
PayableAmount := 0;
end;
{ TInvoiceLines }
function TInvoiceLines.Extract(Item: TObject): TInvoiceLine;
begin Result := TInvoiceLine(inherited Extract(Item)); end;
function TInvoiceLines.First: TInvoiceLine;
begin if Count = 0 then Result := nil else Result := TInvoiceLine(inherited First); end;
function TInvoiceLines.GetItem(Index: Integer): TInvoiceLine;
begin Result := TInvoiceLine(inherited Items[Index]); end;
function TInvoiceLines.Last: TInvoiceLine;
begin if Count = 0 then Result := nil else Result := TInvoiceLine(inherited Last); end;
procedure TInvoiceLines.SetItem(Index: Integer; AItem: TInvoiceLine);
begin inherited Items[Index] := AItem; end;
function TInvoiceLines.AddInvoiceLine: TInvoiceLine;
begin
Result := TInvoiceLine.Create;
Add(Result);
end;
{ TInvoiceAllowanceCharges }
function TInvoiceAllowanceCharges.Extract(Item: TObject): TInvoiceAllowanceCharge;
begin Result := TInvoiceAllowanceCharge(inherited Extract(Item)); end;
function TInvoiceAllowanceCharges.First: TInvoiceAllowanceCharge;
begin if Count = 0 then Result := nil else Result := TInvoiceAllowanceCharge(inherited First); end;
function TInvoiceAllowanceCharges.GetItem(Index: Integer): TInvoiceAllowanceCharge;
begin Result := TInvoiceAllowanceCharge(inherited Items[Index]); end;
function TInvoiceAllowanceCharges.Last: TInvoiceAllowanceCharge;
begin if Count = 0 then Result := nil else Result := TInvoiceAllowanceCharge(inherited Last); end;
procedure TInvoiceAllowanceCharges.SetItem(Index: Integer; AItem: TInvoiceAllowanceCharge);
begin inherited Items[Index] := AItem; end;
function TInvoiceAllowanceCharges.AddAllowanceCharge: TInvoiceAllowanceCharge;
begin
Result := TInvoiceAllowanceCharge.Create;
Add(Result);
end;
{ TInvoicePrecedingInvoiceReferences }
function TInvoicePrecedingInvoiceReferences.Extract(Item: TObject): TInvoicePrecedingInvoiceReference;
begin Result := TInvoicePrecedingInvoiceReference(inherited Extract(Item)); end;
function TInvoicePrecedingInvoiceReferences.First: TInvoicePrecedingInvoiceReference;
begin if Count = 0 then Result := nil else Result := TInvoicePrecedingInvoiceReference(inherited First); end;
function TInvoicePrecedingInvoiceReferences.GetItem(Index: Integer): TInvoicePrecedingInvoiceReference;
begin Result := TInvoicePrecedingInvoiceReference(inherited Items[Index]); end;
function TInvoicePrecedingInvoiceReferences.Last: TInvoicePrecedingInvoiceReference;
begin if Count = 0 then Result := nil else Result := TInvoicePrecedingInvoiceReference(inherited Last); end;
procedure TInvoicePrecedingInvoiceReferences.SetItem(Index: Integer; AItem: TInvoicePrecedingInvoiceReference);
begin inherited Items[Index] := AItem; end;
function TInvoicePrecedingInvoiceReferences.AddPrecedingInvoiceReference: TInvoicePrecedingInvoiceReference;
begin
Result := TInvoicePrecedingInvoiceReference.Create;
Add(Result);
end;
function TInvoicePrecedingInvoiceReferences.IndexOfPrecedingInvoiceReference(
const _ID: String): Integer;
var
i : Integer;
begin
Result := -1;
for i := 0 to Count-1 do
if SameText(_ID,Items[i].ID) then
begin
Result := i;
break;
end;
end;
{ TInvoiceNote }
constructor TInvoiceNote.Create;
begin
Content := '';
SubjectCode := insc_None;
end;
{ TInvoiceNotes }
function TInvoiceNotes.Extract(Item: TObject): TInvoiceNote;
begin Result := TInvoiceNote(inherited Extract(Item)); end;
function TInvoiceNotes.First: TInvoiceNote;
begin if Count = 0 then Result := nil else Result := TInvoiceNote(inherited First); end;
function TInvoiceNotes.GetItem(Index: Integer): TInvoiceNote;
begin Result := TInvoiceNote(inherited Items[Index]); end;
function TInvoiceNotes.Last: TInvoiceNote;
begin if Count = 0 then Result := nil else Result := TInvoiceNote(inherited Last); end;
procedure TInvoiceNotes.SetItem(Index: Integer; AItem: TInvoiceNote);
begin inherited Items[Index] := AItem; end;
function TInvoiceNotes.AddNote: TInvoiceNote;
begin
Result := TInvoiceNote.Create;
Add(Result);
end;
function TInvoiceNotes.NodeContentsAsText: String;
var
i : Integer;
begin
Result := '';
for i := 0 to Count-1 do
begin
Result := Result + Items[i].Content;
if i < Count-1 then
Result := Result + #13#10;
end;
end;
procedure TInvoiceNotes.ReplaceContentWith(_Content: String);
begin
Clear;
if _Content <> '' then
AddNote.Content := _Content;
end;
{ TInvoiceLine }
constructor TInvoiceLine.Create;
begin
ID := '';
GlobalID_EAN_GTIN := '';
Note := '';
Name := '';
Description := '';
Quantity := 0;
UnitCode := iuc_None;
SellersItemIdentification := '';
TaxPercent := 0;
TaxCategory := idtfcc_None;
GrossPriceAmount := 0;
DiscountOnTheGrossPrice := 0;
NetPriceAmount := 0;
BaseQuantity := 0;
BaseQuantityUnitCode := iuc_None;
LineAmount := 0;
AllowanceCharges := TInvoiceAllowanceCharges.Create;
SubInvoiceLines := TInvoiceLines.Create;
ItemAttributes := TInvoiceLineItemAttributes.Create;
InvoiceLinePeriodStartDate := 0;
InvoiceLinePeriodEndDate := 0;
end;
destructor TInvoiceLine.Destroy;
begin
if Assigned(AllowanceCharges) then begin AllowanceCharges.Free; AllowanceCharges := nil; end;
if Assigned(SubInvoiceLines) then begin SubInvoiceLines.Free; SubInvoiceLines := nil; end;
if Assigned(ItemAttributes) then begin ItemAttributes.Free; ItemAttributes := nil; end;
inherited;
end;
{ TInvoiceUnitCodeHelper }
class function TInvoiceUnitCodeHelper.MapUnitOfMeasure(_UnitOfMeasure: String; out _Success: Boolean;
_DefaultOnFailure: TInvoiceUnitCode): TInvoiceUnitCode;
begin
//https://apps.datev.de/help-center/documents/1020477
Result := _DefaultOnFailure;
_Success := false;
_UnitOfMeasure := Trim(_UnitOfMeasure);
if _UnitOfMeasure = '' then
exit;
if SameText(_UnitOfMeasure,'st') or
SameText(_UnitOfMeasure,'st.') or
SameText(_UnitOfMeasure,'stk.') or
SameText(_UnitOfMeasure,'stk') or
SameText(_UnitOfMeasure,'C62') or
SameText(_UnitOfMeasure,'stck') then
begin
Result := iuc_piece;
_Success := true;
exit;
end;
if SameText(_UnitOfMeasure,'Pauschale') or
SameText(_UnitOfMeasure,'psch') or
SameText(_UnitOfMeasure,'psch.') or
SameText(_UnitOfMeasure,'pschl') or
SameText(_UnitOfMeasure,'pschl.') then
begin
Result := iuc_flaterate;
_Success := true;
exit;
end;
if SameText(_UnitOfMeasure,'mal') then
begin
Result := iuc_one;
_Success := true;
exit;
end;
if SameText(_UnitOfMeasure,'std') or
SameText(_UnitOfMeasure,'std.') or
SameText(_UnitOfMeasure,'h') then
begin
Result := iuc_hour;
_Success := true;
exit;
end;
if SameText(_UnitOfMeasure,'tag') or SameText(_UnitOfMeasure,'tage') then
begin
Result := iuc_day;
_Success := true;
exit;
end;
if SameText(_UnitOfMeasure,'monat') then
begin
Result := iuc_month;
_Success := true;
exit;
end;
if SameText(_UnitOfMeasure,'%') then
begin
Result := iuc_percent;
_Success := true;
exit;
end;
if SameText(_UnitOfMeasure,'woche') then
begin
Result := iuc_week;
_Success := true;
exit;
end;
if SameText(_UnitOfMeasure,'g') or
SameText(_UnitOfMeasure,'Gramm') then
begin
Result := iuc_gram;
_Success := true;
exit;
end;
if SameText(_UnitOfMeasure,'kg') then
begin
Result := iuc_kilogram;
_Success := true;
exit;
end;
if SameText(_UnitOfMeasure,'km') then
begin
Result := iuc_kilometre;
_Success := true;
exit;
end;
if SameText(_UnitOfMeasure,'kwh') then
begin
Result := iuc_kilowatt_hour;
_Success := true;