Aller au contenu

Models

CurrencyField(*args, **kwargs)

Bases: DecimalField

Custom database field used for currency.

Source code in accounting/models.py
def __init__(self, *args, **kwargs):
    kwargs["max_digits"] = 12
    kwargs["decimal_places"] = 2
    super().__init__(*args, **kwargs)

Company

Bases: Model

is_owned_by(user)

Check if that object can be edited by the given user.

Source code in accounting/models.py
def is_owned_by(self, user):
    """Check if that object can be edited by the given user."""
    return user.is_in_group(pk=settings.SITH_GROUP_ACCOUNTING_ADMIN_ID)

can_be_edited_by(user)

Check if that object can be edited by the given user.

Source code in accounting/models.py
def can_be_edited_by(self, user):
    """Check if that object can be edited by the given user."""
    return user.memberships.filter(
        end_date=None, club__role=settings.SITH_CLUB_ROLES_ID["Treasurer"]
    ).exists()

can_be_viewed_by(user)

Check if that object can be viewed by the given user.

Source code in accounting/models.py
def can_be_viewed_by(self, user):
    """Check if that object can be viewed by the given user."""
    return user.memberships.filter(
        end_date=None, club__role_gte=settings.SITH_CLUB_ROLES_ID["Treasurer"]
    ).exists()

BankAccount

Bases: Model

is_owned_by(user)

Check if that object can be edited by the given user.

Source code in accounting/models.py
def is_owned_by(self, user):
    """Check if that object can be edited by the given user."""
    if user.is_anonymous:
        return False
    if user.is_in_group(pk=settings.SITH_GROUP_ACCOUNTING_ADMIN_ID):
        return True
    m = self.club.get_membership_for(user)
    return m is not None and m.role >= settings.SITH_CLUB_ROLES_ID["Treasurer"]

ClubAccount

Bases: Model

is_owned_by(user)

Check if that object can be edited by the given user.

Source code in accounting/models.py
def is_owned_by(self, user):
    """Check if that object can be edited by the given user."""
    if user.is_anonymous:
        return False
    return user.is_in_group(pk=settings.SITH_GROUP_ACCOUNTING_ADMIN_ID)

can_be_edited_by(user)

Check if that object can be edited by the given user.

Source code in accounting/models.py
def can_be_edited_by(self, user):
    """Check if that object can be edited by the given user."""
    m = self.club.get_membership_for(user)
    return m and m.role == settings.SITH_CLUB_ROLES_ID["Treasurer"]

can_be_viewed_by(user)

Check if that object can be viewed by the given user.

Source code in accounting/models.py
def can_be_viewed_by(self, user):
    """Check if that object can be viewed by the given user."""
    m = self.club.get_membership_for(user)
    return m and m.role >= settings.SITH_CLUB_ROLES_ID["Treasurer"]

GeneralJournal

Bases: Model

Class storing all the operations for a period of time.

is_owned_by(user)

Check if that object can be edited by the given user.

Source code in accounting/models.py
def is_owned_by(self, user):
    """Check if that object can be edited by the given user."""
    if user.is_anonymous:
        return False
    if user.is_in_group(pk=settings.SITH_GROUP_ACCOUNTING_ADMIN_ID):
        return True
    return self.club_account.can_be_edited_by(user)

can_be_edited_by(user)

Check if that object can be edited by the given user.

Source code in accounting/models.py
def can_be_edited_by(self, user):
    """Check if that object can be edited by the given user."""
    if user.is_in_group(pk=settings.SITH_GROUP_ACCOUNTING_ADMIN_ID):
        return True
    return self.club_account.can_be_edited_by(user)

Operation

Bases: Model

An operation is a line in the journal, a debit or a credit.

is_owned_by(user)

Check if that object can be edited by the given user.

Source code in accounting/models.py
def is_owned_by(self, user):
    """Check if that object can be edited by the given user."""
    if user.is_anonymous:
        return False
    if user.is_in_group(pk=settings.SITH_GROUP_ACCOUNTING_ADMIN_ID):
        return True
    if self.journal.closed:
        return False
    m = self.journal.club_account.club.get_membership_for(user)
    return m is not None and m.role >= settings.SITH_CLUB_ROLES_ID["Treasurer"]

can_be_edited_by(user)

Check if that object can be edited by the given user.

Source code in accounting/models.py
def can_be_edited_by(self, user):
    """Check if that object can be edited by the given user."""
    if user.is_in_group(pk=settings.SITH_GROUP_ACCOUNTING_ADMIN_ID):
        return True
    if self.journal.closed:
        return False
    m = self.journal.club_account.club.get_membership_for(user)
    return m is not None and m.role == settings.SITH_CLUB_ROLES_ID["Treasurer"]

AccountingType

Bases: Model

Accounting types.

Those are numbers used in accounting to classify operations

is_owned_by(user)

Check if that object can be edited by the given user.

Source code in accounting/models.py
def is_owned_by(self, user):
    """Check if that object can be edited by the given user."""
    if user.is_anonymous:
        return False
    return user.is_in_group(pk=settings.SITH_GROUP_ACCOUNTING_ADMIN_ID)

SimplifiedAccountingType

Bases: Model

Simplified version of AccountingType.

Label

Bases: Model

Label allow a club to sort its operations.