from django.contrib import admin
from .models import CostSheet, CostSheetMember, CostSheetTool


class CostSheetMemberInline(admin.TabularInline):
    model = CostSheetMember
    extra = 0
    readonly_fields = ['total_cost']

class CostSheetToolInline(admin.TabularInline):
    model = CostSheetTool
    extra = 0

@admin.register(CostSheet)
class CostSheetAdmin(admin.ModelAdmin):
    list_display = ['lead', 'version', 'status', 'total_cost', 'budget_status', 'created_by']
    list_filter = ['status', 'budget_status']
    inlines = [CostSheetMemberInline, CostSheetToolInline]
