From e26b867459232e1e2abfc2a481c76b291b502e97 Mon Sep 17 00:00:00 2001 From: Sven Harazim Date: Fri, 20 Nov 2020 09:26:56 +0100 Subject: [PATCH] DeliveryInformation added --- Samples/XRechnungUnit1.dfm | 12 +++++-- Samples/XRechnungUnit1.pas | 73 ++++++++++++++++++++++++-------------- intf.Invoice.pas | 29 +++++++++++---- intf.XRechnung.pas | 58 +++++++++++++++++++++++++----- 4 files changed, 129 insertions(+), 43 deletions(-) diff --git a/Samples/XRechnungUnit1.dfm b/Samples/XRechnungUnit1.dfm index 324dfbb..26ed57e 100644 --- a/Samples/XRechnungUnit1.dfm +++ b/Samples/XRechnungUnit1.dfm @@ -49,7 +49,7 @@ object Form1: TForm1 end object Button3: TButton Left = 8 - Top = 185 + Top = 208 Width = 129 Height = 25 Caption = 'Erzeugen' @@ -174,6 +174,14 @@ object Form1: TForm1 Width = 97 Height = 17 Caption = 'Mit Anhaengen' - TabOrder = 19 + TabOrder = 13 + end + object cbDeliveriyInf: TCheckBox + Left = 8 + Top = 185 + Width = 97 + Height = 17 + Caption = 'Lieferanschrift' + TabOrder = 14 end end diff --git a/Samples/XRechnungUnit1.pas b/Samples/XRechnungUnit1.pas index b2bd31b..ebcec35 100644 --- a/Samples/XRechnungUnit1.pas +++ b/Samples/XRechnungUnit1.pas @@ -29,6 +29,7 @@ TForm1 = class(TForm) btX200ConvertHTML: TButton; Button1: TButton; cbAttachments: TCheckBox; + cbDeliveriyInf: TCheckBox; procedure Button3Click(Sender: TObject); procedure FormCreate(Sender: TObject); procedure Button4Click(Sender: TObject); @@ -128,10 +129,10 @@ procedure TForm1.Button1Click(Sender: TObject); inv.AccountingSupplierParty.Name := 'Verkaeufername'; inv.AccountingSupplierParty.RegistrationName := 'Verkaeufername'; //Sollte ausgefüllt werden inv.AccountingSupplierParty.CompanyID := ''; - inv.AccountingSupplierParty.StreetName := 'Verkaeuferstraße 1'; - inv.AccountingSupplierParty.City := 'Verkaeuferstadt'; - inv.AccountingSupplierParty.PostalZone := '01234'; - inv.AccountingSupplierParty.CountryCode := 'DE'; + inv.AccountingSupplierParty.Address.StreetName := 'Verkaeuferstraße 1'; + inv.AccountingSupplierParty.Address.City := 'Verkaeuferstadt'; + inv.AccountingSupplierParty.Address.PostalZone := '01234'; + inv.AccountingSupplierParty.Address.CountryCode := 'DE'; inv.AccountingSupplierParty.VATCompanyID := 'DE12345678'; //TODO mehrere Steuer-IDs inv.AccountingSupplierParty.ContactName := 'Meier'; inv.AccountingSupplierParty.ContactTelephone := '030 0815'; @@ -140,10 +141,10 @@ procedure TForm1.Button1Click(Sender: TObject); inv.AccountingCustomerParty.Name := 'Kaeufername'; inv.AccountingCustomerParty.RegistrationName := 'Kaeufername'; //Sollte ausgefüllt werden inv.AccountingCustomerParty.CompanyID := 'HRB 456'; - inv.AccountingCustomerParty.StreetName := 'Kaeuferstraße 1'; - inv.AccountingCustomerParty.City := 'Kaeuferstadt'; - inv.AccountingCustomerParty.PostalZone := '05678'; - inv.AccountingCustomerParty.CountryCode := 'DE'; + inv.AccountingCustomerParty.Address.StreetName := 'Kaeuferstraße 1'; + inv.AccountingCustomerParty.Address.City := 'Kaeuferstadt'; + inv.AccountingCustomerParty.Address.PostalZone := '05678'; + inv.AccountingCustomerParty.Address.CountryCode := 'DE'; inv.AccountingCustomerParty.VATCompanyID := 'DE12345678'; //TODO mehrere Steuer-IDs inv.AccountingCustomerParty.ContactName := 'Müller'; inv.AccountingCustomerParty.ContactTelephone := '030 1508'; @@ -215,9 +216,9 @@ procedure TForm1.Button3Click(Sender: TObject); inv := TInvoice.Create; inv.InvoiceNumber := 'R2020-0815'; inv.InvoiceIssueDate := Date; - inv.InvoiceDueDate := Date+30; - inv.InvoicePeriodStartDate := Date-30; - inv.InvoicePeriodEndDate := Date-1; + inv.InvoiceDueDate := Date+30; //Rechnungsdatum + inv.InvoicePeriodStartDate := Date-30; //Leistungs-/Lieferzeitpunkt Beginn + inv.InvoicePeriodEndDate := Date-1; //Leistungs-/Lieferzeitpunkt Ende inv.InvoiceTypeCode := TInvoiceTypeCode.itc_CommercialInvoice; //Schlussrechnung inv.InvoiceCurrencyCode := 'EUR'; inv.TaxCurrencyCode := 'EUR'; @@ -228,10 +229,13 @@ procedure TForm1.Button3Click(Sender: TObject); inv.AccountingSupplierParty.Name := 'Verkaeufername'; inv.AccountingSupplierParty.RegistrationName := 'Verkaeufername'; //Sollte ausgefuellt werden inv.AccountingSupplierParty.CompanyID := ''; - inv.AccountingSupplierParty.StreetName := 'Verkaeuferstraße 1'; - inv.AccountingSupplierParty.City := 'Verkaeuferstadt'; - inv.AccountingSupplierParty.PostalZone := '01234'; - inv.AccountingSupplierParty.CountryCode := 'DE'; + inv.AccountingSupplierParty.Address.StreetName := 'Verkaeuferstraße 1'; + inv.AccountingSupplierParty.Address.AdditionalStreetName := 'Hinterhaus'; //optional + inv.AccountingSupplierParty.Address.City := 'Verkaeuferstadt'; + inv.AccountingSupplierParty.Address.PostalZone := '01234'; + inv.AccountingSupplierParty.Address.CountrySubentity := 'Sachsen'; //optional + inv.AccountingSupplierParty.Address.AddressLine := 'Gate 64'; //optional + inv.AccountingSupplierParty.Address.CountryCode := 'DE'; inv.AccountingSupplierParty.VATCompanyID := 'DE12345678'; //TODO mehrere Steuer-IDs inv.AccountingSupplierParty.ContactName := 'Meier'; inv.AccountingSupplierParty.ContactTelephone := '030 0815'; @@ -240,15 +244,30 @@ procedure TForm1.Button3Click(Sender: TObject); inv.AccountingCustomerParty.Name := 'Kaeufername'; inv.AccountingCustomerParty.RegistrationName := 'Kaeufername'; //Sollte ausgefüllt werden inv.AccountingCustomerParty.CompanyID := 'HRB 456'; - inv.AccountingCustomerParty.StreetName := 'Kaeuferstraße 1'; - inv.AccountingCustomerParty.City := 'Kaeuferstadt'; - inv.AccountingCustomerParty.PostalZone := '05678'; - inv.AccountingCustomerParty.CountryCode := 'DE'; + inv.AccountingCustomerParty.Address.StreetName := 'Kaeuferstraße 1'; + inv.AccountingCustomerParty.Address.City := 'Kaeuferstadt'; + inv.AccountingCustomerParty.Address.PostalZone := '05678'; + inv.AccountingCustomerParty.Address.CountryCode := 'DE'; inv.AccountingCustomerParty.VATCompanyID := 'DE12345678'; //TODO mehrere Steuer-IDs inv.AccountingCustomerParty.ContactName := 'Müller'; inv.AccountingCustomerParty.ContactTelephone := '030 1508'; inv.AccountingCustomerParty.ContactElectronicMail := 'mueller@kunde.de'; + //Eine Gruppe von Informationselementen, die Informationen über die Anschrift liefern, an die + //die Waren geliefert oder an der die Dienstleistungen erbracht werden. Die Gruppe ist nur zu + //verwenden, wenn die Lieferanschrift von der Erwerberanschrift abweicht. Wenn die Waren + //abgeholt werden, ist die Abholadresse die Lieferadresse. Eine vollständige gültige Anschrift + //ist anzugeben. + if cbDeliveriyInf.Checked then + begin + inv.DeliveryInformation.Name := 'Firma die es bekommt'; + inv.DeliveryInformation.Address.StreetName := 'Lieferstraße 1'; + inv.DeliveryInformation.Address.City := 'Lieferstadt'; + inv.DeliveryInformation.Address.PostalZone := '05678'; + inv.DeliveryInformation.Address.CountryCode := 'DE'; + inv.DeliveryInformation.ActualDeliveryDate := Date-1; + end; + inv.PaymentMeansCode := ipmc_SEPACreditTransfer; //Ueberweisung inv.PaymentID := 'Verwendungszweck der Ueberweisung...R2020-0815'; inv.PayeeFinancialAccount := 'DE75512108001245126199'; //dies ist eine nicht existerende aber valide IBAN als test dummy @@ -539,10 +558,10 @@ procedure TForm1.Button4Click(Sender: TObject); inv.AccountingSupplierParty.Name := 'Verkaeufername'; inv.AccountingSupplierParty.RegistrationName := 'Verkaeufername'; //Sollte ausgefüllt werden inv.AccountingSupplierParty.CompanyID := ''; - inv.AccountingSupplierParty.StreetName := 'Verkaeuferstraße 1'; - inv.AccountingSupplierParty.City := 'Verkaeuferstadt'; - inv.AccountingSupplierParty.PostalZone := '01234'; - inv.AccountingSupplierParty.CountryCode := 'DE'; + inv.AccountingSupplierParty.Address.StreetName := 'Verkaeuferstraße 1'; + inv.AccountingSupplierParty.Address.City := 'Verkaeuferstadt'; + inv.AccountingSupplierParty.Address.PostalZone := '01234'; + inv.AccountingSupplierParty.Address.CountryCode := 'DE'; inv.AccountingSupplierParty.VATCompanyID := 'DE12345678'; //TODO mehrere Steuer-IDs inv.AccountingSupplierParty.ContactName := 'Meier'; inv.AccountingSupplierParty.ContactTelephone := '030 0815'; @@ -551,10 +570,10 @@ procedure TForm1.Button4Click(Sender: TObject); inv.AccountingCustomerParty.Name := 'Kaeufername'; inv.AccountingCustomerParty.RegistrationName := 'Kaeufername'; //Sollte ausgefüllt werden inv.AccountingCustomerParty.CompanyID := 'HRB 456'; - inv.AccountingCustomerParty.StreetName := 'Kaeuferstraße 1'; - inv.AccountingCustomerParty.City := 'Kaeuferstadt'; - inv.AccountingCustomerParty.PostalZone := '05678'; - inv.AccountingCustomerParty.CountryCode := 'DE'; + inv.AccountingCustomerParty.Address.StreetName := 'Kaeuferstraße 1'; + inv.AccountingCustomerParty.Address.City := 'Kaeuferstadt'; + inv.AccountingCustomerParty.Address.PostalZone := '05678'; + inv.AccountingCustomerParty.Address.CountryCode := 'DE'; inv.AccountingCustomerParty.VATCompanyID := 'DE12345678'; //TODO mehrere Steuer-IDs inv.AccountingCustomerParty.ContactName := 'Müller'; inv.AccountingCustomerParty.ContactTelephone := '030 1508'; diff --git a/intf.Invoice.pas b/intf.Invoice.pas index 25c5876..26227a9 100644 --- a/intf.Invoice.pas +++ b/intf.Invoice.pas @@ -3,6 +3,7 @@ Copyright (C) 2020 Landrix Software GmbH & Co. KG Sven Harazim, info@landrix.de +Version 1.1.0 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 @@ -313,17 +314,24 @@ TInvoiceTaxAmount = record TaxExemptionReason : String; //sollte gesetzt werden bei TaxCategory = AE,E,O,Z end; - TInvoiceAccountingParty = record + TInvoiceAddress = record public - Name : String; - RegistrationName : String; - CompanyID : String; StreetName : String; - //TODO 01129 + AdditionalStreetName : String; City : String; PostalZone : String; - //TODO Sachsen + CountrySubentity : String; + AddressLine : String; CountryCode : String; + end; + + TInvoiceAccountingParty = record + public + Name : String; + RegistrationName : String; + CompanyID : String; + + Address : TInvoiceAddress; IdentifierSellerBuyer : String; //Kreditor-Nr AccountingSupplierParty / Debitor-Nr AccountingCustomerParty @@ -334,6 +342,14 @@ TInvoiceAccountingParty = record ContactElectronicMail : String; end; + TInvoiceDeliveryInformation = record + public + Name : String; + LocationIdentifier : String; //optional Ein Bezeichner für den Ort, an den die Waren geliefert oder an dem die Dienstleistungen erbracht werden. + Address : TInvoiceAddress; + ActualDeliveryDate : TDate; //Lieferdatum + end; + TInvoicePrecedingInvoiceReference = class(TObject) public ID : String; @@ -362,6 +378,7 @@ TInvoice = class(TObject) AccountingSupplierParty : TInvoiceAccountingParty; AccountingCustomerParty : TInvoiceAccountingParty; + DeliveryInformation : TInvoiceDeliveryInformation; //TODO weitere Zahlungswege PaymentMeansCode : TInvoicePaymentMeansCode; diff --git a/intf.XRechnung.pas b/intf.XRechnung.pas index fc0dab6..f704590 100644 --- a/intf.XRechnung.pas +++ b/intf.XRechnung.pas @@ -3,6 +3,7 @@ Copyright (C) 2020 Landrix Software GmbH & Co. KG Sven Harazim, info@landrix.de +Version 1.1.0 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 @@ -364,10 +365,16 @@ class procedure TXRechnungInvoiceAdapter.SaveDocumentUBL(_Invoice: TInvoice; end; with AddChild('cac:PostalAddress') do begin - AddChild('cbc:StreetName').Text := _Invoice.AccountingSupplierParty.StreetName; - AddChild('cbc:CityName').Text := _Invoice.AccountingSupplierParty.City; - AddChild('cbc:PostalZone').Text := _Invoice.AccountingSupplierParty.PostalZone; - AddChild('cac:Country').AddChild('cbc:IdentificationCode').Text := _Invoice.AccountingSupplierParty.CountryCode; + AddChild('cbc:StreetName').Text := _Invoice.AccountingSupplierParty.Address.StreetName; + if not _Invoice.AccountingSupplierParty.Address.AdditionalStreetName.IsEmpty then + AddChild('cbc:AdditionalStreetName').Text := _Invoice.AccountingSupplierParty.Address.AdditionalStreetName; + AddChild('cbc:CityName').Text := _Invoice.AccountingSupplierParty.Address.City; + AddChild('cbc:PostalZone').Text := _Invoice.AccountingSupplierParty.Address.PostalZone; + if not _Invoice.AccountingSupplierParty.Address.CountrySubentity.IsEmpty then + AddChild('cbc:CountrySubentity').Text := _Invoice.AccountingSupplierParty.Address.CountrySubentity; + if not _Invoice.AccountingSupplierParty.Address.AddressLine.IsEmpty then + AddChild('cac:AddressLine').AddChild('cbc:Line').Text := _Invoice.AccountingSupplierParty.Address.AddressLine; + AddChild('cac:Country').AddChild('cbc:IdentificationCode').Text := _Invoice.AccountingSupplierParty.Address.CountryCode; end; if not _Invoice.AccountingSupplierParty.VATCompanyID.IsEmpty then with AddChild('cac:PartyTaxScheme') do @@ -401,10 +408,16 @@ class procedure TXRechnungInvoiceAdapter.SaveDocumentUBL(_Invoice: TInvoice; end; with AddChild('cac:PostalAddress') do begin - AddChild('cbc:StreetName').Text := _Invoice.AccountingCustomerParty.StreetName; - AddChild('cbc:CityName').Text := _Invoice.AccountingCustomerParty.City; - AddChild('cbc:PostalZone').Text := _Invoice.AccountingCustomerParty.PostalZone; - AddChild('cac:Country').AddChild('cbc:IdentificationCode').Text := _Invoice.AccountingCustomerParty.CountryCode; + AddChild('cbc:StreetName').Text := _Invoice.AccountingCustomerParty.Address.StreetName; + if not _Invoice.AccountingCustomerParty.Address.AdditionalStreetName.IsEmpty then + AddChild('cbc:AdditionalStreetName').Text := _Invoice.AccountingCustomerParty.Address.AdditionalStreetName; + AddChild('cbc:CityName').Text := _Invoice.AccountingCustomerParty.Address.City; + AddChild('cbc:PostalZone').Text := _Invoice.AccountingCustomerParty.Address.PostalZone; + if not _Invoice.AccountingCustomerParty.Address.CountrySubentity.IsEmpty then + AddChild('cbc:CountrySubentity').Text := _Invoice.AccountingCustomerParty.Address.CountrySubentity; + if not _Invoice.AccountingCustomerParty.Address.AddressLine.IsEmpty then + AddChild('cac:AddressLine').AddChild('cbc:Line').Text := _Invoice.AccountingCustomerParty.Address.AddressLine; + AddChild('cac:Country').AddChild('cbc:IdentificationCode').Text := _Invoice.AccountingCustomerParty.Address.CountryCode; end; if not _Invoice.AccountingCustomerParty.VATCompanyID.IsEmpty then with AddChild('cac:PartyTaxScheme') do @@ -425,6 +438,35 @@ class procedure TXRechnungInvoiceAdapter.SaveDocumentUBL(_Invoice: TInvoice; end; end; + if (_Invoice.DeliveryInformation.ActualDeliveryDate > 0) or + (not _Invoice.DeliveryInformation.Address.CountryCode.IsEmpty) or + (not _Invoice.DeliveryInformation.Name.IsEmpty) then + with xRoot.AddChild('cac:Delivery') do + begin + if (_Invoice.DeliveryInformation.ActualDeliveryDate > 0) then + AddChild('cbc:ActualDeliveryDate').Text := TXRechnungHelper.DateToStr(_Invoice.DeliveryInformation.ActualDeliveryDate); + with AddChild('cac:DeliveryLocation') do + begin + if (not _Invoice.DeliveryInformation.LocationIdentifier.IsEmpty) then + AddChild('cbc:ID').Text := _Invoice.DeliveryInformation.LocationIdentifier; //TODO schemeID https://docs.peppol.eu/poacc/billing/3.0/syntax/ubl-invoice/cac-Delivery/cac-DeliveryLocation/cbc-ID/ + with AddChild('cac:Address') do + begin + AddChild('cbc:StreetName').Text := _Invoice.DeliveryInformation.Address.StreetName; + if not _Invoice.DeliveryInformation.Address.AdditionalStreetName.IsEmpty then + AddChild('cbc:AdditionalStreetName').Text := _Invoice.DeliveryInformation.Address.AdditionalStreetName; + AddChild('cbc:CityName').Text := _Invoice.DeliveryInformation.Address.City; + AddChild('cbc:PostalZone').Text := _Invoice.DeliveryInformation.Address.PostalZone; + if not _Invoice.DeliveryInformation.Address.CountrySubentity.IsEmpty then + AddChild('cbc:CountrySubentity').Text := _Invoice.DeliveryInformation.Address.CountrySubentity; + if not _Invoice.DeliveryInformation.Address.AddressLine.IsEmpty then + AddChild('cac:AddressLine').AddChild('cbc:Line').Text := _Invoice.DeliveryInformation.Address.AddressLine; + AddChild('cac:Country').AddChild('cbc:IdentificationCode').Text := _Invoice.DeliveryInformation.Address.CountryCode; + end; + end; + if (not _Invoice.DeliveryInformation.Name.IsEmpty) then + AddChild('cac:DeliveryParty').AddChild('cac:PartyName').AddChild('cbc:Name').Text := _Invoice.DeliveryInformation.Name; + end; + if (_Invoice.PaymentMeansCode <> ipmc_None) and (not _Invoice.PayeeFinancialAccount.IsEmpty) then with xRoot.AddChild('cac:PaymentMeans') do begin