Files
monorepo/LCU.API.Collections.RepoApi-old/LCU.API.Collections.RepoApi/Domain/AlertChecker/RepoNotSoldChecker.cs
T
2026-04-20 14:47:24 -05:00

53 lines
2.1 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using LCU.API.Collections.RepoApi.Domain.Extensions;
using LCU.API.Collections.RepoApi.Domain.Processing;
using LCU.API.Collections.RepoApi.Extensions;
using EventAlert = LCU.Shared.Collections.RepoApiLib.Models.EventAlert;
namespace LCU.API.Collections.RepoApi.Domain.AlertChecker
{
public class RepoNotSoldChecker : IAlertChecker
{
private readonly int _dayCount;
private readonly int _repeatDayCount;
private const string RepoStatus = "REPO";
private const string DestinationEmail = "[email protected]";
public RepoNotSoldChecker(int dayCount = 30, int repeatDayCount = 0)
{
_dayCount = dayCount;
_repeatDayCount = repeatDayCount;
}
public List<EventAlert> CheckForAlert(RepoAccountProcessingSlip slip)
{
var status = slip.UpdatedRepoAccount.Status.ToUpper().Trim();
var days = slip.UpdatedRepoAccount.GetDaysInStatus(status);
if (status == RepoStatus && days > 0)
{
if ((days == _dayCount) || days >= _dayCount && ((days - _dayCount) % _repeatDayCount == 0))
{
var member = slip.UpdatedRepoAccount.Borrowers?.First(b => b.OwnershipType == 6);
return new List<EventAlert>
{
new EventAlert()
{
RepoId = slip.UpdatedRepoAccount.RepoId,
AccountNo = slip.UpdatedRepoAccount.AccountNo,
Message = "Repo Not Sold",
CreatedBy = "Batch",
DateAdded = DateTime.Now,
EmailRecipient = DestinationEmail,
EmailBody = string.Format("{0} {1} Account status REPO, Not Sold for extended time.",
slip.UpdatedRepoAccount.AccountNo, member?.IndividualName)
}
};
}
}
return null;
}
}
}