diff --git a/kfet/migrations/0048_articlecategory_has_addcost.py b/kfet/migrations/0048_articlecategory_has_addcost.py new file mode 100644 index 00000000..e79ad7e6 --- /dev/null +++ b/kfet/migrations/0048_articlecategory_has_addcost.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('kfet', '0047_auto_20170104_1528'), + ] + + operations = [ + migrations.AddField( + model_name='articlecategory', + name='has_addcost', + field=models.BooleanField(default=True), + ), + ] diff --git a/kfet/models.py b/kfet/models.py index c6853577..129ea7f3 100644 --- a/kfet/models.py +++ b/kfet/models.py @@ -327,13 +327,16 @@ class CheckoutStatement(models.Model): balance=F('balance') - last_statement.balance_new + self.balance_new) super(CheckoutStatement, self).save(*args, **kwargs) + @python_2_unicode_compatible class ArticleCategory(models.Model): - name = models.CharField(max_length = 45) + name = models.CharField(max_length=45) + has_addcost = models.BooleanField(default=True) def __str__(self): return self.name + @python_2_unicode_compatible class Article(models.Model): name = models.CharField(max_length = 45) diff --git a/kfet/views.py b/kfet/views.py index 19574f11..2164de47 100644 --- a/kfet/views.py +++ b/kfet/views.py @@ -990,7 +990,7 @@ def kpsul_perform_operations(request): for operation in operations: if operation.type == Operation.PURCHASE: operation.amount = - operation.article.price * operation.article_nb - if is_addcost: + if is_addcost & operation.article.category.has_addcost: operation.addcost_for = addcost_for operation.addcost_amount = addcost_amount * operation.article_nb operation.amount -= operation.addcost_amount @@ -1001,7 +1001,7 @@ def kpsul_perform_operations(request): else: operation.is_checkout = False if operationgroup.on_acc.is_cof: - if is_addcost: + if is_addcost & operation.article.category.has_addcost: operation.addcost_amount = operation.addcost_amount / cof_grant_divisor operation.amount = operation.amount / cof_grant_divisor to_articles_stocks[operation.article] -= operation.article_nb