Commit 5d8d0c13 authored by Élie Bouttier's avatar Élie Bouttier
Browse files

expense categories

parent eae9c248
......@@ -23,8 +23,9 @@ from services.admin import ServiceAdmin
from services.models import Service
from .facture import facture
from .models import Echeance, Expense, RecurringExpense, RecurringExpensePayment, \
Invoice, InvoicedProduct, PaymentUpdate, RecurringPayment
from .models import Echeance, Expense, RecurringExpense, ExpenseCategory, \
RecurringExpensePayment, Invoice, InvoicedProduct, \
PaymentUpdate, RecurringPayment
from .utils import notify_payment_update
......@@ -300,7 +301,7 @@ class EcheanceAdmin(admin.ModelAdmin):
class ExpenseAdmin(admin.ModelAdmin):
list_display = ('date', 'amount', 'recipient', 'label',)
list_filter = ('date', 'recipient',)
list_filter = ('date', 'recipient', 'category',)
class RecurringExpensePaymentInline(admin.TabularInline):
......@@ -313,6 +314,11 @@ class RecurringExpenseAdmin(admin.ModelAdmin):
inlines = [ RecurringExpensePaymentInline ]
class ExpenseCategoryAdmin(admin.ModelAdmin):
list_display = ('name',)
list_filter = ('name',)
class InvoicedProductAdmin(admin.TabularInline):
model = InvoicedProduct
verbose_name_plural = 'Produit'
......@@ -481,6 +487,7 @@ class InvoiceAdmin(admin.ModelAdmin):
admin.site.register(RecurringPayment, RecurringPaymentAdmin)
admin.site.register(PaymentUpdate, PaymentUpdateAdmin)
admin.site.register(Echeance, EcheanceAdmin)
admin.site.register(ExpenseCategory, ExpenseCategoryAdmin)
admin.site.register(Expense, ExpenseAdmin)
admin.site.register(RecurringExpense, RecurringExpenseAdmin)
admin.site.register(Invoice, InvoiceAdmin)
# Generated by Django 3.0.5 on 2021-02-04 12:43
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('banking', '0022_echeance'),
]
operations = [
migrations.CreateModel(
name='ExpenseCategory',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=64)),
('description', models.TextField(blank=True, default='')),
],
options={
'verbose_name': 'catégorie de dépense',
'verbose_name_plural': 'catégories de dépense',
},
),
migrations.AddField(
model_name='expense',
name='category',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='expenses', to='banking.ExpenseCategory'),
),
]
......@@ -166,11 +166,24 @@ class Echeance(models.Model):
return '{} € ({})'.format(self.amount, self.adhesion)
class ExpenseCategory(models.Model):
name = models.CharField(max_length=64)
description = models.TextField(blank=True, default='')
class Meta:
verbose_name = 'catégorie de dépense'
verbose_name_plural = 'catégories de dépense'
def __str__(self):
return self.name
class Expense(models.Model):
created = models.DateTimeField(auto_now_add=True)
date = models.DateField(verbose_name='Date')
amount = models.DecimalField(max_digits=9, decimal_places=2, verbose_name='Montant')
recipient = models.CharField(max_length=256, verbose_name='Fournisseur')
category = models.ForeignKey(ExpenseCategory, related_name='expenses', on_delete=models.SET_NULL, null=True)
label = models.CharField(max_length=256, verbose_name='Intitulé')
details = models.TextField(blank=True, default='', verbose_name='Détails', help_text='Informations publics.')
notes = models.TextField(blank=True, default='', verbose_name='Notes', help_text='Informations internes (référence de facture, …).')
......
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