using System;
using BeWo.Report;
using BeWo.Report.ReportObjects;

using DevExpress.XtraReports.UI;

namespace VivatgGmbHReports
{
    public partial class ServiceInvoiceReport : XtraReport, IBeWoReport<ServiceInvoiceRO>
    {
        public ServiceInvoiceReport()
        {
            InitializeComponent();
        }

        public void SetReportDataSource(ServiceInvoiceRO pRO)
        {
			
	        if (pRO.ServiceInvoicePeriods != null)
	        {
		        foreach (var sip in pRO.ServiceInvoicePeriods)
		        {
			        if (sip.ServiceInvoiceItems != null)
			        {
				        foreach (var ii in sip.ServiceInvoiceItems)
				        {
					        if (!string.IsNullOrEmpty(ii.RateFactor))
					        {
						        if (!String.IsNullOrEmpty(ii.RateFactor))
								{
									var rfStr = ii.RateFactor.Replace("%", "").Replace(",00", "").Trim();
									int rfInt = 0;
									Int32.TryParse(rfStr, out rfInt);

									decimal rateFactor = (100m + rfInt) / 100m;

									if (rateFactor != 1)
									{
										ii.Hours *= rateFactor;
									}
									
								}
					        }
				        }
			        }
		        }
	        }
            bindingSource1.DataSource = pRO;
        }
    }
}