Search Posts

Visits: 772

XBRL GL Instance Viewing Service

These are prototype services for viewing XBRL GL instance documents generated by accounting softwares.
(You can find source programs at the GitHub site..)

1. iphix sample(XBRL 2.1)
http://www.sambuichi.jp/xbrlgl/index.html
Original file location http://gl.iphix.net/files.htm

2. PCA (XBRL 2.0a)
2.1 View of  document structure  of XBRL GL instance for each entry
http://www.sambuichi.jp/xbrlgl/pca.html
2.2 View of journal entry by entered slip
http://www.sambuichi.jp/xbrlgl/journal_entry.html
2.3 View of summary by month and/or chart of accounts. These documents are stored in database.
http://www.sambuichi.jp/xbrlgl/list.html

Programming TIPS: jQuery’s XML function

We processed XBRL files with HTML5, CSS3, jQuery, javascript in samples 1. 2. 2.1. 2.2 .
XBRL GL instance documents are XML documents. We can use jQuery’s XML function.
XBRL GL instance documents are stored in a database at Amazon Web Service.
When you click a button, the next function load selected file with load_xmlfile().

[javascript] glLoad function

function glLoad() {
    var glSelectList = $('select#glselect');
    var url = $('option:selected', glSelectList).val();
    load_xmlfile(url);
}

load_xmlfile(url) reads XBRL GL instance document stored at the location defied by URL then process this document to generate page.

[javascript] load_xmlfile function

function load_xmlfile(url) {
    $.ajax({
        url : url,
        type : 'GET',
        dataType : 'text',
        timeout : 1000,
        error : fnc_xmlerr, //call "fnc_xmlerr" on failure
        success : fnc_xml   //call "fnc_xml" on success
    });
};

When program consumed XBRL GL instance normally, this document is passed to fnc_xml(xml) function as an argument xml. XML function of jQuery can process this as a XML document.
With fundamental knowledge of XBRL GL taxonomy, program was coded by an author. This version can only process a standard taxonomy. In case of extending taxonomy, you need special coding for handling extended items and/or special error condition based on extended taxonomy.
XBRL GL instance document is  also a xml document, $(xml).find(“ condition ”) can find any items within a document.
Firstly, we lookup XBRL GL’s <gl-cor:accountingEntries>item.

[javascript] Repeating process for loook up accountingEntries, entryHeader, entryDetail structure

// accountingEntries
$accountingEntries = $(xml).find("gl-cor\:accountingEntries");
// entryHeader
$entryHeaders = $accountingEntries.find("gl-cor\:entryHeader");
$entryHeaders.each(function(num, header) {
    // entryDetail
    $entryDetails = $(header).find("gl-cor\:entryDetail");
    $entryDetails.each(function(line, detail) {
        $account = $(detail).find("gl-cor\:account");
        $accountMainDescription = $account.find("gl-cor\:accountMainDescription");
        $accountSub = $account.find("gl-cor\:accountSub");
        $accountSubDescription = $accountSub.find("gl-cor\:accountSubDescription");
        $accountSubType = $accountSub.find("gl-cor\:accountSubType");
        $amount = $(detail).find("gl-cor\:amount");
        $debitCreditCode = $(detail).find("gl-cor\:debitCreditCode");
        $postingDate = $(detail).find("gl-cor\:postingDate");
        $detailComment = $(detail).find("gl-cor\:detailComment");
    }    
}

[html] <div> element for defining a dynamic <table>

<div id="trace"></div>

[javascript] Repeating process for generate <table> contents

$entryHeaders.each(function(num, header) {
  // entryDetail
  // Define <table>
  $tableDetail = $('<table class="detail" width="97%" border="1" cellpadding="5"></table>');
  $("#trace").append($tableDetail);
  // Look up entryDetail items and store contents in variables
  $entryDetails = $(header).find("gl-cor\:entryDetail");
  $entryDetails.each(function(line, detail) {
        … …
      if ($debitCreditCode.text()=='debit') {
        $tableDetail.append($("<tr/>")
          .append($('<td></td>').text($postingDate.text()))
          .append($('<td></td>').text($accountMainDescription.text()))
          .append($('<td></td>').text($accountSubDescription.text()+"("+$accountSubType.text()+")"))
          .append($('<td></td>').text(""))
          .append($('<td></td>').text(""))
          .append($('<td align="right"></td>').text(addFigure($amount.text())))
          .append($('<td></td>').text(""))
          .append($('<td></td>').text($detailComment.text()))
        );
      }
      else if ($debitCreditCode.text()=='credit') {
        $tableDetail.append($("<tr/>")
          .append($('<td></td>').text($postingDate.text()))
          .append($('<td></td>').text(""))
          .append($('<td></td>').text(""))
          .append($('<td></td>').text($accountMainDescription.text()))
          .append($('<td></td>').text($accountSubDescription.text()+"("+$accountSubType.text()+")"))
          .append($('<td></td>').text(""))
          .append($('<td align="right"></td>').text(addFigure($amount.text())))
          .append($('<td></td>').text($detailComment.text()))
        );
      }
    }
  }
}