Beispiel #1
0
        private PeriodInfo GetIINRateFromEgrm(nm_e_gramatinasGigv egrm, DateTime dt1, DateTime dt2)
        {
            var um0 = new UntMinData();

            um0.Dt1 = dt1;
            um0.Dt2 = dt2;
            var ret = new PeriodInfo();

            ret.DateFirst = dt1;
            ret.DateLast  = dt2;
            var ret2 = new PeriodInfo();

            ret2.DateFirst = dt1;
            ret2.DateLast  = dt2;
            ret2.Item1     = um0;
            ret.LinkedPeriods.Add(ret2);

            var egrm_iinlikme = egrm?.pazime_progr_iin_likmes?.pazime_progr_iin_likme;

            if (egrm_iinlikme == null)
            {
                return(ret);
            }
            var ret3 = new UntMinData()
            {
                Dt1         = egrm_iinlikme.datums_no,
                Dt2         = egrm_iinlikme.datums_lidzSpecified && egrm_iinlikme.datums_lidz != null ? egrm_iinlikme.datums_lidz.Value : dt2,
                IINRateType = 1
            };

            if (ret3.Dt1 < dt1)
            {
                ret3.Dt1 = dt1;
            }
            if (ret3.Dt2 > dt2)
            {
                ret3.Dt2 = dt2;
            }
            if (ret3.Dt1 > dt2 || ret3.Dt2 < dt1 || ret3.Dt2 < ret3.Dt1)
            {
                return(ret);
            }
            ret2.DateFirst = ret3.Dt1;
            ret2.DateLast  = ret3.Dt2;
            ret2.Item1     = ret3;
            return(ret);
        }
Beispiel #2
0
        private PeriodInfo GetUntMinFromEgrm(nm_e_gramatinasGigv egrm, DateTime dt1, DateTime dt2)
        {
            var um0 = new UntMinData();

            um0.Dt1 = dt1;
            um0.Dt2 = dt2;
            var ret = new PeriodInfo();

            ret.DateFirst = dt1;
            ret.DateLast  = dt2;
            var ret2 = new PeriodInfo();

            ret2.DateFirst = dt1;
            ret2.DateLast  = dt2;
            ret2.Item1     = um0;
            ret.LinkedPeriods.Add(ret2);

            if (egrm.prognozetie_mnm == null || egrm.prognozetie_mnm.Length == 0)
            {
                return(ret);
            }

            var pi = new PeriodInfo();

            pi.DateFirst = dt1;
            pi.DateLast  = dt2;
            var ums1 = egrm.prognozetie_mnm
                       .OrderBy(d => d.datums_no)
                       .Where(d => d.datums_no <= dt2)
                       .Select(d =>
            {
                var rt = new UntMinData()
                {
                    Dt1    = d.datums_no,
                    Dt2    = d.datums_lidzSpecified && d.datums_lidz != null ? d.datums_lidz.Value : dt2,
                    UntMin = (decimal)d.summa
                };
                if (rt.Dt1 < dt1)
                {
                    rt.Dt1 = dt1;
                }
                if (rt.Dt2 > dt2)
                {
                    rt.Dt2 = dt2;
                }
                return(rt);
            })
                       .Where(d => d.Dt2 >= d.Dt1 && d.Dt2 >= dt1)
                       .ToList();

            if (ums1.Count == 0)
            {
                return(ret);
            }

            var ums2 = ums1
                       .Select(d => new PeriodInfo()
            {
                DateFirst = d.Dt1,
                DateLast  = d.Dt2,
                Item1     = d
            })
                       .ToList();

            ret.LinkedPeriods.Clear();
            ret.LinkedPeriods.AddRange(ums2);

            return(ret);
        }