-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathXBRL-UK-AE.php
472 lines (417 loc) · 15 KB
/
XBRL-UK-AE.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
<?php
/**
* Audit Exempt taxonomy implementation
*
* @author Bill Seddon
* @version 0.9
* @Copyright (C) 2018 Lyquidity Solutions Limited
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* Load the XBRL implementation
*/
require_once('XBRL.php');
/**
* Define the namespaces of the entry points supported by this taxonomy
* @var array
*/
$entrypoint_namespaces = array(
"http://www.companieshouse.gov.uk/ef/xbrl/uk/fr/gaap/ae/2009-06-21",
);
/**
* Register namespace to class map entries
*
* This call defines the namespaces that apply to the use of the XBRL decendent class defined in this file.
* The static function XBRL::withtaxonomy() will use the information provided by this call to instantiate
* the correct (this) class.
*/
XBRL::add_namespace_to_class_map_entries( array_merge( array(
"http://www.xbrl.org/uk/fr/gcd/2004-12-01",
"http://www.xbrl.org/uk/fr/gaap/pt/2004-12-01",
"http://www.companieshouse.gov.uk/ef/xbrl/uk/fr/gaap/ae/2009-06-21",
"http://www.xbrl.org/uk/fr/gaap/ci/2004-12-01",
), $entrypoint_namespaces ), "XBRL_UK_AE" );
XBRL::add_entry_namespace_to_class_map_entries( $entrypoint_namespaces, "XBRL_UK_AE" );
/**
* Register XSD to compiled taxonomy entries
*/
XBRL::add_xsd_to_compiled_map_entries( array( "uk-gaap-ae-2009-06-21.xsd" ), "uk-ae" );
/**
* Implements an XBRL descendent for the UK AE taxonomy.
* @author Bill Seddon
*/
class XBRL_UK_AE extends XBRL
{
/**
* http://www.companieshouse.gov.uk/ef/xbrl/uk/fr/gaap/ae/2009-06-21
* @var string
*/
public static $uk_AE_NS = "http://www.companieshouse.gov.uk/ef/xbrl/uk/fr/gaap/ae/2009-06-21";
/**
* http://www.xbrl.org/uk/fr/gaap/ci/2004-12-01
* @var string
*/
public static $uk_AE_CI_NS = "http://www.xbrl.org/uk/fr/gaap/ci/2004-12-01";
/**
* http://www.xbrl.org/uk/fr/gcd/2004-12-01
* @var string
*/
public static $uk_AE_GCD_NS = "http://www.xbrl.org/uk/fr/gcd/2004-12-01";
/**
* http://www.xbrl.org/uk/fr/gaap/pt/2004-12-01
* @var string
*/
public static $uk_AE_PT_NS = "http://www.xbrl.org/uk/fr/gaap/pt/2004-12-01";
/**
* The URL of the Commercial & Industrial taxonomy schema document
* @var string
*/
public static $uk_CI_XSD = "http://www.companieshouse.gov.uk/ef/xbrl/gaap/ci/2004-12-01/uk-gaap-ci-2004-12-01.xsd";
/**
* An array of element ids that when they appear in a report their values should be treated as text.
* This has a specific meaning in the default report: the associated values are not shown tied to a
* specific financial year.
* @var string[]
*/
public static $textItems = array(
"uk-gaap-ae_AccountingPolicies",
"uk-gaap-ae_AccountsAreInAccordanceWithSpecialProvisionsCompaniesActRelatingToSmallCompanies",
"uk-gaap-ae_CategoryItem",
"uk-gaap-ae_CompanyEntitledToExemptionUnderSection477CompaniesAct2006",
"uk-gaap-ae_CompanyNotDormant",
"uk-gaap-ae_ContentAccountingPolicy",
"uk-gaap-ae_DateAccountsReceived",
"uk-gaap-ae_DirectorsAcknowledgeTheirResponsibilitiesUnderCompaniesAct",
"uk-gaap-ae_MembersHaveNotRequiredCompanyToObtainAnAudit",
"uk-gaap-ae_TitleAccountingPolicy",
"uk-gaap-ae_TransactionsWithDirectors",
"uk-gaap-ae_TypeDepreciation",
"uk-gaap-pt_AccountsAreInAccordanceWithSpecialProvisionsCompaniesActRelatingToSmallCompanies",
"uk-gaap-pt_CompanyEntitledToExemptionUnderSection477CompaniesAct2006",
"uk-gaap-pt_DateApproval",
"uk-gaap-pt_NameApprovingDirector",
"uk-gaap-pt_StatementOnRelatedPartyDisclosure",
);
/**
* Elements for which the value should be used as a label. Usually used with tuples.
* @var array[string]
*/
public static $labelItems = array(
"uk-gaap-ae_TitleAccountingPolicy" => "uk-gaap-ae_ContentAccountingPolicy",
);
/**
* Default contructor
*/
public function __construct()
{
parent::__construct();
}
/**
* Example of overridding the import schema method which can be used to inject missing schemas
* {@inheritDoc}
* @see XBRL::importSchema()
* @param string $schemaLocation The location of the schema file being loaded
* @param int $depth (optional) The nesting depth
* @param bool $mainSchema True if the schema being loaded is the main DTS schema (entry point)
* @return void
*/
protected function importSchema( $schemaLocation, $depth = 0, $mainSchema = false )
{
parent::importSchema( $schemaLocation, $depth, $mainSchema );
}
/**
* A variable used to record whether the CI taxonomy has been loaded
* @var bool $ci_loaded
*/
private $ci_loaded = false;
/**
* Provides an opportunity for a descendant class implemenentation to take action before each taxonomy is loaded
* @param string $taxonomy_schema The name of the taxonomy being loaded
*/
protected function beforeLoadTaxonomy( $taxonomy_schema )
{
$xsd = "uk-gaap-ae-2009-06-21.xsd";
if ( $this->ci_loaded || basename( $taxonomy_schema ) !== $xsd ) return;
// Prevent recursive calls
$this->ci_loaded = true;
// Path relative to the AE taxonomy file
$xsd = "../../ci/2004-12-01/uk-gaap-ci-2004-12-01.xsd";
$this->log()->info( "Adding taxonomy $xsd" );
$this->importSchema( XBRL::resolve_path( $taxonomy_schema, $xsd ) );
$this->log()->info( $this->getSchemaLocation() );
}
/**
* The CI taxonomy is not imported by any of the schema documents
* {@inheritDoc}
* @see XBRL::afterLoadTaxonomy()
* @param string $taxonomy_schema The name of the taxonomy being loaded
*/
protected function afterLoadTaxonomy( $taxonomy_schema )
{
}
/**
* Gets the alignment for the element based on the type
* @param string $namespace
* @param string $name
* @return string The alignment to use
*/
public function valueAlignmentForNamespace( $namespace, $name )
{
$prefix = "";
switch ( $namespace )
{
case "http://www.companieshouse.gov.uk/ef/xbrl/uk/fr/gaap/ae/2009-06-21":
$prefix = "uk-gaap-ae";
break;
case "http://www.xbrl.org/uk/fr/gcd/2004-12-01":
$prefix = "uk-gcd";
break;
default:
return parent::valueAlignmentForNamespace( $namespace, $name );
}
$type = "$prefix:$name";
switch ( $type )
{
default:
return "left";
}
}
/**
* This function provides an opportunity for a taxonomy to sanitize and/or translate a string
*
* @param string $text The text to be sanitized
* @param string $type An optional element type such as num:integer
* @param string $language An optional language locale
* @return string The sanitized string
*/
public function sanitizeText( $text, $type = null, $language = null )
{
$text = str_replace( utf8_encode( '£' ), "£", $text ); // This is necessary to make sure the whole of the unicode character is replaced.
return rtrim( $text );
}
/**
* Returns the value of $elemment formatted according to the type defined in the taxonomy
* Overloads the implementation in XBRL
* @param array $element A representation of an element from an instance document
* @param XBRL_Instance $instance An instance of an instance class related to the $element
* @param bool $includeCurrency True if the returned monetary value should include a currency symbol
* @return mixed
*/
public function formattedValue( $element, $instance = null, $includeCurrency = true )
{
$value = $element['value'];
$type = XBRL_Instance::getElementType( $element );
switch ( $type )
{
case 'uk-gaap-ae:trueBooleanItemType':
return "True";
case 'uk-gaap-ae:CompaniesHouseDocumentAuthenticationType':
case 'uk-gaap-ae:CompaniesHouseRegisteredNumberType':
return $value;
case XBRL_Constants::$xbrliMonetaryItemType:
$element['value'] = str_replace( ',', '', $element['value'] );
return parent::formattedValue( $element, $instance );
case 'xbrli:decimalItemType':
// If it's the depreciation rate, format at a percent.
if ( $element['taxonomy_element']['id'] === 'uk-gaap-ae_RateDepreciation' )
{
// return sprintf("%.2f%%", $value * 100);
$formatter = new \NumberFormatter( $this->context->locale, NumberFormatter::PERCENT );
return $formatter->format( $value );
}
return parent::formattedValue( $element, $instance, $includeCurrency );
default:
return parent::formattedValue( $element, $instance, $includeCurrency );
}
}
/**
* Return the value of the element after removing any formatting.
* @param array $element
* @return float
* {@inheritDoc}
* @see XBRL::removeValueFormatting()
*/
public function removeNumberValueFormatting( $element )
{
return parent::removeNumberValueFormatting( $element );
}
/**
* Return a default for the language code. Can be overridden.
*/
public function getDefaultLanguage()
{
return 'en';
}
/**
* Returns true if the element value with the $key is defined as one to display as text
* Can be overridden in a descendent.
* @param string $key The key to lookup to determine whether the row should be treated as text
* @param string $type The type of the element
* @return boolean Defaults to false
*/
public function treatAsText( $key, $type )
{
if ( in_array( $key, XBRL_UK_AE::$textItems ) ) return true;
return parent::treatAsText( $key, $type );
}
/**
* Returns true if the element value with the $key is defined as one that should be used as a label - usually in tuple
* Can be overridden in a descendent.
* @param string $key The key to lookup to determine whether the row should be treated as a label
* @return boolean Defaults to false
*/
public function treatAsLabel( $key )
{
if ( isset( XBRL_UK_AE::$labelItems[ $key ] ) ) return XBRL_UK_AE::$labelItems[ $key ];
return parent::treatAsLabel( $key );
}
/**
* Get the default currency
*/
public function getDefaultCurrency()
{
return "USD";
}
/**
* Returns an array of locator(s) and corresponding presentation arc(s) that will be substituted for the $from in the $role
*
* Overrides XBRL to modify the presentation link base hierarchy.
*
* @param string $roleUri A role Uri to identify the base presentation link base being modified.
* @return array An array of locators and links
*/
public function getProxyPresentationNodes( $roleUri )
{
// $this->log()->info( "$roleUri" );
if ( ! property_exists( $this, 'proxyPresentationNodes' ) )
{
// Entity-Information
$this->proxyPresentationNodes[ $this->proxyRoleUriStandardInformation ] = array(
"locators" => $this->proxyLocatorsSI,
"addarcs" => $this->proxyAddArcsSI,
"deletenodes" => array(),
"removearcs" => array(),
);
/*
// Entity-Information
$this->proxyPresentationNodes[ $this->proxyRoleUriBalanceSheet ] = array(
"locators" => $this->proxyLocatorsBS,
"addarcs" => $this->proxyAddArcsBS,
"deletenodes" => array(),
"removearcs" => array(),
"aliases" => array(),
);
*/
// $this->log()->info( json_encode( $this->proxyPresentationNodes ) );
}
if ( ! is_array( $this->proxyPresentationNodes ) )
{
$this->log()->info( "The property 'proxyPresentationNodes' is not an array" );
return false;
}
if ( ! isset( $this->proxyPresentationNodes[ $roleUri ] ) )
return false;
return $this->proxyPresentationNodes[ $roleUri ];
}
/**
* http://www.xbrl-uk.org/ExtendedLinkRoles/AE-Standard-Information
* @var string
*/
private $proxyRoleUriStandardInformation = 'http://www.xbrl-uk.org/ExtendedLinkRoles/AE-Standard-Information';
/**
* http://www.xbrl-uk.org/ExtendedLinkRoles/AE-Balance-Sheet
* @var string
*/
private $proxyRoleUriBalanceSheet = 'http://www.xbrl-uk.org/ExtendedLinkRoles/AE-Balance-Sheet';
/**
* A set of locators to add to the presentation hierarchy
* @var array
*/
private $proxyLocatorsSI = array(
"uk-gcd_EntityInformation" => "uk-gcd-2004-12-01.xsd#uk-gcd_EntityInformation",
"uk-gcd_EntityNames" => "uk-gcd-2004-12-01.xsd#uk-gcd_EntityNames",
"uk-gcd_EntityCurrentLegalName" => "uk-gcd-2004-12-01.xsd#uk-gcd_EntityCurrentLegalName",
"uk-gcd_EntityTradingName" => "uk-gcd-2004-12-01.xsd#uk-gcd_EntityTradingName",
"uk-gcd_EntityFormerName" => "uk-gcd-2004-12-01.xsd#uk-gcd_EntityFormerName",
"uk-gcd_StatementDatesPeriodsCovered" => "uk-gcd-2004-12-01.xsd#uk-gcd_StatementDatesPeriodsCovered",
);
/**
* A set of locators to add to the presentation hierarchy
* @var array
*/
private $proxyLocatorsBS = array(
"uk-gaap-pt_ApprovalDetails" => "uk-gaap-pt-2004-12-01.xsd#uk-gaap-pt_ApprovalDetails",
"uk-gaap-pt_NameApprovingDirector" => "uk-gaap-pt-2004-12-01.xsd#uk-gaap-pt_NameApprovingDirector",
);
/**
* A set of arcs to add to the presentation hierarchy
* @var array
*/
private $proxyAddArcsSI = array(
array(
"from" => "uk-gcd-2004-12-01.xsd#uk-gcd_StandardInformation",
"to" => "uk-gcd-2004-12-01.xsd#uk-gcd_EntityInformation",
"order" => 1,
),
array(
"from" => "uk-gcd-2004-12-01.xsd#uk-gcd_EntityInformation",
"to" => "uk-gcd-2004-12-01.xsd#uk-gcd_EntityNames",
"order" => 1,
),
array(
"from" => "uk-gcd-2004-12-01.xsd#uk-gcd_EntityNames",
"to" => "uk-gcd-2004-12-01.xsd#uk-gcd_EntityCurrentLegalName",
"order" => 1,
),
array(
"from" => "uk-gcd-2004-12-01.xsd#uk-gcd_EntityNames",
"to" => "uk-gcd-2004-12-01.xsd#uk-gcd_EntityTradingName",
"order" => 1,
),
array(
"from" => "uk-gcd-2004-12-01.xsd#uk-gcd_EntityNames",
"to" => "uk-gcd-2004-12-01.xsd#uk-gcd_EntityFormerName",
"order" => 1,
),
array(
"from" => "uk-gcd-2004-12-01.xsd#uk-gcd_StandardInformation",
"to" => "uk-gcd-2004-12-01.xsd#uk-gcd_StatementDatesPeriodsCovered",
"order" => 1,
),
array(
"from" => "uk-gcd-2004-12-01.xsd#uk-gcd_StatementDatesPeriodsCovered",
"to" => "uk-gcd-2004-12-01.xsd#uk-gcd_BalanceSheetDate",
"order" => 1,
),
);
/**
* A set of arcs to add to the presentation hierarchy
* @var array
*/
private $proxyAddArcsBS = array(
array(
"from" => "uk-gaap-pt-2004-12-01.xsd#uk-gaap-pt_ApprovalByBoard",
"to" => "uk-gaap-pt-2004-12-01.xsd#uk-gaap-pt_ApprovalDetails",
"order" => 1,
),
array(
"from" => "uk-gaap-pt-2004-12-01.xsd#uk-gaap-pt_ApprovalDetails",
"to" => "uk-gaap-pt-2004-12-01.xsd#uk-gaap-pt_NameApprovingDirector",
"order" => 1,
),
);
}
?>