Esempio n. 1
0
        public void WriteAsInlineXbrl()
        {
            // Arrange
            var zipArchive     = ZipFile.Open(@"Samples\IFRST_2017-03-09.zip", ZipArchiveMode.Read);
            var fileReader     = new ZipArchiveReader(zipArchive);
            var taxonomySource = new TaxonomyFileSet(fileReader);

            var instance = LoadInstanceFromExcelDocument(@"Samples\BSharpIfrsFactsValuesSampleV1.xlsx");

            instance.Dts.AddTaxonomy(new Uri("http://xbrl.ifrs.org/taxonomy/2017-03-09/full_ifrs_doc_entry_point_2017-03-09.xsd"), taxonomySource);
            AddExtensionTaxonomy(instance.Dts);

            var writerSettings = new InlineXbrlWriterSettings
            {
                Title   = "iXBRL Export",
                Culture = new CultureInfo("en-GB"),
                Scale   = 3,
                Scope   = new ScopeSettings
                {
                    PresentationNetworks = GetSupportedPresentationNetworks()
                },
                IncludeDocumentation = true,
                IncludeReferences    = true
            };

            // Act
            var xTemplate = XDocument.Load(@"Samples\iXBRL.xhtml");
            var writer    = new InlineXbrlWriter(xTemplate, writerSettings);

            instance.Save(writer);

            // Assert
            File.WriteAllText(@"C:\temp\banan-20180710.xhtml", writer.Document.ToString());
        }
        private void SaveAsInlineXbrl(FileInfo fileInfo)
        {
            if (!NamedParameters.ContainsKey("template"))
            {
                Context.Logger.WriteLine("Parameter 'template' is missing.");
                return;
            }
            var template = NamedParameters["template"];

            var xTemplate      = XDocument.Load(template);
            var writerSettings = new InlineXbrlWriterSettings
            {
                Title   = "iXBRL Export",
                Culture = new CultureInfo("en-GB"),
                Scale   = 3,
                IncludeDocumentation = true,
                IncludeReferences    = true,
            };

            var networks = new[]
            {
                new PresentationNetwork
                {
                    Name = "Statement of financial position, current/non-current",
                    Role = new Uri("http://xbrl.ifrs.org/role/ifrs/ias_1_2017-03-09_role-210000")
                },
                new PresentationNetwork
                {
                    Name = "Statement of comprehensive income, profit or loss, by function of expense",
                    Role = new Uri("http://xbrl.ifrs.org/role/ifrs/ias_1_2017-03-09_role-310000")
                },
                new PresentationNetwork
                {
                    Name = "Statement of cash flows, direct method",
                    Role = new Uri("http://xbrl.ifrs.org/role/ifrs/ias_7_2017-03-09_role-510000")
                },
                new PresentationNetwork
                {
                    Name = "Statement of changes in equity",
                    Role = new Uri("http://xbrl.ifrs.org/role/ifrs/ias_1_2017-03-09_role-610000")
                },
                new PresentationNetwork
                {
                    Name = "Notes - Subclassifications of assets, liabilities and equities",
                    Role = new Uri("http://xbrl.ifrs.org/role/ifrs/ias_1_2017-03-09_role-800100")
                },
                new PresentationNetwork
                {
                    Name = "Notes - Analysis of income and expense",
                    Role = new Uri("http://xbrl.ifrs.org/role/ifrs/ias_1_2017-03-09_role-800200")
                },
                new PresentationNetwork
                {
                    Name = "Notes - List of notes",
                    Role = new Uri("http://xbrl.ifrs.org/role/ifrs/ias_1_2017-03-09_role-800500")
                },
                new PresentationNetwork
                {
                    Name = "Notes - List of accounting policies",
                    Role = new Uri("http://xbrl.ifrs.org/role/ifrs/ias_1_2017-03-09_role-800600")
                },
                new PresentationNetwork
                {
                    Name = "Notes - Corporate information and statement of IFRS compliance",
                    Role = new Uri("http://xbrl.ifrs.org/role/ifrs/ias_1_2017-03-09_role-810000")
                },
                new PresentationNetwork
                {
                    Name = "Notes - Property, plant and equipment",
                    Role = new Uri("http://xbrl.ifrs.org/role/ifrs/ias_16_2017-03-09_role-822100")
                },
                new PresentationNetwork
                {
                    Name = "Notes - Fair value measurement",
                    Role = new Uri("http://xbrl.ifrs.org/role/ifrs/ifrs_13_2017-03-09_role-823000")
                },
                new PresentationNetwork
                {
                    Name = "Notes - Investment property",
                    Role = new Uri("http://xbrl.ifrs.org/role/ifrs/ias_40_2017-03-09_role-825100")
                },
                new PresentationNetwork
                {
                    Name = "Notes – Inventories",
                    Role = new Uri("http://xbrl.ifrs.org/role/ifrs/ias_2_2017-03-09_role-826380")
                },
                new PresentationNetwork
                {
                    Name = "Notes – Revenue",
                    Role = new Uri("http://xbrl.ifrs.org/role/ifrs/ias_18_2017-03-09_role-831110")
                },
                new PresentationNetwork
                {
                    Name = "Notes - Revenue from contracts with customers",
                    Role = new Uri("http://xbrl.ifrs.org/role/ifrs/ifrs_15_2017-03-09_role-831150")
                },
                new PresentationNetwork
                {
                    Name = "Notes - Impairment of assets",
                    Role = new Uri("http://xbrl.ifrs.org/role/ifrs/ias_36_2017-03-09_role-832410")
                },
                new PresentationNetwork
                {
                    Name = "Notes - Employee benefits",
                    Role = new Uri("http://xbrl.ifrs.org/role/ifrs/ias_19_2017-03-09_role-834480")
                },
                new PresentationNetwork
                {
                    Name = "Notes - Operating segments",
                    Role = new Uri("http://xbrl.ifrs.org/role/ifrs/ifrs_8_2017-03-09_role-871100")
                },
            };

            //var networks2 = new[]
            //{
            //    new PresentationNetwork
            //    {
            //        Name = "Statement of changes in equity",
            //        Role = new Uri("http://xbrl.ifrs.org/role/ifrs/ias_1_2017-03-09_role-610000")
            //    },
            //};

            writerSettings.Scope = new ScopeSettings
            {
                PresentationNetworks        = networks,
                IncludeEmptyConcepts        = false,
                IncludeEmptyExplicitMembers = false
            };

            var inlineXbrlWriter = new InlineXbrlWriter(xTemplate, writerSettings);

            Instance.Save(inlineXbrlWriter);
            var result = inlineXbrlWriter.Document.ToString();

            File.WriteAllText(fileInfo.FullName, result);
        }