diff --git a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDVisualizer.java b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDVisualizer.java
index f787c706..29cfff26 100644
--- a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDVisualizer.java
+++ b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDVisualizer.java
@@ -100,6 +100,7 @@ public class ZUGFeRDVisualizer {
String zf1Signature = "rsm:CrossIndustryDocument";
String zf2Signature = "rsm:CrossIndustryInvoice";
String ublSignature = "ubl:Invoice";
+ String ublCreditNoteSignature = "ubl:CreditNote";
boolean doPostProcessing=false;
if (fileContent.contains(zf1Signature)) {
applyZF1XSLT(fis, baos);
@@ -114,6 +115,11 @@ public class ZUGFeRDVisualizer {
applyUBL2XSLT(fis, iaos);
doPostProcessing=true;
+ } else if (fileContent.contains(ublCreditNoteSignature)) {
+ //zf2 or fx
+ applyUBLCreditNote2XSLT(fis, iaos);
+ doPostProcessing=true;
+
}
if (doPostProcessing) {
// take the copy of the stream and re-write it to an InputStream
@@ -174,6 +180,17 @@ public class ZUGFeRDVisualizer {
transformer.transform(new StreamSource(xmlFile), new StreamResult(HTMLOutstream));
}
+ public void applyUBLCreditNote2XSLT(final InputStream xmlFile, final OutputStream HTMLOutstream)
+ throws TransformerException {
+ if (mXsltUBLTemplate==null) {
+ mXsltUBLTemplate = mFactory.newTemplates(
+ new StreamSource(CLASS_LOADER.getResourceAsStream(RESOURCE_PATH + "stylesheets/ubl-creditnote-xr.xsl")));
+ }
+ Transformer transformer = mXsltUBLTemplate.newTransformer();
+
+ transformer.transform(new StreamSource(xmlFile), new StreamResult(HTMLOutstream));
+ }
+
public void applyZF1XSLT(final InputStream xmlFile, final OutputStream HTMLOutstream)
throws TransformerException {
Transformer transformer = mXsltZF1HTMLTemplate.newTransformer();
diff --git a/library/src/test/java/org/mustangproject/ZUGFeRD/VisualizationTest.java b/library/src/test/java/org/mustangproject/ZUGFeRD/VisualizationTest.java
index 1e05286a..028b39d0 100644
--- a/library/src/test/java/org/mustangproject/ZUGFeRD/VisualizationTest.java
+++ b/library/src/test/java/org/mustangproject/ZUGFeRD/VisualizationTest.java
@@ -65,6 +65,42 @@ public class VisualizationTest extends ResourceCase {
+ assertNotNull(result);
+ // Reading ZUGFeRD
+ assertEquals(expected, result);
+ }
+ public void testUBLCreditNoteVisualizationBasic() {
+
+ // the writing part
+ CIIToUBL c2u = new CIIToUBL();
+ String sourceFilename = "factur-x.xml";
+ File UBLinputFile = getResourceAsFile("ubl-creditnote.xml");
+
+ String expected = null;
+ String result = null;
+ try {
+ ZUGFeRDVisualizer zvi = new ZUGFeRDVisualizer();
+ /* remove file endings so that tests can also pass after checking
+ out from git with arbitrary options (which may include CSRF changes)
+ */
+ result = zvi.visualize(UBLinputFile.getAbsolutePath(),ZUGFeRDVisualizer.Language.EN).replace("\r","").replace("\n","");
+
+ File expectedResult=getResourceAsFile("factur-x-vis-ubl-creditnote.en.html");
+ expected = new String(Files.readAllBytes(expectedResult.toPath()), StandardCharsets.UTF_8).replace("\r","").replace("\n","");
+ // remove linebreaks as well...
+
+ } catch (UnsupportedOperationException e) {
+ fail("UnsupportedOperationException should not happen: "+e.getMessage());
+ } catch (IllegalArgumentException e) {
+ fail("IllegalArgumentException should not happen: "+e.getMessage());
+ } catch (TransformerException e) {
+ fail("TransformerException should not happen: "+e.getMessage());
+ } catch (IOException e) {
+ fail("IOException should not happen: "+e.getMessage());
+ }
+
+
+
assertNotNull(result);
// Reading ZUGFeRD
assertEquals(expected, result);
diff --git a/library/src/test/resources/factur-x-vis-ubl-creditnote.en.html b/library/src/test/resources/factur-x-vis-ubl-creditnote.en.html
new file mode 100644
index 00000000..b07fb397
--- /dev/null
+++ b/library/src/test/resources/factur-x-vis-ubl-creditnote.en.html
@@ -0,0 +1,2628 @@
+
+
+
+
+ XRechnung
+
+
+
+
+
+
+
+
+
We accept no liability for the correctness of the data
+
+
+
+
Buyer Information
+
+
+
+
Name:
+
The buyercompany inc.
+
+
+
Street / house number:
+
Anystreet
+
+
+
+
+
+
+
State/Province:
+
RegionB
+
+
+
Country:
+
BE (Belgien)
+
+
+
+
+
+
+
E-mail address:
+
john@buyercompany.eu
+
+
+
+
+
+
Seller Information
+
+
+
+
Company name:
+
The Sellercompany Incorporated
+
+
+
Street / house number:
+
Main street
+
+
+
+
+
+
+
+
Country code:
+
DK (Dänemark)
+
+
+
+
+
+
+
E-mail address:
+
antonio@salescompany.dk
+
+
+
+
+
+
+
+
+
Invoice details
+
+
+
+
+
Seller Information:
+
TOSL108
+
+
+
Invoice date:
+
15.12.2009
+
+
+
+
Currency
+
EUR (Euro)
+
+
+
Billing period:
+
+
+
+
+
+
+
+
Contract Number:
+
Contract321
+
+
+
+
+
Previous invoices:
+
+
+
+
+
+
+
+
+
Total amounts of the invoice
+
+
+
Line total
+
netto
+
1.436,50
+
+
+
Total discounts
+
netto
+
100,00
+
+
+
Total charges
+
netto
+
100,00
+
+
+
Grand total
+
netto
+
1.436,50
+
+
+
VAT amount
+
+
292,20
+
+
+
+
Grand total
+
brutto
+
1.729,00
+
+
+
Amount paid
+
brutto
+
1.000,00
+
+
+
rounding amount
+
brutto
+
0,30
+
+
+
Amount Due
+
brutto
+
729,00
+
+
+
+
+
+
+
+
+
Breakdown of VAT at invoice level
+
+
+
VAT category: S (Standard rate)
+
+
+
+
+
Grand total
+
netto
+
1.460,50
+
+
+
+
VAT amount
+
+
292,10
+
+
+
+
Reason for exemption::
+
ID for the exemption reason::
+
+
+
+
+
+
Breakdown of VAT at invoice level
+
+
+
VAT category: AA (Lower rate)
+
+
+
+
+
Grand total
+
netto
+
1,00
+
+
+
+
+
+
Reason for exemption::
+
ID for the exemption reason::
+
+
+
+
+
+
Breakdown of VAT at invoice level
+
+
+
VAT category: E (Exempt from tax)
+
+
+
+
+
Grand total
+
netto
+
-25,00
+
+
+
+
+
+
Reason for exemption:: Exempt New Means of Transport
+
ID for the exemption reason:: AAM
+
+
+
+
+
+
+
+
Allowance at invoice level
+
+
+
VAT category of the discount::
+
+
+
+
+
Basic amount
+
netto
+
+
+
+
+
Allowance
+
netto
+
100,00
+
+
+
VAT rate on allowance
+
+
+
+
+
+
Reason for the allowance: Promotion discount
+
Document level allowance reason code:
+
+
+
+
+
+
+
+
+
Charge amount at invoice level
+
+
+
VAT category of the charge amount:
+
+
+
+
+
Basic amount
+
netto
+
+
+
+
+
Charge amount
+
netto
+
100,00
+
+
+
VAT rate of the charge amount
+
+
+
+
+
+
Reason for the charge amount:: Packing cost
+
Document level charge reason code:
+
+
+
+
+
+
+
+
+
+
Direct debit
+
+
+
Mandate Reference No:
+
+
+
+
+
+
+
+
+
+
+
+
+
Invoice Comment
+
+
+
+
Comment:
+
Ordered in our booth at the convention.
+
+
+
+
+
+
+
+
We accept no liability for the correctness of the data
+
+
+
+
Line1
+
+
+
Free text:
+
Scratch on box
+
+
+
+
+
+
Account assignment information:
+
BookingCode001
+
+
Billing period:
+
+
+
+
+
+
Price details
+
+
+
+
+
Unit price (net)
+
1.273,00
+
+
+
Total price (net)
+
1.273,00
+
+
+
+
+
Discount (net):
+
225,00
+
+
+
Net list price:
+
1.500,00
+
+
+
+
Unit of measure code:
+
C62 (one)
+
+
+
+
VAT rate in percent:
+
%
+
+
+
+
+
+
+
+
+
Allowances at line level
+
+
+
Charges at invoice line level
+
+
+
+
+
+
+
Item Information
+
+
+
+
+
+
Name:
+
Labtop computer
+
+
+
Description:
+
Processor: Intel Core 2 Duo SU9400 LV (1.4GHz). RAM:
+ 3MB. Screen 1440x900
+
+
+
+
Customer's material number:
+
+
+
Article properties:
+
+
+
+
+
+
+
+
Item ID:
+
1234567890124
+
+
+
Item ID schema:
+
GTIN
+
+
+
Item classification code:
+
12344321 65434568
+
+
+
Identifier to form the schema:
+
UNSPSC CPV
+
+
+
Version for creating the schema:
+
+
+
+
Country of origin code:
+
+
+
+
+
+
+
+
+
+
+
+
+
Line2
+
+
+
Free text:
+
Cover is slightly damaged.
+
+
+
+
+
+
Account assignment information:
+
+
+
Billing period:
+
+
+
+
+
+
Price details
+
+
+
+
+
Unit price (net)
+
3,96
+
+
+
Total price (net)
+
-3,96
+
+
+
+
+
+
+
+
Unit of measure code:
+
C62 (one)
+
+
+
+
VAT rate in percent:
+
%
+
+
+
+
+
+
+
+
+
Allowances at line level
+
+
+
Charges at invoice line level
+
+
+
+
+
+
+
Item Information
+
+
+
+
+
+
Name:
+
Returned "Advanced computing" book
+
+
+
+
+
Customer's material number:
+
+
+
Article properties:
+
+
+
+
+
+
+
Item ID:
+
1234567890125
+
+
+
Item ID schema:
+
GTIN
+
+
+
Item classification code:
+
32344324 65434567
+
+
+
Identifier to form the schema:
+
UNSPSC CPV
+
+
+
Version for creating the schema:
+
+
+
+
Country of origin code:
+
+
+
+
+
+
+
+
+
+
+
+
+
Line3
+
+
+
+
+
+
+
Account assignment information:
+
+
+
Billing period:
+
+
+
+
+
+
Price details
+
+
+
+
+
Unit price (net)
+
2,48
+
+
+
Total price (net)
+
4,96
+
+
+
+
+
Discount (net):
+
0,28
+
+
+
Net list price:
+
2,75
+
+
+
+
Unit of measure code:
+
C62 (one)
+
+
+
+
VAT rate in percent:
+
%
+
+
+
+
+
+
+
+
+
Allowances at line level
+
+
+
Charges at invoice line level
+
+
+
+
+
+
+
Item Information
+
+
+
+
+
+
Name:
+
"Computing for dummies" book
+
+
+
+
+
Customer's material number:
+
+
+
Article properties:
+
+
+
+
+
+
+
Item ID:
+
1234567890126
+
+
+
Item ID schema:
+
GTIN
+
+
+
Item classification code:
+
32344324 65434566
+
+
+
Identifier to form the schema:
+
UNSPSC CPV
+
+
+
Version for creating the schema:
+
+
+
+
Country of origin code:
+
+
+
+
+
+
+
+
+
+
+
+
+
Line4
+
+
+
+
+
+
+
Account assignment information:
+
+
+
Billing period:
+
+
+
+
+
+
Price details
+
+
+
+
+
Unit price (net)
+
25,00
+
+
+
Total price (net)
+
-25,00
+
+
+
+
+
+
+
+
Unit of measure code:
+
C62 (one)
+
+
+
+
VAT rate in percent:
+
%
+
+
+
+
+
+
+
+
+
Allowances at line level
+
+
+
Charges at invoice line level
+
+
+
+
+
+
+
Item Information
+
+
+
+
+
+
Name:
+
Returned IBM 5150 desktop
+
+
+
+
+
Customer's material number:
+
+
+
Article properties:
+
+
+
+
+
+
+
Item ID:
+
1234567890127
+
+
+
Item ID schema:
+
GTIN
+
+
+
Item classification code:
+
12344322 65434565
+
+
+
Identifier to form the schema:
+
UNSPSC CPV
+
+
+
Version for creating the schema:
+
+
+
+
Country of origin code:
+
+
+
+
+
+
+
+
+
+
+
+
+
Line5
+
+
+
+
+
+
+
Account assignment information:
+
BookingCode002
+
+
Billing period:
+
+
+
+
+
+
Price details
+
+
+
+
+
Unit price (net)
+
0,75
+
+
+
Total price (net)
+
187,50
+
+
+
+
+
+
+
+
Unit of measure code:
+
C62 (one)
+
+
+
+
VAT rate in percent:
+
%
+
+
+
+
+
+
+
+
+
Allowances at line level
+
+
+
Charges at invoice line level
+
+
+
+
+
+
+
Item Information
+
+
+
+
+
+
Name:
+
Network cable
+
+
+
+
+
Customer's material number:
+
+
+
Article properties:
+
+
+
+
+
+
+
+
Item ID:
+
1234567890128
+
+
+
Item ID schema:
+
GTIN
+
+
+
Item classification code:
+
12344325 65434564
+
+
+
Identifier to form the schema:
+
UNSPSC CPV
+
+
+
Version for creating the schema:
+
+
+
+
Country of origin code:
+
+
+
+
+
+
+
+
+
+
+
+
We accept no liability for the correctness of the data
+
+
+
+
Seller Information
+
+
+
Differing trade name:
+
Salescompany ltd.
+
+
+
+
Electronic address:
+
1234567890123
+
+
+
Electronic address scheme:
+
GLN
+
+
+
Register number:
+
5402697509
+
+
+
+
+
+
Further legal information:
+
+
+
+
+
+
+
+
+
+
+
+
Buyer Information
+
+
+
Differing trade name:
+
Buyercompany ltd
+
+
+
State/Province:
+
RegionB
+
+
+
E-mail address:
+
1234567987654
+
+
+
Electronic address scheme:
+
GLN
+
+
+
Register number:
+
5645342123 ZZZ
+
+
+
Scheme of register/register number:
+
ZZZ
+
+
+
+
+
VAT Statement Date Code:
+
+
+
+
Account assignment information:
+
Project cost code 123
+
+
+
+
+
+
+
+
+
+
Contract Information
+
+
+
+
Receipt confirmation ID:
+
+
+
+
+
+
+
+
+
+
+
+
Payee other than Seller
+
+
+
Name:
+
Ebeneser Scrooge Inc.
+
+
+
+
+
Register number:
+
6411982340
+
+
+
Scheme of register/register number:
+
UK:CH
+
+
+
+
+
+
+
+
We accept no liability for the correctness of the data
+
+
+
+
Documents justifying the invoice
+
+
+
+
+
Reference (e.g. Internet address):
+
+
+
+
+
Format of attachment:
+
+
+
+
Name of attachment:
+
+
+
+
+
+
+
+
Reference (e.g. Internet address):
+
+
+
+
Attachment:
+
+
UjBsR09EbGhjZ0dTQUxNQUFBUUNBRU1tQ1p0dU1GUXhEUzhi
+
+
+
Format of attachment:
+
application/pdf
+
+
+
Name of attachment:
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/library/src/test/resources/ubl-creditnote.xml b/library/src/test/resources/ubl-creditnote.xml
new file mode 100644
index 00000000..d5aaf452
--- /dev/null
+++ b/library/src/test/resources/ubl-creditnote.xml
@@ -0,0 +1,411 @@
+
+
+ 2.1
+ TOSL108
+ 2009-12-15
+ Ordered in our booth at the convention.
+ EUR
+ Project cost code 123
+
+ 2009-11-01
+ 2009-11-30
+
+
+ 123
+
+
+ Contract321
+ Framework agreement
+
+
+ Doc1
+ Timesheet
+
+
+ http://www.suppliersite.eu/sheet001.html
+
+
+
+
+ Doc2
+ Drawing
+
+ UjBsR09EbGhjZ0dTQUxNQUFBUUNBRU1tQ1p0dU1GUXhEUzhi
+
+
+
+
+ 1234567890123
+
+ Supp123
+
+
+ Salescompany ltd.
+
+
+ 1231412341324
+ 5467
+ Main street
+ Suite 123
+ 1
+ Revenue department
+ Big city
+ 54321
+ RegionA
+
+ DK
+
+
+
+ DK12345
+
+ VAT
+
+
+
+ The Sellercompany Incorporated
+ 5402697509
+
+ Big city
+ RegionA
+
+ DK
+
+
+
+
+ 4621230
+ 4621231
+ antonio@salescompany.dk
+
+
+ Antonio
+ M
+ Salemacher
+ Sales manager
+
+
+
+
+
+ 1234567987654
+
+ 345KS5324
+
+
+ Buyercompany ltd
+
+
+ 1238764941386
+ 123
+ Anystreet
+ Back door
+ 8
+ Accounting department
+ Anytown
+ 101
+ RegionB
+
+ BE
+
+
+
+ BE54321
+
+ VAT
+
+
+
+ The buyercompany inc.
+ 5645342123
+
+ Mainplace
+ RegionB
+
+ BE
+
+
+
+
+ 5121230
+ 5121231
+ john@buyercompany.eu
+
+
+ John
+ X
+ Doe
+ Purchasing manager
+
+
+
+
+
+ 098740918237
+
+
+ Ebeneser Scrooge Inc.
+
+
+ 6411982340
+
+
+
+ true
+ Packing cost
+ 100
+
+
+ false
+ Promotion discount
+ 100
+
+
+ 292.20
+
+ 1460.5
+ 292.1
+
+ S
+ 20
+
+ VAT
+
+
+
+
+ 1
+ 0.1
+
+ AA
+ 10
+
+ VAT
+
+
+
+
+ -25
+ 0
+
+ E
+ 0
+ AAM
+ Exempt New Means of Transport
+
+ VAT
+
+
+
+
+
+ 1436.5
+ 1436.5
+ 1729
+ 100
+ 100
+ 1000
+ 0.30
+ 729
+
+
+ 1
+ Scratch on box
+ 1
+ 1273
+ BookingCode001
+
+ 254.6
+
+
+ Processor: Intel Core 2 Duo SU9400 LV (1.4GHz). RAM:
+ 3MB. Screen 1440x900
+ Labtop computer
+
+ JB007
+
+
+ 1234567890124
+
+
+ 12344321
+
+
+ 65434568
+
+
+ S
+ 20
+
+ VAT
+
+
+
+ Color
+ black
+
+
+
+ 1273
+ 1
+
+ false
+ Contract
+ 0.15
+ 225
+ 1500
+
+
+
+
+ 2
+ Cover is slightly damaged.
+ -1
+ -3.96
+
+ -0.396
+
+
+ Returned "Advanced computing" book
+
+ JB008
+
+
+ 1234567890125
+
+
+ 32344324
+
+
+ 65434567
+
+
+ AA
+ 10
+
+ VAT
+
+
+
+
+ 3.96
+ 1
+
+
+
+ 3
+ 2
+ 4.96
+
+ 0.496
+
+
+ "Computing for dummies" book
+
+ JB009
+
+
+ 1234567890126
+
+
+ 32344324
+
+
+ 65434566
+
+
+ AA
+ 10
+
+ VAT
+
+
+
+
+ 2.48
+ 1
+
+ false
+ Contract
+ 0.1
+ 0.275
+ 2.75
+
+
+
+
+ 4
+ -1
+ -25
+
+ 0
+
+
+ Returned IBM 5150 desktop
+
+ JB010
+
+
+ 1234567890127
+
+
+ 12344322
+
+
+ 65434565
+
+
+ E
+ 0
+
+ VAT
+
+
+
+
+ 25
+ 1
+
+
+
+ 5
+ 250
+ 187.5
+ BookingCode002
+
+ 37.5
+
+
+ Network cable
+
+ JB011
+
+
+ 1234567890128
+
+
+ 12344325
+
+
+ 65434564
+
+
+ S
+ 20
+
+ VAT
+
+
+
+ Type
+ Cat5
+
+
+
+ 0.75
+ 1
+
+
+
\ No newline at end of file
diff --git a/library/src/test/resources/ubl-selfbilled-01.20a-INVOICE_ubl.xml b/library/src/test/resources/ubl-selfbilled-01.20a-INVOICE_ubl.xml
new file mode 100644
index 00000000..62559840
--- /dev/null
+++ b/library/src/test/resources/ubl-selfbilled-01.20a-INVOICE_ubl.xml
@@ -0,0 +1,162 @@
+
+
+ urn:cen.eu:en16931:2017#compliant#urn:xoev-de:kosit:standard:xrechnung_2.3
+ 1234567890
+ 2021-01-25
+ 2021-02-04
+ 389
+ #REG#Betriebsstätte
+ EUR
+ 1234567890-54321-40
+
+ Bestellung XRechnung
+
+
+
+
+ [Seller street]
+ [Seller city]
+ 12345
+
+ DE
+
+
+
+ DE123456789
+
+ VAT
+
+
+
+ Betriebsstätte
+
+
+ Reimund Kann
+ 0123456789
+ test@test.de
+
+
+
+
+
+
+ [Street]
+ [City]
+ 12345
+
+ DE
+
+
+
+ DE987654321
+
+ VAT
+
+
+
+ Kunde 1
+
+
+
+
+ 2021-01-25
+
+
+ [Street]
+ [City]
+ 54321
+
+ DE
+
+
+
+
+
+ [ShipToTradeParty]
+
+
+
+
+ 42
+ 1234567890
+
+ 1234 5678 9012 3456 789022
+ Postbank Düsseldorf
+
+ PBNKDEFF
+
+
+
+
+ Zahlbar unter Angabe der Rechungs- und Debitornummer sofort netto Kasse; fällig zum 04.02.2021 ohne Abzug
+
+
+ 57.00
+
+ 300.00
+ 57.00
+
+ S
+ 19
+
+ VAT
+
+
+
+
+
+ 300.00
+ 300.00
+ 357.00
+ 357.00
+
+
+ 1
+ -1.0000
+ -100.00
+
+ 2021-01-25
+ 2021-01-25
+
+
+ Behältermiete
+
+ S
+ 19
+
+ VAT
+
+
+
+
+ 100
+ 1
+
+
+
+ 2
+ 4.0000
+ 400.00
+
+ 2021-01-25
+ 2021-01-25
+
+
+ Ersatztext bei Entsorgung
+ Entsorgung
+
+ S
+ 19
+
+ VAT
+
+
+
+
+ 100
+ 1
+
+
+
\ No newline at end of file