コード例 #1
0
ファイル: form_941.py プロジェクト: brandon-rhodes/publicanus
def tally(company, period, filing):

    tlist = list(company.transactions(
        within=period,
        debit_type='business',
        credit_type='employee',
        ))
    number_of_employees = len(set(t.credit_account.id for t in tlist))
    wages = sum(t.amount for t in tlist) or zero  # "or zero" keeps it Decimal

    p = filing.new_page(1)

    p.ein = company.ein
    p.name = company.name

    p.quarter1 = 'X' if period.number == 1 else ''
    p.quarter2 = 'X' if period.number == 2 else ''
    p.quarter3 = 'X' if period.number == 3 else ''
    p.quarter4 = 'X' if period.number == 4 else ''

    p.line1 = number_of_employees
    p.line2 = wages
    p.line3 = cents(wages * _arbitrary)           # TODO

    p.line5a1 = wages                             # TODO
    p.line5b1 = zero                              # TODO
    p.line5c1 = wages                             # TODO

    p.line5a2 = cents(p.line5a1 * _point104)
    p.line5b2 = cents(p.line5b1 * _point104)
    p.line5c2 = cents(p.line5c1 * _point029)

    p.line5d = p.line5a2 + p.line5b2 + p.line5c2
    p.line5e = zero

    p.line6 = p.line3 + p.line5d + p.line5e

    p.line10 = p.line6

    p.line14 = p.line10

    # TODO: page 2

    filing.balance_due = p.line14

    y = period.end.year
    m = period.end.month
    y, m = (y + 1, 1) if m == 12 else (y, m + 1)
    filing.due_date = Date(y, m, mdays[m]).next_business_day()

    return filing
コード例 #2
0
ファイル: form_940.py プロジェクト: brandon-rhodes/publicanus
def tally(company, period, filing):

    tlist = list(company.transactions(within=period, debit_type="business", credit_type="employee"))
    wages = sum(t.amount for t in tlist)

    p = filing.new_page(1)

    p.ein = company.ein
    p.name = company.name

    p.line3 = wages

    get_employee_id = lambda t: t.credit_account.id
    tlist.sort(key=get_employee_id)
    p.line5 = cents(
        sum(max(0, sum(t.amount for t in sublist) - _sevenk) for k, sublist in groupby(tlist, get_employee_id))
    )

    p.line6 = p.line5
    p.line7a = p.line3 - p.line6

    p.line7b = _sevenk  # TODO
    p.line7d = zero  # TODO

    p.line7c = cents(p.line7b * _eighthpercent)
    p.line7e = cents(p.line7d * _sixthpercent)

    p.line8 = p.line7c + p.line7e
    p.line11 = zero  # TODO
    p.line12 = p.line8 + p.line11
    p.line14 = p.line12

    # TODO: page 2

    filing.balance_due = p.line14
    filing.due_date = Date(period.end.year + 1, 1, 31).next_business_day()

    return filing
コード例 #3
0
ファイル: views.py プロジェクト: brandon-rhodes/publicanus
def index(request):
    company = request.company
    company.preload_filings()
    company.preload_transactions()

    transactions = company.transactions
    filings_by_month = defaultdict(list)

    for form in sorted(registry.all_forms(), key=lambda f: f.name):
        for period in form.periods(company):

            filing = form.tally(company, period)
            filing.real_filings = list(company.filings(
                form=form,
                period=period,
                ))

            filing.state = (
                'filed' if filing.real_filings else
                'warn' if filing.due_date > company.today else
                'late'
                )
            display_month = _display_month(filing)
            filings_by_month[display_month].append(filing)

    sorted_months = sorted(filings_by_month.iterkeys())
    start = sorted_months[0]
    end = sorted_months[-1]
    now_month = company.today.replace(day=1)
    rows = []

    date = start
    while date <= end:
        month = Month(date.year, date.month)
        row = Row()
        row.date = date
        row.is_now = (date == now_month)
        row.employee_cost = dollars(sum(t.amount for t in transactions(
            within=month,
            debit_type='business',
            credit_type='employee',
            )))
        row.consultant_cost = dollars(sum(t.amount for t in transactions(
            within=month,
            debit_type='business',
            credit_type='consultant',
            )))
        filings = filings_by_month.get(date, ())
        row.total_due = cents(sum(f.balance_due for f in filings))
        row.filings = [(form, f) for f in filings]
        rows.append(row)
        if date.month == 12:
            date = date.replace(year=date.year + 1, month=1)
        else:
            date = date.replace(month=date.month + 1)

    return render_to_response('publican/main.html', {
        'rows': rows,
        'this_month': company.today.replace(day=1),
        'today': company.today,
        })