Пример #1
0
def test_ht_computing():
    # test based on a real world problem that raised the error
    kmtype = ExpenseKmType(amount=0.38, label="", code="")
    kmlines = []
    for km in [
            3000, 2800, 280, 200, 540, 2800, 3600, 3000, 3000, 4400, 2000,
            3000, 4600
    ]:
        kmlines.append(ExpenseKmLine(km=km, description="",
                                     type_object=kmtype))

    teltype = ExpenseTelType(percentage=50, label="", code="")
    telline = ExpenseLine(ht=2666,
                          tva=533,
                          description="",
                          type_object=teltype)

    km_lines_total = sum(l.total for l in kmlines)
    km_lines_rounded_total = int(sum(l.total_ht for l in kmlines))
    km_lines_linerounded_total = sum(int(l.total_ht) for l in kmlines)

    telline_total = telline.total
    telline_rounded_total = int(telline.total_tva) + int(telline.total_ht)

    last_rounded_total = int(km_lines_total + telline_total)
    byproduct_rounded_total = km_lines_rounded_total + telline_rounded_total
    byline_rounded_total = km_lines_linerounded_total + telline_rounded_total

    # Option 1
    assert last_rounded_total == byline_rounded_total
    # Option 2
    assert last_rounded_total == byproduct_rounded_total
Пример #2
0
def add_expense_type(type_, **kwargs):
    if type_ == 'km':
        e = ExpenseKmType(**kwargs)
    elif type_ == 'tel':
        e = ExpenseTelType(**kwargs)
    else:
        e = ExpenseType(**kwargs)
    session = DBSESSION()
    session.add(e)
    session.flush()
Пример #3
0
def expensekmtype(dbsession):
    from autonomie.models.expense.types import ExpenseKmType
    type_ = ExpenseKmType(label=u"voiture",
                          year=datetime.date.today().year,
                          amount=1.55,
                          code="CODEKM")

    dbsession.add(type_)
    dbsession.flush()
    return type_
Пример #4
0
 def get_km_column(self):
     """
     Return the columns associated to km expenses
     """
     kmtype = ExpenseKmType.query().first()
     col = None
     if kmtype:
         col = TypedColumn(
             kmtype,
             label=u"Frais de déplacement",
         )
     return col
Пример #5
0
 def get_km_column(self):
     """
     Return the columns associated to km expenses
     """
     kmtype = ExpenseKmType.query().first()
     col = None
     if kmtype:
         col = TypedColumn(
             kmtype,
             label=u"Frais de déplacement",
         )
     return col
Пример #6
0
def expense_kmtype(dbsession):
    from autonomie.models.expense.types import ExpenseKmType
    item = ExpenseKmType(label="KM expense",
                         code="KM",
                         code_tva="KM_TVA",
                         compte_tva="KM_COMPTE_TVA",
                         contribution=False,
                         amount=1.254,
                         year=datetime.date.today().year)
    dbsession.add(item)
    dbsession.flush()
    return item
Пример #7
0
    def _get_expense_km_types_options(self, include_ids):
        """
        Return ExpenseKm defs available for the end user

        :param list include_ids: The ids of already used types
        :returns: The list of available options
        :rtype: list
        """
        available_ids = self._get_kmtype_ids()
        query = ExpenseKmType.query().filter(
            or_(
                ExpenseKmType.id.in_(include_ids),
                ExpenseKmType.id.in_(available_ids),
            ))
        return query.all()
Пример #8
0
    def _get_expense_km_types_options(self, include_ids):
        """
        Return ExpenseKm defs available for the end user

        :param list include_ids: The ids of already used types
        :returns: The list of available options
        :rtype: list
        """
        available_ids = self._get_kmtype_ids()
        query = ExpenseKmType.query().filter(
            or_(
                ExpenseKmType.id.in_(include_ids),
                ExpenseKmType.id.in_(available_ids),
            )
        )
        return query.all()
Пример #9
0
 def load_items(self, year):
     query = ExpenseKmType.query().filter_by(active=True)
     return query.filter_by(year=year)
Пример #10
0
 def load_items(self, year):
     query = ExpenseKmType.query().filter_by(active=True)
     return query.filter_by(year=year)