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 void AddForExFull(CalcRRow2 cr)
 {
     ExDependants        = Math.Max(ExDependants, cr.ExDependants);
     ExInvalidity        = Math.Max(ExInvalidity, cr.ExInvalidity);
     ExNationalMovements = Math.Max(ExNationalMovements, cr.ExNationalMovements);
     ExRetaliation       = Math.Max(ExRetaliation, cr.ExRetaliation);
     ExUntaxedMinimum    = Math.Max(ExUntaxedMinimum, cr.ExUntaxedMinimum);
 }
Exemplo n.º 3
0
 public void Add(CalcRRow2 cr)
 {
     ExDependants        += cr.ExDependants;
     ExInvalidity        += cr.ExInvalidity;
     ExNationalMovements += cr.ExNationalMovements;
     ExRetaliation       += cr.ExRetaliation;
     ExUntaxedMinimum    += cr.ExUntaxedMinimum;
 }
Exemplo n.º 4
0
 public bool Equals(CalcRRow2 cr)
 {
     if (ExDependants != cr.ExDependants)
     {
         return(false);
     }
     if (ExInvalidity != cr.ExInvalidity)
     {
         return(false);
     }
     if (ExNationalMovements != cr.ExNationalMovements)
     {
         return(false);
     }
     if (ExRetaliation != cr.ExRetaliation)
     {
         return(false);
     }
     if (ExUntaxedMinimum != cr.ExUntaxedMinimum)
     {
         return(false);
     }
     if (Ex2Tp != cr.Ex2Tp)
     {
         return(false);
     }
     if (ExExpenses != cr.ExExpenses)
     {
         return(false);
     }
     if (RateDDSN != cr.RateDDSN)
     {
         return(false);
     }
     if (RateDNSN != cr.RateDNSN)
     {
         return(false);
     }
     if (RateIIN != cr.RateIIN)
     {
         return(false);
     }
     if (RateIIN2 != cr.RateIIN2)
     {
         return(false);
     }
     if (IINMargin != cr.IINMargin)
     {
         return(false);
     }
     if (HasTaxDoc != cr.HasTaxDoc)
     {
         return(false);
     }
     return(true);
 }
Exemplo n.º 5
0
        public static void GetIINDeductionsForPerson(CalcRRow2 wt, KlonsADataSet.PERSONS_RRow drpr,
                                                     KlonsADataSet.RATESRow drl, DateTime dt1, DateTime dt2, int calcver)
        {
            wt.ExUntaxedMinimum    = 0.0M;
            wt.ExDependants        = 0.0M;
            wt.ExInvalidity        = 0.0M;
            wt.ExRetaliation       = 0.0M;
            wt.ExNationalMovements = 0.0M;

            if (!string.IsNullOrEmpty(drpr.TAXDOC_NO))
            {
                wt.ExDependants = drl.APGAD * (decimal)drpr.APGAD_SK;

                if (drpr.INVALID == 1 || drpr.INVALID == 2)
                {
                    wt.ExInvalidity = drl.INVALID_12;
                }
                else if (drpr.INVALID == 3)
                {
                    wt.ExInvalidity = drl.INVALID_3;
                }

                if (drpr.PRET == 1)
                {
                    wt.ExNationalMovements = drl.PRET;
                }

                if (drpr.REPRES == 1)
                {
                    wt.ExRetaliation = drl.REPR;
                }

                if (drpr.PENSIONER == 1 || drpr.PENSIONER_SP == 1)
                {
                    wt.ExUntaxedMinimum = 0.0M;
                }
                else
                {
                    if (dt1 < ProgressiveIINStartDate)
                    {
                        wt.ExUntaxedMinimum = drl.NEPLIEK_MIN;
                    }
                    else
                    {
                        if (calcver == KlonsData.VersionRef(0))
                        {
                            wt.ExUntaxedMinimum = GetIINUntaxedMinimum(drpr.PERSONSRow, dt1);
                        }
                        else
                        {
                            wt.ExUntaxedMinimum = GetIINUntaxedMinimum2(drpr.PERSONSRow, dt1, dt2);
                        }
                    }
                }
            }
        }
Exemplo n.º 6
0
 public void SaveStateForMax(CalcRRow2 cr)
 {
     if (!PreparingReport)
     {
         return;
     }
     CrInvalidity.RateMax       = cr.ExInvalidity;
     CrRetaliation.RateMax      = cr.ExRetaliation;
     CrNationalMovement.RateMax = cr.ExNationalMovements;
 }
Exemplo n.º 7
0
        public static void GetRatesForPerson(CalcRRow2 wt, KlonsADataSet.PERSONS_RRow drpr, KlonsADataSet.RATESRow drl, DateTime dt)
        {
            wt.UseProgresiveIINRate = dt >= ProgressiveIINStartDate;
            wt.HasTaxDoc            = !string.IsNullOrEmpty(drpr.TAXDOC_NO);
            if (dt < ProgressiveIINStartDate)
            {
                wt.RateIIN  = drl.IIN_LIKME;
                wt.RateIIN2 = drl.IIN_LIKME;
            }
            else
            {
                wt.RateIIN  = drl.IIN_LIKME;
                wt.RateIIN2 = drl.IIN_LIKME_2;
                int iin_rate_type = GetIINRateType(drpr.PERSONSRow, dt.FirstDayOfMonth());
                if (iin_rate_type == 1)
                {
                    wt.RateIIN = wt.RateIIN2;
                }
            }
            wt.IINMargin = drl.IIN_SLIEKSNIS_1;

            if (drpr.PENSIONER == 1)
            {
                if (drpr.PRISONER == 1)
                {
                    wt.RateDNSN = drl.SIDN_IESLODZ_PENS;
                    wt.RateDDSN = drl.SIDD_IESLODZ_PENS;
                }
                else
                {
                    wt.RateDNSN = drl.SIDN_PENS;
                    wt.RateDDSN = drl.SIDD_PENS;
                }
            }
            else if (drpr.PENSIONER_SP == 1)
            {
                wt.RateDNSN = drl.SIDN_IZDPENS;
                wt.RateDDSN = drl.SIDD_IZDPENS;
            }
            else
            {
                if (drpr.PRISONER == 1)
                {
                    wt.RateDNSN = drl.SIDN_IESLODZ;
                    wt.RateDDSN = drl.SIDD_IESLODZ;
                }
                else
                {
                    wt.RateDNSN = drl.SIDN_PAMATLIKME;
                    wt.RateDDSN = drl.SIDD_PAMATLIKME;
                }
            }
        }
Exemplo n.º 8
0
 public void SaveStateForFinal(CalcRRow2 cr)
 {
     if (!PreparingReport)
     {
         return;
     }
     CrUntaxedMinimum.Rate   = cr.ExUntaxedMinimum;
     CrDependants.Rate       = cr.ExDependants;
     CrInvalidity.Rate       = cr.ExInvalidity;
     CrRetaliation.Rate      = cr.ExRetaliation;
     CrNationalMovement.Rate = cr.ExNationalMovements;
     CrExpenses.Rate         = cr.ExExpenses;
 }
Exemplo n.º 9
0
 public void SetFrom(CalcRRow2 cr)
 {
     ExDependants        = cr.ExDependants;
     ExInvalidity        = cr.ExInvalidity;
     ExNationalMovements = cr.ExNationalMovements;
     ExRetaliation       = cr.ExRetaliation;
     ExUntaxedMinimum    = cr.ExUntaxedMinimum;
     Ex2Tp                = cr.Ex2Tp;
     ExExpenses           = cr.ExExpenses;
     RateDDSN             = cr.RateDDSN;
     RateDNSN             = cr.RateDNSN;
     RateIIN              = cr.RateIIN;
     RateIIN2             = cr.RateIIN2;
     IINMargin            = cr.IINMargin;
     HasTaxDoc            = cr.HasTaxDoc;
     UseProgresiveIINRate = cr.UseProgresiveIINRate;
 }
Exemplo n.º 10
0
        public void CalcR(SalarySheetRowInfo sr, DateTime dt1, DateTime dt2)
        {
            if (dt1 > dt2 || dt1.Month != dt2.Month)
            {
                throw new ArgumentException("Bad call.");
            }

            IINMargin = PayFx.GetIINMargin(dt1);

            var fPersonR   = sr.PersonR.FilterListWithDates(dt1, dt2);
            var fHireFire  = sr.Events.HireFire.FilterListWithDates(dt1, dt2);
            var sickleaveb = sr.Events.SickDays.LinkedPeriods
                             .Where(d => d.EEventId == EEventId.Slimības_lapa_B)
                             .ToArray();

            fPersonR = fPersonR.FilterWithList(fHireFire);
            fPersonR = fPersonR.SubtractList(sickleaveb);

            DaysInMonth  = dt1.DaysInMonth();
            CalendarDays = 0;

            var dr_likmes = dt1.Month == sr.SalarySheet.MT ?
                            sr.SalarySheet.DR_Likmes : null;

            if (dr_likmes == null)
            {
                dr_likmes = DataTasks.GetRates(dt1.FirstDayOfMonth());
            }

            if (fPersonR.LinkedPeriods.Count == 0)
            {
                return;
            }

            var wt1 = new CalcRRow2();
            var pr1 = fPersonR.LinkedPeriods[0].Item1 as KlonsADataSet.PERSONS_RRow;

            IsPensioner          = pr1.PENSIONER == 1;
            HasTaxDoc            = !string.IsNullOrEmpty(pr1.TAXDOC_NO);
            UseProgresiveIINRate = (dt1 >= ProgressiveIINStartDate);

            GetRatesForPerson(wt1, pr1, dr_likmes, dt1);

            RateDDSN             = wt1.RateDDSN;
            RateDNSN             = wt1.RateDNSN;
            RateIIN              = wt1.RateIIN;
            RateIIN2             = wt1.RateIIN2;
            IINMargin            = wt1.IINMargin;
            HasTaxDoc            = wt1.HasTaxDoc;
            UseProgresiveIINRate = wt1.UseProgresiveIINRate;

            for (int i = 0; i < fPersonR.LinkedPeriods.Count; i++)
            {
                var pri     = fPersonR.LinkedPeriods[i];
                var dt1x    = pri.DateFirst;
                var dt2x    = pri.DateLast;
                int caldays = dt2x.Subtract(dt1x).Days + 1;
                CalendarDays += caldays;

                GetIINDeductionsForPerson(wt1, pri.Item1 as KlonsADataSet.PERSONS_RRow, dr_likmes, dt1x, dt2x, CalcVer);

                ExFull.AddForExFull(wt1);

                if (PreparingReport)
                {
                    SaveStateForMonth(wt1);
                    SaveStateDays(caldays);
                }

                decimal rt = (decimal)caldays / (decimal)DaysInMonth;

                wt1.Multiply(rt);

                ExForDays.Add(wt1);

                if (PreparingReport)
                {
                    SaveStateForDays(wt1);
                    AddToList(dt1x, dt2x);
                }
            }

            ExFull.Round();
            ExForDays.Round();
            ExMax2.SetFrom(ExForDays);

            if (!sr.IsSingleRow() && sr.TotalPositionPay.IINExempt2Kind != EIINExempt2Kind.None &&
                sr.SalarySheet.MT == dt1.Month)
            {
                SetMax(sr.TotalPositionPay.IINExempt2Kind);
            }
            else
            {
                FindMax();
            }

            ExDivided.SetFrom(ExMax2);
            ExCorrect.SetFrom(ExMax2);

            if (PreparingReport)
            {
                SaveStateForMonth(ExFull);
                SaveStateForDays(ExForDays);
                SaveStateForMax(ExMax2);
            }
        }
Exemplo n.º 11
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);
        }