Renamed convertToAllowedCharacters() to convertDiacriticsAndReservedXmlCharacters(), removed side effect that containsOnlyAllowedCharacters() converts diacritics and XML characters and added default implementation convertDiacriticsAndReservedXmlCharactersAndCheckIfContainsOnlyAllowedCharacters()
This commit is contained in:
parent
f89e2855d2
commit
deb7f3ad36
|
@ -5,8 +5,14 @@ interface ISepaMessageCreator {
|
|||
|
||||
fun createXmlFile(filename: String, replacementStrings: Map<String, String>): String
|
||||
|
||||
fun convertDiacriticsAndReservedXmlCharactersAndCheckIfContainsOnlyAllowedCharacters(stringToTest: String): Boolean {
|
||||
val convertedString = convertDiacriticsAndReservedXmlCharacters(stringToTest)
|
||||
|
||||
return containsOnlyAllowedCharacters(convertedString)
|
||||
}
|
||||
|
||||
fun containsOnlyAllowedCharacters(stringToTest: String): Boolean
|
||||
|
||||
fun convertToAllowedCharacters(input: String): String
|
||||
fun convertDiacriticsAndReservedXmlCharacters(input: String): String
|
||||
|
||||
}
|
|
@ -26,14 +26,14 @@ open class SepaBankTransferBase(
|
|||
debitorBic,
|
||||
mapOf(
|
||||
SepaMessageCreator.NumberOfTransactionsKey to "1", // TODO: may someday support more then one transaction per file
|
||||
"DebitorName" to messageCreator.convertToAllowedCharacters(debitor.name),
|
||||
"DebitorName" to messageCreator.convertDiacriticsAndReservedXmlCharacters(debitor.name),
|
||||
"DebitorIban" to account.iban!!,
|
||||
"DebitorBic" to debitorBic,
|
||||
"CreditorName" to messageCreator.convertToAllowedCharacters(data.creditorName),
|
||||
"CreditorName" to messageCreator.convertDiacriticsAndReservedXmlCharacters(data.creditorName),
|
||||
"CreditorIban" to data.creditorIban.replace(" ", ""),
|
||||
"CreditorBic" to data.creditorBic.replace(" ", ""),
|
||||
"Amount" to data.amount.toString(), // TODO: check if ',' or '.' should be used as decimal separator
|
||||
"Usage" to if (data.usage.isEmpty()) " " else messageCreator.convertToAllowedCharacters(data.usage),
|
||||
"Usage" to if (data.usage.isEmpty()) " " else messageCreator.convertDiacriticsAndReservedXmlCharacters(data.usage),
|
||||
"RequestedExecutionDate" to RequestedExecutionDateValueForNotScheduledTransfers
|
||||
),
|
||||
messageCreator
|
||||
|
|
|
@ -39,12 +39,10 @@ open class SepaMessageCreator : ISepaMessageCreator {
|
|||
|
||||
|
||||
override fun containsOnlyAllowedCharacters(stringToTest: String): Boolean {
|
||||
val convertedString = convertToAllowedCharacters(stringToTest)
|
||||
|
||||
return AllowedSepaCharactersPattern.matcher(convertedString).matches()
|
||||
return AllowedSepaCharactersPattern.matcher(stringToTest).matches()
|
||||
}
|
||||
|
||||
override fun convertToAllowedCharacters(input: String): String {
|
||||
override fun convertDiacriticsAndReservedXmlCharacters(input: String): String {
|
||||
// TODO: add other replacement strings
|
||||
return input
|
||||
.replace("\"", """)
|
||||
|
|
|
@ -82,7 +82,7 @@ open class InputValidator {
|
|||
}
|
||||
|
||||
open fun convertToAllowedSepaCharacters(string: String): String {
|
||||
return sepaMessageCreator.convertToAllowedCharacters(string)
|
||||
return sepaMessageCreator.convertDiacriticsAndReservedXmlCharacters(string)
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue