Renamed noteToUser to informationForUser

This commit is contained in:
dankito 2024-10-03 19:15:15 +02:00
parent 3c129a9e46
commit 686777b34f
5 changed files with 32 additions and 18 deletions

View File

@ -13,7 +13,14 @@ open class EpcQrCodeConfig(
open val reference: String? = null,
open val noteToUser: String? = null,
/**
* Beneficiary to originator information.
*
* The text contained in Display must be shown to the user after decoding and serves a
* short textual description of what the user is going to initiate.
* This text must not be forwarded with the data handed over to the payment system.
*/
open val informationForUser: String? = null,
open val purposeCode: String? = null,

View File

@ -48,7 +48,7 @@ open class EpcQrCodeGenerator {
param.purposeCode,
null,
param.reference,
param.noteToUser
param.informationForUser
)
open fun generateAsString(param: EpcQrCodeConfig): String {
@ -66,22 +66,22 @@ open class EpcQrCodeGenerator {
epcQrCodeBuilder.appendLine(mapNullable(epcQrCode.amount?.let { (epcQrCode.currencyCode ?: EpcQrCodeValues.CurrencyCodeDefaultValue) + it })) // TODO: ensure that amount is converted to the correct format
epcQrCodeBuilder.appendLine(mapNullable(epcQrCode.purposeCode))
if (epcQrCode.remittanceText != null || epcQrCode.originatorInformation != null) {
if (epcQrCode.remittanceText != null || epcQrCode.informationForUser != null) {
epcQrCodeBuilder.appendLine(mapNullable(epcQrCode.remittanceReference))
} else {
epcQrCodeBuilder.append(mapNullable(epcQrCode.remittanceReference))
}
if (epcQrCode.remittanceText != null || epcQrCode.originatorInformation != null) {
if (epcQrCode.originatorInformation != null) {
if (epcQrCode.remittanceText != null || epcQrCode.informationForUser != null) {
if (epcQrCode.informationForUser != null) {
epcQrCodeBuilder.appendLine(mapNullable(epcQrCode.remittanceText))
} else {
epcQrCodeBuilder.append(mapNullable(epcQrCode.remittanceText))
}
}
if (epcQrCode.originatorInformation != null) {
epcQrCodeBuilder.append(epcQrCode.originatorInformation)
if (epcQrCode.informationForUser != null) {
epcQrCodeBuilder.append(epcQrCode.informationForUser)
}
return epcQrCodeBuilder.toString()

View File

@ -70,7 +70,14 @@ open class EpcQrCodeValues(
open val remittanceText: String?,
open val originatorInformation: String?
/**
* Beneficiary to originator information.
*
* The text contained in Display must be shown to the user after decoding and serves a
* short textual description of what the user is going to initiate.
* This text must not be forwarded with the data handed over to the payment system.
*/
open val informationForUser: String?
) {

View File

@ -34,7 +34,7 @@ class EpcQrCodeGeneratorTest {
""".trimIndent())
assertEquals(10, result.lines().size) // if no reference text or note to user is set, then QR code may only contain the minimum of 10 lines and no empty lines afterwards
assertEquals(10, result.lines().size) // if no reference text or information for user is set, then QR code may only contain the minimum of 10 lines and no empty lines afterwards
}
@Test
@ -58,13 +58,13 @@ class EpcQrCodeGeneratorTest {
$referenceText
""".trimIndent())
assertEquals(11, result.lines().size) // no note to user -> no 12th line may be contained in generated QR code
assertEquals(11, result.lines().size) // no information for user -> no 12th line may be contained in generated QR code
}
@Test
fun includingNoteToUser() {
val noteToUser = "Mach uns reich, Baby"
val config = basicDataConfig(noteToUser = noteToUser)
fun includingInformationForUser() {
val informationForUser = "Mach uns reich, Baby"
val config = basicDataConfig(informationForUser = informationForUser)
val result = underTest.generateAsString(config)
@ -80,10 +80,10 @@ class EpcQrCodeGeneratorTest {
$noteToUser
$informationForUser
""".trimIndent())
assertEquals(12, result.lines().size) // note to user set -> contains the maximum of 12 lines but no line separator at end of 12th line
assertEquals(12, result.lines().size) // information for user set -> contains the maximum of 12 lines but no line separator at end of 12th line
}
@ -109,6 +109,6 @@ class EpcQrCodeGeneratorTest {
assertEquals(1000018, result.bytes.size)
}
private fun basicDataConfig(referenceText: String? = null, noteToUser: String? = null, imageFormat: ImageFormat = ImageFormat.PNG) =
EpcQrCodeConfig(ReceiverName, ReceiverIban, reference = referenceText, noteToUser = noteToUser, imageFormat = imageFormat)
private fun basicDataConfig(referenceText: String? = null, informationForUser: String? = null, imageFormat: ImageFormat = ImageFormat.PNG) =
EpcQrCodeConfig(ReceiverName, ReceiverIban, reference = referenceText, informationForUser = informationForUser, imageFormat = imageFormat)
}

View File

@ -192,7 +192,7 @@ Netter Text für den Zahlenden, damit dieser weiß, was er zahlt und auc
assertEquals(purposeCode, epcQrCode.purposeCode)
assertEquals(reference, epcQrCode.remittanceReference)
assertEquals(text, epcQrCode.remittanceText)
assertEquals(displayText, epcQrCode.originatorInformation)
assertEquals(displayText, epcQrCode.informationForUser)
}
}