Skip to content

Commit 814b642

Browse files
committed
PaymentMeans, PaymentMeansTypeCodes, PaymentTerms
1 parent b4be779 commit 814b642

5 files changed

+447
-1
lines changed

Test/DUnitXZUGFeRDTest.dpr

+2-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ uses
7171
intf.ZUGFeRDTaxExemptionReasonCodes.UnitTests,
7272
intf.ZUGFeRDSubjectCodes.UnitTests,
7373
intf.ZUGFeRDReferenceTypeCodes.UnitTests,
74-
intf.ZUGFeRDProfile.UnitTests
74+
intf.ZUGFeRDProfile.UnitTests,
75+
intf.ZUGFeRDPaymentMeansTypeCodes.UnitTests
7576
;
7677

7778
//Übersetze folgenden C#-Code nach Delphi. Wenn ein Klassenname übersetzt wird, setze ihm den Präfix TZUGFeRD vorran. Stelle alles als Codeblock dar.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
{* Licensed to the Apache Software Foundation (ASF) under one
2+
* or more contributor license agreements. See the NOTICE file
3+
* distributed with this work for additional information
4+
* regarding copyright ownership. The ASF licenses this file
5+
* to you under the Apache License, Version 2.0 (the
6+
* "License"); you may not use this file except in compliance
7+
* with the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing,
12+
* software distributed under the License is distributed on an
13+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
* KIND, either express or implied. See the License for the
15+
* specific language governing permissions and limitations
16+
* under the License.}
17+
18+
unit intf.ZUGFeRDPaymentMeansTypeCodes.UnitTests;
19+
20+
interface
21+
22+
uses
23+
DUnitX.TestFramework, intf.ZUGFeRDPaymentMeansTypeCodes;
24+
25+
type
26+
[TestFixture]
27+
TZUGFeRDPaymentMeansTypeCodesTest = class
28+
public
29+
[Test]
30+
procedure TestFromString;
31+
//[Test]
32+
//procedure TestEnumValueToString;
33+
[Test]
34+
procedure TestEnumToString;
35+
end;
36+
37+
implementation
38+
39+
procedure TZUGFeRDPaymentMeansTypeCodesTest.TestFromString;
40+
var
41+
Code: TZUGFeRDPaymentMeansTypeCodes;
42+
begin
43+
Code := TZUGFeRDPaymentMeansTypeCodesExtensions.FromString('1');
44+
Assert.AreEqual(TZUGFeRDPaymentMeansTypeCodes.NotDefined, Code);
45+
Code := TZUGFeRDPaymentMeansTypeCodesExtensions.FromString('3');
46+
Assert.AreEqual(TZUGFeRDPaymentMeansTypeCodes.AutomatedClearingHouseDebit, Code);
47+
Code := TZUGFeRDPaymentMeansTypeCodesExtensions.FromString('10');
48+
Assert.AreEqual(TZUGFeRDPaymentMeansTypeCodes.InCash, Code);
49+
Code := TZUGFeRDPaymentMeansTypeCodesExtensions.FromString('20');
50+
Assert.AreEqual(TZUGFeRDPaymentMeansTypeCodes.Cheque, Code);
51+
Code := TZUGFeRDPaymentMeansTypeCodesExtensions.FromString('30');
52+
Assert.AreEqual(TZUGFeRDPaymentMeansTypeCodes.CreditTransfer, Code);
53+
Code := TZUGFeRDPaymentMeansTypeCodesExtensions.FromString('31');
54+
Assert.AreEqual(TZUGFeRDPaymentMeansTypeCodes.DebitTransfer, Code);
55+
Code := TZUGFeRDPaymentMeansTypeCodesExtensions.FromString('42');
56+
Assert.AreEqual(TZUGFeRDPaymentMeansTypeCodes.PaymentToBankAccount, Code);
57+
Code := TZUGFeRDPaymentMeansTypeCodesExtensions.FromString('48');
58+
Assert.AreEqual(TZUGFeRDPaymentMeansTypeCodes.BankCard, Code);
59+
Code := TZUGFeRDPaymentMeansTypeCodesExtensions.FromString('49');
60+
Assert.AreEqual(TZUGFeRDPaymentMeansTypeCodes.DirectDebit, Code);
61+
Code := TZUGFeRDPaymentMeansTypeCodesExtensions.FromString('57');
62+
Assert.AreEqual(TZUGFeRDPaymentMeansTypeCodes.StandingAgreement, Code);
63+
Code := TZUGFeRDPaymentMeansTypeCodesExtensions.FromString('58');
64+
Assert.AreEqual(TZUGFeRDPaymentMeansTypeCodes.SEPACreditTransfer, Code);
65+
Code := TZUGFeRDPaymentMeansTypeCodesExtensions.FromString('59');
66+
Assert.AreEqual(TZUGFeRDPaymentMeansTypeCodes.SEPADirectDebit, Code);
67+
Code := TZUGFeRDPaymentMeansTypeCodesExtensions.FromString('97');
68+
Assert.AreEqual(TZUGFeRDPaymentMeansTypeCodes.ClearingBetweenPartners, Code);
69+
Code := TZUGFeRDPaymentMeansTypeCodesExtensions.FromString('0');
70+
Assert.AreEqual(TZUGFeRDPaymentMeansTypeCodes.Unknown, Code);
71+
Code := TZUGFeRDPaymentMeansTypeCodesExtensions.FromString('Invalid');
72+
Assert.AreEqual(TZUGFeRDPaymentMeansTypeCodes.Unknown, Code);
73+
end;
74+
75+
procedure TZUGFeRDPaymentMeansTypeCodesTest.TestEnumToString;
76+
var
77+
Value: string;
78+
begin
79+
Value := TZUGFeRDPaymentMeansTypeCodesExtensions.EnumToString(TZUGFeRDPaymentMeansTypeCodes.Unknown);
80+
Assert.AreEqual('0', Value);
81+
Value := TZUGFeRDPaymentMeansTypeCodesExtensions.EnumToString(TZUGFeRDPaymentMeansTypeCodes.NotDefined);
82+
Assert.AreEqual('1', Value);
83+
Value := TZUGFeRDPaymentMeansTypeCodesExtensions.EnumToString(TZUGFeRDPaymentMeansTypeCodes.AutomatedClearingHouseDebit);
84+
Assert.AreEqual('3', Value);
85+
Value := TZUGFeRDPaymentMeansTypeCodesExtensions.EnumToString(TZUGFeRDPaymentMeansTypeCodes.InCash);
86+
Assert.AreEqual('10', Value);
87+
Value := TZUGFeRDPaymentMeansTypeCodesExtensions.EnumToString(TZUGFeRDPaymentMeansTypeCodes.Cheque);
88+
Assert.AreEqual('20', Value);
89+
Value := TZUGFeRDPaymentMeansTypeCodesExtensions.EnumToString(TZUGFeRDPaymentMeansTypeCodes.CreditTransfer);
90+
Assert.AreEqual('30', Value);
91+
Value := TZUGFeRDPaymentMeansTypeCodesExtensions.EnumToString(TZUGFeRDPaymentMeansTypeCodes.DebitTransfer);
92+
Assert.AreEqual('31', Value);
93+
Value := TZUGFeRDPaymentMeansTypeCodesExtensions.EnumToString(TZUGFeRDPaymentMeansTypeCodes.PaymentToBankAccount);
94+
Assert.AreEqual('42', Value);
95+
Value := TZUGFeRDPaymentMeansTypeCodesExtensions.EnumToString(TZUGFeRDPaymentMeansTypeCodes.BankCard);
96+
Assert.AreEqual('48', Value);
97+
Value := TZUGFeRDPaymentMeansTypeCodesExtensions.EnumToString(TZUGFeRDPaymentMeansTypeCodes.DirectDebit);
98+
Assert.AreEqual('49', Value);
99+
Value := TZUGFeRDPaymentMeansTypeCodesExtensions.EnumToString(TZUGFeRDPaymentMeansTypeCodes.StandingAgreement);
100+
Assert.AreEqual('57', Value);
101+
Value := TZUGFeRDPaymentMeansTypeCodesExtensions.EnumToString(TZUGFeRDPaymentMeansTypeCodes.SEPACreditTransfer);
102+
Assert.AreEqual('58', Value);
103+
Value := TZUGFeRDPaymentMeansTypeCodesExtensions.EnumToString(TZUGFeRDPaymentMeansTypeCodes.SEPADirectDebit);
104+
Assert.AreEqual('59', Value);
105+
Value := TZUGFeRDPaymentMeansTypeCodesExtensions.EnumToString(TZUGFeRDPaymentMeansTypeCodes.ClearingBetweenPartners);
106+
Assert.AreEqual('97', Value);
107+
end;
108+
109+
initialization
110+
111+
//I was hoping to use RTTI to discover the TestFixture classes, however unlike .NET
112+
//if we don't touch the class somehow then the linker will remove
113+
//the class from the resulting exe.
114+
//We could just do this:
115+
//TMyExampleTests.ClassName;
116+
//TExampleFixture2.ClassName;
117+
//which is enough to make the compiler link the classes into the exe, but that seems a
118+
//bit redundent so I guess we'll just use manual registration. If you use the
119+
//{$STRONGLINKTYPES ON} compiler directive then it will link the TestFixtures in and you
120+
//can use RTTI. The downside to that is the resulting exe will potentially much larger.
121+
//Not sure which version {$STRONGLINKTYPES ON} was introduced so we'll allow RTTI and
122+
//manual registration for now.
123+
124+
// TDUnitX.RegisterTestFixture(TZUGFeRDPaymentMeansTypeCodesTest);
125+
126+
end.

intf.ZUGFeRDPaymentMeans.pas

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
{* Licensed to the Apache Software Foundation (ASF) under one
2+
* or more contributor license agreements. See the NOTICE file
3+
* distributed with this work for additional information
4+
* regarding copyright ownership. The ASF licenses this file
5+
* to you under the Apache License, Version 2.0 (the
6+
* "License"); you may not use this file except in compliance
7+
* with the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing,
12+
* software distributed under the License is distributed on an
13+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
* KIND, either express or implied. See the License for the
15+
* specific language governing permissions and limitations
16+
* under the License.}
17+
18+
unit intf.ZUGFeRDPaymentMeans;
19+
20+
interface
21+
22+
uses
23+
intf.ZUGFeRDFinancialCard,intf.ZUGFeRDPaymentMeansTypeCodes;
24+
25+
type
26+
TZUGFeRDPaymentMeans = class
27+
private
28+
FTypeCode: TZUGFeRDPaymentMeansTypeCodes;
29+
FInformation: string;
30+
FSEPACreditorIdentifier: string;
31+
FSEPAMandateReference: string;
32+
FFinancialCard: TZUGFeRDFinancialCard;
33+
public
34+
constructor Create;
35+
destructor Destroy; override;
36+
public
37+
/// <summary>
38+
/// The means expressed as code, for how a payment is expected to be or has been settled.
39+
/// </summary>
40+
property TypeCode: TZUGFeRDPaymentMeansTypeCodes read FTypeCode write FTypeCode;
41+
42+
/// <summary>
43+
/// The means expressed as code, for how a payment is expected to be or has been settled.
44+
/// </summary>
45+
property Information: string read FInformation write FInformation;
46+
47+
/// <summary>
48+
/// Gläubiger-Identifikationsnummer
49+
///
50+
/// https://de.wikipedia.org/wiki/Gl%C3%A4ubiger-Identifikationsnummer
51+
/// </summary>
52+
property SEPACreditorIdentifier: string read FSEPACreditorIdentifier write FSEPACreditorIdentifier;
53+
54+
/// <summary>
55+
/// Mandatsreferenz
56+
///
57+
/// https://de.wikipedia.org/wiki/Mandatsreferenz
58+
/// </summary>
59+
property SEPAMandateReference: string read FSEPAMandateReference write FSEPAMandateReference;
60+
61+
/// <summary>
62+
/// Payment card information.
63+
/// </summary>
64+
property FinancialCard: TZUGFeRDFinancialCard read FFinancialCard write FFinancialCard;
65+
end;
66+
67+
implementation
68+
69+
{ TZUGFeRDPaymentMeans }
70+
71+
constructor TZUGFeRDPaymentMeans.Create;
72+
begin
73+
FFinancialCard := TZUGFeRDFinancialCard.Create;
74+
end;
75+
76+
destructor TZUGFeRDPaymentMeans.Destroy;
77+
begin
78+
if Assigned(FFinancialCard) then begin FFinancialCard.Free; FFinancialCard := nil; end;
79+
inherited;
80+
end;
81+
82+
end.

intf.ZUGFeRDPaymentMeansTypeCodes.pas

+175
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
{* Licensed to the Apache Software Foundation (ASF) under one
2+
* or more contributor license agreements. See the NOTICE file
3+
* distributed with this work for additional information
4+
* regarding copyright ownership. The ASF licenses this file
5+
* to you under the Apache License, Version 2.0 (the
6+
* "License"); you may not use this file except in compliance
7+
* with the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing,
12+
* software distributed under the License is distributed on an
13+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
* KIND, either express or implied. See the License for the
15+
* specific language governing permissions and limitations
16+
* under the License.}
17+
18+
unit intf.ZUGFeRDPaymentMeansTypeCodes;
19+
20+
interface
21+
22+
uses
23+
System.SysUtils,System.TypInfo
24+
;
25+
26+
type
27+
/// <summary>
28+
/// Adopted to ZUGFeRD 1.0, German description from ZUGFeRD specification
29+
/// </summary>
30+
TZUGFeRDPaymentMeansTypeCodes = (
31+
/// <summary>
32+
/// Unknown/ invalid value
33+
/// </summary>
34+
Unknown = 0,
35+
36+
/// <summary>
37+
/// Keine Zahlungsart definiert
38+
/// Available in: Extended
39+
/// </summary>
40+
NotDefined = 1,
41+
42+
/// <summary>
43+
/// Belastung durch automatisierte Clearingstelle, Z.B. bei Abwicklung durch Zahlungsdienstleister wie Online-Bezahlsysteme
44+
/// </summary>
45+
AutomatedClearingHouseDebit = 3,
46+
47+
/// <summary>
48+
/// Bar
49+
/// Available in: Basic, Extended
50+
/// </summary>
51+
InCash = 10,
52+
53+
/// <summary>
54+
/// Scheck
55+
/// Available in: Basic, Extended
56+
/// </summary>
57+
Cheque = 20,
58+
59+
/// <summary>
60+
/// Available in: Basic, Extended
61+
/// </summary>
62+
CreditTransfer = 30,
63+
64+
/// <summary>
65+
/// Lastschriftübermittlung:
66+
/// Zahlung durch Belastung eines Geldbetrages eines
67+
/// Kontos zugunsten eines anderen.
68+
/// Überweisung international und nationale SEPA-Überweisung
69+
///
70+
/// Available in: Extended
71+
/// </summary>
72+
DebitTransfer = 31,
73+
74+
/// <summary>
75+
/// Zahlung an Bankkonto
76+
/// Überweisung national, vor SEPA-Umstellung
77+
/// Available in: Basic, Extended
78+
/// </summary>
79+
PaymentToBankAccount = 42,
80+
81+
/// <summary>
82+
/// Bankkkarte, Kreditkarte
83+
/// Available in: Basic, Extended
84+
/// </summary>
85+
BankCard = 48,
86+
87+
/// <summary>
88+
/// Lastschriftverfahren
89+
///
90+
/// Available in: Basic, Extended
91+
/// /// </summary>
92+
DirectDebit = 49,
93+
94+
/// <summary>
95+
/// Available in: Basic, Extended
96+
/// </summary>
97+
StandingAgreement = 57,
98+
99+
100+
/// <summary>
101+
/// Available in: Basic, Extended
102+
/// </summary>
103+
SEPACreditTransfer = 58,
104+
105+
/// <summary>
106+
/// Available in: Basic, Extended
107+
/// </summary>
108+
SEPADirectDebit = 59,
109+
110+
/// <summary>
111+
/// Ausgleich zwischen Partnern.
112+
/// Beträge, die zwei Partner sich gegenseitig schulden werden ausgeglichen um unnütze Zahlungen zu vermeiden.
113+
/// Available in: Basic, Extended
114+
/// </summary>
115+
ClearingBetweenPartners = 97
116+
);
117+
118+
TZUGFeRDPaymentMeansTypeCodesExtensions = class
119+
public
120+
class function FromString(const s: string): TZUGFeRDPaymentMeansTypeCodes;
121+
class function EnumToString(t: TZUGFeRDPaymentMeansTypeCodes): string;
122+
end;
123+
124+
implementation
125+
126+
class function TZUGFeRDPaymentMeansTypeCodesExtensions.FromString(const s: string): TZUGFeRDPaymentMeansTypeCodes;
127+
begin
128+
if SameText(s,'1') then
129+
Result := TZUGFeRDPaymentMeansTypeCodes.NotDefined
130+
else
131+
if SameText(s,'3') then
132+
Result := TZUGFeRDPaymentMeansTypeCodes.AutomatedClearingHouseDebit
133+
else
134+
if SameText(s,'10') then
135+
Result := TZUGFeRDPaymentMeansTypeCodes.InCash
136+
else
137+
if SameText(s,'20') then
138+
Result := TZUGFeRDPaymentMeansTypeCodes.Cheque
139+
else
140+
if SameText(s,'30') then
141+
Result := TZUGFeRDPaymentMeansTypeCodes.CreditTransfer
142+
else
143+
if SameText(s,'31') then
144+
Result := TZUGFeRDPaymentMeansTypeCodes.DebitTransfer
145+
else
146+
if SameText(s,'42') then
147+
Result := TZUGFeRDPaymentMeansTypeCodes.PaymentToBankAccount
148+
else
149+
if SameText(s,'48') then
150+
Result := TZUGFeRDPaymentMeansTypeCodes.BankCard
151+
else
152+
if SameText(s,'49') then
153+
Result := TZUGFeRDPaymentMeansTypeCodes.DirectDebit
154+
else
155+
if SameText(s,'57') then
156+
Result := TZUGFeRDPaymentMeansTypeCodes.StandingAgreement
157+
else
158+
if SameText(s,'58') then
159+
Result := TZUGFeRDPaymentMeansTypeCodes.SEPACreditTransfer
160+
else
161+
if SameText(s,'59') then
162+
Result := TZUGFeRDPaymentMeansTypeCodes.SEPADirectDebit
163+
else
164+
if SameText(s,'97') then
165+
Result := TZUGFeRDPaymentMeansTypeCodes.ClearingBetweenPartners
166+
else
167+
Result := TZUGFeRDPaymentMeansTypeCodes.Unknown
168+
end;
169+
170+
class function TZUGFeRDPaymentMeansTypeCodesExtensions.EnumToString(t: TZUGFeRDPaymentMeansTypeCodes): string;
171+
begin
172+
Result := IntToStr(Integer(t));
173+
end;
174+
175+
end.

0 commit comments

Comments
 (0)