Skip to content

Commit

Permalink
Merge pull request #1054 from allenbross-wf/XT-3513
Browse files Browse the repository at this point in the history
Added HMRC Unaudited Dormant LLP validations
  • Loading branch information
derekgengenbacher-wf committed Jan 24, 2024
2 parents 22bbbc5 + ea08476 commit 41f4fff
Show file tree
Hide file tree
Showing 16 changed files with 782 additions and 12 deletions.
120 changes: 117 additions & 3 deletions arelle/plugin/validate/HMRC/ValidateHmrc.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,45 @@
from arelle.ModelXbrl import ModelXbrl

# Error codes
CO_ABRID = 'Co.Abrid'
CO_AUDIT_NR = 'Co.AuditNR'
CO_DIR_RESP = 'Co.DirResp'
CO_MICRO = 'Co.Micro'
CO_MISSING_ELEMENT = 'Co.MissingElement'
CO_SM_CO = 'Co.SmCo'
CO_SEC_480 = 'Co.Sec480'
LP_ABRID = 'Lp.Abrid'
LP_MEM_RESP = 'Lp.MemResp'
LP_SEC_477 = 'Lp.Sec477'
LP_SEC_480 = 'Lp.Sec480'
LP_SM_LP = 'Lp.SmLp'


# Concept local names
CONCEPT_ACCOUNTS_STATUS = 'AccountsStatusAuditedOrUnaudited'
CONCEPT_ACCOUNTS_STATUS_DIMENSION = 'AccountsStatusDimension'
CONCEPT_ENTITY_DORMANT = 'EntityDormantTruefalse'
CONCEPT_LANGUAGES_DIMENSION = 'LanguagesDimension'
CONCEPT_LEGAL_FORM_ENTIY = 'LegalFormEntity'
CONCEPT_LEGAL_FORM_ENTIY_DIMENSION = 'LegalFormEntityDimension'
CONCEPT_LLP = 'LimitedLiabilityPartnershipLLP'
CONCEPT_REPORT_PRINCIPAL_LANGUAGE = 'ReportPrincipalLanguage'
CONCEPT_WELSH = 'Welsh'

# Map of error code > concept local name > tuple of pairings of descriptions and regex patterns
TEXT_VALIDATION_PATTERNS: dict[str, dict[str, tuple[tuple[str, re.regex.Pattern[str]], ...]]] = {
CO_ABRID: {
'StatementThatMembersHaveAgreedToPreparationAbridgedAccountsUnderSection444CompaniesAct2006': (
(
'Members" or "Member", then "agreed" or "consented", then "preparation", then "abridged")',
re.compile(r".*(Members|Member).*(agreed|consented).*preparation.*abridged.*"),
),
(
'"Aelodau" or "Aelod", then "wedi cytuno" or "cydsynio", then "paratoi", then "talfyredig")',
re.compile(r".*(Aelodau|Aelod).*(wedi cytuno|cydsynio).*paratoi.*talfyredig.*"),
),
),
},
CO_AUDIT_NR: {
'StatementThatMembersHaveNotRequiredCompanyToObtainAnAudit': (
(
Expand Down Expand Up @@ -91,13 +113,73 @@
re.compile(r".*Paratowyd yn unol â.*darpariaethau.*cwmnïau bach.*"),
),
),
}
},
LP_ABRID: {
'StatementThatMembersHaveAgreedToPreparationAbridgedAccountsUnderSection444CompaniesAct2006': (
(
'Members" or "Member", then "agreed" or "consented", then "preparation", then "abridged")',
re.compile(r".*(Members|Member).*(agreed|consented).*preparation.*abridged.*"),
),
(
'"Aelodau" or "Aelod", then "wedi cytuno" or "cydsynio", then "paratoi", then "talfyredig")',
re.compile(r".*(Aelodau|Aelod).*(wedi cytuno|cydsynio).*paratoi.*talfyredig.*"),
),
),
},
LP_MEM_RESP: {
'StatementThatDirectorsAcknowledgeTheirResponsibilitiesUnderCompaniesAct': (
(
'"Members acknowledge" or "Member acknowledges", then "responsibilities", then "Companies Act 2006" or "the Act", then "Limited Liability Partnership" or "LLP"',
re.compile(r".*(Members acknowledge|Member acknowledges).*responsibilities.*(Companies Act 2006|the Act).*(Limited Liability Partnership|LLP).*"),
),
(
'"Aelodau\'n cydnabod" or "Aelod yn cydnabod", then "cyfrifoldebau", then "Ddeddf Cwmnïau 2006" or "y Ddeddf", then "Partneriaeth Atebolrwydd Cyfyngedig" or "PAC"',
re.compile(r".*(Aelodau'n cydnabod|Aelod yn cydnabod).*cyfrifoldebau.*(Ddeddf Cwmnïau 2006|y Ddeddf).*(Partneriaeth Atebolrwydd Cyfyngedig|PAC).*"),
),
),
},
LP_SEC_477: {
'StatementThatCompanyEntitledToExemptionFromAuditUnderSection477CompaniesAct2006RelatingToSmallCompanies': (
(
'"Exempt" OR "Exemption", then "section 477 of the Companies Act 2006" then, "Limited Liability Partnership" OR "LLP")',
re.compile(r".*(Exempt|Exemption).*section 477 of the Companies Act 2006.*(Limited Liability Partnership|LLP).*"),
),
(
'"Wedi\'i eithrio" or "Eithriad", then "adran 477 o Ddeddf Cwmnïau 2006", then "Partneriaeth Atebolrwydd Cyfyngedig" OR "PAC"',
re.compile(r".*(Wedi'i eithrio|Eithriad).*adran 477 o Ddeddf Cwmnïau 2006.*(Partneriaeth Atebolrwydd Cyfyngedig|PAC).*"),
),
),
},
LP_SEC_480: {
'StatementThatCompanyEntitledToExemptionFromAuditUnderSection480CompaniesAct2006RelatingToDormantCompanies': (
(
'"Exempt" or "Exemption", then "section 480 of the Companies Act 2006", then "Limited Liability Partnership" OR "LLP"',
re.compile(r".*(Exempt|Exemption).*section 480 of the Companies Act 2006.*(Limited Liability Partnership|LLP).*"),
),
(
'"Wedi\'i eithrio" or "Eithriad", then "adran 480 o Ddeddf Cwmnïau 2006"',
re.compile(r".*(Wedi'i eithrio|Eithriad).*adran 480 o Ddeddf Cwmnïau 2006.*(Partneriaeth Atebolrwydd Cyfyngedig|PAC).*"),
),
),
},
LP_SM_LP: {
'StatementThatAccountsHaveBeenPreparedInAccordanceWithProvisionsSmallCompaniesRegime': (
(
'"Prepared in accordance with", then "provisions", then "small Limited Liability Partnership" OR "small LLP',
re.compile(r".*Prepared in accordance with.*provisions.*(small Limited Liability Partnership|small LLP).*"),
),
(
'"Paratowyd yn unol â", then "y darpariaethau", then "Partneriaeth Atebolrwydd Cyfyngedig bach" or "PAC bach")',
re.compile(r".*Paratowyd yn unol â.*y darpariaethau.*(Partneriaeth Atebolrwydd Cyfyngedig bach|PAC bach).*"),
),
),
},
}


class AccountStatus(Enum):
AUDIT_EXEMPT_NO_REPORT = 'AuditExempt-NoAccountantsReport'
AUTIT_EXEMPT_WITH_REPORT = 'AuditExemptWithAccountantsReport'
AUDIT_EXEMPT_WITH_REPORT = 'AuditExemptWithAccountantsReport'


@dataclass
Expand Down Expand Up @@ -229,6 +311,19 @@ def isEntityDormant(self) -> bool:
return False
return all(not f.isNil and isinstance(f.xValue, bool) and f.xValue for f in facts)

@cached_property
def legalFormEntity(self) -> str | None:
facts = self._getFacts(CONCEPT_LEGAL_FORM_ENTIY)
for fact in facts:
if fact is None:
continue
if fact.isNil:
continue
for qname, value in fact.context.qnameDims.items():
if qname.localName == CONCEPT_LEGAL_FORM_ENTIY_DIMENSION:
return cast(str, value.xValue.localName)
return None

def validate(self) -> None:
"""
Find the appropriate set of validations to run on this document and runs them.
Expand All @@ -238,7 +333,10 @@ def validate(self) -> None:
AccountStatus.AUDIT_EXEMPT_NO_REPORT.value,
AccountStatus.AUDIT_EXEMPT_NO_REPORT.value,
}:
self.validateUnauditedDormantCompany()
if self.legalFormEntity == CONCEPT_LLP:
self.validateUnauditedDormantLLP()
else:
self.validateUnauditedDormantCompany()

def validateUnauditedDormantCompany(self) -> None:
"""
Expand All @@ -262,3 +360,19 @@ def validateUnauditedDormantCompany(self) -> None:
if not smCoResult.success:
self._errorOnMissingFactText(CO_MICRO, result)
self._errorOnMissingFactText(CO_SM_CO, smCoResult)

def validateUnauditedDormantLLP(self) -> None:
"""
Checks conditions applicable to unaudited dormant LLPs:
LP.MemResp and LP.Sec480 and LP.SmLP).
:return:
"""
result = self._evaluateCode(LP_MEM_RESP)
if not result.success:
self._errorOnMissingFactText(LP_MEM_RESP, result)
result = self._evaluateCode(LP_SEC_480)
if not result.success:
self._errorOnMissingFactText(LP_SEC_480, result)
result = self._evaluateCode(LP_SM_LP)
if not result.success:
self._errorOnMissingFactText(LP_SM_LP, result)
5 changes: 3 additions & 2 deletions arelle/plugin/validate/HMRC/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,8 +456,9 @@ def checkFacts(facts):
_("Element %(elt)s style attribute has disallowed image reference: %(styleImage)s."),
modelObject=elt, elt=elt.tag.rpartition("}")[2], styleImage=match)

hmrc = ValidateHmrc(modelXbrl)
hmrc.validate()
if val.txmyType != "charities":
hmrc = ValidateHmrc(modelXbrl)
hmrc.validate()

modelXbrl.profileActivity(_statusMsg, minTimeToShow=0.0)
modelXbrl.modelManager.showStatus(None)
Expand Down
1 change: 1 addition & 0 deletions tests/resources/conformance_suites/HMRC/index.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
<testcase uri='jfcvc/3312-testcase.xml' />
<testcase uri='jfcvc/3315-testcase.xml' />
<testcase uri='unaudited_dormant_company/testcase.xml' />
<testcase uri='unaudited_dormant_llp/testcase.xml' />
</testcases>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<xbrl
xmlns="http://www.xbrl.org/2003/instance"
xmlns:bus="http://xbrl.frc.org.uk/cd/2023-01-01/business"
xmlns:char="http://xbrl.frc.org.uk/char/2023-01-01"
xmlns:core="http://xbrl.frc.org.uk/fr/2023-01-01/core"
xmlns:direp="http://xbrl.frc.org.uk/reports/2023-01-01/direp"
xmlns:link="http://www.xbrl.org/2003/linkbase"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<xbrl
xmlns="http://www.xbrl.org/2003/instance"
xmlns:bus="http://xbrl.frc.org.uk/cd/2023-01-01/business"
xmlns:char="http://xbrl.frc.org.uk/char/2023-01-01"
xmlns:core="http://xbrl.frc.org.uk/fr/2023-01-01/core"
xmlns:direp="http://xbrl.frc.org.uk/reports/2023-01-01/direp"
xmlns:link="http://www.xbrl.org/2003/linkbase"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<xbrl
xmlns="http://www.xbrl.org/2003/instance"
xmlns:bus="http://xbrl.frc.org.uk/cd/2023-01-01/business"
xmlns:char="http://xbrl.frc.org.uk/char/2023-01-01"
xmlns:core="http://xbrl.frc.org.uk/fr/2023-01-01/core"
xmlns:direp="http://xbrl.frc.org.uk/reports/2023-01-01/direp"
xmlns:link="http://www.xbrl.org/2003/linkbase"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<xbrl
xmlns="http://www.xbrl.org/2003/instance"
xmlns:bus="http://xbrl.frc.org.uk/cd/2023-01-01/business"
xmlns:char="http://xbrl.frc.org.uk/char/2023-01-01"
xmlns:core="http://xbrl.frc.org.uk/fr/2023-01-01/core"
xmlns:direp="http://xbrl.frc.org.uk/reports/2023-01-01/direp"
xmlns:link="http://www.xbrl.org/2003/linkbase"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<xbrl
xmlns="http://www.xbrl.org/2003/instance"
xmlns:bus="http://xbrl.frc.org.uk/cd/2023-01-01/business"
xmlns:char="http://xbrl.frc.org.uk/char/2023-01-01"
xmlns:core="http://xbrl.frc.org.uk/fr/2023-01-01/core"
xmlns:direp="http://xbrl.frc.org.uk/reports/2023-01-01/direp"
xmlns:link="http://www.xbrl.org/2003/linkbase"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<xbrl
xmlns="http://www.xbrl.org/2003/instance"
xmlns:bus="http://xbrl.frc.org.uk/cd/2023-01-01/business"
xmlns:char="http://xbrl.frc.org.uk/char/2023-01-01"
xmlns:core="http://xbrl.frc.org.uk/fr/2023-01-01/core"
xmlns:direp="http://xbrl.frc.org.uk/reports/2023-01-01/direp"
xmlns:lang="http://xbrl.frc.org.uk/cd/2023-01-01/languages"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<xbrl
xmlns="http://www.xbrl.org/2003/instance"
xmlns:bus="http://xbrl.frc.org.uk/cd/2023-01-01/business"
xmlns:char="http://xbrl.frc.org.uk/char/2023-01-01"
xmlns:core="http://xbrl.frc.org.uk/fr/2023-01-01/core"
xmlns:direp="http://xbrl.frc.org.uk/reports/2023-01-01/direp"
xmlns:lang="http://xbrl.frc.org.uk/cd/2023-01-01/languages"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="UTF-8"?>
<xbrl
xmlns="http://www.xbrl.org/2003/instance"
xmlns:bus="http://xbrl.frc.org.uk/cd/2023-01-01/business"
xmlns:core="http://xbrl.frc.org.uk/fr/2023-01-01/core"
xmlns:direp="http://xbrl.frc.org.uk/reports/2023-01-01/direp"
xmlns:lang="http://xbrl.frc.org.uk/cd/2023-01-01/languages"
xmlns:link="http://www.xbrl.org/2003/linkbase"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xbrldi="http://xbrl.org/2006/xbrldi">
<link:schemaRef
xlink:href="https://xbrl.frc.org.uk/FRS-101/2023-01-01/FRS-101-2023-01-01.xsd"
xlink:type="simple"/>

<context id="accounting-standards">
<entity>
<identifier scheme="http://www.gooog">12345678</identifier>
<segment>
<xbrldi:explicitMember dimension="bus:AccountingStandardsDimension">bus:SmallEntities</xbrldi:explicitMember>
</segment>
</entity>
<period>
<startDate>2021-01-01</startDate>
<endDate>2021-12-30</endDate>
</period>
</context>
<bus:AccountingStandardsApplied contextRef="accounting-standards"></bus:AccountingStandardsApplied>

<context id="accounts-status">
<entity>
<identifier scheme="http://www.gooog">12345678</identifier>
<segment>
<xbrldi:explicitMember dimension="bus:AccountsStatusDimension">bus:AuditExempt-NoAccountantsReport</xbrldi:explicitMember>
</segment>
</entity>
<period>
<startDate>2021-01-01</startDate>
<endDate>2021-12-30</endDate>
</period>
</context>
<bus:AccountsStatusAuditedOrUnaudited contextRef="accounts-status"></bus:AccountsStatusAuditedOrUnaudited>

<context id="accounts-type">
<entity>
<identifier scheme="http://www.gooog">12345678</identifier>
<segment>
<xbrldi:explicitMember dimension="bus:AccountsTypeDimension">bus:FullAccounts</xbrldi:explicitMember>
</segment>
</entity>
<period>
<startDate>2021-01-01</startDate>
<endDate>2021-12-30</endDate>
</period>
</context>
<bus:AccountsType contextRef="accounts-type"></bus:AccountsType>

<context id="duration">
<entity>
<identifier scheme="http://www.gooog">12345678</identifier>
</entity>
<period>
<startDate>2021-01-01</startDate>
<endDate>2021-12-30</endDate>
</period>
</context>
<bus:DescriptionPrincipalActivities contextRef="duration">text</bus:DescriptionPrincipalActivities>
<bus:EntityCurrentLegalOrRegisteredName contextRef="duration">text</bus:EntityCurrentLegalOrRegisteredName>
<bus:EntityDormantTruefalse contextRef="duration">true</bus:EntityDormantTruefalse>
<bus:EntityTradingStatus contextRef="duration"></bus:EntityTradingStatus>
<direp:StatementThatCompanyEntitledToExemptionFromAuditUnderSection477CompaniesAct2006RelatingToSmallCompanies contextRef="duration">
Exempt from audit under section 477 of the Companies Act 2006 LLP
</direp:StatementThatCompanyEntitledToExemptionFromAuditUnderSection477CompaniesAct2006RelatingToSmallCompanies>
<direp:StatementThatCompanyEntitledToExemptionFromAuditUnderSection480CompaniesAct2006RelatingToDormantCompanies contextRef="duration">
Exempt from audit under section 480 of the Companies Act 2006 LLP
</direp:StatementThatCompanyEntitledToExemptionFromAuditUnderSection480CompaniesAct2006RelatingToDormantCompanies>
<core:DirectorSigningFinancialStatements contextRef="duration"></core:DirectorSigningFinancialStatements>
<direp:StatementThatAccountsHaveBeenPreparedInAccordanceWithProvisionsSmallCompaniesRegime contextRef="duration">
Prepared in accordance with provisions micro small LLP
</direp:StatementThatAccountsHaveBeenPreparedInAccordanceWithProvisionsSmallCompaniesRegime>
<!-- CAUSE: Text does not match, should be "Friendship" instead of "Partnership" -->
<direp:StatementThatDirectorsAcknowledgeTheirResponsibilitiesUnderCompaniesAct contextRef="duration">
Member acknowledges responsibilities of the Act of forming Limited Liability Friendship
</direp:StatementThatDirectorsAcknowledgeTheirResponsibilitiesUnderCompaniesAct>
<direp:StatementThatMembersHaveNotRequiredCompanyToObtainAnAudit contextRef="duration">
Members have not required the company to obtain an audit
</direp:StatementThatMembersHaveNotRequiredCompanyToObtainAnAudit>
<direp:StatementThatMembersHaveAgreedToPreparationAbridgedAccountsUnderSection444CompaniesAct2006 contextRef="duration">
Members agreed to the preparation abridged
</direp:StatementThatMembersHaveAgreedToPreparationAbridgedAccountsUnderSection444CompaniesAct2006>

<context id="instant">
<entity>
<identifier scheme="http://www.gooog">12345678</identifier>
</entity>
<period>
<instant>2021-12-30</instant>
</period>
</context>
<bus:BalanceSheetDate contextRef="instant">2021-01-01</bus:BalanceSheetDate>
<bus:EndDateForPeriodCoveredByReport contextRef="instant">2021-01-01</bus:EndDateForPeriodCoveredByReport>
<bus:StartDateForPeriodCoveredByReport contextRef="instant">2020-01-01</bus:StartDateForPeriodCoveredByReport>
<core:DateAuthorisationFinancialStatementsForIssue contextRef="instant">2021-01-01</core:DateAuthorisationFinancialStatementsForIssue>

<context id="legal-form-entity">
<entity>
<identifier scheme="http://www.gooog">12345678</identifier>
<segment>
<xbrldi:explicitMember dimension="bus:LegalFormEntityDimension">bus:LimitedLiabilityPartnershipLLP</xbrldi:explicitMember>
</segment>
</entity>
<period>
<startDate>2021-01-01</startDate>
<endDate>2021-12-30</endDate>
</period>
</context>
<bus:LegalFormEntity contextRef="legal-form-entity"></bus:LegalFormEntity>
</xbrl>

0 comments on commit 41f4fff

Please sign in to comment.