Skip to content

Commit

Permalink
Merge pull request #221 from hmrc/miscoded-movements
Browse files Browse the repository at this point in the history
Miscoded movements
  • Loading branch information
oliverslade authored Sep 26, 2024
2 parents 2afabe7 + 9d320f4 commit 8fb7494
Show file tree
Hide file tree
Showing 22 changed files with 664 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import uk.gov.hmrc.excisemovementcontrolsystemapi.models.messages.MessageTypeFor
import scala.xml.NodeSeq

case class IE704Message(
private val obj: IE704Type,
obj: IE704Type,
key: Option[String],
namespace: Option[String],
auditType: AuditType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import uk.gov.hmrc.excisemovementcontrolsystemapi.models.messages.MessageTypeFor
import scala.xml.NodeSeq

case class IE801Message(
private val obj: IE801Type,
obj: IE801Type,
key: Option[String],
namespace: Option[String],
auditType: AuditType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import uk.gov.hmrc.excisemovementcontrolsystemapi.models.messages.MessageTypeFor
import scala.xml.NodeSeq

case class IE802Message(
private val obj: IE802Type,
obj: IE802Type,
key: Option[String],
namespace: Option[String],
auditType: AuditType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import uk.gov.hmrc.excisemovementcontrolsystemapi.models.messages.MessageTypeFor
import scala.xml.NodeSeq

case class IE803Message(
private val obj: IE803Type,
obj: IE803Type,
key: Option[String],
namespace: Option[String],
auditType: AuditType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import uk.gov.hmrc.excisemovementcontrolsystemapi.models.messages.MessageTypeFor
import scala.xml.NodeSeq

case class IE807Message(
private val obj: IE807Type,
obj: IE807Type,
key: Option[String],
namespace: Option[String],
auditType: AuditType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import uk.gov.hmrc.excisemovementcontrolsystemapi.models.messages.MessageTypeFor
import scala.xml.NodeSeq

case class IE813Message(
private val obj: IE813Type,
obj: IE813Type,
key: Option[String],
namespace: Option[String],
auditType: AuditType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import uk.gov.hmrc.excisemovementcontrolsystemapi.models.messages.MessageTypeFor

import scala.xml.NodeSeq

case class IE815Message(private val obj: IE815Type, auditType: AuditType) extends IEMessage with GeneratedJsonWriters {
case class IE815Message(obj: IE815Type, auditType: AuditType) extends IEMessage with GeneratedJsonWriters {
def localReferenceNumber: String =
obj.Body.SubmittedDraftOfEADESAD.EadEsadDraft.LocalReferenceNumber

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import uk.gov.hmrc.excisemovementcontrolsystemapi.models.messages.MessageTypeFor
import scala.xml.NodeSeq

case class IE818Message(
private val obj: IE818Type,
obj: IE818Type,
key: Option[String],
namespace: Option[String],
auditType: AuditType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import uk.gov.hmrc.excisemovementcontrolsystemapi.models.messages.MessageTypeFor
import scala.xml.NodeSeq

case class IE819Message(
private val obj: IE819Type,
obj: IE819Type,
key: Option[String],
namespace: Option[String],
auditType: AuditType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import uk.gov.hmrc.excisemovementcontrolsystemapi.models.messages.MessageTypeFor
import scala.xml.NodeSeq

case class IE829Message(
private val obj: IE829Type,
obj: IE829Type,
key: Option[String],
namespace: Option[String],
auditType: AuditType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import uk.gov.hmrc.excisemovementcontrolsystemapi.models.messages.MessageTypeFor
import scala.xml.NodeSeq

case class IE837Message(
private val obj: IE837Type,
obj: IE837Type,
key: Option[String],
namespace: Option[String],
auditType: AuditType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import uk.gov.hmrc.excisemovementcontrolsystemapi.models.messages.MessageTypeFor
import scala.xml.NodeSeq

case class IE839Message(
private val obj: IE839Type,
obj: IE839Type,
key: Option[String],
namespace: Option[String],
auditType: AuditType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import uk.gov.hmrc.excisemovementcontrolsystemapi.models.messages.MessageTypeFor
import scala.xml.NodeSeq

case class IE840Message(
private val obj: IE840Type,
obj: IE840Type,
key: Option[String],
namespace: Option[String],
auditType: AuditType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import uk.gov.hmrc.excisemovementcontrolsystemapi.models.messages.MessageTypeFor
import scala.xml.NodeSeq

case class IE871Message(
private val obj: IE871Type,
obj: IE871Type,
key: Option[String],
namespace: Option[String],
auditType: AuditType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import uk.gov.hmrc.excisemovementcontrolsystemapi.models.messages.MessageTypeFor
import scala.xml.NodeSeq

case class IE881Message(
private val obj: IE881Type,
obj: IE881Type,
key: Option[String],
namespace: Option[String],
auditType: AuditType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import uk.gov.hmrc.excisemovementcontrolsystemapi.models.messages.MessageTypeFor
import scala.xml.NodeSeq

case class IE905Message(
private val obj: IE905Type,
obj: IE905Type,
key: Option[String],
namespace: Option[String],
auditType: AuditType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import play.api.libs.json.{JsObject, Json, OFormat}
import uk.gov.hmrc.excisemovementcontrolsystemapi.config.AppConfig
import uk.gov.hmrc.excisemovementcontrolsystemapi.filters.MovementFilter
import uk.gov.hmrc.excisemovementcontrolsystemapi.repository.MovementRepository._
import uk.gov.hmrc.excisemovementcontrolsystemapi.repository.model.{Movement, ProblemMovement, Total}
import uk.gov.hmrc.excisemovementcontrolsystemapi.repository.model.{MiscodedMovement, Movement, ProblemMovement, Total}
import uk.gov.hmrc.excisemovementcontrolsystemapi.utils.{DateTimeService, Mdc}
import uk.gov.hmrc.mongo.MongoComponent
import uk.gov.hmrc.mongo.play.json.Codecs.JsonOps
Expand Down Expand Up @@ -54,7 +54,8 @@ class MovementRepository @Inject() (
Codecs.playFormatCodec(ErnAndLastReceived.format),
Codecs.playFormatCodec(MessageNotification.format),
Codecs.playFormatCodec(ProblemMovement.format),
Codecs.playFormatCodec(Total.format)
Codecs.playFormatCodec(Total.format),
Codecs.playFormatCodec(MiscodedMovement.format)
),
replaceIndexes = false
) {
Expand Down Expand Up @@ -312,6 +313,27 @@ class MovementRepository @Inject() (
)
)
.headOption()

def getMiscodedMovements(): Future[Seq[MiscodedMovement]] =
collection
.find[MiscodedMovement](
Filters.and(
Filters.exists("messages.recipient", exists = true),
Filters.regex("messages.encodedMessage", "^PElFODAxVHlwZS")
)
)
.projection(Projections.fields(Projections.include("_id")))
.toFuture()

def getCountOfMiscodedMovements(): Future[Long] =
collection
.countDocuments(
Filters.and(
Filters.exists("messages.recipient", exists = true),
Filters.regex("messages.encodedMessage", "^PElFODAxVHlwZS")
)
)
.toFuture()
}

object MovementRepository {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright 2024 HM Revenue & Customs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package uk.gov.hmrc.excisemovementcontrolsystemapi.repository.model

import play.api.libs.json.{Json, OFormat}

final case class MiscodedMovement(_id: String)

object MiscodedMovement {

implicit lazy val format: OFormat[MiscodedMovement] = Json.format
}
Loading

0 comments on commit 8fb7494

Please sign in to comment.