71 lines
2.3 KiB
C#
71 lines
2.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using LCU.API.Collections.CollectionsApiLib.Models;
|
|
using LCU.API.Collections.RepoApi.Domain.Processing;
|
|
using LCU.Shared.Collections.RepoApiLib.Models;
|
|
|
|
namespace LCU.API.Collections.RepoApi.Domain.AlertChecker
|
|
{
|
|
public class RtcLetterNotFoundChecker : IAlertChecker
|
|
{
|
|
private readonly string _document;
|
|
private readonly IEnumerable<string> _actionCodes;
|
|
private const string O4RStatus = "O4R";
|
|
private const string StateWisconsin = "WI";
|
|
|
|
public RtcLetterNotFoundChecker(string document, IEnumerable<string> actionCodes)
|
|
{
|
|
_document = document;
|
|
_actionCodes = actionCodes.Select(code => code.Trim().ToUpper());
|
|
}
|
|
|
|
public List<EventAlert> CheckForAlert(RepoAccountProcessingSlip slip)
|
|
{
|
|
if (slip.Member?.Address == null || slip.Member.Address.State != StateWisconsin || slip.Letters == null)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
foreach (var collateral in slip.UpdatedRepoAccount.Collaterals)
|
|
{
|
|
if (collateral.RepoCompanySelections?.FirstOrDefault(x => x.RepoType == RepoType.Voluntary) != null)
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
|
|
var letters = slip.Letters;
|
|
if (IsLetterMissing(letters) && (slip.UpdatedRepoAccount.Status.ToUpper().Trim() == O4RStatus))
|
|
{
|
|
return new List<EventAlert>
|
|
{
|
|
new EventAlert()
|
|
{
|
|
RepoId = slip.UpdatedRepoAccount.RepoId,
|
|
AccountNo = slip.UpdatedRepoAccount.AccountNo,
|
|
Message = _document + " Not Found",
|
|
CreatedBy = "Batch",
|
|
DateAdded = DateTime.Now
|
|
}
|
|
};
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
private bool IsLetterMissing(IEnumerable<RepoLetter> letters)
|
|
{
|
|
var sentLetterCodes = letters.Select(x => x.ActionCode).ToList();
|
|
foreach (var actionCode in _actionCodes)
|
|
{
|
|
if (sentLetterCodes.Contains(actionCode))
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|
|
} |