using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using BS.Shared.DataContracts.Compact;

namespace BS.Shared.DataContracts
{
    [DataContract]
    public class ServiceInvoicePeriodDC : IDataContract
    {
        [DataMember]
        public decimal? ApprovedAmountDefaultHourlyRate { get; set; }

        [DataMember]
        public decimal? ApprovedBE { get; set; }

        [DataMember]
        public decimal? ApprovedFixedAmount { get; set; }

        [DataMember]
        public decimal? ApprovedHours { get; set; }

        [DataMember]
        public decimal? Claim { get; set; }

        [DataMember]
        public AccountingIntervalType? AccountingInterval { get; set; }


        //public decimal? Claim2 
        //{
        //    get
        //    {
        //        if (ApprovedFixedAmount.HasValue && ApprovedFixedAmount.Value != 0)
        //            return ApprovedFixedAmount;
        //        return RecordedBEAmount;
        //    }
        //}

        [DataMember]
        public DateTime? End { get; set; }

        [DataMember]
        public decimal HoursNotBillableAbsence { get; set; }

        [DataMember]
        public decimal HoursNotBillableNotApproved { get; set; }

        [DataMember]
        public List<InvoiceItemDC> InvoiceItems { get; set; }

        public string NotBillableString
        {
            get
            {
                if (this.HoursNotBillableAbsence == 0 && this.HoursNotBillableNotApproved == 0)
                {
                    return string.Empty;
                }

                var s = "Nicht abrechenbare geleistete Stunden im Zeitraum: ";
                if (this.HoursNotBillableAbsence > 0)
                {
                    s += string.Format("{0:0.00} (Klient abwesend) ", this.HoursNotBillableAbsence);
                    if (this.HoursNotBillableNotApproved > 0)
                    {
                        s += " + ";
                    }
                }

                if (this.HoursNotBillableNotApproved > 0)
                {
                    s += string.Format("{0:0.00} (nicht bewilligt) ", this.HoursNotBillableNotApproved);
                }

                return s;
            }
        }

        [DataMember]
        public long? ServiceInvoicePeriodOid { get; set; }

        [DataMember]
        public long? ServiceInvoicePeriodVersion { get; set; }

        [DataMember]
        public string ServiceUnitName { get; set; }

        [DataMember]
        public DateTime? Start { get; set; }

        [DataMember]
        public SupportConceptApprovalPeriodDC SupportConceptApprovalPeriod { get; set; }

        [DataMember]
        public CompactCustomerDC Customer { get; set; }
    }
}