/// <summary> /// Evaluate the given report version, and update previous versions with the given parameters or /// get the current version of the report. /// </summary> /// <param name="reportId">Report to evaluate.</param> /// <param name="reportRecordId">Version to evaluate.</param> /// <param name="registrationDate">Registration date of the current report.</param> /// <param name="abaxXBRLCellStoreMongo">Data access object.</param> /// <returns>The current version identifier or null if the given version is the most recent.</returns> public static string SarchReplacementId(string reportId, string reportRecordId, DateTime registrationDate, AbaxXBRLCellStoreMongo abaxXBRLCellStoreMongo) { string replacementId = null; var recentlySend = GetRecentlyReportSend(reportId, abaxXBRLCellStoreMongo); if (recentlySend != null && recentlySend.Contains("maxDate")) { var maxDate = DateTime.Parse(recentlySend["maxDate"].AsString); if (maxDate > registrationDate) { replacementId = JBRLUtils.CreateReportRecordId(reportId, maxDate); } } return(replacementId); }
/// <summary> /// The report main keys. /// </summary> /// <param name="document">Document to evaluate.</param> /// <returns></returns> public static void SetReportParams(DocumentoInstanciaXbrlDto document, IDictionary <String, String> extraParams) { if (!extraParams.ContainsKey(ConstantsJBRL.REPORT_TAXONOMY_ATT)) { extraParams[ConstantsJBRL.REPORT_TAXONOMY_ATT] = document.Taxonomia.EspacioNombresPrincipal; extraParams[ConstantsJBRL.REPORT_TAXONOMY_NAME_ATT] = GetTaxonomyName(document.Taxonomia.EspacioNombresPrincipal); } var hechoPrincipal = JBRLUtils.GetMainFact(document); var auxiliar = new FactJBRL(); ContextoDto context; if (!extraParams.ContainsKey(ConstantsJBRL.REPORT_ENTITY_ATT) || !extraParams.ContainsKey(ConstantsJBRL.REPORT_DATE_ATT)) { if (document.ContextosPorId.TryGetValue(hechoPrincipal.IdContexto, out context)) { var reportedDateOfReport = context.Periodo.Tipo.Equals(PeriodoDto.Duracion) ? context.Periodo.FechaFin : context.Periodo.FechaInstante; if (!extraParams.ContainsKey(ConstantsJBRL.REPORT_ENTITY_ATT)) { extraParams[ConstantsJBRL.REPORT_ENTITY_ATT] = context.Entidad.Id; } if (!extraParams.ContainsKey(ConstantsJBRL.REPORT_DATE_ATT)) { extraParams[ConstantsJBRL.REPORT_DATE_ATT] = auxiliar.ParseString(reportedDateOfReport); extraParams[ConstantsJBRL.REPORT_YEAR_ATT] = reportedDateOfReport.Year.ToString(); } } } var quarter = JBRLUtils.GetFirstFact(ConstantsJBRL.QUARTER_CONCEPT, document); var trustNumber = JBRLUtils.GetFirstFact(ConstantsJBRL.TRUST_NUMBRE_CONCEPT, document); if (quarter != null) { extraParams[ConstantsJBRL.REPORT_QUARTER_ATT] = quarter.Valor; } if (trustNumber != null) { extraParams[ConstantsJBRL.REPORT_TRUST_NUMBER_ATT] = trustNumber.Valor; } }
/// <summary> /// Insert the facts of a document into the mongo database. /// </summary> /// <param name="documentoInstanciXbrlDto">Documento to evaluate.</param> /// <param name="reportParams">Extra params to include.</param> /// <param name="factsList">Extra facts to include.</param> /// <param name="taskList">List of task to wait befor ends.</param> /// <param name="registrationDate">Registration date of the document.</param> /// <param name="abaxXBRLCellStoreMongo">Data access object of mongo.</param> public static void InsertFacts( DocumentoInstanciaXbrlDto documentoInstanciXbrlDto, IDictionary <String, String> reportParams, IList <FactJBRL> factsList, IList <Task> taskList, DateTime registrationDate, AbaxXBRLCellStoreMongo abaxXBRLCellStoreMongo) { var mongoDB = abaxXBRLCellStoreMongo.GetMongoDB(); JBRLUtils.SetReportParams(documentoInstanciXbrlDto, reportParams); var reportId = JBRLUtils.CreateReportId(reportParams); var reportRecordId = JBRLUtils.CreateReportRecordId(reportId, registrationDate); if (JBRLUtils.ExistsReportRecord(reportRecordId, abaxXBRLCellStoreMongo)) { return; } var replacementId = JBRLUtils.SarchReplacementId(reportId, reportRecordId, registrationDate, abaxXBRLCellStoreMongo); if (replacementId == null) { var taskVersion = JBRLUtils.UpdateReportsReplacementVersionAsync(reportId, reportRecordId, abaxXBRLCellStoreMongo); taskList.Add(taskVersion); } foreach (var hechoId in documentoInstanciXbrlDto.HechosPorId.Keys) { var hecho = documentoInstanciXbrlDto.HechosPorId[hechoId]; if (hecho.TipoDatoXbrl.Contains("64")) { continue; } var hechoJbrl = FactJBRL.Parse( hecho, documentoInstanciXbrlDto, reportId, reportRecordId, registrationDate, reportParams, replacementId); if (hechoJbrl != null) { factsList.Add(hechoJbrl); } else { LogUtil.Error(new Dictionary <string, object>() { { "Error", "No fué posible convertir el hecho a JBRL" }, { "HechoId", hecho.Id ?? "null" }, { "Concepto", hecho.IdConcepto ?? "null" }, { "Hecho", hecho } }); } } var modeloBaseList = new List <IModeloBase>(); modeloBaseList.AddRange(factsList); abaxXBRLCellStoreMongo.InserttChunksCollection(mongoDB, JBRLUtils.COLLECTION_NAME, modeloBaseList); var taskFactsEvaluation = JBRLUtils. UpdatePreviousFactsReplacementVersionAsync(factsList, abaxXBRLCellStoreMongo); taskList.Add(taskFactsEvaluation); }