コード例 #1
0
ファイル: WorkPayCalcInfo.cs プロジェクト: Camel-RD/Klons
        public ErrorList CalcPayWithAvPay(SalarySheetRowInfo sr, SalaryInfo totalwt = null)
        {
            var err = DoAvPay(sr, TotalRow, totalwt);

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

            if (PreparingReport)
            {
                foreach (var rr in ReportRows)
                {
                    DoAvPay(sr, rr, totalwt);
                }
            }

            TotalRow._SALARY = TotalRow.SumSalary();
            TotalRow.AddAvPay();

            if (PreparingReport)
            {
                PrepareList(sr.GetPositionTitle());
            }

            return(err);
        }
コード例 #2
0
        public bool IsAggregatedTimeRate(SalarySheetRowInfo srs)
        {
            var sr   = srs.IsSingleRow() ? srs : srs.SalarySheetRowSet.LinkedRows[0];
            var posr = sr.PositionsR.LinkedPeriods[0].Item1 as KlonsADataSet.POSITIONS_RRow;

            return(posr.XRateType == ESalaryType.Aggregated);
        }
コード例 #3
0
        public ErrorList SetUpFromSHRow(KlonsADataSet.SALARY_SHEET_TEMPLRow dr_sh)
        {
            DR_algas_lapu_sh = dr_sh;

            var error_list        = new ErrorList();
            var this_error_source = string.Format("Lapa:{0}", dr_sh.SNR);

            var er = GetLikmes();

            if (er != "OK")
            {
                error_list.AddError(this_error_source, er);
                return(error_list);
            }

            var drs_sh_r = dr_sh.GetSALARY_SHEET_TEMPL_RRows().OrderBy(d => d.SNR);

            foreach (var dr_sh_r in drs_sh_r)
            {
                var salary_sheet_row = new SalarySheetRowInfo(this);
                var err = salary_sheet_row.SetUpFromSHRow(dr_sh_r);

                if (err.Count > 0)
                {
                    error_list.AddRange(err);
                    continue;
                }

                Rows.Add(salary_sheet_row);
            }

            return(error_list);
        }
コード例 #4
0
        public ErrorList SetUpFromSarRow(KlonsADataSet.SALARY_SHEETSRow dr_lapa)
        {
            var error_list = new ErrorList();

            var er = SetUpLightFromSarRow(dr_lapa);

            if (er != "OK")
            {
                return(new ErrorList("", er));
            }

            var drs_r = dr_lapa.XKind == ESalarySheetKind.Total ?
                        dr_lapa.GetSALARY_SHEETS_RRowsByFK_SALARY_SHEETS_R_IDST().OrderBy(d => d.SNR) :
                        dr_lapa.GetSALARY_SHEETS_RRowsByFK_SALARY_SHEETS_R_IDS().OrderBy(d => d.SNR);

            foreach (var dr_r in drs_r)
            {
                var salary_sheet_row = new SalarySheetRowInfo(this);
                var err = salary_sheet_row.SetUpFromRowX(dr_r);
                if (err.HasErrors)
                {
                    return(err);
                }
                Rows.Add(salary_sheet_row);
            }

            return(error_list);
        }
コード例 #5
0
ファイル: AvPayCalcInfo.cs プロジェクト: Camel-RD/Klons
 public ErrorList CalcList(SalarySheetRowInfo sr)
 {
     if (sr.SalarySheetRowSet == null)
     {
         sr.CheckLinkedRows(sr.Row.IDP);
     }
     return(CalcList(sr.SalarySheet, sr.Row.IDP, sr.SalarySheetRowSet.TotalPersonPay));
 }
コード例 #6
0
        public void CalcAndAddSplit(SalarySheetRowInfo sr, VacationCalcRow v, int calcver)
        {
            var pcri = new CalcRInfo(false, calcver);

            pcri.CalcR(sr, v.DateStart, v.DateEnd);
            v.DNS  = KlonsData.RoundA(pcri.RateDNSN * v.Pay / 100.0M, 2);
            v.Cash = v.Pay - v.DNS;
            Add(v);
        }
コード例 #7
0
ファイル: BonusCalcInfo.cs プロジェクト: Camel-RD/Klons
 public BonusCalcInfo(SalarySheetRowInfo shr, bool fillist = false)
 {
     DataRows        = shr.GetAlgasAllPSRows();
     PreparingReport = fillist;
     if (PreparingReport)
     {
         ReportRows = new List <BonusCalcRow>();
     }
 }
コード例 #8
0
ファイル: SalaryCalcInfo.cs プロジェクト: Camel-RD/Klons
 public SalaryCalcInfo(SalarySheetRowInfo sr, SalaryInfo si, bool filllist)
 {
     SR              = sr;
     SI              = si;
     PositionTitle   = sr.GetPositionTitle();
     PreparingReport = filllist;
     if (PreparingReport)
     {
     }
 }
コード例 #9
0
        public void CalcAndAdd(SalarySheetRowInfo sr, VacationCalcRow v,
                               decimal AvPayRateDay, int calcver)
        {
            v.AvPayRate = AvPayRateDay;
            v.Pay       = KlonsData.RoundA(AvPayRateDay * (decimal)v.Days, 2);
            var pcri = new CalcRInfo(false, calcver);

            pcri.CalcR(sr, v.DateStart, v.DateEnd);
            v.DNS  = KlonsData.RoundA(pcri.RateDNSN * v.Pay / 100.0M, 2);
            v.Cash = v.Pay - v.DNS;
            Add(v);
        }
コード例 #10
0
        public ErrorList SetUpFromRowA(SalarySheetRowInfo sr)
        {
            if (sr?.Row == null)
            {
                throw new Exception("Bad init.");
            }

            var error_list = new ErrorList();

            IDP         = sr.Row.IDP;
            DR_Person_r = sr.DR_Person_r;
            SalarySheet = sr.SalarySheet;
            error_list += SetUpFromRowZ();

            return(error_list);
        }
コード例 #11
0
        public void CalcAndAddNextA(SalarySheetRowInfo sr, VacationCalcRow v)
        {
            Add(v);
            VacationCalcRow vcmt = null;
            int             yrmt = v.DateStart.Year * 12 + v.DateStart.Month - 1;

            if (!PerMonth.TryGetValue(yrmt, out vcmt))
            {
                vcmt           = new VacationCalcRow();
                vcmt.DateStart = v.DateStart;
                vcmt.DateEnd   = v.DateEnd;
                //vcmt.DateStart = new DateTime(v.DateStart.Year, v.DateStart.Month, 1);
                //vcmt.DateEnd = vcmt.DateStart.LastDayOfMonth();
                PerMonth[yrmt] = vcmt;
            }
            vcmt.Add(v);
        }
コード例 #12
0
        public bool GetRow(int addmt, out SalarySheetRowInfo row)
        {
            row = null;
            var table_sar   = MyData.DataSetKlons.SALARY_SHEETS;
            var table_sar_r = MyData.DataSetKlons.SALARY_SHEETS_R;

            int yr = SalarySheet.YR;
            int mt = SalarySheet.MT;

            Utils.AddMonths(ref yr, ref mt, addmt);

            int idp  = Row.IDP;
            int idam = Row.IDAM;

            var drs = table_sar_r.WhereX(
                d =>
            {
                var dr_sar = d.SALARY_SHEETSRowByFK_SALARY_SHEETS_R_IDS;
                return
                (d.IDP == idp &&
                 d.IDAM == idam &&
                 dr_sar.YR == yr &&
                 dr_sar.MT == mt);
            }).ToArray();

            if (drs.Length == 0)
            {
                return(true);
            }
            var dr = drs[0];

            var shr = new SalarySheetRowInfo();
            var err = shr.SetUpFromRowX(dr);

            if (err != null && err.Count > 0)
            {
                return(false);
            }

            row = shr;

            return(true);
        }
コード例 #13
0
ファイル: WorkPayCalcInfo.cs プロジェクト: Camel-RD/Klons
        public ErrorList GatAvPay(SalarySheetRowInfo sr)
        {
            if (IsAvPayCalcDone)
            {
                return(new ErrorList());
            }
            AvPayCalc = new AvPayCalcInfo(PreparingReport);
            var err = AvPayCalc.CalcList(sr);

            if (err.HasErrors)
            {
                return(err);
            }
            IsAvPayCalcDone      = true;
            AvPayRateHour        = AvPayCalc.RateHour;
            AvPayRateDay         = AvPayCalc.RateDay;
            AvPayRateCalendarDay = AvPayCalc.RateCalendarDay;
            return(new ErrorList());
        }
コード例 #14
0
        public void CalcAndAddNext(SalarySheetRowInfo sr, VacationCalcRow v,
                                   decimal AvPayRateDay)
        {
            v.AvPayRate = AvPayRateDay;
            v.Pay       = KlonsData.RoundA(AvPayRateDay * (decimal)v.Days, 2);
            Add(v);
            VacationCalcRow vcmt = null;
            int             yrmt = v.DateStart.Year * 12 + v.DateStart.Month - 1;

            if (!PerMonth.TryGetValue(yrmt, out vcmt))
            {
                vcmt           = new VacationCalcRow();
                vcmt.DateStart = v.DateStart;
                vcmt.DateEnd   = v.DateEnd;
                //vcmt.DateStart = new DateTime(v.DateStart.Year, v.DateStart.Month, 1);
                //vcmt.DateEnd = vcmt.DateStart.LastDayOfMonth();
                PerMonth[yrmt] = vcmt;
            }
            vcmt.Add(v);
        }
コード例 #15
0
        private void PrepareListB(SalarySheetRowInfo sr, VacationCalcInfo totalvc)
        {
            if (totalvc.Rows.Count == 0)
            {
                return;
            }
            var rows2 = new List <VacationCalcRow>();
            var r1    = new VacationCalcRow();

            r1.Caption = "Kopā";
            rows2.Add(r1);
            rows2.AddRange(totalvc.Rows);

            rows2.Add(new VacationCalcRow());

            r1         = new VacationCalcRow();
            r1.Caption = sr.GetPositionTitle();
            rows2.Add(r1);
            rows2.AddRange(Rows);
            Rows = rows2;
        }
コード例 #16
0
        public PayFx CalcAll(SalarySheetRowInfo sr, VacationCalcRow v, int calcver)
        {
            var cri = new CalcRInfo(false, calcver);

            cri.CalcR(sr, v.DateStart, v.DateEnd);
            var pfx = new PayFx(cri);

            if (cri.UseProgresiveIINRate)
            {
                pfx.IinEx = 0.0M;
            }
            else
            {
                pfx.IinEx = cri.ExMax2.SumIINExempts();
            }
            pfx.Pay = v.Pay;
            pfx.CalcAllAndRound();
            v.DNS   = pfx.DNS;
            v.IINEX = pfx.UsedIinEx;
            v.IIN   = pfx.IIN;
            v.Cash  = pfx.Cash;
            return(pfx);
        }
コード例 #17
0
        public ErrorList CalcSickDays(SalarySheetRowInfo sr)
        {
            var err = sr.CheckLinkedRows(sr.Row.IDP);

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

            if (sr.IsSingleRow())
            {
                err = CalcSickDaysB(sr, null);
                return(err);
            }

            TotalSDCI = new SickDayCalcInfo(PreparingReport);
            err       = TotalSDCI.CalcSickDaysA(sr.SalarySheetRowSet);
            if (err.HasErrors)
            {
                return(err);
            }

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

            SetAvPayFrom(TotalSDCI);

            SickDayCalcInfo[] sdcs      = null;
            string[]          positions = null;

            if (sr.Row.XType == ESalarySheetRowType.Total)
            {
                var srs = sr.SalarySheetRowSet;

                sdcs      = new SickDayCalcInfo[srs.LinkedRows.Length];
                positions = new string[srs.LinkedRows.Length];

                for (int i = 0; i < srs.LinkedRows.Length; i++)
                {
                    var lr  = srs.LinkedRows[i];
                    var sdc = new SickDayCalcInfo(PreparingReport);
                    positions[i] = lr.GetPositionTitle();
                    sdcs[i]      = sdc;
                    sdc.SetAvPayFrom(this);

                    err = sdc.CalcSickDaysB(lr, TotalSDCI);
                    if (err.HasErrors)
                    {
                        return(err);
                    }
                }
                SumTotalPay(sdcs, TotalSDCI);
                if (PreparingReport)
                {
                    PrepareListT(sdcs, positions);
                }
            }
            else
            {
                if (PreparingReport)
                {
                    PrepareListA(sr.GetPositionTitle());
                }
                err = CalcSickDaysB(sr, TotalSDCI);
                if (err.HasErrors)
                {
                    return(err);
                }
            }

            return(new ErrorList());
        }
コード例 #18
0
ファイル: WorkPayCalcInfo.cs プロジェクト: Camel-RD/Klons
        public void CalcWorkPay(SalarySheetRowInfo sr, SalaryInfo si = null)
        {
            if (sr.Row.XType == ESalarySheetRowType.Total)
            {
                throw new Exception("Bad idea.");
            }

            var dt1 = sr.SalarySheet.DT1;
            var dt2 = sr.SalarySheet.DT2;

            if (si == null)
            {
                TotalRow = new SalaryInfo();
            }
            else
            {
                TotalRow = si;
            }

            var posR      = sr.PositionsR.FilterListWithDates(dt1, dt2);
            var amatirpay = new SalaryInfo[posR.LinkedPeriods.Count];

            TotalRow._CALENDAR_DAYS     = sr.SalarySheet.CalendarMonth.DaysInMonth;
            TotalRow._CALENDAR_DAYS_USE = sr.CountCalendarDays();

            sr.DLRows.CountPlanMonth(TotalRow, sr.SalarySheet.MDT1, sr.SalarySheet.MDT2);
            sr.DLRows.CountPlan(TotalRow, sr.SalarySheet.MDT1, sr.SalarySheet.MDT2);

            PeriodInfo amats_hf;

            if (!sr.Events.Positions.TryGetValue(sr.Row.IDAM, out amats_hf))
            {
                throw new Exception("Bad init.");
            }
            amats_hf = amats_hf.FilterListWithDates(dt1, dt2);

            for (int i = 0; i < amatirpay.Length; i++)
            {
                var ari_x = posR.LinkedPeriods[i];
                var ari_l = ari_x.FilterThisWithList(amats_hf);

                if (ari_l.LinkedPeriods.Count == 0)
                {
                    continue;
                }

                var wt = new SalaryInfo();
                amatirpay[i] = wt;

                for (int j = 0; j < ari_l.LinkedPeriods.Count; j++)
                {
                    var ari = ari_l.LinkedPeriods[j];
                    sr.DLRows.CountPlan(wt, ari.DateFirst, ari.DateLast);
                    sr.DLRows.CountFact(wt, ari.DateFirst, ari.DateLast);
                }

                var dr_amati_r = ari_x.Item1 as KlonsADataSet.POSITIONS_RRow;

                switch (dr_amati_r.XRateType)
                {
                case ESalaryType.Month:
                case ESalaryType.Day:
                    wt.GetRateDefs(dr_amati_r, TotalRow._MONTH_WORKDAYS, TotalRow._MONTH_WORKHOURS);
                    CalcPayWithDayRate(wt, dr_amati_r);
                    break;

                case ESalaryType.Hour:
                    wt.GetRateDefs(dr_amati_r, TotalRow._MONTH_WORKDAYS, TotalRow._MONTH_WORKHOURS);
                    CalcPayWithHourRate(wt, dr_amati_r);
                    break;

                case ESalaryType.Aggregated:
                    wt.GetRateDefs(dr_amati_r, TotalRow._MONTH_WORKDAYS, TotalRow._MONTH_WORKHOURS);
                    CalcPayWithoutAvPay(wt, dr_amati_r);
                    AvPayCalcRequired = true;
                    break;

                case ESalaryType.Piece:
                    CalcPayWithoutAvPay(wt, dr_amati_r);
                    AvPayCalcRequired = true;
                    break;
                }

                wt._SALARY = wt.SumSalary();

                if (PreparingReport)
                {
                    ReportRows.Add(wt);
                    var dtr1 = ari_l.LinkedPeriods[0].DateFirst;
                    var dtr2 = ari_l.LinkedPeriods[ari_l.LinkedPeriods.Count - 1].DateLast;
                    var jr   = new WorkPayCalcJoinRow();
                    jr.DateStart = dtr1;
                    jr.DateEnd   = dtr2;
                    JoinRows.Add(jr);
                }

                TotalRow.AddWorkTime(wt);
                TotalRow.AddSalary(wt);
            }

            TotalRow._SALARY_PIECEWORK = CalcPieceWorkPay(dt1, dt2, sr.Row.IDAM);

            TotalRow.PlanedWorkPay = KlonsData.RoundA(TotalRow.PlanedWorkPay, 2);

            TotalRow._SALARY_DAY                      = KlonsData.RoundA(TotalRow._SALARY_DAY, 2);
            TotalRow._SALARY_NIGHT                    = KlonsData.RoundA(TotalRow._SALARY_NIGHT, 2);
            TotalRow._SALARY_OVERTIME                 = KlonsData.RoundA(TotalRow._SALARY_OVERTIME, 2);
            TotalRow._SALARY_HOLIDAYS_DAY             = KlonsData.RoundA(TotalRow._SALARY_HOLIDAYS_DAY, 2);
            TotalRow._SALARY_HOLIDAYS_NIGHT           = KlonsData.RoundA(TotalRow._SALARY_HOLIDAYS_NIGHT, 2);
            TotalRow._SALARY_HOLIDAYS_OVERTIME        = KlonsData.RoundA(TotalRow._SALARY_HOLIDAYS_OVERTIME, 2);
            TotalRow._SALARY_AVPAY_FREE_DAYS          = KlonsData.RoundA(TotalRow._SALARY_AVPAY_FREE_DAYS, 2);
            TotalRow._SALARY_AVPAY_WORK_DAYS          = KlonsData.RoundA(TotalRow._SALARY_AVPAY_WORK_DAYS, 2);
            TotalRow._SALARY_AVPAY_WORK_DAYS_OVERTIME = KlonsData.RoundA(TotalRow._SALARY_AVPAY_WORK_DAYS_OVERTIME, 2);
            TotalRow._SALARY_AVPAY_HOLIDAYS           = KlonsData.RoundA(TotalRow._SALARY_AVPAY_HOLIDAYS, 2);
            TotalRow._SALARY_AVPAY_HOLIDAYS_OVERTIME  = KlonsData.RoundA(TotalRow._SALARY_AVPAY_HOLIDAYS_OVERTIME, 2);

            TotalRow._SALARY = TotalRow.SumSalary();
            TotalRow.SumForAvPay();

            if (PreparingReport && !AvPayCalcRequired)
            {
                PrepareList(sr.GetPositionTitle());
            }
        }
コード例 #19
0
ファイル: WorkPayCalcInfo.cs プロジェクト: Camel-RD/Klons
        public ErrorList DoAvPay(SalarySheetRowInfo sr, SalaryInfo wt, SalaryInfo totalwt = null)
        {
            var err = GatAvPay(sr);

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

            decimal _AvPayRate = AvPayRateDay;

            if (IsAggregatedTimeRate(sr))
            {
                _AvPayRate = AvPayRateCalendarDay;
            }

            if (totalwt == null)
            {
                decimal rateo  = wt.R_MT_OVERTIME / 100.0M;
                decimal rateh  = wt.R_MT_HOLIDAY / 100.0M;
                decimal rateho = wt.R_MT_HOLIDAY_OVERTIME / 100.0M;

                wt._SALARY_AVPAY_FREE_DAYS += _AvPayRate * (decimal)wt.FACT_AVPAY_FREE_DAYS_2;

                wt._SALARY_AVPAY_WORK_DAYS          += _AvPayRate * (decimal)wt.FACT_AVPAY_WORK_DAYS_2;
                wt._SALARY_AVPAY_WORK_DAYS_OVERTIME += _AvPayRate * rateo * (decimal)wt.FACT_AVPAY_HOURS_OVERTIME_2;
                wt._SALARY_AVPAY_HOLIDAYS           += _AvPayRate * rateh * (decimal)wt.FACT_AVPAY_WORKINHOLIDAYS_2;
                wt._SALARY_AVPAY_HOLIDAYS_OVERTIME  += _AvPayRate * rateho * (decimal)wt.FACT_AVPAY_HOLIDAYS_HOURS_OVERT_2;
            }
            else
            {
                if (wt.FACT_AVPAY_FREE_HOURS_2 > 0.0f)
                {
                    wt._SALARY_AVPAY_FREE_DAYS +=
                        (decimal)wt.FACT_AVPAY_FREE_HOURS_2 /
                        (decimal)totalwt.FACT_AVPAY_FREE_HOURS_2 *
                        totalwt._SALARY_AVPAY_FREE_DAYS;
                }

                if (wt.FACT_AVPAY_HOURS_2 > 0.0f)
                {
                    wt._SALARY_AVPAY_WORK_DAYS +=
                        (decimal)wt.FACT_AVPAY_HOURS_2 /
                        (decimal)totalwt.FACT_AVPAY_HOURS_2 *
                        totalwt._SALARY_AVPAY_WORK_DAYS;
                }

                if (wt.FACT_AVPAY_HOURS_OVERTIME_2 > 0.0f)
                {
                    wt._SALARY_AVPAY_WORK_DAYS_OVERTIME +=
                        (decimal)wt.FACT_AVPAY_HOURS_OVERTIME_2 /
                        (decimal)totalwt.FACT_AVPAY_HOURS_OVERTIME_2 *
                        totalwt._SALARY_AVPAY_WORK_DAYS_OVERTIME;
                }

                if (wt.FACT_AVPAY_HOLIDAYS_HOURS_2 > 0.0f)
                {
                    wt._SALARY_AVPAY_HOLIDAYS +=
                        (decimal)wt.FACT_AVPAY_HOLIDAYS_HOURS_2 /
                        (decimal)totalwt.FACT_AVPAY_HOLIDAYS_HOURS_2 *
                        totalwt._SALARY_AVPAY_HOLIDAYS;
                }

                if (wt.FACT_AVPAY_HOLIDAYS_HOURS_OVERT_2 > 0.0f)
                {
                    wt._SALARY_AVPAY_HOLIDAYS_OVERTIME +=
                        (decimal)wt.FACT_AVPAY_HOLIDAYS_HOURS_OVERT_2 /
                        (decimal)totalwt.FACT_AVPAY_HOLIDAYS_HOURS_OVERT_2 *
                        totalwt._SALARY_AVPAY_HOLIDAYS_OVERTIME;
                }
            }

            wt._SALARY_AVPAY_FREE_DAYS          = KlonsData.RoundA(wt._SALARY_AVPAY_FREE_DAYS, 2);
            wt._SALARY_AVPAY_WORK_DAYS          = KlonsData.RoundA(wt._SALARY_AVPAY_WORK_DAYS, 2);
            wt._SALARY_AVPAY_WORK_DAYS_OVERTIME = KlonsData.RoundA(wt._SALARY_AVPAY_WORK_DAYS_OVERTIME, 2);
            wt._SALARY_AVPAY_HOLIDAYS           = KlonsData.RoundA(wt._SALARY_AVPAY_HOLIDAYS, 2);
            wt._SALARY_AVPAY_HOLIDAYS_OVERTIME  = KlonsData.RoundA(wt._SALARY_AVPAY_HOLIDAYS_OVERTIME, 2);

            wt._SALARY = wt.SumSalary();
            return(err);
        }
コード例 #20
0
ファイル: WorkPayCalcInfo.cs プロジェクト: Camel-RD/Klons
        public bool IsAggregatedTimeRate(SalarySheetRowInfo sr)
        {
            var posr = sr.PositionsR.LinkedPeriods[0].Item1 as KlonsADataSet.POSITIONS_RRow;

            return(posr.XRateType == ESalaryType.Aggregated);
        }
コード例 #21
0
        public ErrorList CalcVacationDays2(SalarySheetRowInfo srs, VacationCalcInfo[] vcs, int calcver)
        {
            var error_list = new ErrorList();

            if (vcs != null && srs != srs?.SalarySheetRowSet?.TotalRow)
            {
                throw new ArgumentException("Bad call.");
            }

            var dt1  = srs.SalarySheet.DT1;
            var dt2  = srs.SalarySheet.DT2;
            var mdt1 = srs.SalarySheet.MDT1;
            var mdt2 = srs.SalarySheet.MDT2;

            var ps = srs.Events.Vacations.LinkedPeriods.Where(
                d =>
            {
                if (!SomeDataDefs.IsEventPaidVacation(d.EEventId))
                {
                    return(false);
                }

                var dr_not = (d.Item1 as KlonsADataSet.EVENTSRow);
                if (dr_not.IsDATE3Null())
                {
                    return(false);
                }

                return((d.DateFirst <= dt2 && d.DateLast >= dt1) ||
                       (dr_not.DATE3 >= dt1 && dr_not.DATE3 <= dt2));
            }).ToArray();


            // kompensācija atlaižot
            var fire_evs = srs.Events.HireFire.LinkedPeriods
                           .Where(d => d.DateLast >= dt1 && d.DateLast <= dt2)
                           .ToArray();

            if (ps.Length == 0 && fire_evs.Length == 0)
            {
                return(error_list);
            }

            var ps_cur = ps.Where(
                d =>
                d.DateFirst <= dt2 && d.DateLast >= dt1
                ).ToArray();

            var ps_next = ps.Where(
                d =>
            {
                var dr_not = (d.Item1 as KlonsADataSet.EVENTSRow);
                if (dr_not.IsDATE3Null())
                {
                    return(false);
                }
                return((d.DateLast > dt2) &&
                       (dr_not.DATE3 >= dt1 && dr_not.DATE3 <= dt2));
            }).ToArray();

            var ps_prev = ps_cur.Where(
                d =>
            {
                var dr_not = (d.Item1 as KlonsADataSet.EVENTSRow);
                if (dr_not.IsDATE3Null())
                {
                    return(false);
                }
                return(dr_not.DATE3 < dt1);
            }).ToArray();



            SalaryInfo prevsi = srs.GetPrevRow();

            if (prevsi != null)
            {
                VcrPrev.Pay = prevsi._VACATION_PAY_NEXT;
                VcrPrev.DNS = prevsi._VACATION_DNS_NEXT;
                VcrPrev.IIN = prevsi._VACATION_IIN_NEXT;
                AdvancePrev = prevsi._VACATION_ADVANCE_NEXT;

                if (vcs != null)
                {
                    for (int i = 0; i < vcs.Length; i++)
                    {
                        var vci = vcs[i];
                        if (vci == null)
                        {
                            continue;
                        }
                        var sr      = srs.SalarySheetRowSet.LinkedRows[i];
                        var prevsi2 = sr.GetPrevRow();
                        if (prevsi2 == null)
                        {
                            continue;
                        }
                        vci.VcrPrev.Pay = prevsi._VACATION_PAY_NEXT;
                        vci.VcrPrev.DNS = prevsi._VACATION_DNS_NEXT;
                        vci.VcrPrev.IIN = prevsi._VACATION_IIN_NEXT;
                        vci.AdvancePrev = prevsi._VACATION_ADVANCE_NEXT;
                    }
                }
            }

            error_list += GetAvPayCalc(srs);
            if (error_list.HasErrors)
            {
                return(error_list);
            }

            float               caldays   = 0;
            VacationCalcRow     vt        = new VacationCalcRow();
            VacationCalcRow     v         = new VacationCalcRow();
            TimeSheetRowSetList dlrowsetT = null;
            TimeSheetRowSet     dlrowset  = null;
            decimal             r         = 0.0M;

            decimal _AvPayRate = AvPayRateDay;

            if (IsAggregatedTimeRate(srs))
            {
                _AvPayRate = AvPayRateCalendarDay;
            }
            vt.AvPayRate = _AvPayRate;

            caldays = 0;
            foreach (var pi in ps_prev)
            {
                vt.DateStart = pi.DateFirst;
                vt.DateEnd   = pi.DateLast;
                if (vt.DateStart < dt1)
                {
                    vt.DateStart = dt1;
                }
                if (vt.DateEnd > dt2)
                {
                    vt.DateEnd = dt2;
                }

                if (dlrowsetT == null)
                {
                    dlrowsetT = srs.GetDLRowSetList();
                }
                dlrowsetT.CountVacationTime(vt);
                caldays += (vt.DateEnd - vt.DateStart).Days + 1;
                VcrPrevCurrent.CalcAndAdd(srs, vt, _AvPayRate, CalcVer);

                if (PreparingReport)
                {
                    AddRepRow(vt, "A", "Kopā");
                }

                if (vcs != null)
                {
                    v.DateStart = vt.DateStart;
                    v.DateEnd   = vt.DateEnd;

                    int ct = vcs.Where(d => d != null).Count();

                    for (int i = 0; i < vcs.Length; i++)
                    {
                        var vci = vcs[i];
                        if (vci == null)
                        {
                            continue;
                        }
                        var sr = srs.SalarySheetRowSet.LinkedRows[i];
                        dlrowset = dlrowsetT[i];
                        dlrowset.CountVacationTime(v);

                        if (vt.Hours == 0.0f)
                        {
                            r = 1.0M / (decimal)ct;
                        }
                        else
                        {
                            r = (decimal)(v.Hours / vt.Hours);
                        }

                        v.Pay = KlonsData.RoundA(vt.Pay * r, 2);
                        vci.VcrPrevCurrent.CalcAndAddSplit(sr, v, CalcVer);

                        if (PreparingReport)
                        {
                            vci.AddRepRow(vt, "A", sr.GetPositionTitle());
                        }
                    }
                }
            }

            caldays = 0;
            foreach (var pi in ps_cur)
            {
                vt.DateStart = pi.DateFirst;
                vt.DateEnd   = pi.DateLast;
                if (vt.DateStart < dt1)
                {
                    vt.DateStart = dt1;
                }
                if (vt.DateEnd > dt2)
                {
                    vt.DateEnd = dt2;
                }

                if (dlrowsetT == null)
                {
                    dlrowsetT = srs.GetDLRowSetList();
                }
                dlrowsetT.CountVacationTime(vt);
                caldays += (vt.DateEnd - vt.DateStart).Days + 1;
                VcrCurrent.CalcAndAdd(srs, vt, _AvPayRate, CalcVer);

                if (PreparingReport)
                {
                    AddRepRow(vt, "B", "Kopā");
                }

                if (vcs != null)
                {
                    v.DateStart = vt.DateStart;
                    v.DateEnd   = vt.DateEnd;

                    int ct = vcs.Where(d => d != null).Count();

                    for (int i = 0; i < vcs.Length; i++)
                    {
                        var vci = vcs[i];
                        if (vci == null)
                        {
                            continue;
                        }
                        var sr = srs.SalarySheetRowSet.LinkedRows[i];

                        dlrowset = dlrowsetT[i];
                        dlrowset.CountVacationTime(v);

                        if (vt.Hours == 0.0f)
                        {
                            r = 1.0M / (decimal)ct;
                        }
                        else
                        {
                            r = (decimal)(v.Hours / vt.Hours);
                        }

                        v.Pay = KlonsData.RoundA(vt.Pay * r, 2);
                    }

                    Utils.MakeExactSum(vt.Pay, vcs,
                                       d => d.VcrCurrent.Pay,
                                       (d, val) => d.VcrCurrent.Pay = val);

                    for (int i = 0; i < vcs.Length; i++)
                    {
                        var vci = vcs[i];
                        if (vci == null)
                        {
                            continue;
                        }
                        var sr = srs.SalarySheetRowSet.LinkedRows[i];
                        vci.VcrCurrent.CalcAndAddSplit(sr, v, CalcVer);
                        if (PreparingReport)
                        {
                            vci.AddRepRow(vt, "B", sr.GetPositionTitle());
                        }
                    }
                }
            }

            foreach (var pi in ps_next)
            {
                vt.DateStart = dt2.AddDays(1);
                vt.DateEnd   = pi.DateLast;
                if (vt.DateStart < pi.DateFirst)
                {
                    vt.DateStart = pi.DateFirst;
                }
                var dtpe = vt.DateStart.LastDayOfMonth();
                if (vt.DateEnd > dtpe)
                {
                    vt.DateEnd = dtpe;
                }

                while (true)
                {
                    int addmt = Utils.MonthDiff(dt1, vt.DateStart);

                    var nextdlrowsetT = srs.GetDLRowSetList(addmt);
                    if (nextdlrowsetT.Count == 0)
                    {
                        break;
                    }

                    nextdlrowsetT.CountVacationTime(vt);
                    caldays += (vt.DateEnd - vt.DateStart).Days + 1;
                    VcrNext.CalcAndAddNext(srs, vt, _AvPayRate);

                    if (PreparingReport)
                    {
                        AddRepRow(vt, "C", "Kopā");
                    }


                    if (vcs != null)
                    {
                        v.DateStart = vt.DateStart;
                        v.DateEnd   = vt.DateEnd;

                        int ct = vcs.Where(d => d != null).Count();

                        for (int i = 0; i < vcs.Length; i++)
                        {
                            var vci = vcs[i];
                            if (vci == null)
                            {
                                continue;
                            }
                            var sr = srs.SalarySheetRowSet.LinkedRows[i];

                            var nextdlrowset = nextdlrowsetT[i];
                            if (nextdlrowset == null)
                            {
                                //error_list.AddPersonError(srs.DR_Person_r.ID, )
                            }
                            nextdlrowset.CountVacationTime(v);

                            if (vt.Hours == 0.0f)
                            {
                                r = 1.0M / (decimal)ct;
                            }
                            else
                            {
                                r = (decimal)(v.Hours / vt.Hours);
                            }

                            v.Pay = KlonsData.RoundA(vt.Pay * r, 2);
                        }

                        Utils.MakeExactSum(vt.Pay, vcs,
                                           d => d.VcrNext.Pay,
                                           (d, val) => d.VcrNext.Pay = val);

                        for (int i = 0; i < vcs.Length; i++)
                        {
                            var vci = vcs[i];
                            if (vci == null)
                            {
                                continue;
                            }
                            var sr = srs.SalarySheetRowSet.LinkedRows[i];
                            vci.VcrNext.CalcAndAddNextA(sr, v);
                            if (PreparingReport)
                            {
                                vci.AddRepRow(vt, "C", sr.GetPositionTitle());
                            }
                        }
                    }

                    if (vt.DateEnd == pi.DateLast)
                    {
                        break;
                    }
                    vt.DateStart = dtpe.AddDays(1);
                    vt.DateEnd   = pi.DateLast;
                    dtpe         = dtpe.AddDays(1).LastDayOfMonth();
                    if (vt.DateEnd > dtpe)
                    {
                        vt.DateEnd = dtpe;
                    }
                }
            }

            // kompensācija atlaižot
            vt.Days = 0;
            foreach (var fe in fire_evs)
            {
                var dr_ev = fe.Item2 as KlonsADataSet.EVENTSRow;
                if (dr_ev == null)
                {
                    continue;
                }
                if (calcver == KlonsData.VersionRef(0))
                {
                    vt.Days += dr_ev.DAYS;
                }
                else
                {
                    vt.Days += dr_ev.DAYS2;
                }
            }
            if (vt.Days > 0)
            {
                error_list += GetAvPayCalc(srs);
                if (error_list.HasErrors)
                {
                    return(error_list);
                }

                vt.DateStart = srs.SalarySheet.DT1;
                vt.DateEnd   = srs.SalarySheet.DT2;
                caldays      = vt.Days;
                vt.Hours     = 0.0f;

                VcrCompensation.CalcAndAdd(srs, vt, AvPayRateCalendarDay, CalcVer);

                if (PreparingReport)
                {
                    AddRepRow(vt, "D", "Kopā");
                }

                if (vcs != null)
                {
                    v.DateStart = vt.DateStart;
                    v.DateEnd   = vt.DateEnd;
                    v.Days      = vt.Days;
                    v.Hours     = 0.0f;

                    int ct = vcs.Where(d => d != null).Count();

                    for (int i = 0; i < vcs.Length; i++)
                    {
                        var vci = vcs[i];
                        if (vci == null)
                        {
                            continue;
                        }
                        var sr = srs.SalarySheetRowSet.LinkedRows[i];

                        r     = 1.0M / (decimal)ct;
                        v.Pay = KlonsData.RoundA(vt.Pay * r, 2);
                    }

                    Utils.MakeExactSum(vt.Pay, vcs,
                                       d => d.VcrCompensation.Pay,
                                       (d, val) => d.VcrCompensation.Pay = val);

                    for (int i = 0; i < vcs.Length; i++)
                    {
                        var vci = vcs[i];
                        if (vci == null)
                        {
                            continue;
                        }
                        var sr = srs.SalarySheetRowSet.LinkedRows[i];
                        vci.VcrCompensation.CalcAndAddSplit(sr, v, CalcVer);
                        if (PreparingReport)
                        {
                            vci.AddRepRow(vt, "D", sr.GetPositionTitle());
                        }
                    }
                }
            }

            VcrNext.CalcAll(srs, vcs, CalcVer);

            if (PreparingReport)
            {
                PrepareRows();
            }
            return(error_list);
        }
コード例 #22
0
        public void CalcAll(SalarySheetRowInfo sr, VacationCalcInfo[] vcs, int calcver)
        {
            Days  = 0.0f;
            Hours = 0.0f;
            Pay   = 0.0M;
            DNS   = 0.0M;
            IINEX = 0.0M;
            IIN   = 0.0M;
            Cash  = 0.0M;

            foreach (var v in PerMonth)
            {
                CalcAll(sr, v.Value, calcver);
                Add(v.Value);
            }

            if (vcs == null)
            {
                return;
            }


            var pfx = new PayFx();

            pfx.Pay       = Pay;
            pfx.DNS       = DNS;
            pfx.UsedIinEx = IINEX;
            pfx.IIN       = IIN;
            pfx.Cash      = Cash;

            var vcrms = new VacationCalcRow[vcs.Length];
            var pfxs  = new PayFx[vcs.Length];

            for (int i = 0; i < vcs.Length; i++)
            {
                var vci = vcs[i];
                if (vci == null)
                {
                    continue;
                }
                var vcri = vci.VcrCompensation;
                vcrms[i] = vcri;
                var pfx1 = new PayFx();
                pfx1.Pay = vcri.Pay;
                pfxs[i]  = pfx1;
            }

            PayFx.SplitAndRound(pfx, pfxs);

            for (int i = 0; i < vcs.Length; i++)
            {
                var vci = vcs[i];
                if (vci == null)
                {
                    continue;
                }
                var vcrm = vcrms[i];
                var pfx1 = pfxs[i];
                vcrm.DNS   = pfx1.DNS;
                vcrm.IINEX = pfx1.UsedIinEx;
                vcrm.IIN   = pfx1.IIN;
                vcrm.Cash  = pfx1.Cash;
            }
        }
コード例 #23
0
ファイル: CalcRInfo.cs プロジェクト: Camel-RD/Klons
        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);
            }
        }
コード例 #24
0
        public static ReportViewerData MakeReportData(KlonsADataSet.SALARY_SHEETS_RRow dr_lapas_r)
        {
            var sr  = new SalarySheetRowInfo();
            var err = sr.SetUpFromRowX(dr_lapas_r);

            if (err.HasErrors)
            {
                Form_ErrorList.ShowErrorList(MyData.MyMainForm, err);
                return(null);
            }
            sr.CheckLinkedRows(dr_lapas_r.IDP);

            var sc = new SalaryCalcTInfo(sr.SalarySheetRowSet, new SalaryInfo(), true);

            err = sc.FillRow();
            if (err.HasErrors)
            {
                Form_ErrorList.ShowErrorList(MyData.MyMainForm, err);
                return(null);
            }

            var person = string.Format("{0} {1}, {2}", sr.DR_Person_r.FNAME,
                                       sr.DR_Person_r.LNAME, sr.GetPositionTitle().Nz().ToLower());
            var period = string.Format("{0:dd.MM.yyyy} - {1:dd.MM.yyyy}",
                                       sr.SalarySheet.DT1, sr.SalarySheet.DT2);

            ReportViewerData rd = new ReportViewerData();

            rd.FileName = "ReportA_AprIzklasts_1";
            if (sr.IsSingleRow())
            {
                var sc0 = sc.LinkedSCI[0];
                sc0.CheckBeforeReport();

                sc0.AvPayCalc.SetCurMonthPay(sr.SalarySheet.YR, sr.SalarySheet.MT, sc.TotalSI._TOTAL_BEFORE_TAXES, sc.TotalSI._PAY);

                rd.Sources["dsSickPay"]     = sc0.SickDayCalc?.Rows;
                rd.Sources["dsAvPay"]       = sc0.AvPayCalc.ReportRows;
                rd.Sources["dsWorkPay"]     = sc0.WorkPayCalc.GetRows2();
                rd.Sources["dsVacationPay"] = sc0.VacationCalc.Rows;
                rd.Sources["dsCalcR"]       = sc0.CalcR.ReportRows;
                rd.Sources["dsBonus"]       = sc0.BonusCalc.ReportRows;
                rd.Sources["dsSalary"]      = sc0.MakeReport1();
                rd.AddReportParameters(new string[]
                {
                    "CompanyName", MyData.Params.CompNameX,
                    "RPerson", person,
                    "RPeriod", period,
                    "RSickPay", sc0.SickDayCalc.TotalRow.SickDayPay.ToString("N2"),
                    "RSickPay75", sc0.SickDayCalc.TotalRow.SickDayPay75.ToString("N2"),
                    "RSickPay80", sc0.SickDayCalc.TotalRow.SickDayPay80.ToString("N2"),
                    "RAvPayHour", sc0.AvPayCalc.RateHour.ToString("N4"),
                    "RAvPayDay", sc0.AvPayCalc.RateDay.ToString("N4"),
                    "RAvPayCalDay", sc0.AvPayCalc.RateCalendarDay.ToString("N4"),
                    "RAvPayRemark", sc0.AvPayCalc.UsingMinRate?"Izmantotas minimālās likmes.": "",
                    "RPosTitle0", sc0.SR.GetPositionTitle(),
                    "RPosTitle1", null,
                    "RPosTitle2", null,
                    "RPosTitle3", null,
                    "RPosTitle4", null,
                    "RIsAvPayUsed", sc0.SI.IsAvPayUsed().ToString()
                });
            }
            else
            {
                var rep = sc.MakeReport1();
                sc.CheckBeforeReport();

                sc.AvPayCalc.SetCurMonthPay(sr.SalarySheet.YR, sr.SalarySheet.MT, sc.TotalSI._TOTAL_BEFORE_TAXES, sc.TotalSI._PAY);

                rd.Sources["dsSickPay"]     = sc.SickDayCalc.Rows;
                rd.Sources["dsAvPay"]       = sc.AvPayCalc.ReportRows;
                rd.Sources["dsWorkPay"]     = sc.WorkPayCalc.GetRows2();
                rd.Sources["dsVacationPay"] = sc.VacationCalc.Rows;
                rd.Sources["dsCalcR"]       = sc.CalcR.ReportRows;
                rd.Sources["dsBonus"]       = sc.BonusCalc.ReportRows;
                rd.Sources["dsSalary"]      = rep.GetGoodRows();
                rd.AddReportParameters(new string[]
                {
                    "CompanyName", MyData.Params.CompNameX,
                    "RPerson", person,
                    "RPeriod", period,
                    "RSickPay", sc.SickDayCalc.TotalRow.SickDayPay.ToString("N2"),
                    "RSickPay75", sc.SickDayCalc.TotalRow.SickDayPay75.ToString("N2"),
                    "RSickPay80", sc.SickDayCalc.TotalRow.SickDayPay80.ToString("N2"),
                    "RAvPayHour", sc.AvPayCalc.RateHour.ToString("N4"),
                    "RAvPayDay", sc.AvPayCalc.RateDay.ToString("N4"),
                    "RAvPayCalDay", sc.AvPayCalc.RateCalendarDay.ToString("N4"),
                    "RAvPayRemark", sc.AvPayCalc.UsingMinRate?"Izmantotas minimālās likmes.": "",
                    "RPosTitle0", rep.Titles[0],
                    "RPosTitle1", rep.Titles[1],
                    "RPosTitle2", rep.Titles[2],
                    "RPosTitle3", rep.Titles[3],
                    "RPosTitle4", rep.Titles[4],
                    "RIsAvPayUsed", sc.TotalSI.IsAvPayUsed().ToString()
                });
            }
            return(rd);
        }
コード例 #25
0
        private ErrorList SetUpFromRowZ(SalarySheetRowInfo sr = null)
        {
            if ((sr != null && sr.Row == null) || DR_Person_r == null || SalarySheet == null)
            {
                throw new Exception("Bad init.");
            }

            var       error_list = new ErrorList();
            ErrorList err;

            TotalRow   = null;
            LinkedRows = new SalarySheetRowInfo[0];

            CheckLinkedRows(IDP);

            if (DrTotalRow == null || DrLinkedRows.Length == 0)
            {
                return(error_list);
            }

            LinkedRows = new SalarySheetRowInfo[DrLinkedRows.Length];

            var error_source = string.Format("{0} {1} ({2}-{3})",
                                             DR_Person_r.FNAME,
                                             DR_Person_r.LNAME,
                                             SalarySheet.CalendarMonth.Year,
                                             SalarySheet.CalendarMonth.Month);

            GetEventList(error_list, IDP);

            if (error_list.Count > 0)
            {
                return(error_list);
            }

            for (int i = 0; i < DrLinkedRows.Length; i++)
            {
                var dr = DrLinkedRows[i];
                if (dr == sr?.Row)
                {
                    LinkedRows[i]        = sr;
                    sr.SalarySheetRowSet = this;
                    sr.Events            = Events;
                    continue;
                }
                var lr = new SalarySheetRowInfo(SalarySheet, dr);
                LinkedRows[i]        = lr;
                lr.SalarySheetRowSet = this;
                lr.Events            = Events;
                err         = lr.SetUpFromRow(dr);
                error_list += err;
            }

            if (IsSingleRow())
            {
                TotalRow = LinkedRows[0];
            }
            else
            {
                if (DrTotalRow == sr?.Row)
                {
                    TotalRow = sr;
                    TotalRow.SalarySheetRowSet = this;
                }
                else
                {
                    TotalRow = new SalarySheetRowInfo(SalarySheet, DrTotalRow);
                    TotalRow.SalarySheetRowSet = this;
                    TotalRow.Events            = Events;
                    error_list += TotalRow.SetUpT(IDP);
                }
            }

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

            if (TotalRow?.TotalPositionPay != null)
            {
                TotalPersonPay = TotalRow.TotalPositionPay;
            }

            if (error_list.HasErrors)
            {
                LinkedRows = null;
                return(error_list);
            }

            return(error_list);
        }
コード例 #26
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());
        }