Implement invoice model and admin API

This commit is contained in:
Jan Dittberner 2023-04-23 14:43:44 +02:00
parent a136bcc52b
commit 0962891a9b
16 changed files with 331 additions and 1 deletions

View file

@ -0,0 +1,38 @@
# Generated by Django 3.2.18 on 2023-04-23 10:37
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import invoices.models
class Migration(migrations.Migration):
initial = True
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name='Invoice',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('invoice', models.FileField(upload_to=invoices.models.customer_invoice_path)),
('invoice_number', models.SlugField(max_length=10, unique=True, verbose_name='Invoice number')),
('invoice_date', models.DateField(verbose_name='Invoice date')),
('invoice_value', models.DecimalField(decimal_places=2, max_digits=10, verbose_name='Amount')),
('invoice_currency', models.PositiveSmallIntegerField(choices=[(1, 'EUR')], verbose_name='Currency')),
('due_date', models.DateField(verbose_name='Due date')),
('payment_date', models.DateField(blank=True, null=True, verbose_name='Payment date')),
('payment_variant', models.TextField(blank=True, null=True, verbose_name='Payment variant')),
('customer', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='customer')),
],
options={
'verbose_name': 'Invoice',
'verbose_name_plural': 'Invoices',
'ordering': ['-invoice_date', 'customer'],
},
),
]

View file

@ -0,0 +1,59 @@
# Generated by Django 3.2.18 on 2023-04-23 12:15
import django.core.validators
from django.db import migrations, models
import invoices.models
class Migration(migrations.Migration):
dependencies = [
('invoices', '0001_initial_invoice_model'),
]
operations = [
migrations.AlterModelOptions(
name='invoice',
options={'ordering': ['-invoice_date', 'customer'], 'verbose_name': 'invoice', 'verbose_name_plural': 'invoices'},
),
migrations.AlterField(
model_name='invoice',
name='due_date',
field=models.DateField(verbose_name='due date'),
),
migrations.AlterField(
model_name='invoice',
name='invoice',
field=models.FileField(upload_to=invoices.models.customer_invoice_path, validators=[invoices.models.validate_pdf, django.core.validators.FileExtensionValidator(allowed_extensions=['pdf'])]),
),
migrations.AlterField(
model_name='invoice',
name='invoice_currency',
field=models.PositiveSmallIntegerField(choices=[(1, 'EUR')], verbose_name='currency'),
),
migrations.AlterField(
model_name='invoice',
name='invoice_date',
field=models.DateField(verbose_name='invoice date'),
),
migrations.AlterField(
model_name='invoice',
name='invoice_number',
field=models.SlugField(max_length=10, unique=True, verbose_name='invoice number'),
),
migrations.AlterField(
model_name='invoice',
name='invoice_value',
field=models.DecimalField(decimal_places=2, max_digits=10, verbose_name='amount'),
),
migrations.AlterField(
model_name='invoice',
name='payment_date',
field=models.DateField(blank=True, null=True, verbose_name='payment date'),
),
migrations.AlterField(
model_name='invoice',
name='payment_variant',
field=models.TextField(blank=True, null=True, verbose_name='payment variant'),
),
]