django-reversion = 1.3.3
auf.django.workflow = 0.10dev
django-ajax-selects = 1.1.4
-reportlab = 2.1
+reportlab = 2.5
html5lib = 0.90
pyPDF = 1.13
pisa = 3.0.33
class Model:
model = dae.DossierComparaison
-
class DossierComparaisonForm(inlineformset_factory(dae.Dossier, dae.DossierComparaison, extra=3, max_num=3, form=DossierComparaisonForm)):
pass
+class FlexibleRemunForm(forms.ModelForm):
+
+ montant_mensuel = forms.DecimalField(required=False)
+ montant = forms.DecimalField(required=True, label='Montant annuel')
+
+ class Meta:
+ model = dae.Remuneration
+
+class RemunForm(inlineformset_factory(dae.Dossier, dae.Remuneration, extra=5, form=FlexibleRemunForm)):
+ pass
+
class JustificationNouvelEmployeForm(inlineformset_factory(dae.Dossier,
dae.JustificationNouvelEmploye,
extra=0,
+{% for f in remunForm.management_form %}
+ {{ f }}
+{% endfor %}
+
+<table id="global-cost">
<tr>
<th>Type</th>
<th>Devise locale</th>
<th>Mensuel</th>
<th>Annuel</th>
- <th colspan="2">Conversion en Euros</th>
+ <th>Mensuel Euros</th>
+ <th>Annuel Euros</th>
<th>Précision</th>
+ <th>Supprimer</th>
</tr>
+{% for f in remunForm.forms %}
+<tr>
+ {{ f.id }}
+ <td>{{ f.type.errors }} {{ f.type }}</td>
+ <td>{{ f.devise.errors }} {{ f.devise }}</td>
+ <td>{{ f.montant_mensuel.errors }} {{ f.montant_mensuel }}</td>
+ <td>{{ f.montant.errors }} {{ f.montant }}</td>
+ <td id="id_{{ f.prefix }}-montant_mensuel_euros"></td>
+ <td id="id_{{ f.prefix }}-montant_annuel_euros"></td>
+ <td>{{ f.precision.errors }} {{ f.precision }}</td>
+ <td>{{ f.DELETE }}</td>
+</tr>
+{% endfor %}
+</table>
+{% comment %}
+<table>
+<tr>
+ <th>Type</th>
+ <th>Devise locale</th>
+ <th>Mensuel</th>
+ <th>Annuel</th>
+ <th colspan="2">Conversion en Euros</th>
+ <th>Précision</th>
+</tr>
<tr>
<th colspan="5">Coûts AUF</th>
<th id="sous-total-cout" class="montant"></th>
<th id="remun-total" class="montant"></th>
<th>EUR</th>
</tr>
+{% endcomment %}
<script src="{{ MEDIA_URL }}js/jquery-1.5.1.min.js"
type="text/javascript"></script>
+ <script type="text/javascript">
+ var DEVISES = {};
+ {% for d in devises %}
+ DEVISES['{{d.devise_code}}'] = {{d.taux_euro}};
+ {% endfor %}
+ </script>
+
{% comment %} style pour le calendier {% endcomment %}
<script type="text/javascript">
window.__admin_media_prefix__ = "{% filter escapejs %}{% admin_media_prefix %}{% endfilter %}";
<fieldset>
- {% if dossier.id == None %}
- <p>
- Vous devez enregister ce dossier avant de pouvoir détailler le
- coût global.
- </p>
- {% else %}
- <table cellspacing="0" id="global-cost">
- {% include 'dae/embauche-remun.html' %}
- </table>
-
- <select id="type-remun" name="type-remun">
- <option value="">(Ajouter une ligne)</option>
- {% for tr in type_remun %}
- <option value="{{ tr.id }}">{{ tr.nom }}</option>
- {% endfor %}
- </select>
- {% endif %}
+ <table cellspacing="0" id="global-cost">
+ {% include 'dae/embauche-remun.html' %}
+ </table>
+
+ {% comment %}
+ <select id="type-remun" name="type-remun">
+ <option value="">(Ajouter une ligne)</option>
+ {% for tr in type_remun %}
+ <option value="{{ tr.id }}">{{ tr.nom }}</option>
+ {% endfor %}
+ </select>
+ {% endcomment %}
</fieldset>
url(r'^liste_valeurs_point$', 'liste_valeurs_point', name='liste_valeurs_point'),
url(r'^liste_postes$', 'liste_postes', name='liste_postes'),
url(r'^devise$', 'devise', name='dae_devise'),
+ url(r'^devises$', 'devises', name='devises'),
url(r'^devise/code$', 'devise_code', name='dae_devise_code'),
url(r'^add-remun$', 'add_remun', name='add_remun'),
url(r'^add-remun/(?P<dossier>.*)/(?P<type_remun>.*)$', 'add_remun',
pisa.showLogging()
+def devises():
+ liste = []
+ for d in rh.Devise.objects.all():
+ annee = date.today().year
+ taux = rh.TauxChange.objects.filter(annee=annee, devise=d)
+ data = {}
+ if len(taux) == 0:
+ data['taux_euro'] = 0
+ else:
+ data['taux_euro'] = taux[0].taux
+ data['devise_code'] = d.code
+ liste.append(data)
+ return liste
+
def reponse_pdf(template_src, context_dict):
"""
Générer une réponse HTTP avec un PDF
return render_to_response('dae/postes_liste.html', vars, RequestContext(request))
def filtered_type_remun():
- # Exclusion de "Indemnité de fonction" des types de rémun utilisés
- return rh.TypeRemuneration.objects.exclude(pk=7)
+ defaut = (2, 3, 8, 17) # salaire de base, indemnité de fonction, charges patronales
+ return rh.TypeRemuneration.objects.filter(pk__in=defaut)
@dae_groupe_requis
@dossier_dans_ma_region_ou_service
justificationsNouveauForm = JustificationNouvelEmployeForm(request.POST, instance=dossier)
justificationsAutreForm = JustificationAutreEmployeForm(request.POST, instance=dossier)
dossiersComparaisonsForm = DossierComparaisonForm(request.POST, instance=dossier)
+ remunForm = RemunForm(request.POST, instance=dossier)
+ print remunForm.errors
+ if dossier_form.is_valid() and \
+ piecesForm.is_valid() and \
+ justificationsNouveauForm.is_valid() and \
+ justificationsAutreForm.is_valid() and \
+ dossiersComparaisonsForm.is_valid() and \
+ remunForm.is_valid():
- if dossier_form.is_valid() and piecesForm.is_valid() and justificationsNouveauForm.is_valid() and justificationsAutreForm.is_valid() and dossiersComparaisonsForm.is_valid():
dossier = dossier_form.save()
piecesForm.instance = dossier
piecesForm.save()
justificationsAutreForm.save()
dossiersComparaisonsForm.instance = dossier
dossiersComparaisonsForm.save()
-
- if not dossier.remuneration_set.all():
- # Pré-peuplement des entrées de la section "coût
- # global", à l'exclusion de "Indemnité de fonction"
- for type in type_remun.all():
- dae.Remuneration(dossier=dossier, type=type,
- devise=dossier.devise).save()
-
- else:
- # Sauvegarde du coût global
- cg_lines = defaultdict(dict)
- for k, v in request.POST.items():
- if k.startswith('cg-'):
- prefix, field_name, cg_id = k.split('-')
- cg_lines[int(cg_id)][unicode(field_name)] = v
-
- for r in dossier.remuneration_set.all():
- print 'trying %r' % r
- if r.id in cg_lines:
- if cg_lines[r.id]['montant'] == '':
- r.delete()
- else:
- for k, v in cg_lines[r.id].items():
- setattr(r, k, v)
- r.save()
+ remunForm.instance = dossier
+ remunForm.save()
+
+ #if not dossier.remuneration_set.all():
+ # # Pré-peuplement des entrées de la section "coût
+ # # global", à l'exclusion de "Indemnité de fonction"
+ # for type in type_remun.all():
+ # dae.Remuneration(dossier=dossier, type=type,
+ # devise=dossier.devise).save()
+
+ #else:
+ # # Sauvegarde du coût global
+ # cg_lines = defaultdict(dict)
+ # for k, v in request.POST.items():
+ # if k.startswith('cg-'):
+ # prefix, field_name, cg_id = k.split('-')
+ # cg_lines[int(cg_id)][unicode(field_name)] = v
+
+ # for r in dossier.remuneration_set.all():
+ # print 'trying %r' % r
+ # if r.id in cg_lines:
+ # if cg_lines[r.id]['montant'] == '':
+ # r.delete()
+ # else:
+ # for k, v in cg_lines[r.id].items():
+ # setattr(r, k, v)
+ # r.save()
messages.add_message(request, messages.SUCCESS, "Le dossier %s a été sauvegardé." % dossier)
if request.POST.has_key('save'):
justificationsNouveauForm = JustificationNouvelEmployeForm(instance=dossier)
justificationsAutreForm = JustificationAutreEmployeForm(instance=dossier)
dossiersComparaisonsForm = DossierComparaisonForm(instance=dossier)
+ remunForm = RemunForm(instance=dossier)
else:
# Initialisation d'un formulaire vide
dossier_rh = rh.Dossier()
justificationsNouveauForm = JustificationNouvelEmployeForm(instance=dossier)
justificationsAutreForm = JustificationAutreEmployeForm(instance=dossier)
dossiersComparaisonsForm = DossierComparaisonForm(instance=dossier)
+ remunForm = RemunForm(instance=dossier)
vars = dict(step='employe',
type_remun=type_remun,
+ devises=devises(),
poste=poste,
dossier=dossier,
piecesForm=piecesForm,
+ remunForm=remunForm,
justificationsNouveauForm=justificationsNouveauForm,
justificationsAutreForm=justificationsAutreForm,
dossiersComparaisonsForm=dossiersComparaisonsForm,
}
function remun_line(input) {
- var idParts = input.attr('id').split('-'),
- name = idParts[0],
- id = idParts[1];
-
- var montant_mensuel = $('#montant_mois-' + id);
- var montant_annuel = $('#montant-' + id);
+ var idParts = input.attr('id').split('-');
+ var prefix = idParts[0] + "-" + idParts[1];
+ var field = idParts[2];
+
+ var montant_mensuel = $('#' + prefix + '-montant_mensuel');
+ var montant_annuel = $('#' + prefix + '-montant');
+ var montant_mensuel_euros = $('#' + prefix + '-montant_mensuel_euros');
+ var montant_annuel_euros = $('#' + prefix + '-montant_annuel_euros');
+
+ /* auto calcul a besoin d'un type (autrement ca devient un champs requis)*/
+ if ($('#' + prefix + '-type').val() == '') {
+ montant_mensuel.val('');
+ montant_annuel.val('');
+ montant_mensuel_euros.val('');
+ montant_annuel_euros.val('');
+ return;
+ }
+
+ if (input.attr('id') == montant_mensuel.attr('id') && montant_mensuel.val() != 0) {
+ value = (montant_mensuel.val() * 12);
+ }
+ else {
+ value = (montant_annuel.val());
+ }
+
+ montant_mensuel.val(value / 12);
+ montant_annuel.val(value);
+
+ var devise = $('#' + prefix + '-devise').val();
+ var taux = parseFloat(DEVISES[devise]);
+ if (isNaN(taux)) taux = 0;
+ montant_mensuel_euros.text(value / 12 * taux)
+ montant_annuel_euros.text(value * taux)
- if (input.attr('id') == montant_mensuel.attr('id')) value = (montant_mensuel.val() * 12);
- if (input.attr('id') == montant_annuel.attr('id')) value = (montant_annuel.val());
-
- montant_mensuel.val(round2(value / 12));
- montant_annuel.val(round2(value));
-
- var taux = $('#taux_devise-' + id).val();
- $('#montant_euro_mois-' + id).text(clean_float(round2(value / 12 * taux)));
- $('#montant_euro-' + id).text(clean_float(round2(value * taux)));
}
function remun_totaux() {
- $('#global-cost input[id^="montant"]').each(function() {
+ $('#global-cost input[type="text"]').each(function() {
remun_line($(this));
});
contrat_mois();
/* totaux remu */
- $('#global-cost input').change(function() {
+ $('#global-cost input, #global-cost select').change(function() {
remun_line($(this));
remun_totaux();
});
/* Ajouter une ligne aux couts globals */
- $('#type-remun').change(function() {
+ /*$('#type-remun').change(function() {
var dossier_id = $('#dossier').attr('dossier');
if ($(this).val() != '') {
$('#global-cost').html('<tr><td>Chargement...</td></tr>')
});
}
});
+ */
remun_totaux();
/* Traitement de la recherche AJAX pour les dossiers de comparaison */