/// <summary> /// Получить все договоры и доп. соглашения на завершении, где Я ответственный. /// </summary> /// <param name="query">Запрос виджета.</param> /// <param name="needAutomaticRenewal">Признак "С пролонгацией".</param> /// <param name="substitution">Параметр "Учитывать замещения".</param> /// <param name="show">Параметр "Показывать".</param> /// <returns>Список договоров и доп. соглашений на завершении.</returns> public IQueryable <Sungero.Contracts.IContractualDocument> GetMyExpiringSoonContracts(IQueryable <Sungero.Contracts.IContractualDocument> query, bool?needAutomaticRenewal, bool substitution, Enumeration show) { var today = Calendar.UserToday; var lastDate = today.AddDays(14); // Если показывать надо не все Договоры, то дофильтровываем по ответственному. if (show != Sungero.ContractsUI.Widgets.MyContracts.Show.All) { var currentEmployee = Employees.Current; var responsibleEmployees = new List <IUser>(); if (currentEmployee != null) { responsibleEmployees.Add(currentEmployee); } var employeeDepartment = currentEmployee != null ? currentEmployee.Department : null; // Учитывать замещения, если выставлен соответствующий параметр. if (substitution) { var substitutions = Substitutions.ActiveSubstitutedUsersWithoutSystem; responsibleEmployees.AddRange(substitutions); } // Если выбрано значение параметра "Договоры подразделения", то добавляем к списку ответственных всех сотрудников подразделения. if (show == Sungero.ContractsUI.Widgets.MyContracts.Show.Department) { var departmentsEmployees = Company.Employees.GetAll(e => Equals(e.Department, employeeDepartment)); responsibleEmployees.AddRange(departmentsEmployees); } query = query.Where(cd => responsibleEmployees.Contains(cd.ResponsibleEmployee)); } query = query .Where(q => ContractBases.Is(q) || SupAgreements.Is(q)) .Where(q => q.LifeCycleState == Sungero.Contracts.SupAgreement.LifeCycleState.Active); query = query.Where(q => q.ValidTill.HasValue) .Where(q => (ContractBases.Is(q) && today.AddDays(ContractBases.As(q).DaysToFinishWorks ?? 14) >= q.ValidTill) || (SupAgreements.Is(q) && q.ValidTill.Value <= lastDate)) .Where(q => SupAgreements.Is(q) || ContractBases.Is(q) && (ContractBases.As(q).DaysToFinishWorks == null || ContractBases.As(q).DaysToFinishWorks <= Docflow.PublicConstants.Module.MaxDaysToFinish)); // Признак с автопролонгацией у договоров. if (needAutomaticRenewal.HasValue) { query = query.Where(q => ContractBases.Is(q) && ContractBases.As(q).IsAutomaticRenewal.HasValue&& ContractBases.As(q).IsAutomaticRenewal.Value == needAutomaticRenewal.Value); } return(query); }
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))); }
/// <summary> /// Получить все договоры и доп. соглашения в стадии согласования, где Я ответственный. /// </summary> /// <param name="query">Запрос виджета.</param> /// <param name="substitution">Параметр "Учитывать замещения".</param> /// <param name="show">Параметр "Показывать".</param> /// <returns>Список договоров и доп. соглашений.</returns> public IQueryable <Sungero.Contracts.IContractualDocument> GetMyContractualDocuments(IQueryable <Sungero.Contracts.IContractualDocument> query, bool substitution, Enumeration show) { query = query.Where(cd => ContractBases.Is(cd) || SupAgreements.Is(cd)); // Проверить статус жизненного цикла. query = query.Where(cd => cd.LifeCycleState == Docflow.OfficialDocument.LifeCycleState.Draft) .Where(cd => cd.InternalApprovalState == Docflow.OfficialDocument.InternalApprovalState.OnApproval || cd.InternalApprovalState == Docflow.OfficialDocument.InternalApprovalState.OnRework || cd.InternalApprovalState == Docflow.OfficialDocument.InternalApprovalState.PendingSign || cd.InternalApprovalState == Docflow.OfficialDocument.InternalApprovalState.Signed || cd.ExternalApprovalState == Docflow.OfficialDocument.ExternalApprovalState.OnApproval); // Если показывать надо не все Договоры, то дофильтровываем по ответственному. if (show != Sungero.ContractsUI.Widgets.MyContracts.Show.All) { var currentEmployee = Company.Employees.Current; var responsibleEmployees = new List <IUser>(); if (currentEmployee != null) { responsibleEmployees.Add(currentEmployee); } var employeeDepartment = currentEmployee != null ? currentEmployee.Department : null; // Учитывать замещения, если выставлен соответствующий параметр. if (substitution) { var substitutions = Substitutions.ActiveSubstitutedUsersWithoutSystem; responsibleEmployees.AddRange(substitutions); } // Если выбрано значение параметра "Договоры подразделения", то добавляем к списку ответственных всех сотрудников подразделения. if (show == Sungero.ContractsUI.Widgets.MyContracts.Show.Department) { var departmentsEmployees = Company.Employees.GetAll(e => Equals(e.Department, employeeDepartment)); responsibleEmployees.AddRange(departmentsEmployees); } query = query.Where(cd => responsibleEmployees.Contains(cd.ResponsibleEmployee)); } return(query); }
/// <summary> /// Агент создания задач по завершению контрольных точек договоров. /// </summary> public virtual void SendTaskForContractMilestones() { var contracts = ContractualDocuments.GetAll().Where(c => c.Milestones.Any()); foreach (var contract in contracts) { if (!Locks.GetLockInfo(contract).IsLocked) { foreach (var milestone in contract.Milestones) { // Создание задач. var daysToFinishWorks = milestone.DaysToFinishWorks != null ? milestone.DaysToFinishWorks.Value : 3; if (milestone.IsCompleted == false && milestone.Deadline < Calendar.Now.AddWorkingDays(milestone.Performer, daysToFinishWorks) && (milestone.Task == null || milestone.Task.Status == Workflow.SimpleTask.Status.Aborted || milestone.Task.Status == Workflow.SimpleTask.Status.Suspended)) { var subject = string.Format(Sungero.Contracts.Resources.ContractMilestoneTaskSubject, milestone.Name, contract.Name); if (subject.Length > Workflow.SimpleTasks.Info.Properties.Subject.Length) { subject = subject.Substring(0, Workflow.SimpleTasks.Info.Properties.Subject.Length); } subject = Docflow.PublicFunctions.Module.TrimQuotes(subject); var attachments = new List <IContractualDocument>() { contract }; if (SupAgreements.Is(contract)) { attachments.Add(ContractualDocuments.As(contract.LeadingDocument)); } var milestoneDeadline = milestone.Deadline.Value.Date < Calendar.GetUserToday(milestone.Performer) ? Calendar.Now.AddWorkingDays(milestone.Performer, 1) : milestone.Deadline.Value; var task = Workflow.SimpleTasks.Create(subject, milestoneDeadline, new IUser[] { milestone.Performer }, attachments); task.NeedsReview = false; var contractTypeName = contract.DocumentKind.DocumentType.Name.ToLower(); task.ActiveText = Sungero.Contracts.Resources.ContractMilestoneTaskTextFormat(CaseConverter.ConvertJobTitleToTargetDeclension(contractTypeName, DeclensionCase.Dative)); if (!string.IsNullOrEmpty(milestone.Note)) { task.ActiveText += "\n" + string.Format(Sungero.Contracts.Resources.ContractMilestoneTaskTextNote, milestone.Note); } var observers = new List <IUser>(); // Проверка на наличие дублей наблюдателей. if (contract.ResponsibleEmployee != null && !Equals(contract.ResponsibleEmployee, milestone.Performer)) { if (Docflow.PublicFunctions.PersonalSetting.GetPersonalSettings(contract.ResponsibleEmployee).MyContractsNotification == true) { observers.Add(contract.ResponsibleEmployee); } var responsibleManager = Docflow.PublicFunctions.Module.Remote.GetManager(contract.ResponsibleEmployee); if (responsibleManager != null && !Equals(responsibleManager, milestone.Performer) && !Equals(responsibleManager, contract.ResponsibleEmployee) && Docflow.PublicFunctions.PersonalSetting.GetPersonalSettings(responsibleManager).MySubordinatesContractsNotification == true) { observers.Add(responsibleManager); } } var performerManager = Docflow.PublicFunctions.Module.Remote.GetManager(milestone.Performer); if (performerManager != null && !Equals(performerManager, milestone.Performer) && Docflow.PublicFunctions.PersonalSetting.GetPersonalSettings(performerManager).MySubordinatesContractsNotification == true && !observers.Contains(performerManager)) { observers.Add(performerManager); } foreach (var observer in observers) { task.Observers.AddNew().Observer = observer; } foreach (var attachment in attachments) { if (!attachment.AccessRights.IsGrantedDirectly(DefaultAccessRightsTypes.Read, milestone.Performer)) { attachment.AccessRights.Grant(milestone.Performer, DefaultAccessRightsTypes.Read); } if (performerManager != null && !attachment.AccessRights.IsGrantedDirectly(DefaultAccessRightsTypes.Read, performerManager)) { attachment.AccessRights.Grant(performerManager, DefaultAccessRightsTypes.Read); } } task.Save(); task.Start(); milestone.Task = task; } if (milestone.Task != null) { // Проставление признака завершенности. if (milestone.Task.Status == Workflow.SimpleTask.Status.Completed) { milestone.IsCompleted = true; } // Актуализация сроков заданий. if (milestone.Deadline > milestone.Task.Deadline) { milestone.Task.Deadline = milestone.Deadline; var assignment = Workflow.SimpleAssignments.GetAll().Where(a => Equals(a.Task, milestone.Task)).FirstOrDefault(); if (assignment != null) { assignment.Deadline = milestone.Deadline; } assignment.Save(); } // Прекращение задачи if (milestone.IsCompleted == true) { milestone.Task.Abort(); milestone.Task = null; } } } if (contract.State.IsChanged) { contract.Save(); } } } }
public virtual IQueryable <Sungero.Docflow.IOfficialDocument> ContractsAtContractorsDataQuery(IQueryable <Sungero.Docflow.IOfficialDocument> query) { var documents = Docflow.OfficialDocuments.GetAll().Where(c => c.IsHeldByCounterParty.Value && (ContractBases.Is(c) || SupAgreements.Is(c) || FinancialArchive.ContractStatements.Is(c) || FinancialArchive.Waybills.Is(c) || FinancialArchive.UniversalTransferDocuments.Is(c))); if (_filter == null) { return(documents); } #region Фильтры // Фильтр "Вид документа". if (_filter.DocumentKind != null) { documents = documents.Where(c => Equals(c.DocumentKind, _filter.DocumentKind)); } // Фильтр "Категория". if (_filter.Category != null) { documents = documents.Where(c => !ContractBases.Is(c) || (ContractBases.Is(c) && Equals(c.DocumentGroup, _filter.Category))); } // Фильтр "Контрагент". if (_filter.Contractor != null) { documents = documents.Where(c => (Docflow.ContractualDocumentBases.Is(c) && Equals(Docflow.ContractualDocumentBases.As(c).Counterparty, _filter.Contractor)) || (Docflow.AccountingDocumentBases.Is(c) && Equals(Docflow.AccountingDocumentBases.As(c).Counterparty, _filter.Contractor))); } // Фильтр "Наша организация". if (_filter.BusinessUnit != null) { documents = documents.Where(c => Equals(c.BusinessUnit, _filter.BusinessUnit)); } // Фильтр "Ответственный за возврат". if (_filter.Responsible != null) { documents = documents.Where(c => Equals(c.ResponsibleForReturnEmployee, _filter.Responsible)); } // Фильтр "Только просроченные". if (_filter.OnlyOverdue) { var today = Calendar.UserToday; documents = documents.Where(c => c.ScheduledReturnDateFromCounterparty < today); } #endregion return(documents); }
public virtual IQueryable <Sungero.Contracts.IContractualDocument> ExpiringSoonContractsDataQuery(IQueryable <Sungero.Contracts.IContractualDocument> query) { // Документ действующий и осталось 14 (либо указанное в договоре число) дней до окончания документа. var today = Calendar.UserToday; var documents = query.Where(d => d.LifeCycleState == Sungero.Docflow.OfficialDocument.LifeCycleState.Active) .Where(d => SupAgreements.Is(d) || ContractBases.Is(d) && (ContractBases.As(d).DaysToFinishWorks == null || ContractBases.As(d).DaysToFinishWorks <= Docflow.PublicConstants.Module.MaxDaysToFinish)) .Where(d => (ContractBases.Is(d) && today.AddDays(ContractBases.As(d).DaysToFinishWorks ?? 14) >= d.ValidTill) || (SupAgreements.Is(d) && today.AddDays(14) >= d.ValidTill)); if (_filter == null) { return(documents); } #region Фильтры // Фильтр "Вид документа". if (_filter.DocumentKind != null) { documents = documents.Where(d => Equals(d.DocumentKind, _filter.DocumentKind)); } // Фильтр "Категория". if (_filter.Category != null) { documents = documents.Where(d => ContractBases.Is(d) && Equals(d.DocumentGroup, _filter.Category)); } // Фильтр "Контрагент". if (_filter.Contractor != null) { documents = documents.Where(d => Equals(d.Counterparty, _filter.Contractor)); } // Фильтр "Наша организация". if (_filter.BusinessUnit != null) { documents = documents.Where(d => Equals(d.BusinessUnit, _filter.BusinessUnit)); } // Фильтр "Ответственный". if (_filter.Responsible != null) { documents = documents.Where(d => Equals(d.ResponsibleEmployee, _filter.Responsible)); } // Фильтр по типу документа if (_filter.Contracts && !_filter.SupAgreements) { return(documents.Where(d => ContractBases.Is(d))); } if (_filter.SupAgreements && !_filter.Contracts) { return(documents.Where(d => SupAgreements.Is(d))); } #endregion return(documents); }
public virtual IQueryable <Sungero.Contracts.IContractualDocument> ContractsHistoryDataQuery(IQueryable <Sungero.Contracts.IContractualDocument> query) { var documents = query.Where(d => ContractBases.Is(d) || SupAgreements.Is(d)); if (_filter == null) { return(documents); } #region Фильтр по состоянию и датам DateTime beginPeriod = Calendar.SqlMinValue; DateTime endPeriod = Calendar.UserToday.EndOfDay().FromUserTime(); if (_filter.Last30days) { beginPeriod = Docflow.PublicFunctions.Module.Remote.GetTenantDateTimeFromUserDay(Calendar.UserToday.AddDays(-30)); } if (_filter.Last365days) { beginPeriod = Docflow.PublicFunctions.Module.Remote.GetTenantDateTimeFromUserDay(Calendar.UserToday.AddDays(-365)); } if (_filter.ManualPeriod) { if (_filter.DateRangeFrom.HasValue) { beginPeriod = Docflow.PublicFunctions.Module.Remote.GetTenantDateTimeFromUserDay(_filter.DateRangeFrom.Value); } endPeriod = _filter.DateRangeTo.HasValue ? _filter.DateRangeTo.Value.EndOfDay().FromUserTime() : Calendar.SqlMaxValue; } Enumeration?operation = null; var lifeCycleStates = new List <Enumeration>(); if (_filter.Concluded) { operation = new Enumeration("SetToActive"); lifeCycleStates.Add(Sungero.Contracts.ContractBase.LifeCycleState.Active); lifeCycleStates.Add(Sungero.Contracts.ContractBase.LifeCycleState.Closed); lifeCycleStates.Add(Sungero.Contracts.ContractBase.LifeCycleState.Terminated); } if (_filter.Executed) { operation = new Enumeration("SetToClosed"); lifeCycleStates.Add(Sungero.Contracts.ContractBase.LifeCycleState.Closed); } if (_filter.Terminated) { operation = new Enumeration("SetToTerminated"); lifeCycleStates.Add(Sungero.Contracts.ContractBase.LifeCycleState.Terminated); } if (_filter.Cancelled) { operation = new Enumeration("SetToObsolete"); lifeCycleStates.Add(Sungero.Contracts.ContractBase.LifeCycleState.Obsolete); } // Использовать можно только один WhereDocumentHistory, т.к. это отдельный подзапрос (+join). documents = documents.Where(d => d.LifeCycleState.HasValue && lifeCycleStates.Contains(d.LifeCycleState.Value)) .WhereDocumentHistory(h => h.Operation == operation && h.HistoryDate.Between(beginPeriod, endPeriod)); #endregion #region Фильтры по полям навигации // Фильтр "Вид документа". if (_filter.DocumentKind != null) { documents = documents.Where(c => Equals(c.DocumentKind, _filter.DocumentKind)); } // Фильтр "Категория". if (_filter.Category != null) { documents = documents.Where(c => Equals(c.DocumentGroup, _filter.Category)); } // Фильтр "Наша организация". if (_filter.BusinessUnit != null) { documents = documents.Where(c => Equals(c.BusinessUnit, _filter.BusinessUnit)); } // Фильтр "Ответственный". if (_filter.Responsible != null) { documents = documents.Where(c => Equals(c.ResponsibleEmployee, _filter.Responsible)); } #endregion #region Фильтр по типу документа if (_filter.SupAgreements || _filter.Contracts) { documents = documents.Where(d => _filter.Contracts && ContractBases.Is(d) || _filter.SupAgreements && SupAgreements.Is(d)); } #endregion return(documents); }
public virtual IQueryable <Sungero.Contracts.IContractualDocument> ContractsListDataQuery(IQueryable <Sungero.Contracts.IContractualDocument> query) { if (_filter == null) { return(query.Where(d => ContractBases.Is(d) || SupAgreements.Is(d))); } #region Фильтры // Фильтр по состоянию. var statuses = new List <Enumeration>(); if (_filter.Draft) { statuses.Add(Sungero.Contracts.ContractBase.LifeCycleState.Draft); } if (_filter.Active) { statuses.Add(Sungero.Contracts.ContractBase.LifeCycleState.Active); } if (_filter.Executed) { statuses.Add(Sungero.Contracts.ContractBase.LifeCycleState.Closed); } if (_filter.Terminated) { statuses.Add(Sungero.Contracts.ContractBase.LifeCycleState.Terminated); } if (_filter.Cancelled) { statuses.Add(Sungero.Contracts.ContractBase.LifeCycleState.Obsolete); } // Фильтр по состоянию. if (statuses.Any()) { query = query.Where(q => q.LifeCycleState != null && statuses.Contains(q.LifeCycleState.Value)); } // Фильтр "Вид документа". if (_filter.DocumentKind != null) { query = query.Where(c => Equals(c.DocumentKind, _filter.DocumentKind)); } // Фильтр "Категория". if (_filter.Category != null) { query = query.Where(c => ContractBases.Is(c) && Equals(c.DocumentGroup, _filter.Category)); } // Фильтр "Контрагент". if (_filter.Contractor != null) { query = query.Where(c => Equals(c.Counterparty, _filter.Contractor)); } // Фильтр "Наша организация". if (_filter.BusinessUnit != null) { query = query.Where(c => Equals(c.BusinessUnit, _filter.BusinessUnit)); } // Фильтр "Подразделение". if (_filter.Department != null) { query = query.Where(c => Equals(c.Department, _filter.Department)); } #region Фильтрация по дате договора var beginDate = Calendar.UserToday.AddDays(-30); var endDate = Calendar.UserToday; if (_filter.Last365days) { beginDate = Calendar.UserToday.AddDays(-365); } if (_filter.ManualPeriod) { beginDate = _filter.DateRangeFrom ?? Calendar.SqlMinValue; endDate = _filter.DateRangeTo ?? Calendar.SqlMaxValue; } var serverPeriodBegin = Equals(Calendar.SqlMinValue, beginDate) ? beginDate : Docflow.PublicFunctions.Module.Remote.GetTenantDateTimeFromUserDay(beginDate); var serverPeriodEnd = Equals(Calendar.SqlMaxValue, endDate) ? endDate : endDate.EndOfDay().FromUserTime(); var clientPeriodEnd = !Equals(Calendar.SqlMaxValue, endDate) ? endDate.AddDays(1) : Calendar.SqlMaxValue; query = query.Where(j => (j.DocumentDate.Between(serverPeriodBegin, serverPeriodEnd) || j.DocumentDate == beginDate) && j.DocumentDate != clientPeriodEnd); #endregion // Фильтр по типу документа if (_filter.Contracts != _filter.SupAgreements) { if (_filter.Contracts) { query = query.Where(d => ContractBases.Is(d)); } if (_filter.SupAgreements) { query = query.Where(d => SupAgreements.Is(d)); } } else { query = query.Where(d => ContractBases.Is(d) || SupAgreements.Is(d)); } #endregion return(query); }
public virtual IQueryable <Sungero.Contracts.IContractualDocument> FinContractListDataQuery(IQueryable <Sungero.Contracts.IContractualDocument> query) { var documents = query.Where(x => x.LifeCycleState == Contracts.ContractBase.LifeCycleState.Terminated || x.LifeCycleState == Contracts.ContractBase.LifeCycleState.Active || x.LifeCycleState == Contracts.ContractBase.LifeCycleState.Closed); if (_filter == null) { return(documents); } #region Фильтры // Фильтр "Вид документа". if (_filter.DocumentKind != null) { documents = documents.Where(c => Equals(c.DocumentKind, _filter.DocumentKind)); } // Фильтр "Категория". if (_filter.Category != null) { documents = documents.Where(c => Equals(c.DocumentGroup, _filter.Category)); } // Фильтр "Контрагент". if (_filter.Contractor != null) { documents = documents.Where(c => Equals(c.Counterparty, _filter.Contractor)); } // Фильтр "Наша организация". if (_filter.BusinessUnit != null) { documents = documents.Where(c => Equals(c.BusinessUnit, _filter.BusinessUnit)); } // Фильтр "Подразделение". if (_filter.Department != null) { documents = documents.Where(c => Equals(c.Department, _filter.Department)); } #region Фильтрация по дате договора DateTime?beginDate = null; DateTime?endDate = null; var today = Calendar.UserToday; if (_filter.CurrentMonth) { beginDate = today.BeginningOfMonth(); endDate = today.EndOfMonth(); } if (_filter.PreviousMonth) { beginDate = today.AddMonths(-1).BeginningOfMonth(); endDate = today.AddMonths(-1).EndOfMonth(); } if (_filter.CurrentQuarter) { beginDate = Docflow.PublicFunctions.AccountingDocumentBase.BeginningOfQuarter(today); endDate = Docflow.PublicFunctions.AccountingDocumentBase.EndOfQuarter(today); } if (_filter.PreviousQuarter) { beginDate = Docflow.PublicFunctions.AccountingDocumentBase.BeginningOfQuarter(today.AddMonths(-3)); endDate = Docflow.PublicFunctions.AccountingDocumentBase.EndOfQuarter(today.AddMonths(-3)); } if (_filter.ManualPeriod) { if (_filter.DateRangeFrom.HasValue) { beginDate = _filter.DateRangeFrom.Value; } if (_filter.DateRangeTo.HasValue) { endDate = _filter.DateRangeTo.Value; } } if (beginDate != null) { documents = documents.Where(q => q.ValidTill != null && q.ValidTill >= beginDate || q.ValidTill == null); } if (endDate != null) { documents = documents.Where(q => q.ValidFrom != null && q.ValidFrom <= endDate || q.ValidFrom == null); } #endregion // Фильтр по типу документа if (_filter.Contracts && !_filter.SupAgreements) { return(documents.Where(d => ContractBases.Is(d))); } if (_filter.SupAgreements && !_filter.Contracts) { return(documents.Where(d => SupAgreements.Is(d))); } #endregion return(documents); }
public ISupAgreement CreateSupAgreemnt() { return(SupAgreements.Create()); }
public static List <IContractualDocument> FindContract(string uuid, string number, string date, string businessUnitTIN, string businessUnitTRRC, string counterpartyUuid, string counterpartyTIN, string counterpartyTRRC, string sysid) { // Найти документ среди синхронизированных ранее. if (!string.IsNullOrWhiteSpace(uuid) && !string.IsNullOrWhiteSpace(sysid)) { // Получить GUID типа Договор и доп.соглашение из разработки. var etalonContractTypeGuid = Sungero.Metadata.Services.MetadataSearcher.FindEntityMetadata(typeof(IContract).GetFinalType()).NameGuid.ToString(); var etalonSubAgreementTypeGuid = Sungero.Metadata.Services.MetadataSearcher.FindEntityMetadata(typeof(ISupAgreement).GetFinalType()).NameGuid.ToString(); var extLinks = Commons.PublicFunctions.Module.GetExternalEntityLinks(uuid, sysid) .Where(x => x.EntityType == etalonContractTypeGuid || x.EntityType == etalonSubAgreementTypeGuid) .ToList(); var contractIds = extLinks.Where(x => x.EntityType.ToUpper() == etalonContractTypeGuid.ToUpper()).Select(x => x.EntityId).ToList(); var supAgreeIds = extLinks.Where(x => x.EntityType.ToUpper() == etalonSubAgreementTypeGuid.ToUpper()).Select(x => x.EntityId).ToList(); var existDocuments = new List <IContractualDocument>(); existDocuments.AddRange(Contracts.GetAll().Where(x => contractIds.Contains(x.Id))); existDocuments.AddRange(SupAgreements.GetAll().Where(x => supAgreeIds.Contains(x.Id))); if (existDocuments.Any()) { return(existDocuments); } } var result = ContractualDocuments.GetAll(); // Фильтр по НОР. if (string.IsNullOrWhiteSpace(businessUnitTIN) || string.IsNullOrWhiteSpace(businessUnitTRRC)) { return(new List <IContractualDocument>()); } var businessUnit = Sungero.Company.BusinessUnits.GetAll().FirstOrDefault(x => x.TIN == businessUnitTIN && x.TRRC == businessUnitTRRC); if (businessUnit == null) { return(new List <IContractualDocument>()); } else { result = result.Where(x => Equals(x.BusinessUnit, businessUnit)); } // Фильтр по номеру. if (string.IsNullOrEmpty(number)) { var emptyNumberSynonyms = new List <string> { "б/н", "бн", "б-н", "б.н.", "б\\н" }; result = result.Where(x => emptyNumberSynonyms.Contains(x.RegistrationNumber.ToLower())); } else { result = result.Where(x => x.RegistrationNumber == number); } // Фильтр по дате. DateTime parsedDate; if (!string.IsNullOrWhiteSpace(date) && DateTime.TryParseExact(date, "dd'.'MM'.'yyyy", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out parsedDate)) { result = result.Where(x => x.RegistrationDate == parsedDate); } // Фильтр по контрагенту. var counterparties = Sungero.Parties.PublicFunctions.Module.Remote.FindCounterparty(counterpartyUuid, counterpartyTIN, counterpartyTRRC, sysid); if (counterparties.Any()) { result = result.Where(x => counterparties.Contains(x.Counterparty)); } return(result.ToList()); }
public static string GetNamePartBySupAgreementIgnoreAccessRights(int supAgreementId) { return(Functions.SupAgreement.GetNamePartBySupAgreement(SupAgreements.As(Functions.ContractualDocument.GetIgnoreAccessRights(supAgreementId)))); }