Ejemplo n.º 1
0
def reconciliation_xml(request, cik, quarter):
    """
    Returns the XML rendered for a tax reconciliation report

    Args:
        request (HTTPResquest): the Django request
        cik (Str): the company's cik number
        quarter (Str): the quarter as YYYYQ

    Return:
        Httpresponse
 
    """
    
    values = { 'report': None }
    try:
        report = Index.objects.get(cik=cik, quarter=quarter, form='10-K')
        if report: 
            dates, dicttable = extract_report(report, TAXRECELTS, 'fields')
            print "dicttable"
            print dicttable
            # Note: zipping in the TAXFIELDS so that they are available in
            # the template at the element level
            staxfields = sorted(TAXFIELDS)
            table = [ ( date, zip(staxfields, dicttable[date]) ) for date in dates ] 
            values['report'] = report
            values['table'] = table
            values['dates'] = dates
            values['fields'] = TAXFIELDS
        else:
            values['error'] = "Report extraction failed for %s" % cik
    except:
        values['error'] = "10-K not found for %s" % cik
        raise
    return render(request, 'pysec/reconciliation.xml', values, content_type='application/xml')
Ejemplo n.º 2
0
def reconciliation(request, cik, quarter):
    """
    Returns the HTML rendered for a tax reconciliation report

    Args:
        request (HTTPResquest): the Django request
        cik (Str): the company's cik number
        quarter (Str): the quarter as YYYYQ

    Return:
        HTTPResponse

    TODO: make some template tags which give readable versions of the
    dollar amounts ("677000000" -> "$677,000,000" or "$M677") and 
    percentages ("0.252" -> "25,2%")

    """
    values = {'report': None}
    try:
        report = Index.objects.get(cik=cik, quarter=quarter, form='10-K')
        if report:
            dates, dicttable = extract_report(report, TAXRECELTS, 'dates')
            table = [(field, dicttable[field]) for field in TAXFIELDS]
            values['report'] = report
            values['table'] = table
            values['dates'] = dates
            values['fields'] = TAXFIELDS
        else:
            values['error'] = "Report extraction failed for %s" % cik
    except:
        values['error'] = "10-K not found for %s" % cik
        raise
    return render(request, 'pysec/reconciliation.html', values)
Ejemplo n.º 3
0
def reconciliation(request, cik, quarter):
    """
    Returns the HTML rendered for a tax reconciliation report

    Args:
        request (HTTPResquest): the Django request
        cik (Str): the company's cik number
        quarter (Str): the quarter as YYYYQ

    Return:
        HTTPResponse

    TODO: make some template tags which give readable versions of the
    dollar amounts ("677000000" -> "$677,000,000" or "$M677") and 
    percentages ("0.252" -> "25,2%")

    """
    values = { 'report': None }
    try:
        report = Index.objects.get(cik=cik, quarter=quarter, form='10-K')
        if report: 
            dates, dicttable = extract_report(report, TAXRECELTS, 'dates')
            table =  [ ( field, dicttable[field] ) for field in TAXFIELDS ]
            values['report'] = report
            values['table'] = table
            values['dates'] = dates
            values['fields'] = TAXFIELDS
        else:
            values['error'] = "Report extraction failed for %s" % cik
    except:
        values['error'] = "10-K not found for %s" % cik
        raise
    return render(request, 'pysec/reconciliation.html', values)
Ejemplo n.º 4
0
def reconciliation_xml(request, cik, quarter):
    """
    Returns the XML rendered for a tax reconciliation report

    Args:
        request (HTTPResquest): the Django request
        cik (Str): the company's cik number
        quarter (Str): the quarter as YYYYQ

    Return:
        Httpresponse
 
    """

    values = {'report': None}
    try:
        report = Index.objects.get(cik=cik, quarter=quarter, form='10-K')
        if report:
            dates, dicttable = extract_report(report, TAXRECELTS, 'fields')
            print "dicttable"
            print dicttable
            # Note: zipping in the TAXFIELDS so that they are available in
            # the template at the element level
            staxfields = sorted(TAXFIELDS)
            table = [(date, zip(staxfields, dicttable[date]))
                     for date in dates]
            values['report'] = report
            values['table'] = table
            values['dates'] = dates
            values['fields'] = TAXFIELDS
        else:
            values['error'] = "Report extraction failed for %s" % cik
    except:
        values['error'] = "10-K not found for %s" % cik
        raise
    return render(request,
                  'pysec/reconciliation.xml',
                  values,
                  content_type='application/xml')