amélioration + correction calcul dates
This commit is contained in:
parent
a1bf1c485c
commit
3738ea0721
@ -6,23 +6,16 @@
|
|||||||
- date_fin
|
- date_fin
|
||||||
résultat : nbjours
|
résultat : nbjours
|
||||||
*}}
|
*}}
|
||||||
{{* pour simplifier : 30 jours par mois et 360 jours par an *}}
|
|
||||||
|
|
||||||
{{:assign jour_debut=$date_debut|date:"d"}}
|
{{:assign ts_debut=$date_debut|strtotime}}
|
||||||
{{:assign jour_debut="min(%d, 30)"|math:$jour_debut}}
|
{{:assign ts_fin=$date_fin|strtotime}}
|
||||||
{{:assign mois_debut=$date_debut|date:"m"}}
|
{{:assign nbjours="1+(%d-%d)/(60*60*24)"|math:$ts_fin:$ts_debut}}
|
||||||
{{:assign annee_debut=$date_debut|date:"Y"}}
|
|
||||||
|
|
||||||
{{:assign jour_fin=$date_fin|date:"d"}}
|
|
||||||
{{:assign jour_fin="min(%d, 30)"|math:$jour_fin}}
|
|
||||||
{{:assign mois_fin=$date_fin|date:"m"}}
|
|
||||||
{{:assign annee_fin=$date_fin|date:"Y"}}
|
|
||||||
|
|
||||||
{{:assign nbjours="%d-%d"|math:$jour_fin:$jour_debut}}
|
|
||||||
{{:assign nbjours="%d+(%d-%d)*30"|math:$nbjours:$mois_fin:$mois_debut}}
|
|
||||||
{{:assign nbjours="%d+(%d-%d)*360"|math:$nbjours:$annee_fin:$annee_debut}}
|
|
||||||
|
|
||||||
{{* au cas où les deux dates seraient inversées ... *}}
|
{{* au cas où les deux dates seraient inversées ... *}}
|
||||||
{{if $nbjours < 0}}
|
{{if $nbjours < 0}}
|
||||||
{{:assign nbjours="-1*%d"|math:$nbjours}}
|
{{:assign nbjours="-1*%d"|math:$nbjours}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
{{* pour simplifier : 360 jours par an *}}
|
||||||
|
{{if $nbjours > 360}}
|
||||||
|
{{:assign nbjours=360}}
|
||||||
|
{{/if}}
|
||||||
|
13
_next_year.html
Normal file
13
_next_year.html
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{{* -*- brindille -*- *}}
|
||||||
|
{{*
|
||||||
|
Rend une date située un an après la date paramètre
|
||||||
|
paramètres :
|
||||||
|
- date
|
||||||
|
résultat : date_amort
|
||||||
|
*}}
|
||||||
|
|
||||||
|
{{:assign jour=$date|date:"d"}}
|
||||||
|
{{:assign mois=$date|date:"m"}}
|
||||||
|
{{:assign annee=$date|date:"Y"}}
|
||||||
|
{{:assign annee="%d+1"|math:$annee}}
|
||||||
|
{{:assign date_amort="%s/%s/%s"|args:$jour:$mois:$annee}}
|
@ -29,7 +29,7 @@
|
|||||||
{{:error message="Pas d'info concernant l'immobilisation %s"|args:$_GET.immo_id}}
|
{{:error message="Pas d'info concernant l'immobilisation %s"|args:$_GET.immo_id}}
|
||||||
{{/load}}
|
{{/load}}
|
||||||
{{:assign var="duree" from="info_immo.duration"|args:$_GET.immo_id}}
|
{{:assign var="duree" from="info_immo.duration"|args:$_GET.immo_id}}
|
||||||
{{:assign date_debut=$info_immo.date|date_short}}
|
{{:assign date_debut=$info_immo.date}}
|
||||||
|
|
||||||
{{#select
|
{{#select
|
||||||
line.id as immo_id,
|
line.id as immo_id,
|
||||||
@ -48,8 +48,8 @@
|
|||||||
where line.id = :line_id;
|
where line.id = :line_id;
|
||||||
:line_id = $_GET.immo_id|intval
|
:line_id = $_GET.immo_id|intval
|
||||||
assign=ligne_immo
|
assign=ligne_immo
|
||||||
}}
|
}}
|
||||||
<h2>Amortissement de « {{$label}} » d'un montant de {{"%f"|math:$montant|money_currency}} en date du {{$date_debut}} sur {{$duree}} ans</h2>
|
<h2>Amortissement de « {{$label}} » d'un montant de {{"%f"|math:$montant|money_currency}} en date du {{$date_debut|date_short}} sur {{$duree}} ans</h2>
|
||||||
{{else}}
|
{{else}}
|
||||||
{{:error message="Immobilisation %s non trouvée"|args:$_GET.immo_id}}
|
{{:error message="Immobilisation %s non trouvée"|args:$_GET.immo_id}}
|
||||||
{{/select}}
|
{{/select}}
|
||||||
@ -95,12 +95,15 @@
|
|||||||
{{* montant de l'annuité théorique *}}
|
{{* montant de l'annuité théorique *}}
|
||||||
{{:assign montant="%f"|math:$ligne_immo.montant}}
|
{{:assign montant="%f"|math:$ligne_immo.montant}}
|
||||||
{{:assign annuite="%f/%f"|math:$montant:$duree}}
|
{{:assign annuite="%f/%f"|math:$montant:$duree}}
|
||||||
|
|
||||||
{{* première annuité *}}
|
{{* première annuité *}}
|
||||||
{{:assign date_amort=$ligne_immo.date_amort|date_short}}
|
{{:assign date_amort=$ligne_immo.date_amort}}
|
||||||
|
{{if $date_amort|strtotime < $date_debut|strtotime}}
|
||||||
|
{{* changer d'exercice *}}
|
||||||
|
{{:include file="_next_year.html" date=$date_amort keep="date_amort"}}
|
||||||
|
{{:assign date_amort=$date_amort|parse_date}}
|
||||||
|
{{/if}}
|
||||||
{{:include file="_calcul_dates.html" date_debut=$date_debut date_fin=$date_amort keep="nbjours"}}
|
{{:include file="_calcul_dates.html" date_debut=$date_debut date_fin=$date_amort keep="nbjours"}}
|
||||||
{{:assign annuite_1="%f/360*%d"|math:$annuite:$nbjours|intval}}
|
{{:assign annuite_1="%f/360*%d"|math:$annuite:$nbjours|intval}}
|
||||||
|
|
||||||
{{:assign annuite_courante=$annuite_1}}
|
{{:assign annuite_courante=$annuite_1}}
|
||||||
{{:assign current_year=$ligne_immo.year_id}}
|
{{:assign current_year=$ligne_immo.year_id}}
|
||||||
{{:assign solde=$ligne_immo.montant}}
|
{{:assign solde=$ligne_immo.montant}}
|
||||||
@ -112,7 +115,7 @@
|
|||||||
Amortissements attachés à « <a class="num"
|
Amortissements attachés à « <a class="num"
|
||||||
href={{"%s/acc/transactions/details.php?id=%s"|args:$admin_url:$ligne_immo.trans_id}}>{{$ligne_immo.trans_id}}</a>
|
href={{"%s/acc/transactions/details.php?id=%s"|args:$admin_url:$ligne_immo.trans_id}}>{{$ligne_immo.trans_id}}</a>
|
||||||
{{$ligne_immo.label}} »
|
{{$ligne_immo.label}} »
|
||||||
({{"%f"|math:$ligne_immo.montant|money_currency}}, {{$date_debut}})
|
({{"%f"|math:$ligne_immo.montant|money_currency}}, {{$date_debut|date_short}})
|
||||||
</h3>
|
</h3>
|
||||||
<table class="list">
|
<table class="list">
|
||||||
<thead>
|
<thead>
|
||||||
@ -154,11 +157,7 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{:assign annuite_courante=$annuite}}
|
{{:assign annuite_courante=$annuite}}
|
||||||
{{:assign jour=$date_amort|date:"d"}}
|
{{:include file="_next_year.html" date=$date_amort keep="date_amort"}}
|
||||||
{{:assign mois=$date_amort|date:"m"}}
|
|
||||||
{{:assign annee=$date_amort|date:"Y"}}
|
|
||||||
{{:assign annee="%d+1"|math:$annee}}
|
|
||||||
{{:assign date_amort="%s/%s/%s"|args:$jour:$mois:$annee|parse_date|date_short}}
|
|
||||||
{{:assign nbamort="%d+1"|math:$nbamort}}
|
{{:assign nbamort="%d+1"|math:$nbamort}}
|
||||||
{{/foreach}}
|
{{/foreach}}
|
||||||
</tbody>
|
</tbody>
|
||||||
@ -196,7 +195,7 @@
|
|||||||
{{/select}}
|
{{/select}}
|
||||||
<tr>
|
<tr>
|
||||||
<td class="num">{{"%d+1"|math:$num}}</td>
|
<td class="num">{{"%d+1"|math:$num}}</td>
|
||||||
<td>{{$date_amort}}</td>
|
<td>{{$date_amort|date_short}}</td>
|
||||||
<td class="money">{{"%f"|math:$annuite_courante|money}}</td>
|
<td class="money">{{"%f"|math:$annuite_courante|money}}</td>
|
||||||
<td class="money">{{if $solde == 0}}0,00{{else}}{{"%f"|math:$solde|money}}{{/if}}</td>
|
<td class="money">{{if $solde == 0}}0,00{{else}}{{"%f"|math:$solde|money}}{{/if}}</td>
|
||||||
<td>
|
<td>
|
||||||
@ -216,11 +215,7 @@
|
|||||||
{{/if}}
|
{{/if}}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{:assign jour=$date_amort|date:"d"}}
|
{{:include file="_next_year.html" date=$date_amort keep="date_amort"}}
|
||||||
{{:assign mois=$date_amort|date:"m"}}
|
|
||||||
{{:assign annee=$date_amort|date:"Y"}}
|
|
||||||
{{:assign annee="%d+1"|math:$annee}}
|
|
||||||
{{:assign date_amort="%s/%s/%s"|args:$jour:$mois:$annee|parse_date|date_short}}
|
|
||||||
{{:assign annuite_courante="min(%f,%f)"|math:$annuite:$solde}}
|
{{:assign annuite_courante="min(%f,%f)"|math:$annuite:$solde}}
|
||||||
{{if $solde == 0}}{{:break}}{{/if}}
|
{{if $solde == 0}}{{:break}}{{/if}}
|
||||||
{{/foreach}}
|
{{/foreach}}
|
||||||
|
Loading…
Reference in New Issue
Block a user