
using System;
using System.Collections;
using System.Collections.Generic;
using BeWo.Data.Entities;
using BeWo.Report.ReportObjects;
using BS.Shared.Core;


namespace BeWo.FibMarburg
{
	public class FibMarburgMitarbeiterstundenkontoBerechnung : MitarbeiterstundenkontoBerechnung
	{
		public override void CreateEmployeeDetails(MitarbeiterstundenkontoRO ro)
		{
			base.CreateEmployeeDetails(ro);

			if (ro.ReportStartDate >= new DateTime(2015, 1, 1))
			{
				foreach (var employeeDetail in ro.EmployeeDetailList)
				{
					if (employeeDetail.LastName == "Becker")
					{
						AddUeberstunden(employeeDetail, 87.04m);
					}
					else if (employeeDetail.LastName == "Bohn")
					{
						AddUeberstunden(employeeDetail, 33.55m);
					}
					else if (employeeDetail.LastName == "Bohnert")
					{
						AddUeberstunden(employeeDetail, 100m);
					}
					else if (employeeDetail.LastName == "Brock" && employeeDetail.FirstName == "Heike")
					{
						AddUeberstunden(employeeDetail, 50.43m);
					}
					else if (employeeDetail.LastName == "Däfler")
					{
						AddUeberstunden(employeeDetail, 67.02m);
					}
					else if (employeeDetail.LastName == "Eberling")
					{
						AddUeberstunden(employeeDetail, -20.25m);
					}
					else if (employeeDetail.LastName == "Fedunyk")
					{
						AddUeberstunden(employeeDetail, 37.86m);
					}
					else if (employeeDetail.LastName == "Glas")
					{
						AddUeberstunden(employeeDetail, 29.68m);
					}

					else if (employeeDetail.LastName == "Gülmez")
					{
						AddUeberstunden(employeeDetail, 104.38m);
					}
					else if (employeeDetail.LastName == "Hacke")
					{
						AddUeberstunden(employeeDetail, -6.5m);
					}
					else if (employeeDetail.LastName == "Hammann")
					{
						AddUeberstunden(employeeDetail, 12.26m);
					}
					else if (employeeDetail.LastName == "Hilliges")
					{
						AddUeberstunden(employeeDetail, 36.46m);
					}
					else if (employeeDetail.LastName == "Holz")
					{
						AddUeberstunden(employeeDetail, 81.83m);
					}
					else if (employeeDetail.LastName == "Jakobi")
					{
						AddUeberstunden(employeeDetail, -22.75m);
					}
					else if (employeeDetail.LastName == "Krakovszky-Jahn")
					{
						AddUeberstunden(employeeDetail, 49.35m);
					}
					else if (employeeDetail.LastName == "Köksal")
					{
						AddUeberstunden(employeeDetail, 12.15m);
					}
					else if (employeeDetail.LastName == "Michel")
					{
						AddUeberstunden(employeeDetail, 7.64m);
					}
					else if (employeeDetail.LastName == "Nanni")
					{
						AddUeberstunden(employeeDetail, 68.01m);
					}
					else if (employeeDetail.LastName == "Otto")
					{
						AddUeberstunden(employeeDetail, 62.06m);
					}
					else if (employeeDetail.LastName == "Reichert")
					{
						AddUeberstunden(employeeDetail, 54.93m);
					}
					else if (employeeDetail.LastName == "Schranz")
					{
						AddUeberstunden(employeeDetail, 75.03m);
					}
					else if (employeeDetail.LastName == "Schulz")
					{
						AddUeberstunden(employeeDetail, 6.45m);
					}
					else if (employeeDetail.LastName == "Schimanski")
					{
						AddUeberstunden(employeeDetail, -21.4m);
					}
					else if (employeeDetail.LastName == "Stein")
					{
						AddUeberstunden(employeeDetail, 37.71m);
					}
					else if (employeeDetail.LastName == "Ventzke")
					{
						AddUeberstunden(employeeDetail, 20.69m);
					}

				}
			}
		}

		private void AddUeberstunden(MitarbeiterstundenkontoRO.EmployeeDetail employeeDetail, decimal stunden)
		{
			if (!employeeDetail.Ueberstunden.HasValue)
			{
				employeeDetail.Ueberstunden = 0;
			}
			if (!employeeDetail.UeberstundenGesamt.HasValue)
			{
				employeeDetail.UeberstundenGesamt = 0;
			}

			if (!employeeDetail.UeberstundenVormonat.HasValue)
			{
				employeeDetail.UeberstundenVormonat = 0;
			}
			employeeDetail.UeberstundenVormonat += stunden;

			employeeDetail.UeberstundenGesamt += stunden;
		}

		public override List<DateTime> GetFeiertage(int year)
		{
			var list = base.GetFeiertage(year);

			list.Add(new DateTime(year, 12, 31));
			list.Remove(new DateTime(year, 11, 1)); // , "Allerheiligen "

			return list;
		}

		public override bool IsUrlaubAbsenceTime(AbsenceTime absenceTime)
		{
			return !String.IsNullOrEmpty(absenceTime.AbsenceReason.Description) &&
				   absenceTime.AbsenceReason.Description.ToLower() == "urlaub";
		}
	}
}
