diff --git a/accounting/migrations/0012_auto_20160720_1847.py b/accounting/migrations/0012_auto_20160720_1847.py new file mode 100644 index 00000000..23322935 --- /dev/null +++ b/accounting/migrations/0012_auto_20160720_1847.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('accounting', '0011_auto_20160718_1805'), + ] + + operations = [ + migrations.AlterModelOptions( + name='operation', + options={'ordering': ['-number']}, + ), + migrations.AddField( + model_name='operation', + name='number', + field=models.IntegerField(default=1, verbose_name='number'), + preserve_default=False, + ), + migrations.AlterUniqueTogether( + name='operation', + unique_together=set([('number', 'journal')]), + ), + ] diff --git a/accounting/models.py b/accounting/models.py index 7b590e77..616b5352 100644 --- a/accounting/models.py +++ b/accounting/models.py @@ -1,7 +1,10 @@ from django.core.urlresolvers import reverse +from django.core.exceptions import ValidationError +from django.db.models import Count from django.db import models from django.conf import settings from django.utils.translation import ugettext_lazy as _ +from django.template import defaultfilters from decimal import Decimal from core.models import User @@ -128,6 +131,7 @@ class Operation(models.Model): """ An operation is a line in the journal, a debit or a credit """ + number = models.IntegerField(_('number')) journal = models.ForeignKey(GeneralJournal, related_name="operations", null=False) amount = CurrencyField(_('amount')) date = models.DateField(_('date')) @@ -139,7 +143,19 @@ class Operation(models.Model): done = models.BooleanField(_('is done'), default=False) accounting_type = models.ForeignKey('AccountingType', related_name="operations") + class Meta: + unique_together = ('number', 'journal') + ordering = ['-number'] + + def clean(self): + super(Operation, self).clean() + if self.date < self.journal.start_date: + raise ValidationError(_("""The date can not be before the start date of the journal, which is +%(start_date)s.""") % {'start_date': defaultfilters.date(self.journal.start_date, settings.DATE_FORMAT)}) + def save(self): + if self.number is None: + self.number = self.journal.operations.count() + 1 super(Operation, self).save() self.journal.update_amounts() diff --git a/accounting/templates/accounting/club_account_details.jinja b/accounting/templates/accounting/club_account_details.jinja index c2bd5f13..4c0eff9b 100644 --- a/accounting/templates/accounting/club_account_details.jinja +++ b/accounting/templates/accounting/club_account_details.jinja @@ -17,6 +17,7 @@

{% trans %}You can not create new journal while you still have one opened{% endtrans %}

{% endif %} + @@ -24,7 +25,10 @@ + + + {% for j in object.journals.all() %} @@ -45,5 +49,6 @@ {% trans %}Edit{% endtrans %} {% endfor %} +
{% trans %}Name{% endtrans %} {% trans %}Start{% endtrans %}{% trans %}Amount{% endtrans %} {% trans %}Effective amount{% endtrans %} {% trans %}Closed{% endtrans %}{% trans %}Actions{% endtrans %}
{{ j.name }}
{% endblock %} diff --git a/accounting/templates/accounting/journal_details.jinja b/accounting/templates/accounting/journal_details.jinja index d08be1b6..ae4286d0 100644 --- a/accounting/templates/accounting/journal_details.jinja +++ b/accounting/templates/accounting/journal_details.jinja @@ -15,6 +15,7 @@

{% trans %}New operation{% endtrans %}

{% endif %} + @@ -28,9 +29,11 @@ + + {% for o in object.operations.all() %} - + @@ -50,5 +53,6 @@ {% endfor %} +
{% trans %}Nb{% endtrans %} {% trans %}Date{% endtrans %}{% trans %}Comment{% endtrans %} {% trans %}Actions{% endtrans %}
{{ o.id }}{{ o.number }} {{ o.date }} {{ o.label }} {{ o.amount }} €
{% endblock %} diff --git a/core/static/core/form.css b/core/static/core/form.css index 83b926f7..53a37663 100644 --- a/core/static/core/form.css +++ b/core/static/core/form.css @@ -180,9 +180,3 @@ select[multiple] vertical-align: top; } -/* Tables ------------------------------------------------*/ -tbody>tr{ - display: block; - margin: 3px; -} diff --git a/core/static/core/style.css b/core/static/core/style.css index a3a7b5c4..26394f67 100644 --- a/core/static/core/style.css +++ b/core/static/core/style.css @@ -111,6 +111,24 @@ ul, ol { display: inline-block; margin: 4px; } +table { + width: 100%; +} +td { + padding: 4px; + border: solid 1px black; + border-collapse: collapse; +} +thead { + font-weight: bold; +} +tbody>tr:nth-child(even) { + background: lightgrey; +} +tbody>tr:hover { + background: yellow; + width: 100%; +} /*-----------------------------USER PROFILE----------------------------*/ .user_profile { diff --git a/counter/models.py b/counter/models.py index 377d4379..3adf2eac 100644 --- a/counter/models.py +++ b/counter/models.py @@ -65,7 +65,7 @@ class Product(models.Model): icon = models.ImageField(upload_to='products', null=True, blank=True) club = models.ForeignKey(Club, related_name="products") - def is_owned_by(self, user): # TODO do this for all models + def is_owned_by(self, user): """ Method to see if that object can be edited by the given user """ diff --git a/sith/settings_sample.py b/sith/settings_sample.py index ac8e8340..43238b23 100644 --- a/sith/settings_sample.py +++ b/sith/settings_sample.py @@ -144,9 +144,9 @@ DATABASES = { # Internationalization # https://docs.djangoproject.com/en/1.8/topics/i18n/ -LANGUAGE_CODE = 'en-us' +LANGUAGE_CODE = 'fr-FR' -TIME_ZONE = 'UTC' +TIME_ZONE = 'Europe/Paris' USE_I18N = True