Added convenience constructors for languages not supporting default values

This commit is contained in:
dankito 2020-07-18 15:21:17 +02:00
parent 427b47a324
commit 3ed323cd69
4 changed files with 33 additions and 13 deletions

View File

@ -54,17 +54,24 @@ open class AccountTransaction(
}
// for object deserializers
internal constructor() : this(BankAccount(), null, "", BigDecimal.Zero, Date(), null)
/* convenience constructors for languages not supporting default values */
constructor(bankAccount: BankAccount, otherPartyName: String?, unparsedUsage: String, amount: BigDecimal, valueDate: Date, bookingText: String?)
: this(bankAccount, amount, "EUR", unparsedUsage, valueDate,
otherPartyName, null, null, bookingText, valueDate)
constructor(bankAccount: BankAccount, amount: BigDecimal, currency: String, unparsedUsage: String, bookingDate: Date,
otherPartyName: String?, otherPartyBankCode: String?, otherPartyAccountId: String?,
bookingText: String?, valueDate: Date)
: this(bankAccount, amount, currency, unparsedUsage, bookingDate,
otherPartyName, otherPartyBankCode, otherPartyAccountId, bookingText, valueDate,
0, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, "", "", null, null, "", null)
otherPartyName, otherPartyBankCode, otherPartyAccountId, bookingText, valueDate,
0, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, "", "", null, null, "", null)
// for object deserializers
internal constructor() : this(BankAccount(), BigDecimal.Zero, "","", Date(), null, null, null, null, Date(), 0, null, BigDecimal.Zero, BigDecimal.Zero,
null, null, null, null, null, null, null, null, null, null, null, null, null,
null, "", "", null, null, "", null)
open var id: String = "${bankAccount.id} ${IdDateFormat.format(bookingDate)} ${IdDateFormat.format(valueDate)} $amount $currency $unparsedUsage $otherPartyName $otherPartyBankCode $otherPartyAccountId"

View File

@ -29,7 +29,14 @@ open class BankAccount @JvmOverloads constructor(
bookedAccountTransactions: List<AccountTransaction> = listOf()
) {
internal constructor() : this(Customer(), "", "", null, null, "") // for object deserializers
internal constructor() : this(Customer(), null, "") // for object deserializers
/* convenience constructors for languages not supporting default values */
constructor(customer: Customer, productName: String?, identifier: String) : this(customer, productName, identifier, BankAccountType.Girokonto)
constructor(customer: Customer, productName: String?, identifier: String, type: BankAccountType = BankAccountType.Girokonto, balance: BigDecimal = BigDecimal.Zero)
: this(customer, identifier, "", null, null, "", balance, "EUR", type, productName)
open var id: String = UUID.random()

View File

@ -27,6 +27,11 @@ open class Customer(
internal constructor() : this("", "", "", "", "", "", "") // for object deserializers
/* convenience constructors for languages not supporting default values */
constructor(bankCode: String, customerId: String, password: String, finTsServerAddress: String)
: this(bankCode, customerId, password, finTsServerAddress, "", "", "")
var id: String = UUID.random()

View File

@ -5,19 +5,20 @@ import BankingUiSwift
let previewBanks = createPreviewBanks()
func createPreviewBanks() -> [BUCCustomer] {
let bank1 = BUCCustomer(bankCode: "", customerId: "", password: "", finTsServerAddress: "", bankName: "Abzockbank", bic: "", customerName: "", userId: "", iconUrl: "", accounts: [])
let bank1 = BUCCustomer(bankCode: "", customerId: "", password: "", finTsServerAddress: "", bankName: "Abzockbank", bic: "", customerName: "Marieke Musterfrau", userId: "", iconUrl: "", accounts: [])
bank1.accounts = [
BUCBankAccount(customer: bank1, identifier: "id", accountHolderName: "Marieke Musterfrau", iban: nil, subAccountNumber: nil, customerId: "", balance: CommonBigDecimal(double: 17.0), currency: "EUR", type: .girokonto, productName: "Girokonto", accountLimit: nil, lastRetrievedTransactionsTimestamp: nil, supportsRetrievingAccountTransactions: true, supportsRetrievingBalance: true, supportsTransferringMoney: true, supportsInstantPaymentMoneyTransfer: true, bookedAccountTransactions: []),
BUCBankAccount(customer: bank1, productName: "Girokonto", identifier: "1234567890"),
BUCBankAccount(customer: bank1, identifier: "id", accountHolderName: "Marieke Musterfrau", iban: nil, subAccountNumber: nil, customerId: "", balance: CommonBigDecimal(double: 17.0), currency: "EUR", type: .festgeldkonto, productName: "Tagesgeld Minus", accountLimit: nil, lastRetrievedTransactionsTimestamp: nil, supportsRetrievingAccountTransactions: true, supportsRetrievingBalance: true, supportsTransferringMoney: true, supportsInstantPaymentMoneyTransfer: true, bookedAccountTransactions: [])
BUCBankAccount(customer: bank1, productName: "Tagesgeld Minus", identifier: "0987654321")
]
let bank2 = BUCCustomer(bankCode: "", customerId: "", password: "", finTsServerAddress: "", bankName: "Kundenverarschebank", bic: "", customerName: "", userId: "", iconUrl: "", accounts: [])
let bank2 = BUCCustomer(bankCode: "", customerId: "", password: "", finTsServerAddress: "", bankName: "Kundenverarschebank", bic: "", customerName: "Marieke Musterfrau", userId: "", iconUrl: "", accounts: [])
bank2.accounts = [
BUCBankAccount(customer: bank1, identifier: "id", accountHolderName: "Marieke Musterfrau", iban: nil, subAccountNumber: nil, customerId: "", balance: CommonBigDecimal(double: 17.0), currency: "EUR", type: .girokonto, productName: "Girokonto", accountLimit: nil, lastRetrievedTransactionsTimestamp: nil, supportsRetrievingAccountTransactions: true, supportsRetrievingBalance: true, supportsTransferringMoney: true, supportsInstantPaymentMoneyTransfer: true, bookedAccountTransactions: [])
BUCBankAccount(customer: bank2, productName: "Girokonto", identifier: "1234567890")
]
return [ bank1, bank2 ]
}
}