def test_treasury_measure_type():
    from autonomie.models.accounting.treasury_measures import TreasuryMeasureType

    type_ = TreasuryMeasureType(label=u"Test", account_prefix="11,22,33")
    assert type_.match("1122334455")
    assert not type_.match("1222334455")
    assert type_.match("3322334455")

    type_ = TreasuryMeasureType(label=u"Test", account_prefix="11,-112")
    assert type_.match("11111")
    assert not type_.match("112111")
    type_ = TreasuryMeasureType(label=u"Test", account_prefix="11,")
    assert type_.match("11111")
    assert not type_.match("12")
Esempio n. 2
0
def populate_accounting_treasury_measure_types(session):
    """
    Populate the database with treasury measure types
    """
    from autonomie.models.config import Config
    from autonomie.models.accounting.treasury_measures import TreasuryMeasureType
    if TreasuryMeasureType.query().count() == 0:
        for internal_id, start, label in (
            (
                1,
                '5',
                u"Trésorerie du jour",
            ),
            (
                2,
                "42,-421,-425,43,44",
                u"Impôts, taxes et cotisations dues",
            ),
            (
                3,
                "40",
                u"Fournisseurs à payer",
            ),
            (
                5,
                "421",
                u"Salaires à payer",
            ),
            (6, "41", u"Clients à encaisser"),
            (7, '425', u"Notes de dépenses à payer"),
            (9, "1,2,3", u"Comptes bilan non pris en compte"),
        ):
            session.add(
                TreasuryMeasureType(internal_id=internal_id,
                                    account_prefix=start,
                                    label=label))
        Config.set("treasury_measure_ui", "1")
        session.flush()
Esempio n. 3
0
    def measure_by_internal_id(cls, instance, internal_id):
        from autonomie.models.accounting.treasury_measures import (
            TreasuryMeasure,
            TreasuryMeasureType,
        )
        type_id = TreasuryMeasureType.get_by_internal_id(internal_id)

        if type_id is not None:
            query = TreasuryMeasure.query().filter_by(grid_id=instance.id)
            query = query.filter_by(measure_type_id=type_id)
            result = query.first()
        else:
            result = None
        return result
Esempio n. 4
0
    def measure_by_internal_id(cls, instance, internal_id):
        from autonomie.models.accounting.treasury_measures import (
            TreasuryMeasure,
            TreasuryMeasureType,
        )
        type_id = TreasuryMeasureType.get_by_internal_id(internal_id)

        if type_id is not None:
            query = TreasuryMeasure.query().filter_by(grid_id=instance.id)
            query = query.filter_by(measure_type_id=type_id)
            result = query.first()
        else:
            result = None
        return result
Esempio n. 5
0
def treasury_measure_types(dbsession):
    from autonomie.models.accounting.treasury_measures import (
        TreasuryMeasureType,
    )
    types = []
    for internal_id, start, label in (
        (1, '5', u"Trésorerie du jour",),
        (2, "42,-421,-425,43,44", u"Impôts, taxes et cotisations dues",),
        (3, "40", u"Fournisseurs à payer",),
        (5, "421", u"Salaires à payer",),
        (6, "41", u"Clients à encaisser"),
        (7, '425', u"Notes de dépenses à payer"),
        (9, "1,2,3", u"Comptes bilan non pris en compte"),
    ):
        typ = TreasuryMeasureType(
            internal_id=internal_id, account_prefix=start, label=label
            )
        dbsession.add(typ)
        types.append(typ)
    return types
def test_treasury_measure_type():
    from autonomie.models.accounting.treasury_measures import TreasuryMeasureType

    type_ = TreasuryMeasureType(label=u"Test", account_prefix="11,22,33")
    assert type_.match("1122334455")
    assert not type_.match("1222334455")
    assert type_.match("3322334455")

    type_ = TreasuryMeasureType(label=u"Test", account_prefix="11,-112")
    assert type_.match("11111")
    assert not type_.match("112111")
    type_ = TreasuryMeasureType(label=u"Test", account_prefix="11,")
    assert type_.match("11111")
    assert not type_.match("12")