Skip to content

Commit

Permalink
CDMS-154 removes uneeded version related decision status. Adds some m…
Browse files Browse the repository at this point in the history
…ore test scenarios (#81)
  • Loading branch information
craigedmunds authored and Lim Sim committed Jan 29, 2025
1 parent a6ad87a commit a485743
Show file tree
Hide file tree
Showing 15 changed files with 29 additions and 59 deletions.
6 changes: 3 additions & 3 deletions Btms.Analytics/MovementExceptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public class MovementExceptions(IMongoDbContext context, ILogger logger)
{
exceptionsResult.AddRange(moreComplexMovementsQuery
.OrderBy(a => -a.Total)
.Take(10)
.Take(3)
.Execute(logger)
.Select(r =>
new ExceptionResult()
Expand Down Expand Up @@ -103,7 +103,7 @@ public class MovementExceptions(IMongoDbContext context, ILogger logger)
{
exceptionsResult.AddRange(movementsWhereAlvsLinksButNotBtmsQuery
.OrderBy(a => a.Total)
.Take(10)
.Take(3)
.Execute(logger)
.Select(r =>
new ExceptionResult()
Expand Down Expand Up @@ -135,7 +135,7 @@ public class MovementExceptions(IMongoDbContext context, ILogger logger)
{
exceptionsResult.AddRange(movementsWhereWeHaveAndContigousVersionsButDecisionsAreDifferentQuery
.OrderBy(a => a.Total)
.Take(10)
.Take(3)
.Execute(logger)
.Select(r =>
new ExceptionResult()
Expand Down
9 changes: 2 additions & 7 deletions Btms.Backend.Cli/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,9 @@
"commandLineArgs": "download-scenario-data --environment Local --clearance-request 24GBCSRYLJM7JCYAR3 --rootFolder PRODREDACTED-202412 --outputFolder C:\\temp\\downloads"
},

"download-scenario-data-24GBDPN81VSULAGAR9": {
"download-scenario-data-24GBE2TF54PWDGXAR0": {
"commandName": "Project",
//"commandLineArgs": "generate-ipaffs-model --schema D:\\repos\\esynergy\\tdm-prototype-backend\\TdmPrototypeBackend.Cli\\Features\\GenerateModels\\GenerateIpaffsModel\\\\jsonschema.json --outputPath D:\\repos\\esynergy\\tdm-prototype-backend\\TdmPrototypeBackend.Types\\Ipaffs\\"
//"commandLineArgs": "generate-ipaffs-model --schema D:\\repos\\esynergy\\btms-backend\\Btms.Backend.Cli\\Features\\GenerateModels\\GenerateIpaffsModel\\\\jsonschema.json"

// "commandLineArgs": "generate-vehicle-movement-model"
//"commandLineArgs": "generate-alvs-model"
"commandLineArgs": "download-scenario-data --environment Local --clearance-request 24GBDE3CF94H96TAR0 --rootFolder PRODREDACTED-202412 --outputFolder ~/src/defra/cdms/btms-backend/TestDataGenerator/Scenarios/Samples/Mrn-24GBDE3CF94H96TAR0"
"commandLineArgs": "download-scenario-data --environment Local --clearance-request 24GBE2TF54PWDGXAR0 --rootFolder PRODREDACTED-202412 --outputFolder ~/src/defra/cdms/btms-backend/TestDataGenerator/Scenarios/Samples/Mrn-24GBE2TF54PWDGXAR0"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public class DecisionCodeTests(ITestOutputHelper output) : MultipleScenarioGener
[InlineData(typeof(ChedPn03ScenarioGenerator), "N03")]
[InlineData(typeof(ChedPn04ScenarioGenerator), "N04")]
[InlineData(typeof(ChedPn07ScenarioGenerator), "N07")]
[InlineData(typeof(MissingChedScenarioGenerator), "X00")]
[InlineData(typeof(IuuScenarioGenerator), "X00")]
public void ShouldHaveCorrectDecisionCode(Type generatorType, string expectedDecisionCode)
{
base.TestOutputHelper.WriteLine("Generator : {0}, Decision Code : {1}", generatorType!.FullName, expectedDecisionCode);
Expand Down
18 changes: 0 additions & 18 deletions Btms.Business/Builders/MovementBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -405,24 +405,6 @@ private void CompareDecisions(AlvsDecision alvsDecision, CdsClearanceRequest btm
{
decisionStatus = DecisionStatusEnum.HasChedppChecks;
}
else if (!_movement.ClearanceRequests.Exists(c => c.Header!.EntryVersionNumber == 1))
{
decisionStatus = DecisionStatusEnum.AlvsClearanceRequestVersion1NotPresent;
}
else if (!_movement.ClearanceRequests.AreNumbersComplete(c => c.Header!.EntryVersionNumber!.Value))
{
decisionStatus = DecisionStatusEnum.AlvsClearanceRequestVersionsNotComplete;
}
else if (alvsDecision.Context.AlvsDecisionNumber!.Value != 1 &&
!_movement.AlvsDecisionStatus.Decisions
.Exists(d => d.Context.AlvsDecisionNumber == 1))
{
decisionStatus = DecisionStatusEnum.AlvsDecisionVersion1NotPresent;
}
else if (_movement.AlvsDecisionStatus.Decisions.Count > 0 && !_movement.AlvsDecisionStatus.Decisions.AreNumbersComplete(d => d.Context.AlvsDecisionNumber))
{
decisionStatus = DecisionStatusEnum.AlvsDecisionVersionsNotComplete;
}

alvsDecision.Context.DecisionComparison.DecisionStatus = decisionStatus;
}
Expand Down
22 changes: 4 additions & 18 deletions Btms.Business/Extensions/MovementExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,6 @@ public static bool AreNumbersComplete<T>(this IEnumerable<T> source, Func<T, int
return true;
}

// public static void AddLinkStatus(this Movement movement)
// {
// if (movement.BtmsStatus.LinkStatus == LinkStatusEnum.Error) return;
//
// var linkStatus = LinkStatusEnum.NotLinked;
// var linked = false;
//
// if (movement.Relationships.Notifications.Data.Count > 0)
// {
// linkStatus = LinkStatusEnum.Linked;
// linked = true;
// }
//
// movement.BtmsStatus.LinkStatus = linkStatus;
// movement.BtmsStatus.Linked = linked;
// }

public static string[] UniqueDocumentReferences(this Movement movement)
{
return movement.Items
Expand All @@ -67,10 +50,13 @@ public static List<string> UniqueNotificationRelationshipIds(this Movement movem
.ToList();
}

public static List<string> UniqueDocumentReferenceIds(this Movement movement)
public static List<string> UniqueDocumentReferenceIdsThatShouldLink(this Movement movement)
{
return movement.Items
.SelectMany(i => i.Documents ?? [])
// Only CHED document refs should result in links
.Where(d => d.DocumentReference != null &&
d.DocumentReference.StartsWith("GBCHD"))
.Select(d => d.DocumentReference!.TrimUniqueNumber())
.Distinct()
.ToList();
Expand Down
2 changes: 1 addition & 1 deletion Btms.Business/Services/Validating/ValidationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ await Task.WhenAll(linkResult.Movements.Select(async m =>
var chedTypes = m.BtmsStatus.ChedTypes;

var notificationRelationshipIds = m.UniqueNotificationRelationshipIds();
var documentReferenceIds = m.UniqueDocumentReferenceIds();
var documentReferenceIds = m.UniqueDocumentReferenceIdsThatShouldLink();

m.BtmsStatus = MovementStatus.Default();
m.BtmsStatus.ChedTypes = chedTypes;
Expand Down
12 changes: 0 additions & 12 deletions Btms.Model/Cds/AlvsDecision.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,18 +234,6 @@ public enum DecisionStatusEnum
[EnumMember(Value = "Has Multiple Cheds")]
HasMultipleCheds,

[EnumMember(Value = "Alvs Clearance Request Version 1 Not Present")]
AlvsClearanceRequestVersion1NotPresent,

[EnumMember(Value = "Alvs Clearance Request Versions Not Complete")]
AlvsClearanceRequestVersionsNotComplete,

[EnumMember(Value = "Alvs Decision Version 1 Not Present")]
AlvsDecisionVersion1NotPresent,

[EnumMember(Value = "Alvs Decision Versions Not Complete")]
AlvsDecisionVersionsNotComplete,

[EnumMember(Value = "Investigation Needed")]
InvestigationNeeded,

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"serviceHeader":{"sourceSystem":"CDS","destinationSystem":"ALVS","correlationId":"1305910","serviceCallTimestamp":1733052930000},"header":{"entryReference":"24GBD48YGL8RMD6AR6","entryVersionNumber":2,"previousVersionNumber":1,"declarationUCR":"4GB269573944000-PORTAL100253939","declarationPartNumber":null,"declarationType":"F","arrivalDateTime":null,"submitterTURN":"GB269573944000","declarantId":"GB269573944000","declarantName":"GB269573944000","dispatchCountryCode":"IT","goodsLocationCode":"DVRDOVDVRGVM","masterUCR":null},"items":[{"itemNumber":1,"customsProcedureCode":"40001CG","taricCommodityCode":"1601009190","goodsDescription":"NDUJA","consigneeId":"GB118357314000","consigneeName":"GB118357314000","itemNetMass":732.59,"itemSupplementaryUnits":0,"itemThirdQuantity":null,"itemOriginCountryCode":"IT","documents":[{"documentCode":"N853","documentReference":"GBCHD2024.5203274","documentStatus":"AE","documentControl":"P","documentQuantity":null}],"checks":[{"checkCode":"H222","departmentCode":"PHA"}]},{"itemNumber":2,"customsProcedureCode":"40001CG","taricCommodityCode":"0210121100","goodsDescription":"GUANCIALE","consigneeId":"GB118357314000","consigneeName":"GB118357314000","itemNetMass":4.5,"itemSupplementaryUnits":0,"itemThirdQuantity":null,"itemOriginCountryCode":"IT","documents":[{"documentCode":"N853","documentReference":"GBCHD2024.5203274","documentStatus":"AE","documentControl":"P","documentQuantity":null}],"checks":[{"checkCode":"H222","departmentCode":"PHA"}]}]}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"serviceHeader":{"sourceSystem":"ALVS","destinationSystem":"CDS","correlationId":"000","serviceCallTimestamp":1733052949951},"header":{"entryReference":"24GBD48YGL8RMD6AR6","entryVersionNumber":2,"decisionNumber":3},"items":[{"itemNumber":1,"documents":[],"checks":[{"checkCode":"H222","decisionCode":"C03","decisionValidUntil":null,"decisionReasons":[]}]},{"itemNumber":2,"documents":[],"checks":[{"checkCode":"H222","decisionCode":"C03","decisionValidUntil":null,"decisionReasons":[]}]}]}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"serviceHeader":{"sourceSystem":"CDS","destinationSystem":"ALVS","correlationId":"1363275","serviceCallTimestamp":1734712535000},"header":{"entryReference":"24GBE2TF54PWDGXAR0","entryVersionNumber":1,"previousVersionNumber":null,"declarationUCR":"4GB422561868000-SID00041885","declarationPartNumber":null,"declarationType":"S","arrivalDateTime":null,"submitterTURN":"GB646552129000","declarantId":"GB646552129000","declarantName":"GB646552129000","dispatchCountryCode":"VN","goodsLocationCode":"IMMIMMIMM","masterUCR":"607720104"},"items":[{"itemNumber":1,"customsProcedureCode":"6121000","taricCommodityCode":"0306150000","goodsDescription":"FROZEN SCAMPI TAILS","consigneeId":"GB422561868000","consigneeName":"GB422561868000","itemNetMass":15540,"itemSupplementaryUnits":0,"itemThirdQuantity":null,"itemOriginCountryCode":"VN","documents":[{"documentCode":"C673","documentReference":"GBIUUGBR-2024-CC-46765825B","documentStatus":"AE","documentControl":"P","documentQuantity":null},{"documentCode":"C673","documentReference":"GBIUUGBR-2024-CC-AFCA780C6","documentStatus":"AE","documentControl":"P","documentQuantity":null},{"documentCode":"C673","documentReference":"GBIUUGBR-2024-CC-B428EF588","documentStatus":"AE","documentControl":"P","documentQuantity":null},{"documentCode":"C673","documentReference":"GBIUUGBR-2024-CC-EB7C8E1D1","documentStatus":"AE","documentControl":"P","documentQuantity":null},{"documentCode":"N853","documentReference":"GBCHD2024.5131067","documentStatus":"AE","documentControl":"P","documentQuantity":null}],"checks":[{"checkCode":"H222","departmentCode":"PHA"},{"checkCode":"H224","departmentCode":"PHA"}]}]}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"serviceHeader":{"sourceSystem":"CDS","destinationSystem":"ALVS","correlationId":"1365309","serviceCallTimestamp":1734813313000},"header":{"entryReference":"24GBE2TF54PWDGXAR0","entryVersionNumber":2,"previousVersionNumber":1,"declarationUCR":"4GB422561868000-SID00041885","declarationPartNumber":null,"declarationType":"S","arrivalDateTime":null,"submitterTURN":"GB646552129000","declarantId":"GB646552129000","declarantName":"GB646552129000","dispatchCountryCode":"VN","goodsLocationCode":"IMMIMMIMM","masterUCR":"607720104"},"items":[{"itemNumber":1,"customsProcedureCode":"6121000","taricCommodityCode":"0306150000","goodsDescription":"FROZEN SCAMPI TAILS","consigneeId":"GB422561868000","consigneeName":"GB422561868000","itemNetMass":15540,"itemSupplementaryUnits":0,"itemThirdQuantity":null,"itemOriginCountryCode":"VN","documents":[{"documentCode":"C673","documentReference":"GBIUUGBR-2024-CC-46765825B","documentStatus":"AE","documentControl":"P","documentQuantity":null},{"documentCode":"C673","documentReference":"GBIUUGBR-2024-CC-AFCA780C6","documentStatus":"AE","documentControl":"P","documentQuantity":null},{"documentCode":"C673","documentReference":"GBIUUGBR-2024-CC-B428EF588","documentStatus":"AE","documentControl":"P","documentQuantity":null},{"documentCode":"C673","documentReference":"GBIUUGBR-2024-CC-EB7C8E1D1","documentStatus":"AE","documentControl":"P","documentQuantity":null},{"documentCode":"N853","documentReference":"GBCHD2024.5131067","documentStatus":"AE","documentControl":"P","documentQuantity":null}],"checks":[{"checkCode":"H222","departmentCode":"PHA"},{"checkCode":"H224","departmentCode":"PHA"}]}]}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"serviceHeader":{"sourceSystem":"ALVS","destinationSystem":"CDS","correlationId":"000","serviceCallTimestamp":1734712616447},"header":{"entryReference":"24GBE2TF54PWDGXAR0","entryVersionNumber":1,"decisionNumber":1},"items":[{"itemNumber":1,"documents":[],"checks":[{"checkCode":"H222","decisionCode":"C03","decisionValidUntil":null,"decisionReasons":[]},{"checkCode":"H224","decisionCode":"C07","decisionValidUntil":null,"decisionReasons":[]}]}]}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"serviceHeader":{"sourceSystem":"ALVS","destinationSystem":"CDS","correlationId":"000","serviceCallTimestamp":1734813365406},"header":{"entryReference":"24GBE2TF54PWDGXAR0","entryVersionNumber":2,"decisionNumber":2},"items":[{"itemNumber":1,"documents":[],"checks":[{"checkCode":"H222","decisionCode":"C03","decisionValidUntil":null,"decisionReasons":[]},{"checkCode":"H224","decisionCode":"C07","decisionValidUntil":null,"decisionReasons":[]}]}]}
Loading

0 comments on commit a485743

Please sign in to comment.