# -*- coding: utf-8 -*-
from django.contrib import admin
from coin.billing.models import Invoice, InvoiceDetail, Payment
import autocomplete_light


class InvoiceDetailInline(admin.StackedInline):
    model = InvoiceDetail
    extra = 0
    fields = (('label', 'amount', 'quantity', 'tax', 'offer'),)


class PaymentInline(admin.StackedInline):
    model = Payment
    extra = 0
    fields = (('date', 'payment_mean', 'amount'),)


class InvoiceAdmin(admin.ModelAdmin):
	list_display = ('number', 'date', 'status', 'amount', 'member')
	list_display_links = ('number', 'date')
	inlines = [InvoiceDetailInline, PaymentInline]
	fields = (('number', 'date', 'status'),
			  ('period_from', 'period_to', 'date_due'),
			  'member')
	form = autocomplete_light.modelform_factory(Invoice)


admin.site.register(Invoice, InvoiceAdmin)
