Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        public List <SalaryCalcRow> MakeReport1()
        {
            var rep = new Report_SalaryCalc1();

            rep.Titles[0] = SR.GetPositionTitle();
            rep.MakeReport1(SI);
            return(rep.Rows);
        }
Ejemplo n.º 3
0
 public SalaryCalcInfo(SalarySheetRowInfo sr, SalaryInfo si, bool filllist)
 {
     SR              = sr;
     SI              = si;
     PositionTitle   = sr.GetPositionTitle();
     PreparingReport = filllist;
     if (PreparingReport)
     {
     }
 }
Ejemplo n.º 4
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;
        }
Ejemplo n.º 5
0
        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());
            }
        }
Ejemplo n.º 6
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());
        }
Ejemplo n.º 7
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);
        }