Added JavaScript target. - Had to remove @JvmOverloads for that. - Had to replace Math.pow() and String.format().
This commit is contained in:
parent
fb04aad5c4
commit
fbaa9fa941
|
@ -123,7 +123,3 @@ allprojects {
|
|||
group 'net.dankito.banking'
|
||||
version appVersionName
|
||||
}
|
||||
|
||||
task clean(type: Delete) {
|
||||
delete rootProject.buildDir
|
||||
}
|
|
@ -22,6 +22,22 @@ kotlin {
|
|||
|
||||
android()
|
||||
|
||||
js() {
|
||||
|
||||
nodejs {
|
||||
testTask {
|
||||
enabled = false
|
||||
}
|
||||
}
|
||||
|
||||
browser {
|
||||
testTask {
|
||||
enabled = false
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sourceSets {
|
||||
commonMain {
|
||||
|
@ -37,7 +53,7 @@ kotlin {
|
|||
|
||||
api "com.soywiz.korlibs.klock:klock:$klockVersion"
|
||||
|
||||
api("com.ionspin.kotlin:bignum:$bigNumVersion")
|
||||
api "com.ionspin.kotlin:bignum:$bigNumVersion"
|
||||
|
||||
implementation "com.benasher44:uuid:$uuidVersion"
|
||||
}
|
||||
|
@ -48,11 +64,6 @@ kotlin {
|
|||
implementation kotlin("test-common")
|
||||
implementation kotlin("test-annotations-common")
|
||||
|
||||
|
||||
implementation project(":BankingUiCommon")
|
||||
implementation project(":BankFinder")
|
||||
implementation project(":fints4kBankingClient")
|
||||
|
||||
implementation "ch.tutteli.atrium:atrium-fluent-en_GB:$atriumVersion"
|
||||
}
|
||||
}
|
||||
|
@ -81,6 +92,13 @@ kotlin {
|
|||
implementation "org.assertj:assertj-core:$assertJVersion"
|
||||
implementation "org.mockito:mockito-core:$mockitoVersion"
|
||||
|
||||
implementation "ch.tutteli.atrium:atrium-fluent-en_GB-jvm:$atriumVersion"
|
||||
|
||||
|
||||
implementation project(":BankingUiCommon")
|
||||
implementation project(":BankFinder")
|
||||
implementation project(":fints4kBankingClient")
|
||||
|
||||
|
||||
implementation "org.apache.commons:commons-csv:1.8"
|
||||
|
||||
|
@ -98,6 +116,32 @@ kotlin {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
jsMain {
|
||||
dependsOn commonMain
|
||||
|
||||
dependencies {
|
||||
api kotlin("stdlib-js")
|
||||
|
||||
implementation "io.ktor:ktor-client-js:$ktorVersion"
|
||||
implementation "io.ktor:ktor-client-encoding-js:$ktorVersion"
|
||||
implementation "io.ktor:ktor-client-js-kotlinMultiplatform:$ktorVersion"
|
||||
|
||||
|
||||
implementation "com.soywiz.korlibs.klock:klock-js:$klockVersion"
|
||||
|
||||
implementation "com.ionspin.kotlin:bignum-js:$bigNumVersion"
|
||||
}
|
||||
}
|
||||
|
||||
jsTest {
|
||||
dependencies {
|
||||
implementation kotlin("test-js")
|
||||
|
||||
implementation "ch.tutteli.atrium:atrium-fluent-en_GB-js:$atriumVersion"
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,13 +13,11 @@ abstract class Datenelement(existenzstatus: Existenzstatus): DatenelementBase(ex
|
|||
|| existenzstatus == Existenzstatus.Optional && isValueSet
|
||||
|
||||
|
||||
@Throws(IllegalArgumentException::class)
|
||||
abstract fun validate()
|
||||
|
||||
|
||||
@Throws(IllegalArgumentException::class)
|
||||
protected fun throwValidationException(message: String) {
|
||||
throw IllegalArgumentException("Daten von ${javaClass.simpleName} sind ungültig: $message")
|
||||
throw IllegalArgumentException("Daten von ${this::class.simpleName} sind ungültig: $message")
|
||||
}
|
||||
|
||||
}
|
|
@ -6,7 +6,7 @@ import net.dankito.banking.fints.messages.Existenzstatus
|
|||
/**
|
||||
* Es gilt der FinTS-Basiszeichensatz ohne die Zeichen CR und LF.
|
||||
*/
|
||||
open class AlphanumerischesDatenelement @JvmOverloads constructor(
|
||||
open class AlphanumerischesDatenelement(
|
||||
alphanumericValue: String?, existenzstatus: Existenzstatus, val maxLength: Int? = null
|
||||
) : TextDatenelement(alphanumericValue, existenzstatus) {
|
||||
|
||||
|
|
|
@ -9,11 +9,12 @@ import net.dankito.banking.fints.messages.Existenzstatus
|
|||
* für binäre Daten keine Gültigkeit besitzt. Ferner gelten die speziellen Syntaxregeln für
|
||||
* binäre Daten (s. Kap. H.1.3).
|
||||
*/
|
||||
open class BinaerDatenelement @JvmOverloads constructor(data: String?, existenzstatus: Existenzstatus, val maxLength: Int? = null)
|
||||
open class BinaerDatenelement(data: String?, existenzstatus: Existenzstatus, val maxLength: Int? = null)
|
||||
: TextDatenelement(data, existenzstatus) {
|
||||
|
||||
@JvmOverloads constructor(data: ByteArray, existenzstatus: Existenzstatus, maxLength: Int? = null) :
|
||||
this(String(data), existenzstatus, maxLength)
|
||||
@OptIn(ExperimentalStdlibApi::class)
|
||||
constructor(data: ByteArray, existenzstatus: Existenzstatus, maxLength: Int? = null) :
|
||||
this(data.decodeToString(), existenzstatus, maxLength) // TODO: is this correct?
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,7 +14,12 @@ open class NumerischesDatenelement(val number: Int?, val numberOfDigits: Int, ex
|
|||
super.validate()
|
||||
|
||||
if (writeToOutput && number != null) { // if number is null and number has to be written to output then validation already fails above
|
||||
val maxValue = Math.pow(10.0, numberOfDigits.toDouble()) - 1
|
||||
// can't believe it, there's no Math.pow() in Kotlin multiplatform
|
||||
var maxValue = 1
|
||||
IntRange(1, numberOfDigits).forEach {
|
||||
maxValue *= 10
|
||||
}
|
||||
maxValue -= 1
|
||||
|
||||
if (number < 0 || number > maxValue) {
|
||||
throwValidationException("Wert '$number' muss im Wertebereich von 0 - $maxValue liegen.")
|
||||
|
|
|
@ -10,8 +10,15 @@ abstract class ZiffernDatenelement(value: Int?, numberOfDigits: Int, existenzsta
|
|||
: NumerischesDatenelement(value, numberOfDigits, existenzstatus) {
|
||||
|
||||
|
||||
@OptIn(ExperimentalStdlibApi::class)
|
||||
override fun formatValue(value: String): String {
|
||||
return String.format("%0${numberOfDigits}d", number)
|
||||
val formatted = StringBuilder("" + number)
|
||||
|
||||
while (formatted.length < numberOfDigits) {
|
||||
formatted.insert(0, '0')
|
||||
}
|
||||
|
||||
return formatted.toString()
|
||||
}
|
||||
|
||||
}
|
|
@ -6,7 +6,7 @@ import net.dankito.banking.fints.messages.datenelemente.implementierte.Kreditins
|
|||
import net.dankito.banking.fints.messages.datenelementgruppen.Datenelementgruppe
|
||||
|
||||
|
||||
open class Kreditinstitutskennung @JvmOverloads constructor(
|
||||
open class Kreditinstitutskennung(
|
||||
val bankCountryCode: Int,
|
||||
val bankCode: String,
|
||||
existenzstatus: Existenzstatus = Existenzstatus.Mandatory
|
||||
|
|
|
@ -8,7 +8,7 @@ import net.dankito.banking.fints.messages.datenelementgruppen.Datenelementgruppe
|
|||
import net.dankito.banking.fints.messages.segmente.id.ISegmentId
|
||||
|
||||
|
||||
open class Segmentkopf @JvmOverloads constructor(
|
||||
open class Segmentkopf(
|
||||
identifier: String,
|
||||
segmentVersion: Int,
|
||||
segmentNumber: Int = 0,
|
||||
|
|
|
@ -30,7 +30,7 @@ import net.dankito.banking.fints.messages.datenelementgruppen.Datenelementgruppe
|
|||
* des Sicherheitsverfahrens HBCI darf die DEG nicht belegt werden. Ihr Inhalt wird
|
||||
* in diesem Fall ignoriert.
|
||||
*/
|
||||
open class BenutzerdefinierteSignatur @JvmOverloads constructor(pin: String, tan: String? = null)
|
||||
open class BenutzerdefinierteSignatur(pin: String, tan: String? = null)
|
||||
: Datenelementgruppe(listOf(
|
||||
PinOrTan(pin, Existenzstatus.Mandatory),
|
||||
PinOrTan(tan, Existenzstatus.Optional)
|
||||
|
|
|
@ -12,7 +12,7 @@ import net.dankito.banking.fints.messages.segmente.id.MessageSegmentId
|
|||
* Der Signaturabschluss stellt die Verbindung mit dem dazugehörigen Signaturkopf
|
||||
* her und enthält als "Validierungsresultat" die elektronische Signatur.
|
||||
*/
|
||||
open class Signaturabschluss @JvmOverloads constructor(
|
||||
open class Signaturabschluss(
|
||||
segmentNumber: Int,
|
||||
securityControlReference: String,
|
||||
pin: String,
|
||||
|
|
|
@ -113,7 +113,7 @@ open class Response(
|
|||
|
||||
|
||||
override fun toString(): String {
|
||||
val formattedResponse = receivedResponse?.replace(Separators.SegmentSeparator, System.lineSeparator()) ?: ""
|
||||
val formattedResponse = receivedResponse?.replace(Separators.SegmentSeparator, "\r\n") ?: ""
|
||||
|
||||
if (successful) {
|
||||
return formattedResponse
|
||||
|
|
|
@ -15,7 +15,7 @@ class LoggerFactory {
|
|||
}
|
||||
|
||||
fun getLogger(kClass: KClass<*>): Logger {
|
||||
return getLogger(kClass.qualifiedName ?: kClass.toString())
|
||||
return getLogger(kClass.simpleName ?: kClass.toString()) // TODO: use qualifiedName on JVM
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>fints4k</title>
|
||||
|
||||
<script type="text/javascript" src="./fints4k.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,5 @@
|
|||
config.output = config.output || {}
|
||||
config.output.library = "fints"
|
||||
|
||||
config.devServer = config.devServer || {}
|
||||
config.devServer.port = 3001
|
Loading…
Reference in New Issue