Skip to content

Commit

Permalink
DeliveryInformation added
Browse files Browse the repository at this point in the history
  • Loading branch information
landrix committed Nov 20, 2020
1 parent dd562a4 commit e26b867
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 43 deletions.
12 changes: 10 additions & 2 deletions Samples/XRechnungUnit1.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ object Form1: TForm1
end
object Button3: TButton
Left = 8
Top = 185
Top = 208
Width = 129
Height = 25
Caption = 'Erzeugen'
Expand Down Expand Up @@ -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
73 changes: 46 additions & 27 deletions Samples/XRechnungUnit1.pas
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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';
Expand All @@ -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';
Expand Down Expand Up @@ -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';
Expand All @@ -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';
Expand All @@ -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 := '[email protected]';

//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
Expand Down Expand Up @@ -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';
Expand All @@ -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';
Expand Down
29 changes: 23 additions & 6 deletions intf.Invoice.pas
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Copyright (C) 2020 Landrix Software GmbH & Co. KG
Sven Harazim, [email protected]
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
Expand Down Expand Up @@ -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 <cbc:AdditionalStreetName>01129</cbc:AdditionalStreetName>
AdditionalStreetName : String;
City : String;
PostalZone : String;
//TODO <cbc:CountrySubentity>Sachsen</cbc:CountrySubentity>
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

Expand All @@ -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;
Expand Down Expand Up @@ -362,6 +378,7 @@ TInvoice = class(TObject)

AccountingSupplierParty : TInvoiceAccountingParty;
AccountingCustomerParty : TInvoiceAccountingParty;
DeliveryInformation : TInvoiceDeliveryInformation;

//TODO weitere Zahlungswege
PaymentMeansCode : TInvoicePaymentMeansCode;
Expand Down
58 changes: 50 additions & 8 deletions intf.XRechnung.pas
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Copyright (C) 2020 Landrix Software GmbH & Co. KG
Sven Harazim, [email protected]
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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit e26b867

Please sign in to comment.