diff --git a/comet/account/migrations/0005_auto_20190205_1841.py b/comet/account/migrations/0005_auto_20190205_1841.py new file mode 100644 index 0000000..0dfc96f --- /dev/null +++ b/comet/account/migrations/0005_auto_20190205_1841.py @@ -0,0 +1,23 @@ +# Generated by Django 2.1.4 on 2019-02-05 18:41 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('account', '0004_auto_20181214_1844'), + ] + + operations = [ + migrations.AlterField( + model_name='article', + name='price', + field=models.DecimalField(decimal_places=3, max_digits=4, verbose_name='Prix unitaire (au €/g)'), + ), + migrations.AlterField( + model_name='sale', + name='price', + field=models.DecimalField(decimal_places=3, max_digits=5, verbose_name='Prix (€)'), + ), + ] diff --git a/comet/account/models.py b/comet/account/models.py index c71a2ff..d042805 100644 --- a/comet/account/models.py +++ b/comet/account/models.py @@ -2,6 +2,7 @@ from django.db import models from django.utils import timezone + class Account(models.Model): """Account for a member.""" balance = models.DecimalField( @@ -18,25 +19,27 @@ class Account(models.Model): """Adjust the ballance according to the sales, without saving the model.""" self.balance = Sale.objects.filter(account=self)\ - .aggregate(models.Sum('price'))['price__sum'] + .aggregate(models.Sum('price'))['price__sum'] + class Sale(models.Model): """Represents a sale""" price = models.DecimalField( verbose_name="Prix (€)", - max_digits=4, - decimal_places=2 + max_digits=5, + decimal_places=3 ) account = models.ForeignKey(Account, on_delete=models.SET_NULL, null=True) title = models.CharField(max_length=255, verbose_name="Intitulé") date = models.DateTimeField(verbose_name="Date", default=timezone.now) + class Article(models.Model): """An article which can be sold.""" price = models.DecimalField( verbose_name="Prix unitaire (au €/g)", max_digits=4, - decimal_places=2 + decimal_places=3 ) name = models.CharField( max_length=255,