mirror of
https://github.com/ae-utbm/sith3.git
synced 2024-06-01 04:19:43 +00:00
Merge b9afe302d2
into 66fcb76cb5
This commit is contained in:
commit
b91a6f0586
|
@ -23,6 +23,7 @@
|
|||
#
|
||||
#
|
||||
import importlib
|
||||
from typing import Optional, Tuple
|
||||
|
||||
from django.db import models
|
||||
from django.core.mail import send_mail
|
||||
|
@ -318,6 +319,26 @@ class User(AbstractBaseUser):
|
|||
def to_dict(self):
|
||||
return self.__dict__
|
||||
|
||||
@cached_property
|
||||
def last_subscription_date(self) -> Optional[date]:
|
||||
latest_subscription = (
|
||||
self.subscriptions.filter(subscription_end__lte=timezone.now())
|
||||
.order_by("-subscription_end")
|
||||
.first()
|
||||
)
|
||||
if latest_subscription:
|
||||
return latest_subscription.subscription_end
|
||||
else:
|
||||
return None
|
||||
|
||||
def last_subscription_since(self) -> Tuple[int, int, int]:
|
||||
last_date = self.last_subscription_date
|
||||
if last_date is None:
|
||||
return (0, 0, 0)
|
||||
|
||||
diff = date.today() - last_date
|
||||
return [diff.days // 365, (diff.days % 365) // 30, (diff.days % 365) % 30]
|
||||
|
||||
@cached_property
|
||||
def was_subscribed(self):
|
||||
return self.subscriptions.exists()
|
||||
|
|
|
@ -155,7 +155,12 @@
|
|||
{% endif %}
|
||||
{% else %}
|
||||
<div>
|
||||
{% trans %}Not subscribed{% endtrans %}
|
||||
{% if profile.was_subscribed %}
|
||||
{% set duration = profile.last_subscription_since() %}
|
||||
{% trans y=duration[0], m=duration[1], d=duration[2], date=profile.last_subscription_date %}Not subscribed for {{ y }} year(s) {{ m }} month(s) {{ d }} day(s) ({{ date }}){% endtrans %}
|
||||
{% else %}
|
||||
{% trans %}Never subscribed{% endtrans %}
|
||||
{% endif %}
|
||||
{% if user.is_board_member %}
|
||||
<a href="{{ url('subscription:subscription') }}?member={{ profile.id }}">{% trans %}New subscription{% endtrans
|
||||
%}</a>
|
||||
|
|
|
@ -10,13 +10,19 @@
|
|||
<form method="get" action="">
|
||||
<select name="month">
|
||||
{% for m in months %}
|
||||
<option value="{{ m|date("Y-m") }}">{{ m|date("Y-m") }}</option>
|
||||
<option value="{{ m|date('Y-m') }}">{{ m|date("Y-m") }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<input type="submit" value="{% trans %}Go{% endtrans %}" />
|
||||
</form>
|
||||
<br>
|
||||
<p>{% trans %}CB Payments{% endtrans %} : {{ sum_cb }} €</p>
|
||||
<p>
|
||||
{% trans money=sum_accounts[0], users=sum_accounts[1] %}Money accross all users account : {{ money }} € (on {{ users }} account(s)){% endtrans %}
|
||||
</p>
|
||||
<p>
|
||||
{% trans money=sum_inactive_accounts[0], users=sum_inactive_accounts[1], year=settings.SITH_ACCOUNTING_DELTA_DUMP["years"] %}Including those who have not been contributors for at least {{ year }} year(s) : {{ money }} € (on {{ users }} account(s)){% endtrans %}
|
||||
</p>
|
||||
<br>
|
||||
<table>
|
||||
<thead>
|
||||
|
|
|
@ -17,7 +17,7 @@ import json
|
|||
from urllib.parse import parse_qs
|
||||
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.db.models import F
|
||||
from django.db.models import F, Sum, Count
|
||||
from django.shortcuts import get_object_or_404
|
||||
from django.http import Http404
|
||||
from django.core.exceptions import PermissionDenied
|
||||
|
@ -45,9 +45,11 @@ from django.db import DataError, transaction
|
|||
import json
|
||||
import re
|
||||
import pytz
|
||||
from datetime import timedelta, datetime
|
||||
from datetime import timedelta, datetime, date
|
||||
from dateutil.relativedelta import relativedelta
|
||||
from http import HTTPStatus
|
||||
|
||||
from sith.settings import SITH_ACCOUNTING_DELTA_DUMP as DELTA_DUMP
|
||||
from core.utils import get_start_of_semester
|
||||
from core.views import CanViewMixin, TabedViewMixin, CanEditMixin
|
||||
from core.views.forms import LoginForm
|
||||
|
@ -1504,6 +1506,25 @@ class InvoiceCallView(CounterAdminTabsMixin, CounterAdminMixin, TemplateView):
|
|||
)
|
||||
]
|
||||
)
|
||||
kwargs["sum_accounts"] = [
|
||||
round(Customer.objects.aggregate(Sum("amount"))["amount__sum"], 2)
|
||||
if Customer.objects.aggregate(Sum("amount"))["amount__sum"] is not None
|
||||
else 0,
|
||||
Customer.objects.count(),
|
||||
]
|
||||
|
||||
inactive_accounts = User.objects.filter(
|
||||
customer__amount__gt=0,
|
||||
subscriptions__subscription_end__lte=date.today()
|
||||
- relativedelta(years=DELTA_DUMP["years"], months=DELTA_DUMP["months"]),
|
||||
).aggregate(Sum("customer__amount"), Count("customer"))
|
||||
kwargs["sum_inactive_accounts"] = [
|
||||
round(inactive_accounts["customer__amount__sum"], 2)
|
||||
if inactive_accounts["customer__amount__sum"] is not None
|
||||
else 0,
|
||||
inactive_accounts["customer__count"],
|
||||
]
|
||||
|
||||
kwargs["start_date"] = start_date
|
||||
kwargs["sums"] = (
|
||||
Selling.objects.values("club__name")
|
||||
|
|
|
@ -3171,9 +3171,13 @@ msgstr "Avatar"
|
|||
msgid "Scrub"
|
||||
msgstr "Blouse"
|
||||
|
||||
#: core/templates/core/user_detail.jinja:141
|
||||
msgid "Not subscribed"
|
||||
msgstr "Non cotisant"
|
||||
#: core/templates/core/user_detail.jinja:160
|
||||
msgid "Not subscribed for %(y)s year(s) %(m)s month(s) %(d)s day(s) (%(date)s)"
|
||||
msgstr "Non cotisant depuis %(y)s année(s) %(m)s mois %(d)s jour(s) (%(date)s)"
|
||||
|
||||
#: core/templates/core/user_detail.jinja:162
|
||||
msgid "Never subscribed"
|
||||
msgstr "N'a jamais cotisé"
|
||||
|
||||
#: core/templates/core/user_detail.jinja:143
|
||||
#: subscription/templates/subscription/subscription.jinja:4
|
||||
|
@ -4188,7 +4192,15 @@ msgstr "Choisir un autre mois : "
|
|||
|
||||
#: counter/templates/counter/invoices_call.jinja:19
|
||||
msgid "CB Payments"
|
||||
msgstr "Payements en Carte Bancaire"
|
||||
msgstr "Paiements en Carte Bancaire"
|
||||
|
||||
#: counter/templates/counter/invoices_call.jinja:21
|
||||
msgid "Money accross all users account : %(money)s € (on %(users)s account(s))"
|
||||
msgstr "Argent sur tous les comptes utilisateurs : %(money)s € (sur %(users)s compte(s))"
|
||||
|
||||
#: counter/templates/counter/invoices_call.jinja:26
|
||||
msgid "Including those who have not been contributors for at least %(year)s year(s) : %(money)s € (on %(users)s account(s))"
|
||||
msgstr "Dont ceux qui n'ont pas été cotisant depuis au moins %(year)s an(s) : %(money)s € (sur %(users)s compte(s))"
|
||||
|
||||
#: counter/templates/counter/last_ops.jinja:5
|
||||
#: counter/templates/counter/last_ops.jinja:15
|
||||
|
|
|
@ -44,6 +44,7 @@ import sys
|
|||
import sentry_sdk
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from sentry_sdk.integrations.django import DjangoIntegration
|
||||
from dateutil.relativedelta import relativedelta
|
||||
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
|
@ -382,6 +383,9 @@ SITH_PROFILE_DEPARTMENTS = [
|
|||
("NA", _("N/A")),
|
||||
]
|
||||
|
||||
SITH_ACCOUNTING_DELTA_NOTIFICATION = {"years": 1, "months": 10}
|
||||
SITH_ACCOUNTING_DELTA_DUMP = {"years": 2, "months": 0}
|
||||
|
||||
SITH_ACCOUNTING_PAYMENT_METHOD = [
|
||||
("CHECK", _("Check")),
|
||||
("CASH", _("Cash")),
|
||||
|
|
Loading…
Reference in New Issue
Block a user