Commit 82481281 authored by Michal Čihař's avatar Michal Čihař

Add invoice tracking model

Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 5cf27c1b
......@@ -22,7 +22,7 @@ from __future__ import unicode_literals
from django.contrib import admin
from django.utils.translation import ugettext_lazy as _
from weblate.billing.models import Plan, Billing
from weblate.billing.models import Plan, Billing, Invoice
class PlanAdmin(admin.ModelAdmin):
......@@ -51,5 +51,18 @@ class BillingAdmin(admin.ModelAdmin):
list_projects.short_description = _('Projects')
class InvoiceAdmin(admin.ModelAdmin):
list_display = (
'billing', 'start', 'end', 'payment', 'currency', 'ref'
)
list_filter = ('currency',)
search_fields = (
'billing__user__username', 'billing__projects__name',
'ref', 'note',
)
date_hierarchy = 'end'
admin.site.register(Plan, PlanAdmin)
admin.site.register(Billing, BillingAdmin)
admin.site.register(Invoice, InvoiceAdmin)
# -*- coding: utf-8 -*-
# Generated by Django 1.9.2 on 2016-02-10 12:53
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('billing', '0006_auto_20160106_1834'),
]
operations = [
migrations.CreateModel(
name='Invoice',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('start', models.DateField()),
('end', models.DateField()),
('payment', models.IntegerField()),
('currency', models.IntegerField(choices=[(0, 'EUR'), (1, 'BTC')], default=1)),
('ref', models.CharField(blank=True, max_length=50)),
('note', models.TextField(blank=True)),
('billing', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='billing.Billing')),
],
),
]
......@@ -127,3 +127,26 @@ class Billing(models.Model):
)
)
in_limits.boolean = True
@python_2_unicode_compatible
class Invoice(models.Model):
CURRENCY_EUR = 0
CURRENCY_BTC = 1
billing = models.ForeignKey(Billing)
start = models.DateField()
end = models.DateField()
payment = models.IntegerField()
currency = models.IntegerField(
choices=(
(CURRENCY_EUR, 'EUR'),
(CURRENCY_BTC, 'BTC'),
),
default=CURRENCY_BTC
)
ref = models.CharField(blank=True, max_length=50)
note = models.TextField(blank=True)
def __str__(self):
return '{0} - {1}: {2}'.format(self.start, self.end, self.billing)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment