示例#1
0
文件: views.py 项目: dbaty/Brouz
def _update_report_with_fixed_assets(report, year, session):
    """Update report with fixed assets ("immobilisations et
    amortissements").
    """
    assets = []
    for transaction in session.query(Transaction).\
            filter_by(category=CATEGORY_EXPENDITURE_FIXED_ASSETS,
                      composite=False):
        amortization = accounting.calculate_amortization(transaction)
        this_year_index = year - transaction.year
        past = accounting.RoundedPrice(sum(amortization[:this_year_index]))
        try:
            this_year = amortization[this_year_index]
        except IndexError:
            this_year = 0  # already amortized
        asset = {'title': transaction.title,
                 'date': transaction.date,
                 'amount': accounting.RoundedPrice(abs(transaction.signed_amount)),
                 'vat': accounting.RoundedPrice(transaction.vat),
                 'base': accounting.RoundedPrice(abs(transaction.signed_amount) - transaction.vat),
                 'past': past,
                 'this_year': this_year}
        assets.append(asset)
    report['fixed_assets'] = {
        'assets': assets,
        'total_amount': accounting.RoundedPrice(sum(a['amount'] for a in assets)),
        'total_base': accounting.RoundedPrice(sum(a['base'] for a in assets)),
        'total_past': accounting.RoundedPrice(sum(a['past'] for a in assets)),
        'total_this_year': accounting.RoundedPrice(sum(a['this_year'] for a in assets))}
示例#2
0
 def _call_fut(self, asset):
     return accounting.calculate_amortization(asset)