forked from DGNum/gestioCOF
K-Psul - Edition
- Via "F8", possible de faire des charges sans modifier la caisse si l'utilisateur a la permission `kfet.edit_balance_account`. Un commentaire est alors nécessaire sur la commande.
This commit is contained in:
parent
95fd6ed655
commit
3444426114
5 changed files with 44 additions and 10 deletions
18
kfet/migrations/0042_auto_20160831_0126.py
Normal file
18
kfet/migrations/0042_auto_20160831_0126.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('kfet', '0041_auto_20160830_1502'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterModelOptions(
|
||||
name='globalpermissions',
|
||||
options={'managed': False, 'permissions': (('is_team', 'Is part of the team'), ('perform_deposit', 'Effectuer une charge'), ('perform_negative_operations', 'Enregistrer des commandes en négatif'), ('override_frozen_protection', "Forcer le gel d'un compte"), ('cancel_old_operations', 'Annuler des commandes non récentes'), ('manage_perms', 'Gérer les permissions K-Fêt'), ('manage_addcosts', 'Gérer les majorations'), ('perform_commented_operations', 'Enregistrer des commandes avec commentaires'), ('view_negs', 'Voir la liste des négatifs'), ('order_to_inventory', "Générer un inventaire à partir d'une commande"), ('edit_balance_account', "Modifier la balance d'un compte"))},
|
||||
),
|
||||
]
|
|
@ -547,7 +547,8 @@ class GlobalPermissions(models.Model):
|
|||
('manage_addcosts', 'Gérer les majorations'),
|
||||
('perform_commented_operations', 'Enregistrer des commandes avec commentaires'),
|
||||
('view_negs', 'Voir la liste des négatifs'),
|
||||
('order_to_inventory', "Générer un inventaire à partir d'une commande")
|
||||
('order_to_inventory', "Générer un inventaire à partir d'une commande"),
|
||||
('edit_balance_account', "Modifier la balance d'un compte"),
|
||||
)
|
||||
|
||||
class Settings(models.Model):
|
||||
|
|
|
@ -34,6 +34,7 @@ function KHistory(options={}) {
|
|||
} else {
|
||||
infos1 = parsed_amount.toFixed(2)+'€';
|
||||
infos2 = (ope['type'] == 'deposit') ? 'Charge' : 'Retrait';
|
||||
infos2 = ope['is_checkout'] ? infos2 : 'Édition';
|
||||
}
|
||||
|
||||
$ope_html
|
||||
|
|
|
@ -543,8 +543,8 @@ $(document).ready(function() {
|
|||
var articleSelect = $('#article_autocomplete');
|
||||
var articleId = $('#article_id');
|
||||
var articleNb = $('#article_number');
|
||||
// 8:Backspace|9:Tab|13:Enter|46:DEL|112-117:F1-6|120-123:F9-F12
|
||||
var normalKeys = /^(8|9|13|46|112|113|114|115|116|117|120|121|122|123)$/;
|
||||
// 8:Backspace|9:Tab|13:Enter|46:DEL|112-117:F1-6|119-123:F8-F12
|
||||
var normalKeys = /^(8|9|13|46|112|113|114|115|116|117|119|120|121|122|123)$/;
|
||||
var articlesList = [];
|
||||
|
||||
function deleteNonMatching(array, str) {
|
||||
|
@ -694,14 +694,15 @@ $(document).ready(function() {
|
|||
updateBasketRel();
|
||||
}
|
||||
|
||||
function addDeposit(amount) {
|
||||
function addDeposit(amount, is_checkout=1) {
|
||||
var deposit_basket_html = $(item_basket_default_html);
|
||||
var amount = parseFloat(amount).toFixed(2);
|
||||
var index = addDepositToFormset(amount);
|
||||
var index = addDepositToFormset(amount, is_checkout);
|
||||
var text = is_checkout ? 'Charge' : 'Édition';
|
||||
deposit_basket_html
|
||||
.attr('data-opeindex', index)
|
||||
.find('.number').text(amount+"€").end()
|
||||
.find('.name').text('Charge').end()
|
||||
.find('.name').text(text).end()
|
||||
.find('.amount').text(amountToUKF(amount, account_data['is_cof']));
|
||||
basket_container.prepend(deposit_basket_html);
|
||||
updateBasketRel();
|
||||
|
@ -809,9 +810,10 @@ $(document).ready(function() {
|
|||
// Ask deposit or withdraw
|
||||
// -----
|
||||
|
||||
function askDeposit() {
|
||||
function askDeposit(is_checkout=1) {
|
||||
var title = is_checkout ? 'Montant de la charge' : "Montant de l'édition";
|
||||
$.confirm({
|
||||
title: 'Montant de la charge',
|
||||
title: title,
|
||||
content: '<input type="number" step="0.01" min="0.01" on autofocus placeholder="€">',
|
||||
backgroundDismiss: true,
|
||||
animation:'top',
|
||||
|
@ -821,7 +823,7 @@ $(document).ready(function() {
|
|||
var amount = this.$content.find('input').val();
|
||||
if (!$.isNumeric(amount) || amount <= 0)
|
||||
return false;
|
||||
addDeposit(amount);
|
||||
addDeposit(amount, is_checkout);
|
||||
},
|
||||
onOpen: function() {
|
||||
var that = this
|
||||
|
@ -1150,6 +1152,10 @@ $(document).ready(function() {
|
|||
articleSelect.focus();
|
||||
}
|
||||
return false;
|
||||
case 119:
|
||||
// F8 - Edition
|
||||
askDeposit(0);
|
||||
return false;
|
||||
case 120:
|
||||
// F9 - Addcost
|
||||
askAddcost();
|
||||
|
|
|
@ -800,6 +800,7 @@ def kpsul_perform_operations(request):
|
|||
to_articles_stocks = defaultdict(lambda:0) # For stocks articles
|
||||
is_addcost = (addcost_for and addcost_amount
|
||||
and addcost_for != operationgroup.on_acc)
|
||||
need_comment = operationgroup.on_acc.need_comment
|
||||
|
||||
# Filling data of each operations + operationgroup + calculating other stuffs
|
||||
for operation in operations:
|
||||
|
@ -811,7 +812,10 @@ def kpsul_perform_operations(request):
|
|||
operation.amount -= operation.addcost_amount
|
||||
to_addcost_for_balance += operation.addcost_amount
|
||||
if operationgroup.on_acc.is_cash:
|
||||
operation.is_checkout = True
|
||||
to_checkout_balance += -operation.amount
|
||||
else:
|
||||
operation.is_checkout = False
|
||||
if operationgroup.on_acc.is_cof:
|
||||
if is_addcost:
|
||||
operation.addcost_amount = operation.addcost_amount / cof_grant_divisor
|
||||
|
@ -824,6 +828,10 @@ def kpsul_perform_operations(request):
|
|||
operationgroup.amount += operation.amount
|
||||
if operation.type == Operation.DEPOSIT:
|
||||
required_perms.add('kfet.perform_deposit')
|
||||
if (not operation.is_checkout
|
||||
and operation.type in [Operation.DEPOSIT, Operation.WITHDRAW]):
|
||||
required_perms.add('kfet.edit_balance_account')
|
||||
need_comment = True
|
||||
if operationgroup.on_acc.is_cof:
|
||||
to_addcost_for_balance = to_addcost_for_balance / cof_grant_divisor
|
||||
|
||||
|
@ -831,7 +839,7 @@ def kpsul_perform_operations(request):
|
|||
amount = operationgroup.amount)
|
||||
required_perms |= perms
|
||||
|
||||
if operationgroup.on_acc.need_comment:
|
||||
if need_comment:
|
||||
operationgroup.comment = operationgroup.comment.strip()
|
||||
if not operationgroup.comment:
|
||||
data['errors']['need_comment'] = True
|
||||
|
|
Loading…
Reference in a new issue