コード例 #1
0
        public void MakeColumnHeadersA(CalendarMonthInfo calmt)
        {
            string[] daystr = SomeDataDefs.GetDaysStr(calmt.WeekDays);
            for (int i = 0; i < 31; i++)
            {
                var s  = daystr[i] + "\n" + (i + 1);
                var d1 = calmt.WeekDays[i];
                if (d1 == -1)
                {
                    s = "";
                }
                Headers[i] = s;

                var hd  = calmt.HolyDays[i];
                var col = HeaderEmptyColor;
                if (hd == EHolyDay.Holiday)
                {
                    col = HeaderHolyDay;
                }
                else if (d1 == 6 || d1 == 7)
                {
                    col = HeaderWeekEndDay;
                }
                HeaderColors[i] = ColorTranslator.ToHtml(col);
            }
        }
コード例 #2
0
ファイル: TimeSheetRowSetList.cs プロジェクト: Camel-RD/Klons
        public void CountSickDays2(DateTime dt1, DateTime dt2,
                                   out int sickdaysA, out int sickdaysB, out int sickdaysN)
        {
            int i1 = dt1.Day;
            int i2 = dt2.Day;

            sickdaysA = 0;
            sickdaysB = 0;
            sickdaysN = 0;

            for (int i = i1; i <= i2; i++)
            {
                bool factdayadded = false;

                for (int j = 0; j < this.Count; j++)
                {
                    var dlset = this[j];

                    var daycodeplan = dlset.Plan.DxPlan[i - 1];
                    var daycodefact = dlset.Fact.DxFact[i - 1];

                    if (daycodeplan == EDayPlanId.None)
                    {
                        continue;
                    }
                    if (daycodefact == EDayFactId.X || daycodefact == EDayFactId.None)
                    {
                        continue;
                    }

                    var isPlanWorkDay = daycodeplan == EDayPlanId.DD || daycodeplan == EDayPlanId.DDSD;

                    var isFactSickDay = SomeDataDefs.IsSickDay(daycodefact);

                    if (!isPlanWorkDay)
                    {
                        continue;
                    }

                    if (!factdayadded && isFactSickDay)
                    {
                        if (daycodefact == EDayFactId.SA)
                        {
                            sickdaysA++;
                        }
                        if (daycodefact == EDayFactId.SB)
                        {
                            sickdaysB++;
                        }
                        if (daycodefact == EDayFactId.SN)
                        {
                            sickdaysN++;
                        }
                        factdayadded = true;
                    }
                }
            }
        }
コード例 #3
0
        public string FormatCell(float v, short daycode, EKind1 kind1)
        {
            string ret = v.ToString();

            if (SomeDataDefs.IsKindPlan(kind1))
            {
                var daycodeplan = (EDayPlanId)daycode;
                if (daycodeplan == EDayPlanId.DD)
                {
                    return(ret);
                }
                string daystr = SomeDataDefs.GetPlanIdStr(daycodeplan);
                if (daycodeplan == EDayPlanId.BD || daycodeplan == EDayPlanId.SD)
                {
                    if (v == 0.0f)
                    {
                        ret = string.Format("{0}", daystr);
                    }
                    else
                    {
                        ret = string.Format("{0} {1}", daystr, v);
                    }
                    return(ret);
                }
                ret = string.Format("{0} {1}", daystr, v);
                return(ret);
            }

            if (kind1 == EKind1.Fact)
            {
                var daycodefact = (EDayFactId)daycode;
                if (daycodefact == EDayFactId.D)
                {
                    return(ret);
                }
                string daystr = SomeDataDefs.GetFactIdStr(daycodefact);
                if (v == 0.0f)
                {
                    ret = daystr;
                }
                else
                {
                    ret = string.Format("{0} {1}", daystr, v);
                }
                return(ret);
            }

            if (v == 0.0f)
            {
                return("");
            }
            return(ret);
        }
コード例 #4
0
ファイル: TimeSheetRowSetList.cs プロジェクト: Camel-RD/Klons
        public void CountVacationTime(DateTime dt1, DateTime dt2, out int days, out float hours)
        {
            int   i1 = dt1.Day;
            int   i2 = dt2.Day;
            float vp;

            days  = 0;
            hours = 0.0f;

            for (int i = i1; i <= i2; i++)
            {
                bool factdayadded = false;

                for (int j = 0; j < this.Count; j++)
                {
                    var dlset = this[j];

                    var daycodeplan = dlset.Plan.DxPlan[i - 1];
                    var daycodefact = dlset.Fact.DxFact[i - 1];

                    if (daycodeplan == EDayPlanId.None)
                    {
                        continue;
                    }
                    if (daycodefact == EDayFactId.X || daycodefact == EDayFactId.None)
                    {
                        continue;
                    }

                    var isPlanWorkDay      = daycodeplan == EDayPlanId.DD || daycodeplan == EDayPlanId.DDSD;
                    var isFactPaidVacation = SomeDataDefs.IsDayPaidVacation(daycodefact);

                    if (!isPlanWorkDay || !isFactPaidVacation)
                    {
                        continue;
                    }

                    vp = dlset.Plan.Vx[i - 1];

                    hours += vp;

                    if (!factdayadded)
                    {
                        days        += 1;
                        factdayadded = true;
                    }
                }
            }
        }
コード例 #5
0
 public void MakeColumnHeaders(CalendarMonthInfo calmt, TimeReportRow1 row)
 {
     string[] daystr = SomeDataDefs.GetDaysStr(calmt.WeekDays);
     for (int i = 0; i < 31; i++)
     {
         var s  = daystr[i] + "\n" + (i + 1);
         var d1 = calmt.WeekDays[i];
         if (d1 == -1)
         {
             s = "";
         }
         row.DX[i] = s;
     }
     row.RowType = 1;
     row.K1      = "Σ";
 }
コード例 #6
0
        public static bool ParseFactDayStr(string fs, out EDayFactId daycode, out float hours)
        {
            daycode = EDayFactId.None;
            hours   = 0.0f;
            int v, k = -1;

            for (int i = 0; i < fs.Length; i++)
            {
                var c = fs.Substring(i, 1);
                if (int.TryParse(c, out v))
                {
                    k = i;
                    break;
                }
            }

            if (k == -1)
            {
                hours   = 0.0f;
                daycode = SomeDataDefs.GetFactStrId(fs.Trim().ToUpper());
                if (daycode == EDayFactId.Error)
                {
                    return(false);
                }
                return(true);
            }

            if (k > 0)
            {
                var daystr = fs.Substring(0, k).Trim().ToUpper();
                daycode = SomeDataDefs.GetFactStrId(daystr);
                if (daycode == EDayFactId.Error)
                {
                    return(false);
                }
            }
            else
            {
                daycode = EDayFactId.None;
            }
            var hoursstr = fs.Substring(k).Trim();

            return(float.TryParse(hoursstr, out hours));
        }
コード例 #7
0
ファイル: TimeSheetRowSetList.cs プロジェクト: Camel-RD/Klons
        public int CountVacationDays(DateTime dt1, DateTime dt2)
        {
            int i1  = dt1.Day;
            int i2  = dt2.Day;
            int ret = 0;

            for (int i = i1; i <= i2; i++)
            {
                bool factdayadded = false;

                for (int j = 0; j < this.Count; j++)
                {
                    var dlset = this[j];

                    var daycodeplan = dlset.Plan.DxPlan[i - 1];
                    var daycodefact = dlset.Fact.DxFact[i - 1];

                    if (daycodeplan == EDayPlanId.None)
                    {
                        continue;
                    }
                    if (daycodefact == EDayFactId.X || daycodefact == EDayFactId.None)
                    {
                        continue;
                    }

                    var isPlanWorkDay = daycodeplan == EDayPlanId.DD || daycodeplan == EDayPlanId.DDSD;

                    var isFactPaidVacation = SomeDataDefs.IsDayPaidVacation(daycodefact);

                    if (!isPlanWorkDay)
                    {
                        continue;
                    }

                    if (!factdayadded && isFactPaidVacation)
                    {
                        ret         += 1;
                        factdayadded = true;
                    }
                }
            }
            return(ret);
        }
コード例 #8
0
        public Color ColorCell(float v, short daycode, EKind1 kind1)
        {
            if (SomeDataDefs.IsKindPlan(kind1))
            {
                var daycodeplan = (EDayPlanId)daycode;

                switch (daycodeplan)
                {
                case EDayPlanId.BD:
                    return(FreeDay);

                case EDayPlanId.SD:
                case EDayPlanId.SDDD:
                case EDayPlanId.DDSD:
                    return(HolyDay);

                default:
                    return(Color.Empty);
                }
            }
            else
            {
                var daycodefact = (EDayFactId)daycode;
                if (SomeDataDefs.IsDayVacation(daycodefact))
                {
                    return(VacationDay);
                }
                if (SomeDataDefs.IsSickDay(daycodefact))
                {
                    return(SickDay);
                }
                if (daycodefact == EDayFactId.B)
                {
                    return(FreeDay);
                }
                if (daycodefact == EDayFactId.S || daycodefact == EDayFactId.DS ||
                    daycodefact == EDayFactId.KS || daycodefact == EDayFactId.V)
                {
                    return(HolyDay);
                }

                return(Color.Empty);
            }
        }
コード例 #9
0
        public string CheckVacationTimePlan(int idam)
        {
            var dt1  = SalarySheet.DT1;
            var dt2  = SalarySheet.DT2;
            var mdt1 = SalarySheet.MDT1;
            var mdt2 = SalarySheet.MDT2;

            var ps = Events.Vacations.LinkedPeriods.Where(
                d =>
            {
                if (!SomeDataDefs.IsEventPaidVacation(d.EEventId))
                {
                    return(false);
                }

                var dr_not = (d.Item1 as KlonsADataSet.EVENTSRow);
                if (dr_not.IsDATE3Null())
                {
                    return(false);
                }

                return((d.DateFirst <= dt2 && d.DateLast >= dt1) ||
                       (dr_not.DATE3 >= dt1 && dr_not.DATE3 <= dt2));
            }).ToArray();


            if (ps.Length == 0)
            {
                return("OK");
            }

            var ps_next = ps.Where(
                d =>
            {
                var dr_not = (d.Item1 as KlonsADataSet.EVENTSRow);
                if (dr_not.IsDATE3Null())
                {
                    return(false);
                }
                return((d.DateLast > dt2) &&
                       (dr_not.DATE3 >= dt1 && dr_not.DATE3 <= dt2));
            }).ToArray();


            foreach (var pi in ps_next)
            {
                var dtp1 = dt2.AddDays(1);
                var dtp2 = pi.DateLast;
                if (dtp1 < pi.DateFirst)
                {
                    dtp1 = pi.DateFirst;
                }
                var dtpe = dtp1.LastDayOfMonth();
                if (dtp2 > dtpe)
                {
                    dtp2 = dtpe;
                }

                while (true)
                {
                    int addmt = Utils.MonthDiff(dt1, dtp1);

                    var nextdlrowset = GetDLRowSet(addmt, idam);
                    if (nextdlrowset == null || nextdlrowset.Plan == null)
                    {
                        return("Atvaļinājumam nav izveidots darba laika plāns.");
                    }

                    if (dtp2 == pi.DateLast)
                    {
                        break;
                    }

                    dtp1 = dtpe.AddDays(1);
                    dtp2 = pi.DateLast;
                    dtpe = dtp1.LastDayOfMonth();
                    if (dtp2 > dtpe)
                    {
                        dtp2 = dtpe;
                    }
                }
            }

            return("OK");
        }
コード例 #10
0
ファイル: TimeSheetRowSetList.cs プロジェクト: Camel-RD/Klons
        public ErrorList CountTotalPlan(IWorkTimeData wt, DateTime dt1, DateTime dt2)
        {
            var        error_list = new ErrorList();
            string     errstr = string.Format("{0}.{1}", dt1.Year, dt1.Month);
            int        i, j;
            float      vp, vpn;
            int        i1          = dt1.Day;
            int        i2          = dt2.Day;
            EDayPlanId daycodeplan = EDayPlanId.None;
            EDayFactId daycodefact = EDayFactId.None;

            for (i = i1; i <= i2; i++)
            {
                bool plandayadded     = false;
                bool planworkdayadded = false;

                for (j = 0; j < this.Count; j++)
                {
                    var dlset = this[j];

                    daycodeplan = dlset.Plan.DxPlan[i - 1];
                    daycodefact = dlset.Fact.DxFact[i - 1];

                    if (daycodeplan == EDayPlanId.None)
                    {
                        continue;
                    }
                    if (daycodefact == EDayFactId.None || daycodefact == EDayFactId.X)
                    {
                        continue;
                    }

                    vp  = dlset.Plan.Vx[i - 1];
                    vpn = dlset.PlanNight == null ? 0.0f : dlset.PlanNight.Vx[i - 1];

                    if (vp + vpn == 0.0f)
                    {
                        continue;
                    }

                    if (!plandayadded)
                    {
                        wt._PLAN_DAYS++;
                    }
                    wt._PLAN_HOURS       += vp;
                    wt._PLAN_HOURS_NIGHT += vpn;

                    if (SomeDataDefs.IsPlanWorkday(daycodeplan) &&
                        (SomeDataDefs.IsDayForWork(daycodefact) || daycodefact == EDayFactId.B))
                    {
                        if (!planworkdayadded)
                        {
                            wt._PLAN_WORK_DAYS++;
                        }
                        wt._PLAN_WORK_HOURS       += vp;
                        wt._PLAN_WORK_HOURS_NIGHT += vpn;
                        planworkdayadded           = true;
                    }

                    if (daycodeplan == EDayPlanId.DDSD)
                    {
                        if (!plandayadded)
                        {
                            wt._PLAN_HOLIDAYS_DAYS++;
                        }
                        wt._PLAN_HOLIDAYS_HOURS       += vp;
                        wt._PLAN_HOLIDAYS_HOURS_NIGHT += vpn;
                    }

                    plandayadded = true;
                }
            }

            return(error_list);
        }
コード例 #11
0
ファイル: TimeSheetRowSetList.cs プロジェクト: Camel-RD/Klons
        public ErrorList CountTotalFact(IWorkTimeData wt, DateTime dt1, DateTime dt2)
        {
            var        error_list = new ErrorList();
            string     errstr = string.Format("{0}.{1}", dt1.Year, dt1.Month);
            int        i, j;
            float      v, vn, vo, vp;
            int        i1          = dt1.Day;
            int        i2          = dt2.Day;
            EDayPlanId daycodeplan = EDayPlanId.None;
            EDayFactId daycodefact = EDayFactId.None;

            for (i = i1; i <= i2; i++)
            {
                bool factdayadded = false;

                for (j = 0; j < this.Count; j++)
                {
                    var dlset = this[j];

                    daycodeplan = dlset.Plan.DxPlan[i - 1];
                    daycodefact = dlset.Fact.DxFact[i - 1];

                    if (daycodeplan == EDayPlanId.None)
                    {
                        continue;
                    }
                    if (daycodefact == EDayFactId.X || daycodefact == EDayFactId.None)
                    {
                        continue;
                    }

                    bool isFactHolidayWithBonus = daycodefact == EDayFactId.DS ||
                                                  daycodefact == EDayFactId.KS;
                    bool isAvPayFreeDay = daycodefact == EDayFactId.S ||
                                          daycodefact == EDayFactId.V || daycodefact == EDayFactId.AM;
                    //bool isAvPayWorkDay = daycodefact == EDayFactId.K;
                    bool isAvPayWorkDay = false;
                    bool IsFactWorkDay  = SomeDataDefs.IsDayForWork(daycodefact);


                    v  = dlset.Fact.Vx[i - 1];
                    vn = dlset.FactNight == null ? 0.0f : dlset.FactNight.Vx[i - 1];
                    vo = dlset.FactOvertime == null ? 0.0f : dlset.FactOvertime.Vx[i - 1];
                    vp = dlset.Plan.Vx[i - 1];

                    if (v + vp == 0)
                    {
                        continue;
                    }

                    if (isAvPayFreeDay)
                    {
                        if (vp == 0.0f)
                        {
                            continue;
                        }
                        if (!factdayadded)
                        {
                            wt._FACT_AVPAY_FREE_DAYS++;
                        }
                        wt._FACT_AVPAY_FREE_HOURS += vp;
                        wt._FACT_HOURS            += vp;

                        if (!factdayadded)
                        {
                            wt._FACT_DAYS++;
                        }

                        factdayadded = true;
                        continue;
                    }

                    if (!IsFactWorkDay)
                    {
                        continue;
                    }
                    if (v == 0)
                    {
                        continue;
                    }

                    wt._FACT_HOURS          += v;
                    wt._FACT_HOURS_NIGHT    += vn;
                    wt._FACT_HOURS_OVERTIME += vo;

                    if (isAvPayWorkDay)
                    {
                        if (!factdayadded)
                        {
                            wt._FACT_AVPAY_WORK_DAYS++;
                        }
                        wt._FACT_AVPAY_HOURS          += v;
                        wt._FACT_AVPAY_HOURS_OVERTIME += vo;

                        if (isFactHolidayWithBonus)
                        {
                            if (!factdayadded)
                            {
                                wt._FACT_AVPAY_WORKINHOLIDAYS++;
                            }
                            wt._FACT_AVPAY_HOLIDAYS_HOURS       += v;
                            wt._FACT_AVPAY_HOLIDAYS_HOURS_OVERT += vo;
                        }

                        if (!factdayadded)
                        {
                            wt._FACT_DAYS++;
                        }
                        factdayadded = true;
                        continue;
                    }

                    if (!factdayadded)
                    {
                        wt._FACT_WORK_DAYS++;
                    }
                    wt._FACT_WORK_HOURS          += v;
                    wt._FACT_WORK_HOURS_NIGHT    += vn;
                    wt._FACT_WORK_HOURS_OVERTIME += vo;

                    if (isFactHolidayWithBonus)
                    {
                        if (!factdayadded)
                        {
                            wt._FACT_HOLIDAYS_DAYS++;
                        }
                        wt._FACT_HOLIDAYS_HOURS          += v;
                        wt._FACT_HOLIDAYS_HOURS_NIGHT    += vn;
                        wt._FACT_HOLIDAYS_HOURS_OVERTIME += vo;
                    }

                    if (!factdayadded)
                    {
                        wt._FACT_DAYS++;
                    }
                    factdayadded = true;
                }
            }

            return(error_list);
        }
コード例 #12
0
ファイル: TimeSheetRowSetList.cs プロジェクト: Camel-RD/Klons
        public ErrorList CheckDays(SalaryInfo wt, DateTime dt1, DateTime dt2, int idp)
        {
            var        error_list = new ErrorList();
            string     errstr = string.Format("{0}.{1}", dt1.Year, dt1.Month);
            int        i, j;
            int        i1           = dt1.Day;
            int        i2           = dt2.Day;
            EDayPlanId daycodeplan  = EDayPlanId.None;
            EDayFactId daycodefact  = EDayFactId.None;
            EDayPlanId daycodeplan2 = EDayPlanId.None;
            EDayFactId daycodefact2 = EDayFactId.None;
            bool       iscodeset;

            for (i = i1; i <= i2; i++)
            {
                iscodeset = false;
                for (j = 0; j < this.Count; j++)
                {
                    daycodeplan = this[j].Plan.DxPlan[i - 1];
                    if (!iscodeset)
                    {
                        daycodeplan2 = daycodeplan;
                        iscodeset    = true;
                        continue;
                    }
                    if (daycodeplan != daycodeplan2)
                    {
                        var errs = string.Format("{0} nesakrīt darba laika plāna dati dažādiem amatiem dienai: {1}", errstr, i);
                        error_list.AddPersonError(idp, errs);
                    }
                }
                iscodeset = false;
                for (j = 0; j < this.Count; j++)
                {
                    daycodefact = this[j].Fact.DxFact[i - 1];
                    daycodeplan = this[j].Plan.DxPlan[i - 1];
                    if (daycodefact == EDayFactId.X || daycodefact == EDayFactId.None)
                    {
                        continue;
                    }
                    if (!iscodeset)
                    {
                        daycodefact2 = daycodefact;
                        daycodeplan2 = daycodeplan;
                        iscodeset    = true;

                        if (!SomeDataDefs.CanPlanHaveFact(daycodeplan, daycodefact))
                        {
                            var errs = string.Format("{0} nekorekts faktiski nostrādās dienas kods: {1}", errstr, i);
                            error_list.AddPersonError(idp, errs);
                        }

                        continue;
                    }

                    bool b1 = SomeDataDefs.IsSickDay(daycodefact) ||
                              SomeDataDefs.IsDayVacation(daycodefact) ||
                              daycodefact == EDayFactId.V;

                    bool b2 = SomeDataDefs.IsSickDay(daycodefact2) ||
                              SomeDataDefs.IsDayVacation(daycodefact2) ||
                              daycodefact2 == EDayFactId.V;

                    if (b1 != b2)
                    {
                        var errs = string.Format("{0} nesakrīt darba laika dati dažādiem amatiem dienai: {1}", errstr, i);
                        error_list.AddPersonError(idp, errs);
                    }
                }
            }

            return(error_list);
        }
コード例 #13
0
        public ErrorList CalcVacationDays2(SalarySheetRowInfo srs, VacationCalcInfo[] vcs, int calcver)
        {
            var error_list = new ErrorList();

            if (vcs != null && srs != srs?.SalarySheetRowSet?.TotalRow)
            {
                throw new ArgumentException("Bad call.");
            }

            var dt1  = srs.SalarySheet.DT1;
            var dt2  = srs.SalarySheet.DT2;
            var mdt1 = srs.SalarySheet.MDT1;
            var mdt2 = srs.SalarySheet.MDT2;

            var ps = srs.Events.Vacations.LinkedPeriods.Where(
                d =>
            {
                if (!SomeDataDefs.IsEventPaidVacation(d.EEventId))
                {
                    return(false);
                }

                var dr_not = (d.Item1 as KlonsADataSet.EVENTSRow);
                if (dr_not.IsDATE3Null())
                {
                    return(false);
                }

                return((d.DateFirst <= dt2 && d.DateLast >= dt1) ||
                       (dr_not.DATE3 >= dt1 && dr_not.DATE3 <= dt2));
            }).ToArray();


            // kompensācija atlaižot
            var fire_evs = srs.Events.HireFire.LinkedPeriods
                           .Where(d => d.DateLast >= dt1 && d.DateLast <= dt2)
                           .ToArray();

            if (ps.Length == 0 && fire_evs.Length == 0)
            {
                return(error_list);
            }

            var ps_cur = ps.Where(
                d =>
                d.DateFirst <= dt2 && d.DateLast >= dt1
                ).ToArray();

            var ps_next = ps.Where(
                d =>
            {
                var dr_not = (d.Item1 as KlonsADataSet.EVENTSRow);
                if (dr_not.IsDATE3Null())
                {
                    return(false);
                }
                return((d.DateLast > dt2) &&
                       (dr_not.DATE3 >= dt1 && dr_not.DATE3 <= dt2));
            }).ToArray();

            var ps_prev = ps_cur.Where(
                d =>
            {
                var dr_not = (d.Item1 as KlonsADataSet.EVENTSRow);
                if (dr_not.IsDATE3Null())
                {
                    return(false);
                }
                return(dr_not.DATE3 < dt1);
            }).ToArray();



            SalaryInfo prevsi = srs.GetPrevRow();

            if (prevsi != null)
            {
                VcrPrev.Pay = prevsi._VACATION_PAY_NEXT;
                VcrPrev.DNS = prevsi._VACATION_DNS_NEXT;
                VcrPrev.IIN = prevsi._VACATION_IIN_NEXT;
                AdvancePrev = prevsi._VACATION_ADVANCE_NEXT;

                if (vcs != null)
                {
                    for (int i = 0; i < vcs.Length; i++)
                    {
                        var vci = vcs[i];
                        if (vci == null)
                        {
                            continue;
                        }
                        var sr      = srs.SalarySheetRowSet.LinkedRows[i];
                        var prevsi2 = sr.GetPrevRow();
                        if (prevsi2 == null)
                        {
                            continue;
                        }
                        vci.VcrPrev.Pay = prevsi._VACATION_PAY_NEXT;
                        vci.VcrPrev.DNS = prevsi._VACATION_DNS_NEXT;
                        vci.VcrPrev.IIN = prevsi._VACATION_IIN_NEXT;
                        vci.AdvancePrev = prevsi._VACATION_ADVANCE_NEXT;
                    }
                }
            }

            error_list += GetAvPayCalc(srs);
            if (error_list.HasErrors)
            {
                return(error_list);
            }

            float               caldays   = 0;
            VacationCalcRow     vt        = new VacationCalcRow();
            VacationCalcRow     v         = new VacationCalcRow();
            TimeSheetRowSetList dlrowsetT = null;
            TimeSheetRowSet     dlrowset  = null;
            decimal             r         = 0.0M;

            decimal _AvPayRate = AvPayRateDay;

            if (IsAggregatedTimeRate(srs))
            {
                _AvPayRate = AvPayRateCalendarDay;
            }
            vt.AvPayRate = _AvPayRate;

            caldays = 0;
            foreach (var pi in ps_prev)
            {
                vt.DateStart = pi.DateFirst;
                vt.DateEnd   = pi.DateLast;
                if (vt.DateStart < dt1)
                {
                    vt.DateStart = dt1;
                }
                if (vt.DateEnd > dt2)
                {
                    vt.DateEnd = dt2;
                }

                if (dlrowsetT == null)
                {
                    dlrowsetT = srs.GetDLRowSetList();
                }
                dlrowsetT.CountVacationTime(vt);
                caldays += (vt.DateEnd - vt.DateStart).Days + 1;
                VcrPrevCurrent.CalcAndAdd(srs, vt, _AvPayRate, CalcVer);

                if (PreparingReport)
                {
                    AddRepRow(vt, "A", "Kopā");
                }

                if (vcs != null)
                {
                    v.DateStart = vt.DateStart;
                    v.DateEnd   = vt.DateEnd;

                    int ct = vcs.Where(d => d != null).Count();

                    for (int i = 0; i < vcs.Length; i++)
                    {
                        var vci = vcs[i];
                        if (vci == null)
                        {
                            continue;
                        }
                        var sr = srs.SalarySheetRowSet.LinkedRows[i];
                        dlrowset = dlrowsetT[i];
                        dlrowset.CountVacationTime(v);

                        if (vt.Hours == 0.0f)
                        {
                            r = 1.0M / (decimal)ct;
                        }
                        else
                        {
                            r = (decimal)(v.Hours / vt.Hours);
                        }

                        v.Pay = KlonsData.RoundA(vt.Pay * r, 2);
                        vci.VcrPrevCurrent.CalcAndAddSplit(sr, v, CalcVer);

                        if (PreparingReport)
                        {
                            vci.AddRepRow(vt, "A", sr.GetPositionTitle());
                        }
                    }
                }
            }

            caldays = 0;
            foreach (var pi in ps_cur)
            {
                vt.DateStart = pi.DateFirst;
                vt.DateEnd   = pi.DateLast;
                if (vt.DateStart < dt1)
                {
                    vt.DateStart = dt1;
                }
                if (vt.DateEnd > dt2)
                {
                    vt.DateEnd = dt2;
                }

                if (dlrowsetT == null)
                {
                    dlrowsetT = srs.GetDLRowSetList();
                }
                dlrowsetT.CountVacationTime(vt);
                caldays += (vt.DateEnd - vt.DateStart).Days + 1;
                VcrCurrent.CalcAndAdd(srs, vt, _AvPayRate, CalcVer);

                if (PreparingReport)
                {
                    AddRepRow(vt, "B", "Kopā");
                }

                if (vcs != null)
                {
                    v.DateStart = vt.DateStart;
                    v.DateEnd   = vt.DateEnd;

                    int ct = vcs.Where(d => d != null).Count();

                    for (int i = 0; i < vcs.Length; i++)
                    {
                        var vci = vcs[i];
                        if (vci == null)
                        {
                            continue;
                        }
                        var sr = srs.SalarySheetRowSet.LinkedRows[i];

                        dlrowset = dlrowsetT[i];
                        dlrowset.CountVacationTime(v);

                        if (vt.Hours == 0.0f)
                        {
                            r = 1.0M / (decimal)ct;
                        }
                        else
                        {
                            r = (decimal)(v.Hours / vt.Hours);
                        }

                        v.Pay = KlonsData.RoundA(vt.Pay * r, 2);
                    }

                    Utils.MakeExactSum(vt.Pay, vcs,
                                       d => d.VcrCurrent.Pay,
                                       (d, val) => d.VcrCurrent.Pay = val);

                    for (int i = 0; i < vcs.Length; i++)
                    {
                        var vci = vcs[i];
                        if (vci == null)
                        {
                            continue;
                        }
                        var sr = srs.SalarySheetRowSet.LinkedRows[i];
                        vci.VcrCurrent.CalcAndAddSplit(sr, v, CalcVer);
                        if (PreparingReport)
                        {
                            vci.AddRepRow(vt, "B", sr.GetPositionTitle());
                        }
                    }
                }
            }

            foreach (var pi in ps_next)
            {
                vt.DateStart = dt2.AddDays(1);
                vt.DateEnd   = pi.DateLast;
                if (vt.DateStart < pi.DateFirst)
                {
                    vt.DateStart = pi.DateFirst;
                }
                var dtpe = vt.DateStart.LastDayOfMonth();
                if (vt.DateEnd > dtpe)
                {
                    vt.DateEnd = dtpe;
                }

                while (true)
                {
                    int addmt = Utils.MonthDiff(dt1, vt.DateStart);

                    var nextdlrowsetT = srs.GetDLRowSetList(addmt);
                    if (nextdlrowsetT.Count == 0)
                    {
                        break;
                    }

                    nextdlrowsetT.CountVacationTime(vt);
                    caldays += (vt.DateEnd - vt.DateStart).Days + 1;
                    VcrNext.CalcAndAddNext(srs, vt, _AvPayRate);

                    if (PreparingReport)
                    {
                        AddRepRow(vt, "C", "Kopā");
                    }


                    if (vcs != null)
                    {
                        v.DateStart = vt.DateStart;
                        v.DateEnd   = vt.DateEnd;

                        int ct = vcs.Where(d => d != null).Count();

                        for (int i = 0; i < vcs.Length; i++)
                        {
                            var vci = vcs[i];
                            if (vci == null)
                            {
                                continue;
                            }
                            var sr = srs.SalarySheetRowSet.LinkedRows[i];

                            var nextdlrowset = nextdlrowsetT[i];
                            if (nextdlrowset == null)
                            {
                                //error_list.AddPersonError(srs.DR_Person_r.ID, )
                            }
                            nextdlrowset.CountVacationTime(v);

                            if (vt.Hours == 0.0f)
                            {
                                r = 1.0M / (decimal)ct;
                            }
                            else
                            {
                                r = (decimal)(v.Hours / vt.Hours);
                            }

                            v.Pay = KlonsData.RoundA(vt.Pay * r, 2);
                        }

                        Utils.MakeExactSum(vt.Pay, vcs,
                                           d => d.VcrNext.Pay,
                                           (d, val) => d.VcrNext.Pay = val);

                        for (int i = 0; i < vcs.Length; i++)
                        {
                            var vci = vcs[i];
                            if (vci == null)
                            {
                                continue;
                            }
                            var sr = srs.SalarySheetRowSet.LinkedRows[i];
                            vci.VcrNext.CalcAndAddNextA(sr, v);
                            if (PreparingReport)
                            {
                                vci.AddRepRow(vt, "C", sr.GetPositionTitle());
                            }
                        }
                    }

                    if (vt.DateEnd == pi.DateLast)
                    {
                        break;
                    }
                    vt.DateStart = dtpe.AddDays(1);
                    vt.DateEnd   = pi.DateLast;
                    dtpe         = dtpe.AddDays(1).LastDayOfMonth();
                    if (vt.DateEnd > dtpe)
                    {
                        vt.DateEnd = dtpe;
                    }
                }
            }

            // kompensācija atlaižot
            vt.Days = 0;
            foreach (var fe in fire_evs)
            {
                var dr_ev = fe.Item2 as KlonsADataSet.EVENTSRow;
                if (dr_ev == null)
                {
                    continue;
                }
                if (calcver == KlonsData.VersionRef(0))
                {
                    vt.Days += dr_ev.DAYS;
                }
                else
                {
                    vt.Days += dr_ev.DAYS2;
                }
            }
            if (vt.Days > 0)
            {
                error_list += GetAvPayCalc(srs);
                if (error_list.HasErrors)
                {
                    return(error_list);
                }

                vt.DateStart = srs.SalarySheet.DT1;
                vt.DateEnd   = srs.SalarySheet.DT2;
                caldays      = vt.Days;
                vt.Hours     = 0.0f;

                VcrCompensation.CalcAndAdd(srs, vt, AvPayRateCalendarDay, CalcVer);

                if (PreparingReport)
                {
                    AddRepRow(vt, "D", "Kopā");
                }

                if (vcs != null)
                {
                    v.DateStart = vt.DateStart;
                    v.DateEnd   = vt.DateEnd;
                    v.Days      = vt.Days;
                    v.Hours     = 0.0f;

                    int ct = vcs.Where(d => d != null).Count();

                    for (int i = 0; i < vcs.Length; i++)
                    {
                        var vci = vcs[i];
                        if (vci == null)
                        {
                            continue;
                        }
                        var sr = srs.SalarySheetRowSet.LinkedRows[i];

                        r     = 1.0M / (decimal)ct;
                        v.Pay = KlonsData.RoundA(vt.Pay * r, 2);
                    }

                    Utils.MakeExactSum(vt.Pay, vcs,
                                       d => d.VcrCompensation.Pay,
                                       (d, val) => d.VcrCompensation.Pay = val);

                    for (int i = 0; i < vcs.Length; i++)
                    {
                        var vci = vcs[i];
                        if (vci == null)
                        {
                            continue;
                        }
                        var sr = srs.SalarySheetRowSet.LinkedRows[i];
                        vci.VcrCompensation.CalcAndAddSplit(sr, v, CalcVer);
                        if (PreparingReport)
                        {
                            vci.AddRepRow(vt, "D", sr.GetPositionTitle());
                        }
                    }
                }
            }

            VcrNext.CalcAll(srs, vcs, CalcVer);

            if (PreparingReport)
            {
                PrepareRows();
            }
            return(error_list);
        }
コード例 #14
0
ファイル: BonusCalcInfo.cs プロジェクト: Camel-RD/Klons
        public PayFx2 AddRow(SalaryInfo si, KlonsADataSet.SALARY_PLUSMINUSRow dr,
                             decimal dfrom, decimal addamount, int divby)
        {
            OrderedDataRows.Add(dr);
            int ind_dr = DataRows.IndexOf(dr);
            var pfx    = BonusPfx[ind_dr];

            switch (dr.XBonusType)
            {
            case EBonusType.NoSAI:
            case EBonusType.AuthorsFees:
            case EBonusType.MinusBeforeIIN:
                //if(dr.AMOUNT != 0.0M) dr.AMOUNT = 0.0M;
                pfx.IinEx     = 0.0M;
                pfx.UsedIinEx = 0.0M;
                return(pfx);
            }

            switch (dr.XBonusType)
            {
            case EBonusType.Taxed:
                si._PLUS_TAXED += addamount;
                pfx.Pay        += addamount;
                break;

            case EBonusType.NoSAI:
                si._PLUS_NOSAI += addamount;
                pfx.PayNs      += addamount;
                break;

            case EBonusType.AuthorsFees:
                si._PLUS_AUTHORS_FEES += addamount;
                pfx.PayNs             += addamount;
                break;

            case EBonusType.NotTaxed:
                si._PLUS_NOTTAXED += addamount;
                pfx.PayNt         += addamount;
                break;

            case EBonusType.MinusBeforeIIN:
                si._MINUS_BEFORE_IIN += addamount;
                break;

            case EBonusType.MinusAfterIIN:
                si._MINUS_AFTER_IIN += addamount;
                pfx.Cash            -= addamount;
                break;

            case EBonusType.PfNotTaxed:
                si._PLUS_PF_NOTTAXED += addamount;
                si._PLUS_NOTTAXED    += addamount;
                pfx.PayNt            += addamount;
                break;

            case EBonusType.PfTaxed:
                si._PLUS_PF_TAXED += addamount;
                si._PLUS_TAXED    += addamount;
                pfx.Pay           += addamount;
                break;

            case EBonusType.LiNotTaxed:
                si._PLUS_LI_NOTTAXED += addamount;
                si._PLUS_NOTTAXED    += addamount;
                pfx.PayNt            += addamount;
                break;

            case EBonusType.LiTaxed:
                si._PLUS_LI_TAXED += addamount;
                si._PLUS_TAXED    += addamount;
                pfx.Pay           += addamount;
                break;

            case EBonusType.HiNotTaxed:
                si._PLUS_HI_NOTTAXED += addamount;
                si._PLUS_NOTTAXED    += addamount;
                pfx.PayNt            += addamount;
                break;

            case EBonusType.HiTaxed:
                si._PLUS_HI_TAXED += addamount;
                si._PLUS_TAXED    += addamount;
                pfx.Pay           += addamount;
                break;

            case EBonusType.ReverseCalc:
                si._PLUS_TAXED += addamount;
                pfx.Pay        += addamount;
                break;
            }

            if (dr.IS_INAVPAY == 1 && dr.XBonusType != EBonusType.MinusAfterIIN)
            {
                ForAvpayCalc += addamount;
            }


            switch (dr.XBonusType)
            {
            case EBonusType.PfTaxed:
            case EBonusType.LiTaxed:
            case EBonusType.HiTaxed:
                NotPaidTaxed      += addamount;
                si._PLUS_NP_TAXED += addamount;
                break;

            case EBonusType.PfNotTaxed:
            case EBonusType.LiNotTaxed:
            case EBonusType.HiNotTaxed:
                NotPaidNotTaxed      += addamount;
                si._PLUS_NP_NOTTAXED += addamount;
                break;
            }

            if (dr.IS_PAID == 0)
            {
                switch (dr.XBonusType)
                {
                case EBonusType.Taxed:
                    NotPaidTaxed      += addamount;
                    si._PLUS_NP_TAXED += addamount;
                    break;

                case EBonusType.ReverseCalc:
                    NotPaidFromEnd     += addamount;
                    NotPaidFromEndCash += dr.RATE / (decimal)divby + GetRoundingError(dr.RATE, divby);
                    si._PLUS_NP_TAXED  += dr.AMOUNT;
                    break;

                case EBonusType.NoSAI:
                case EBonusType.AuthorsFees:
                    NotPaidNoSAI      += dr.AMOUNT;
                    si._PLUS_NP_NOSAI += dr.AMOUNT;
                    break;

                case EBonusType.NotTaxed:
                    NotPaidNotTaxed      += dr.AMOUNT;
                    si._PLUS_NP_NOTTAXED += dr.AMOUNT;
                    break;
                }
            }

            if (PreparingReport)
            {
                var br = new BonusCalcRow();
                br.Caption   = dr.DESCR;
                br.AddTo     = SomeDataDefs.GetEBonusText(dr.XBonusType);
                br.CalcFrom  = SomeDataDefs.GetEBonusFromString(dr.XBonusFrom);
                br.BonusType = dr.XBonusType;
                br.Rate      = dr.RATE;
                if (divby > 1)
                {
                    br.RateType = "1/" + divby;
                }
                else
                {
                    br.RateType = dr.XRateType == EBonusRateType.Money ? "€" : "%";
                }
                br.CalcBase = dfrom;
                br.Pay      = dr.AMOUNT;
                br.InAvPay  = dr.IS_INAVPAY == 1;
                br.IsPaid   = dr.IS_PAID == 1;
                if (br.BonusType == EBonusType.ReverseCalc)
                {
                    br.Cash = dr.RATE / (decimal)divby + GetRoundingError(dr.RATE, divby);
                }
                ReportRows.Add(br);
            }

            return(pfx);
        }