amélioration + correction calcul dates
This commit is contained in:
parent
a1bf1c485c
commit
3738ea0721
@ -6,23 +6,16 @@
|
||||
- date_fin
|
||||
résultat : nbjours
|
||||
*}}
|
||||
{{* pour simplifier : 30 jours par mois et 360 jours par an *}}
|
||||
|
||||
{{:assign jour_debut=$date_debut|date:"d"}}
|
||||
{{:assign jour_debut="min(%d, 30)"|math:$jour_debut}}
|
||||
{{:assign mois_debut=$date_debut|date:"m"}}
|
||||
{{: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}}
|
||||
{{:assign ts_debut=$date_debut|strtotime}}
|
||||
{{:assign ts_fin=$date_fin|strtotime}}
|
||||
{{:assign nbjours="1+(%d-%d)/(60*60*24)"|math:$ts_fin:$ts_debut}}
|
||||
|
||||
{{* au cas où les deux dates seraient inversées ... *}}
|
||||
{{if $nbjours < 0}}
|
||||
{{:assign nbjours="-1*%d"|math:$nbjours}}
|
||||
{{/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}}
|
||||
{{/load}}
|
||||
{{: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
|
||||
line.id as immo_id,
|
||||
@ -48,8 +48,8 @@
|
||||
where line.id = :line_id;
|
||||
:line_id = $_GET.immo_id|intval
|
||||
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}}
|
||||
{{:error message="Immobilisation %s non trouvée"|args:$_GET.immo_id}}
|
||||
{{/select}}
|
||||
@ -95,12 +95,15 @@
|
||||
{{* montant de l'annuité théorique *}}
|
||||
{{:assign montant="%f"|math:$ligne_immo.montant}}
|
||||
{{:assign annuite="%f/%f"|math:$montant:$duree}}
|
||||
|
||||
{{* 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"}}
|
||||
{{:assign annuite_1="%f/360*%d"|math:$annuite:$nbjours|intval}}
|
||||
|
||||
{{:assign annuite_courante=$annuite_1}}
|
||||
{{:assign current_year=$ligne_immo.year_id}}
|
||||
{{:assign solde=$ligne_immo.montant}}
|
||||
@ -112,7 +115,7 @@
|
||||
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>
|
||||
{{$ligne_immo.label}} »
|
||||
({{"%f"|math:$ligne_immo.montant|money_currency}}, {{$date_debut}})
|
||||
({{"%f"|math:$ligne_immo.montant|money_currency}}, {{$date_debut|date_short}})
|
||||
</h3>
|
||||
<table class="list">
|
||||
<thead>
|
||||
@ -154,11 +157,7 @@
|
||||
</td>
|
||||
</tr>
|
||||
{{:assign annuite_courante=$annuite}}
|
||||
{{:assign jour=$date_amort|date:"d"}}
|
||||
{{: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}}
|
||||
{{:include file="_next_year.html" date=$date_amort keep="date_amort"}}
|
||||
{{:assign nbamort="%d+1"|math:$nbamort}}
|
||||
{{/foreach}}
|
||||
</tbody>
|
||||
@ -196,7 +195,7 @@
|
||||
{{/select}}
|
||||
<tr>
|
||||
<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">{{if $solde == 0}}0,00{{else}}{{"%f"|math:$solde|money}}{{/if}}</td>
|
||||
<td>
|
||||
@ -216,11 +215,7 @@
|
||||
{{/if}}
|
||||
</td>
|
||||
</tr>
|
||||
{{:assign jour=$date_amort|date:"d"}}
|
||||
{{: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}}
|
||||
{{:include file="_next_year.html" date=$date_amort keep="date_amort"}}
|
||||
{{:assign annuite_courante="min(%f,%f)"|math:$annuite:$solde}}
|
||||
{{if $solde == 0}}{{:break}}{{/if}}
|
||||
{{/foreach}}
|
||||
|
Loading…
Reference in New Issue
Block a user