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

namespace VivatgGmbHReports.Neu
{
    public partial class Spitzabrechnung : DevExpress.XtraReports.UI.XtraReport, IBeWoReport<Settlement2RO>
    {
        public Spitzabrechnung()
        {
            InitializeComponent();
        }

		public void SetReportDataSource(Settlement2RO pRO)
        {

			foreach (var ii in pRO.InvoiceItems)
			{
				decimal rf = 1;
				if (ii.RateFactor.HasValue)
				{
					rf = (100 + ii.RateFactor.Value)/100;
				}
				ii.UnitDescription = String.Format("{0:dd.MM.yyyy} bis {1:dd.MM.yyyy}", ii.PeriodStartDate, ii.PeriodEndDate);
				ii.ItemDescription = String.Format("{0:0.##} FLS {1}x {2:c}", ii.UnitCount,
					rf == 1 ? "" : String.Format("x {0:0.##} ", rf), ii.AmountPerUnit);
			}
	        this.bindingSource1.DataSource = pRO;
        }

	    
    }
}
