Skip to content

Commit 27a062f

Browse files
committed
new classes added
1 parent 71ff060 commit 27a062f

7 files changed

+283
-1
lines changed

Test/DUnitXZUGFeRDTest.dpr

+1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ uses
7777
intf.ZUGFeRDElectronicAddressSchemeIdentifiers.UnitTests,
7878
intf.ZUGFeRDSpecialServiceDescriptionCodes.UnitTests,
7979
intf.ZUGFeRDAllowanceOrChargeIdentificationCodes.UnitTests,
80+
intf.ZUGFeRDDesignatedProductClassificationClassCodes.UnitTests,
8081

8182
intf.ZUGFeRDInvoiceDescriptor,intf.ZUGFeRDTradeLineItem,intf.ZUGFeRDInvoiceValidator,
8283
intf.ZUGFeRDInvoiceDescriptorReader,intf.ZUGFeRDInvoiceDescriptorWriter,

Test/intf.ZUGFeRD22Tests.UnitTests.pas

+55-1
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ TZUGFeRD22Tests = class
127127
procedure TestWriteAndReadDespatchAdviceDocumentReferenceXRechnung;
128128
[Test]
129129
procedure TestSpecifiedTradeAllowanceCharge;
130+
[Test]
131+
procedure TestUBLInvoiceCreation;
132+
[Test]
133+
procedure TestUBLTradelineitemProductCharacterstics;
130134
end;
131135

132136
implementation
@@ -1750,7 +1754,57 @@ procedure TZUGFeRD22Tests.TestTradeAllowanceChargeWithoutExplicitPercentage;
17501754
// Assert.AreEqual(allowanceCharges[0].BasisAmount, 100m);
17511755
// Assert.AreEqual(allowanceCharges[0].Amount, 10m);
17521756
// Assert.AreEqual(allowanceCharges[0].ChargePercentage, null);
1753-
end; // !TestTradeAllowanceChargeWithoutExplicitPercentage()
1757+
end;
1758+
1759+
procedure TZUGFeRD22Tests.TestUBLInvoiceCreation;
1760+
begin
1761+
// InvoiceDescriptor desc = this.InvoiceProvider.CreateInvoice();
1762+
// MemoryStream ms = new MemoryStream();
1763+
//
1764+
// desc.Save(ms, ZUGFeRDVersion.Version22,Profile.XRechnung,ZUGFeRDFormats.UBL);
1765+
// ms.Seek(0, SeekOrigin.Begin);
1766+
//
1767+
// InvoiceDescriptor loadedInvoice = InvoiceDescriptor.Load(ms);
1768+
//
1769+
// Assert.AreEqual(loadedInvoice.Invoicee, null);
1770+
// Assert.AreNotEqual(loadedInvoice.Seller, null);
1771+
// Assert.AreEqual(loadedInvoice.Taxes.Count, 2);
1772+
// Assert.AreEqual(loadedInvoice.SellerContact.Name, "Max Mustermann");
1773+
// Assert.IsNull(loadedInvoice.BuyerContact);
1774+
end;
1775+
1776+
procedure TZUGFeRD22Tests.TestUBLTradelineitemProductCharacterstics;
1777+
begin
1778+
// InvoiceDescriptor desc = this.InvoiceProvider.CreateInvoice();
1779+
//
1780+
// desc.TradeLineItems[0].ApplicableProductCharacteristics = new ApplicableProductCharacteristic[]
1781+
// {
1782+
// new ApplicableProductCharacteristic()
1783+
// {
1784+
// Description = "Test Description",
1785+
// Value = "1.5 kg"
1786+
// },
1787+
// new ApplicableProductCharacteristic()
1788+
// {
1789+
// Description = "UBL Characterstics 2",
1790+
// Value = "3 kg"
1791+
// },
1792+
// }.ToList();
1793+
//
1794+
// MemoryStream ms = new MemoryStream();
1795+
//
1796+
// desc.Save(ms, ZUGFeRDVersion.Version22, Profile.XRechnung, ZUGFeRDFormats.UBL);
1797+
// ms.Seek(0, SeekOrigin.Begin);
1798+
//
1799+
// InvoiceDescriptor loadedInvoice = InvoiceDescriptor.Load(ms);
1800+
//
1801+
// Assert.IsNotNull(loadedInvoice.TradeLineItems);
1802+
// Assert.AreEqual(loadedInvoice.TradeLineItems[0].ApplicableProductCharacteristics.Count, 2);
1803+
// Assert.AreEqual(loadedInvoice.TradeLineItems[0].ApplicableProductCharacteristics[0].Description, "Test Description");
1804+
// Assert.AreEqual(loadedInvoice.TradeLineItems[0].ApplicableProductCharacteristics[1].Value, "3 kg");
1805+
end;
1806+
1807+
// !TestTradeAllowanceChargeWithoutExplicitPercentage()
17541808

17551809
procedure TZUGFeRD22Tests.TestTradeAllowanceChargeWithExplicitPercentage;
17561810
begin
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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.ZUGFeRDDesignatedProductClassificationClassCodes.UnitTests;
19+
20+
interface
21+
22+
uses
23+
DUnitX.TestFramework,
24+
intf.ZUGFeRDDesignatedProductClassificationClassCodes;
25+
26+
type
27+
[TestFixture]
28+
TZUGFeRDDesignatedProductClassificationClassCodesTest = class
29+
public
30+
[Test]
31+
procedure TestFromString;
32+
[Test]
33+
procedure TestEnumToString;
34+
end;
35+
36+
implementation
37+
38+
procedure TZUGFeRDDesignatedProductClassificationClassCodesTest.TestFromString;
39+
begin
40+
Assert.AreEqual(TZUGFeRDDesignatedProductClassificationClassCodes.HS, TZUGFeRDDesignatedProductClassificationClassCodesExtensions.FromString('HS'));
41+
Assert.AreEqual(TZUGFeRDDesignatedProductClassificationClassCodes.Unknown, TZUGFeRDDesignatedProductClassificationClassCodesExtensions.FromString('Unknown'));
42+
Assert.AreEqual(TZUGFeRDDesignatedProductClassificationClassCodes.Unknown, TZUGFeRDDesignatedProductClassificationClassCodesExtensions.FromString('Invalid'));
43+
end;
44+
45+
procedure TZUGFeRDDesignatedProductClassificationClassCodesTest.TestEnumToString;
46+
begin
47+
Assert.AreEqual('HS', TZUGFeRDDesignatedProductClassificationClassCodesExtensions.EnumToString(TZUGFeRDDesignatedProductClassificationClassCodes.HS));
48+
Assert.AreEqual('', TZUGFeRDDesignatedProductClassificationClassCodesExtensions.EnumToString(TZUGFeRDDesignatedProductClassificationClassCodes.Unknown));
49+
end;
50+
51+
initialization
52+
53+
//I was hoping to use RTTI to discover the TestFixture classes, however unlike .NET
54+
//if we don't touch the class somehow then the linker will remove
55+
//the class from the resulting exe.
56+
//We could just do this:
57+
//TMyExampleTests.ClassName;
58+
//TExampleFixture2.ClassName;
59+
//which is enough to make the compiler link the classes into the exe, but that seems a
60+
//bit redundent so I guess we'll just use manual registration. If you use the
61+
//{$STRONGLINKTYPES ON} compiler directive then it will link the TestFixtures in and you
62+
//can use RTTI. The downside to that is the resulting exe will potentially much larger.
63+
//Not sure which version {$STRONGLINKTYPES ON} was introduced so we'll allow RTTI and
64+
//manual registration for now.
65+
66+
end.

Test/intf.ZUGFeRDInvoiceProvider.pas

+1
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ class function TZUGFeRDInvoiceProvider.CreateInvoice: TZUGFeRDInvoiceDescriptor;
101101
// desc.ActualDeliveryDate = new DateTime(2018, 03, 05);
102102
// desc.SetPaymentMeans(PaymentMeansTypeCodes.SEPACreditTransfer, "Zahlung per SEPA Überweisung.");
103103
// desc.AddCreditorFinancialAccount(iban: "DE02120300000000202051", bic: "BYLADEM1001", name: "Kunden AG");
104+
// //desc.AddDebitorFinancialAccount(iban: "DB02120300000000202051", bic: "DBBYLADEM1001", bankName: "KundenDB AG");
104105
//
105106
// desc.AddApplicableTradeTax(basisAmount: 275.0m,
106107
// percent: 7m,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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.ZUGFeRDDesignatedProductClassification;
19+
20+
interface
21+
22+
uses
23+
intf.ZUGFeRDDesignatedProductClassificationClassCodes;
24+
25+
type
26+
/// <summary>
27+
/// Detailed information on the item classification
28+
/// </summary>
29+
TZUGFeRDDesignatedProductClassification = class
30+
private
31+
FClassName: String;
32+
FListID: String;
33+
FListVersionID: String;
34+
FClassCode: TZUGFeRDDesignatedProductClassificationClassCodes;
35+
public
36+
/// <summary>
37+
/// A code for the classification of an item according to type or kind or nature.
38+
///
39+
/// Classification codes are used for the aggregation of similar products, which might be useful for various
40+
/// purposes, for instance like public procurement, in accordance with the Common Vocabulary for Public Procurement
41+
/// [CPV]), e-Commerce(UNSPSC) etc.
42+
/// </summary>
43+
property ClassCode : TZUGFeRDDesignatedProductClassificationClassCodes read FClassCode write FClassCode;
44+
45+
/// <summary>
46+
/// Product classification name
47+
/// </summary>
48+
property ListID : String read FListID write FListID;
49+
50+
/// <summary>
51+
/// Version of product classification
52+
/// </summary>
53+
property ListVersionID : String read FListVersionID write FListVersionID;
54+
55+
/// <summary>
56+
/// Classification name
57+
/// </summary>
58+
property ClassName : String read FClassName write FClassName;
59+
end;
60+
61+
implementation
62+
63+
end.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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.ZUGFeRDDesignatedProductClassificationClassCodes;
19+
20+
interface
21+
22+
uses
23+
System.SysUtils,System.TypInfo
24+
;
25+
26+
type
27+
TZUGFeRDDesignatedProductClassificationClassCodes = (
28+
HS,
29+
Unknown
30+
);
31+
32+
TZUGFeRDDesignatedProductClassificationClassCodesExtensions = class
33+
public
34+
class function FromString(const s: string): TZUGFeRDDesignatedProductClassificationClassCodes;
35+
class function EnumToString(c: TZUGFeRDDesignatedProductClassificationClassCodes): string;
36+
end;
37+
38+
implementation
39+
40+
{ TZUGFeRDDesignatedProductClassificationClassCodesExtensions }
41+
42+
class function TZUGFeRDDesignatedProductClassificationClassCodesExtensions.EnumToString(
43+
c: TZUGFeRDDesignatedProductClassificationClassCodes): string;
44+
begin
45+
case c of
46+
TZUGFeRDDesignatedProductClassificationClassCodes.HS: Result := 'HS';
47+
else Result := '';
48+
end;
49+
end;
50+
51+
class function TZUGFeRDDesignatedProductClassificationClassCodesExtensions.FromString(
52+
const s: string): TZUGFeRDDesignatedProductClassificationClassCodes;
53+
begin
54+
if SameText(s,'HS') then
55+
Result := TZUGFeRDDesignatedProductClassificationClassCodes.HS
56+
else
57+
Result := TZUGFeRDDesignatedProductClassificationClassCodes.Unknown;
58+
end;
59+
60+
end.

intf.ZUGFeRDFormats.pas

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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.ZUGFeRDFormats;
19+
20+
interface
21+
22+
type
23+
TZUGFeRDFormats = (
24+
/// <summary>
25+
/// Cross Industrie Invoice
26+
/// </summary>
27+
CII,
28+
29+
/// <summary>
30+
/// Universal Business Language
31+
/// </summary>
32+
UBL
33+
);
34+
35+
implementation
36+
37+
end.

0 commit comments

Comments
 (0)