Skip to content

Commit

Permalink
Fix sonarqube issue
Browse files Browse the repository at this point in the history
  • Loading branch information
craigedmunds committed Feb 3, 2025
1 parent 2a79e0b commit 3f36dd6
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 32 deletions.
9 changes: 5 additions & 4 deletions Btms.Analytics/MovementExceptions.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Diagnostics.CodeAnalysis;
using System.Text;
using Btms.Analytics.Extensions;
using Btms.Backend.Data;
Expand All @@ -20,9 +21,10 @@ private static string FormatUnmatched(DecisionStatusEnum decisionStatus, Movemen

return matched.ToString();
}
//Returns a summary of the exceptions or a list
// Means we can share the same anonymous / query code without needing to create loads
// of classes

[SuppressMessage("SonarLint", "S3776",
Justification =
"Means we can share the same anonymous / query code without needing to create loads of classes for the intermediate state")]
public (SingleSeriesDataset summary, List<ExceptionResult>) GetAllExceptions(DateTime from, DateTime to, bool finalisedOnly, bool summary, ImportNotificationTypeEnum[]? chedTypes = null, string? country = null)
{
var exceptionsSummary = new SingleSeriesDataset();
Expand All @@ -31,7 +33,6 @@ private static string FormatUnmatched(DecisionStatusEnum decisionStatus, Movemen
var simplifiedMovementView = context
.Movements
.WhereFilteredByCreatedDateAndParams(from, to, finalisedOnly, chedTypes, country)
// .Where(m => m.Id == "24GBE3BA7NHLFZMAR1")
.Select(m => new
{
// NB - we should think about pre-calculating this stuff and storing it on the movement...
Expand Down
64 changes: 36 additions & 28 deletions Btms.Business/Builders/MovementBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,40 @@ private void GuardNullMovement()
"Can't call this without first calling 'From' to initialise the builder.");
}
}

private StatusChecker GetAlvsCheckStatus(List<ItemCheck> alvsChecks)
{
return new StatusChecker()
{
AllMatch = alvsChecks.All(c => !c.AlvsDecisionCode.StartsWith('X')),
AnyMatch = alvsChecks.Any(c => !c.AlvsDecisionCode.StartsWith('X')),
AllNoMatch = alvsChecks.All(c => c.AlvsDecisionCode.StartsWith('X')),
AnyNoMatch = alvsChecks.Any(c => c.AlvsDecisionCode.StartsWith('X')),
AllRefuse = alvsChecks.All(c => c.AlvsDecisionCode.StartsWith('N')),
AnyRefuse = alvsChecks.Any(c => c.AlvsDecisionCode.StartsWith('N')),
AllRelease = alvsChecks.All(c => c.AlvsDecisionCode.StartsWith('C')),
AnyRelease = alvsChecks.Any(c => c.AlvsDecisionCode.StartsWith('C')),
AllHold = alvsChecks.All(c => c.AlvsDecisionCode.StartsWith('H')),
AnyHold = alvsChecks.Any(c => c.AlvsDecisionCode.StartsWith('H'))
};
}

private StatusChecker GeBtmsCheckStatus(List<ItemCheck> alvsChecks)
{
return new StatusChecker()
{
AllMatch = alvsChecks.All(c => c.BtmsDecisionCode.HasValue() && c.BtmsDecisionCode.StartsWith('X')),
AnyMatch = alvsChecks.Any(c => !(c.BtmsDecisionCode.HasValue() && c.BtmsDecisionCode.StartsWith('X'))),
AllNoMatch = alvsChecks.All(c => c.BtmsDecisionCode.HasValue() && c.BtmsDecisionCode.StartsWith('X')),
AnyNoMatch = alvsChecks.Any(c => c.BtmsDecisionCode.HasValue() && c.BtmsDecisionCode.StartsWith('X')),
AllRefuse = alvsChecks.All(c => c.BtmsDecisionCode.HasValue() && c.BtmsDecisionCode.StartsWith('N')),
AnyRefuse = alvsChecks.Any(c => c.BtmsDecisionCode.HasValue() && c.BtmsDecisionCode.StartsWith('N')),
AllRelease = alvsChecks.All(c => c.BtmsDecisionCode.HasValue() && c.BtmsDecisionCode.StartsWith('C')),
AnyRelease = alvsChecks.Any(c => c.BtmsDecisionCode.HasValue() && c.BtmsDecisionCode.StartsWith('C')),
AllHold = alvsChecks.All(c => c.BtmsDecisionCode.HasValue() && c.BtmsDecisionCode.StartsWith('H')),
AnyHold = alvsChecks.Any(c => c.BtmsDecisionCode.HasValue() && c.BtmsDecisionCode.StartsWith('H'))
};
}

private void CompareDecisions(AlvsDecision alvsDecision, CdsDecision btmsDecision)
{
Expand Down Expand Up @@ -352,34 +386,8 @@ private void CompareDecisions(AlvsDecision alvsDecision, CdsDecision btmsDecisio
.ToList();

alvsDecision.Context.DecisionComparison.Checks = alvsChecks;

alvsDecision.Context.AlvsCheckStatus = new StatusChecker()
{
AllMatch = alvsChecks.All(c => !c.AlvsDecisionCode.StartsWith('X')),
AnyMatch = alvsChecks.Any(c => !c.AlvsDecisionCode.StartsWith('X')),
AllNoMatch = alvsChecks.All(c => c.AlvsDecisionCode.StartsWith('X')),
AnyNoMatch = alvsChecks.Any(c => c.AlvsDecisionCode.StartsWith('X')),
AllRefuse = alvsChecks.All(c => c.AlvsDecisionCode.StartsWith('N')),
AnyRefuse = alvsChecks.Any(c => c.AlvsDecisionCode.StartsWith('N')),
AllRelease = alvsChecks.All(c => c.AlvsDecisionCode.StartsWith('C')),
AnyRelease = alvsChecks.Any(c => c.AlvsDecisionCode.StartsWith('C')),
AllHold = alvsChecks.All(c => c.AlvsDecisionCode.StartsWith('H')),
AnyHold = alvsChecks.Any(c => c.AlvsDecisionCode.StartsWith('H'))
};

alvsDecision.Context.BtmsCheckStatus = new StatusChecker()
{
AllMatch = alvsChecks.All(c => c.BtmsDecisionCode.HasValue() && c.BtmsDecisionCode.StartsWith('X')),
AnyMatch = alvsChecks.Any(c => !(c.BtmsDecisionCode.HasValue() && c.BtmsDecisionCode.StartsWith('X'))),
AllNoMatch = alvsChecks.All(c => c.BtmsDecisionCode.HasValue() && c.BtmsDecisionCode.StartsWith('X')),
AnyNoMatch = alvsChecks.Any(c => c.BtmsDecisionCode.HasValue() && c.BtmsDecisionCode.StartsWith('X')),
AllRefuse = alvsChecks.All(c => c.BtmsDecisionCode.HasValue() && c.BtmsDecisionCode.StartsWith('N')),
AnyRefuse = alvsChecks.Any(c => c.BtmsDecisionCode.HasValue() && c.BtmsDecisionCode.StartsWith('N')),
AllRelease = alvsChecks.All(c => c.BtmsDecisionCode.HasValue() && c.BtmsDecisionCode.StartsWith('C')),
AnyRelease = alvsChecks.Any(c => c.BtmsDecisionCode.HasValue() && c.BtmsDecisionCode.StartsWith('C')),
AllHold = alvsChecks.All(c => c.BtmsDecisionCode.HasValue() && c.BtmsDecisionCode.StartsWith('H')),
AnyHold = alvsChecks.Any(c => c.BtmsDecisionCode.HasValue() && c.BtmsDecisionCode.StartsWith('H'))
};
alvsDecision.Context.AlvsCheckStatus = GetAlvsCheckStatus(alvsChecks);
alvsDecision.Context.BtmsCheckStatus = GeBtmsCheckStatus(alvsChecks);

var decisionStatus = DecisionStatusEnum.InvestigationNeeded;
var checksMatch = alvsChecks.All(c => c.AlvsDecisionCode == c.BtmsDecisionCode);
Expand Down

0 comments on commit 3f36dd6

Please sign in to comment.