Пример #1
0
        public decimal CalcCashNotPaid(SalaryInfo si, decimal iinrate, decimal dnsrate)
        {
            decimal sai       = NotPaidTaxed * dnsrate;
            decimal aftersai  = NotPaidTaxed - sai;
            decimal beforeIIN = aftersai + NotPaidNoSAI;

            decimal totalbeforeiin =
                si._AMOUNT_BEFORE_SN +
                si._PLUS_NOSAI +
                si._PLUS_AUTHORS_FEES -
                si._DNSN_AMOUNT;

            decimal iin = 0.0M;

            if (totalbeforeiin != 0.0M)
            {
                iin = si._IIN_AMOUNT * beforeIIN / totalbeforeiin;
            }

            decimal notPaiTotal = NotPaidNotTaxed + NotPaidTaxed + NotPaidNoSAI +
                                  NotPaidFromEndCash - sai - iin;

            notPaiTotal = KlonsData.RoundA(notPaiTotal, 2);

            return(notPaiTotal);
        }
Пример #2
0
        public void CorrectVacCash()
        {
            if (PFxB.PFx_vacation_prev != null)
            {
                VacationCalc.VcrPrevCurrent.IINEX = PFxB.PFx_vacation_prev.UsedIinEx;
                VacationCalc.VcrPrevCurrent.IIN   = PFxB.PFx_vacation_prev.IIN;
                VacationCalc.VcrPrevCurrent.Cash  = PFxB.PFx_vacation_prev.Cash;
            }
            if (PFxB.PFx_vacation != null)
            {
                VacationCalc.VcrCurrent.IINEX = PFxB.PFx_vacation.UsedIinEx;
                VacationCalc.VcrCurrent.IIN   = PFxB.PFx_vacation.IIN;
                VacationCalc.VcrCurrent.Cash  = PFxB.PFx_vacation.Cash;

                if (VacationCalc.VcrCompensation.Pay > 0.0M && VacationCalc.VcrCurrent.Pay > 0.0M)
                {
                    decimal r =
                        VacationCalc.VcrCompensation.Pay /
                        VacationCalc.VcrCurrent.Pay;

                    VacationCalc.VcrCompensation.IINEX = VacationCalc.VcrCurrent.IINEX * r;
                    VacationCalc.VcrCompensation.IIN   = VacationCalc.VcrCurrent.IIN * r;

                    VacationCalc.VcrCompensation.IINEX = KlonsData.RoundA(VacationCalc.VcrCompensation.IINEX, 2);
                    VacationCalc.VcrCompensation.IIN   = KlonsData.RoundA(VacationCalc.VcrCompensation.IIN, 2);

                    VacationCalc.VcrCompensation.Cash =
                        VacationCalc.VcrCompensation.Pay -
                        VacationCalc.VcrCompensation.DNS -
                        VacationCalc.VcrCompensation.IIN;
                }
            }
        }
Пример #3
0
        public List <PayFx2> CalcProc(SalaryInfo si, EBonusFrom efrom, decimal dfrom)
        {
            var ret = new List <PayFx2>();

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

                decimal v = KlonsData.RoundA(dfrom * dr.RATE / 100.0M, 2);
                if (dr.AMOUNT != v)
                {
                    dr.AMOUNT = v;
                }
                var pfx = AddRow(si, dr, dfrom, dr.AMOUNT, 1);
                ret.Add(pfx);
            }
            return(ret);
        }
Пример #4
0
 public void Round()
 {
     ExDependants        = KlonsData.RoundA(ExDependants, 2);
     ExInvalidity        = KlonsData.RoundA(ExInvalidity, 2);
     ExNationalMovements = KlonsData.RoundA(ExNationalMovements, 2);
     ExRetaliation       = KlonsData.RoundA(ExRetaliation, 2);
     ExUntaxedMinimum    = KlonsData.RoundA(ExUntaxedMinimum, 2);
 }
Пример #5
0
 public void ApplyRatio(decimal r)
 {
     ExDependants        = KlonsData.RoundA(r * ExDependants, 2);
     ExInvalidity        = KlonsData.RoundA(r * ExInvalidity, 2);
     ExNationalMovements = KlonsData.RoundA(r * ExNationalMovements, 2);
     ExRetaliation       = KlonsData.RoundA(r * ExRetaliation, 2);
     ExUntaxedMinimum    = KlonsData.RoundA(r * ExUntaxedMinimum, 2);
 }
Пример #6
0
        public ErrorList CalcAvPay(SalarySheetRowSetInfo srs, SalaryInfo si)
        {
            var err_list = CalcList(srs.SalarySheet, srs.IDP, srs.TotalPersonPay);

            si._AVPAYCALC_HOUR = KlonsData.RoundA(RateHour, 4);
            si._AVPAYCALC_DAY  = KlonsData.RoundA(RateDay, 4);
            return(err_list);
        }
Пример #7
0
        private bool IsDisposed = false; // To detect redundant calls

        public void Dispose()
        {
            if (KlonsTableAdapterManager?.TUSERSTableAdapter?.Connection != null)
            {
                KlonsTableAdapterManager.TUSERSTableAdapter.Connection.StateChange -= Connection_StateChange;
            }
            _KlonsData = null;
            IsDisposed = true;
        }
Пример #8
0
        public void CalcAndAddSplit(SalarySheetRowInfo sr, VacationCalcRow v, int calcver)
        {
            var pcri = new CalcRInfo(false, calcver);

            pcri.CalcR(sr, v.DateStart, v.DateEnd);
            v.DNS  = KlonsData.RoundA(pcri.RateDNSN * v.Pay / 100.0M, 2);
            v.Cash = v.Pay - v.DNS;
            Add(v);
        }
Пример #9
0
 private decimal GetRoundingErrorA(decimal amount, int divby)
 {
     if (divby == 1)
     {
         return(0.0M);
     }
     amount = KlonsData.RoundA(amount, 2);
     return(amount - KlonsData.RoundA(amount / (decimal)divby, 2) * (decimal)divby);
 }
Пример #10
0
        public decimal CalcFromEndC(SalaryInfo si,
                                    decimal totalinex,
                                    decimal curbruto, decimal brutonosai,
                                    decimal brutomargin,
                                    bool useprogressiveiin, bool hastaxdoc,
                                    decimal iinrate1, decimal iinrate2, decimal dnsrate, int divby,
                                    out List <PayFx2> rpfx)
        {
            rpfx = new List <PayFx2>();
            decimal ret = 0.0M;

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

            decimal calcbruto = curbruto;

            var p1 = new PayFx(useprogressiveiin);

            p1.Ir        = iinrate1 / 100.0M;
            p1.Ir2       = iinrate2 / 100.0M;
            p1.Sr        = dnsrate / 100.0M;
            p1.IM        = brutomargin;
            p1.HasTaxDoc = hastaxdoc;
            p1.Pay       = curbruto;
            p1.PayNs     = brutonosai;
            p1.IinEx     = totalinex;

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

                decimal v = dr.RATE;

                calcbruto = p1.GetPayByIncCash(v);
                calcbruto = KlonsData.RoundA(calcbruto, 2);
                v         = calcbruto - curbruto;
                p1.Pay    = calcbruto;
                curbruto  = calcbruto;
                if (dr.AMOUNT != v)
                {
                    dr.AMOUNT = v;
                }
                var rpfx1 = AddRow(si, dr, dr.RATE, v, 1);
                rpfx.Add(rpfx1);
                ret += v;
            }

            return(ret);
        }
Пример #11
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);
        }
Пример #12
0
        public static void GetIINDeductionsForPerson(CalcRRow2 wt, KlonsADataSet.PERSONS_RRow drpr,
                                                     KlonsADataSet.RATESRow drl, DateTime dt1, DateTime dt2, int calcver)
        {
            wt.ExUntaxedMinimum    = 0.0M;
            wt.ExDependants        = 0.0M;
            wt.ExInvalidity        = 0.0M;
            wt.ExRetaliation       = 0.0M;
            wt.ExNationalMovements = 0.0M;

            if (!string.IsNullOrEmpty(drpr.TAXDOC_NO))
            {
                wt.ExDependants = drl.APGAD * (decimal)drpr.APGAD_SK;

                if (drpr.INVALID == 1 || drpr.INVALID == 2)
                {
                    wt.ExInvalidity = drl.INVALID_12;
                }
                else if (drpr.INVALID == 3)
                {
                    wt.ExInvalidity = drl.INVALID_3;
                }

                if (drpr.PRET == 1)
                {
                    wt.ExNationalMovements = drl.PRET;
                }

                if (drpr.REPRES == 1)
                {
                    wt.ExRetaliation = drl.REPR;
                }

                if (drpr.PENSIONER == 1 || drpr.PENSIONER_SP == 1)
                {
                    wt.ExUntaxedMinimum = 0.0M;
                }
                else
                {
                    if (dt1 < ProgressiveIINStartDate)
                    {
                        wt.ExUntaxedMinimum = drl.NEPLIEK_MIN;
                    }
                    else
                    {
                        if (calcver == KlonsData.VersionRef(0))
                        {
                            wt.ExUntaxedMinimum = GetIINUntaxedMinimum(drpr.PERSONSRow, dt1);
                        }
                        else
                        {
                            wt.ExUntaxedMinimum = GetIINUntaxedMinimum2(drpr.PERSONSRow, dt1, dt2);
                        }
                    }
                }
            }
        }
Пример #13
0
 public static void ResetInstance()
 {
     if (_KlonsData == null)
     {
         _KlonsData.Dispose();
         _KlonsData = null;
     }
     _KlonsData       = new KlonsData();
     _KlonsDataModule = _KlonsData;
 }
Пример #14
0
        public void CalcAndAdd(SalarySheetRowInfo sr, VacationCalcRow v,
                               decimal AvPayRateDay, int calcver)
        {
            v.AvPayRate = AvPayRateDay;
            v.Pay       = KlonsData.RoundA(AvPayRateDay * (decimal)v.Days, 2);
            var pcri = new CalcRInfo(false, calcver);

            pcri.CalcR(sr, v.DateStart, v.DateEnd);
            v.DNS  = KlonsData.RoundA(pcri.RateDNSN * v.Pay / 100.0M, 2);
            v.Cash = v.Pay - v.DNS;
            Add(v);
        }
Пример #15
0
        public decimal CalcURVN()
        {
            decimal r = 0.0M;

            if (SR?.SalarySheet?.DR_Likmes != null)
            {
                r = SR.SalarySheet.DR_Likmes.URN /
                    (decimal)SR.GetLinkedRowsCount();
            }
            r = KlonsData.RoundA(r, 2);
            return(r);
        }
Пример #16
0
        public void CalcSAI()
        {
            decimal pay1 =
                SI._SALARY +
                SI._SALARY_AVPAY_FREE_DAYS +
                SI._SICKDAYS_PAY +
                SI._VACATION_PAY_CURRENT +
                SI._PLUS_TAXED;

            SI._AMOUNT_BEFORE_SN = pay1;

            SI._DNSN_AMOUNT = KlonsData.RoundA(SI._AMOUNT_BEFORE_SN * SI._RATE_DNSN / 100.0M, 2);
            SI._DDSN_AMOUNT = KlonsData.RoundA(SI._AMOUNT_BEFORE_SN * SI._RATE_DDSN / 100.0M, 2);
            SI._SN_AMOUNT   = SI._DDSN_AMOUNT + SI._DNSN_AMOUNT;
        }
Пример #17
0
        public void RecalcAndRound()
        {
            PAY_TAXED        = KlonsData.RoundA(PAY_TAXED, 2);
            PAY_NOSAI        = KlonsData.RoundA(PAY_NOSAI, 2);
            PAY_NOTTAXED     = KlonsData.RoundA(PAY_NOTTAXED, 2);
            NOTPAID_TAXED    = KlonsData.RoundA(NOTPAID_TAXED, 2);
            NOTPAID_NOSAI    = KlonsData.RoundA(NOTPAID_NOSAI, 2);
            NOTPAID_NOTTAXED = KlonsData.RoundA(NOTPAID_NOTTAXED, 2);
            PFNT             = KlonsData.RoundA(PFNT, 2);
            LIT  = KlonsData.RoundA(LIT, 2);
            HIT  = KlonsData.RoundA(HIT, 2);
            PFT  = KlonsData.RoundA(PFT, 2);
            LINT = KlonsData.RoundA(LINT, 2);
            HINT = KlonsData.RoundA(HINT, 2);

            var pfx = new PayFx();

            SetTo(pfx);
            pfx.CalcAllAndRound();
            SetFrom(pfx);

            if (pfx.IinEx > 0.0M)
            {
                UNTAXED_MINIMUM  = KlonsData.RoundA(UNTAXED_MINIMUM, 2);
                IINEX_DEPENDANTS = KlonsData.RoundA(IINEX_DEPENDANTS, 2);
                IINEX2           = KlonsData.RoundA(IINEX2, 2);
                IINEX_EXP        = KlonsData.RoundA(IINEX_EXP, 2);
                var dd = new decimal[] { UNTAXED_MINIMUM, IINEX_DEPENDANTS, IINEX2, IINEX_EXP };
                PayFxA.MakeExactSum(pfx.UsedIinEx, dd);
                UNTAXED_MINIMUM  = dd[0];
                IINEX_DEPENDANTS = dd[1];
                IINEX2           = dd[2];
                IINEX_EXP        = dd[3];
            }

            CASH_NOTPAID = 0.0M;
            if (NOTPAID_TAXED == 0.0M && NOTPAID_NOSAI == 0.0M && NOTPAID_NOTTAXED == 0.0M)
            {
                return;
            }

            pfx.Pay   = Math.Min(PAY_TAXED, NOTPAID_TAXED);
            pfx.PayNs = Math.Min(PAY_NOSAI, NOTPAID_NOSAI);
            pfx.PayNt = Math.Min(PAY_NOTTAXED, NOTPAID_NOTTAXED);
            pfx.CalcAllAndRound();
            CASH_NOTPAID = pfx.Cash;
        }
Пример #18
0
        //part = 0 - skip MinusAfterIIN
        //part = 1 - only MinusAfterIIN
        public List <PayFx2> CalcNotProc(SalaryInfo si, int part, int divby = 1)
        {
            var ret = new List <PayFx2>();

            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;
                }

                decimal v = 0.0M;
                if (dr.IsIDANull())
                {
                    v = KlonsData.RoundA(dr.RATE / (decimal)divby, 2);
                    if (dr.AMOUNT != v)
                    {
                        dr.AMOUNT = v;
                    }
                    v += GetRoundingError(dr.RATE, divby);
                }
                else
                {
                    v = dr.RATE;
                    if (dr.AMOUNT != v)
                    {
                        dr.AMOUNT = v;
                    }
                }
                var pfx = AddRow(si, dr, dr.RATE, v, divby);
                ret.Add(pfx);
            }
            return(ret);
        }
Пример #19
0
        public void FillLinkedRow(SalaryInfo target)
        {
            decimal ratio = target._AMOUNT_BEFORE_IIN / TotalSI._AMOUNT_BEFORE_IIN;

            target._IIN_EXEMPT_UNTAXED_MINIMUM   = KlonsData.RoundA(TotalSI._IIN_EXEMPT_UNTAXED_MINIMUM * ratio, 2);
            target._IIN_EXEMPT_DEPENDANTS        = KlonsData.RoundA(TotalSI._IIN_EXEMPT_DEPENDANTS * ratio, 2);
            target._IIN_EXEMPT_INVALIDITY        = KlonsData.RoundA(TotalSI._IIN_EXEMPT_INVALIDITY * ratio, 2);
            target._IIN_EXEMPT_NATIONAL_MOVEMENT = KlonsData.RoundA(TotalSI._IIN_EXEMPT_NATIONAL_MOVEMENT * ratio, 2);
            target._IIN_EXEMPT_RETALIATION       = KlonsData.RoundA(TotalSI._IIN_EXEMPT_RETALIATION * ratio, 2);

            /*
             * target._PLUS_PF_NOTTAXED = Math.Round(total._PLUS_PF_NOTTAXED * ratio, 2);
             * target._PLUS_PF_TAXED = Math.Round(total._PLUS_PF_TAXED * ratio, 2);
             * target._PLUS_LI_NOTTAXED = Math.Round(total._PLUS_PF_NOTTAXED * ratio, 2);
             * target._PLUS_LI_TAXED = Math.Round(total._PLUS_PF_TAXED * ratio, 2);
             * target._PLUS_HI_NOTTAXED = Math.Round(total._PLUS_PF_NOTTAXED * ratio, 2);
             * target._PLUS_HI_TAXED = Math.Round(total._PLUS_PF_TAXED * ratio, 2);
             */
        }
Пример #20
0
        public void CalcAndAddNext(SalarySheetRowInfo sr, VacationCalcRow v,
                                   decimal AvPayRateDay)
        {
            v.AvPayRate = AvPayRateDay;
            v.Pay       = KlonsData.RoundA(AvPayRateDay * (decimal)v.Days, 2);
            Add(v);
            VacationCalcRow vcmt = null;
            int             yrmt = v.DateStart.Year * 12 + v.DateStart.Month - 1;

            if (!PerMonth.TryGetValue(yrmt, out vcmt))
            {
                vcmt           = new VacationCalcRow();
                vcmt.DateStart = v.DateStart;
                vcmt.DateEnd   = v.DateEnd;
                //vcmt.DateStart = new DateTime(v.DateStart.Year, v.DateStart.Month, 1);
                //vcmt.DateEnd = vcmt.DateStart.LastDayOfMonth();
                PerMonth[yrmt] = vcmt;
            }
            vcmt.Add(v);
        }
Пример #21
0
        private KlonsData()
        {
            _KlonsData   = this;
            CurrentDBTag = null;

            LoadSettings();
            LoadMasterList();

            ColorThemeHelper.MyToolStripRenderer.SetColorTheme(Settings.ColorTheme);

            if (Settings.MasterEntry.Name != "")
            {
                var me = MasterList.GetMasterEntryByName(Settings.MasterEntry.Name);
                if (me != null)
                {
                    Settings.MasterEntry.CopyFrom(me);
                }
            }

            _Params = new KlonsParams();

            ReportHelper = new ReportHelperA();

            _klonsDataSetHelper = new DataSetHelper(
                typeof(KlonsADataSet),
                typeof(KlonsAdapters.TableAdapterManager),
                typeof(KlonsAdapters.QueriesTableAdapter),
                "ConnectionString1",
                KlonsA.Properties.Settings.Default);

            _dataSetHelpers["KlonsData"] = _klonsDataSetHelper;

            _klonsRepDataSetHelper = new DataSetHelper(
                typeof(KlonsARepDataSet),
                typeof(KlonsRepAdapters.TableAdapterManager),
                null,
                "ConnectionString1",
                KlonsA.Properties.Settings.Default);

            _dataSetHelpers["KlonsRep"] = _klonsRepDataSetHelper;
        }
Пример #22
0
        public decimal CalcPay0()
        {
            decimal totalpay1 =
                SI._PLUS_NP_NOTTAXED +
                SI._PLUS_NP_NOSAI +
                SI._PLUS_NP_TAXED;

            decimal sai         = KlonsData.RoundA(SI._PLUS_NP_TAXED * SI._RATE_DNSN / 100.0M, 2);
            decimal beforeiinex =
                SI._PLUS_NP_NOSAI +
                SI._PLUS_NP_TAXED -
                sai;

            decimal totaliinex = SI.SumIINExemptsAll();
            decimal iinex      = Math.Min(totaliinex, beforeiinex);
            decimal iin        = 0.0M;

            if (CalcR.UseProgresiveIINRate)
            {
                iin  = (Math.Min(SI._PLUS_NP_TAXED + SI._PLUS_NP_NOSAI, CalcR.IINMargin) - sai - iinex) * SI._RATE_IIN / 100.0M;
                iin += Math.Max(SI._PLUS_NP_TAXED + SI._PLUS_NP_NOSAI - CalcR.IINMargin, 0.0M) * SI._RATE_IIN2 / 100.0M;
                iin  = KlonsData.RoundA(Math.Max(iin, 0.0M), 2);
            }
            else
            {
                iin = KlonsData.RoundA((beforeiinex - iinex) * SI._RATE_IIN / 100.0M, 2);
            }

            decimal pay0 = totalpay1 - sai - iin + SI._MINUS_AFTER_IIN;

            if (SI._ADVANCE < 0.0M)
            {
                pay0 += -SI._ADVANCE;
            }
            pay0 = Math.Min(pay0, SI._PAY);

            return(pay0);
        }
Пример #23
0
        public void CheckPlusFromEnd(out decimal bruto, out decimal pay)
        {
            decimal d = 0.0M;

            for (int i = 0; i < LinkedSCI.Length; i++)
            {
                var sc = LinkedSCI[i];
                d += sc.BonusCalc.PlusFromEnd;
            }

            decimal extotal  = CalcR.ExMax2.SumIINExemptsAll();
            decimal exused   = CalcR.ExCorrect.SumIINExemptsAll();
            decimal exusable = extotal - exused;

            decimal v  = Math.Min(d, exusable);
            decimal v1 = v / (1.0M - CalcR.RateDNSN);
            decimal v2 = (d - v1) / (1.0M - CalcR.RateIIN) / (1.0M - CalcR.RateDNSN);

            v = KlonsData.RoundA(v1 + v2, 2);

            bruto = v;
            pay   = d;
        }
Пример #24
0
        public void CalcSAI()
        {
            var SI = TotalSI;

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

            SI._AMOUNT_BEFORE_SN = pay1;

            SI._DNSN_AMOUNT = KlonsData.RoundA(SI._AMOUNT_BEFORE_SN * SI._RATE_DNSN / 100.0M, 2);
            SI._DDSN_AMOUNT = KlonsData.RoundA(SI._AMOUNT_BEFORE_SN * SI._RATE_DDSN / 100.0M, 2);
            SI._SN_AMOUNT   = SI._DDSN_AMOUNT + SI._DNSN_AMOUNT;

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

            Utils.MakeExactSum(SI._DNSN_AMOUNT, LinkedSCI,
                               d => d.SI._DNSN_AMOUNT,
                               (d, val) => d.SI._DNSN_AMOUNT = val);

            Utils.MakeExactSum(SI._DDSN_AMOUNT, LinkedSCI,
                               d => d.SI._DDSN_AMOUNT,
                               (d, val) => d.SI._DDSN_AMOUNT = val);

            for (int i = 0; i < LinkedSCI.Length; i++)
            {
                var lsc = LinkedSCI[i];
                lsc.SI._SN_AMOUNT = lsc.SI._DNSN_AMOUNT + lsc.SI._DDSN_AMOUNT;
            }
        }
Пример #25
0
        public void CalcWorkPay(SalarySheetRowInfo sr, SalaryInfo si = null)
        {
            if (sr.Row.XType == ESalarySheetRowType.Total)
            {
                throw new Exception("Bad idea.");
            }

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

            if (si == null)
            {
                TotalRow = new SalaryInfo();
            }
            else
            {
                TotalRow = si;
            }

            var posR      = sr.PositionsR.FilterListWithDates(dt1, dt2);
            var amatirpay = new SalaryInfo[posR.LinkedPeriods.Count];

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

            sr.DLRows.CountPlanMonth(TotalRow, sr.SalarySheet.MDT1, sr.SalarySheet.MDT2);
            sr.DLRows.CountPlan(TotalRow, sr.SalarySheet.MDT1, sr.SalarySheet.MDT2);

            PeriodInfo amats_hf;

            if (!sr.Events.Positions.TryGetValue(sr.Row.IDAM, out amats_hf))
            {
                throw new Exception("Bad init.");
            }
            amats_hf = amats_hf.FilterListWithDates(dt1, dt2);

            for (int i = 0; i < amatirpay.Length; i++)
            {
                var ari_x = posR.LinkedPeriods[i];
                var ari_l = ari_x.FilterThisWithList(amats_hf);

                if (ari_l.LinkedPeriods.Count == 0)
                {
                    continue;
                }

                var wt = new SalaryInfo();
                amatirpay[i] = wt;

                for (int j = 0; j < ari_l.LinkedPeriods.Count; j++)
                {
                    var ari = ari_l.LinkedPeriods[j];
                    sr.DLRows.CountPlan(wt, ari.DateFirst, ari.DateLast);
                    sr.DLRows.CountFact(wt, ari.DateFirst, ari.DateLast);
                }

                var dr_amati_r = ari_x.Item1 as KlonsADataSet.POSITIONS_RRow;

                switch (dr_amati_r.XRateType)
                {
                case ESalaryType.Month:
                case ESalaryType.Day:
                    wt.GetRateDefs(dr_amati_r, TotalRow._MONTH_WORKDAYS, TotalRow._MONTH_WORKHOURS);
                    CalcPayWithDayRate(wt, dr_amati_r);
                    break;

                case ESalaryType.Hour:
                    wt.GetRateDefs(dr_amati_r, TotalRow._MONTH_WORKDAYS, TotalRow._MONTH_WORKHOURS);
                    CalcPayWithHourRate(wt, dr_amati_r);
                    break;

                case ESalaryType.Aggregated:
                    wt.GetRateDefs(dr_amati_r, TotalRow._MONTH_WORKDAYS, TotalRow._MONTH_WORKHOURS);
                    CalcPayWithoutAvPay(wt, dr_amati_r);
                    AvPayCalcRequired = true;
                    break;

                case ESalaryType.Piece:
                    CalcPayWithoutAvPay(wt, dr_amati_r);
                    AvPayCalcRequired = true;
                    break;
                }

                wt._SALARY = wt.SumSalary();

                if (PreparingReport)
                {
                    ReportRows.Add(wt);
                    var dtr1 = ari_l.LinkedPeriods[0].DateFirst;
                    var dtr2 = ari_l.LinkedPeriods[ari_l.LinkedPeriods.Count - 1].DateLast;
                    var jr   = new WorkPayCalcJoinRow();
                    jr.DateStart = dtr1;
                    jr.DateEnd   = dtr2;
                    JoinRows.Add(jr);
                }

                TotalRow.AddWorkTime(wt);
                TotalRow.AddSalary(wt);
            }

            TotalRow._SALARY_PIECEWORK = CalcPieceWorkPay(dt1, dt2, sr.Row.IDAM);

            TotalRow.PlanedWorkPay = KlonsData.RoundA(TotalRow.PlanedWorkPay, 2);

            TotalRow._SALARY_DAY                      = KlonsData.RoundA(TotalRow._SALARY_DAY, 2);
            TotalRow._SALARY_NIGHT                    = KlonsData.RoundA(TotalRow._SALARY_NIGHT, 2);
            TotalRow._SALARY_OVERTIME                 = KlonsData.RoundA(TotalRow._SALARY_OVERTIME, 2);
            TotalRow._SALARY_HOLIDAYS_DAY             = KlonsData.RoundA(TotalRow._SALARY_HOLIDAYS_DAY, 2);
            TotalRow._SALARY_HOLIDAYS_NIGHT           = KlonsData.RoundA(TotalRow._SALARY_HOLIDAYS_NIGHT, 2);
            TotalRow._SALARY_HOLIDAYS_OVERTIME        = KlonsData.RoundA(TotalRow._SALARY_HOLIDAYS_OVERTIME, 2);
            TotalRow._SALARY_AVPAY_FREE_DAYS          = KlonsData.RoundA(TotalRow._SALARY_AVPAY_FREE_DAYS, 2);
            TotalRow._SALARY_AVPAY_WORK_DAYS          = KlonsData.RoundA(TotalRow._SALARY_AVPAY_WORK_DAYS, 2);
            TotalRow._SALARY_AVPAY_WORK_DAYS_OVERTIME = KlonsData.RoundA(TotalRow._SALARY_AVPAY_WORK_DAYS_OVERTIME, 2);
            TotalRow._SALARY_AVPAY_HOLIDAYS           = KlonsData.RoundA(TotalRow._SALARY_AVPAY_HOLIDAYS, 2);
            TotalRow._SALARY_AVPAY_HOLIDAYS_OVERTIME  = KlonsData.RoundA(TotalRow._SALARY_AVPAY_HOLIDAYS_OVERTIME, 2);

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

            if (PreparingReport && !AvPayCalcRequired)
            {
                PrepareList(sr.GetPositionTitle());
            }
        }
Пример #26
0
        public ErrorList DoAvPay(SalarySheetRowInfo sr, SalaryInfo wt, SalaryInfo totalwt = null)
        {
            var err = GatAvPay(sr);

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

            decimal _AvPayRate = AvPayRateDay;

            if (IsAggregatedTimeRate(sr))
            {
                _AvPayRate = AvPayRateCalendarDay;
            }

            if (totalwt == null)
            {
                decimal rateo  = wt.R_MT_OVERTIME / 100.0M;
                decimal rateh  = wt.R_MT_HOLIDAY / 100.0M;
                decimal rateho = wt.R_MT_HOLIDAY_OVERTIME / 100.0M;

                wt._SALARY_AVPAY_FREE_DAYS += _AvPayRate * (decimal)wt.FACT_AVPAY_FREE_DAYS_2;

                wt._SALARY_AVPAY_WORK_DAYS          += _AvPayRate * (decimal)wt.FACT_AVPAY_WORK_DAYS_2;
                wt._SALARY_AVPAY_WORK_DAYS_OVERTIME += _AvPayRate * rateo * (decimal)wt.FACT_AVPAY_HOURS_OVERTIME_2;
                wt._SALARY_AVPAY_HOLIDAYS           += _AvPayRate * rateh * (decimal)wt.FACT_AVPAY_WORKINHOLIDAYS_2;
                wt._SALARY_AVPAY_HOLIDAYS_OVERTIME  += _AvPayRate * rateho * (decimal)wt.FACT_AVPAY_HOLIDAYS_HOURS_OVERT_2;
            }
            else
            {
                if (wt.FACT_AVPAY_FREE_HOURS_2 > 0.0f)
                {
                    wt._SALARY_AVPAY_FREE_DAYS +=
                        (decimal)wt.FACT_AVPAY_FREE_HOURS_2 /
                        (decimal)totalwt.FACT_AVPAY_FREE_HOURS_2 *
                        totalwt._SALARY_AVPAY_FREE_DAYS;
                }

                if (wt.FACT_AVPAY_HOURS_2 > 0.0f)
                {
                    wt._SALARY_AVPAY_WORK_DAYS +=
                        (decimal)wt.FACT_AVPAY_HOURS_2 /
                        (decimal)totalwt.FACT_AVPAY_HOURS_2 *
                        totalwt._SALARY_AVPAY_WORK_DAYS;
                }

                if (wt.FACT_AVPAY_HOURS_OVERTIME_2 > 0.0f)
                {
                    wt._SALARY_AVPAY_WORK_DAYS_OVERTIME +=
                        (decimal)wt.FACT_AVPAY_HOURS_OVERTIME_2 /
                        (decimal)totalwt.FACT_AVPAY_HOURS_OVERTIME_2 *
                        totalwt._SALARY_AVPAY_WORK_DAYS_OVERTIME;
                }

                if (wt.FACT_AVPAY_HOLIDAYS_HOURS_2 > 0.0f)
                {
                    wt._SALARY_AVPAY_HOLIDAYS +=
                        (decimal)wt.FACT_AVPAY_HOLIDAYS_HOURS_2 /
                        (decimal)totalwt.FACT_AVPAY_HOLIDAYS_HOURS_2 *
                        totalwt._SALARY_AVPAY_HOLIDAYS;
                }

                if (wt.FACT_AVPAY_HOLIDAYS_HOURS_OVERT_2 > 0.0f)
                {
                    wt._SALARY_AVPAY_HOLIDAYS_OVERTIME +=
                        (decimal)wt.FACT_AVPAY_HOLIDAYS_HOURS_OVERT_2 /
                        (decimal)totalwt.FACT_AVPAY_HOLIDAYS_HOURS_OVERT_2 *
                        totalwt._SALARY_AVPAY_HOLIDAYS_OVERTIME;
                }
            }

            wt._SALARY_AVPAY_FREE_DAYS          = KlonsData.RoundA(wt._SALARY_AVPAY_FREE_DAYS, 2);
            wt._SALARY_AVPAY_WORK_DAYS          = KlonsData.RoundA(wt._SALARY_AVPAY_WORK_DAYS, 2);
            wt._SALARY_AVPAY_WORK_DAYS_OVERTIME = KlonsData.RoundA(wt._SALARY_AVPAY_WORK_DAYS_OVERTIME, 2);
            wt._SALARY_AVPAY_HOLIDAYS           = KlonsData.RoundA(wt._SALARY_AVPAY_HOLIDAYS, 2);
            wt._SALARY_AVPAY_HOLIDAYS_OVERTIME  = KlonsData.RoundA(wt._SALARY_AVPAY_HOLIDAYS_OVERTIME, 2);

            wt._SALARY = wt.SumSalary();
            return(err);
        }
Пример #27
0
        public void GetRateDefs(KlonsADataSet.POSITIONS_RRow dr_amati_r, int calcdays, float calchours)
        {
            var rt = dr_amati_r.XRateType;

            R_TYPE                     = dr_amati_r.SALARY_TYPE;
            R_MT                       = dr_amati_r.RATE;
            R_MT_NIGHT                 = dr_amati_r.RATE_NIGHT;
            R_MT_NIGHT_TYPE            = dr_amati_r.RATE_NIGHT_TYPE;
            R_MT_OVERTIME              = dr_amati_r.RATE_OVERTIME;
            R_MT_OVERTIME_TYPE         = dr_amati_r.RATE_OVERTIME_TYPE;
            R_MT_HOLIDAY               = dr_amati_r.RATE_HOLIDAY;
            R_MT_HOLIDAY_TYPE          = dr_amati_r.RATE_HOLIDAY_TYPE;
            R_MT_HOLIDAY_NIGHT         = dr_amati_r.RATE_HOLIDAY_NIGHT;
            R_MT_HOLIDAY_NIGHT_TYPE    = dr_amati_r.RATE_HOLIDAY_NIGHT_TYPE;
            R_MT_HOLIDAY_OVERTIME      = dr_amati_r.RATE_HOLIDAY_OVERTIME;
            R_MT_HOLIDAY_OVERTIME_TYPE = dr_amati_r.RATE_HOLIDAY_OVERTIME_TYPE;

            R_HR                  = R_MT;
            R_HR_NIGHT            = GetRate(R_HR, R_MT_NIGHT_TYPE, R_MT_NIGHT);
            R_HR_OVERTIME         = GetRate(R_HR, R_MT_OVERTIME_TYPE, R_MT_OVERTIME);
            R_HR_HOLIDAY          = GetRate(R_HR, R_MT_HOLIDAY_TYPE, R_MT_HOLIDAY);
            R_HR_HOLIDAY_NIGHT    = GetRate(R_HR, R_MT_HOLIDAY_NIGHT_TYPE, R_MT_HOLIDAY_NIGHT);
            R_HR_HOLIDAY_OVERTIME = GetRate(R_HR, R_MT_HOLIDAY_OVERTIME_TYPE, dr_amati_r.RATE_HOLIDAY_OVERTIME);

            decimal d;

            //mēneša likmes tiek pārrēķinātas dienas likmēs
            if (rt == ESalaryType.Month)
            {
                if (calcdays > 0)
                {
                    d             = (decimal)calcdays;
                    R_HR         /= d;
                    R_HR_NIGHT   /= d;
                    R_HR_HOLIDAY /= d;
                }
                if (calchours > 0.0f)
                {
                    d                      = (decimal)calchours;
                    R_HR_NIGHT            /= d;
                    R_HR_OVERTIME         /= d;
                    R_HR_HOLIDAY_NIGHT    /= d;
                    R_HR_HOLIDAY_OVERTIME /= d;
                }
            }
            if (rt == ESalaryType.Day && calchours > 0.0f)
            {
                d                      = (decimal)dr_amati_r.NORMAL_DAY_HOURS;
                R_HR_NIGHT            /= d;
                R_HR_OVERTIME         /= d;
                R_HR_HOLIDAY_NIGHT    /= d;
                R_HR_HOLIDAY_OVERTIME /= d;
            }

            R_HR                  = KlonsData.RoundA(R_HR, 6);
            R_HR_NIGHT            = KlonsData.RoundA(R_HR_NIGHT, 6);
            R_HR_OVERTIME         = KlonsData.RoundA(R_HR_OVERTIME, 6);
            R_HR_HOLIDAY          = KlonsData.RoundA(R_HR_HOLIDAY, 6);
            R_HR_HOLIDAY_NIGHT    = KlonsData.RoundA(R_HR_HOLIDAY_NIGHT, 6);
            R_HR_HOLIDAY_OVERTIME = KlonsData.RoundA(R_HR_HOLIDAY_OVERTIME, 6);
        }
Пример #28
0
        public ErrorList CalcSickDaysB(SalarySheetRowInfo sr, SickDayCalcInfo totalsdci)
        {
            var dt1  = sr.SalarySheet.DT1;
            var dt2  = sr.SalarySheet.DT2;
            var mdt1 = sr.SalarySheet.MDT1;
            var mdt2 = sr.SalarySheet.MDT2;
            var mdt3 = sr.SalarySheet.MDT1.AddMonths(-1);

            var ps = sr.Events.SickDays.LinkedPeriods.Where(
                d =>
                d.EEventId == EEventId.Slimības_lapa_A &&
                d.DateLast >= dt1 &&
                d.DateLast <= dt2
                ).ToArray();

            if (ps.Length == 0)
            {
                return(new ErrorList());
            }

            int d1;

            SickDayCalcRow sdi = TotalRow;

            foreach (var pi in ps)
            {
                var dtp1 = pi.DateFirst;
                if (dtp1 < mdt3)
                {
                    continue;
                }

                d1 = 0;

                if (PreparingReport)
                {
                    sdi           = new SickDayCalcRow();
                    sdi.DateStart = pi.DateFirst;
                    sdi.DateEnd   = pi.DateLast;
                    Rows.Add(sdi);
                }


                if (dtp1 < mdt1)
                {
                    var prevdlrowset = sr.GetDLRowSet(-1, sr.Row.IDAM);
                    if (prevdlrowset != null)
                    {
                        var dtp2 = dtp1.LastDayOfMonth();
                        prevdlrowset.CountSickDays(sdi, dtp1, dtp2, 0);

                        d1 = (dtp2 - dtp1).Days + 1;
                        if (d1 <= 10)
                        {
                            sr.DLRows.CountSickDays(sdi, mdt1, pi.DateLast, d1);
                        }
                    }
                }
                else
                {
                    sr.DLRows.CountSickDays(sdi, pi.DateFirst, pi.DateLast, d1);
                }

                if (PreparingReport)
                {
                    TotalRow.AddB(sdi);
                }
            }

            if (PreparingReport)
            {
                Rows.Add(TotalRow);
                PrepareListA();
            }

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

            var err = GatAvPay(sr);

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

            decimal _AvPayRate = AvPayRateDay;

            if (IsAggregatedTimeRate(sr))
            {
                _AvPayRate = AvPayRateCalendarDay;
            }
            TotalRow.AvPayRate = _AvPayRate;

            if (totalsdci == null)
            {
                TotalRow.SickDayPay75 = KlonsData.RoundA(_AvPayRate * TotalRow.DaysCount75 * 0.75M, 2);
                TotalRow.SickDayPay80 = KlonsData.RoundA(_AvPayRate * TotalRow.DaysCount80 * 0.8M, 2);
            }
            else
            {
                TotalRow.SickDayPay75 = (decimal)TotalRow.HoursCount75 / (decimal)totalsdci.TotalRow.HoursCount75;
                TotalRow.SickDayPay80 = (decimal)TotalRow.HoursCount80 / (decimal)totalsdci.TotalRow.HoursCount80;
                TotalRow.SickDayPay75 = KlonsData.RoundA(TotalRow.SickDayPay75 * totalsdci.TotalRow.SickDayPay75, 2);
                TotalRow.SickDayPay80 = KlonsData.RoundA(TotalRow.SickDayPay80 * totalsdci.TotalRow.SickDayPay80, 2);
            }
            TotalRow.SickDayPay = TotalRow.SickDayPay75 + TotalRow.SickDayPay80;

            return(new ErrorList());
        }
Пример #29
0
 public static decimal RoundA(decimal d)
 {
     return(KlonsData.RoundA(d, 2));
 }
Пример #30
0
        public void CalcIIN()
        {
            decimal pay1 =
                SI._AMOUNT_BEFORE_SN -
                SI._PLUS_NOSAI +
                SI._PLUS_AUTHORS_FEES;

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

            decimal iinexempts = SI.SumIINExemptsAll();

            if (!CalcR.UseProgresiveIINRate)
            {
                iinexempts            = Math.Min(iinexempts, payAfterSAI);
                SI._AMOUNT_BEFORE_IIN = payAfterSAI - iinexempts;
                SI._IIN_AMOUNT        = KlonsData.RoundA(SI._AMOUNT_BEFORE_IIN * SI._RATE_IIN / 100.0M, 2);
            }
            else if (CalcR.HasTaxDoc)
            {
                if (pay1 <= CalcR.IINMargin)
                {
                    iinexempts            = Math.Min(iinexempts, payAfterSAI);
                    SI._AMOUNT_BEFORE_IIN = payAfterSAI - iinexempts;
                    SI._IIN_AMOUNT        = KlonsData.RoundA(SI._AMOUNT_BEFORE_IIN * SI._RATE_IIN / 100.0M, 2);
                }
                else
                {
                    decimal amountbeforeiin =
                        CalcR.IINMargin -
                        SI._DNSN_AMOUNT -
                        SI._MINUS_BEFORE_IIN -
                        iinexempts;

                    decimal iin = amountbeforeiin * SI._RATE_IIN / 100.0M;

                    decimal amountbeforeiin2 =
                        pay1 -
                        CalcR.IINMargin;

                    iin += amountbeforeiin2 * SI._RATE_IIN2 / 100.0M;

                    if (iin < 0.0M)
                    {
                        iinexempts += KlonsData.RoundA(iin / (SI._RATE_IIN / 100.0M), 2);
                        iin         = 0.0M;
                    }

                    SI._IIN_AMOUNT = KlonsData.RoundA(iin, 2);
                }
            }
            else
            {
                if (SI._CALC_VER < KlonsData.VersionRef(2))
                {
                    iinexempts            = 0.0M;
                    SI._AMOUNT_BEFORE_IIN = payAfterSAI - iinexempts;
                    decimal iin =
                        (SI._AMOUNT_BEFORE_IIN + SI._DNSN_AMOUNT) * SI._RATE_IIN2 / 100.0M -
                        SI._DNSN_AMOUNT * SI._RATE_IIN / 100.0M;
                    SI._IIN_AMOUNT = KlonsData.RoundA(iin, 2);
                }
                else
                {
                    SI._AMOUNT_BEFORE_IIN = payAfterSAI - iinexempts;
                    decimal iin =
                        (SI._AMOUNT_BEFORE_IIN + SI._DNSN_AMOUNT) * SI._RATE_IIN2 / 100.0M -
                        SI._DNSN_AMOUNT * SI._RATE_IIN / 100.0M;
                    if (iin < 0.0M)
                    {
                        iin        = 0.0M;
                        iinexempts = payAfterSAI + SI._DNSN_AMOUNT - SI._DNSN_AMOUNT * SI._RATE_IIN / SI._RATE_IIN2;
                        iinexempts = KlonsData.RoundA(iinexempts, 2);
                    }
                    SI._IIN_AMOUNT = KlonsData.RoundA(iin, 2);
                }
            }

            SI._AMOUNT_BEFORE_IIN = payAfterSAI - iinexempts;

            CalcR.ExDivided.ApplyTo0(SI);
            CalcR.CorrectIINExempts(iinexempts);
            CalcR.ExCorrect.ApplyTo(SI);
            CalcR.SaveStateForFinal(CalcR.ExCorrect);
            CalcR.AddToListT();
            CalcR.PrepareList();
        }