コード例 #1
0
def expensetype(dbsession):
    from autonomie.models.expense.types import ExpenseType
    type_ = ExpenseType(label=u"Restauration", code=u"CODE")

    dbsession.add(type_)
    dbsession.flush()
    return type_
コード例 #2
0
def deferred_type_id_validator(node, kw):
    """
    deferred Expensetype id validator
    """
    from autonomie.models.expense.types import ExpenseType
    ids = [t.id for t in ExpenseType.query()]
    return colander.OneOf(ids)
コード例 #3
0
ファイル: expense.py プロジェクト: tonthon/autonomie
def deferred_type_id_validator(node, kw):
    """
    deferred Expensetype id validator
    """
    from autonomie.models.expense.types import ExpenseType
    ids = [t.id for t in ExpenseType.query()]
    return colander.OneOf(ids)
コード例 #4
0
ファイル: fake_database.py プロジェクト: tonthon/autonomie
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()
コード例 #5
0
    def _get_expense_types_options(self, type_label, include_ids):
        """
        Return ExpenseType defs or ExpenseTelType available for the end user

        :param str type_label: 'expense' or 'expensetel'
        :param list include_ids: The ids of already used types
        :returns: The list of available options
        :rtype: list
        """
        query = ExpenseType.query().filter_by(type=type_label).filter(
            or_(ExpenseType.id.in_(include_ids), ExpenseType.active == True))
        return query.all()
コード例 #6
0
def expense_type(dbsession):
    from autonomie.models.expense.types import ExpenseType
    item = ExpenseType(
        label="KM expense",
        code="KM",
        code_tva="KM_TVA",
        compte_tva="KM_COMPTE_TVA",
        contribution=False,
    )
    dbsession.add(item)
    dbsession.flush()
    return item
コード例 #7
0
    def _get_expense_types_options(self, type_label, include_ids):
        """
        Return ExpenseType defs or ExpenseTelType available for the end user

        :param str type_label: 'expense' or 'expensetel'
        :param list include_ids: The ids of already used types
        :returns: The list of available options
        :rtype: list
        """
        query = ExpenseType.query().filter_by(type=type_label).filter(
            or_(
                ExpenseType.id.in_(include_ids),
                ExpenseType.active == True
            )
        )
        return query.all()
コード例 #8
0
    def _check_config(self, config):
        """
        Check all configuration values are set for export

        :param config: The application configuration dict
        """
        contribution_is_active = False
        for type_ in ExpenseType.query().filter_by(active=True):
            if not type_.code:  # or not type_.compte_tva or not type_.code_tva:
                return False
            if type_.contribution:
                contribution_is_active = True

        for key in self.config_keys:
            if not config.get(key):
                return False
            if contribution_is_active:
                for key in self.contribution_config_keys:
                    if not config.get(key):
                        return False
        return True
コード例 #9
0
    def _check_config(self, config):
        """
        Check all configuration values are set for export

        :param config: The application configuration dict
        """
        contribution_is_active = False
        for type_ in ExpenseType.query().filter_by(active=True):
            if not type_.code:  # or not type_.compte_tva or not type_.code_tva:
                return False
            if type_.contribution:
                contribution_is_active = True

        for key in self.config_keys:
            if not config.get(key):
                return False
            if contribution_is_active:
                for key in self.contribution_config_keys:
                    if not config.get(key):
                        return False
        return True
コード例 #10
0
ファイル: expense_excel.py プロジェクト: Kilya/autonomie
    def get_columns(self):
        """
            Retrieve all columns and define a global column attribute
            :param internal: are we asking columns for internal expenses
        """
        columns = []
        # Add the two first columns
        columns.append(StaticColumn(label='Date', key='date'))
        columns.append(
            StaticColumn(label='Description', key='description', nb_col=3))

        # Telephonic fees are only available as internal expenses
        tel_column = self.get_tel_column()
        if tel_column is not None:
            columns.append(tel_column)

        km_column = self.get_km_column()
        if km_column:
            columns.append(km_column)
            kmtype_code = km_column.code
        else:
            kmtype_code = None

        commontypes = ExpenseType.query()\
            .filter(ExpenseType.type == "expense")\
            .filter(ExpenseType.active == True)
        for type_ in commontypes:
            # Here's a hack to allow to group km fee types and displacement fees
            if kmtype_code is not None and \
               type_.code != kmtype_code:
                columns.append(TypedColumn(type_))

        columns.extend(self.get_disabled_types_columns())

        # Add the last columns
        columns.append(
            StaticColumn(label='Total HT',
                         key='total_ht',
                         formatter=integer_to_amount))
        columns.append(
            StaticColumn(label='Tva', key='tva', formatter=integer_to_amount))
        columns.append(
            StaticColumn(
                label="Total",
                key="total",
                formatter=integer_to_amount,
                style=NUMBER_CELL,
            ))

        # We set the appropriate letter to each column
        index = 0
        for col in columns:
            letter = ASCII_UPPERCASE[index]
            additional_cell_nb = col.additional_cell_nb
            if additional_cell_nb:
                last_letter = ASCII_UPPERCASE[index + additional_cell_nb]
                index += additional_cell_nb + 1
            else:
                last_letter = letter
                index += 1
            col.set_letter(letter, last_letter)
        return columns
コード例 #11
0
    def get_columns(self):
        """
            Retrieve all columns and define a global column attribute
            :param internal: are we asking columns for internal expenses
        """
        columns = []
        # Add the two first columns
        columns.append(StaticColumn(label='Date', key='date'))
        columns.append(
            StaticColumn(
                label='Description',
                key='description',
                nb_col=3
            )
        )

        # Telephonic fees are only available as internal expenses
        tel_column = self.get_tel_column()
        if tel_column is not None:
            columns.append(tel_column)

        km_column = self.get_km_column()
        if km_column:
            columns.append(km_column)
            kmtype_code = km_column.code
        else:
            kmtype_code = None

        commontypes = ExpenseType.query()\
            .filter(ExpenseType.type == "expense")\
            .filter(ExpenseType.active == True)
        for type_ in commontypes:
            # Here's a hack to allow to group km fee types and displacement fees
            if kmtype_code is not None and \
               type_.code != kmtype_code:
                columns.append(TypedColumn(type_))

        columns.extend(self.get_disabled_types_columns())

        # Add the last columns
        columns.append(
            StaticColumn(
                label='Total HT',
                key='total_ht',
                formatter=integer_to_amount
            )
        )
        columns.append(
            StaticColumn(
                label='Tva',
                key='tva',
                formatter=integer_to_amount
            )
        )
        columns.append(
            StaticColumn(
                label="Total",
                key="total",
                formatter=integer_to_amount,
                style=NUMBER_CELL,
            )
        )

        # We set the appropriate letter to each column
        index = 0
        for col in columns:
            letter = ASCII_UPPERCASE[index]
            additional_cell_nb = col.additional_cell_nb
            if additional_cell_nb:
                last_letter = ASCII_UPPERCASE[index + additional_cell_nb]
                index += additional_cell_nb + 1
            else:
                last_letter = letter
                index += 1
            col.set_letter(letter, last_letter)
        return columns