Aller au contenu

Views

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)

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"]

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()

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)

Label

Bases: Model

Label allow a club to sort its operations.

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"]

SimplifiedAccountingType

Bases: Model

Simplified version of AccountingType.

BankAccountListView

Bases: CanViewMixin, ListView

A list view for the admins.

SimplifiedAccountingTypeListView

Bases: CanViewMixin, ListView

A list view for the admins.

SimplifiedAccountingTypeEditView

Bases: CanViewMixin, UpdateView

An edit view for the admins.

SimplifiedAccountingTypeCreateView

Bases: CanCreateMixin, CreateView

Create an accounting type (for the admins).

AccountingTypeListView

Bases: CanViewMixin, ListView

A list view for the admins.

AccountingTypeEditView

Bases: CanViewMixin, UpdateView

An edit view for the admins.

AccountingTypeCreateView

Bases: CanCreateMixin, CreateView

Create an accounting type (for the admins).

BankAccountEditView

Bases: CanViewMixin, UpdateView

An edit view for the admins.

BankAccountDetailView

Bases: CanViewMixin, DetailView

A detail view, listing every club account.

BankAccountCreateView

Bases: CanCreateMixin, CreateView

Create a bank account (for the admins).

BankAccountDeleteView

Bases: CanEditPropMixin, DeleteView

Delete a bank account (for the admins).

ClubAccountEditView

Bases: CanViewMixin, UpdateView

An edit view for the admins.

ClubAccountDetailView

Bases: CanViewMixin, DetailView

A detail view, listing every journal.

ClubAccountCreateView

Bases: CanCreateMixin, CreateView

Create a club account (for the admins).

ClubAccountDeleteView

Bases: CanEditPropMixin, DeleteView

Delete a club account (for the admins).

JournalTabsMixin

JournalCreateView

Bases: CanCreateMixin, CreateView

Create a general journal.

JournalDetailView

Bases: JournalTabsMixin, CanViewMixin, DetailView

A detail view, listing every operation.

JournalEditView

Bases: CanEditMixin, UpdateView

Update a general journal.

JournalDeleteView

Bases: CanEditPropMixin, DeleteView

Delete a club account (for the admins).

OperationForm(*args, **kwargs)

Bases: ModelForm

Source code in accounting/views.py
def __init__(self, *args, **kwargs):
    club_account = kwargs.pop("club_account", None)
    super().__init__(*args, **kwargs)
    if club_account:
        self.fields["label"].queryset = club_account.labels.order_by("name").all()
    if self.instance.target_type == "USER":
        self.fields["user"].initial = self.instance.target_id
    elif self.instance.target_type == "ACCOUNT":
        self.fields["club_account"].initial = self.instance.target_id
    elif self.instance.target_type == "CLUB":
        self.fields["club"].initial = self.instance.target_id
    elif self.instance.target_type == "COMPANY":
        self.fields["company"].initial = self.instance.target_id

OperationCreateView

Bases: CanCreateMixin, CreateView

Create an operation.

get_context_data(**kwargs)

Add journal to the context.

Source code in accounting/views.py
def get_context_data(self, **kwargs):
    """Add journal to the context."""
    kwargs = super().get_context_data(**kwargs)
    if self.journal:
        kwargs["object"] = self.journal
    return kwargs

OperationEditView

Bases: CanEditMixin, UpdateView

An edit view, working as detail for the moment.

get_context_data(**kwargs)

Add journal to the context.

Source code in accounting/views.py
def get_context_data(self, **kwargs):
    """Add journal to the context."""
    kwargs = super().get_context_data(**kwargs)
    kwargs["object"] = self.object.journal
    return kwargs

OperationPDFView

Bases: CanViewMixin, DetailView

Display the PDF of a given operation.

JournalNatureStatementView

Bases: JournalTabsMixin, CanViewMixin, DetailView

Display a statement sorted by labels.

get_context_data(**kwargs)

Add infos to the context.

Source code in accounting/views.py
def get_context_data(self, **kwargs):
    """Add infos to the context."""
    kwargs = super().get_context_data(**kwargs)
    kwargs["statement"] = self.big_statement()
    return kwargs

JournalPersonStatementView

Bases: JournalTabsMixin, CanViewMixin, DetailView

Calculate a dictionary with operation target and sum of operations.

get_context_data(**kwargs)

Add journal to the context.

Source code in accounting/views.py
def get_context_data(self, **kwargs):
    """Add journal to the context."""
    kwargs = super().get_context_data(**kwargs)
    kwargs["credit_statement"] = self.statement("CREDIT")
    kwargs["debit_statement"] = self.statement("DEBIT")
    kwargs["total_credit"] = self.total("CREDIT")
    kwargs["total_debit"] = self.total("DEBIT")
    return kwargs

JournalAccountingStatementView

Bases: JournalTabsMixin, CanViewMixin, DetailView

Calculate a dictionary with operation type and sum of operations.

get_context_data(**kwargs)

Add journal to the context.

Source code in accounting/views.py
def get_context_data(self, **kwargs):
    """Add journal to the context."""
    kwargs = super().get_context_data(**kwargs)
    kwargs["statement"] = self.statement()
    return kwargs

CompanyListView

Bases: CanViewMixin, ListView

CompanyCreateView

Bases: CanCreateMixin, CreateView

Create a company.

CompanyEditView

Bases: CanCreateMixin, UpdateView

Edit a company.

LabelListView

Bases: CanViewMixin, DetailView

LabelCreateView

Bases: CanCreateMixin, CreateView

LabelEditView

Bases: CanEditMixin, UpdateView

LabelDeleteView

Bases: CanEditMixin, DeleteView

CloseCustomerAccountForm

Bases: Form

RefoundAccountView

Bases: FormView

Create a selling with the same amount than the current user money.