示例#1
0
        public ErrorList SetUpFromRowX(KlonsADataSet.SALARY_SHEETS_RRow dr_r)
        {
            Row = dr_r;
            var dr_sar = dr_r.SALARY_SHEETSRowByFK_SALARY_SHEETS_R_IDS;
            var ssh    = new SalarySheetInfo(dr_sar);

            SalarySheet = ssh;
            var er = ssh.SetUpLightFromSarRow(dr_sar);

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

            if (dr_r.XType == ESalarySheetRowType.Total)
            {
                return(SetUpT(dr_r.IDP));
            }

            if (dr_r.IsIDAMNull())
            {
                throw new Exception("Bad row.");
            }

            return(SetUp(dr_r.IDP, dr_r.IDAM));
        }
示例#2
0
 public SalarySheetInfo(SalarySheetInfo si)
 {
     YR            = si.YR;
     MT            = si.MT;
     MDT1          = si.MDT1;
     MDT2          = si.MDT2;
     DT1           = MDT1;
     DT2           = MDT2;
     CalendarMonth = si.CalendarMonth;
 }
示例#3
0
        public ErrorList SetUpFromRowX(KlonsADataSet.SALARY_SHEETS_RRow dr_r)
        {
            var dr_sar1 = dr_r.SALARY_SHEETSRowByFK_SALARY_SHEETS_R_IDS;
            var ssh     = new SalarySheetInfo(dr_sar1);
            var er      = ssh.SetUpLightFromSarRow(dr_sar1);

            if (er != "OK")
            {
                return(new ErrorList("", er));
            }
            return(SetUpFromRowB(ssh, dr_r.IDP));
        }
示例#4
0
        public ErrorList SetUpFromRowB(SalarySheetInfo sh, int idp)
        {
            var error_list = new ErrorList();

            SalarySheet = sh;

            if (!GetPersonRow(error_list, idp, SalarySheet))
            {
                return(error_list);
            }

            error_list += SetUpFromRowZ();

            return(error_list);
        }
示例#5
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);
        }
示例#6
0
        public static List <SalaryRepRow2> MakeReport2(SalarySheetInfo sh)
        {
            var ret = new List <SalaryRepRow2>();
            var drs = sh.DR_algas_lapa.KIND == 1 ?
                      sh.DR_algas_lapa.GetSALARY_SHEETS_RRowsByFK_SALARY_SHEETS_R_IDST().OrderBy(d => d.SNR) :
                      sh.DR_algas_lapa.GetSALARY_SHEETS_RRowsByFK_SALARY_SHEETS_R_IDS().OrderBy(d => d.SNR);
            var drsa = drs.ToArray();

            for (int i = 0; i < drsa.Length; i++)
            {
                var dr = drsa[i];
                var si = new SalaryInfo();
                si.SetFromRow(dr);
                var reprow = new SalaryRepRow2();
                reprow.SetFrom(si);
                reprow.SNR = i + 1;
                ret.Add(reprow);
            }
            return(ret);
        }
示例#7
0
        public static void MakeReport(KlonsADataSet.SALARY_SHEETSRow dr_algas_lapa, ERepType tp)
        {
            var sh = new SalarySheetInfo(dr_algas_lapa);
            var er = sh.SetUpLightFromSarRow(dr_algas_lapa);

            if (er != "OK")
            {
                MyData.MyMainForm.ShowWarning(er);
                return;
            }
            var rep = Report_Salary2.MakeReport2(sh);

            if (rep.Count == 0)
            {
                return;
            }

            var period = MakePeriodString(sh.DT1, sh.DT2);

            ReportViewerData rd = new ReportViewerData();

            if (tp == ERepType.WithPosNoSign)
            {
                rd.FileName = "ReportA_AlgasLapa_1";
            }
            else
            {
                rd.FileName = "ReportA_AlgasLapa_2";
            }
            rd.Sources["dsSalaryReport"] = rep;
            rd.AddReportParameters(new string[]
            {
                "CompanyName", MyData.Params.CompNameX,
                "RNr", dr_algas_lapa.SNR.ToString(),
                "RPerson", "",
                "RPeriod", period,
                "RRemark", "",
            });
            MyData.MyMainForm.ShowReport(rd);
        }
示例#8
0
        public bool GetPersonRow(ErrorList err, int idp, SalarySheetInfo sh)
        {
            var table_persons = MyData.DataSetKlons.PERSONS;

            IDP = idp;
            var dr_person = table_persons.FindByID(idp);

            if (dr_person == null)
            {
                var es = string.Format("{0} ({1}-{2})",
                                       IDP,
                                       sh.CalendarMonth.Year,
                                       sh.CalendarMonth.Month);
                err.AddError(es, "Nav darbinieka");
                return(false);
            }

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

            var dt2 = sh.MDT2;

            DR_Person_r = PeriodInfo.FindNearestBefore(drs_persons_r,
                                                       dt2, d => d.EDIT_DATE);

            if (DR_Person_r == null)
            {
                var es = string.Format("{0} {1} ({2}-{3})",
                                       dr_person.FNAME,
                                       dr_person.LNAME,
                                       sh.CalendarMonth.Year,
                                       sh.CalendarMonth.Month);
                err.AddError(es, "Norādītajam periodam nav ievadīti darbinieka dati.");
                return(false);
            }
            return(true);
        }
示例#9
0
 public KlonsADataSet.SALARY_SHEETSRow MakeTotalsSheet()
 {
     return(SalarySheetInfo.MakeTotalsSheet(DT1, DT2));
 }
示例#10
0
 public KlonsADataSet.SALARY_SHEETSRow FindTotalListForPeriod()
 {
     return(SalarySheetInfo.FindTotalListForPeriod(DT1, DT2));
 }
示例#11
0
 public SalarySheetRowInfo(SalarySheetInfo salarySheet, KlonsADataSet.SALARY_SHEETS_RRow dr_r)
 {
     SalarySheet = salarySheet;
     Row         = dr_r;
 }
示例#12
0
 public SalarySheetRowInfo(SalarySheetInfo salarySheet)
 {
     SalarySheet = salarySheet;
 }
示例#13
0
        public ErrorList CalcList(SalarySheetInfo sh, int idp, SalaryInfo si)
        {
            var err_list = new ErrorList();

            var dt1  = sh.MDT1;
            var dt1a = sh.MDT1.AddMonths(-1);
            var dt2  = sh.MDT1.AddMonths(-5);
            var dt3  = sh.MDT1.AddMonths(-11);
            int yr1  = sh.CalendarMonth.Year;
            int mt1  = sh.CalendarMonth.Month;
            int yr1a = yr1;
            int mt1a = mt1;

            Utils.AddMonths(ref yr1a, ref mt1a, -1);
            int yr2 = dt2.Year;
            int mt2 = dt2.Month;
            int yr3 = dt3.Year;
            int mt3 = dt3.Month;

            if (PreparingReport)
            {
                this.Year  = yr1;
                this.Month = mt1;
                this.FName = si._FNAME;
                this.LName = si._LNAME;
            }

            var table = MyData.DataSetKlonsRep.AVPAYCALC;
            var ad    = new KlonsA.DataSets.KlonsARepDataSetTableAdapters.AVPAYCALCTableAdapter();

            table.Clear();
            ad.FillBy_SP_AVPAYCALC_01(table, idp, yr3, mt3, yr1a, mt1a);

            int k1 = yr1 * 12 + mt1 - 1;
            int k2 = yr2 * 12 + mt2 - 1;
            int k3 = yr3 * 12 + mt3 - 1;

            decimal sbruto    = 0.0M;
            decimal sbruto2   = 0.0M;
            int     sdays     = 0;
            int     splandays = 0;
            float   shours    = 0.0f;

            bool backto12 = false;

            var drs_m = table.WhereX(
                d =>
            {
                int k = (d.YR * 12 + d.MT - 1);
                return(k >= k2 && k < k1);
            }).ToArray();

            foreach (var dr in drs_m)
            {
                sbruto    += dr.FORAVPAYCALC_BRUTO;
                sbruto2   += dr.TOTAL_BEFORE_TAXES;
                sdays     += dr.FORAVPAYCALC_DAYS;
                splandays += dr.PLAN_WORKDAYS;
                shours    += dr.FORAVPAYCALC_HOURS;
            }

            sbruto += si._FORAVPAYCALC_BRUTO;
            //jo aprēķina laikā kopējā bruto alga nav zināma
            if (sh.YR > 2022 || sh.YR == 2022 && sh.MT > 2)
            {
                sbruto2 += si._FORAVPAYCALC_BRUTO;
            }
            else
            {
                sbruto2 += si._TOTAL_BEFORE_TAXES;
            }
            sdays     += si._FORAVPAYCALC_DAYS;
            splandays += si._PLAN_WORK_DAYS;
            shours    += si._FORAVPAYCALC_HOURS;

            if (sdays == 0 || shours == 0.0f || sbruto2 == 0.0M)
            {
                backto12 = true;

                drs_m = table.WhereX(
                    d =>
                {
                    int k = (d.YR * 12 + d.MT - 1);
                    return(d.XType != ESalarySheetRowType.OneOfMany && k >= k3 && k < k2);
                }).ToArray();

                sbruto    = 0.0M;
                sbruto2   = 0.0M;
                sdays     = 0;
                splandays = 0;
                shours    = 0.0f;

                foreach (var dr in drs_m)
                {
                    sbruto    += dr.FORAVPAYCALC_BRUTO;
                    sbruto2   += dr.TOTAL_BEFORE_TAXES;
                    sdays     += dr.FORAVPAYCALC_DAYS;
                    splandays += dr.PLAN_WORKDAYS;
                    shours    += dr.FORAVPAYCALC_HOURS;
                }
            }

            if (sdays == 0 || shours == 0.0f || sbruto2 == 0.0M)
            {
                UsingMinRate    = true;
                RateHour        = sh.DR_Likmes.MIN_PAY_HOUR;
                RateDay         = RateHour * 8;
                RateCalendarDay = sh.DR_Likmes.MIN_PAY_MONTH / 30.42M;
            }
            else
            {
                UsingMinRate    = false;
                RateHour        = KlonsData.RoundA(sbruto / (decimal)shours, 4);
                RateDay         = KlonsData.RoundA(sbruto / (decimal)sdays, 4);
                RateCalendarDay = KlonsData.RoundA(sbruto / (decimal)splandays, 4);

                if (PreparingReport)
                {
                    var drl = ReportRows[5];
                    if (!backto12)
                    {
                        drl.Year           = yr1;
                        drl.Month          = mt1;
                        drl.CalendarDays   = si._CALENDAR_DAYS_USE;
                        drl.DaysPlan       = si._PLAN_DAYS;
                        drl.WorkDaysPlan   = si._PLAN_WORK_DAYS;
                        drl.MonthWorkDays  = si._MONTH_WORKDAYS;
                        drl.MonthWorkHours = si._MONTH_WORKHOURS;
                        drl.DaysFact       = si._FORAVPAYCALC_DAYS;
                        drl.HoursPlan      = si._PLAN_HOURS;
                        drl.WorkHoursPlan  = si._PLAN_WORK_HOURS;
                        drl.HoursFact      = si._FORAVPAYCALC_HOURS;
                        drl.Salary         = si._FORAVPAYCALC_BRUTO;
                        drl.Salary2        = si._TOTAL_BEFORE_TAXES;
                        drl.Pay            = si._FORAVPAYCALC_PAYOUT;
                        drl.Caption        = string.Format("{0}. {1} {2:00}", drl.SNR, drl.Year, drl.Month);
                    }

                    for (int i = 0; i < drs_m.Length; i++)
                    {
                        var dr  = drs_m[drs_m.Length - i - 1];
                        var snr = (dr.YR * 12 + dr.MT - 1) - (backto12 ? k3 : k2) + 1;
                        if (snr < 1 || snr > 6)
                        {
                            continue;
                        }
                        if (!backto12 && snr == 6)
                        {
                            continue;
                        }

                        drl = ReportRows[snr - 1];

                        drl.Year            = dr.YR;
                        drl.Month           = dr.MT;
                        drl.CalendarDays   += dr.CALENDAR_DAYS;
                        drl.MonthWorkDays  += dr.MONTH_WORKDAYS;
                        drl.MonthWorkHours += dr.MONTH_WORKHOURS;
                        drl.DaysPlan       += dr.PLAN_DAYS;
                        drl.WorkDaysPlan   += dr.PLAN_WORKDAYS;
                        drl.DaysFact       += dr.FORAVPAYCALC_DAYS;
                        drl.HoursPlan      += dr.PLAN_HOURS;
                        drl.WorkHoursPlan  += dr.PLAN_WORKHOURS;
                        drl.HoursFact      += dr.FORAVPAYCALC_HOURS;
                        drl.Salary         += dr.FORAVPAYCALC_BRUTO;
                        drl.Salary2        += dr.TOTAL_BEFORE_TAXES;
                        drl.Pay            += dr.FORAVPAYCALC_PAYOUT;
                        drl.Caption         = string.Format("{0}. {1} {2:00}", drl.SNR, drl.Year, drl.Month);
                    }

                    for (int i = 0; i < ReportRows.Count - 1; i++)
                    {
                        drl = ReportRows[i];
                        TotalRow.CalendarDays   += drl.CalendarDays;
                        TotalRow.MonthWorkDays  += drl.MonthWorkDays;
                        TotalRow.MonthWorkHours += drl.MonthWorkHours;
                        TotalRow.DaysPlan       += drl.DaysPlan;
                        TotalRow.WorkDaysPlan   += drl.WorkDaysPlan;
                        TotalRow.DaysFact       += drl.DaysFact;
                        TotalRow.HoursPlan      += drl.HoursPlan;
                        TotalRow.WorkHoursPlan  += drl.WorkHoursPlan;
                        TotalRow.HoursFact      += drl.HoursFact;
                        TotalRow.Salary         += drl.Salary;
                        TotalRow.Salary2        += drl.Salary2;
                        TotalRow.Pay            += drl.Pay;
                    }
                }
            }

            return(err_list);
        }