"""Admin for the accounting app.""" from django.contrib import admin from django.utils.translation import gettext_lazy as _ from .models import Order from .models import Payment @admin.register(Order) class OrderAdmin(admin.ModelAdmin): """Admin for the Order model.""" list_display = ("who", "description", "created", "is_paid") @admin.display(description=_("Customer")) def who(self, instance: Order) -> str: """Return the full name of the user who made the order.""" return instance.user.get_full_name() @admin.register(Payment) class PaymentAdmin(admin.ModelAdmin): """Admin for the Payment model.""" list_display = ("who", "description", "order_id", "created") @admin.display(description=_("Customer")) def who(self, instance: Payment) -> str: """Return the full name of the user who made the payment.""" return instance.order.user.get_full_name() @admin.display(description=_("Order ID")) def order_id(self, instance: Payment) -> int: """Return the ID of the order.""" return instance.order.id