Ejemplo n.º 1
0
Archivo: views.py Proyecto: dbaty/Brouz
def _calculate_report(lines):
    # Les commentaires correspondent aux intitules exacts de la
    # declaration 2035-1K (2012).
    def _get_sum_of_lines(lines, category, compute=None):
        total = 0
        if compute is None:
            compute = lambda line: line.net_amount
        for line in lines:
            if line.category == category:
                total += compute(line)
        return accounting.RoundedPrice(total)
    # Recettes encaissees y compris les remboursements de frais
    aa = _get_sum_of_lines(lines, CATEGORY_INCOME_MISC)
    total_income = aa
    # Achats
    ba = _get_sum_of_lines(lines, CATEGORY_EXPENDITURE_PURCHASE)
    # TVA
    bd = _get_sum_of_lines(lines, CATEGORY_EXPENDITURE_VAT)
    # Contribution economique territoriale (CET)
    #   =   Contribution fonciere des entreprises (CFE)
    #     + CVAE (nulle si CA < 150.000 EUR environ)
    jy = _get_sum_of_lines(lines, CATEGORY_EXPENDITURE_CET)
    # Autres impots
    bs = _get_sum_of_lines(lines, CATEGORY_EXPENDITURE_OTHER_TAXES)
    # CSG deductible
    bv = _get_sum_of_lines(lines, CATEGORY_EXPENDITURE_DEDUCTIBLE_CSG)
    # Location de materiel et de mobilier
    bg = _get_sum_of_lines(
        lines, CATEGORY_EXPENDITURE_HARDWARE_FURNITURE_RENTAL)
    # Petit outillage
    bh_small_furniture = _get_sum_of_lines(
        lines, CATEGORY_EXPENDITURE_SMALL_FURNITURE)
    # Primes d'assurance
    bh_insurance_premium = _get_sum_of_lines(
        lines, CATEGORY_EXPENDITURE_INSURANCE_PREMIUM)
    # Honoraires ne constituant pas des retrocessions
    bh_fees_no_retrocession = _get_sum_of_lines(
        lines, CATEGORY_EXPENDITURE_FEES_NO_RETROCESSION)
    # Total : travaux, fournitures et services exterieurs
    bh = accounting.sum_rounded_prices(
        bh_small_furniture, bh_insurance_premium, bh_fees_no_retrocession)
    # Autres frais de deplacements (voyages...)
    bj_travel_expenses = _get_sum_of_lines(
        lines, CATEGORY_EXPENDITURE_TRAVEL_EXPENSES, accounting.get_meal_deductible)
    # Total : transports et deplacements
    bj = accounting.sum_rounded_prices(bj_travel_expenses)
    # Charges sociales personnelles obligatoires
    bt = _get_sum_of_lines(
        lines, CATEGORY_EXPENDITURE_OBLIGATORY_SOCIAL_CHARGES)
    # Charges sociales personnelles facultatives
    bu = _get_sum_of_lines(lines, CATEGORY_EXPENDITURE_OPTIONAL_SOCIAL_CHARGES)
    # Total charges sociales personnelles
    bk = accounting.sum_rounded_prices(bt, bu)
    # Frais de reception, de representation et de congres
    bm_conferences = _get_sum_of_lines(lines, CATEGORY_EXPENDITURE_CONFERENCES)
    # Fournitures de bureau, frais de documentation, de correspondance
    # et de telephone
    bm_office = _get_sum_of_lines(lines, CATEGORY_EXPENDITURE_OFFICE_FURNITURE)
    # Autres frais divers de gestion
    bm_other = _get_sum_of_lines(
        lines, CATEGORY_EXPENDITURE_OTHER_MISC_EXPENSES)
    # Total : frais divers de gestion
    bm = accounting.sum_rounded_prices(bm_conferences, bm_office, bm_other)
    # Frais financiers
    bn = _get_sum_of_lines(lines, CATEGORY_EXPENDITURE_BANKING_CHARGES)
    # Total (BR)
    total_expenditure = accounting.sum_rounded_prices(
        ba, bd, jy, bs, bv, bg, bh, bj, bk, bm, bn)
    report = {'aa': aa,
              'total_income': total_income,
              'ba': ba,
              'bd': bd,
              'jy': jy,
              'bs': bs,
              'bv': bv,
              'bh_small_furniture': bh_small_furniture,
              'bh_fees_no_retrocession': bh_fees_no_retrocession,
              'bh_insurance_premium': bh_insurance_premium,
              'bg': bg,
              'bh': bh,
              'bj_travel_expenses': bj_travel_expenses,
              'bj': bj,
              'bt': bt,
              'bu': bu,
              'bk': bk,
              'bm_conferences': bm_conferences,
              'bm_office': bm_office,
              'bm_other': bm_other,
              'bm': bm,
              'bn': bn,
              'total_expenditure': total_expenditure}
    return report
Ejemplo n.º 2
0
 def _call_fut(self, *args):
     return accounting.sum_rounded_prices(*args)