Fixed that purposeCode is not in each case "CHAR" and made it configurable
This commit is contained in:
parent
c420ca22e2
commit
0d32afda75
|
@ -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,
|
||||
|
|
|
@ -35,8 +35,7 @@ open class EpcQrCodeGenerator {
|
|||
return imageFormat.encode(qrCodeBitmap)
|
||||
}
|
||||
|
||||
open fun generate(param: EpcQrCodeConfig): EpcQrCodeValues {
|
||||
return EpcQrCodeValues(
|
||||
open fun generate(param: EpcQrCodeConfig): EpcQrCodeValues = EpcQrCodeValues(
|
||||
EpcQrCodeValues.ServiceTagDefaultValue,
|
||||
EpcQrCodeVersion.Version2,
|
||||
param.encoding,
|
||||
|
@ -46,12 +45,11 @@ open class EpcQrCodeGenerator {
|
|||
param.iban,
|
||||
EpcQrCodeValues.CurrencyCodeDefaultValue,
|
||||
param.amount,
|
||||
EpcQrCodeValues.PurposeCodeDefaultValue,
|
||||
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) {
|
||||
|
|
|
@ -82,8 +82,6 @@ open class EpcQrCodeValues(
|
|||
|
||||
const val CurrencyCodeDefaultValue = "EUR"
|
||||
|
||||
const val PurposeCodeDefaultValue = "CHAR"
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue