category addcost added
This commit is contained in:
parent
fbd0d760b6
commit
ee6de35627
19
kfet/migrations/0048_articlecategory_has_addcost.py
Normal file
19
kfet/migrations/0048_articlecategory_has_addcost.py
Normal file
|
@ -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),
|
||||||
|
),
|
||||||
|
]
|
|
@ -327,13 +327,16 @@ class CheckoutStatement(models.Model):
|
||||||
balance=F('balance') - last_statement.balance_new + self.balance_new)
|
balance=F('balance') - last_statement.balance_new + self.balance_new)
|
||||||
super(CheckoutStatement, self).save(*args, **kwargs)
|
super(CheckoutStatement, self).save(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
@python_2_unicode_compatible
|
@python_2_unicode_compatible
|
||||||
class ArticleCategory(models.Model):
|
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):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
|
||||||
@python_2_unicode_compatible
|
@python_2_unicode_compatible
|
||||||
class Article(models.Model):
|
class Article(models.Model):
|
||||||
name = models.CharField(max_length = 45)
|
name = models.CharField(max_length = 45)
|
||||||
|
|
|
@ -990,7 +990,7 @@ def kpsul_perform_operations(request):
|
||||||
for operation in operations:
|
for operation in operations:
|
||||||
if operation.type == Operation.PURCHASE:
|
if operation.type == Operation.PURCHASE:
|
||||||
operation.amount = - operation.article.price * operation.article_nb
|
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_for = addcost_for
|
||||||
operation.addcost_amount = addcost_amount * operation.article_nb
|
operation.addcost_amount = addcost_amount * operation.article_nb
|
||||||
operation.amount -= operation.addcost_amount
|
operation.amount -= operation.addcost_amount
|
||||||
|
@ -1001,7 +1001,7 @@ def kpsul_perform_operations(request):
|
||||||
else:
|
else:
|
||||||
operation.is_checkout = False
|
operation.is_checkout = False
|
||||||
if operationgroup.on_acc.is_cof:
|
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.addcost_amount = operation.addcost_amount / cof_grant_divisor
|
||||||
operation.amount = operation.amount / cof_grant_divisor
|
operation.amount = operation.amount / cof_grant_divisor
|
||||||
to_articles_stocks[operation.article] -= operation.article_nb
|
to_articles_stocks[operation.article] -= operation.article_nb
|
||||||
|
|
Loading…
Reference in a new issue