// return;
// }
- value = (montant_annuel.val());
- value = roundNumber(value, 2)
+ value = montant_annuel.val();
montant_annuel.val(roundNumber(value, 2));
{% load l10n %}
+{% load dae %}
{% for f in remunForm.management_form %}
{{ f }}
<th>Devise locale</th>
<th>Annuel<br/>(visé)</th>
<th>Annuel Euros<br/>(visé)</th>
+ {% if remunForm.read_only %}
<th>Annuel Euros<br/>(ajusté par période)</th>
+ {% endif %}
<th>Précision</th>
{% if not remunForm.read_only %}
<th>Supprimer</th>
{% for f in group.forms %}
<tr class="calculable remunform">
{{ f.id }}
- <td class="spaced">{{ f.type.errors }} {{ f.type }}</td>
+ <td class="spaced">{{ f.type.errors }} {{ f.type }}
+ {% if f.instance.date_debut or f.instance.date_fin %}
+ {% if f.instance.date_debut or f.instance.date_fin %}({% endif %}
+ {% if f.instance.date_debut %}{{f.instance.date_debut}}{% endif %}
+ -
+ {% if f.instance.date_fin %}{{f.instance.date_fin}}{% endif %}
+ {% if f.instance.date_debut or f.instance.date_fin %}){% endif %}
+ {% endif %}
+ </td>
<td>{{ f.devise.errors }} {{ f.devise }}</td>
<td class="monnaie cumulable">{{ f.montant.errors }} {{ f.montant }}</td>
<td class="euro cumulable" id="id_{{ f.prefix }}-montant_annuel_euros"></td>
- <td class="euro-ajuste cumulable" id="id_{{ f.prefix }}-montant_annuel_euros_ajuste">{{ f.instance.montant_ajuste_euros|stringformat:".2f" }}</td>
+ <!-- <td class="euro-ajuste cumulable" id="id_{{ f.prefix }}-montant_annuel_euros_ajuste">{{ f.instance.montant_ajuste_euros|stringformat:".2f" }}</td> -->
+ {% if remunForm.read_only %}
+ <td class="euro-ajuste cumulable" id="id_{{ f.prefix }}-montant_annuel_euros_ajuste">
+ {% remun_ajuste f.instance annee_remun %}
+ </td>
+ {% endif %}
<td>{{ f.commentaire.errors }} {{ f.commentaire }}</td>
{% if not remunForm.read_only %}
<td>{{ f.DELETE }}</td>
<td><!-- Laisser ce td pour que le javascript fonctionne bien. --></td>
<td class="sous-total"></td>
<td class="sous-total"></td>
+ {% if remunForm.read_only %}
<td class="sous-total"></td>
+ {% endif %}
<td> </td>
{% if not remunForm.read_only %}
<td> </td>
<th><!-- Laisser ce td pour que le javascript fonctionne bien. --></th>
<th class="total"></th>
<th class="total"></th>
+ {% if remunForm.read_only %}
<th class="total"></th>
+ {% endif %}
<th> </th>
{% if not remunForm.read_only %}
<th> </th>
<th><!-- Laisser ce td pour que le javascript fonctionne bien. --></th>
<th></th>
<th></th>
+ {% if remunForm.read_only %}
<th></th>
+ {% endif %}
<th> </th>
{% if not remunForm.read_only %}
<th> </th>
<td>{{ f.devise.errors }} {{ f.devise }}</td>
<td class="monnaie cumulable">{{ f.montant.errors }} {{ f.montant }}</td>
<td class="euro cumulable" id="id_{{ f.prefix }}-montant_annuel_euros"></td>
- <td class="euro-ajuste cumulable" id="id_{{ f.prefix }}-montant_annuel_euros_ajuste"> {{ f.instance.montant_ajuste_euros|stringformat:".2f" }}</td>
+ {% if remunForm.read_only %}
+ <td class="euro-ajuste cumulable" id="id_{{ f.prefix }}-montant_annuel_euros_ajuste">
+ {% remun_ajuste f.instance annee_remun %}
+ </td>
+ {% endif %}
<td>{{ f.commentaire.errors }} {{ f.commentaire }}</td>
{% if not remunForm.read_only %}
<td>{{ f.DELETE }}</td>
<td><!-- Laisser ce td pour que le javascript fonctionne bien. --></td>
<td class="sous-total"></td>
<td class="sous-total"></td>
+ {% if remunForm.read_only %}
<td class="sous-total"></td>
+ {% endif %}
<td> </td>
{% if not remunForm.read_only %}
<td> </td>
# -*- encoding: utf-8 -*-
import os
+import datetime
from django import template
+from django.db.models import Q
# -*- coding: utf-8 -*-
from project import groups
def remun_form(context, dossier):
return {
+ 'annee_remun': None,
'remunForm': ReadOnlyRemunFormSet(instance=dossier)
}
def rh_remun_form(context, dossier):
return {
+ 'annee_remun': None,
'remunForm': RHReadOnlyRemunFormSet(instance=dossier)
}
@register.inclusion_tag('dae/embauche-remun.html', takes_context=True)
def poste_cmp_remun_form(context, poste_cmp):
return {
+ 'annee_remun': None,
'remunForm': PosteCompReadOnlyRemunFormSet(instance=poste_cmp)
}
@register.inclusion_tag('dae/embauche-remun.html', takes_context=True)
def dossier_cmp_remun_form(context, dossier_cmp):
return {
+ 'annee_remun': None,
'remunForm': DossierCompReadOnlyRemunFormSet(instance=dossier_cmp)
}
)
def _get_qs(inst):
- return inst.model.objects.filter(
- dossier=inst.instance,
- date_debut__year=year,
- )
+ year_start = datetime.date(year, 1, 1)
+ year_end = datetime.date(year, 12, 31)
+ qs = inst.model.objects.filter(
+ Q(dossier=inst.instance) & (
+ Q(date_debut__lte=year_end, date_fin__gte=year_start) |
+ Q(date_debut__lte=year_end, date_fin__isnull=True) |
+ Q(date_debut__isnull=True, date_fin__gte=year_start) |
+ Q(date_debut__isnull=True, date_fin__isnull=True)
+ ))
+ return qs
fs.get_queryset = _get_qs
return {
+ 'annee_remun': year,
'remunForm': fs(instance=dossier)
}
+@register.simple_tag
+def remun_ajuste(remun, annee=None):
+ return '%.2f' % remun.montant_ajuste_euros(annee)
"""
objects = RemunerationManager()
+ @staticmethod
+ def find_yearly_range(from_date, to_date, year):
+ today = date.today()
+ year = year or date.today().year
+ year_start = date(year, 1, 1)
+ year_end = date(year, 12, 31)
+
+ def constrain_to_year(*dates):
+ """
+ S'assure que les dates soient dans le range year_start a
+ year_end
+ """
+ return [min(max(year_start, d), year_end)
+ for d in dates]
+
+ start_date = max(
+ from_date or year_start, year_start)
+ end_date = min(
+ to_date or year_end, year_end)
+
+ start_date, end_date = constrain_to_year(start_date, end_date)
+
+ jours_annee = (year_end - year_start).days
+ jours_dates = (end_date - start_date).days
+ factor = Decimal(str(jours_dates)) / Decimal(str(jours_annee))
+
+ return start_date, end_date, factor
+
+
def montant_ajuste_euros(self, annee=None):
"""
Le montant ajusté représente le montant annuel, ajusté sur la
période de temps travaillée, multipliée par le ratio de temps
travaillé (en rapport au temps plein).
"""
- if not annee:
- annee = min(
- self.date_debut or date.today(), date.today()).year
-
- debut_annee = date(annee, 1, 1)
- fin_annee = date(annee, 12, 31)
- jours_annee = (fin_annee - debut_annee).days + 1
-
- date_count_debut = max(
- self.date_debut or debut_annee, debut_annee)
- date_count_fin = min(self.date_fin or fin_annee, fin_annee)
- jours = (date_count_fin - date_count_debut).days + 1
- print "Date debut: ", date_count_debut
- print "Date fin: ", date_count_fin
- print "Jours: ", jours
-
- montant_euro = Decimal(str(self.montant_euros_float()))
+ date_debut, date_fin, factor = self.find_yearly_range(
+ self.date_debut,
+ self.date_fin,
+ annee,
+ )
+
+ montant_euros = Decimal(str(self.montant_euros_float()) or '0')
+
if self.type.nature_remuneration != u'Accessoire':
- return (montant_euro * ((
- min(self.date_fin or fin_annee, fin_annee) -
- max(self.date_debut or debut_annee, debut_annee)
- ).days + 1) / jours_annee * self.dossier.regime_travail / 100)
+ return (montant_euros * factor *
+ self.dossier.regime_travail / 100)
else:
- return montant_euro
-
-
+ return montant_euros
+
def montant_mois(self):
return round(self.montant / 12, 2)
)
NATURE_REMUNERATION_CHOICES = (
- (u'Accessoire', u'Accessoire'),
- (u'Charges', u'Charges patronales'),
+ (u'Traitement', u'Traitement'),
(u'Indemnité', u'Indemnité autre'),
+ (u'Charges', u'Charges patronales'),
+ (u'Accessoire', u'Accessoire'),
(u'RAS', u'Rémunération autre source'),
- (u'Traitement', u'Traitement'),
)
<script type="text/javascript">
var DEVISES = {};
{% for d in devises %}
- DEVISES['{{d.devise_code}}'] = {{d.taux_euro|stringformat:"f"}};
+ DEVISES['{{d.devise_code}}'] = {{d.taux_euro|stringformat:".10f"}};
{% endfor %}
</script>
<script src="{{ STATIC_URL }}js/dae.js" type="text/javascript"></script>
{% endfor %}
</table>
{% endif %}
-
-
data['taux_euro'] = taux[0].taux
data['devise_code'] = d.id
liste.append(data)
+
return liste