Пример #1
0
        public ErrorList CalcSickDaysB(SalarySheetRowInfo sr, SickDayCalcInfo totalsdci)
        {
            var dt1  = sr.SalarySheet.DT1;
            var dt2  = sr.SalarySheet.DT2;
            var mdt1 = sr.SalarySheet.MDT1;
            var mdt2 = sr.SalarySheet.MDT2;
            var mdt3 = sr.SalarySheet.MDT1.AddMonths(-1);

            var ps = sr.Events.SickDays.LinkedPeriods.Where(
                d =>
                d.EEventId == EEventId.Slimības_lapa_A &&
                d.DateLast >= dt1 &&
                d.DateLast <= dt2
                ).ToArray();

            if (ps.Length == 0)
            {
                return(new ErrorList());
            }

            int d1;

            SickDayCalcRow sdi = TotalRow;

            foreach (var pi in ps)
            {
                var dtp1 = pi.DateFirst;
                if (dtp1 < mdt3)
                {
                    continue;
                }

                d1 = 0;

                if (PreparingReport)
                {
                    sdi           = new SickDayCalcRow();
                    sdi.DateStart = pi.DateFirst;
                    sdi.DateEnd   = pi.DateLast;
                    Rows.Add(sdi);
                }


                if (dtp1 < mdt1)
                {
                    var prevdlrowset = sr.GetDLRowSet(-1, sr.Row.IDAM);
                    if (prevdlrowset != null)
                    {
                        var dtp2 = dtp1.LastDayOfMonth();
                        prevdlrowset.CountSickDays(sdi, dtp1, dtp2, 0);

                        d1 = (dtp2 - dtp1).Days + 1;
                        if (d1 <= 10)
                        {
                            sr.DLRows.CountSickDays(sdi, mdt1, pi.DateLast, d1);
                        }
                    }
                }
                else
                {
                    sr.DLRows.CountSickDays(sdi, pi.DateFirst, pi.DateLast, d1);
                }

                if (PreparingReport)
                {
                    TotalRow.AddB(sdi);
                }
            }

            if (PreparingReport)
            {
                Rows.Add(TotalRow);
                PrepareListA();
            }

            if (TotalRow.DaysCount == 0)
            {
                return(new ErrorList());
            }

            var err = GatAvPay(sr);

            if (err.HasErrors)
            {
                return(err);
            }

            decimal _AvPayRate = AvPayRateDay;

            if (IsAggregatedTimeRate(sr))
            {
                _AvPayRate = AvPayRateCalendarDay;
            }
            TotalRow.AvPayRate = _AvPayRate;

            if (totalsdci == null)
            {
                TotalRow.SickDayPay75 = KlonsData.RoundA(_AvPayRate * TotalRow.DaysCount75 * 0.75M, 2);
                TotalRow.SickDayPay80 = KlonsData.RoundA(_AvPayRate * TotalRow.DaysCount80 * 0.8M, 2);
            }
            else
            {
                TotalRow.SickDayPay75 = (decimal)TotalRow.HoursCount75 / (decimal)totalsdci.TotalRow.HoursCount75;
                TotalRow.SickDayPay80 = (decimal)TotalRow.HoursCount80 / (decimal)totalsdci.TotalRow.HoursCount80;
                TotalRow.SickDayPay75 = KlonsData.RoundA(TotalRow.SickDayPay75 * totalsdci.TotalRow.SickDayPay75, 2);
                TotalRow.SickDayPay80 = KlonsData.RoundA(TotalRow.SickDayPay80 * totalsdci.TotalRow.SickDayPay80, 2);
            }
            TotalRow.SickDayPay = TotalRow.SickDayPay75 + TotalRow.SickDayPay80;

            return(new ErrorList());
        }