Exemplo n.º 1
0
        static void LoadInvalidInstance()
        {
            var xbrlDoc = new XbrlDocument();

            xbrlDoc.Load(@"..\..\..\..\..\..\JeffFerguson.Gepsio.Test\XBRL-CONF-2014-12-10\Common\300-instance\301-10-FootnoteFromOutOfScope.xml");
            CheckValidity(xbrlDoc);
        }
Exemplo n.º 2
0
        //-------------------------------------------------------------------------------
        //-------------------------------------------------------------------------------
        private void ExecuteVariation(string TestcaseXmlSourceDirectory, XmlNode VariationNode)
        {
            var currentVariation = new XBRLCONFCR520120124TestVariation(VariationNode);
            if (string.IsNullOrEmpty(currentVariation.Instance) == true)
                return;

            Debug.WriteLine("{0} [{1}]", currentVariation.Instance, currentVariation.Description);
            var instanceXmlSourceFullPathBuilder = new StringBuilder();
            instanceXmlSourceFullPathBuilder.AppendFormat("{0}{1}{2}", TestcaseXmlSourceDirectory, Path.DirectorySeparatorChar, currentVariation.Instance);
            var instanceXmlSourceFullPath = instanceXmlSourceFullPathBuilder.ToString();

            var newXbrlDocument = new XbrlDocument();
            newXbrlDocument.Load(instanceXmlSourceFullPath);
            if (newXbrlDocument.IsValid == true)
            {
                if (currentVariation.ValidityExpected == false)
                    AnnounceTestFailure(currentVariation);
            }
            if (newXbrlDocument.IsValid == false)
            {
                if (currentVariation.ValidityExpected == true)
                    AnnounceTestFailure(currentVariation, newXbrlDocument);
            }
            thisTestsPassed++;
        }
Exemplo n.º 3
0
        public void VerifyFixForIssue1()
        {
            var xbrlDoc = new XbrlDocument();

            xbrlDoc.Load("http://xbrlsite.com/US-GAAP/BasicExample/2010-09-30/abc-20101231.xml");
            Assert.IsTrue(xbrlDoc.IsValid);
        }
Exemplo n.º 4
0
        static void LoadValidInstance()
        {
            var xbrlDoc = new XbrlDocument();

            xbrlDoc.Load(@"..\..\..\..\..\..\JeffFerguson.Gepsio.Test\XBRL-CONF-2014-12-10\Common\300-instance\301-01-IdScopeValid.xml");
            CheckValidity(xbrlDoc);
        }
Exemplo n.º 5
0
        public void VerifyFixForIssue3_EnsureLocalSchemaLoad()
        {
            var xbrlDoc = new XbrlDocument();

            xbrlDoc.Load(@"..\..\..\IssueTests\3\offentliggorelse.xml");
            Assert.IsTrue(xbrlDoc.XbrlFragments[0].Schemas.Count > 0);
        }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            var xbrlDoc1 = new XbrlDocument();

            xbrlDoc1.Load(@"..\..\..\..\..\..\JeffFerguson.Gepsio.Test\XBRL-CONF-2014-12-10\Common\300-instance\301-01-IdScopeValid.xml");
            ShowContextsInDocument(xbrlDoc1);
            ShowFactsInDocument(xbrlDoc1);
        }
Exemplo n.º 7
0
        [Ignore]         // iXBRL unsupported at this time
        public void UKGAAP2009Test()
        {
            var doc = new XbrlDocument();

            doc.Load(@"..\..\..\JeffFerguson.Test.Gepsio\ixbrl-samples\UKGAAP2009.xml");
            Assert.IsNotNull(doc.XbrlFragments);
            Assert.AreNotEqual <int>(0, doc.XbrlFragments.Count, "No fragments found in document.");
        }
Exemplo n.º 8
0
        public void GetRoleTypeTest()
        {
            var NewXbrlDocument = new XbrlDocument();

            NewXbrlDocument.Load(@"..\..\..\JeffFerguson.Test.Gepsio\RoleType\tgt-20130202.xml");
            var balanceSheetRoleType = NewXbrlDocument.GetRoleType("BalanceSheet");

            Assert.IsNotNull(balanceSheetRoleType);
        }
Exemplo n.º 9
0
        public void VerifyFixForIssue3_EnsureAlternativeSchemaLoadPath()
        {
            var xbrlDoc = new XbrlDocument();
            var d       = Directory.GetCurrentDirectory();

            xbrlDoc.Load(@"..\..\..\IssueTests\3\offentliggorelse.xml");
            var loadedSchema = xbrlDoc.XbrlFragments[0].Schemas[0];

            Assert.AreNotEqual(loadedSchema.SchemaReferencePath, loadedSchema.LoadPath);
        }
Exemplo n.º 10
0
        public void PresentableTreeForAig20130630()
        {
            var xbrlDoc = new XbrlDocument();

            xbrlDoc.Load(GetRelativePathForDocument("aig-20130630.xml"));
            var firstFragment = xbrlDoc.XbrlFragments[0];
            var tree          = firstFragment.GetPresentableFactTree();

            Assert.IsNotNull(tree);
        }
Exemplo n.º 11
0
        static void Main(string[] args)
        {
            var xbrlDoc = new XbrlDocument();

            Console.Write("Loading...");
            xbrlDoc.Load("https://www.sec.gov/Archives/edgar/data/845877/000084587717000155/agm-20170930.xml");
            Console.WriteLine("done.");
            var calculationLinkbase = FindFirstAvailableCalculationLinkbase(xbrlDoc);

            PrintArcFactsAndWeights(calculationLinkbase);
        }
Exemplo n.º 12
0
        public void WorkItem9612Test()
        {
            var xbrlDocument = new XbrlDocument();

            xbrlDocument.Load(@"..\..\..\JeffFerguson.Test.Gepsio\WorkItemsInput\WorkItem9612\intc-20111231.xml");
            Assert.AreEqual <int>(1, xbrlDocument.XbrlFragments.Count);
            var firstFragment = xbrlDocument.XbrlFragments[0];

            Assert.AreEqual <int>(1, firstFragment.Schemas.Count);
            var firstSchema = firstFragment.Schemas[0];
        }
Exemplo n.º 13
0
        public void aig20130630()
        {
            var xbrlDoc        = new XbrlDocument();
            var timeBeforeLoad = System.DateTime.Now;

            xbrlDoc.Load(GetRelativePathForDocument("aig-20130630.xml"));
            var timeAfterLoad = System.DateTime.Now;
            var loadTime      = timeAfterLoad - timeBeforeLoad;

            Assert.IsTrue(xbrlDoc.IsValid);
        }
Exemplo n.º 14
0
        static void Main(string[] args)
        {
            var xbrlDoc = new XbrlDocument();

            xbrlDoc.Load(@"..\..\..\..\..\..\JeffFerguson.Gepsio.Test\XBRL-CONF-2014-12-10\Common\300-instance\301-01-IdScopeValid.xml");

            Console.WriteLine($"Number of fragments in the loaded document: {xbrlDoc.XbrlFragments.Count}.");
            foreach (var currentFragment in xbrlDoc.XbrlFragments)
            {
                // Work with the fragment here.
            }
        }
Exemplo n.º 15
0
        public void LoadXbrlFromStreamWithRelativeSchema()
        {
            var    webClient = new WebClient();
            string readXml   = webClient.DownloadString("http://www.sec.gov/Archives/edgar/data/789019/000119312515020351/msft-20141231.xml");

            byte[]       byteArray = Encoding.ASCII.GetBytes(readXml);
            MemoryStream memStream = new MemoryStream(byteArray);
            var          newDoc    = new XbrlDocument();

            newDoc.Load(memStream);
            Assert.IsFalse(newDoc.IsValid);
        }
Exemplo n.º 16
0
        public void LoadXbrlFromStreamSuccessfully()
        {
            var    webClient = new WebClient();
            string readXml   = webClient.DownloadString("http://www.xbrl.org/taxonomy/int/fr/ias/ci/pfs/2002-11-15/SampleCompany-2002-11-15.xml");

            byte[]       byteArray = Encoding.ASCII.GetBytes(readXml);
            MemoryStream memStream = new MemoryStream(byteArray);
            var          newDoc    = new XbrlDocument();

            newDoc.Load(memStream);
            Assert.IsTrue(newDoc.IsValid);
        }
Exemplo n.º 17
0
        static void Main(string[] args)
        {
            var xbrlDoc1 = new XbrlDocument();

            xbrlDoc1.Load(@"..\..\JeffFerguson.Gepsio.Test\XBRL-CONF-2014-12-10\Common\300-instance\301-01-IdScopeValid.xml");
            ShowFactsInDocument(xbrlDoc1);
            FindFactInDocument(xbrlDoc1, "changeInRetainedEarnings");

            var xbrlDoc2 = new XbrlDocument();

            xbrlDoc2.Load(@"..\..\JeffFerguson.Gepsio.Test\XBRL-CONF-2014-12-10\Common\300-instance\306-02-RequiredInstanceTupleValid.xml");
            ShowFactsInDocument(xbrlDoc2);
        }
Exemplo n.º 18
0
        public void WorkItem9571Test()
        {
            var xbrlDocument = new XbrlDocument();

            xbrlDocument.Load(@"..\..\..\JeffFerguson.Test.Gepsio\WorkItemsInput\WorkItem9571\Sample-Instance-Proof.xml");
            Assert.AreEqual <int>(1, xbrlDocument.XbrlFragments.Count);
            var firstFragment = xbrlDocument.XbrlFragments[0];

            Assert.AreEqual <int>(1, firstFragment.Schemas.Count);
            var firstSchema = firstFragment.Schemas[0];

            Assert.AreEqual <int>(60, firstSchema.RoleTypes.Count);
        }
Exemplo n.º 19
0
 public void VerifyFixForIssue16()
 {
     try
     {
         CultureInfo.CurrentCulture = CultureInfo.GetCultureInfo("fr");
         var xbrlDoc = new XbrlDocument( );
         xbrlDoc.Load("https://www.sec.gov/Archives/edgar/data/1688568/000168856818000036/csc-20170331.xml");
     }
     catch (FormatException)
     {
         Assert.Fail("Decimal number format should be culture independant.");
     }
 }
Exemplo n.º 20
0
        public void VerifyFixForIssue22()
        {
            var xbrlDoc = new XbrlDocument();

            try
            {
                xbrlDoc.Load(@"https://www.sec.gov/Archives/edgar/data/1018724/000101872419000004/amzn-20181231.xml");
            }
            catch (System.Exception)
            {
                Assert.Fail();
            }
        }
Exemplo n.º 21
0
        public void VerifyFixForIssue10()
        {
            var xbrlDoc = new XbrlDocument();

            xbrlDoc.Load("https://www.sec.gov/Archives/edgar/data/1688568/000168856818000036/csc-20170331.xml");
            foreach (var validationError in xbrlDoc.ValidationErrors)
            {
                if (validationError.Message.Contains("http://fasb.org/us-gaap/2017-01-31") == true)
                {
                    Assert.Fail();
                }
            }
        }
        public string GetXbrl()
        {
            var xbrlDoc = new XbrlDocument();

            xbrlDoc.Load("https://www.sec.gov/Archives/edgar/data/874292/000144526020000011/aey-20191231.xml");
            return(JsonConvert.SerializeObject(xbrlDoc.XbrlFragments
                                               .SelectMany(frag => frag.Facts)
                                               .Select(fact => new DTOs.FactResult
            {
                Name = fact.Name,
                Value = (fact as Item).Value
            }), Formatting.Indented));
        }
Exemplo n.º 23
0
        public void WalkPresentableTree()
        {
            var xbrlDoc = new XbrlDocument();

            xbrlDoc.Load(GetRelativePathForDocument("aig-20130630.xml"));
            var firstFragment = xbrlDoc.XbrlFragments[0];
            var tree          = firstFragment.GetPresentableFactTree();

            foreach (var currentNode in tree.TopLevelNodes)
            {
                WalkPresentableTreeNode(currentNode, 0);
            }
        }
Exemplo n.º 24
0
        public void Example13Row4()
        {
            XbrlDocument NewXbrlDocument = new XbrlDocument();

            NewXbrlDocument.Load(@"..\..\..\JeffFerguson.Test.Gepsio\InferPrecisionTestDocuments\Example13Row4.xbrl");
            Assert.AreEqual <int>(1, NewXbrlDocument.XbrlFragments.Count, "No XBRL fragments found.");
            XbrlFragment FirstFragment = NewXbrlDocument.XbrlFragments[0];

            Assert.AreEqual <int>(1, FirstFragment.Facts.Count, "No facts found in fragment.");
            Item FirstFact = FirstFragment.Facts[0] as Item;

            Assert.IsTrue(FirstFact.DecimalsSpecified);
            Assert.IsFalse(FirstFact.PrecisionSpecified);
            Assert.IsTrue(FirstFact.PrecisionInferred);
            Assert.AreEqual <int>(5, FirstFact.Precision);
        }
Exemplo n.º 25
0
        XbrlDocument acqire(Uri url)
        {
            var r = ResultWithValue.Of <Uri, WeakReference <XbrlDocument> >(wdic.TryGetValue, url)
                    .TrueOrNot(
                o => ResultWithValue.Of <XbrlDocument>(o.TryGetTarget).Value,
                x => null);

            if (r != null)
            {
                return(r);
            }
            deflag();
            //var ins = XbrlParser.ParseXmlFile(xp.Acqire(url));
            var ins = new XbrlDocument();

            ins.Load(url.ToString());
            wdic.Add(url, new WeakReference <XbrlDocument>(ins));
            return(ins);
        }
        public void ProcessXbrlInstanceDocument(string xmlUrl, Dictionary<string, List<string>> xbrlTaxonomyTree)
        {
            JeffFerguson.Gepsio.XbrlDocument xbrlDoc = new XbrlDocument();
            xbrlDoc.Load(xmlUrl);

            //AddXbrlNodes(xbrlDoc);

            int yearsToLoad = 3;

            string fileName = System.IO.Path.GetFileNameWithoutExtension(xmlUrl);
            string tickerSymbol = fileName.Split(new[] { '-' })[0];
            int year = GetFiscalYear(tickerSymbol, xbrlDoc.XbrlFragments[0]);

            IncomeStatement incToAdd = new IncomeStatement();
            BalanceSheet balToAdd = new BalanceSheet();
            CompanyAnnualData compAnnToAdd = new CompanyAnnualData();

            Dictionary<string, Object> yahooStats = GetYahooStatistics(tickerSymbol);

            CreateCompanyObject(tickerSymbol, xbrlDoc, yahooStats);

            for (int y = year; y > year - yearsToLoad; y--)
            {
                XbrlIncomeStatementFilter incFilter = new XbrlIncomeStatementFilter();
                XbrlBalanceSheetFilter bsFilter = new XbrlBalanceSheetFilter();
                XbrlCompanyAnnualFilter compAnFilter = new XbrlCompanyAnnualFilter();
                
                incToAdd = incFilter.Populate(this, xbrlDoc, tickerSymbol, y, xbrlTaxonomyTree);
                balToAdd = bsFilter.Populate(xbrlDoc, tickerSymbol, y, xbrlTaxonomyTree);
                compAnnToAdd = compAnFilter.Populate(xbrlDoc, tickerSymbol, y);

                compAnnToAdd.LeveredBeta = Convert.ToDecimal(yahooStats["Beta"]);
                compAnnToAdd.DividendYield = Convert.ToDecimal(yahooStats["DividendYield"]);

                IncomeStatementBL.Instance.UpdateIncomeStatement(incToAdd);
                BalanceSheetBL.Instance.UpdateBalanceSheet(balToAdd);
                CompanyAnnualDataBL.Instance.UpdateCompanyAnnual(compAnnToAdd);
            }
        }
Exemplo n.º 27
0
        public void ProcessXbrlInstanceDocument(string xmlUrl, Dictionary <string, List <string> > xbrlTaxonomyTree)
        {
            JeffFerguson.Gepsio.XbrlDocument xbrlDoc = new XbrlDocument();
            xbrlDoc.Load(xmlUrl);

            //AddXbrlNodes(xbrlDoc);

            int yearsToLoad = 3;

            string fileName     = System.IO.Path.GetFileNameWithoutExtension(xmlUrl);
            string tickerSymbol = fileName.Split(new[] { '-' })[0];
            int    year         = GetFiscalYear(tickerSymbol, xbrlDoc.XbrlFragments[0]);

            IncomeStatement   incToAdd     = new IncomeStatement();
            BalanceSheet      balToAdd     = new BalanceSheet();
            CompanyAnnualData compAnnToAdd = new CompanyAnnualData();

            Dictionary <string, Object> yahooStats = GetYahooStatistics(tickerSymbol);

            CreateCompanyObject(tickerSymbol, xbrlDoc, yahooStats);

            for (int y = year; y > year - yearsToLoad; y--)
            {
                XbrlIncomeStatementFilter incFilter    = new XbrlIncomeStatementFilter();
                XbrlBalanceSheetFilter    bsFilter     = new XbrlBalanceSheetFilter();
                XbrlCompanyAnnualFilter   compAnFilter = new XbrlCompanyAnnualFilter();

                incToAdd     = incFilter.Populate(this, xbrlDoc, tickerSymbol, y, xbrlTaxonomyTree);
                balToAdd     = bsFilter.Populate(xbrlDoc, tickerSymbol, y, xbrlTaxonomyTree);
                compAnnToAdd = compAnFilter.Populate(xbrlDoc, tickerSymbol, y);

                compAnnToAdd.LeveredBeta   = Convert.ToDecimal(yahooStats["Beta"]);
                compAnnToAdd.DividendYield = Convert.ToDecimal(yahooStats["DividendYield"]);

                IncomeStatementBL.Instance.UpdateIncomeStatement(incToAdd);
                BalanceSheetBL.Instance.UpdateBalanceSheet(balToAdd);
                CompanyAnnualDataBL.Instance.UpdateCompanyAnnual(compAnnToAdd);
            }
        }
Exemplo n.º 28
0
        public void VerifyFixForIssue13()
        {
            var xbrlDoc = new XbrlDocument();

            xbrlDoc.Load(@"..\..\..\IssueTests\13\Issue13.xml");
        }
Exemplo n.º 29
0
        public void VerifyFixForIssue8()
        {
            var xbrlDoc = new XbrlDocument();

            xbrlDoc.Load("https://www.sec.gov/Archives/edgar/data/1688568/000168856818000036/csc-20170331.xml");
        }
Exemplo n.º 30
0
        /// <summary>
        /// Opens a XML file in the Gepsio framework and stores all field values to the database
        /// </summary>
        /// <param name="TemporaryFilePath"></param>
        /// <returns></returns>
        private bool SaveXBRLtoDatabase(string TemporaryFilePath, int RSSD, DateTime Period)
        {
            // Make sure we were passed a valid file
            if (!File.Exists(TemporaryFilePath))
            {
                throw new FileNotFoundException();
            }

            XbrlDocument LocalReport = new XbrlDocument();

            try
            {
                // Checks to see if a file exists.  If it does, load the file and return the XBLR document, otherwise return null
                LocalReport.Load(TemporaryFilePath);
            }
            catch (Exception) { Console.WriteLine("Could not load XbrlDocument from Temporary File"); return(false); }

            try
            {
                using (var db = database.GetContext())
                {
                    // Get the report shell from the database
                    Report DatabaseReport = db.GetBank(RSSD).GetReport(Period);

                    // Each report may contain the current period value, as well as prior quarter and prior year values, identified in the 'contextrefname'
                    // Filter out values from prior periods and store the valid items in an array of Item objects
                    Item[] Facts = (from Item f in LocalReport.XbrlFragments[0].Facts.AsParallel()
                                    where f.ContextRefName.Contains(Period.ToString("yyyy-MM-dd"))
                                    select f).ToArray();

                    // Parse each Item and send to the database for storage
                    for (int i = 0; i < Facts.Count(); i++)
                    {
                        if (Decimal.TryParse(Facts[i].Value, out decimal parseResultDec))
                        {
                            DatabaseReport.SetValue(Facts[i].Name, parseResultDec);
                        }
                        else if (Boolean.TryParse(Facts[i].Value, out Boolean parseResultBool))
                        {
                            DatabaseReport.SetValue(Facts[i].Name, Convert.ToDecimal(parseResultBool));
                        }
                        else
                        {
                            DatabaseReport.SetValue(Facts[i].Name, 0);
                        }
                    }

                    db.SaveChanges();

                    Console.WriteLine("Saved XBRL data to database for ID: {0}  Date: {1}", RSSD, Period);

                    LocalReport = null;
                    Facts       = null;

                    return(true);
                }
            }
            catch (Exception ex) { Console.WriteLine("Report load error: {0}", ex.Message); }
            finally
            {
                LocalReport = null;
            }

            return(false);
        }
Exemplo n.º 31
0
        static void LoadFromUrl()
        {
            var xbrlDoc = new XbrlDocument();

            xbrlDoc.Load("http://xbrlsite.com/US-GAAP/BasicExample/2010-09-30/abc-20101231.xml");
        }