Esempio n. 1
0
 public void SetAvPayTo(SalaryCalcInfo sc)
 {
     if (!IsAvPayCalcDone)
     {
         return;
     }
     sc.SetAvPayFrom(AvPayCalc, AvPayRateHour, AvPayRateDay, AvPayRateCalendarDay);
 }
Esempio n. 2
0
 public void SetAvPayFrom(SalaryCalcInfo sc)
 {
     if (sc.AvPayCalc != null)
     {
         AvPayCalc = sc.AvPayCalc;
     }
     if (IsAvPayCalcDone)
     {
         return;
     }
     IsAvPayCalcDone = sc.IsAvPayCalcDone;
     AvPayRateHour   = sc.AvPayRateHour;
     AvPayRateDay    = sc.AvPayRateDay;
 }
Esempio n. 3
0
        public ErrorList CalcVacationDays(SalaryCalcInfo sci)
        {
            ErrorList err;

            if (!sci.SR.IsSingleRow())
            {
                throw new Exception("Bad call.");
            }

            SetAvPayFrom(sci);

            err = CalcVacationDays2(sci.SR, null, sci.SI._CALC_VER);
            if (err.HasErrors)
            {
                return(err);
            }

            SetAvPayTo(sci);
            WriteTo(sci.SI);

            return(err);
        }
Esempio n. 4
0
        public ErrorList CalcSickDays(SalaryCalcInfo sci)
        {
            ErrorList err;

            if (!sci.SR.IsSingleRow())
            {
                throw new Exception("Bad call.");
            }
            SetAvPayFrom(sci);

            err = CalcSickDaysB(sci.SR, null);
            if (err.HasErrors)
            {
                return(err);
            }

            SetAvPayTo(sci);

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

            return(err);
        }
Esempio n. 5
0
 public void SetAvPayFrom(SalaryCalcInfo sc)
 {
     SetAvPayFrom(sc.AvPayCalc, sc.AvPayRateHour, sc.AvPayRateDay, sc.AvPayRateCalendarDay);
 }
Esempio n. 6
0
 public void SetAvPayTo(SalaryCalcInfo sc)
 {
     sc.SetAvPayFrom(AvPayCalc, AvPayRateHour, AvPayRateDay, AvPayRateCalendarDay);
 }
Esempio n. 7
0
        public ErrorList FillRow()
        {
            IsAvPayCalcDone = false;


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

            var       err_list = new ErrorList();
            ErrorList err      = null;

            // -- should be done in initialization
            //CheckLinkedRows(DrTotalRow.IDP);

            SRS.CheckAlgasPS();

            LinkedSCI = new SalaryCalcInfo[SRS.LinkedRows.Length];
            for (int i = 0; i < SRS.LinkedRows.Length; i++)
            {
                LinkedSCI[i] = new SalaryCalcInfo(SRS.LinkedRows[i], new SalaryInfo(), PreparingReport);
                SRS.LinkedRows[i].TotalPositionPay = LinkedSCI[i].SI;
            }

            if (SRS.IsSingleRow())
            {
                var sci = LinkedSCI[0];
                TotalSI            = sci.SI;
                SRS.TotalPersonPay = TotalSI;
                err = sci.FillRow();
                err_list.AddRange(err);
                SRS.TotalPersonPay = sci.SI;

                return(err_list);
            }

            BonusCalcInfo bonus_am;

            TotalSI = new SalaryInfo();

            if (PreparingReport)
            {
                TotalSI._CALC_VER = SRS.TotalRow.Row.CALC_VER;
            }
            else
            {
                TotalSI._CALC_VER = 2;
            }

            SRS.TotalPersonPay            = TotalSI;
            SRS.TotalRow.TotalPositionPay = TotalSI;

            MakeWorkTime(); // updates all rows and TotalPersonPay
            CalcRf(dt1, dt2, TotalSI._CALC_VER);

            var drs_bonust = SRS.GetAlgasAllPSRows();

            BonusCalc = new BonusCalcInfo(CalcR, drs_bonust, PreparingReport);

            for (int i = 0; i < LinkedSCI.Length; i++)
            {
                var lr  = SRS.LinkedRows[i];
                var lsc = LinkedSCI[i];

                bonus_am = BonusCalc.Filter(
                    d =>
                    d.IsIDANull() ||
                    (!d.IsIDANull() &&
                     d.IDA == lr.Row.IDAM));

                lsc.BonusCalc = bonus_am;

                lsc.SR.CheckAlgasPS();
                lsc.CalcRR(dt1, dt2, lsc.SI._CALC_VER);
            }
            LinkedSCI[0].BonusCalc.TakeRoundingError = true;


            PFxB = new PayFxB();

            var cret1 = BonusCalc.CalcNotProcT(this, 0);

            BonusCalc.CalcFromEndAT(this);

            var cret2 = BonusCalc.CalcProcT(this, EBonusFrom.FromMonthSalary, d => d.PlanedWorkPay);
            var cret3 = BonusCalc.CalcProcT(this, EBonusFrom.FromPay, d => d._SALARY);

            TotalSI._FORAVPAYCALC_BRUTO += BonusCalc.ForAvpayCalc;
            foreach (var sci in LinkedSCI)
            {
                sci.SI._FORAVPAYCALC_BRUTO += sci.BonusCalc.ForAvpayCalc;
            }

            PFxB.TempCRets0.AddRange(cret1);
            PFxB.TempCRets0.AddRange(cret2);
            PFxB.TempCRets0.AddRange(cret3);

            //SummForAvPayCalcBruto(); //--allredy done

            decimal[] avpay1  = GetAvPay();
            decimal   savpay1 = avpay1.Sum();

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

            decimal[] avpay2  = GetAvPay();
            decimal   savpay2 = avpay2.Sum();

            if (savpay2 > savpay1)
            {
                for (int i = 0; i < avpay1.Length; i++)
                {
                    avpay2[i] -= avpay1[i];
                }
                //PFxB.DoPayFxB_AvPay(savpay2 - savpay1, avpay2);
            }


            cret1 = BonusCalc.CalcProcT(this, EBonusFrom.FromPayAndVacSick,
                                        d =>
                                        d._SALARY +
                                        d._SALARY_AVPAY_FREE_DAYS +
                                        d._SICKDAYS_PAY +
                                        d._VACATION_PAY_CURRENT);

            cret2 = BonusCalc.CalcProcT(this, EBonusFrom.FromPayBeforeSAI,
                                        d =>
                                        d._SALARY +
                                        d._SALARY_AVPAY_FREE_DAYS +
                                        d._SICKDAYS_PAY +
                                        d._VACATION_PAY_CURRENT +
                                        d._PLUS_TAXED);

            CalcSAI();

            cret3 = BonusCalc.CalcProcT(this, EBonusFrom.FromPayAfterSAI,
                                        d =>
                                        d._AMOUNT_BEFORE_SN -
                                        d._DNSN_AMOUNT);

            PFxB.TempCRets1.AddRange(cret1);
            PFxB.TempCRets1.AddRange(cret2);
            PFxB.TempCRets1.AddRange(cret3);



            //done in BonusCalc.Calc
            //Summ1();


            decimal payAfterSAI =
                TotalSI._AMOUNT_BEFORE_SN -
                TotalSI._DNSN_AMOUNT +
                TotalSI._PLUS_NOSAI +
                TotalSI._PLUS_AUTHORS_FEES -
                TotalSI._MINUS_BEFORE_IIN;

            TotalSI._AMOUNT_BEFORE_IIN = payAfterSAI;

            decimal curbruto =
                TotalSI._AMOUNT_BEFORE_SN -
                TotalSI._PLUS_NOSAI +
                TotalSI._PLUS_AUTHORS_FEES -
                TotalSI._MINUS_BEFORE_IIN;

            decimal iinexempts1 = TotalSI.SumIINExemptsAll();

            List <BonusCalcInfo.CalcRet> rpfx = null;
            var plusfromendbruto = BonusCalc.CalcFromEndCT(
                sct: this,
                totalinex: iinexempts1,
                curbruto: curbruto,
                brutonosai: TotalSI._PLUS_NOSAI,
                brutomargin: CalcR.IINMargin,
                useprogressiveiin: CalcR.UseProgresiveIINRate,
                hastaxdoc: CalcR.HasTaxDoc,
                iinrate1: TotalSI._RATE_IIN,
                iinrate2: TotalSI._RATE_IIN2,
                dnsrate: TotalSI._RATE_DNSN,
                divby: LinkedSCI.Length,
                rpfx: out rpfx);

            PFxB.TempCRets1.AddRange(rpfx);

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

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


            CalcIIN();

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

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


            PFxB.SetFrom(CalcR);
            PFxB.IinEx = TotalSI.SumIINExemptsAll();
            PFxB.InitParts(this);

            PFxB.DoPayFxB_Salary(TotalSI._SALARY, GetValues(d => d._SALARY));
            PFxB.DoPayFxB_Bonus(PFxB.TempCRets0);
            PFxB.DoPayFxB_AvPay(
                TotalSI._SALARY_AVPAY_FREE_DAYS,
                GetValues(d => d._SALARY_AVPAY_FREE_DAYS));
            PFxB.DoPayFxB_SickPay(
                TotalSI._SICKDAYS_PAY,
                GetValues(d => d._SICKDAYS_PAY));
            PFxB.DoPayFxB_VacationPrev(
                TotalSI._VACATION_PAY_PREV,
                GetValues(d => d._VACATION_PAY_PREV));
            PFxB.DoPayFxB_Vacation(
                TotalSI._VACATION_PAY_CURRENT,
                GetValues(d => d._VACATION_PAY_CURRENT));

            CorrectVacCash();
            PFxB.DoPayFxB_Bonus(PFxB.TempCRets1);

            MakeExactIINExSplit();

            for (int i = 0; i < LinkedSCI.Length; i++)
            {
                var lsc = LinkedSCI[i];
                lsc.FillRowFromParentA(PFxB.Parts[i].IIN);
            }


            cret1 = BonusCalc.CalcNotProcT(this, 1);
            cret2 = BonusCalc.CalcProcT(this, EBonusFrom.FromPayAfterIIN,
                                        d => d._PAY);


            PFxB.TempCRets2.AddRange(cret1);
            PFxB.TempCRets2.AddRange(cret2);
            PFxB.DoPayFxB_BonusSimpleAdd(PFxB.TempCRets2);
            BonusCalc.CalcCashT(this);


            //  ?????? ?????
            //Summ1();

            TotalSI._MINUS_AFTER_IIN +=
                TotalSI._PLUS_NP_TAXED +
                TotalSI._PLUS_NP_NOTTAXED +
                TotalSI._PLUS_NP_NOSAI;

            //---Negatīva izmaksājamā summa ir OK
            TotalSI._VACATION_ADVANCE_CURRENT = -TotalSI._VACATION_ADVANCE_PREV;

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

            TotalSI._ADVANCE =
                TotalSI._VACATION_CASH_NEXT +
                TotalSI._VACATION_ADVANCE_CURRENT;

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

            TotalSI._FORAVPAYCALC_PAYOUT = TotalSI._PAY;

            TotalSI._PAY0 = CalcPay0();

            if (SRS?.SalarySheet?.DR_Likmes != null)
            {
                TotalSI._URVN_AMAOUNT = SRS.SalarySheet.DR_Likmes.URN;
            }


            for (int i = 0; i < LinkedSCI.Length; i++)
            {
                var lsc = LinkedSCI[i];
                lsc.FillRowFromParentB();
            }


            TotalSI._FORAVPAYCALC_BRUTO  = 0.0M;
            TotalSI._FORAVPAYCALC_PAYOUT = 0.0M;

            for (int i = 0; i < LinkedSCI.Length; i++)
            {
                var si = LinkedSCI[i].SI;
                TotalSI._FORAVPAYCALC_BRUTO  += si._FORAVPAYCALC_BRUTO;
                TotalSI._FORAVPAYCALC_PAYOUT += si._FORAVPAYCALC_PAYOUT;
            }


            return(err_list);
        }
Esempio n. 8
0
 public void SetAvPayTo(SalaryCalcInfo sc)
 {
     sc.SetAvPayFrom(this, RateHour, RateDay, RateCalendarDay);
 }