52 lines
2.1 KiB
C#
52 lines
2.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using LCU.API.Collections.RepoApi.Domain.Processing;
|
|
using LCU.Shared.Collections.RepoApiLib.Models;
|
|
|
|
namespace LCU.API.Collections.RepoApi.Domain.AlertChecker
|
|
{
|
|
public class NoticeOfSurplusDeficiencyNotSentChecker : IAlertChecker
|
|
{
|
|
private const int OwnershipTypeImportant = 6;
|
|
private const int DaysBeforeConsideredNotSent = 2;
|
|
|
|
public List<EventAlert> CheckForAlert(RepoAccountProcessingSlip slip)
|
|
{
|
|
var updatedRepoAccount = slip.UpdatedRepoAccount;
|
|
if (updatedRepoAccount.RefundStatus?.RefundsReceivedDate == null || updatedRepoAccount.DateClosed != null)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
var letterSentBy = DateTime.Now.AddDays(-DaysBeforeConsideredNotSent).Date;
|
|
if (updatedRepoAccount.RefundStatus.RefundsReceivedDate < letterSentBy && updatedRepoAccount.Bankruptcy == null)
|
|
{
|
|
return new List<EventAlert>
|
|
{
|
|
new EventAlert()
|
|
{
|
|
RepoId = updatedRepoAccount.RepoId,
|
|
AccountNo = updatedRepoAccount.AccountNo,
|
|
Message = "Notice of Surplus Deficiency Letter Not Sent",
|
|
CreatedBy = "Batch",
|
|
DateAdded = DateTime.Now,
|
|
EmailRecipient = "[email protected]",
|
|
EmailBody = CreateEmailBody(updatedRepoAccount)
|
|
}
|
|
};
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
private string CreateEmailBody(RepoAccount repoAccount)
|
|
{
|
|
var message = "Notice of Surplus Deficiency Not Sent.<br/><br/>";
|
|
var member = repoAccount.Borrowers?.First(b => b.OwnershipType == OwnershipTypeImportant);
|
|
var memberName = "Member Name: " + member?.IndividualName + "<br/>";
|
|
var accountNo = "Account No: " + repoAccount.AccountNo + "<br/>";
|
|
return string.Concat(message, memberName, accountNo);
|
|
}
|
|
}
|
|
} |