forked from DGNum/gestioCOF
Merge branch 'k-fet' of git.eleves.ens.fr:cof-geek/gestioCOF into Aufinal/visibilite_stock
This commit is contained in:
commit
43aab26530
4 changed files with 13 additions and 12 deletions
|
@ -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) {
|
||||||
|
|
|
@ -222,7 +222,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>';
|
||||||
|
@ -620,7 +620,7 @@ $(document).ready(function() {
|
||||||
if (-5 <= article['stock'] && article['stock'] <= 5) {
|
if (-5 <= article['stock'] && article['stock'] <= 5) {
|
||||||
article_html.addClass('low-stock');
|
article_html.addClass('low-stock');
|
||||||
}
|
}
|
||||||
article_html.find('.price').text(amountToUKF(article['price'], false)+' UKF');
|
article_html.find('.price').text(amountToUKF(article['price'], false, false)+' UKF');
|
||||||
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) {
|
||||||
|
@ -856,7 +856,7 @@ $(document).ready(function() {
|
||||||
.attr('data-opeindex', index)
|
.attr('data-opeindex', index)
|
||||||
.find('.number').text('('+nb+'/'+article_data[4]+')').end()
|
.find('.number').text('('+nb+'/'+article_data[4]+')').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);
|
||||||
if (is_low_stock(id, nb))
|
if (is_low_stock(id, nb))
|
||||||
article_basket_html.find('.lowstock')
|
article_basket_html.find('.lowstock')
|
||||||
|
@ -883,7 +883,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();
|
||||||
}
|
}
|
||||||
|
@ -896,7 +896,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();
|
||||||
}
|
}
|
||||||
|
@ -952,7 +952,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));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -971,9 +971,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)
|
||||||
|
|
|
@ -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)
|
|
||||||
|
|
|
@ -1687,6 +1687,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