Exemplo n.º 1
0
        public void SetCurrentRates(DateTime dt)
        {
            var dr_persons_r = DataTasks.GetPersonsR(IDP, dt);
            var dr_rates     = DataTasks.GetRates(dt);

            if (dr_persons_r == null || dr_rates == null)
            {
                return;
            }
            var cr = new CalcRRow2();

            CalcRInfo.GetRatesForPerson(cr, dr_persons_r, dr_rates, dt);
            CalcRInfo.GetIINDeductionsForPerson(cr, dr_persons_r, dr_rates, dt);
            ExDependants        = cr.ExDependants;
            ExInvalidity        = cr.ExInvalidity;
            ExNationalMovements = cr.ExNationalMovements;
            ExRetaliation       = cr.ExRetaliation;
            ExUntaxedMinimum    = cr.ExUntaxedMinimum;
            //Ex2Tp = cr.Ex2Tp;
            RateDDSN             = cr.RateDDSN;
            RateDNSN             = cr.RateDNSN;
            RateIIN              = cr.RateIIN;
            RateIIN2             = cr.RateIIN2;
            UseProgresiveIINRate = cr.UseProgresiveIINRate;
        }
Exemplo n.º 2
0
        public List <KeyValuePair <DateTime, CalcRRow2> > GetDatesAndRates(DateTime dte)
        {
            var table_persons    = MyData.DataSetKlons.PERSONS;
            var table_persons_r  = MyData.DataSetKlons.PERSONS_R;
            var table_events     = MyData.DataSetKlons.EVENTS;
            var table_rates      = MyData.DataSetKlons.RATES;
            var table_untaxedmin = MyData.DataSetKlons.UNTAXED_MIN;

            var dr_person     = table_persons.FindByID(IDP);
            var drs_persons_r = dr_person.GetPERSONS_RRows()
                                .OrderBy(d => d.EDIT_DATE)
                                .ToArray();

            var drs_events = dr_person.GetEVENTSRows();

            var drsn_hirefire = drs_events
                                .Where(d =>
                                       Utils.IN(d.IDN, (int)EEventId.Pieņemts, (int)EEventId.Atlaists))
                                .OrderBy(d => d.DATE1)
                                .ToArray();

            if (drsn_hirefire.Length == 0)
            {
                return(null);
            }

            DateTime dt1, dt2;

            var dd = new DateList();

            for (int i = 0; i < drsn_hirefire.Length; i += 2)
            {
                dt1 = drsn_hirefire[i].DATE1;
                dt2 = i + 1 == drsn_hirefire.Length ?
                      dte :
                      drsn_hirefire[i].DATE1;
                dd.List.Add(new DatesFromTo(dt1, dt2));
            }

            dt1 = dd.List[0].DateFrom;
            dt2 = dd.List[dd.List.Count - 1].DateTo;

            var drsn_hire = drsn_hirefire
                            .Where(d =>
                                   d.IDN == (int)EEventId.Pieņemts)
                            .OrderBy(d => d.DATE1)
                            .ToArray();

            var drs_rates_ordered = table_rates
                                    .WhereX(d =>
                                            d.ONDATE <= dte)
                                    .OrderBy(d => d.ONDATE)
                                    .ToArray();

            var drs_rates = drs_rates_ordered
                            .Where(d =>
                                   dd.HasDate(d.ONDATE))
                            .ToArray();

            var drs_untaxedmin = table_untaxedmin
                                 .WhereX(d => d.ONDATE <= dte)
                                 .OrderBy(d => d.ONDATE)
                                 .ToArray();

            var l_dates = new List <DateTime>();

            l_dates.AddRange(drsn_hire.Select(d => d.DATE1));
            l_dates.AddRange(drs_persons_r.Select(d => d.EDIT_DATE));
            l_dates.AddRange(drs_rates.Select(d => d.ONDATE));
            l_dates.AddRange(drs_untaxedmin.Select(d => d.ONDATE));
            l_dates.Sort();
            var a_dates = l_dates.DistinctForOrdered().ToArray();

            var list_ret = new List <KeyValuePair <DateTime, CalcRRow2> >();

            foreach (var dti in a_dates)
            {
                var dr_pr = drs_persons_r
                            .Where(d => d.EDIT_DATE <= dti)
                            .LastOrDefault();
                var dr_rt = drs_rates_ordered
                            .Where(d => d.ONDATE <= dti)
                            .LastOrDefault();
                if (dr_pr == null || dr_rt == null)
                {
                    continue;
                }
                var cr = new CalcRRow2();
                CalcRInfo.GetRatesForPerson(cr, dr_pr, dr_rt, dti);
                CalcRInfo.GetIINDeductionsForPerson(cr, dr_pr, dr_rt, dti);
                if (list_ret.Count > 0 && list_ret[list_ret.Count - 1].Value.Equals(cr))
                {
                    continue;
                }
                list_ret.Add(new KeyValuePair <DateTime, CalcRRow2>(dti, cr));
            }

            return(list_ret);
        }