using System;
using System.Collections.Generic;
using BeWo.Report;
using BeWo.Report.ReportObjects;

namespace LebenshilfeRemscheid
{
    partial class Stundenzettel : DevExpress.XtraReports.UI.XtraReport, IBeWoReport<ServicesOverviewRO>
    {
        public Stundenzettel()
        {
            InitializeComponent();
        }

        public void SetReportDataSource(ServicesOverviewRO pRO)
        {

            lblBewilligteLeistung.Text = String.Format("{0:0.00} h / {1:0} min. mtl. // {2:0.##} h ges.", pRO.ApprovedFLSPerWeek, Math.Round(pRO.ApprovedFLSPerWeek * 4.34m * 60, 0, MidpointRounding.AwayFromZero), pRO.ApprovedFLSTotal);
           
            if (pRO.Services != null)
            {
                List<ServicesOverviewRO.ServiceDetail> servicesBillable = new List<ServicesOverviewRO.ServiceDetail>();
                

                foreach (var item in pRO.Services)
                {
                    if (item.IsBillable) 
                    {
                        
                        servicesBillable.Add(item);
                    }
                }

                pRO.Services = servicesBillable;
            }
            
            this.bindingSource1.DataSource = pRO;
        }

    }
}
