Compare commits
3 Commits
f76c243b8c
...
3738ea0721
Author | SHA1 | Date | |
---|---|---|---|
3738ea0721 | |||
a1bf1c485c | |||
b1a78a3047 |
@ -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}}
|
@ -36,6 +36,9 @@
|
|||||||
{{:error message="Erreur : la date de mise en service (%s) ne peut être antérieure à la date d'acquisition (%s)"|args:$dd:$da}}
|
{{:error message="Erreur : la date de mise en service (%s) ne peut être antérieure à la date d'acquisition (%s)"|args:$dd:$da}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{:assign duration=$_POST.duree|intval}}
|
{{:assign duration=$_POST.duree|intval}}
|
||||||
|
{{if $duration <= 0}}
|
||||||
|
{{:error message="Erreur : la durée d'amortissement doit être strictement positive"}}
|
||||||
|
{{/if}}
|
||||||
{{:assign noamort=false}}
|
{{:assign noamort=false}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
@ -75,7 +78,7 @@
|
|||||||
<dl>
|
<dl>
|
||||||
{{:input id="no_amort" type="checkbox" value=1 name="no_amort" label="Ne pas amortir" default=$checked help="Cocher pour ne pas amortir" onclick="toggleInputs('infos_immo','f_no_amort_1')"}}
|
{{:input id="no_amort" type="checkbox" value=1 name="no_amort" label="Ne pas amortir" default=$checked help="Cocher pour ne pas amortir" onclick="toggleInputs('infos_immo','f_no_amort_1')"}}
|
||||||
{{:input type="date" name="date_mes" label="Date de mise en service" disabled=$disabled help="à renseigner uniquement si différente de la date d'acquisition"}}
|
{{:input type="date" name="date_mes" label="Date de mise en service" disabled=$disabled help="à renseigner uniquement si différente de la date d'acquisition"}}
|
||||||
{{:input type="number" name="duree" label="Durée d'amortissement" required=true min=0 default=1 disabled=$disabled}}
|
{{:input type="number" name="duree" label="Durée d'amortissement" required=true min=1 default=1 disabled=$disabled}}
|
||||||
</dl>
|
</dl>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
|
@ -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,
|
||||||
@ -49,7 +49,7 @@
|
|||||||
: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}}
|
||||||
|
@ -68,6 +68,19 @@
|
|||||||
{{if $amortissable == "non"}}
|
{{if $amortissable == "non"}}
|
||||||
{{:continue}}
|
{{:continue}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
{{* voir s'il existe des écritures d'amortissement associées *}}
|
||||||
|
{{#select
|
||||||
|
links.id_transaction,
|
||||||
|
links.id_related
|
||||||
|
FROM acc_transactions_links AS links
|
||||||
|
WHERE links.id_transaction = :trans_id OR links.id_related = :trans_id;
|
||||||
|
:trans_id=$trans_id
|
||||||
|
}}
|
||||||
|
{{:assign exist_amort=true}}
|
||||||
|
{{else}}
|
||||||
|
{{:assign exist_amort=false}}
|
||||||
|
{{/select}}
|
||||||
|
{{*:debug trans_id=$trans_id trans_label=$trans_label exist_amort=$exist_amort*}}
|
||||||
<tr>
|
<tr>
|
||||||
<td class="num"><a href={{$trans_url}}>#{{$trans_id}}</a></td>
|
<td class="num"><a href={{$trans_url}}>#{{$trans_id}}</a></td>
|
||||||
<td>{{$trans_date|date_short}}</td>
|
<td>{{$trans_date|date_short}}</td>
|
||||||
@ -86,6 +99,14 @@
|
|||||||
target="_dialog"
|
target="_dialog"
|
||||||
}}
|
}}
|
||||||
{{else}}
|
{{else}}
|
||||||
|
{{if ! $exist_amort}}
|
||||||
|
{{:linkbutton
|
||||||
|
label="Modifier infos"
|
||||||
|
href="modif_infos.html?immo_id=%s&amort=1"|args:$immo_id
|
||||||
|
shape="help"
|
||||||
|
target="_dialog"
|
||||||
|
}}
|
||||||
|
{{/if}}
|
||||||
{{:linkbutton
|
{{:linkbutton
|
||||||
label="Amortissements"
|
label="Amortissements"
|
||||||
href="amortization.html?immo_id=%s"|args:$immo_id
|
href="amortization.html?immo_id=%s"|args:$immo_id
|
||||||
|
@ -7,11 +7,15 @@
|
|||||||
{{:include file="_nav.html" current="index"}}
|
{{:include file="_nav.html" current="index"}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
|
{{* infos de l'immobilisation *}}
|
||||||
|
{{:assign var="immo_id" value=$_GET.immo_id|intval}}
|
||||||
|
{{#load type="immo" assign="info_immo" where="$$.line = :line_id" :line_id=$immo_id|intval}}
|
||||||
|
{{/load}}
|
||||||
|
|
||||||
{{* Traiter l'envoi du formulaire *}}
|
{{* Traiter l'envoi du formulaire *}}
|
||||||
{{#form on="change"}}
|
{{#form on="change"}}
|
||||||
|
|
||||||
{{* chercher la date d'acquisition de l'immobilisation *}}
|
{{* chercher la date d'acquisition de l'immobilisation *}}
|
||||||
{{:assign var="immo_id" value=$_GET.immo_id|intval}}
|
|
||||||
{{#select
|
{{#select
|
||||||
trans.date as date_achat
|
trans.date as date_achat
|
||||||
from acc_transactions_lines as line
|
from acc_transactions_lines as line
|
||||||
@ -36,16 +40,15 @@
|
|||||||
{{:error message="Erreur : la date de mise en service (%s) ne peut être antérieure à la date d'acquisition (%s)"|args:$dd:$da}}
|
{{:error message="Erreur : la date de mise en service (%s) ne peut être antérieure à la date d'acquisition (%s)"|args:$dd:$da}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{:assign duration=$_POST.duree|intval}}
|
{{:assign duration=$_POST.duree|intval}}
|
||||||
|
{{if $duration <= 0}}
|
||||||
|
{{:error message="Erreur : la durée d'amortissement doit être strictement positive"}}
|
||||||
|
{{/if}}
|
||||||
{{:assign noamort=false}}
|
{{:assign noamort=false}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{#load type="immo" where="$$.line = :line_id" :line_id=$immo_id|intval}}
|
|
||||||
{{:assign key=$key}}
|
|
||||||
{{/load}}
|
|
||||||
{{* enregistrer les infos modifiées de l'immobilisation *}}
|
{{* enregistrer les infos modifiées de l'immobilisation *}}
|
||||||
{{*:assign key=""|uuid*}}
|
|
||||||
{{:save
|
{{:save
|
||||||
key=$key
|
key=$info_immo.key
|
||||||
validate_schema="schema.json"
|
validate_schema="schema.json"
|
||||||
type="immo"
|
type="immo"
|
||||||
line=$immo_id
|
line=$immo_id
|
||||||
@ -64,7 +67,8 @@
|
|||||||
{{:form_errors}}
|
{{:form_errors}}
|
||||||
{{/form}}
|
{{/form}}
|
||||||
|
|
||||||
{{* renseigner la date de mise en service et durée d'amortissement *}}
|
{{* modifier la date de mise en service et durée d'amortissement *}}
|
||||||
|
|
||||||
{{if $_GET.amort == 0}}
|
{{if $_GET.amort == 0}}
|
||||||
{{:assign checked=1}}
|
{{:assign checked=1}}
|
||||||
{{:assign disabled=1}}
|
{{:assign disabled=1}}
|
||||||
@ -72,13 +76,14 @@
|
|||||||
{{:assign checked=0}}
|
{{:assign checked=0}}
|
||||||
{{:assign disabled=0}}
|
{{:assign disabled=0}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
<form method="post" action="">
|
<form method="post" action="">
|
||||||
<fieldset id="infos_immo">
|
<fieldset id="infos_immo">
|
||||||
<legend></legend>
|
<legend></legend>
|
||||||
<dl>
|
<dl>
|
||||||
{{:input id="no_amort" type="checkbox" value=1 name="no_amort" label="Ne pas amortir" default=$checked help="Cocher pour ne pas amortir" onclick="toggleInputs('infos_immo','f_no_amort_1')"}}
|
{{:input id="no_amort" type="checkbox" value=1 name="no_amort" label="Ne pas amortir" default=$checked help="Cocher pour ne pas amortir" onclick="toggleInputs('infos_immo','f_no_amort_1')"}}
|
||||||
{{:input type="date" name="date_mes" label="Date de mise en service" disabled=$disabled help="à renseigner uniquement si différente de la date d'acquisition"}}
|
{{:input type="date" name="date_mes" label="Date de mise en service" default=$info_immo.date disabled=$disabled help="à renseigner uniquement si différente de la date d'acquisition"}}
|
||||||
{{:input type="number" name="duree" label="Durée d'amortissement" required=true min=0 default=1 disabled=$disabled}}
|
{{:input type="number" name="duree" label="Durée d'amortissement" default=$info_immo.duration required=true min=1 disabled=$disabled}}
|
||||||
</dl>
|
</dl>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user