Ejemplo n.º 1
0
        }         // GetBusinessCaisStatuses

        public ConsumerLatesModel GetLates(
            int customerId,
            DateTime asOfDate,
            int minLateStatus,
            int lastMonthStatuses,
            List <CaisStatus> caisStatuses = null
            )
        {
            if (caisStatuses == null)
            {
                caisStatuses = GetConsumerCaisStatuses(customerId);
            }

            var numOfLates = 0;
            var lateDays   = 0;

            DateTime prevMonth      = asOfDate.AddMonths(-1);
            DateTime prevMonthStart = prevMonth.AddDays(1 - prevMonth.Day).Date;

            foreach (var caisStatus in caisStatuses)
            {
                if (caisStatus.LastUpdatedDate < prevMonthStart)
                {
                    continue;
                }

                bool isLateInAccount = false;

                for (int i = 0; i < lastMonthStatuses; ++i)
                {
                    if (caisStatus.AccountStatusCodes.Length - i <= 0)
                    {
                        continue;
                    }

                    string status = caisStatus.AccountStatusCodes[caisStatus.AccountStatusCodes.Length - i - 1].ToString();

                    var accountStatus = AccountStatusDictionary.GetAccountStatus(status);

                    if (accountStatus.IsLate && accountStatus.LateStatus > minLateStatus)
                    {
                        isLateInAccount = true;
                        lateDays        = lateDays < accountStatus.LateDays ? accountStatus.LateDays : lateDays;
                    }             // if
                }                 // for

                if (isLateInAccount)
                {
                    numOfLates++;
                }
            }             // for each CAIS status

            return(new ConsumerLatesModel {
                LateDays = lateDays,
                NumOfLates = numOfLates
            });
        }         // GetLates
Ejemplo n.º 2
0
        }         // GetLates

        public DefaultsModel GetDefaults(
            int customerId,
            DateTime asOfDate,
            int minAmount,
            int lastMonthStatuses,
            List <CaisStatus> caisStatuses = null
            )
        {
            if (caisStatuses == null)
            {
                caisStatuses = GetConsumerCaisStatuses(customerId);
            }

            DateTime asOfMonth = new DateTime(asOfDate.Year, asOfDate.Month, 1, 0, 0, 0, DateTimeKind.Utc);

            DateTime lastRelevantMonth = asOfMonth.AddMonths(-lastMonthStatuses + 1);

            var numOfDefaults  = 0;
            var defaultsAmount = 0;

            foreach (CaisStatus caisStatus in caisStatuses)
            {
                DateTime thisMonth = new DateTime(
                    caisStatus.LastUpdatedDate.Year,
                    caisStatus.LastUpdatedDate.Month,
                    1,
                    0,
                    0,
                    0,
                    DateTimeKind.Utc
                    );

                if (thisMonth < lastRelevantMonth)
                {
                    continue;
                }

                int monthSinceUpdate = 1 + MiscUtils.DateDiffInMonths(thisMonth, asOfMonth);

                int useLastStatusMonths = lastMonthStatuses - monthSinceUpdate + 1;

                bool isDefaultInAccount = false;

                for (int i = 0; i < useLastStatusMonths; ++i)
                {
                    if (caisStatus.AccountStatusCodes.Length - i <= 0)
                    {
                        continue;
                    }

                    string            status        = caisStatus.AccountStatusCodes[caisStatus.AccountStatusCodes.Length - i - 1].ToString();
                    CaisAccountStatus accountStatus = AccountStatusDictionary.GetAccountStatus(status);
                    int balance = Math.Max(caisStatus.Balance, caisStatus.CurrentDefBalance);

                    if (accountStatus.IsDefault && balance > minAmount)
                    {
                        isDefaultInAccount = true;
                    }
                }                 // for

                if (isDefaultInAccount)
                {
                    numOfDefaults++;
                    defaultsAmount += caisStatus.Balance;
                }         // if
            }             // for each CAIS status

            return(new DefaultsModel {
                DefaultsAmount = defaultsAmount,
                NumOfDefaults = numOfDefaults
            });
        }         // GetDefaults