forked from DGNum/gestioCOF
Merge branch 'k-fet' into qwann/k-fet/stats
This commit is contained in:
commit
9cae3ad0bd
5 changed files with 31 additions and 25 deletions
|
@ -1,21 +1,17 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
from __future__ import (absolute_import, division,
|
|
||||||
print_function, unicode_literals)
|
|
||||||
from builtins import *
|
|
||||||
|
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
from django.core.validators import MinLengthValidator
|
from django.core.validators import MinLengthValidator
|
||||||
from django.contrib.auth.models import User, Group, Permission
|
from django.contrib.auth.models import User, Group, Permission
|
||||||
from django.contrib.contenttypes.models import ContentType
|
from django.contrib.contenttypes.models import ContentType
|
||||||
from django.forms import modelformset_factory, inlineformset_factory
|
from django.forms import modelformset_factory
|
||||||
from django.forms.models import BaseInlineFormSet
|
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from kfet.models import (Account, Checkout, Article, OperationGroup, Operation,
|
from kfet.models import (
|
||||||
|
Account, Checkout, Article, OperationGroup, Operation,
|
||||||
CheckoutStatement, ArticleCategory, Settings, AccountNegative, Transfer,
|
CheckoutStatement, ArticleCategory, Settings, AccountNegative, Transfer,
|
||||||
TransferGroup, Supplier, Inventory, InventoryArticle)
|
TransferGroup, Supplier)
|
||||||
from gestioncof.models import CofProfile
|
from gestioncof.models import CofProfile
|
||||||
|
|
||||||
# -----
|
# -----
|
||||||
|
@ -131,7 +127,16 @@ class UserRestrictTeamForm(UserForm):
|
||||||
|
|
||||||
class UserGroupForm(forms.ModelForm):
|
class UserGroupForm(forms.ModelForm):
|
||||||
groups = forms.ModelMultipleChoiceField(
|
groups = forms.ModelMultipleChoiceField(
|
||||||
Group.objects.filter(name__icontains='K-Fêt'))
|
Group.objects.filter(name__icontains='K-Fêt'),
|
||||||
|
required=False)
|
||||||
|
|
||||||
|
def clean_groups(self):
|
||||||
|
groups = self.cleaned_data.get('groups')
|
||||||
|
# Si aucun groupe, on le dénomme
|
||||||
|
if not groups:
|
||||||
|
groups = self.instance.groups.exclude(name__icontains='K-Fêt')
|
||||||
|
return groups
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = User
|
model = User
|
||||||
fields = ['groups']
|
fields = ['groups']
|
||||||
|
|
|
@ -37,9 +37,10 @@ function amountDisplay(amount, is_cof=false, tri='') {
|
||||||
return amountToUKF(amount, is_cof);
|
return amountToUKF(amount, is_cof);
|
||||||
}
|
}
|
||||||
|
|
||||||
function amountToUKF(amount, is_cof=false) {
|
function amountToUKF(amount, is_cof=false, account=false) {
|
||||||
|
var rounding = account ? Math.floor : Math.round ;
|
||||||
var coef_cof = is_cof ? 1 + settings['subvention_cof'] / 100 : 1;
|
var coef_cof = is_cof ? 1 + settings['subvention_cof'] / 100 : 1;
|
||||||
return Math.floor(amount * coef_cof * 10);
|
return rounding(amount * coef_cof * 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
function isValidTrigramme(trigramme) {
|
function isValidTrigramme(trigramme) {
|
||||||
|
|
|
@ -221,7 +221,7 @@ $(document).ready(function() {
|
||||||
function displayAccountData() {
|
function displayAccountData() {
|
||||||
var balance = account_data['trigramme'] != 'LIQ' ? account_data['balance'] : '';
|
var balance = account_data['trigramme'] != 'LIQ' ? account_data['balance'] : '';
|
||||||
if (balance != '')
|
if (balance != '')
|
||||||
balance = amountToUKF(account_data['balance'], account_data['is_cof']);
|
balance = amountToUKF(account_data['balance'], account_data['is_cof'], true);
|
||||||
var is_cof = account_data['trigramme'] ? account_data['is_cof'] : '';
|
var is_cof = account_data['trigramme'] ? account_data['is_cof'] : '';
|
||||||
if (is_cof !== '')
|
if (is_cof !== '')
|
||||||
is_cof = is_cof ? '<b>COF</b>' : '<b>Non-COF</b>';
|
is_cof = is_cof ? '<b>COF</b>' : '<b>Non-COF</b>';
|
||||||
|
@ -616,7 +616,7 @@ $(document).ready(function() {
|
||||||
for (var elem in article) {
|
for (var elem in article) {
|
||||||
article_html.find('.'+elem).text(article[elem])
|
article_html.find('.'+elem).text(article[elem])
|
||||||
}
|
}
|
||||||
article_html.find('.price').text(amountToUKF(article['price'], false));
|
article_html.find('.price').text(amountToUKF(article['price'], false, false));
|
||||||
var category_html = articles_container
|
var category_html = articles_container
|
||||||
.find('#data-category-'+article['category_id']);
|
.find('#data-category-'+article['category_id']);
|
||||||
if (category_html.length == 0) {
|
if (category_html.length == 0) {
|
||||||
|
@ -834,7 +834,7 @@ $(document).ready(function() {
|
||||||
.attr('data-opeindex', index)
|
.attr('data-opeindex', index)
|
||||||
.find('.number').text(nb).end()
|
.find('.number').text(nb).end()
|
||||||
.find('.name').text(article_data[0]).end()
|
.find('.name').text(article_data[0]).end()
|
||||||
.find('.amount').text(amountToUKF(amount_euro, account_data['is_cof']));
|
.find('.amount').text(amountToUKF(amount_euro, account_data['is_cof'], false));
|
||||||
basket_container.prepend(article_basket_html);
|
basket_container.prepend(article_basket_html);
|
||||||
updateBasketRel();
|
updateBasketRel();
|
||||||
}
|
}
|
||||||
|
@ -848,7 +848,7 @@ $(document).ready(function() {
|
||||||
.attr('data-opeindex', index)
|
.attr('data-opeindex', index)
|
||||||
.find('.number').text(amount+"€").end()
|
.find('.number').text(amount+"€").end()
|
||||||
.find('.name').text(text).end()
|
.find('.name').text(text).end()
|
||||||
.find('.amount').text(amountToUKF(amount, account_data['is_cof']));
|
.find('.amount').text(amountToUKF(amount, account_data['is_cof'], false));
|
||||||
basket_container.prepend(deposit_basket_html);
|
basket_container.prepend(deposit_basket_html);
|
||||||
updateBasketRel();
|
updateBasketRel();
|
||||||
}
|
}
|
||||||
|
@ -861,7 +861,7 @@ $(document).ready(function() {
|
||||||
.attr('data-opeindex', index)
|
.attr('data-opeindex', index)
|
||||||
.find('.number').text(amount+"€").end()
|
.find('.number').text(amount+"€").end()
|
||||||
.find('.name').text('Retrait').end()
|
.find('.name').text('Retrait').end()
|
||||||
.find('.amount').text(amountToUKF(amount, account_data['is_cof']));
|
.find('.amount').text(amountToUKF(amount, account_data['is_cof'], false));
|
||||||
basket_container.prepend(withdraw_basket_html);
|
basket_container.prepend(withdraw_basket_html);
|
||||||
updateBasketRel();
|
updateBasketRel();
|
||||||
}
|
}
|
||||||
|
@ -903,7 +903,7 @@ $(document).ready(function() {
|
||||||
var amount = $(this).find('#id_form-'+opeindex+'-amount');
|
var amount = $(this).find('#id_form-'+opeindex+'-amount');
|
||||||
if (!deleted && type == "purchase")
|
if (!deleted && type == "purchase")
|
||||||
amount.val(amountEuroPurchase(article_id, article_nb));
|
amount.val(amountEuroPurchase(article_id, article_nb));
|
||||||
basket_container.find('[data-opeindex='+opeindex+'] .amount').text(amountToUKF(amount.val(), account_data['is_cof']));
|
basket_container.find('[data-opeindex='+opeindex+'] .amount').text(amountToUKF(amount.val(), account_data['is_cof'], false));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -922,9 +922,9 @@ $(document).ready(function() {
|
||||||
basketrel_html += '<div>Sur 20€: '+ (20-amount).toFixed(2) +' €</div>';
|
basketrel_html += '<div>Sur 20€: '+ (20-amount).toFixed(2) +' €</div>';
|
||||||
} else if (account_data['trigramme'] != '' && !isBasketEmpty()) {
|
} else if (account_data['trigramme'] != '' && !isBasketEmpty()) {
|
||||||
var amount = getAmountBasket();
|
var amount = getAmountBasket();
|
||||||
var amountUKF = amountToUKF(amount, account_data['is_cof']);
|
var amountUKF = amountToUKF(amount, account_data['is_cof'], false);
|
||||||
var newBalance = account_data['balance'] + amount;
|
var newBalance = account_data['balance'] + amount;
|
||||||
var newBalanceUKF = amountToUKF(newBalance, account_data['is_cof']);
|
var newBalanceUKF = amountToUKF(newBalance, account_data['is_cof'], true);
|
||||||
basketrel_html += '<div>Total: '+amountUKF+'</div>';
|
basketrel_html += '<div>Total: '+amountUKF+'</div>';
|
||||||
basketrel_html += '<div>Nouveau solde: '+newBalanceUKF+'</div>';
|
basketrel_html += '<div>Nouveau solde: '+newBalanceUKF+'</div>';
|
||||||
if (newBalance < 0)
|
if (newBalance < 0)
|
||||||
|
@ -959,7 +959,7 @@ $(document).ready(function() {
|
||||||
var title = is_checkout ? 'Montant de la charge' : "Montant de l'édition";
|
var title = is_checkout ? 'Montant de la charge' : "Montant de l'édition";
|
||||||
$.confirm({
|
$.confirm({
|
||||||
title: title,
|
title: title,
|
||||||
content: '<input type="number" step="0.01" min="0.01" on autofocus placeholder="€">',
|
content: '<input type="number" lang="en" step="0.01" min="0.01" on autofocus placeholder="€">',
|
||||||
backgroundDismiss: true,
|
backgroundDismiss: true,
|
||||||
animation:'top',
|
animation:'top',
|
||||||
closeAnimation:'bottom',
|
closeAnimation:'bottom',
|
||||||
|
@ -986,7 +986,7 @@ $(document).ready(function() {
|
||||||
function askWithdraw() {
|
function askWithdraw() {
|
||||||
$.confirm({
|
$.confirm({
|
||||||
title: 'Montant du retrait',
|
title: 'Montant du retrait',
|
||||||
content: '<input type="number" step="0.01" min="0.01" on autofocus placeholder="€">',
|
content: '<input type="number" lang="en" step="0.01" min="0.01" on autofocus placeholder="€">',
|
||||||
backgroundDismiss: true,
|
backgroundDismiss: true,
|
||||||
animation:'top',
|
animation:'top',
|
||||||
closeAnimation:'bottom',
|
closeAnimation:'bottom',
|
||||||
|
@ -1164,7 +1164,7 @@ $(document).ready(function() {
|
||||||
function askAddcost(errors = '') {
|
function askAddcost(errors = '') {
|
||||||
$.confirm({
|
$.confirm({
|
||||||
title: 'Majoration',
|
title: 'Majoration',
|
||||||
content: errors + '<input type="text" placeholder="Trigramme" autocomplete="off" name="trigramme" spellcheck="false" style="text-transform:uppercase" autofocus><input type="number" step="0.01" min="0.01" placeholder="€" name="amount">',
|
content: errors + '<input type="text" placeholder="Trigramme" autocomplete="off" name="trigramme" spellcheck="false" style="text-transform:uppercase" autofocus><input type="number" lang="en" step="0.01" min="0.01" placeholder="€" name="amount">',
|
||||||
backgroundDismiss: true,
|
backgroundDismiss: true,
|
||||||
animation:'top',
|
animation:'top',
|
||||||
closeAnimation:'bottom',
|
closeAnimation:'bottom',
|
||||||
|
@ -1251,7 +1251,7 @@ $(document).ready(function() {
|
||||||
}
|
}
|
||||||
for (var i=0; i<data['articles'].length; i++) {
|
for (var i=0; i<data['articles'].length; i++) {
|
||||||
article = data['articles'][i];
|
article = data['articles'][i];
|
||||||
articles_container.find('[data-article='+article['id']+'] .stock')
|
articles_container.find('#data-article-'+article['id']+' .stock')
|
||||||
.text(article['stock']);
|
.text(article['stock']);
|
||||||
}
|
}
|
||||||
if (data['addcost']) {
|
if (data['addcost']) {
|
||||||
|
|
|
@ -41,5 +41,4 @@ def highlight_clipper(clipper, q):
|
||||||
@register.filter()
|
@register.filter()
|
||||||
def ukf(balance, is_cof):
|
def ukf(balance, is_cof):
|
||||||
grant = is_cof and (1 + Settings.SUBVENTION_COF() / 100) or 1
|
grant = is_cof and (1 + Settings.SUBVENTION_COF() / 100) or 1
|
||||||
# float nécessaire car sinon problème avec le round de future.builtins
|
return floor(balance * 10 * grant)
|
||||||
return floor(float(balance) * 10 * grant)
|
|
||||||
|
|
|
@ -1692,6 +1692,7 @@ def order_create(request, pk):
|
||||||
|
|
||||||
articles = (Article.objects
|
articles = (Article.objects
|
||||||
.filter(suppliers=supplier.pk)
|
.filter(suppliers=supplier.pk)
|
||||||
|
.distinct()
|
||||||
.select_related('category')
|
.select_related('category')
|
||||||
.order_by('category__name', 'name'))
|
.order_by('category__name', 'name'))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue