diff --git a/balance_sheet_exit.html b/balance_sheet_exit.html index ad1a00a..b557a8e 100644 --- a/balance_sheet_exit.html +++ b/balance_sheet_exit.html @@ -67,19 +67,22 @@ {{:assign valeur_nette="%f-%f"|math:$ligne_immo.montant:$amort_amount}} {{* - lister les exercices qui englobent la date de début du prochain amortissement +lister les exercices ouverts : + - dont la date de fin est postérieure à la date du dernier amortissment + - dont la date de début est antérieure ou égale à la date du jour *}} {{:assign default_exit_date=""}} -{{#years closed=false order="start_date" where="start_date <= :debut AND :debut <= end_date" - :debut=$date_debut assign=years.}} +{{#years closed=false order="start_date" where=":debut <= end_date" :debut=$date_debut}} {{if $start_date|strtotime <= $now && $now <= $end_date|strtotime}} {{:assign default_exit_date=$now|date_short}} {{/if}} - {{:assign ts_fin=$end_date|strtotime}} + {{if $start_date|strtotime > $now}} + {{:break}} + {{/if}} + {{:assign var="years." id=$id label=$label start_date=$start_date end_date=$end_date}} {{: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}} {{else}} {{:error message="Aucun exercice ouvert pour enregistrer un amortissement"}} {{/years}} @@ -141,6 +144,7 @@ {{* vérifier que la date de sortie est située dans un exercice ouvert *}} {{:assign ts_exit = $_POST.date_sortie|parse_date|strtotime}} {{:assign ok=false}} + {{:assign msg_amort=""}} {{#foreach from=$years}} {{if $id == $_POST.id_year}} {{:assign selected_year=$id}} @@ -149,16 +153,24 @@ {{:break}} {{/if}} {{/if}} + {{* voir si des amortissements ont été oubliés *}} + {{if $start_date|strtotime > $amort_line.last_amort_date|strtotime && $end_date|strtotime < $now}} + {{:assign debut=$start_date|date_short}} + {{:assign fin=$end_date|date_short}} + {{:assign msg_amort=$msg_amort|cat:"\n"|cat:" - "|cat:$label|cat:" : du "|cat:$debut|cat:" au "|cat:$fin}} + {{/if}} {{/foreach}} {{if ! $ok}} {{:error message="La date choisie n'est pas dans l'exercice sélectionné !"}} {{/if}} + {{if $msg_amort != ""}} + {{:error message="Vous devez d'abord enregistrer les amortissements des exercices suivants : %s"|args:$msg_amort}} + {{/if}} {{:redirect to="compute_exit_data.html?immo_id=%s&amort_amount=%s&year=%s&date_mes=%s&date_debut=%s&exit_date=%s&duree_amort=%s"|args:$_GET.immo_id:$amort_amount:$selected_year:$ts_mes:$ts_debut:$ts_exit:$duree_amort}} {{/form}} {{:admin_header title="Sortie de bilan" custom_css="./style.css" current="module_amortissement"}} - {{* barre de navigation *}} {{if ! $dialog}} {{:include file="_nav.html" current="index" subcurrent="%s"|args:$_GET.type_immo subsubcurrent="balance_exit"}}