Skip to content

Commit

Permalink
EIOPA DPM database, improve enumeration checks, output
Browse files Browse the repository at this point in the history
monetary and percentage with minimum decimal lexical zeros
  • Loading branch information
hefischer committed Jul 1, 2015
1 parent cba68a2 commit 30fa1f5
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions arelle/plugin/xbrlDB/XbrlDpmSqlDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@
decimalsPattern = re.compile("^(-?[0-9]+|INF)$")
sigDimPattern = re.compile(r"([^(]+)[(]([^\[)]*)(\[([0-9;]+)\])?[)]")
ONE = Decimal("1")
ONE00 = Decimal("1.00")
ONE0000 = Decimal("1.0000")

def insertIntoDB(modelXbrl,
user=None, password=None, host=None, port=None, database=None, timeout=None,
Expand Down Expand Up @@ -372,10 +374,15 @@ def insertInstanceToDB(self, isStreaming=False):
self.largeDimensionMemberIds[_dim][_memQn] = _memId

# get enumeration element values
result = self.execute("select mem.MemberXBRLCode, enum.MemberXBRLCode from mMember mem "
"inner join mMetric met on met.CorrespondingMemberID = mem.MemberID "
result = self.execute("select mem.MemberXBRLCode, enum.MemberXBRLCode from mMetric met "
"inner join mMember mem on mem.MemberID = met.CorrespondingMemberID "
"inner join mHierarchyNode hn on hn.HierarchyID = met.ReferencedHierarchyID "
"inner join mMember enum on enum.MemberID = hn.MemberID ")
"inner join mMember enum on enum.MemberID = hn.MemberID "
"where (hn.IsAbstract is null or hn.IsAbstract = 0) "
" and case when met.HierarchyStartingMemberID is not null then "
" (hn.Path like '%'||ifnull(met.HierarchyStartingMemberID,'')||'%' "
" or (hn.MemberID = ifnull(met.HierarchyStartingMemberID,'') and 1 = ifnull(met.IsStartingMemberIncluded,0))) "
" else 1 end")
self.enumElementValues = defaultdict(set)
for _elt, _enum in result:
self.enumElementValues[_elt].add(_enum)
Expand Down Expand Up @@ -1171,17 +1178,13 @@ def nilTypedDimElt(dimQn):
text = Locale.format(Locale.C_LOCALE, "%.*f", (dec, num)) # culture-invariant locale
'''
try:
'''
text = str(numVal)
if c == 'm':
text = "{:.2f}".format(numVal)
text = str(Decimal(text) + ONE00 - ONE) # force two decimals
elif c == 'p':
text = "{:.4f}".format(numVal)
text = str(Decimal(text) + ONE0000 - ONE) # force four decimals
elif c == 'i':
text = "{:.0f}".format(numVal)
else:
text = str(numVal)
'''
text = str(numVal)
text = str(int(numVal))
except Exception:
text = str(numVal)
else:
Expand Down

0 comments on commit 30fa1f5

Please sign in to comment.