mirror of https://github.com/nanoy42/coope
11 changed files with 249 additions and 7 deletions
@ -0,0 +1,7 @@ |
|||
import math |
|||
|
|||
def compute_price(price, a, b, c, alpha): |
|||
if price < a: |
|||
return price * (a + b * math.exp(-c/(price-alpha)**2)) |
|||
else: |
|||
return price * a |
|||
@ -0,0 +1,25 @@ |
|||
# Generated by Django 2.1 on 2019-06-23 12:37 |
|||
|
|||
from django.db import migrations, models |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('preferences', '0015_dividehistory'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.CreateModel( |
|||
name='PriceProfile', |
|||
fields=[ |
|||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), |
|||
('name', models.CharField(max_length=255)), |
|||
('a', models.DecimalField(decimal_places=2, max_digits=3, verbose_name='Marge constante')), |
|||
('b', models.DecimalField(decimal_places=2, max_digits=3, verbose_name='Marge constante')), |
|||
('c', models.DecimalField(decimal_places=2, max_digits=4, verbose_name='Marge constante')), |
|||
('alpha', models.DecimalField(decimal_places=2, max_digits=4, verbose_name='Marge constante')), |
|||
('use_for_draft', models.BooleanField(default=False)), |
|||
], |
|||
), |
|||
] |
|||
@ -0,0 +1,38 @@ |
|||
# Generated by Django 2.1 on 2019-06-23 12:53 |
|||
|
|||
from django.db import migrations, models |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('preferences', '0016_priceprofile'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.AlterField( |
|||
model_name='priceprofile', |
|||
name='alpha', |
|||
field=models.DecimalField(decimal_places=2, max_digits=4, verbose_name='Étendue'), |
|||
), |
|||
migrations.AlterField( |
|||
model_name='priceprofile', |
|||
name='b', |
|||
field=models.DecimalField(decimal_places=2, max_digits=3, verbose_name='Marge variable'), |
|||
), |
|||
migrations.AlterField( |
|||
model_name='priceprofile', |
|||
name='c', |
|||
field=models.DecimalField(decimal_places=2, max_digits=4, verbose_name='Paramètre de forme'), |
|||
), |
|||
migrations.AlterField( |
|||
model_name='priceprofile', |
|||
name='name', |
|||
field=models.CharField(max_length=255, verbose_name='Nom'), |
|||
), |
|||
migrations.AlterField( |
|||
model_name='priceprofile', |
|||
name='use_for_draft', |
|||
field=models.BooleanField(default=False, verbose_name='Utiliser pour les pressions ?'), |
|||
), |
|||
] |
|||
@ -0,0 +1,45 @@ |
|||
{% extends "base.html" %} |
|||
{% block entete %}Gestion des profils de prix{% endblock %} |
|||
{% block navbar %} |
|||
<ul> |
|||
<li><a href="#first">Liste des profils de prix</a></li> |
|||
</ul> |
|||
{% endblock %} |
|||
{% block content %} |
|||
<section id="first" class="main"> |
|||
<header class="major"> |
|||
<h2>Liste des profils de prix</h2> |
|||
</header> |
|||
{% if perms.preferences.add_priceprofile %} |
|||
<a class="button" href="{% url 'preferences:addPriceProfile' %}"><i class="fa fa-plus-square"></i> Créer un profil de prix</a><br><br> |
|||
{% endif %} |
|||
<div class="table-wrapper"> |
|||
<table> |
|||
<thead> |
|||
<tr> |
|||
<th>Nom</th> |
|||
<th>a (marge constante)</th> |
|||
<th>b (marge variable)</th> |
|||
<th>c (paramètre de forme)</th> |
|||
<th>alpha (étendue)</th> |
|||
<th>Pression ?</th> |
|||
<th>Administration</th> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
{% for pp in price_profiles %} |
|||
<tr> |
|||
<td>{{ pp.name }} </td> |
|||
<td>{{ pp.a }}</td> |
|||
<td>{{ pp.b }}</td> |
|||
<td>{{ pp.c }}</td> |
|||
<td>{{ pp.alpha }}</td> |
|||
<td>{{ pp.use_for_draft | yesno:"Oui,Non"}}</td> |
|||
<td>{% if perms.preferences.change_priceprofile %}<a class="button small" href="{% url 'preferences:editPriceProfile' pp.pk %}"><i class="fa fa-pencil-alt"></i> Modifier</a> {% endif %}{% if perms.preferences.delete_priceprofile %}<a class="button small" href="{% url 'preferences:deletePriceProfile' pp.pk %}"><i class="fa fa-trash"></i> Supprimer</a>{% endif %}</td> |
|||
</tr> |
|||
{% endfor %} |
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
</section> |
|||
{% endblock %} |
|||
@ -0,0 +1,17 @@ |
|||
# Generated by Django 2.1 on 2019-06-23 12:37 |
|||
|
|||
from django.db import migrations |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('users', '0008_auto_20190623_1105'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.AlterModelOptions( |
|||
name='profile', |
|||
options={'permissions': (('can_generate_invoices', 'Can generate invocies'),), 'verbose_name': 'Profil'}, |
|||
), |
|||
] |
|||
Loading…
Reference in new issue