Skip to content
This repository has been archived by the owner on Sep 8, 2023. It is now read-only.

Commit

Permalink
Merge pull request #17 from antoinepairet/b12/feat/sanitize-batch
Browse files Browse the repository at this point in the history
Sanitize names in the batch
  • Loading branch information
phil1618 authored Jan 24, 2019
2 parents b26dd8a + 2c6ce7f commit b298304
Showing 1 changed file with 27 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,27 @@ class EfactServiceImpl(private val stsService: STSService, private val mapper: M
return stringWriter.toString()
}

fun sanitizeBatchNames(batch: InvoicesBatch): InvoicesBatch {
val specialChars = Regex("[!@#&/\\\\]")
batch.sender = batch.sender?.apply {
firstName = firstName?.replace(specialChars, "")
lastName = lastName?.replace(specialChars, "")
}

batch.invoices.replaceAll {
it.patient = it.patient?.apply {
firstName = firstName?.replace(specialChars, "")
lastName = lastName?.replace(specialChars, "")
spouseName = spouseName?.replace(specialChars, "")
maidenName = maidenName?.replace(specialChars, "")
partnerName = partnerName?.replace(specialChars, "")
}
it
}

return batch
}

override fun sendBatch(keystoreId: UUID, tokenId: UUID, passPhrase: String, batch: InvoicesBatch): EfactSendResponse {
requireNotNull(keystoreId) { "Keystore id cannot be null" }
requireNotNull(tokenId) { "Token id cannot be null" }
Expand All @@ -179,9 +200,11 @@ class EfactServiceImpl(private val stsService: STSService, private val mapper: M

val isTest = config.getProperty("endpoint.mcn.tarification").contains("-acpt")

val fed = batch.ioFederationCode
val inputReference = "" + DecimalFormat("00000000000000").format(batch.numericalRef ?: 0)
val content = makeFlatFile(batch, isTest)
val sanitizedBatch = sanitizeBatchNames(batch)

val fed = sanitizedBatch.ioFederationCode
val inputReference = "" + DecimalFormat("00000000000000").format(sanitizedBatch.numericalRef ?: 0)
val content = makeFlatFile(sanitizedBatch, isTest)

val requestObjectBuilder = try {
BuilderFactory.getRequestObjectBuilder("invoicing")
Expand All @@ -201,7 +224,7 @@ class EfactServiceImpl(private val stsService: STSService, private val mapper: M
isIsTest = isTest!!
}
origin =
buildOriginType(batch.sender!!.nihii!!.toString(), batch.sender!!.ssin!!.toString(), batch.sender!!.firstName!!, batch.sender!!.lastName!!)
buildOriginType(sanitizedBatch.sender!!.nihii!!.toString(), sanitizedBatch.sender!!.ssin!!.toString(), sanitizedBatch.sender!!.firstName!!, sanitizedBatch.sender!!.lastName!!)
this.inputReference = inputReference
}

Expand Down

0 comments on commit b298304

Please sign in to comment.