forked from ZUGFeRD/mustangproject
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implemented sepa direct debit as payment means
- Loading branch information
Jochen Stärk
authored and
Jochen Stärk
committed
Sep 14, 2019
1 parent
3d8c1ad
commit 211889b
Showing
8 changed files
with
304 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package org.mustangproject; | ||
|
||
public class XMLTools { | ||
public static String encodeXML(CharSequence s) { | ||
StringBuilder sb = new StringBuilder(); | ||
int len = s.length(); | ||
for (int i=0;i<len;i++) { | ||
int c = s.charAt(i); | ||
if (c >= 0xd800 && c <= 0xdbff && i + 1 < len) { | ||
c = ((c-0xd7c0)<<10) | (s.charAt(++i)&0x3ff); // UTF16 decode | ||
} | ||
if (c < 0x80) { // ASCII range: test most common case first | ||
if (c < 0x20 && (c != '\t' && c != '\r' && c != '\n')) { | ||
// Illegal XML character, even encoded. Skip or substitute | ||
sb.append("�"); // Unicode replacement character | ||
} else { | ||
switch(c) { | ||
case '&': sb.append("&"); break; | ||
case '>': sb.append(">"); break; | ||
case '<': sb.append("<"); break; | ||
// Uncomment next two if encoding for an XML attribute | ||
// case '\'' sb.append("'"); break; | ||
// case '\"' sb.append("""); break; | ||
// Uncomment next three if you prefer, but not required | ||
// case '\n' sb.append(" "); break; | ||
// case '\r' sb.append(" "); break; | ||
// case '\t' sb.append("	"); break; | ||
|
||
default: sb.append((char)c); | ||
} | ||
} | ||
} else if ((c >= 0xd800 && c <= 0xdfff) || c == 0xfffe || c == 0xffff) { | ||
// Illegal XML character, even encoded. Skip or substitute | ||
sb.append("�"); // Unicode replacement character | ||
} else { | ||
sb.append("&#x"); | ||
sb.append(Integer.toHexString(c)); | ||
sb.append(';'); | ||
} | ||
} | ||
return sb.toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/main/java/org/mustangproject/ZUGFeRD/IZUGFeRDTradeSettlement.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** ********************************************************************** | ||
* | ||
* Copyright 2019 by ak on 12.04.19. | ||
* | ||
* Use is subject to license terms. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy | ||
* of the License at http://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*********************************************************************** */ | ||
package org.mustangproject.ZUGFeRD; | ||
|
||
public interface IZUGFeRDTradeSettlement { | ||
|
||
/*** | ||
* | ||
* @return zf2 xml for applicableHeaderTradeSettlement | ||
*/ | ||
String getSettlementXML(); | ||
|
||
|
||
/*** | ||
* | ||
* @return zf2 xml for applicableHeaderTradePayment | ||
*/ | ||
default String getPaymentXML() { | ||
return null; | ||
} | ||
|
||
|
||
|
||
} |
57 changes: 57 additions & 0 deletions
57
src/main/java/org/mustangproject/ZUGFeRD/IZUGFeRDTradeSettlementDebit.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/** ********************************************************************** | ||
* | ||
* Copyright 2019 by ak on 12.04.19. | ||
* | ||
* Use is subject to license terms. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy | ||
* of the License at http://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*********************************************************************** */ | ||
package org.mustangproject.ZUGFeRD; | ||
|
||
import org.mustangproject.XMLTools; | ||
|
||
public interface IZUGFeRDTradeSettlementDebit extends IZUGFeRDTradeSettlement { | ||
|
||
|
||
|
||
default String getSettlementXML() { | ||
|
||
|
||
|
||
String xml = " <ram:SpecifiedTradeSettlementPaymentMeans>\n" //$NON-NLS-1$ | ||
+ " <ram:TypeCode>59</ram:TypeCode>\n" //$NON-NLS-1$ | ||
+ " <ram:PayerPartyDebtorFinancialAccount>\n" //$NON-NLS-1$ | ||
+ " <ram:IBANID>"+XMLTools.encodeXML(getIBAN())+"</ram:IBANID>\n" //$NON-NLS-1$ | ||
+ " </ram:PayerPartyDebtorFinancialAccount>\n"; //$NON-NLS-1$ | ||
|
||
xml = xml + " </ram:SpecifiedTradeSettlementPaymentMeans>\n"; //$NON-NLS-1$ | ||
return xml; | ||
} | ||
|
||
default String getPaymentXML() { | ||
return "<ram:DirectDebitMandateID>"+XMLTools.encodeXML(getMandate())+"</ram:DirectDebitMandateID>"; | ||
} | ||
|
||
|
||
/*** | ||
* @return IBAN of the debtor (optional) | ||
*/ | ||
String getIBAN(); | ||
|
||
|
||
/*** | ||
* @return sepa direct debit mandate reference | ||
*/ | ||
String getMandate(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.