Skip to content

Commit 4185994

Browse files
committed
New package type for US-GAAP base taxonomies
1 parent 4ff328c commit 4185994

File tree

2 files changed

+145
-0
lines changed

2 files changed

+145
-0
lines changed

TaxonomyPackageTypes.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"classNames": [
55
"XBRL_ESMA_ESEF_Package",
66
"XBRL_IFRS_Package",
7+
"XBRL_USGAAP_Package",
78
"XBRL_TaxonomyPackage",
89
"XBRL_SEC_JSON_Package",
910
"XBRL_SEC_XML_Package",

XBRL-USGAAP-Package.php

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
<?php
2+
/**
3+
* XBRL IFRS Taxonomy Package handler
4+
*
5+
* @author Bill Seddon
6+
* @version 0.9
7+
* @Copyright (C) 2018 Lyquidity Solutions Limited
8+
*
9+
* This program is free software: you can redistribute it and/or modify
10+
* it under the terms of the GNU General Public License as published by
11+
* the Free Software Foundation, either version 3 of the License, or
12+
* (at your option) any later version.
13+
*
14+
* This program is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
* GNU General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU General Public License
20+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
21+
*
22+
*/
23+
24+
/**
25+
* Implements functions to read an IFRS taxonomy package
26+
*/
27+
class XBRL_USGAAP_Package extends XBRL_TaxonomyPackage
28+
{
29+
/**
30+
* Notes about using this package instance
31+
* @var string
32+
*/
33+
const notes = <<<EOT
34+
Uses the path of the entry point in the taxonomyPackage.xml file to determine the path to use in the cache.
35+
This should be the same as the value used in the schemaRef element in the instance document.
36+
The 'identifier' value in the taxonomyPackage.xml file appears to be the namespace of the taxonomy.\n\n
37+
The static array '\$defaultEntryPoints' will need to be updated each time there is a new taxonomy release
38+
to add a new default entry point.\n\n
39+
EOT;
40+
41+
/**
42+
* This will need to be updated when a new taxonomy is released
43+
* @var array Indexed by publication date
44+
*/
45+
private static $defaultEntryPoints = array(
46+
'2016-01-31' => 'http://xbrl.fasb.org/us-gaap/2016/entire/us-gaap-entryPoint-all-2016-01-31.xsd',
47+
'2017-01-31' => 'http://xbrl.fasb.org/us-gaap/2017/entire/us-gaap-entryPoint-all-2017-01-31.xsd',
48+
'2018-01-31' => 'http://xbrl.fasb.org/us-gaap/2018/entire/us-gaap-entryPoint-all-2018-01-31.xsd',
49+
'2019-01-31' => 'http://xbrl.fasb.org/us-gaap/2019/entire/us-gaap-entryPoint-all-2019-01-31.xsd',
50+
'2020-01-31' => 'http://xbrl.fasb.org/us-gaap/2020/entire/us-gaap-entryPoint-all-2020-01-31.xsd'
51+
);
52+
53+
/**
54+
*
55+
* @param \ZipArchive $zipArchive
56+
*/
57+
public function __construct( $zipArchive )
58+
{
59+
$this->skipEntryPoints = array(
60+
'http://xbrl.fasb.org/us-gaap/2017/entire/us-gaap-entryPoint-all-2017-01-31.xsd'
61+
);
62+
63+
parent::__construct( $zipArchive );
64+
}
65+
66+
/**
67+
* Returns true if the zip file represents a package that meets the taxonomy package specification
68+
* {@inheritDoc}
69+
* @see XBRL_Package::isPackage()
70+
*/
71+
public function isPackage()
72+
{
73+
if ( ! parent::isPackage() ) return false;
74+
75+
// If it is a package then is an IFRS taxonomy package?
76+
// A US-GAAP package is characterised by having one or more of the
77+
// package entry points be the entry points in the XBRL_US_GAAP_2015 entry point list
78+
// and no instance document.
79+
// Check the entry points first because they are already in an array.
80+
foreach ( $this->getSchemaEntryPoints() as $entryPoint )
81+
{
82+
if ( XBRL::startsWith( $entryPoint, "http://xbrl.fasb.org/us-gaap/" ) ) return true;
83+
}
84+
85+
return false;
86+
}
87+
88+
/**
89+
* Returns false
90+
* @param string $schemaFile
91+
* @return bool
92+
* @final
93+
*/
94+
public function isExtensionTaxonomy( $schemaFile = null )
95+
{
96+
return false;
97+
}
98+
99+
/**
100+
* Workout which file is the schema file
101+
* @return void
102+
* @throws "tpe:schemaFileNotFound"
103+
*/
104+
protected function determineSchemaFile()
105+
{
106+
if ( ! is_null( $this->schemaFile ) ) return;
107+
108+
$schemaFilesList = $this->getSchemaEntryPoints();
109+
110+
if ( count( $schemaFilesList ) == 0 )
111+
{
112+
throw XBRL_TaxonomyPackageException::withError( "tpe:schemaFileNotFound", "The package does not contain a schema (.xsd) file" );
113+
}
114+
115+
foreach ( $schemaFilesList as $schemaFile )
116+
{
117+
$actualUri = $this->getActualUri( $schemaFile );
118+
$content = $this->getFile( $actualUri );
119+
if ( $content )
120+
{
121+
$schemaNamespace = $this->getTargetNamespace( $schemaFile, $content );
122+
123+
$this->setUrlMap( $schemaNamespace, $schemaFile );
124+
125+
if ( isset( XBRL_IFRS_Package::$defaultEntryPoints[ $this->publicationDate ] ) &&
126+
XBRL_IFRS_Package::$defaultEntryPoints[ $this->publicationDate ] == $schemaFile )
127+
{
128+
$this->schemaNamespace = $schemaNamespace;
129+
$this->schemaFile = $schemaFile;
130+
}
131+
}
132+
}
133+
}
134+
135+
/**
136+
* Returns the name of the XBRL class that supports S GAAP pckage contents
137+
* {@inheritDoc}
138+
* @see XBRL_Package::getXBRLClassname()
139+
*/
140+
public function getXBRLClassname()
141+
{
142+
return "XBRL_US_GAAP_2015";
143+
}
144+
}

0 commit comments

Comments
 (0)