Exemple #1
0
        public void PrepareReportT(SalaryCalcTInfo sct)
        {
            if (!PreparingReport)
            {
                return;
            }
            var list = new List <CalcRRow>();
            var c1   = new CalcRRow()
            {
                IsTitle = true, Caption = "Kopā amati"
            };

            list.Add(c1);
            list.AddRange(ReportRows);
            var ce = new CalcRRow()
            {
                IsTitle = true
            };

            foreach (var sc in sct.LinkedSCI)
            {
                list.Add(ce);
                c1 = new CalcRRow()
                {
                    IsTitle = true, Caption = sc.SR.GetPositionTitle()
                };
                list.Add(c1);
                list.AddRange(sc.CalcR.ReportRows);
            }
            ReportRows = list;
        }
Exemple #2
0
 public void SetAvPayTo(SalaryCalcTInfo sc)
 {
     if (!IsAvPayCalcDone)
     {
         return;
     }
     sc.SetAvPayFrom(AvPayCalc, AvPayRateHour, AvPayRateDay, AvPayRateCalendarDay);
 }
Exemple #3
0
        public List <CalcRet> CalcNotProcT(SalaryCalcTInfo scti, int part)
        {
            var ret   = new List <CalcRet>();
            int divby = scti.LinkedSCI.Length;

            foreach (var dr in DataRows)
            {
                if (dr.XRateType != EBonusRateType.Money ||
                    dr.XBonusType == EBonusType.ReverseCalc)
                {
                    continue;
                }

                if (part == 0 && dr.XBonusType == EBonusType.MinusAfterIIN)
                {
                    continue;
                }
                if (part == 1 && dr.XBonusType != EBonusType.MinusAfterIIN)
                {
                    continue;
                }

                var ret1 = new CalcRet(divby);

                decimal v = dr.RATE;
                if (dr.AMOUNT != v)
                {
                    dr.AMOUNT = v;
                }
                var pfx = AddRow(scti.TotalSI, dr, dr.RATE, v, 1);
                ret1.PfxT = pfx;

                if (dr.IsIDANull())
                {
                    v = KlonsData.RoundA(v / (decimal)divby, 2);
                    for (int i = 0; i < divby; i++)
                    {
                        var     sci = scti.LinkedSCI[i];
                        decimal v1  = v;
                        if (i == 0)
                        {
                            v1 += GetRoundingErrorA(dr.RATE, divby);
                        }
                        ret1.Pfxs[i] = sci.BonusCalc.AddRow(sci.SI, dr, dr.RATE, v1, divby);
                    }
                }
                else
                {
                    int i   = FindAM(scti, dr.IDA);
                    var sci = scti.LinkedSCI[i];
                    ret1.Pfxs[i] = sci.BonusCalc.AddRow(sci.SI, dr, dr.RATE, v, 1);
                }
                ret.Add(ret1);
            }
            return(ret);
        }
Exemple #4
0
        public void CalcFromEndAT(SalaryCalcTInfo scti)
        {
            int divby = scti.LinkedSCI.Length;

            CalcFromEndA(1);
            for (int i = 0; i < divby; i++)
            {
                var sci = scti.LinkedSCI[i];
                sci.BonusCalc.CalcFromEndA(divby);
            }
        }
Exemple #5
0
 private int FindAM(SalaryCalcTInfo scti, int idam)
 {
     for (int i = 0; i < scti.LinkedSCI.Length; i++)
     {
         if (scti.LinkedSCI[i].SR.Row.IDAM == idam)
         {
             return(i);
         }
     }
     return(-1);
 }
Exemple #6
0
 public void InitParts(SalaryCalcTInfo pcti)
 {
     for (int i = 0; i < pcti.LinkedSCI.Length; i++)
     {
         var lsc     = pcti.LinkedSCI[i];
         var partpfx = new PayFxA();
         partpfx.SetFrom(this);
         lsc.PFxA         = partpfx;
         partpfx.Position = lsc.PositionTitle;
         Parts.Add(partpfx);
     }
 }
Exemple #7
0
 public void CalcCashT(SalaryCalcTInfo scti)
 {
     if (!PreparingReport)
     {
         return;
     }
     CalcCash();
     for (int i = 0; i < scti.LinkedSCI.Length; i++)
     {
         var sci = scti.LinkedSCI[i];
         sci.BonusCalc.CalcCash();
     }
 }
Exemple #8
0
 public void SetAvPayFrom(SalaryCalcTInfo sc)
 {
     if (sc.AvPayCalc != null)
     {
         AvPayCalc = sc.AvPayCalc;
     }
     if (IsAvPayCalcDone)
     {
         return;
     }
     IsAvPayCalcDone      = sc.IsAvPayCalcDone;
     AvPayRateHour        = sc.AvPayRateHour;
     AvPayRateDay         = sc.AvPayRateDay;
     AvPayRateCalendarDay = sc.AvPayRateCalendarDay;
 }
Exemple #9
0
        public ErrorList FillRow()
        {
            var dt1 = SalarySheet.DT1;
            var dt2 = SalarySheet.DT2;

            TotalPersonPay = new SalaryInfo();
            var sci = new SalaryCalcTInfo(this, TotalPersonPay, false);

            var err_list = sci.FillRow();

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

            sci.WriteData();
            return(err_list);
        }
Exemple #10
0
        public ErrorList CalcWorkPayTAvPay(SalaryCalcTInfo scti)
        {
            if (!AvPayCalcRequired)
            {
                return(new ErrorList());
            }
            TotalRow = scti.TotalSI;
            //TotalRow.ClearSalaryAvPayPart();

            var sis = scti.LinkedSCI.Select(x => x.SI).ToArray();

            SummAvPayTime2(TotalRow, sis);

            //uses avcalc from LinkedSCI[0] and applies to TotalRow
            LinkedWorkPayCalcs[0].DoAvPay(scti.SRS.TotalRow, TotalRow, null);

            for (int i = 0; i < scti.LinkedSCI.Length; i++)
            {
                var lsci = scti.LinkedSCI[i];
                var wpc  = LinkedWorkPayCalcs[i];
                wpc.TotalRow = lsci.SI;

                var err = wpc.CalcPayWithAvPay(lsci.SR, TotalRow);
                if (err.HasErrors)
                {
                    return(err);
                }

                //TotalRow.AddSalaryAvPayPart(wpc.TotalRow);
            }

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

            MakeAvPayExactSum();

            if (PreparingReport)
            {
                PrepareListT();
            }
            return(new ErrorList());
        }
Exemple #11
0
        public void CalcWorkPayT(SalaryCalcTInfo scti)
        {
            TotalRow = scti.TotalSI;
            var sr = scti.SRS;

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

            var dlrowlist = sr.GetDLRowSetList();

            dlrowlist.CountPlanMonth(TotalRow, sr.SalarySheet.MDT1, sr.SalarySheet.MDT2);
            dlrowlist.CountTotalPlan(TotalRow, sr.SalarySheet.MDT1, sr.SalarySheet.MDT2);
            dlrowlist.CountTotalFact(TotalRow, sr.SalarySheet.MDT1, sr.SalarySheet.MDT2);

            LinkedWorkPayCalcs = new WorkPayCalcInfo[scti.LinkedSCI.Length];

            for (int i = 0; i < scti.LinkedSCI.Length; i++)
            {
                var lsci = scti.LinkedSCI[i];
                var wpc  = new WorkPayCalcInfo(PreparingReport);
                wpc.CalcWorkPay(lsci.SR, lsci.SI);
                TotalRow.AddSalary(lsci.SI);

                if (wpc.AvPayCalcRequired)
                {
                    AvPayCalcRequired = true;
                }
                lsci.WorkPayCalc      = wpc;
                wpc.PositionTitle     = lsci.SR.GetPositionTitle();
                LinkedWorkPayCalcs[i] = wpc;
            }

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

            if (PreparingReport && !AvPayCalcRequired)
            {
                PrepareListT();
            }
        }
Exemple #12
0
        public ErrorList CalcVacationDaysT(SalaryCalcTInfo scti)
        {
            ErrorList err;
            var       sr = scti.SRS.TotalRow;

            sr.CheckLinkedRows(sr.Row.IDP);
            SetAvPayFrom(scti);

            if (sr.IsSingleRow())
            {
                var lsci = scti.LinkedSCI[0];

                err = CalcVacationDays(lsci);
                if (err.HasErrors)
                {
                    return(err);
                }

                SetAvPayTo(scti);
                SetAvPayTo(lsci);
                WriteTo(lsci.SI);
                WriteTo(scti.TotalSI);
                if (PreparingReport)
                {
                    scti.LinkedSCI[0].VacationCalc = this;
                }
                return(err);
            }

            if (sr.Row.XType != ESalarySheetRowType.Total)
            {
                throw new Exception("Bad call");
            }

            GetAvPayCalc(scti.SRS.TotalRow);

            var vcs = new VacationCalcInfo[scti.LinkedSCI.Length];

            for (int i = 0; i < scti.LinkedSCI.Length; i++)
            {
                var vc = new VacationCalcInfo(PreparingReport, CalcVer);
                vcs[i] = vc;
                vc.SetAvPayFrom(this);
            }

            err = CalcVacationDays2(scti.SRS.TotalRow, vcs, scti.TotalSI._CALC_VER);
            if (err.HasErrors)
            {
                return(err);
            }

            SetAvPayTo(scti);

            EnsureExactSum(vcs);

            for (int i = 0; i < scti.LinkedSCI.Length; i++)
            {
                var lsci = scti.LinkedSCI[i];
                var lr   = scti.SRS.LinkedRows[i];
                var vc   = vcs[i];
                lsci.VacationCalc = vc;
                vc.WriteTo(lsci.SI);
            }

            WriteTo(scti.TotalSI);

            if (PreparingReport)
            {
                var positions = new string[scti.LinkedSCI.Length];
                for (int i = 0; i < scti.LinkedSCI.Length; i++)
                {
                    var lsci = scti.LinkedSCI[i];
                    positions[i] = lsci.PositionTitle;
                }
                PrepareListT(vcs, positions, this);
            }

            return(err);
        }
Exemple #13
0
        public decimal CalcFromEndCT(SalaryCalcTInfo sct,
                                     decimal totalinex,
                                     decimal curbruto, decimal brutonosai,
                                     decimal brutomargin,
                                     bool useprogressiveiin, bool hastaxdoc,
                                     decimal iinrate1, decimal iinrate2, decimal dnsrate, int divby,
                                     out List <CalcRet> rpfx)
        {
            rpfx = new List <CalcRet>();
            decimal ret = 0.0M;

            if (PlusFromEnd <= 0.0M)
            {
                return(ret);
            }

            List <PayFx2> rpfxt = null;

            decimal calcbruto = CalcFromEndC(sct.TotalSI,
                                             totalinex,
                                             curbruto, brutonosai,
                                             brutomargin,
                                             useprogressiveiin, hastaxdoc,
                                             iinrate1, iinrate2, dnsrate, divby, out rpfxt);

            for (int i = 0; i < DataRows.Length; i++)
            {
                var dr = DataRows[i];
                if (dr.XRateType != EBonusRateType.Money ||
                    dr.XBonusType != EBonusType.ReverseCalc)
                {
                    continue;
                }

                var pfx  = BonusPfx[i];
                var ret1 = new CalcRet(divby);
                ret1.PfxT = pfx;
                decimal v = dr.AMOUNT;

                if (dr.IsIDANull())
                {
                    v = KlonsData.RoundA(v / (decimal)divby, 2);
                    for (int j = 0; j < divby; j++)
                    {
                        var     sci = sct.LinkedSCI[j];
                        decimal v1  = v;
                        if (j == 0)
                        {
                            v1 += GetRoundingErrorA(dr.AMOUNT, divby);
                        }
                        ret1.Pfxs[j] = sci.BonusCalc.AddRow(sci.SI, dr, dr.RATE, v1, divby);
                    }
                }
                else
                {
                    int ind = FindAM(sct, dr.IDA);
                    var sci = sct.LinkedSCI[ind];
                    ret1.Pfxs[i] = sci.BonusCalc.AddRow(sci.SI, dr, dr.RATE, v, 1);
                }

                rpfx.Add(ret1);
                ret += pfx.Pay;
            }

            return(ret);
        }
Exemple #14
0
        public ErrorList CalcSickDaysT(SalaryCalcTInfo scti)
        {
            var sr = scti.SRS.TotalRow;

            sr.CheckLinkedRows(sr.Row.IDP);

            var err = new ErrorList();

            scti.TotalSI._SICKDAYS     = 0;
            scti.TotalSI._SICKDAYS_PAY = 0.0M;

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

                scti.TotalSI._SICKDAYS     = TotalRow.DaysCount;
                scti.TotalSI._SICKDAYS_PAY = TotalRow.SickDayPay;

                if (PreparingReport)
                {
                    scti.LinkedSCI[0].SickDayCalc = this;
                }
                return(err);
            }

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

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


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

            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 sci = scti.LinkedSCI[i];
                var sdc = new SickDayCalcInfo(PreparingReport);
                positions[i] = lr.GetPositionTitle();
                sdcs[i]      = sdc;
                sdc.SetAvPayFrom(this);

                sci.SI._SICKDAYS     = 0;
                sci.SI._SICKDAYS_PAY = 0.0M;

                err = sdc.CalcSickDaysB(lr, TotalSDCI);
                if (err.HasErrors)
                {
                    return(err);
                }

                sci.SI._SICKDAYS     = sdc.TotalRow.DaysCount;
                sci.SI._SICKDAYS_PAY = sdc.TotalRow.SickDayPay;

                if (PreparingReport)
                {
                    sci.SickDayCalc = sdc;
                }
            }
            SumTotalPay(sdcs, TotalSDCI);

            scti.TotalSI._SICKDAYS     = TotalRow.DaysCount;
            scti.TotalSI._SICKDAYS_PAY = TotalRow.SickDayPay;

            if (PreparingReport)
            {
                PrepareListT(sdcs, positions);
            }

            return(new ErrorList());
        }
Exemple #15
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);
        }
Exemple #16
0
        public List <CalcRet> CalcProcT(SalaryCalcTInfo scti, EBonusFrom efrom,
                                        Func <SalaryInfo, decimal> fdfrom)
        {
            var ret   = new List <CalcRet>();
            int divby = scti.LinkedSCI.Length;

            foreach (var dr in DataRows)
            {
                if (dr.XRateType != EBonusRateType.Percent ||
                    dr.XBonusType == EBonusType.ReverseCalc)
                {
                    continue;
                }
                if (dr.XBonusFrom != efrom)
                {
                    continue;
                }

                var ret1 = new CalcRet(divby);

                if (dr.IsIDANull())
                {
                    decimal dfrom = fdfrom(scti.TotalSI);
                    decimal v     = KlonsData.RoundA(dfrom * dr.RATE / 100.0M, 2);
                    decimal vs    = v;
                    if (dr.AMOUNT != v)
                    {
                        dr.AMOUNT = v;
                    }
                    var pfx = AddRow(scti.TotalSI, dr, dfrom, v, 1);
                    ret1.PfxT = pfx;

                    for (int i = 0; i < divby; i++)
                    {
                        var sci = scti.LinkedSCI[i];
                        dfrom = fdfrom(sci.SI);
                        v     = KlonsData.RoundA(dfrom * dr.RATE / 100.0M, 2);
                        vs   -= v;
                        if (i == divby - 1)
                        {
                            v += vs;
                        }
                        ret1.Pfxs[i] = sci.BonusCalc.AddRow(sci.SI, dr, dfrom, v, divby);
                    }
                }
                else
                {
                    int     i     = FindAM(scti, dr.IDA);
                    var     sci   = scti.LinkedSCI[i];
                    decimal dfrom = fdfrom(sci.SI);
                    decimal v     = KlonsData.RoundA(dfrom * dr.RATE / 100.0M, 2);
                    if (dr.AMOUNT != v)
                    {
                        dr.AMOUNT = v;
                    }
                    var pfx = AddRow(scti.TotalSI, dr, dfrom, v, 1);
                    ret1.PfxT    = pfx;
                    ret1.Pfxs[i] = sci.BonusCalc.AddRow(sci.SI, dr, dfrom, v, 1);
                }
                ret.Add(ret1);
            }
            return(ret);
        }
Exemple #17
0
 public void SetAvPayTo(SalaryCalcTInfo sc)
 {
     sc.SetAvPayFrom(this, RateHour, RateDay, RateCalendarDay);
 }