Using now Date and UUID from common in fints4k. Could therefore remove klock
This commit is contained in:
parent
194c996ec0
commit
19c8e4ea8e
|
@ -13,12 +13,6 @@ ext {
|
|||
|
||||
ktorVersion = "1.3.2"
|
||||
|
||||
klockVersion = "1.11.12"
|
||||
|
||||
bigNumVersion = "0.1.5"
|
||||
|
||||
uuidVersion = "0.1.0"
|
||||
|
||||
|
||||
javaUtilsVersion = '1.0.16'
|
||||
|
||||
|
|
|
@ -7,6 +7,14 @@ fun NSTimeInterval.toMillis(): Long {
|
|||
return this.toLong() * 1000
|
||||
}
|
||||
|
||||
fun NSDate?.toDate(): Date? {
|
||||
return this?.toDate()
|
||||
}
|
||||
|
||||
fun NSDate.toDate(): Date {
|
||||
return Date(this)
|
||||
}
|
||||
|
||||
|
||||
actual class Date(val date: NSDate) { // cannot subclass NSDate as it's a class cluster
|
||||
|
||||
|
|
|
@ -62,10 +62,6 @@ kotlin {
|
|||
api project(":common")
|
||||
|
||||
implementation "io.ktor:ktor-client-core:$ktorVersion"
|
||||
|
||||
api "com.soywiz.korlibs.klock:klock:$klockVersion"
|
||||
|
||||
implementation "com.benasher44:uuid:$uuidVersion"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -84,8 +80,6 @@ kotlin {
|
|||
// implementation "io.ktor:ktor-client-cio:$ktorVersion"
|
||||
implementation "io.ktor:ktor-client-okhttp:$ktorVersion"
|
||||
|
||||
api "com.soywiz.korlibs.klock:klock-jvm:$klockVersion"
|
||||
|
||||
implementation "org.slf4j:slf4j-api:$slf4jVersion"
|
||||
}
|
||||
}
|
||||
|
@ -143,9 +137,6 @@ kotlin {
|
|||
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"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
package net.dankito.banking.fints
|
||||
|
||||
import com.soywiz.klock.DateTime
|
||||
import com.soywiz.klock.DateTimeSpan
|
||||
import com.soywiz.klock.DateTimeTz
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.launch
|
||||
import net.dankito.banking.fints.callback.FinTsClientCallback
|
||||
|
@ -35,6 +32,7 @@ import net.dankito.utils.multiplatform.log.LoggerFactory
|
|||
import net.dankito.banking.fints.webclient.IWebClient
|
||||
import net.dankito.banking.fints.webclient.KtorWebClient
|
||||
import net.dankito.banking.fints.webclient.WebClientResponse
|
||||
import net.dankito.utils.multiplatform.Date
|
||||
|
||||
|
||||
open class FinTsClient(
|
||||
|
@ -51,6 +49,8 @@ open class FinTsClient(
|
|||
val FindAccountTransactionsStartRegex = Regex("^HIKAZ:\\d:\\d:\\d\\+@\\d+@", RegexOption.MULTILINE)
|
||||
val FindAccountTransactionsEndRegex = Regex("^-'", RegexOption.MULTILINE)
|
||||
|
||||
const val NinetyDaysMillis = 90 * 24 * 60 * 60 * 1000L
|
||||
|
||||
|
||||
private val log = LoggerFactory.getLogger(FinTsClient::class)
|
||||
}
|
||||
|
@ -285,10 +285,10 @@ open class FinTsClient(
|
|||
protected open fun tryGetTransactionsOfLast90DaysWithoutTan(bank: BankData, customer: CustomerData, account: AccountData,
|
||||
hasRetrievedTransactionsWithTanJustBefore: Boolean): GetTransactionsResponse {
|
||||
|
||||
val now = DateTimeTz.nowLocal()
|
||||
val ninetyDaysAgo = now.minus(DateTimeSpan(days = 90))
|
||||
val now = Date()
|
||||
val ninetyDaysAgo = Date(now.millisSinceEpoch - NinetyDaysMillis)
|
||||
|
||||
val response = getTransactions(GetTransactionsParameter(account.supportsFeature(AccountFeature.RetrieveBalance), ninetyDaysAgo.local.date, abortIfTanIsRequired = true), bank, customer, account)
|
||||
val response = getTransactions(GetTransactionsParameter(account.supportsFeature(AccountFeature.RetrieveBalance), ninetyDaysAgo, abortIfTanIsRequired = true), bank, customer, account)
|
||||
|
||||
|
||||
account.triedToRetrieveTransactionsOfLast90DaysWithoutTan = true
|
||||
|
@ -669,7 +669,7 @@ open class FinTsClient(
|
|||
|
||||
|
||||
protected open fun addMessageLog(message: String, type: MessageLogEntryType, dialogContext: DialogContext) {
|
||||
val timeStamp = DateTime.now()
|
||||
val timeStamp = Date()
|
||||
val messagePrefix = "${if (type == MessageLogEntryType.Sent) "Sending" else "Received"} message:\r\n" // currently no need to translate
|
||||
val prettyPrintMessage = prettyPrintHbciMessage(message)
|
||||
val prettyPrintMessageWithPrefix = "$messagePrefix$prettyPrintMessage"
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package net.dankito.banking.fints.messages
|
||||
|
||||
import com.soywiz.klock.DateTime
|
||||
import net.dankito.banking.fints.messages.datenelemente.implementierte.Aufsetzpunkt
|
||||
import net.dankito.banking.fints.messages.datenelemente.implementierte.KundensystemID
|
||||
import net.dankito.banking.fints.messages.datenelemente.implementierte.Synchronisierungsmodus
|
||||
|
@ -23,6 +22,7 @@ import net.dankito.banking.fints.response.segments.JobParameters
|
|||
import net.dankito.banking.fints.response.segments.SepaAccountInfoParameters
|
||||
import net.dankito.banking.fints.response.segments.TanResponse
|
||||
import net.dankito.banking.fints.util.FinTsUtils
|
||||
import net.dankito.utils.multiplatform.Date
|
||||
import kotlin.math.absoluteValue
|
||||
import kotlin.random.Random
|
||||
|
||||
|
@ -357,7 +357,7 @@ open class MessageBuilder(protected val generator: ISegmentNumberGenerator = Seg
|
|||
}
|
||||
|
||||
protected open fun createControlReference(): String {
|
||||
return Random(DateTime.nowUnixLong()).nextInt().absoluteValue.toString()
|
||||
return Random(Date().millisSinceEpoch).nextInt().absoluteValue.toString()
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
package net.dankito.banking.fints.messages.datenelemente.abgeleiteteformate
|
||||
|
||||
import com.soywiz.klock.Date
|
||||
import com.soywiz.klock.DateFormat
|
||||
import com.soywiz.klock.parse
|
||||
import net.dankito.banking.fints.messages.Existenzstatus
|
||||
import net.dankito.banking.fints.messages.datenelemente.basisformate.NumerischesDatenelement
|
||||
import net.dankito.utils.multiplatform.Date
|
||||
import net.dankito.utils.multiplatform.DateFormatter
|
||||
|
||||
|
||||
/**
|
||||
|
@ -17,15 +16,15 @@ open class Datum(date: Int?, existenzstatus: Existenzstatus) : NumerischesDatene
|
|||
companion object {
|
||||
const val HbciDateFormatString = "yyyyMMdd"
|
||||
|
||||
val HbciDateFormat = DateFormat(HbciDateFormatString)
|
||||
val HbciDateFormat = DateFormatter(HbciDateFormatString)
|
||||
|
||||
|
||||
fun format(date: Date): String {
|
||||
return HbciDateFormat.format(date.dateTimeDayStart.localUnadjusted) // TODO: is this correct?
|
||||
return HbciDateFormat.format(date) // TODO: is this correct?
|
||||
}
|
||||
|
||||
fun parse(dateString: String): Date {
|
||||
return HbciDateFormat.parse(dateString).utc.date // TODO: really use UTC?
|
||||
return HbciDateFormat.parse(dateString) !!
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
package net.dankito.banking.fints.messages.datenelemente.abgeleiteteformate
|
||||
|
||||
import com.soywiz.klock.*
|
||||
import net.dankito.banking.fints.messages.Existenzstatus
|
||||
import net.dankito.banking.fints.messages.datenelemente.basisformate.ZiffernDatenelement
|
||||
import net.dankito.utils.multiplatform.Date
|
||||
import net.dankito.utils.multiplatform.DateFormatter
|
||||
|
||||
|
||||
/**
|
||||
|
@ -16,20 +17,20 @@ open class Uhrzeit(time: Int?, existenzstatus: Existenzstatus) : ZiffernDatenele
|
|||
companion object {
|
||||
const val HbciTimeFormatString = "HHmmss"
|
||||
|
||||
val HbciTimeFormat = DateFormat(HbciTimeFormatString)
|
||||
val HbciTimeFormat = DateFormatter(HbciTimeFormatString)
|
||||
|
||||
|
||||
fun format(time: Time): String {
|
||||
return HbciTimeFormat.format(DateTimeTz.Companion.fromUnixLocal(time.encoded.milliseconds)) // TODO: is this correct?
|
||||
fun format(time: Date): String {
|
||||
return HbciTimeFormat.format(time) // TODO: is this correct?
|
||||
}
|
||||
|
||||
fun parse(dateString: String): Time {
|
||||
return HbciTimeFormat.parse(dateString).utc.time // TODO: is this correct?
|
||||
fun parse(dateString: String): Date {
|
||||
return HbciTimeFormat.parse(dateString) !!
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
constructor(time: Time?, existenzstatus: Existenzstatus)
|
||||
constructor(time: Date?, existenzstatus: Existenzstatus)
|
||||
: this(time?.let { format(time).toInt() }, existenzstatus)
|
||||
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
package net.dankito.banking.fints.messages.datenelemente.implementierte.tan
|
||||
|
||||
import com.soywiz.klock.Date
|
||||
import net.dankito.utils.multiplatform.Date
|
||||
|
||||
|
||||
open class TanGeneratorTanMedium(
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package net.dankito.banking.fints.messages.segmente.implementierte.sepa
|
||||
|
||||
import com.soywiz.klock.DateFormat
|
||||
import com.soywiz.klock.DateTime
|
||||
import net.dankito.utils.multiplatform.Date
|
||||
import net.dankito.utils.multiplatform.DateFormatter
|
||||
|
||||
|
||||
/**
|
||||
|
@ -28,7 +28,7 @@ open class SepaMessageCreator : ISepaMessageCreator {
|
|||
|
||||
const val NumberOfTransactionsKey = "NumberOfTransactions"
|
||||
|
||||
val IsoDateFormat = DateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS")
|
||||
val IsoDateFormat = DateFormatter("yyyy-MM-dd'T'HH:mm:ss.SSS")
|
||||
}
|
||||
|
||||
|
||||
|
@ -85,8 +85,8 @@ open class SepaMessageCreator : ISepaMessageCreator {
|
|||
override fun createXmlFile(messageTemplate: PaymentInformationMessages, replacementStrings: Map<String, String>): String {
|
||||
var xmlFile = messageTemplate.xmlTemplate
|
||||
|
||||
val now = DateTime.now()
|
||||
val nowInIsoDate = IsoDateFormat.format(now.localUnadjusted)
|
||||
val now = Date()
|
||||
val nowInIsoDate = IsoDateFormat.format(now)
|
||||
|
||||
if (replacementStrings.containsKey(MessageIdKey) == false) {
|
||||
xmlFile = replacePlaceholderWithValue(xmlFile, MessageIdKey, nowInIsoDate)
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package net.dankito.banking.fints.model
|
||||
|
||||
import com.soywiz.klock.Date
|
||||
import com.soywiz.klock.DateTime
|
||||
import net.dankito.utils.multiplatform.Date
|
||||
|
||||
|
||||
open class AccountTransaction(
|
||||
|
@ -45,7 +44,7 @@ open class AccountTransaction(
|
|||
) {
|
||||
|
||||
// for object deserializers
|
||||
internal constructor() : this(AccountData(), Money(Amount.Zero, ""), false, "", DateTime.EPOCH.date, null, null, null, null, DateTime.EPOCH.date, 0, null, null, null,
|
||||
internal constructor() : this(AccountData(), Money(Amount.Zero, ""), false, "", Date(0), null, null, null, null, Date(0), 0, null, null, null,
|
||||
null, null, null, null, null, null, null, null, null, null, null, null, null,
|
||||
null, "", "", null, null, "", null)
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package net.dankito.banking.fints.model
|
||||
|
||||
import com.soywiz.klock.Date
|
||||
import net.dankito.utils.multiplatform.Date
|
||||
|
||||
|
||||
open class GetTransactionsParameter(
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package net.dankito.banking.fints.model
|
||||
|
||||
import com.soywiz.klock.DateTime
|
||||
import net.dankito.utils.multiplatform.Date
|
||||
|
||||
|
||||
open class MessageLogEntry(
|
||||
val message: String,
|
||||
val time: DateTime,
|
||||
val time: Date,
|
||||
val customer: CustomerData
|
||||
) {
|
||||
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
package net.dankito.banking.fints.response
|
||||
|
||||
import com.soywiz.klock.Date
|
||||
import com.soywiz.klock.DateTime
|
||||
import com.soywiz.klock.Time
|
||||
import net.dankito.banking.fints.messages.Separators
|
||||
import net.dankito.banking.fints.messages.datenelemente.abgeleiteteformate.Datum
|
||||
import net.dankito.banking.fints.messages.datenelemente.abgeleiteteformate.Uhrzeit
|
||||
|
@ -20,6 +17,7 @@ import net.dankito.banking.fints.messages.segmente.id.MessageSegmentId
|
|||
import net.dankito.banking.fints.model.Amount
|
||||
import net.dankito.banking.fints.response.segments.*
|
||||
import net.dankito.banking.fints.util.MessageUtils
|
||||
import net.dankito.utils.multiplatform.Date
|
||||
import net.dankito.utils.multiplatform.log.LoggerFactory
|
||||
|
||||
|
||||
|
@ -837,13 +835,13 @@ open class ResponseParser(
|
|||
return Amount(adjustedAmountString)
|
||||
}
|
||||
|
||||
protected open fun parseNullableDateTime(dataElementGroup: String): DateTime? {
|
||||
protected open fun parseNullableDateTime(dataElementGroup: String): Date? {
|
||||
val dataElements = getDataElements(dataElementGroup)
|
||||
|
||||
if (dataElements.size >= 2) {
|
||||
parseNullableDate(dataElements[0])?.let { date ->
|
||||
parseNullableTime(dataElements[1])?.let { time ->
|
||||
return DateTime.Companion.invoke(date, time)
|
||||
return Date(date.millisSinceEpoch + time.millisSinceEpoch) // TODO: is this correct?
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -863,11 +861,11 @@ open class ResponseParser(
|
|||
return null
|
||||
}
|
||||
|
||||
protected open fun parseTime(timeString: String): Time {
|
||||
protected open fun parseTime(timeString: String): Date {
|
||||
return Uhrzeit.parse(timeString)
|
||||
}
|
||||
|
||||
protected open fun parseNullableTime(timeString: String): Time? {
|
||||
protected open fun parseNullableTime(timeString: String): Date? {
|
||||
try {
|
||||
return parseTime(timeString)
|
||||
} catch (ignored: Exception) { }
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
package net.dankito.banking.fints.response.segments
|
||||
|
||||
import com.soywiz.klock.Date
|
||||
import com.soywiz.klock.Time
|
||||
import net.dankito.banking.fints.model.Amount
|
||||
import net.dankito.utils.multiplatform.Date
|
||||
|
||||
|
||||
open class Balance(
|
||||
val amount: Amount,
|
||||
val date: Date,
|
||||
val time: Time?
|
||||
val time: Date?
|
||||
) {
|
||||
|
||||
override fun toString(): String {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package net.dankito.banking.fints.response.segments
|
||||
|
||||
import com.soywiz.klock.Date
|
||||
import net.dankito.banking.fints.model.Amount
|
||||
import net.dankito.utils.multiplatform.Date
|
||||
|
||||
|
||||
open class BalanceSegment(
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package net.dankito.banking.fints.response.segments
|
||||
|
||||
import com.soywiz.klock.DateTime
|
||||
import net.dankito.banking.fints.messages.datenelemente.implementierte.tan.TanProcess
|
||||
import net.dankito.utils.multiplatform.Date
|
||||
|
||||
|
||||
open class TanResponse(
|
||||
|
@ -31,7 +31,7 @@ open class TanResponse(
|
|||
val challenge: String?, // M: bei TAN-Prozess=1, 3, 4. O: bei TAN-Prozess=2
|
||||
|
||||
val challengeHHD_UC: String?,
|
||||
val validityDateTimeForChallenge: DateTime?,
|
||||
val validityDateTimeForChallenge: Date?,
|
||||
val tanMediaIdentifier: String? = null, // M: bei TAN-Prozess=1, 3, 4 und „Anzahl unterstützter aktiver TAN-Medien“ nicht vorhanden. O: sonst
|
||||
|
||||
segmentString: String
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package net.dankito.banking.fints.transactions.mt940
|
||||
|
||||
import com.soywiz.klock.*
|
||||
import net.dankito.banking.fints.model.Amount
|
||||
import net.dankito.banking.fints.transactions.mt940.model.*
|
||||
import net.dankito.utils.multiplatform.Date
|
||||
import net.dankito.utils.multiplatform.DateFormatter
|
||||
import net.dankito.utils.multiplatform.Month
|
||||
import net.dankito.utils.multiplatform.log.LoggerFactory
|
||||
|
||||
|
||||
|
@ -442,7 +444,7 @@ open class Mt940Parser : IMt940Parser {
|
|||
}
|
||||
}
|
||||
|
||||
return DateFormat.parse(dateString).utc.date // fallback to not thread-safe SimpleDateFormat. Works in most cases but not all
|
||||
return DateFormatter.parse(dateString)!! // fallback to not thread-safe SimpleDateFormat. Works in most cases but not all
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -452,8 +454,9 @@ open class Mt940Parser : IMt940Parser {
|
|||
val bookingDate = parseMt940Date(valueDateString.substring(0, 2) + bookingDateString)
|
||||
|
||||
// there are rare cases that booking date is e.g. on 31.12.2019 and value date on 01.01.2020 -> booking date would be on 31.12.2020 (and therefore in the future)
|
||||
if (bookingDate.month != valueDate.month && bookingDate.month == Month.December) {
|
||||
return parseMt940Date("" + (valueDate.year - 1 - 2000) + bookingDateString)
|
||||
val bookingDateMonth = bookingDate.month()
|
||||
if (bookingDateMonth != valueDate.month() && bookingDateMonth == Month.December) {
|
||||
return parseMt940Date("" + (valueDate.year() - 1 - 2000) + bookingDateString)
|
||||
}
|
||||
|
||||
return bookingDate
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
package net.dankito.banking.fints.transactions.mt940.model
|
||||
|
||||
import com.soywiz.klock.Date
|
||||
import com.soywiz.klock.DateTime
|
||||
import net.dankito.banking.fints.model.Amount
|
||||
import net.dankito.utils.multiplatform.Date
|
||||
|
||||
|
||||
open class Balance(
|
||||
|
@ -42,7 +41,7 @@ open class Balance(
|
|||
|
||||
) {
|
||||
|
||||
internal constructor() : this(false, false, DateTime.EPOCH.date, "", Amount.Zero) // for object deserializers
|
||||
internal constructor() : this(false, false, Date(0), "", Amount.Zero) // for object deserializers
|
||||
|
||||
|
||||
override fun toString(): String {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package net.dankito.banking.fints.transactions.mt940.model
|
||||
|
||||
import com.soywiz.klock.Date
|
||||
import net.dankito.banking.fints.model.Amount
|
||||
import net.dankito.utils.multiplatform.Date
|
||||
|
||||
|
||||
open class StatementLine(
|
||||
|
|
|
@ -1,17 +1,15 @@
|
|||
package net.dankito.banking.fints.util
|
||||
|
||||
import com.soywiz.klock.Date
|
||||
import com.soywiz.klock.DateTime
|
||||
import com.soywiz.klock.Time
|
||||
import net.dankito.banking.fints.messages.datenelemente.abgeleiteteformate.Datum
|
||||
import net.dankito.banking.fints.messages.datenelemente.abgeleiteteformate.Uhrzeit
|
||||
import net.dankito.utils.multiplatform.Date
|
||||
|
||||
|
||||
open class FinTsUtils {
|
||||
|
||||
|
||||
open fun formatDateToday(): String {
|
||||
return formatDate(DateTime.now().date)
|
||||
return formatDate(Date())
|
||||
}
|
||||
|
||||
open fun formatDate(date: Date): String {
|
||||
|
@ -28,10 +26,10 @@ open class FinTsUtils {
|
|||
|
||||
|
||||
open fun formatTimeNow(): String {
|
||||
return formatTime(DateTime.now().time)
|
||||
return formatTime(Date())
|
||||
}
|
||||
|
||||
open fun formatTime(time: Time): String {
|
||||
open fun formatTime(time: Date): String {
|
||||
return Uhrzeit.format(time)
|
||||
}
|
||||
|
||||
|
@ -39,7 +37,7 @@ open class FinTsUtils {
|
|||
return convertToInt(formatTimeNow())
|
||||
}
|
||||
|
||||
open fun formatTimeAsInt(time: Time): Int {
|
||||
open fun formatTimeAsInt(time: Date): Int {
|
||||
return convertToInt(formatTime(time))
|
||||
}
|
||||
|
||||
|
|
|
@ -2,9 +2,6 @@ package net.dankito.banking.fints
|
|||
|
||||
import ch.tutteli.atrium.api.fluent.en_GB.*
|
||||
import ch.tutteli.atrium.api.verbs.expect
|
||||
import com.benasher44.uuid.uuid4
|
||||
import com.soywiz.klock.DateFormat
|
||||
import com.soywiz.klock.DateTimeTz
|
||||
import net.dankito.banking.bankfinder.InMemoryBankFinder
|
||||
import net.dankito.banking.fints.callback.FinTsClientCallback
|
||||
import net.dankito.banking.fints.extensions.isTrue
|
||||
|
@ -26,6 +23,9 @@ import net.dankito.banking.fints.util.IBase64Service
|
|||
import net.dankito.banking.fints.util.IThreadPool
|
||||
import net.dankito.banking.fints.util.PureKotlinBase64Service
|
||||
import net.dankito.banking.fints.webclient.KtorWebClient
|
||||
import net.dankito.utils.multiplatform.Date
|
||||
import net.dankito.utils.multiplatform.DateFormatter
|
||||
import net.dankito.utils.multiplatform.UUID
|
||||
import kotlin.test.DefaultAsserter.fail
|
||||
import kotlin.test.Ignore
|
||||
import kotlin.test.Test
|
||||
|
@ -35,7 +35,7 @@ import kotlin.test.Test
|
|||
open class FinTsClientTestBase {
|
||||
|
||||
companion object {
|
||||
val DateTimeFormatForUniqueBankTransferUsage = DateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS")
|
||||
val DateTimeFormatForUniqueBankTransferUsage = DateFormatter("yyyy-MM-dd'T'HH:mm:ss.SSS")
|
||||
}
|
||||
|
||||
|
||||
|
@ -222,7 +222,7 @@ open class FinTsClientTestBase {
|
|||
|
||||
// transfer 1 cent to yourself. Transferring money to oneself also doesn't require to enter a TAN according to PSD2
|
||||
val BankTransferData = BankTransferData(Customer.name, account?.iban!!, Bank.bic, Money(Amount("0,01"), "EUR"),
|
||||
"${DateTimeFormatForUniqueBankTransferUsage.format(DateTimeTz.nowLocal())} Test transaction ${uuid4()}")
|
||||
"${DateTimeFormatForUniqueBankTransferUsage.format(Date())} Test transaction ${UUID.random()}")
|
||||
|
||||
|
||||
// when
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package net.dankito.banking.fints
|
||||
|
||||
import com.benasher44.uuid.uuid4
|
||||
import com.soywiz.klock.Date
|
||||
import net.dankito.banking.fints.messages.datenelemente.abgeleiteteformate.Datum
|
||||
import net.dankito.banking.fints.messages.datenelemente.abgeleiteteformate.Laenderkennzeichen
|
||||
import net.dankito.banking.fints.messages.datenelemente.implementierte.Dialogsprache
|
||||
|
@ -10,6 +8,8 @@ import net.dankito.banking.fints.model.*
|
|||
import net.dankito.banking.fints.response.segments.AccountType
|
||||
import net.dankito.banking.fints.response.segments.ChangeTanMediaParameters
|
||||
import net.dankito.banking.fints.response.segments.JobParameters
|
||||
import net.dankito.utils.multiplatform.Date
|
||||
import net.dankito.utils.multiplatform.UUID
|
||||
|
||||
|
||||
abstract class FinTsTestBase {
|
||||
|
@ -64,7 +64,7 @@ abstract class FinTsTestBase {
|
|||
|
||||
|
||||
protected open fun createDialogId(): String {
|
||||
return uuid4().toString().replace("-", "")
|
||||
return UUID.random().replace("-", "")
|
||||
}
|
||||
|
||||
protected open fun convertDate(date: Date): String {
|
||||
|
|
|
@ -3,14 +3,13 @@ package net.dankito.banking.fints.messages
|
|||
import ch.tutteli.atrium.api.fluent.en_GB.notToBeNull
|
||||
import ch.tutteli.atrium.api.fluent.en_GB.toBe
|
||||
import ch.tutteli.atrium.api.verbs.expect
|
||||
import com.soywiz.klock.Date
|
||||
import com.soywiz.klock.Month
|
||||
import com.soywiz.klock.Time
|
||||
import net.dankito.banking.fints.FinTsTestBase
|
||||
import net.dankito.banking.fints.model.*
|
||||
import net.dankito.banking.fints.response.segments.AccountType
|
||||
import net.dankito.banking.fints.response.segments.JobParameters
|
||||
import net.dankito.banking.fints.util.FinTsUtils
|
||||
import net.dankito.utils.multiplatform.Date
|
||||
import net.dankito.utils.multiplatform.Month
|
||||
import kotlin.test.AfterTest
|
||||
import kotlin.test.Test
|
||||
|
||||
|
@ -22,7 +21,7 @@ class MessageBuilderTest : FinTsTestBase() {
|
|||
return Date.toString()
|
||||
}
|
||||
|
||||
override fun formatTime(time: Time): String {
|
||||
override fun formatTime(time: Date): String {
|
||||
return Time.toString()
|
||||
}
|
||||
}) {
|
||||
|
|
|
@ -16,6 +16,7 @@ import ch.tutteli.atrium.api.verbs.expect
|
|||
import net.dankito.banking.fints.extensions.isFalse
|
||||
import net.dankito.banking.fints.extensions.isTrue
|
||||
import net.dankito.banking.fints.model.Amount
|
||||
import net.dankito.utils.multiplatform.Date
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.fail
|
||||
|
||||
|
@ -965,7 +966,7 @@ class ResponseParserTest : FinTsTestBase() {
|
|||
|
||||
// given
|
||||
val balance = "1234,56"
|
||||
val date = com.soywiz.klock.Date(1988, 3, 27)
|
||||
val date = Date(1988, 3, 27)
|
||||
val bankCode = "12345678"
|
||||
val accountId = "0987654321"
|
||||
val accountProductName = "Sichteinlagen"
|
||||
|
@ -992,7 +993,7 @@ class ResponseParserTest : FinTsTestBase() {
|
|||
|
||||
// given
|
||||
val balance = Amount.Zero
|
||||
val date = com.soywiz.klock.Date(2020, 6, 11)
|
||||
val date = Date(2020, 6, 11)
|
||||
val bankCode = "12345678"
|
||||
val accountId = "0987654321"
|
||||
val accountProductName = "Girokonto"
|
||||
|
@ -1019,7 +1020,7 @@ class ResponseParserTest : FinTsTestBase() {
|
|||
|
||||
// given
|
||||
val balance = Amount.Zero
|
||||
val date = com.soywiz.klock.Date(2020, 6, 11)
|
||||
val date = Date(2020, 6, 11)
|
||||
val bankCode = "12345678"
|
||||
val accountId = "0987654321"
|
||||
val accountProductName = "Girokonto"
|
||||
|
|
|
@ -10,10 +10,10 @@ import net.dankito.banking.fints.transactions.mt940.model.InformationToAccountOw
|
|||
import net.dankito.banking.fints.transactions.mt940.model.StatementLine
|
||||
import ch.tutteli.atrium.api.verbs.expect
|
||||
import kotlin.test.Test
|
||||
import com.soywiz.klock.Date
|
||||
import com.soywiz.klock.DateFormat
|
||||
import net.dankito.banking.fints.extensions.isFalse
|
||||
import net.dankito.banking.fints.model.Amount
|
||||
import net.dankito.utils.multiplatform.Date
|
||||
import net.dankito.utils.multiplatform.DateFormatter
|
||||
|
||||
|
||||
class Mt940ParserTest : FinTsTestBase() {
|
||||
|
@ -39,6 +39,9 @@ class Mt940ParserTest : FinTsTestBase() {
|
|||
|
||||
val AccountStatement1ClosingBalanceAmount = Amount("13580,23")
|
||||
val AccountStatement1With2TransactionsClosingBalanceAmount = Amount("13148,13")
|
||||
|
||||
val Mt940DateFormatter = DateFormatter("yyMMdd")
|
||||
val BookingDateFormatter = DateFormatter("MMdd")
|
||||
}
|
||||
|
||||
private val underTest = Mt940Parser()
|
||||
|
@ -348,11 +351,11 @@ class Mt940ParserTest : FinTsTestBase() {
|
|||
|
||||
|
||||
private fun convertMt940Date(date: Date): String {
|
||||
return Mt940Parser.DateFormat.format(date.dateTimeDayStart.localUnadjusted)
|
||||
return Mt940DateFormatter.format(date)
|
||||
}
|
||||
|
||||
private fun convertToShortBookingDate(date: Date): String {
|
||||
return DateFormat("MMdd").format(date.dateTimeDayStart.localUnadjusted)
|
||||
return BookingDateFormatter.format(date)
|
||||
}
|
||||
|
||||
}
|
|
@ -4,7 +4,7 @@ import ch.tutteli.atrium.api.fluent.en_GB.ExperimentalWithOptions
|
|||
import ch.tutteli.atrium.api.fluent.en_GB.toBe
|
||||
import ch.tutteli.atrium.api.fluent.en_GB.withRepresentation
|
||||
import ch.tutteli.atrium.api.verbs.expect
|
||||
import com.soywiz.klock.DateTime
|
||||
import net.dankito.utils.multiplatform.Date
|
||||
import kotlin.random.Random
|
||||
import kotlin.test.Test
|
||||
|
||||
|
@ -60,7 +60,7 @@ class Base64Test {
|
|||
@ExperimentalWithOptions
|
||||
fun testRandomStrings() {
|
||||
val steps = 1000000
|
||||
val random = Random(DateTime.nowUnixLong())
|
||||
val random = Random(Date().millisSinceEpoch)
|
||||
|
||||
for (count in 0 until steps) {
|
||||
// given
|
||||
|
|
|
@ -2,8 +2,7 @@ package net.dankito.banking.fints.util
|
|||
|
||||
import ch.tutteli.atrium.api.fluent.en_GB.toBe
|
||||
import ch.tutteli.atrium.api.verbs.expect
|
||||
import com.soywiz.klock.Date
|
||||
import com.soywiz.klock.Time
|
||||
import net.dankito.utils.multiplatform.Date
|
||||
import kotlin.test.Test
|
||||
|
||||
class FinTsUtilsTest {
|
||||
|
@ -42,7 +41,7 @@ class FinTsUtilsTest {
|
|||
fun formatTime_AM() {
|
||||
|
||||
// given
|
||||
val time = Time(8, 2, 1)
|
||||
val time = Date(8, 2, 1)
|
||||
|
||||
// when
|
||||
val result = underTest.formatTime(time)
|
||||
|
@ -55,7 +54,7 @@ class FinTsUtilsTest {
|
|||
fun formatTime_PM() {
|
||||
|
||||
// given
|
||||
val time = Time(18, 22, 51)
|
||||
val time = Date(18, 22, 51)
|
||||
|
||||
// when
|
||||
val result = underTest.formatTime(time)
|
||||
|
@ -68,7 +67,7 @@ class FinTsUtilsTest {
|
|||
fun formatTimeAsInt_AM() {
|
||||
|
||||
// given
|
||||
val time = Time(8, 2, 1)
|
||||
val time = Date(8, 2, 1)
|
||||
|
||||
// when
|
||||
val result = underTest.formatTimeAsInt(time)
|
||||
|
@ -81,7 +80,7 @@ class FinTsUtilsTest {
|
|||
fun formatTimeAsInt_PM() {
|
||||
|
||||
// given
|
||||
val time = Time(18, 22, 51)
|
||||
val time = Date(18, 22, 51)
|
||||
|
||||
// when
|
||||
val result = underTest.formatTimeAsInt(time)
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import com.soywiz.klock.Date
|
||||
import kotlinx.cinterop.addressOf
|
||||
import kotlinx.cinterop.convert
|
||||
import kotlinx.cinterop.usePinned
|
||||
|
@ -14,19 +13,4 @@ fun ByteArray.toNSData(): NSData = NSMutableData().apply {
|
|||
this@toNSData.usePinned {
|
||||
appendBytes(it.addressOf(0), size.convert())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun NSDate?.toDate(): Date? {
|
||||
return this?.toDate()
|
||||
}
|
||||
|
||||
fun NSDate.toDate(): Date {
|
||||
val calendar = NSCalendar.currentCalendar()
|
||||
|
||||
return Date.invoke(
|
||||
calendar.component(NSCalendarUnitYear, this).toInt(),
|
||||
calendar.component(NSCalendarUnitMonth, this).toInt(),
|
||||
calendar.component(NSCalendarUnitDay, this).toInt()
|
||||
)
|
||||
}
|
|
@ -8,6 +8,7 @@ import net.dankito.banking.fints.response.client.AddAccountResponse
|
|||
import net.dankito.banking.fints.response.client.FinTsClientResponse
|
||||
import net.dankito.banking.fints.response.client.GetTransactionsResponse
|
||||
import net.dankito.banking.fints.webclient.IWebClient
|
||||
import net.dankito.utils.multiplatform.toDate
|
||||
import kotlin.native.concurrent.TransferMode
|
||||
import kotlin.native.concurrent.Worker
|
||||
import kotlin.native.concurrent.freeze
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package net.dankito.banking.persistence
|
||||
|
||||
import net.dankito.utils.multiplatform.File
|
||||
import net.dankito.banking.LuceneConfig
|
||||
import net.dankito.banking.LuceneConfig.Companion.AmountFieldName
|
||||
import net.dankito.banking.LuceneConfig.Companion.BalanceFieldName
|
||||
|
@ -22,7 +23,6 @@ import net.dankito.utils.lucene.index.DocumentsWriter
|
|||
import net.dankito.utils.lucene.index.FieldBuilder
|
||||
import org.apache.lucene.index.IndexableField
|
||||
import org.slf4j.LoggerFactory
|
||||
import java.io.File
|
||||
|
||||
|
||||
open class LuceneBankingPersistence(
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
rootProject.name = 'fints4kProject'
|
||||
|
||||
enableFeaturePreview('GRADLE_METADATA') // for klock
|
||||
enableFeaturePreview('GRADLE_METADATA')
|
||||
|
||||
|
||||
include ':fints4k'
|
||||
|
|
|
@ -2,7 +2,7 @@ package net.dankito.banking.extensions
|
|||
|
||||
import net.dankito.banking.fints.model.Amount
|
||||
import net.dankito.banking.fints.model.Money
|
||||
import java.math.BigDecimal
|
||||
import net.dankito.utils.multiplatform.BigDecimal
|
||||
|
||||
|
||||
fun BigDecimal.toAmount(): Amount {
|
||||
|
@ -13,10 +13,10 @@ fun BigDecimal.toMoney(): Money {
|
|||
return Money(this.toAmount(), "EUR")
|
||||
}
|
||||
|
||||
fun Amount.toJavaBigDecimal(): BigDecimal {
|
||||
fun Amount.toBigDecimal(): BigDecimal {
|
||||
return BigDecimal(this.string.replace(',', '.'))
|
||||
}
|
||||
|
||||
fun Money.toJavaBigDecimal(): BigDecimal {
|
||||
return this.amount.toJavaBigDecimal()
|
||||
fun Money.toBigDecimal(): BigDecimal {
|
||||
return this.amount.toBigDecimal()
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
package net.dankito.banking.extensions
|
||||
|
||||
import com.soywiz.klock.jvm.toDate
|
||||
import com.soywiz.klock.jvm.toDateTime
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
|
||||
|
||||
fun Date.toKlockDate(): com.soywiz.klock.Date {
|
||||
return this.toDateTime().date
|
||||
}
|
||||
|
||||
fun com.soywiz.klock.Date.toJavaUtilDate(): Date {
|
||||
try {
|
||||
// there's a bug that some banks like Sparkasse return as date '190229' (= 29.02.2019), which simply doesn't exist
|
||||
return this.dateTimeDayStart.toDate()
|
||||
} catch (e: Exception) { // -> catch it and parse it manually, java.util.Date knows how to handle this
|
||||
return SimpleDateFormat("yyyy-MM-dd").parse(String.format("%04d-%02d-%02d", this.year, this.month1, this.day))
|
||||
}
|
||||
|
||||
}
|
|
@ -8,6 +8,7 @@ import net.dankito.banking.ui.model.tan.ImageTanChallenge
|
|||
import net.dankito.banking.ui.model.tan.TanChallenge
|
||||
import net.dankito.banking.ui.model.tan.TanImage
|
||||
import net.dankito.banking.util.hbci4jModelMapper
|
||||
import net.dankito.utils.multiplatform.Date
|
||||
import org.kapott.hbci.callback.AbstractHBCICallback
|
||||
import org.kapott.hbci.callback.HBCICallback
|
||||
import org.kapott.hbci.manager.HBCIUtils
|
||||
|
@ -15,7 +16,6 @@ import org.kapott.hbci.manager.MatrixCode
|
|||
import org.kapott.hbci.manager.QRCode
|
||||
import org.kapott.hbci.passport.HBCIPassport
|
||||
import org.slf4j.LoggerFactory
|
||||
import java.util.*
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -15,6 +15,10 @@ import net.dankito.banking.util.hbci4jModelMapper
|
|||
import net.dankito.banking.bankfinder.BankInfo
|
||||
import net.dankito.banking.util.*
|
||||
import net.dankito.utils.ThreadPool
|
||||
import net.dankito.utils.multiplatform.BigDecimal
|
||||
import net.dankito.utils.multiplatform.Date
|
||||
import net.dankito.utils.multiplatform.File
|
||||
import net.dankito.utils.multiplatform.toBigDecimal
|
||||
import org.kapott.hbci.GV.HBCIJob
|
||||
import org.kapott.hbci.GV_Result.GVRKUms
|
||||
import org.kapott.hbci.GV_Result.GVRSaldoReq
|
||||
|
@ -26,8 +30,6 @@ import org.kapott.hbci.passport.HBCIPassport
|
|||
import org.kapott.hbci.status.HBCIExecStatus
|
||||
import org.kapott.hbci.structures.Value
|
||||
import org.slf4j.LoggerFactory
|
||||
import java.io.File
|
||||
import java.math.BigDecimal
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
|
||||
|
@ -105,7 +107,7 @@ open class hbci4jBankingClient(
|
|||
|
||||
bookedTransactions.put(bankAccount, response.bookedTransactions)
|
||||
unbookedTransactions.put(bankAccount, response.unbookedTransactions)
|
||||
balances.put(bankAccount, response.balance ?: BigDecimal.ZERO) // TODO: really add BigDecimal.Zero if balance couldn't be retrieved?
|
||||
balances.put(bankAccount, response.balance?.toBigDecimal() ?: BigDecimal.Zero) // TODO: really add BigDecimal.Zero if balance couldn't be retrieved?
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -162,7 +164,7 @@ open class hbci4jBankingClient(
|
|||
}
|
||||
|
||||
// Auswertung des Saldo-Abrufs.
|
||||
var balance = BigDecimal.ZERO
|
||||
var balance = BigDecimal.Zero
|
||||
if (parameter.alsoRetrieveBalance && nullableBalanceJob != null) {
|
||||
val balanceResult = nullableBalanceJob.jobResult as GVRSaldoReq
|
||||
if(balanceResult.isOK == false) {
|
||||
|
@ -170,7 +172,7 @@ open class hbci4jBankingClient(
|
|||
return GetTransactionsResponse(bankAccount, false, null, error = Exception("Could not fetch balance of bank account $bankAccount: $balanceResult"))
|
||||
}
|
||||
|
||||
balance = balanceResult.entries[0].ready.value.bigDecimalValue
|
||||
balance = balanceResult.entries[0].ready.value.bigDecimalValue.toBigDecimal()
|
||||
}
|
||||
|
||||
|
||||
|
@ -185,7 +187,7 @@ open class hbci4jBankingClient(
|
|||
}
|
||||
|
||||
return GetTransactionsResponse(bankAccount, true, null, accountTransactionMapper.mapAccountTransactions(bankAccount, result),
|
||||
listOf(), balance)
|
||||
listOf(), balance?.toBigDecimal())
|
||||
}
|
||||
catch(e: Exception) {
|
||||
log.error("Could not get accounting details for bank ${credentials.bankCode}", e)
|
||||
|
|
|
@ -5,7 +5,7 @@ import net.dankito.banking.ui.IBankingClient
|
|||
import net.dankito.banking.ui.IBankingClientCreator
|
||||
import net.dankito.banking.bankfinder.BankInfo
|
||||
import net.dankito.banking.util.IAsyncRunner
|
||||
import java.io.File
|
||||
import net.dankito.utils.multiplatform.File
|
||||
|
||||
|
||||
open class hbci4jBankingClientCreator : IBankingClientCreator {
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package net.dankito.banking.util
|
||||
|
||||
import net.dankito.utils.multiplatform.BigDecimal
|
||||
import net.dankito.utils.multiplatform.toBigDecimal
|
||||
import net.dankito.banking.ui.model.Customer
|
||||
import net.dankito.banking.ui.model.BankAccount
|
||||
import net.dankito.banking.ui.model.BankAccountType
|
||||
|
@ -8,7 +10,6 @@ import net.dankito.banking.ui.model.tan.TanProcedureType
|
|||
import org.kapott.hbci.passport.HBCIPassport
|
||||
import org.kapott.hbci.structures.Konto
|
||||
import org.kapott.hbci.structures.Value
|
||||
import java.math.BigDecimal
|
||||
|
||||
|
||||
open class hbci4jModelMapper {
|
||||
|
@ -46,7 +47,7 @@ open class hbci4jModelMapper {
|
|||
|
||||
BankAccount(customer, bankAccount.number,
|
||||
if (bankAccount.name2.isNullOrBlank() == false) bankAccount.name + " " + bankAccount.name2 else bankAccount.name,
|
||||
iban, bankAccount.subnumber, bankAccount.customerid, BigDecimal.ZERO, bankAccount.curr, mapBankAccountType(bankAccount),
|
||||
iban, bankAccount.subnumber, bankAccount.customerid, BigDecimal.Zero, bankAccount.curr, mapBankAccountType(bankAccount),
|
||||
null, bankAccount.limit?.value?.let { mapValue(it).toString() }, null,
|
||||
bankAccount.allowedGVs.contains("HKKAZ"), bankAccount.allowedGVs.contains("HKSAL"), bankAccount.allowedGVs.contains("HKCCS"))
|
||||
}
|
||||
|
@ -71,7 +72,7 @@ open class hbci4jModelMapper {
|
|||
}
|
||||
|
||||
protected open fun mapValue(value: Value): BigDecimal {
|
||||
return BigDecimal.valueOf(value.longValue).divide(BigDecimal.valueOf(100))
|
||||
return java.math.BigDecimal.valueOf(value.longValue).divide(java.math.BigDecimal.valueOf(100)).toBigDecimal()
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue