コード例 #1
0
ファイル: SalaryCalcInfo.cs プロジェクト: Camel-RD/Klons
        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);
        }