protected int ComputeTimeToMaturityMonthsPerRecord(Loanbook_Data loanbookRecord, int expOdPerformacePastRepoting, int odPerformancePastExpiry)
        {
            if (loanbookRecord.ContractId.Substring(0, 3) == ECLStringConstants.i.ExpiredContractsPrefix)
            {
                return(0);
            }
            else
            {
                int xValue = 0;
                int yValue = 0;

                DateTime?endDate = new DateTime(1900, 01, 01);
                if (loanbookRecord.RestructureIndicator && loanbookRecord.RestructureEndDate != null)
                {
                    if (loanbookRecord.RestructureEndDate == null)
                    {
                        xValue = 0;
                    }
                    else
                    {
                        endDate = DateTime.Parse(loanbookRecord.RestructureEndDate.ToString());
                    }
                }
                else
                {
                    if (loanbookRecord.ContractEndDate == null)
                    {
                        xValue = 0;
                    }
                    else
                    {
                        endDate = DateTime.Parse(loanbookRecord.ContractEndDate.ToString());
                    }
                }

                var prod = 0;
                if (endDate != null && endDate != new DateTime(1900, 01, 01))
                {
                    if (!endDate.ToString().Contains("0001"))
                    {
                        var eomonth  = ExcelFormulaUtil.EOMonth(endDate);
                        var yearFrac = ExcelFormulaUtil.YearFrac(GetReportingDate(_eclType, _eclId), eomonth);
                        var round    = Convert.ToInt32(Math.Round(yearFrac * 12, 0));

                        var rptDate = GetReportingDate(_eclType, _eclId);
                        xValue = endDate > rptDate ? round : 0;

                        var maxx = Math.Max(expOdPerformacePastRepoting - round, 0);
                        prod = endDate < rptDate ? maxx : odPerformancePastExpiry;
                    }
                }
                loanbookRecord.ProductType = loanbookRecord.ProductType ?? "";
                yValue = loanbookRecord.ProductType.ToLower() == ECLStringConstants.i._productType_card.ToLower() || loanbookRecord.ProductType.ToLower() == ECLStringConstants.i._productType_od.ToLower() ? prod : 0;

                //Financial.YearFrac()
                return(xValue + yValue);
            }
        }
Exemple #2
0
        protected double ComputeStageDaysPastDue(string date)
        {
            var r = date == null ? 0 : ExcelFormulaUtil.YearFrac(DateTime.Parse(date), GetReportingDate(_eclType, _eclId)) * 365;

            return(r);
        }