Classification manuelle des immobilisations
This commit is contained in:
parent
79e536a0b3
commit
ec94358f47
7 changed files with 81 additions and 60 deletions
|
@ -58,18 +58,16 @@
|
|||
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$trans_id}}
|
||||
{{:assign compte_url="%s/acc/accounts/journal.php?id=%s&year=%s"|args:$admin_url:$account_id:$trans_id_year}}
|
||||
{{:assign duration=null}}
|
||||
|
||||
{{* voir si l'immo est prise en charge *}}
|
||||
{{#load type="immo" where="$$.line = :line_id" :line_id=$immo_id|intval}}
|
||||
{{:assign duration=$duration}}
|
||||
{{if $status == "ignored"}}
|
||||
{{:assign amortissable="non"}}
|
||||
{{else}}
|
||||
{{:assign amortissable="oui"}}
|
||||
{{/if}}
|
||||
{{:assign status=$status}}
|
||||
{{else}}
|
||||
{{:assign amortissable="nsp"}}
|
||||
{{:assign status="unknown"}}
|
||||
{{/load}}
|
||||
{{if $amortissable == "non"}}
|
||||
{{if $status == "ignored"}}
|
||||
{{:continue}}
|
||||
{{/if}}
|
||||
|
||||
|
@ -93,8 +91,9 @@
|
|||
:line_id = $immo_id|intval
|
||||
}}
|
||||
{{:assign ignore=true}}
|
||||
{{:assign status="archived"}}
|
||||
{{/select}}
|
||||
{{if $ignore}}
|
||||
{{if $status == "archived"}}
|
||||
{{:continue}}
|
||||
{{/if}}
|
||||
|
||||
|
@ -132,13 +131,12 @@
|
|||
{{/if}}
|
||||
{{/select}}
|
||||
|
||||
|
||||
{{* classement par onglet *}}
|
||||
{{if $type_immo == "encours" && $amort_amount >= $debit ||
|
||||
$type_immo == "amortie" && $amort_amount < $debit ||
|
||||
$amortissable == "nsp" && ! $exist_amort
|
||||
}}
|
||||
{{:continue}}
|
||||
{{/if}}
|
||||
{{if $type_immo == "encours" && $amort_amount >= $debit}}{{:continue}}{{/if}}
|
||||
{{if $type_immo == "encours" && $status == "amortized"}}{{:continue}}{{/if}}
|
||||
{{if $status == "unknown" && ! $exist_amort}}{{:continue}}{{/if}}
|
||||
{{if $type_immo == "amortie" && $amort_amount < $debit && $status != "amortized"}}{{:continue}}{{/if}}
|
||||
{{:assign nb_immo="%d+1"|math:$nb_immo}}
|
||||
<tr>
|
||||
<td class="num"><a href={{$trans_url}}>#{{$trans_id}}</a></td>
|
||||
|
@ -156,7 +154,7 @@
|
|||
shape="settings"
|
||||
target="_dialog"
|
||||
}}
|
||||
{{elseif $amortissable == "nsp"}}
|
||||
{{elseif $status == "unknown"}}
|
||||
{{:linkbutton
|
||||
label="Paramètres"
|
||||
href="add_infos.html?immo_id=%s&amort=1&op=new&type_immo=%s"|args:$immo_id:$type_immo
|
||||
|
|
|
@ -52,13 +52,14 @@
|
|||
}}
|
||||
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$trans_id}}
|
||||
{{:assign compte_url="%s/acc/accounts/journal.php?id=%s&year=%s"|args:$admin_url:$account_id:$trans_id_year}}
|
||||
|
||||
{{* voir si l'immo est prise en charge *}}
|
||||
{{#load type="immo" where="$$.line = :line_id" :line_id=$immo_id|intval}}
|
||||
{{:assign status=$status}}
|
||||
{{else}}
|
||||
{{:assign status="nsp"}}
|
||||
{{:assign status="unknown"}}
|
||||
{{/load}}
|
||||
{{if $status != "ignored" && $status != "nsp"}}
|
||||
{{if $status != "unknown"}}
|
||||
{{:continue}}
|
||||
{{/if}}
|
||||
|
||||
|
@ -87,7 +88,7 @@
|
|||
account.code LIKE '28%';
|
||||
:line_id = $immo_id|intval
|
||||
}}
|
||||
{{if $status == "nsp" && $amort_amount != null}}
|
||||
{{if $status == "unknown" && $amort_amount != null}}
|
||||
{{:assign ignore=true}}
|
||||
{{else}}
|
||||
{{:assign ignore=false}}
|
||||
|
@ -107,16 +108,16 @@
|
|||
<td><a href={{$compte_url}}>{{$account_code}}</a></td>
|
||||
<td>{{$account_label}}</td>
|
||||
<td class="actions">
|
||||
{{if $status == "nsp"}}
|
||||
{{if $status == "unknown"}}
|
||||
{{:linkbutton
|
||||
label="Amortir"
|
||||
label="Paramètres"
|
||||
href="add_infos.html?immo_id=%s&amort=0&op=new&type_immo=autre"|args:$immo_id
|
||||
shape="settings"
|
||||
target="_dialog"
|
||||
}}
|
||||
{{else}}
|
||||
{{:linkbutton
|
||||
label="Amortir"
|
||||
label="Paramètres"
|
||||
href="add_infos.html?immo_id=%s&amort=0&op=modif&type_immo=autre"|args:$immo_id
|
||||
shape="settings"
|
||||
target="_dialog"
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
@param immo_id
|
||||
@param amort = 1 si immo amortissable, 0 si non
|
||||
@param op = new ou modif
|
||||
@param type_immo : encours, sortie, amortie, autre
|
||||
@param type_immo : encours, amortie, sortie, autre
|
||||
*}}
|
||||
|
||||
{{if $_GET.op == "modif"}}
|
||||
|
@ -14,6 +14,9 @@
|
|||
|
||||
{{* Traiter l'envoi du formulaire *}}
|
||||
{{#form on="save"}}
|
||||
{{if $_POST.classify == null}}
|
||||
{{:error message="Vous devez choisir une action"}}
|
||||
{{/if}}
|
||||
|
||||
{{* chercher la date d'acquisition de l'immobilisation *}}
|
||||
{{#select
|
||||
|
@ -26,7 +29,7 @@
|
|||
}}
|
||||
{{/select}}
|
||||
|
||||
{{if ! $_POST.amortir}}
|
||||
{{if $_POST.classify == "ignored"}}
|
||||
{{* ne pas amortir *}}
|
||||
{{:assign duration=0}}
|
||||
{{:assign date_debut=$ligne_immo.date_achat|parse_date}}
|
||||
|
@ -39,12 +42,17 @@
|
|||
{{:assign da=$ligne_immo.date_achat|date_short}}
|
||||
{{: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 $_POST.classify == "amortized"}}
|
||||
{{:assign duration=0}}
|
||||
{{:assign status="amortized"}}
|
||||
{{else}}
|
||||
{{:assign duration=$_POST.duree|intval}}
|
||||
{{if $duration <= 0}}
|
||||
{{:error message="Erreur : la durée d'amortissement doit être strictement positive"}}
|
||||
{{/if}}
|
||||
{{:assign status="managed"}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
{{* enregistrer les infos de l'immobilisation *}}
|
||||
{{if $_GET.op == "new"}}
|
||||
|
@ -62,8 +70,10 @@
|
|||
status=$status
|
||||
}}
|
||||
|
||||
{{if ! $_POST.amortir}}
|
||||
{{:assign type_immo="autre"}}
|
||||
{{if $_POST.classify == "managed"}}
|
||||
{{:assign type_immo="encours"}}
|
||||
{{elseif $_POST.classify == "amortized"}}
|
||||
{{:assign type_immo="amortie"}}
|
||||
{{else}}
|
||||
{{:assign type_immo=$_GET.type_immo}}
|
||||
{{/if}}
|
||||
|
@ -81,31 +91,32 @@
|
|||
|
||||
{{* renseigner ou modifier la date de mise en service et la durée d'amortissement *}}
|
||||
{{if $_GET.amort == 0}}
|
||||
{{:assign checked=0}}
|
||||
{{:assign disabled=1}}
|
||||
{{:assign default=""}}
|
||||
{{else}}
|
||||
{{:assign checked=1}}
|
||||
{{:assign disabled=0}}
|
||||
{{:assign default="managed"}}
|
||||
{{/if}}
|
||||
|
||||
<form method="post" action="">
|
||||
<fieldset id="infos_immo">
|
||||
<legend></legend>
|
||||
<dl>
|
||||
{{if $checked}}
|
||||
{{:assign helptext = "Dé-cocher pour ne pas amortir"}}
|
||||
{{else}}
|
||||
{{:assign helptext = "Cocher pour amortir"}}
|
||||
{{/if}}
|
||||
{{:input id="amortir" type="checkbox" value=1 name="amortir" label="Amortir" default=$checked help=$helptext onclick="toggleInputs('infos_immo','f_amortir_1')"}}
|
||||
<dt><label>Faites un choix</label> <b>(obligatoire)</b></dt>
|
||||
{{:input type="radio" name="classify" value="managed" label="Amortir" help="Amortir cette immobilisation" default=$default onclick="toggleInputs('div_inputs','f_classify_managed', 'f_classify_amortized')"}}
|
||||
{{:input type="radio" name="classify" value="amortized" label="Marquer amortie" help="Cette immobilisation sera classée parmi les immobilisations amorties" onclick="toggleInputs('div_inputs','f_classify_managed', 'f_classify_amortized')"}}
|
||||
{{:input type="radio" name="classify" value="ignored" label="Ignorer l'écriture" help="Cette écriture n'apparaitra plus dans la liste des immobilisations" onclick="toggleInputs('div_inputs','f_classify_managed', 'f_classify_amortized')"}}
|
||||
|
||||
{{if $info_immo != null}}
|
||||
{{:assign date_defaut=$info_immo.date}}
|
||||
{{:assign duree_defaut=$info_immo.duration}}
|
||||
{{else}}
|
||||
{{:assign duree_defaut=1}}
|
||||
{{:assign duree_defaut=null}}
|
||||
{{/if}}
|
||||
<div id="div_inputs">
|
||||
{{:input type="number" name="duree" label="Durée d'amortissement" default=$duree_defaut required=true min=1 disabled=$disabled}}
|
||||
{{:input type="date" name="date_mes" label="Date de mise en service" default=$date_defaut disabled=$disabled help="à renseigner uniquement si différente de la date d'acquisition"}}
|
||||
</div>
|
||||
</dl>
|
||||
</fieldset>
|
||||
|
||||
|
@ -117,19 +128,19 @@
|
|||
|
||||
{{* activer/désactiver les champs de saisie *}}
|
||||
<script type="text/javascript">
|
||||
function toggleInputs(idfs, idcb) {
|
||||
const amortir = document.getElementById(idcb);
|
||||
const fs = document.getElementById(idfs);
|
||||
function toggleInputs(idiv, idrb1, idrb2) {
|
||||
const rb1 = document.getElementById(idrb1);
|
||||
const rb2 = document.getElementById(idrb2);
|
||||
const fs = document.getElementById(idiv);
|
||||
for (let field of fs.querySelectorAll("input")) {
|
||||
if (field == amortir) { continue }
|
||||
if (! amortir.checked) {
|
||||
if (! rb1.checked) {
|
||||
field.setAttribute("disabled","disabled");
|
||||
}
|
||||
else {
|
||||
field.removeAttribute("disabled");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
{{:admin_footer}}
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
{{#load type="immo" where="$$.line = :line_id" :line_id=$_GET.immo_id|intval}}
|
||||
{{:assign duree=$duration}}
|
||||
{{:assign date_debut=$date}}
|
||||
{{:assign status=$status}}
|
||||
{{/load}}
|
||||
|
||||
{{* chercher des écritures d'amortissement liées à l'immobilisation *}}
|
||||
|
@ -67,10 +68,15 @@
|
|||
{{/if}}
|
||||
{{/select}}
|
||||
|
||||
{{:assign valeur_residuelle=$ligne_immo.montant}}
|
||||
{{#foreach from=$linked_lines}}
|
||||
{{if $status == "amortized"}}
|
||||
{{:assign amort_amount=$ligne_immo.montant}}
|
||||
{{:assign valeur_residuelle=0}}
|
||||
{{else}}
|
||||
{{:assign valeur_residuelle=$ligne_immo.montant}}
|
||||
{{#foreach from=$linked_lines}}
|
||||
{{:assign valeur_residuelle="%d-%d"|math:$valeur_residuelle:$amort_amount}}
|
||||
{{/foreach}}
|
||||
{{/foreach}}
|
||||
{{/if}}
|
||||
|
||||
{{* Autres amortissements non rattachés *}}
|
||||
{{#select
|
||||
|
|
|
@ -57,7 +57,11 @@
|
|||
{{/select}}
|
||||
|
||||
{{if $amort_line.amort_number == 0}}
|
||||
{{if $info_immo.status == "amortized"}}
|
||||
{{:assign amort_amount=$ligne_immo.montant}}
|
||||
{{else}}
|
||||
{{:assign amort_amount=0}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{:assign amort_amount=$amort_line.amort_amount}}
|
||||
{{:assign date_debut=$amort_line.last_amort_date|strtotime}}
|
||||
|
@ -153,8 +157,9 @@ lister les exercices ouverts :
|
|||
{{: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}}
|
||||
{{if $info_immo.status != "amortized" && $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}}
|
||||
|
|
|
@ -69,7 +69,7 @@
|
|||
<dt>Date de mise en service</dt>
|
||||
<dd>{{$_GET.date_mes|date:"d/m/Y"}}</dd>
|
||||
{{/if}}
|
||||
{{if $_GET.duree_amort != null}}
|
||||
{{if $_GET.duree_amort != null && $_GET.duree_amort != 0}}
|
||||
<dt>Durée de l'amortissement</dt>
|
||||
<dd id="duree_amort" class="num">{{$_GET.duree_amort}} ans</dd>
|
||||
{{/if}}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
},
|
||||
"status" : {
|
||||
"type" : ["string", "null"],
|
||||
"enum" : ["managed", "archived", "ignored"]
|
||||
"enum" : ["managed", "amortized", "archived", "ignored"]
|
||||
}
|
||||
},
|
||||
"required": ["type", "line", "duration", "date"]
|
||||
|
|
Loading…
Add table
Reference in a new issue