Skip to content

Commit

Permalink
Requested changes done
Browse files Browse the repository at this point in the history
  • Loading branch information
kerstenkenan committed Dec 10, 2024
1 parent 3093737 commit c3d5390
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 16 deletions.
4 changes: 3 additions & 1 deletion tapir/accounts/templates/accounts/user_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ <h5 class="card-header d-flex justify-content-between align-items-center flex-wr
<div class="col-xl-6">{% purchase_tracking_card tapir_user=object %}</div>
{% if tapir_user.share_owner and tapir_user.allows_purchase_tracking %}
<div class="col-xl-6">{% purchase_statistics_card tapir_user=object %}</div>
</div>
{% endif %}
</div>
{% if tapir_user.share_owner and tapir_user.allows_purchase_tracking %}
<div class="row justify-content-end">
<div class="col-xl-6">{% credit_account_card tapir_user=object %}</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from tapir.accounts.models import TapirUser
from tapir.statistics.models import ProcessedCreditFiles, CreditAccount
from tapir.utils.shortcuts import get_timezone_aware_datetime
from tapir.statistics.management.commands import process_purchase_files
from tapir.statistics.management.commands.process_purchase_files import Command


class Command(BaseCommand):
Expand Down Expand Up @@ -67,7 +67,7 @@ def process_file(cls, file: SFTPFile, file_name: str):
CreditAccount.objects.create(
source_file=source_file,
credit_date=credit_date,
credit_amount=process_purchase_files.parse_german_number(row["Betrag"]),
credit_amount=Command.parse_german_number(row["Betrag"]),
credit_counter=row["Bon"],
cashier=row["Kasse"],
info=row["Info"],
Expand Down
9 changes: 5 additions & 4 deletions tapir/statistics/templatetags/statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ def purchase_statistics_card(context, tapir_user):
@register.inclusion_tag("statistics/tags/credit_account_card.html", takes_context=True)
def credit_account_card(context, tapir_user):
user_credits = CreditAccount.objects.filter(tapir_user=tapir_user)
context["last_credits"] = user_credits.order_by("-credit_date")[:10]
context["actual_credit"] = "{:.2f}".format(
user_credits.aggregate(total_credit=Sum("credit_amount"))["total_credit"]
)
if user_credits:
context["last_credits"] = user_credits.order_by("-credit_date")[:10]
context["actual_credit"] = "{:.2f}".format(
user_credits.aggregate(total_credit=Sum("credit_amount"))["total_credit"]
)
return context


Expand Down
12 changes: 3 additions & 9 deletions tapir/utils/management/commands/generate_test_data_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,17 +595,11 @@ def generate_credit_account():
share_owners = NumberOfSharesService.annotate_share_owner_queryset_with_nb_of_active_shares(
share_owners, current_date
)
# share_owners = (
# MembershipPauseService.annotate_share_owner_queryset_with_has_active_pause(
# share_owners, current_date
# )
# )

purchasing_users = [
credit_users = [
share_owner
for share_owner in share_owners.with_status(
status=MemberStatus.ACTIVE, at_datetime=current_date
)
)[::2]
if share_owner.user
]
info = random.choice(["Guthabenkarte", "Einkauf"])
Expand All @@ -628,7 +622,7 @@ def generate_credit_account():
info=info,
tapir_user=share_owner.user,
)
for share_owner in purchasing_users
for share_owner in credit_users
]
)

Expand Down

0 comments on commit c3d5390

Please sign in to comment.