/// <summary>
        /// Проверить доп. соглашение на дубли.
        /// </summary>
        /// <param name="supAgreement">Доп. соглашение.</param>
        /// <param name="businessUnit">НОР.</param>
        /// <param name="registrationNumber">Рег. номер.</param>
        /// <param name="registrationDate">Дата регистрации.</param>
        /// <param name="counterparty">Контрагент.</param>
        /// <param name="contract">Договор.</param>
        /// <returns>Признак дублей.</returns>
        public static bool HaveDuplicates(ISupAgreement supAgreement,
                                          Sungero.Company.IBusinessUnit businessUnit,
                                          string registrationNumber,
                                          DateTime?registrationDate,
                                          Sungero.Parties.ICounterparty counterparty,
                                          IOfficialDocument contract)
        {
            if (supAgreement == null ||
                businessUnit == null ||
                string.IsNullOrWhiteSpace(registrationNumber) ||
                registrationDate == null ||
                counterparty == null ||
                contract == null)
            {
                return(false);
            }

            return(Functions.SupAgreement.Remote.GetDuplicates(supAgreement,
                                                               businessUnit,
                                                               registrationNumber,
                                                               registrationDate,
                                                               counterparty,
                                                               contract)
                   .Any());
        }
        public static string GetSupAgreementNamePart(ISupAgreement supAgreement)
        {
            if (supAgreement == null)
            {
                return(string.Empty);
            }

            return(supAgreement.AccessRights.CanRead() ?
                   GetNamePartBySupAgreement(supAgreement) :
                   Functions.SupAgreement.Remote.GetNamePartBySupAgreementIgnoreAccessRights(supAgreement.Id));
        }
        /// <summary>
        /// Получить данные доп.согл. для формирования имени акта.
        /// </summary>
        /// <param name="supAgreement">Доп. соглашение.</param>
        /// <returns>Часть имени.</returns>
        /// <remarks>Если нет прав на доп. соглашение, то возникнет исключение.</remarks>
        public static string GetNamePartBySupAgreement(ISupAgreement supAgreement)
        {
            var namePart = ContractBases.Resources.NamePartForLeadDocument + supAgreement.DocumentKind.ShortName.ToLower();

            if (!string.IsNullOrWhiteSpace(supAgreement.RegistrationNumber))
            {
                namePart += OfficialDocuments.Resources.Number + supAgreement.RegistrationNumber;
            }

            namePart += Functions.ContractBase.GetContractNamePart(supAgreement.LeadingDocument);

            return(namePart);
        }
 public static IQueryable <ISupAgreement> GetDuplicates(ISupAgreement supAgreement,
                                                        Sungero.Company.IBusinessUnit businessUnit,
                                                        string registrationNumber,
                                                        DateTime?registrationDate,
                                                        Sungero.Parties.ICounterparty counterparty,
                                                        IOfficialDocument contract)
 {
     return(SupAgreements.GetAll()
            .Where(l => Equals(supAgreement.DocumentKind, l.DocumentKind))
            .Where(l => Equals(businessUnit, l.BusinessUnit))
            .Where(l => registrationDate == l.RegistrationDate)
            .Where(l => registrationNumber == l.RegistrationNumber)
            .Where(l => Equals(counterparty, l.Counterparty))
            .Where(l => Equals(contract, l.LeadingDocument))
            .Where(l => !Equals(supAgreement, l)));
 }