using System.Collections.Generic;
using System.Runtime.Serialization;

using BS.Shared.Core;

namespace BS.Shared.DataContracts
{
    [DataContract]
    public partial class OrganisationDC : IDataContract
    {
        // Contacts
        private List<ContactDC> _ContactInformations;

        private List<CostRatePeriodDC> _CostRatePeriods;

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

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

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

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

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

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

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

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

		[DataMember]
		public ActivationTypeId ActivationType { get; set; }

        [DataMember]
        public List<ContactDC> ContactInformations
        {
            get
            {
                return this._ContactInformations ?? (this._ContactInformations = new List<ContactDC>());
            }

            set
            {
                this._ContactInformations = value;
            }
        }

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

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

        [DataMember]
        public List<CostRatePeriodDC> CostRatePeriods
        {
            get
            {
                return this._CostRatePeriods ?? (this._CostRatePeriods = new List<CostRatePeriodDC>());
            }

            set
            {
                this._CostRatePeriods = value;
            }
        }

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

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

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

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

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

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

        [DataMember]
        public bool IsCalculatingWithFactor { get; set; }

        [DataMember]
        public bool IsSingleInvoicePerCustomer { get; set; }

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

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

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

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

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

        [DataMember]
        public List<OrganisationPersonRelationDC> RelatedPersons { get; set; }

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

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

        public bool ContainsAddressData()
        {
            return !Utils.AreAllNullOrEmpty(this.Street, this.PostalCode, this.Town);
        }

        public bool ContainsBankAccountData()
        {
            return !Utils.AreAllNullOrEmpty(this.BankCode, this.BankName, this.AccountNumber, this.IBAN, this.Bic);
        }

        public bool ContainsCostBearerData()
        {
            return !Utils.AreAllNullOrEmpty(this._CostRatePeriods) || this.IsCalculatingWithFactor;
        }

        public bool ContainsInvoiceAddressData()
        {
            return !Utils.AreAllNullOrEmpty(this.InvoiceAddressStreet, this.InvoiceAddressPostalCode, this.InvoiceAddressTown);
        }

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

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

		[DataMember]
		public List<VarFieldDC> VarFields { get; set; }
    }
}