using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using BeWo.Data.Entities;
using BeWo.Report.ReportObjects;


namespace BeWo.DerKarren
{
	public class KarrenMitarbeiterstundenkontoBerechnung : MitarbeiterstundenkontoBerechnung
	{
		public override List<DateTime> GetFeiertage(int year)
		{
			var list = base.GetFeiertage(year);

			list.Add(new DateTime(year, 12, 31));

			return list;
		}

		public override void CreateEmployeeDetails(MitarbeiterstundenkontoRO ro)
		{
			base.CreateEmployeeDetails(ro);

			if (ro.ReportStartDate >= new DateTime(2015, 2, 1))
			{
				foreach (var employeeDetail in ro.EmployeeDetailList)
				{

					if (employeeDetail.LastName == "Becker")
					{
						AddUeberstunden(employeeDetail, -4.9m);
					}
					else if (employeeDetail.LastName == "Bierther")
					{
						AddUeberstunden(employeeDetail, 48.87m);
					}
					else if (employeeDetail.LastName == "Dederichs")
					{
						AddUeberstunden(employeeDetail, 4.7m);
					}
					else if (employeeDetail.LastName == "Derksen")
					{
						AddUeberstunden(employeeDetail, 19.53m);
					}
					else if (employeeDetail.LastName == "Pietsch")
					{
						AddUeberstunden(employeeDetail, 5.4m);
					}
					else if (employeeDetail.LastName == "Rix")
					{
						AddUeberstunden(employeeDetail, 12.23m);
					}
					else if (employeeDetail.LastName == "Zimmermann")
					{
						AddUeberstunden(employeeDetail, 10);
					}
					else if (employeeDetail.LastName == "Zöller")
					{
						AddUeberstunden(employeeDetail, -19.4m);
					}

					else if (employeeDetail.LastName == "Becker-Schmitt")
					{
						AddUeberstunden(employeeDetail, -14);
					}
					else if (employeeDetail.LastName == "Heinz")
					{
						AddUeberstunden(employeeDetail, 9.8m);
					}
					else if (employeeDetail.LastName == "Höller")
					{
						AddUeberstunden(employeeDetail, 44.5m);
					}
					else if (employeeDetail.LastName == "Leiendecker")
					{
						AddUeberstunden(employeeDetail, 26.3m);
					}
					else if (employeeDetail.LastName == "Palmersheim")
					{
						AddUeberstunden(employeeDetail, 40.65m);
					}
					else if (employeeDetail.LastName == "Siegel")
					{
						AddUeberstunden(employeeDetail, 78.3m);
					}
					else if (employeeDetail.LastName == "Kalhöfer")
					{
						AddUeberstunden(employeeDetail, 80.2m);
					}
				}
			}

		}


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

	}
}
