Plus de décimales
This commit is contained in:
parent
23bceaf51f
commit
ef664804de
2 changed files with 30 additions and 4 deletions
23
comet/account/migrations/0005_auto_20190205_1841.py
Normal file
23
comet/account/migrations/0005_auto_20190205_1841.py
Normal 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 (€)'),
|
||||
),
|
||||
]
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue