Plus de décimales

This commit is contained in:
Hugo LEVY-FALK 2019-02-05 19:41:28 +01:00
parent 23bceaf51f
commit ef664804de
2 changed files with 30 additions and 4 deletions

View file

@ -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 (€)'),
),
]

View file

@ -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(
@ -20,23 +21,25 @@ class Account(models.Model):
self.balance = Sale.objects.filter(account=self)\
.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,