from django.contrib import admin
from .models import Account, AccountTransaction, ExpenseCategory, Expense, OtherIncome, OwnerDraw


@admin.register(Account)
class AccountAdmin(admin.ModelAdmin):
    list_display = ('name', 'account_type', 'balance', 'is_active')
    list_filter = ('account_type', 'is_active')


@admin.register(AccountTransaction)
class AccountTransactionAdmin(admin.ModelAdmin):
    list_display = ('account', 'tx_type', 'direction', 'amount', 'description', 'date')
    list_filter = ('tx_type', 'direction', 'account')
    date_hierarchy = 'date'


@admin.register(ExpenseCategory)
class ExpenseCategoryAdmin(admin.ModelAdmin):
    list_display = ('name',)


@admin.register(Expense)
class ExpenseAdmin(admin.ModelAdmin):
    list_display = ('description', 'category', 'account', 'amount', 'date', 'created_by')
    list_filter = ('category', 'account')
    date_hierarchy = 'date'


@admin.register(OtherIncome)
class OtherIncomeAdmin(admin.ModelAdmin):
    list_display = ('description', 'account', 'amount', 'date')
    date_hierarchy = 'date'


@admin.register(OwnerDraw)
class OwnerDrawAdmin(admin.ModelAdmin):
    list_display = ('account', 'amount', 'date', 'created_by')
    date_hierarchy = 'date'