diff --git a/EpcQrCode/src/commonMain/kotlin/net/codinux/banking/epcqrcode/EpcQrCodeConfig.kt b/EpcQrCode/src/commonMain/kotlin/net/codinux/banking/epcqrcode/EpcQrCodeConfig.kt index bb2609e..8ed27e2 100644 --- a/EpcQrCode/src/commonMain/kotlin/net/codinux/banking/epcqrcode/EpcQrCodeConfig.kt +++ b/EpcQrCode/src/commonMain/kotlin/net/codinux/banking/epcqrcode/EpcQrCodeConfig.kt @@ -15,6 +15,8 @@ open class EpcQrCodeConfig( open val noteToUser: String? = null, + open val purposeCode: String? = null, + open val qrCodeHeightAndWidth: Int = EpcQrCode.DefaultHeightAndWidth, open val encoding: EpcQrCodeCharacterSet = EpcQrCodeCharacterSet.UTF_8, diff --git a/EpcQrCode/src/commonMain/kotlin/net/codinux/banking/epcqrcode/EpcQrCodeGenerator.kt b/EpcQrCode/src/commonMain/kotlin/net/codinux/banking/epcqrcode/EpcQrCodeGenerator.kt index ed6cd0c..17b330b 100644 --- a/EpcQrCode/src/commonMain/kotlin/net/codinux/banking/epcqrcode/EpcQrCodeGenerator.kt +++ b/EpcQrCode/src/commonMain/kotlin/net/codinux/banking/epcqrcode/EpcQrCodeGenerator.kt @@ -35,23 +35,21 @@ open class EpcQrCodeGenerator { return imageFormat.encode(qrCodeBitmap) } - open fun generate(param: EpcQrCodeConfig): EpcQrCodeValues { - return EpcQrCodeValues( - EpcQrCodeValues.ServiceTagDefaultValue, - EpcQrCodeVersion.Version2, - param.encoding, - EpcQrCodeValues.FunctionDefaultValue, - param.bic, - param.receiverName, - param.iban, - EpcQrCodeValues.CurrencyCodeDefaultValue, - param.amount, - EpcQrCodeValues.PurposeCodeDefaultValue, - null, - param.reference, - param.noteToUser - ) - } + open fun generate(param: EpcQrCodeConfig): EpcQrCodeValues = EpcQrCodeValues( + EpcQrCodeValues.ServiceTagDefaultValue, + EpcQrCodeVersion.Version2, + param.encoding, + EpcQrCodeValues.FunctionDefaultValue, + param.bic, + param.receiverName, + param.iban, + EpcQrCodeValues.CurrencyCodeDefaultValue, + param.amount, + param.purposeCode, + null, + param.reference, + param.noteToUser + ) open fun generateAsString(param: EpcQrCodeConfig): String { val epcQrCode = generate(param) @@ -66,7 +64,7 @@ open class EpcQrCodeGenerator { epcQrCodeBuilder.appendLine(epcQrCode.receiverName) epcQrCodeBuilder.appendLine(epcQrCode.iban) epcQrCodeBuilder.appendLine(mapNullable(epcQrCode.amount?.let { (epcQrCode.currencyCode ?: EpcQrCodeValues.CurrencyCodeDefaultValue) + it })) // TODO: ensure that amount is converted to the correct format - epcQrCodeBuilder.appendLine(epcQrCode.purposeCode) + epcQrCodeBuilder.appendLine(mapNullable(epcQrCode.purposeCode)) epcQrCodeBuilder.appendLine(mapNullable(epcQrCode.remittanceReference)) if (epcQrCode.remittanceText != null || epcQrCode.originatorInformation != null) { diff --git a/EpcQrCode/src/commonMain/kotlin/net/codinux/banking/epcqrcode/EpcQrCodeValues.kt b/EpcQrCode/src/commonMain/kotlin/net/codinux/banking/epcqrcode/EpcQrCodeValues.kt index a6c3f02..76ff201 100644 --- a/EpcQrCode/src/commonMain/kotlin/net/codinux/banking/epcqrcode/EpcQrCodeValues.kt +++ b/EpcQrCode/src/commonMain/kotlin/net/codinux/banking/epcqrcode/EpcQrCodeValues.kt @@ -82,8 +82,6 @@ open class EpcQrCodeValues( const val CurrencyCodeDefaultValue = "EUR" - const val PurposeCodeDefaultValue = "CHAR" - } diff --git a/EpcQrCode/src/commonTest/kotlin/net.codinux.banking.epcqrcode/EpcQrCodeGeneratorTest.kt b/EpcQrCode/src/commonTest/kotlin/net.codinux.banking.epcqrcode/EpcQrCodeGeneratorTest.kt index e2ca8a1..074d817 100644 --- a/EpcQrCode/src/commonTest/kotlin/net.codinux.banking.epcqrcode/EpcQrCodeGeneratorTest.kt +++ b/EpcQrCode/src/commonTest/kotlin/net.codinux.banking.epcqrcode/EpcQrCodeGeneratorTest.kt @@ -28,7 +28,7 @@ class EpcQrCodeGeneratorTest { Liebe DE01234567890123456789 - CHAR + """.trimIndent()) @@ -38,8 +38,8 @@ class EpcQrCodeGeneratorTest { fun png() { val result = underTest.generateEpcQrCode(basicDataConfig(ImageFormat.PNG)) - // don't know why, in JavaScript it's 1000643, on all other platforms 10592 bytes - assertTrue(listOf(10592, 1000643).contains(result.bytes.size)) + // don't know why, in JavaScript it's 1000643, on all other platforms 10446 bytes + assertTrue(listOf(10446, 1000643).contains(result.bytes.size)) } @Test