private PeriodInfo GetUntMinFromDB(KlonsADataSet.PERSONSRow drpr, DateTime dt1, DateTime dt2) { var um0 = new UntMinData(); um0.Dt1 = dt1; um0.Dt2 = dt2; var ret = new PeriodInfo(); ret.DateFirst = dt1; ret.DateLast = dt2; var ret2 = new PeriodInfo(); ret2.DateFirst = dt1; ret2.DateLast = dt2; ret2.Item1 = um0; ret.LinkedPeriods.Add(ret2); var pi = new PeriodInfo(); pi.DateFirst = dt1; pi.DateLast = dt2; var drs = drpr.GetUNTAXED_MINRows() .OrderBy(d => d.ONDATE) .ToArray(); if (drs.Length == 0) { return(ret); } var rt = pi.ReadDateListFilter(drs, d => d.ONDATE); if (rt != PeriodInfo.ERetReadStartEndList.OK || pi.LinkedPeriods.Count == 0) { return(ret); } ret.LinkedPeriods.Clear(); foreach (var pi2 in pi.LinkedPeriods) { var dr_untmin = (pi2.Item1 as KlonsADataSet.UNTAXED_MINRow); var um1 = new UntMinData(); um1.Dt1 = pi2.DateFirst; um1.Dt2 = pi2.DateLast; um1.UntMin = dr_untmin.UNTAXED_MIN; um1.IINRateType = dr_untmin.IIN_RATE_TYPE; var pi_out = new PeriodInfo(); pi_out.DateFirst = um1.Dt1; pi_out.DateLast = um1.Dt2; pi_out.Item1 = um1; ret.LinkedPeriods.Add(pi_out); } return(ret); }
public static decimal GetIINUntaxedMinimum2(KlonsADataSet.PERSONSRow drpr, DateTime dt1, DateTime dt2) { var pi = new PeriodInfo(); pi.DateFirst = dt1; pi.DateLast = dt2; var drs = drpr.GetUNTAXED_MINRows() .OrderBy(d => d.ONDATE) .ToArray(); if (drs.Length == 0) { return(0.0M); } var rt = pi.ReadDateListFilter(drs, d => d.ONDATE); if (rt != PeriodInfo.ERetReadStartEndList.OK || pi.LinkedPeriods.Count == 0) { return(0.0M); } decimal daysinmonth = dt1.DaysInMonth(); decimal sum = 0.0M; decimal daysct = 0.0M; foreach (var pi2 in pi.LinkedPeriods) { daysct = (decimal)((pi2.DateLast - pi2.DateFirst).TotalDays + 1); decimal rate = (pi2.Item1 as KlonsADataSet.UNTAXED_MINRow).UNTAXED_MIN; sum += rate * daysct / daysinmonth; } daysct = (decimal)((dt2 - dt1).TotalDays + 1); sum = sum / daysct * daysinmonth; return(sum); }
public ErrorList SetUp(int idp, int idam) { if (SalarySheet == null) { throw new Exception("Bad init."); } var table_sar = MyData.DataSetKlons.SALARY_SHEETS; var table_sar_r = MyData.DataSetKlons.SALARY_SHEETS_R; var table_darba_laiks = MyData.DataSetKlons.TIMESHEET; var table_sh = MyData.DataSetKlons.SALARY_SHEET_TEMPL; var table_sh_r = MyData.DataSetKlons.SALARY_SHEET_TEMPL_R; var table_persons = MyData.DataSetKlons.PERSONS; var table_amati = MyData.DataSetKlons.POSITIONS; var table_dl_sar_r = MyData.DataSetKlons.TIMESHEET_LISTS_R; var error_list = new ErrorList(); string error_source; int yr = SalarySheet.YR; int mt = SalarySheet.MT; var dt1 = SalarySheet.MDT1; var dt2 = SalarySheet.MDT2; //var dv_dl_sar_r = new DataView(table_dl_sar_r); //dv_dl_sar_r.RowFilter = string.Format("Parent(FK_TIMESHEET_LISTS_R_IDS).YR = {0} AND Parent(FK_TIMESHEET_LISTS_R_IDS).MT = {1}", yr, mt); var dr_person = table_persons.FindByID(idp); var dr_amats = table_amati.FindByID(idam); if (dr_person == null) { error_list.AddError("Algas lapa", "Nav darbinieka"); return(error_list); } if (dr_amats == null) { error_list.AddError("Algas lapa", "Nav amata"); return(error_list); } if (DR_salary_sheet_r_templ == null) { error_source = string.Format("Darbinieks :{0} {1} ({2})", dr_person.FNAME, dr_person.LNAME, dr_amats.TITLE); } else { error_source = string.Format("Lapa:{0} rinda:{1}", DR_salary_sheet_r_templ.SALARY_SHEET_TEMPLRow.SNR, DR_salary_sheet_r_templ.SNR); } var drs_persons_r = dr_person.GetPERSONS_RRows().OrderBy(d => d.EDIT_DATE).ToArray(); DR_Person_r = PeriodInfo.FindNearestBefore(drs_persons_r, dt2, d => d.EDIT_DATE); if (DR_Person_r == null) { error_list.AddError(error_source, "Norādītajam periodam nav ievadīti darbinieka dati."); return(error_list); } PersonR.DateFirst = dt1; PersonR.DateLast = dt2; var drs_person_r = dr_person.GetPERSONS_RRows().OrderBy(d => d.EDIT_DATE).ToArray(); //var rete = PersonR.ReadDateListFilter(drs_person_r, d => d.EDIT_DATE); var rete = PersonR.ReadDateListAll(drs_person_r, d => d.EDIT_DATE); if (rete != PeriodInfo.ERetReadStartEndList.OK || PersonR.LinkedPeriods[0].DateFirst > dt2) { error_list.AddError(error_source, "Norādītajam periodam nav ievadīti darbinieka dati."); return(error_list); } PositionsR.DateFirst = dt1; PositionsR.DateLast = dt2; var drs_amats_r = dr_amats.GetPOSITIONS_RRows().OrderBy(d => d.EDIT_DATE).ToArray(); rete = PositionsR.ReadDateListFilter(drs_amats_r, d => d.EDIT_DATE); if (rete != PeriodInfo.ERetReadStartEndList.OK) { error_list.AddError(error_source, "Norādītajam periodam nav ievadīti amata dati."); return(error_list); } var drs_dl_sar_r = dr_person.GetTIMESHEET_LISTS_RRows() .WhereX( d => d.TIMESHEET_LISTSRow.YR == yr && d.TIMESHEET_LISTSRow.MT == mt && d.IDAM == dr_amats.ID) .ToArray(); if (drs_dl_sar_r.Length == 0) { error_list.AddError(error_source, "Norādītajam periodam nav darba laika uzskaites datu."); return(error_list); } if (drs_dl_sar_r.Length > 1) { error_list.AddError(error_source, "Darba laika uzskaites datu rindu skaits > 1."); return(error_list); } var dr_dl_sar_r = drs_dl_sar_r[0]; var dlrowset = dr_dl_sar_r.GetDLRowSet(); DLRows = dlrowset; SetDLRows(dlrowset); if (DLRows == null || DLRows.Plan == null || DLRows.Fact == null || (dr_dl_sar_r.NIGHT == 1 && (DLRows.PlanNight == null || DLRows.FactNight == null)) || (dr_dl_sar_r.OVERTIME == 1 && DLRows.FactOvertime == null)) { error_list.AddError(error_source, "Nekorekti darba laika uzskaites dati."); return(error_list); } if (Events == null) { if (!GetEventList(error_list, idp)) { return(error_list); } } if (IsRateTypeChangedDuringVacation(drs_amats_r)) { error_list.AddError(error_source, "Atvaļinājuma laikā nevar mainīt algas likmes veidu."); } var err1 = CheckVacationTimePlan(idam); if (err1 != "OK") { error_list.AddError(error_source, err1); return(error_list); } if (Row != null) { TotalPositionPay = new SalaryInfo(); TotalPositionPay.SetFromRow(Row); } return(error_list); }