Esempio n. 1
0
def do(conf, account, date, inout):
    book = Workbook()

    sh = book.add_sheet('касса')

    title = u'%s %s %s. ' % (conf.get('firm_name', ''), account.name, account.desc)

    sh[0:0].value = title + (u'Приход за ' if inout else u'Расход за ') + taburet.utils.lenc(
        date.strftime('%B %Y'))

    date_from, date_to = taburet.utils.month_date_range(date)

    begin_saldo = account.balance(None, date_from - timedelta(days=1))
    sh[1:0].value = 'Сальдо на начало %.2f' % begin_saldo.balance

    end_saldo = account.balance(None, date_to)
    sh[1:5].value = 'Сальдо на конец %.2f' % end_saldo.balance

    sh[2:0].value = 'Счет'
    sh[2:1].value = 'Контрагент'

    pivot, days = get_pivot(account, date_from, date_to, inout)

    fill_transactions(sh, 2, pivot, days)

    with sh.style as style:
        style.align.vert.center()
        style.format = '0.00'

    sh.rows.height = 255
    sh[:0].autofit(3)
    sh[:1].autofit(3)

    return book
Esempio n. 2
0
def do(conf, account, date):
    book = Workbook()

    sh = book.add_sheet("касса")

    title = u"%s %s %s. " % (conf.get("firm_name", ""), account.name, account.desc)

    sh.merge(0, 0, 0, 9).value = title + u"Отчет за " + lenc(date.strftime("%d %B %Y"))

    begin_saldo = account.balance(None, date - timedelta(days=1))
    sh[1:0].value = "Сальдо на начало %.2f" % begin_saldo.balance

    end_saldo = account.balance(None, date)
    sh[1:5].value = "Сальдо на конец %.2f" % end_saldo.balance

    sh.merge(2, 2, 0, 4).value = "Приход"
    sh.merge(2, 2, 5, 9).value = "Расход"

    sh[2:0].style.align.horz.center()
    sh[2:5].style.align.horz.center()

    for sc in (0, 5):
        sh[3 : 0 + sc].value = "№"
        sh[3 : 1 + sc].value = "Счет"
        sh[3 : 2 + sc].value = "Кто"
        sh[3 : 3 + sc].value = "Сколько"
        sh[3 : 4 + sc].value = "За что"

    in_transactions = get_transactions(account, date, income=True)
    fill_transactions(sh, 4, 0, in_transactions)

    out_transactions = get_transactions(account, date, outcome=True)
    fill_transactions(sh, 4, 5, out_transactions)

    total_row = sh.maxrow + 1

    sh[total_row:0].value = "ИТОГО"
    fill_total(sh, total_row, 3, in_transactions)
    fill_total(sh, total_row, 8, out_transactions)

    sh.range(2, 3, 0, 4).set_borders()
    sh.range(4, total_row - 1, 0, 4).set_borders()
    sh.range(total_row, total_row, 0, 4).set_borders(0)

    sh.range(2, 3, 5, 9).set_borders()
    sh.range(4, total_row - 1, 5, 9).set_borders()
    sh.range(total_row, total_row, 5, 9).set_borders(0)

    fill_amounts_grouped_by_account(sh, total_row + 2, 1, in_transactions)
    fill_amounts_grouped_by_account(sh, total_row + 2, 6, out_transactions)

    sh.rows.height = 255

    with sh.style as style:
        style.align.vert.center()
        style.format = "0.00"

    for column in (0, 1, 2, 5, 6, 7):
        sh[:column].autofit(3)

    return book