Recalculer le montant de l'amortissement en fonction de l'exercice et de la date
This commit is contained in:
parent
515eb443fa
commit
99aa29a4a1
2 changed files with 117 additions and 19 deletions
|
|
@ -72,6 +72,7 @@
|
|||
|
||||
{{if $amort_line.amort_amount == null}}
|
||||
{{* 1er amortissement *}}
|
||||
{{:assign premier_amort=true}}
|
||||
{{* déterminer le compte d'amortissement en fonction du compte d'immobilisation *}}
|
||||
{{#select code, label from acc_accounts where id = :id; :id=$ligne_immo.account_id assign=amort_account}}
|
||||
{{/select}}
|
||||
|
|
@ -84,6 +85,7 @@
|
|||
{{:assign var=libelle value="Amortissement %s"|args:$ligne_immo.label}}
|
||||
{{else}}
|
||||
{{* amortissements suivants *}}
|
||||
{{:assign premier_amort=false}}
|
||||
{{:assign date_debut=$amort_line.amort_date|strtotime}}
|
||||
{{:assign date_debut="%d+(60*60*24)"|math:$date_debut|date:"Y-m-d"}}
|
||||
{{:assign var=code_amort value=$amort_line.account_code}}
|
||||
|
|
@ -92,17 +94,21 @@
|
|||
{{/if}}
|
||||
|
||||
{{*
|
||||
lister les exercices dont la date de fin est postérieure à la date
|
||||
de mise en service de l'immo ou à la date du dernier amortissement
|
||||
lister les exercices qui englobent la date de mise en service de l'immo
|
||||
ou la date du dernier amortissement
|
||||
*}}
|
||||
{{:assign msg_years=""}}
|
||||
{{#years closed=false order="start_date" where="end_date > :debut" :debut=$date_debut assign=years.}}
|
||||
{{:assign ts_debut=$start_date|strtotime}}
|
||||
{{#years closed=false order="start_date" where="start_date <= :debut AND :debut <= end_date" :debut=$date_debut assign=years.}}
|
||||
{{if $premier_amort}}
|
||||
{{:assign ts_debut=$date_debut|strtotime}}
|
||||
{{else}}
|
||||
{{:assign ts_debut=$start_date|strtotime}}
|
||||
{{/if}}
|
||||
{{:assign ts_fin=$end_date|strtotime}}
|
||||
{{:assign var="years_data.%d"|args:$id value=$ts_debut|cat:" "|cat:$ts_fin}}
|
||||
{{:assign debut=$start_date|date_short}}
|
||||
{{:assign fin=$end_date|date_short}}
|
||||
{{:assign var="open_years.%d"|args:$id value=$label|cat:" (du "|cat:$debut|cat:" au "|cat:$fin|cat:")"}}
|
||||
{{:assign var="years_data.%d"|args:$id value=$ts_debut|cat:" "|cat:$ts_fin}}
|
||||
{{:assign msg_years=$msg_years|cat:"\n"|cat:" - "|cat:$label|cat:" : "|cat:$debut|cat:" à "|cat:$fin}}
|
||||
{{else}}
|
||||
{{:error message="Aucun exercice ouvert pour enregistrer un amortissement"}}
|
||||
|
|
@ -229,8 +235,8 @@
|
|||
|
||||
{{* -------------------------------------------------------------------------------- *}}
|
||||
|
||||
<div id="erreur" class="hidden">
|
||||
<p class="block error">La date choisie n'est dans aucun exercice ouvert</p>
|
||||
<div id="f_erreur" class="hidden">
|
||||
<p class="block error">La date saisie n'est pas dans l'exercice choisi</p>
|
||||
</div>
|
||||
|
||||
<form method="post" action="">
|
||||
|
|
@ -258,6 +264,9 @@
|
|||
default=$credit_account
|
||||
}}
|
||||
<div id="donnees" class="hidden">
|
||||
{{:input type="text" name="montant_immo" default=$ligne_immo.montant}}
|
||||
{{:input type="text" name="duree_amort" default=$duree}}
|
||||
{{:input type="text" name="somme_amort" default=$amort_line.amort_amount}}
|
||||
{{:input type="select" name="years_data" options=$years_data}}
|
||||
</div>
|
||||
</dl>
|
||||
|
|
@ -272,13 +281,39 @@
|
|||
<script type="text/javascript" src="scripts.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
// afficher la date de fin de l'exercice choisi
|
||||
function setDate(evt, id_exercices = 'f_id_year', id_date = 'f_date_amort', id_years = 'f_years_data') {
|
||||
// afficher la date de fin de l'exercice choisi et recalculer le montant de l'amortissement
|
||||
function redisplayData(evt,
|
||||
id_immo = 'f_montant_immo',
|
||||
id_duree = 'f_duree_amort',
|
||||
id_amort = 'f_somme_amort',
|
||||
id_years = 'f_years_data',
|
||||
id_exercices = 'f_id_year',
|
||||
id_date = 'f_date_amort',
|
||||
id_montant = 'f_montant',
|
||||
id_erreur = 'f_erreur'
|
||||
)
|
||||
{
|
||||
setDateEnd(id_exercices, id_date, id_years);
|
||||
displayAmort(id_immo, id_duree, id_amort, id_years, id_exercices, id_montant, id_erreur);
|
||||
}
|
||||
|
||||
function redisplayAmort(evt,
|
||||
id_immo = 'f_montant_immo',
|
||||
id_duree = 'f_duree_amort',
|
||||
id_amort = 'f_somme_amort',
|
||||
id_years = 'f_years_data',
|
||||
id_exercices = 'f_id_year',
|
||||
id_date = 'f_date_amort',
|
||||
id_montant = 'f_montant',
|
||||
id_erreur = 'f_erreur'
|
||||
)
|
||||
{
|
||||
displayAmort(id_immo, id_duree, id_amort, id_years, id_exercices, id_montant, id_erreur, id_date);
|
||||
}
|
||||
|
||||
(function () {
|
||||
setDateEnd('f_id_year', 'f_date_amort', 'f_years_data');
|
||||
document.getElementById('f_id_year').onchange = setDate;
|
||||
document.getElementById('f_id_year').onchange = redisplayData;
|
||||
document.getElementById('f_date_amort').onchange = redisplayAmort;
|
||||
})();
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue