from django.contrib import admin

from billing.models import Invoice, InvoiceLine, Payment, Payout
from recycle_core.admin import OrgScopedAdmin


@admin.register(Invoice)
class InvoiceAdmin(OrgScopedAdmin):
    list_display = ("id", "organization", "customer", "total_amount", "status", "issued_at")
    list_filter = ("status",)
    search_fields = ("id", "customer__name")


@admin.register(InvoiceLine)
class InvoiceLineAdmin(OrgScopedAdmin):
    list_display = ("invoice", "description", "material", "quantity", "unit_price", "line_total")
    search_fields = ("invoice__id", "description")


@admin.register(Payment)
class PaymentAdmin(OrgScopedAdmin):
    list_display = ("invoice", "amount", "currency_code", "received_at", "reference")
    search_fields = ("invoice__id", "reference")


@admin.register(Payout)
class PayoutAdmin(OrgScopedAdmin):
    list_display = ("organization", "customer", "amount", "currency_code", "paid_at", "reference")
    search_fields = ("customer__name", "reference")
