示例#1
0
        public void AddThat(PayCalcRow cr)
        {
            PAY_TAXED        += cr.PAY_TAXED;
            PAY_NOSAI        += cr.PAY_NOSAI;
            PAY_NOTTAXED     += cr.PAY_NOTTAXED;
            NOTPAID_TAXED    += cr.NOTPAID_TAXED;
            NOTPAID_NOSAI    += cr.NOTPAID_NOSAI;
            NOTPAID_NOTTAXED += cr.NOTPAID_NOTTAXED;

            UNTAXED_MINIMUM  += cr.UNTAXED_MINIMUM;
            IINEX_DEPENDANTS += cr.IINEX_DEPENDANTS;
            IINEX2           += cr.IINEX2;
            DNSI             += cr.DNSI;

            PFT  += cr.PFT;
            LIT  += cr.LIT;
            HIT  += cr.HIT;
            PFNT += cr.PFNT;
            LINT += cr.LINT;
            HINT += cr.HINT;

            IINEX_EXP    += cr.IINEX_EXP;
            IIN          += cr.IIN;
            CASH         += cr.CASH;
            CASH_NOTPAID += cr.CASH_NOTPAID;
        }
示例#2
0
        public void SubtractThat(PayCalcRow cr)
        {
            PAY_TAXED        -= cr.PAY_TAXED;
            PAY_NOSAI        -= cr.PAY_NOSAI;
            PAY_NOTTAXED     -= cr.PAY_NOTTAXED;
            NOTPAID_TAXED    -= cr.NOTPAID_TAXED;
            NOTPAID_NOSAI    -= cr.NOTPAID_NOSAI;
            NOTPAID_NOTTAXED -= cr.NOTPAID_NOTTAXED;

            UNTAXED_MINIMUM  -= cr.UNTAXED_MINIMUM;
            IINEX_DEPENDANTS -= cr.IINEX_DEPENDANTS;
            IINEX2           -= cr.IINEX2;
            DNSI             -= cr.DNSI;

            PFT  -= cr.PFT;
            LIT  -= cr.LIT;
            HIT  -= cr.HIT;
            PFNT -= cr.PFNT;
            LINT -= cr.LINT;
            HINT -= cr.HINT;

            IINEX_EXP    -= cr.IINEX_EXP;
            IIN          -= cr.IIN;
            CASH         -= cr.CASH;
            CASH_NOTPAID -= cr.CASH_NOTPAID;
        }
示例#3
0
        public PayCalcRow AsCopy(string cap = null)
        {
            var cr = new PayCalcRow(cap);

            cr.SetFrom(this);
            return(cr);
        }
示例#4
0
        public void MakeReportB(KlonsADataSet.PAYLISTS_RRow dr)
        {
            idp = dr.IDP;
            int idam = dr.IDAM;

            Name     = DataTasks.GetPersonName(idp);
            PosTitle = DataTasks.GetPositionTitle(idam);
            Dates1   = Utils.DateToString(dr.PAYLISTSRow.DT);
            Dates2   = Utils.DateToString(dr.DT1) + " - " + Utils.DateToString(dr.DT2);
            var ad  = new KlonsA.DataSets.KlonsARepDataSetTableAdapters.SP_PAY_MATCHLISTS_2XTableAdapter();
            var tab = ad.GetDataBy_SP_PAY_MATCHLISTS_21(dr.ID);

            for (int i = 0; i < tab.Count; i++)
            {
                var dri = tab[i];
                var dts = Utils.DateToString(dri.DT1) + " - " + Utils.DateToString(dri.DT2);
                var cr  = new PayCalcRow(dts);
                cr.SetFrom(dri);
                RepRows.Add(cr);
            }
        }
示例#5
0
        public void SetFrom(PayCalcRow cr)
        {
            ID_P   = cr.ID_P;
            ID_AM  = cr.ID_AM;
            ID_SHR = cr.ID_SHR;

            DT1 = cr.DT1;
            DT2 = cr.DT2;

            IIN_RATE  = cr.IIN_RATE;
            IIN_RATE2 = cr.IIN_RATE2;
            SI_RATE   = cr.SI_RATE;

            PAY_TAXED        = cr.PAY_TAXED;
            PAY_NOSAI        = cr.PAY_NOSAI;
            PAY_NOTTAXED     = cr.PAY_NOTTAXED;
            NOTPAID_TAXED    = cr.NOTPAID_TAXED;
            NOTPAID_NOSAI    = cr.NOTPAID_NOSAI;
            NOTPAID_NOTTAXED = cr.NOTPAID_NOTTAXED;

            UNTAXED_MINIMUM  = cr.UNTAXED_MINIMUM;
            IINEX_DEPENDANTS = cr.IINEX_DEPENDANTS;
            IINEX2           = cr.IINEX2;
            IINEX2_TP        = cr.IINEX2_TP;
            DNSI             = cr.DNSI;

            PFT  = cr.PFT;
            LIT  = cr.LIT;
            HIT  = cr.HIT;
            PFNT = cr.PFNT;
            LINT = cr.LINT;
            HINT = cr.HINT;

            IINEX_EXP    = cr.IINEX_EXP;
            IIN          = cr.IIN;
            CASH         = cr.CASH;
            CASH_NOTPAID = cr.CASH_NOTPAID;

            HAS_TAXDOC = cr.HAS_TAXDOC;
        }
示例#6
0
        public void SetTo(PayFx pfx, PayCalcRow fromsr)
        {
            pfx.Ir  = IIN_RATE / 100.0M;
            pfx.Ir2 = IIN_RATE2 / 100.0M;
            pfx.Sr  = SI_RATE / 100.0M;
            pfx.IM  = PayFx.GetIINMargin(DT1);

            pfx.IinEx =
                fromsr.UNTAXED_MINIMUM +
                fromsr.IINEX_DEPENDANTS +
                fromsr.IINEX2 +
                fromsr.IINEX_EXP;

            pfx.UsedIinEx =
                UNTAXED_MINIMUM +
                IINEX_DEPENDANTS +
                IINEX2 +
                IINEX_EXP;

            pfx.HasProgressiveIIN = DT1 >= PayFx.ProgressiveIINStartDate;
            if (HAS_TAXDOC == null)
            {
                pfx.HasTaxDoc = pfx.IinEx > 0.0M;
            }
            else
            {
                pfx.HasTaxDoc = HAS_TAXDOC.Value;
            }

            pfx.Pay   = PAY_TAXED;
            pfx.PayNs = PAY_NOSAI;
            pfx.PayNt = PAY_NOTTAXED;

            pfx.DNS = DNSI;

            pfx.IIN  = IIN;
            pfx.Cash = CASH;
        }
示例#7
0
        public string Calc1(PayCalcRow sr, PayCalcRow paid, decimal pay, out PayCalcRow rpay)
        {
            rpay = new PayCalcRow();

            rpay.SetFrom(sr);
            rpay.SubtractThat(paid);
            rpay.CASH_REQ = pay;

            if (rpay.CASH == 0.0M)
            {
                return("OK");
            }
            if (rpay.PAY_TAXED == 0.0M && rpay.PAY_NOSAI == 0.0M && rpay.PAY_NOTTAXED == 0.0M)
            {
                return("OK");
            }

            var pfx  = new PayFx();
            var pfx2 = new PayFx();
            var pfx3 = new PayFx();

            paid.SetTo(pfx, sr);
            pfx2.SetFrom(pfx);
            pfx.IncPayByIncCash(pay, rpay.PAY_TAXED, rpay.PAY_NOSAI, rpay.PAY_NOTTAXED);
            pfx3.SetFrom(pfx);
            pfx.CalcAll();
            pfx.Subtract(pfx2);
            rpay.SetFrom(pfx);

            pfx3.Pay   = Math.Min(pfx3.Pay, sr.NOTPAID_TAXED);
            pfx3.PayNs = Math.Min(pfx3.PayNs, sr.NOTPAID_NOSAI);
            pfx3.PayNt = Math.Min(pfx3.PayNt, sr.NOTPAID_NOTTAXED);

            pfx3.CalcAll();
            rpay.CASH_NOTPAID = pfx3.Cash - paid.CASH_NOTPAID;

            return("OK");
        }
示例#8
0
        public string Calc(KlonsADataSet.PAYLISTS_RRow dr,
                           KlonsARepDataSet.SP_PAY_MATCHLISTS_1XRow dr_x)
        {
            var        sr1   = new PayCalcRow();
            var        paid1 = new PayCalcRow();
            PayCalcRow rpay1 = null;
            var        sr2   = new PayCalcRow();
            var        paid2 = new PayCalcRow();
            PayCalcRow rpay2 = null;

            if (PreparingReport)
            {
                idp      = dr.IDP;
                Name     = DataTasks.GetPersonName(idp);
                PosTitle = DataTasks.GetPositionTitle(dr_x.IDAM);
            }

            if (!dr_x.IsIDSHR1Null() && dr.R1 < 1.0f)
            {
                sr1.SetFromA1(dr_x);
                paid1.SetFromA2(dr_x);
                sr1.HAS_TAXDOC   = DataTasks.IsPersonWithTaxDoc(dr.IDP, sr1.DT1, sr1.DT2);
                paid1.HAS_TAXDOC = sr1.HAS_TAXDOC;
                if (PreparingReport)
                {
                    Dates1 = Utils.DateToString(sr1.DT1) + " - " + Utils.DateToString(sr1.DT2);
                    RepRows.Add(new PayCalcRow("Aprēķins 1")
                    {
                        IsTitle = true
                    });
                }
                var ret = Calc2(sr1, paid1, dr_x.PAY1, out rpay1);
                if (ret != "OK")
                {
                    if (!PreparingReport)
                    {
                        PayCalcRow.Empty.WriteTo1(dr);
                    }
                    return(ret);
                }
                if (!PreparingReport)
                {
                    rpay1.WriteTo1(dr);
                }
            }
            else
            {
                if (!PreparingReport)
                {
                    PayCalcRow.Empty.WriteTo1(dr);
                }
            }

            if (!dr_x.IsIDSHR2Null() && dr.R2 < 1.0f)
            {
                sr2.SetFromB1(dr_x);
                paid2.SetFromB2(dr_x);
                sr2.HAS_TAXDOC   = DataTasks.IsPersonWithTaxDoc(dr.IDP, sr2.DT1, sr2.DT2);
                paid2.HAS_TAXDOC = sr2.HAS_TAXDOC;
                if (PreparingReport)
                {
                    Dates2 = Utils.DateToString(sr2.DT1) + " - " + Utils.DateToString(sr2.DT2);
                    RepRows.Add(new PayCalcRow("Aprēķins 2")
                    {
                        IsTitle = true
                    });
                }
                var ret = Calc2(sr2, paid2, dr_x.PAY2, out rpay2);
                if (ret != "OK")
                {
                    if (!PreparingReport)
                    {
                        PayCalcRow.Empty.WriteTo2(dr);
                    }
                    return(ret);
                }
                if (!PreparingReport)
                {
                    rpay2.WriteTo2(dr);
                }
            }
            else
            {
                if (!PreparingReport)
                {
                    PayCalcRow.Empty.WriteTo2(dr);
                }
            }

            return("OK");
        }
示例#9
0
        public string Calc2(PayCalcRow sr, PayCalcRow paid, decimal pay, out PayCalcRow rpay)
        {
            sr.CASH_NOTPAID   = sr.RecalcCashNotPaid();
            paid.CASH_NOTPAID = paid.RecalcCashNotPaid();

            rpay = new PayCalcRow();
            rpay.SetFrom(sr);
            rpay.SubtractThat(paid);
            rpay.CASH_REQ = pay;

            decimal paya  = paid.CASH + pay;
            var     paid2 = new PayCalcRow();

            paid2.SetFrom(paid);
            decimal payleft = paya - paid2.CASH;

            if (PreparingReport)
            {
                RepRows.Add(sr.AsCopy("No algas apr."));
                RepRows.Add(paid.AsCopy("Jau izmaksāts"));
                RepRows.Add(rpay.AsCopy("Atlicis"));
            }
            int ct1 = 0;

            if (PreparingReport)
            {
                ct1 = RepRows.Count;
            }


            if (rpay.CASH <= payleft)
            {
                var rpay0 = new PayCalcRow();
                rpay0.SetFrom(rpay);
                paid2.AddThat(rpay0);
                rpay.SetFrom(rpay0);

                if (PreparingReport)
                {
                    RepRows.Add(rpay0.AsCopy("Aprēķins"));
                    RepRows.Add(paid2.AsCopy("Pēc aprēķina"));
                }
                return("OK");
            }

            if (rpay.PAY_TAXED == 0.0M && rpay.PAY_NOSAI == 0.0M && rpay.PAY_NOTTAXED == 0.0M)
            {
                rpay = new PayCalcRow();
                return("OK");
            }

            //not-paid-not-taxed-PF-LI-HI
            var     rpayNPNT = new PayCalcRow();
            decimal npnt     = rpay.PFNT + rpay.LINT + rpay.HINT;
            decimal npnt2    = Math.Min(npnt, pay);

            if (npnt2 > 0.0M)
            {
                rpayNPNT.PAY_NOTTAXED     = npnt2;
                rpayNPNT.NOTPAID_NOTTAXED = npnt2;
                rpayNPNT.PFNT             = rpay.PFNT;
                rpayNPNT.LINT             = rpay.LINT;
                rpayNPNT.HINT             = rpay.HINT;
                if (npnt2 < npnt)
                {
                    decimal x = npnt2 / npnt;
                    rpayNPNT.PFNT *= x;
                    rpayNPNT.LINT *= x;
                    rpayNPNT.HINT *= x;
                }
                rpayNPNT.CASH         = npnt2;
                rpayNPNT.CASH_NOTPAID = npnt2;

                paid2.AddThat(rpayNPNT);
                rpay.SetFrom(sr);
                rpay.SubtractThat(paid2);
                payleft = paya - paid2.CASH;

                if (PreparingReport)
                {
                    RepRows.Add(rpayNPNT.AsCopy("Neapl.iemaks.PF"));
                    RepRows.Add(paid2.AsCopy("Pēc neapl.iemaks.PF"));
                }


                if (rpay.CASH <= payleft)
                {
                    var rpay0 = new PayCalcRow();
                    rpay0.SetFrom(rpay);
                    paid2.AddThat(rpay0);
                    paid2.RecalcAndRound();
                    rpay.SetFrom(paid2);
                    rpay.SubtractThat(paid);

                    if (PreparingReport)
                    {
                        RepRows.Add(rpay0.AsCopy("Aprēķins"));
                        RepRows.Add(paid2.AsCopy("Pēc aprēķina"));
                    }
                    return("OK");
                }

                if (rpay.PAY_TAXED == 0.0M && rpay.PAY_NOSAI == 0.0M && rpay.PAY_NOTTAXED == 0.0M)
                {
                    paid2.RecalcAndRound();
                    rpay.SetFrom(paid2);
                    rpay.SubtractThat(paid);
                    return("OK");
                }
            }


            //not-paid-whats-left
            PayCalcRow rpayNP = null;
            decimal    np     = rpay.NOTPAID_TAXED + rpay.NOTPAID_NOSAI + rpay.NOTPAID_NOTTAXED;

            if (np > 0.0M)
            {
                var srNP = new PayCalcRow();
                srNP.SetFrom(sr);

                srNP.PAY_TAXED    = rpay.NOTPAID_TAXED;
                srNP.PAY_NOSAI    = rpay.NOTPAID_NOSAI;
                srNP.PAY_NOTTAXED = rpay.NOTPAID_NOTTAXED;

                srNP.NOTPAID_TAXED    = rpay.NOTPAID_TAXED;
                srNP.NOTPAID_NOSAI    = rpay.NOTPAID_NOSAI;
                srNP.NOTPAID_NOTTAXED = rpay.NOTPAID_NOTTAXED;

                Calc1(srNP, paid2, pay - rpayNPNT.CASH, out rpayNP);
                paid2.AddThat(rpayNP);
                rpay.SetFrom(paid2);
                rpay.SubtractThat(paid);
                payleft = paya - paid2.CASH;

                if (PreparingReport)
                {
                    RepRows.Add(rpayNP.AsCopy("Neizm."));
                    RepRows.Add(paid2.AsCopy("Pēc neizm."));
                }

                if (rpay.CASH <= payleft)
                {
                    var rpay0 = new PayCalcRow();
                    rpay0.SetFrom(rpay);
                    paid2.AddThat(rpay0);
                    paid2.RecalcAndRound();
                    rpay.SetFrom(paid2);
                    rpay.SubtractThat(paid);

                    if (PreparingReport)
                    {
                        RepRows.Add(rpay0.AsCopy("Aprēķins"));
                        RepRows.Add(paid2.AsCopy("Pēc aprēķina"));
                    }
                    return("OK");
                }

                if (rpay.PAY_TAXED == 0.0M && rpay.PAY_NOSAI == 0.0M && rpay.PAY_NOTTAXED == 0.0M)
                {
                    paid2.RecalcAndRound();
                    rpay.SetFrom(paid2);
                    rpay.SubtractThat(paid);
                    return("OK");
                }
            }

            //paid
            PayCalcRow rpayP = null;

            Calc1(sr, paid2, paya - paid2.CASH, out rpayP);
            paid2.AddThat(rpayP);

            if (PreparingReport)
            {
                RepRows.Add(rpayP.AsCopy("Aprēķins"));
                RepRows.Add(paid2.AsCopy("Pēc aprēķina"));
            }

            paid2.RecalcAndRound();
            rpay.SetFrom(paid2);
            rpay.SubtractThat(paid);

            if (PreparingReport && ct1 > RepRows.Count + 2)
            {
                RepRows.Add(rpay.AsCopy("Kopā aprēķins"));
            }


            return("OK");
        }