Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
        public ErrorList FillRow()
        {
            if (SR.Row.XType == ESalarySheetRowType.Total)
            {
                return(SR.FillRowX());
            }

            if (PreparingReport)
            {
                SI._CALC_VER = SR.Row.CALC_VER;
            }
            else
            {
                SI._CALC_VER = 2;
            }

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

            var err_list = new ErrorList();

            SR.CheckAlgasPS();

            MakeWorkTime();
            CalcRR(dt1, dt2, SI._CALC_VER);

            if (SR.IsSingleRow())
            {
                BonusCalc = new BonusCalcInfo(CalcR, SR.GetAlgasAllPSRows(), PreparingReport);
            }
            else
            {
                BonusCalc = new BonusCalcInfo(CalcR, SR.GetAlgasPSRowsX(SR.Row.IDAM), PreparingReport);
            }

            PFxA          = new PayFxA();
            PFxA.Position = PositionTitle;
            PFxA.SetFrom(CalcR);

            var pfxs1 = BonusCalc.CalcNotProc(SI, 0, 1);

            BonusCalc.CalcFromEndA(1);

            var pfxs2 = BonusCalc.CalcProc(SI, EBonusFrom.FromMonthSalary, SI.PlanedWorkPay);
            var pfxs3 = BonusCalc.CalcProc(SI, EBonusFrom.FromPay, SI._SALARY);

            SI._FORAVPAYCALC_BRUTO += BonusCalc.ForAvpayCalc;

            PFxA.TempRows0.AddRange(pfxs1);
            PFxA.TempRows0.AddRange(pfxs2);
            PFxA.TempRows0.AddRange(pfxs3);

            decimal avpay1 =
                SI._SALARY_AVPAY_FREE_DAYS +
                SI._SALARY_AVPAY_WORK_DAYS +
                SI._SALARY_AVPAY_WORK_DAYS_OVERTIME +
                SI._SALARY_AVPAY_HOLIDAYS +
                SI._SALARY_AVPAY_HOLIDAYS_OVERTIME;

            //vid.izpeïòas dienas, slimîbas, atvaïinājuma nauda
            var err = FillRowVcSdc();

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

            decimal avpay2 =
                SI._SALARY_AVPAY_FREE_DAYS +
                SI._SALARY_AVPAY_WORK_DAYS +
                SI._SALARY_AVPAY_WORK_DAYS_OVERTIME +
                SI._SALARY_AVPAY_HOLIDAYS +
                SI._SALARY_AVPAY_HOLIDAYS_OVERTIME;

            //PFxA.DoPayFxA_AvPay(avpay2 - avpay1);

            decimal pay1 =
                SI._SALARY +
                SI._SALARY_AVPAY_FREE_DAYS +
                SI._SICKDAYS_PAY +
                SI._VACATION_PAY_CURRENT;

            pfxs1 = BonusCalc.CalcProc(SI, EBonusFrom.FromPayAndVacSick, pay1);

            decimal payBeforeSAI =
                pay1 +
                SI._PLUS_TAXED;

            SI._AMOUNT_BEFORE_SN = payBeforeSAI;

            pfxs2 = BonusCalc.CalcProc(SI, EBonusFrom.FromPayBeforeSAI, payBeforeSAI);

            PFxA.TempRows1.AddRange(pfxs1);
            PFxA.TempRows1.AddRange(pfxs2);

            CalcSAI();

            decimal payAfterSAI =
                SI._AMOUNT_BEFORE_SN -
                SI._DNSN_AMOUNT;

            pfxs3 = BonusCalc.CalcProc(SI, EBonusFrom.FromPayAfterSAI, payAfterSAI);
            PFxA.TempRows1.AddRange(pfxs3);

            payAfterSAI =
                payAfterSAI +
                SI._PLUS_NOSAI +
                SI._PLUS_AUTHORS_FEES -
                SI._MINUS_BEFORE_IIN;

            SI._AMOUNT_BEFORE_IIN = payAfterSAI; // pay before iin exempts


            //neto bonus -> bruto
            decimal curbruto =
                SI._AMOUNT_BEFORE_SN -
                SI._PLUS_NOSAI +
                SI._PLUS_AUTHORS_FEES -
                SI._MINUS_BEFORE_IIN;

            decimal iinexempts1  = SI.SumIINExemptsAll();
            decimal payBeforeIIN = payAfterSAI - iinexempts1;

            SI._AMOUNT_BEFORE_IIN = payBeforeIIN;

            //-- useless
            //BonusCalc.CalcProc(SI, EBonusFrom.FromPayBeforeIIN, payBeforeIIN);

            decimal iinexempts1a = iinexempts1;

            decimal iinexempts1b = iinexempts1;

            List <PayFx2> rpfx             = null;
            var           plusfromendbruto = BonusCalc.CalcFromEndC(si: SI,
                                                                    totalinex: iinexempts1,
                                                                    curbruto: curbruto,
                                                                    brutonosai: SI._PLUS_NOSAI,
                                                                    brutomargin: CalcR.IINMargin,
                                                                    useprogressiveiin: CalcR.UseProgresiveIINRate,
                                                                    hastaxdoc: CalcR.HasTaxDoc,
                                                                    iinrate1: SI._RATE_IIN,
                                                                    iinrate2: SI._RATE_IIN2,
                                                                    dnsrate: SI._RATE_DNSN,
                                                                    divby: SR.GetLinkedRowsCount(),
                                                                    rpfx: out rpfx);

            PFxA.TempRows1.AddRange(rpfx);

            if (plusfromendbruto != 0.0M)
            {
                CalcSAI();

                payAfterSAI =
                    SI._AMOUNT_BEFORE_SN -
                    SI._DNSN_AMOUNT +
                    SI._PLUS_NOSAI +
                    SI._PLUS_AUTHORS_FEES -
                    SI._MINUS_BEFORE_IIN;
            }

            CalcIIN();

            SI._TOTAL_BEFORE_TAXES =
                SI._AMOUNT_BEFORE_SN +
                SI._PLUS_NOTTAXED +
                SI._PLUS_NOSAI +
                SI._PLUS_AUTHORS_FEES;

            SI._PAY =
                SI._TOTAL_BEFORE_TAXES -
                SI._DNSN_AMOUNT -
                SI._IIN_AMOUNT;

            pfxs1 = BonusCalc.CalcNotProc(SI, 1, 1);
            pfxs2 = BonusCalc.CalcProc(SI, EBonusFrom.FromPayAfterIIN, SI._PAY);

            PFxA.TempRows2.AddRange(pfxs1);
            PFxA.TempRows2.AddRange(pfxs2);


            PFxA.IinEx = SI.SumIINExemptsAll();

            PFxA.DoPayFxA_Salary(SI._SALARY);
            PFxA.DoPayFxA_Bonus(PFxA.TempRows0);
            PFxA.DoPayFxA_AvPay(SI._SALARY_AVPAY_FREE_DAYS);
            PFxA.DoPayFxA_SickPay(SI._SICKDAYS_PAY);
            PFxA.DoPayFxA_Vacation(SI._VACATION_PAY_CURRENT, SI._VACATION_PAY_PREV);
            CorrectVacCash();
            PFxA.DoPayFxA_Bonus(PFxA.TempRows1);
            PFxA.DoPayFxA_BonusSimpleAdd(PFxA.TempRows2);

            var cashNotPaid = BonusCalc.CalcCashNotPaid(SI, SI._RATE_IIN, SI._RATE_DNSN);

            BonusCalc.CalcCash();


            //viens no diviem variantiem
            //SI._MINUS_AFTER_IIN += cashNotPaid;
            SI._MINUS_AFTER_IIN +=
                SI._PLUS_NP_TAXED +
                SI._PLUS_NP_NOTTAXED +
                SI._PLUS_NP_NOSAI;

            //---Negatîva izmaksājamā summa ir OK
            SI._VACATION_ADVANCE_CURRENT = -SI._VACATION_ADVANCE_PREV;

            SI._VACATION_ADVANCE_NEXT =
                SI._VACATION_ADVANCE_PREV +
                SI._VACATION_ADVANCE_CURRENT +
                SI._VACATION_CASH_NEXT;

            SI._ADVANCE = SI._VACATION_CASH_NEXT + SI._VACATION_ADVANCE_CURRENT;

            SI._PAYT =
                SI._PAY +
                SI._ADVANCE -
                SI._MINUS_AFTER_IIN;

            SI._FORAVPAYCALC_PAYOUT = SI._PAY;

            SI._PAY0 = CalcPay0();

            SI._URVN_AMAOUNT = CalcURVN();


            return(err_list);
        }
Ejemplo n.º 3
0
        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);
            }
        }
Ejemplo n.º 4
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.º 5
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);
        }