Compare commits
15 commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
472b5551b1 | ||
![]() |
bcf89ba874 | ||
![]() |
e7763d7cac | ||
![]() |
f1f6910a36 | ||
![]() |
e3bbdf7574 | ||
![]() |
688cada3e8 | ||
![]() |
eae9a2f31c | ||
![]() |
ec94358f47 | ||
![]() |
79e536a0b3 | ||
![]() |
ff4b295cf6 | ||
![]() |
19e2fed248 | ||
![]() |
0688ad0fec | ||
![]() |
dc823c90e2 | ||
![]() |
e0cf555851 | ||
![]() |
ab9b2a37ff |
21 changed files with 664 additions and 226 deletions
|
@ -37,10 +37,9 @@
|
|||
{{* Immobilisation avec une écriture de sortie de bilan *}}
|
||||
{{:read file="./defaut.json" assign="config_json"}}
|
||||
{{:assign config_defaut=$config_json|json_decode}}
|
||||
{{:assign var="prefix_array" value=$config_defaut.prefixes|keys}}
|
||||
|
||||
{{:assign condition="("}}
|
||||
{{#foreach from=$prefix_array item="code"}}
|
||||
{{#foreach from=$config_defaut.prefixes item="code"}}
|
||||
{{:assign code=$code|cat:"%"|quote_sql}}
|
||||
{{:assign condition=$condition|cat:"account.code LIKE "|cat:$code|cat:" OR "}}
|
||||
{{/foreach}}
|
||||
|
|
23
_get_config.html
Normal file
23
_get_config.html
Normal file
|
@ -0,0 +1,23 @@
|
|||
{{* -*- brindille -*- *}}
|
||||
|
||||
{{*
|
||||
Récupérer la config
|
||||
*}}
|
||||
|
||||
{{* config par défaut *}}
|
||||
{{:read file="./defaut.json" assign="config_defaut"}}
|
||||
{{:assign config_defaut=$config_defaut|json_decode}}
|
||||
|
||||
{{*
|
||||
{{if $module.config.tva != null}}
|
||||
{{:assign var="config.tva" value=$module.config.tva}}
|
||||
{{else}}
|
||||
{{:assign var="config.tva" value=$config_defaut.tva}}
|
||||
{{/if}}
|
||||
*}}
|
||||
|
||||
{{if $module.config.prefixes != null}}
|
||||
{{:assign var="config.prefixes" value=$module.config.prefixes}}
|
||||
{{else}}
|
||||
{{:assign var="config.prefixes" value=$config_defaut.prefixes}}
|
||||
{{/if}}
|
|
@ -1,11 +1,11 @@
|
|||
{{* -*- brindille -*- *}}
|
||||
|
||||
{{* Liste des immobilisations amortissable ou à définir *}}
|
||||
{{* Liste des immobilisations en cours ou amorties *}}
|
||||
|
||||
<section class="immobilisation">
|
||||
{{if $type_immo == "encours"}}
|
||||
{{if $type_immo == "managed"}}
|
||||
<h2 class="ruler">Immobilisations en cours</h2>
|
||||
{{elseif $type_immo == "fini"}}
|
||||
{{elseif $type_immo == "amortized"}}
|
||||
<h2 class="ruler">Immobilisations amorties</h2>
|
||||
{{/if}}
|
||||
{{:assign nb_immo=0}}
|
||||
|
@ -28,9 +28,8 @@
|
|||
{{* lister les immobilisations *}}
|
||||
{{:read file="./defaut.json" assign="config_json"}}
|
||||
{{:assign config_defaut=$config_json|json_decode}}
|
||||
{{:assign var="prefix_array" value=$config_defaut.prefixes|keys}}
|
||||
{{:assign condition="("}}
|
||||
{{#foreach from=$prefix_array item="code"}}
|
||||
{{#foreach from=$config_defaut.prefixes item="code"}}
|
||||
{{:assign code=$code|cat:"%"|quote_sql}}
|
||||
{{:assign condition=$condition|cat:" account.code LIKE "|cat:$code|cat:" OR "}}
|
||||
{{/foreach}}
|
||||
|
@ -58,18 +57,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 +90,9 @@
|
|||
:line_id = $immo_id|intval
|
||||
}}
|
||||
{{:assign ignore=true}}
|
||||
{{:assign status="archived"}}
|
||||
{{/select}}
|
||||
{{if $ignore}}
|
||||
{{if $status == "archived"}}
|
||||
{{:continue}}
|
||||
{{/if}}
|
||||
|
||||
|
@ -133,12 +131,11 @@
|
|||
{{/select}}
|
||||
|
||||
{{* classement par onglet *}}
|
||||
{{if $type_immo == "encours" && $amort_amount >= $debit ||
|
||||
$type_immo == "fini" && $amort_amount < $debit ||
|
||||
$amortissable == "nsp" && ! $exist_amort
|
||||
}}
|
||||
{{:continue}}
|
||||
{{/if}}
|
||||
{{if $type_immo == "managed" && $amort_amount >= $debit}}{{:continue}}{{/if}}
|
||||
{{if $type_immo == "managed" && $status == "amortized"}}{{:continue}}{{/if}}
|
||||
{{if $status == "unknown" && ! $exist_amort}}{{:continue}}{{/if}}
|
||||
{{if $type_immo == "amortized" && $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>
|
||||
|
@ -152,14 +149,14 @@
|
|||
{{if ! $exist_amort}}
|
||||
{{:linkbutton
|
||||
label="Paramètres"
|
||||
href="add_infos.html?immo_id=%s&amort=1&op=modif&type_immo=%s"|args:$immo_id:$type_immo
|
||||
href="add_infos.html?immo_id=%s&type_immo=%s"|args:$immo_id:$type_immo
|
||||
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
|
||||
href="add_infos.html?immo_id=%s&type_immo=%s"|args:$immo_id:$type_immo
|
||||
shape="settings"
|
||||
target="_dialog"
|
||||
}}
|
||||
|
|
|
@ -6,6 +6,12 @@
|
|||
<h2 class="ruler">Autres immobilisations</h2>
|
||||
{{:assign nb_immo=0}}
|
||||
|
||||
<form method="post" action="">
|
||||
<fieldset>
|
||||
{{:input type="checkbox" value=1 name="unhide" label="Afficher les écritures marquées ignorées" }}
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
<table class="list">
|
||||
<thead>
|
||||
<tr>
|
||||
|
@ -23,9 +29,8 @@
|
|||
{{* lister les immobilisations *}}
|
||||
{{:read file="./defaut.json" assign="config_json"}}
|
||||
{{:assign config_defaut=$config_json|json_decode}}
|
||||
{{:assign var="prefix_array" value=$config_defaut.prefixes|keys}}
|
||||
{{:assign condition="("}}
|
||||
{{#foreach from=$prefix_array item="code"}}
|
||||
{{#foreach from=$config_defaut.prefixes item="code"}}
|
||||
{{:assign code=$code|cat:"%"|quote_sql}}
|
||||
{{:assign condition=$condition|cat:" account.code LIKE "|cat:$code|cat:" OR "}}
|
||||
{{/foreach}}
|
||||
|
@ -52,14 +57,21 @@
|
|||
}}
|
||||
{{: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"}}
|
||||
{{:continue}}
|
||||
{{if $_POST.unhide == null}}
|
||||
{{if $status != "unknown"}}
|
||||
{{:continue}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{if $status != "ignored" && $status != "unknown"}}
|
||||
{{:continue}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
{{* voir s'il existe des écritures d'amortissement associées *}}
|
||||
|
@ -87,7 +99,7 @@
|
|||
account.code LIKE '28%';
|
||||
:line_id = $immo_id|intval
|
||||
}}
|
||||
{{if $status == "nsp" && $amort_amount != null}}
|
||||
{{if $amort_amount != null}}
|
||||
{{:assign ignore=true}}
|
||||
{{else}}
|
||||
{{:assign ignore=false}}
|
||||
|
@ -107,24 +119,24 @@
|
|||
<td><a href={{$compte_url}}>{{$account_code}}</a></td>
|
||||
<td>{{$account_label}}</td>
|
||||
<td class="actions">
|
||||
{{if $status == "nsp"}}
|
||||
{{if $status == "unknown"}}
|
||||
{{:linkbutton
|
||||
label="Paramètres"
|
||||
href="add_infos.html?immo_id=%s&amort=0&op=new&type_immo=autres"|args:$immo_id
|
||||
href="add_infos.html?immo_id=%s&type_immo=other"|args:$immo_id
|
||||
shape="settings"
|
||||
target="_dialog"
|
||||
}}
|
||||
{{else}}
|
||||
{{:linkbutton
|
||||
label="Paramètres"
|
||||
href="add_infos.html?immo_id=%s&amort=0&op=modif&type_immo=autres"|args:$immo_id
|
||||
href="add_infos.html?immo_id=%s&type_immo=other"|args:$immo_id
|
||||
shape="settings"
|
||||
target="_dialog"
|
||||
}}
|
||||
{{/if}}
|
||||
{{:linkbutton
|
||||
label="Amortissements"
|
||||
href="amortization.html?immo_id=%s&type_immo=autres"|args:$immo_id
|
||||
href="amortization.html?immo_id=%s&type_immo=other"|args:$immo_id
|
||||
shape="table"
|
||||
}}
|
||||
</td>
|
||||
|
@ -136,3 +148,15 @@
|
|||
<p class="block alert">Aucune immobilisation</p>
|
||||
{{/if}}
|
||||
</section>
|
||||
|
||||
<script type="text/javascript">
|
||||
function changeVisibility(evt, idcheck = 'f_unhide_1') {
|
||||
this.form.dispatchEvent(new Event('submit'));
|
||||
this.form.submit();
|
||||
}
|
||||
|
||||
(function () {
|
||||
document.getElementById('f_unhide_1').onclick = changeVisibility;
|
||||
})();
|
||||
|
||||
</script>
|
||||
|
|
39
_nav.html
39
_nav.html
|
@ -1,38 +1,35 @@
|
|||
{{* -*- brindille -*- *}}
|
||||
|
||||
<nav class="tabs">
|
||||
{{if $current == 'index' && $subsubcurrent == null}}
|
||||
{{if $current == "index" && $subsubcurrent == null}}
|
||||
<aside>
|
||||
{{:linkbutton label="Ajouter une immobilisation" shape="plus" href="add_asset.html" target="_dialog"}}
|
||||
</aside>
|
||||
{{elseif $subsubcurrent == "amortization" && $type_immo == null || $type_immo == "managed" || $type_immo == "other"}}
|
||||
<aside>
|
||||
{{if $autres_amort != null}}
|
||||
{{:linkbutton label="Attacher un amortissement" href="other_amortizations.html?immo_id=%s"|args:$_GET.immo_id shape="plus" target="_dialog"}}
|
||||
{{/if}}
|
||||
{{:linkbutton label="Enregistrer un amortissement" shape="plus"
|
||||
href="save_amort.html?immo_id=%s"|args:$_GET.immo_id target="_dialog"}}
|
||||
</aside>
|
||||
{{/if}}
|
||||
|
||||
{{*
|
||||
<ul>
|
||||
<li {{if $current == 'index'}} class="current"{{/if}}><a href="{{$module.url}}index.html">Immobilisations</a></li>
|
||||
<li {{if $current == 'aide'}} class="current"{{/if}}><a href="{{$module.url}}aide.html">Aide</a></li>
|
||||
<li {{if $subcurrent == "managed"}}class="current"{{/if}}><a href="index.html?type_immo=managed">En cours</a></li>
|
||||
<li {{if $subcurrent == "amortized"}}class="current"{{/if}}><a href="index.html?type_immo=amortized">Amorties</a></li>
|
||||
<li {{if $subcurrent == "archived"}}class="current"{{/if}}><a href="index.html?type_immo=archived">Sorties du bilan</a></li>
|
||||
<li {{if $subcurrent == "other"}}class="current"{{/if}}><a href="index.html?type_immo=other">Autres</a></li>
|
||||
<li {{if $current == "config"}} class="current"{{/if}}><a href="config.html">Configuration</a></li>
|
||||
</ul>
|
||||
*}}
|
||||
|
||||
{{if $current == 'index' && $subsubcurrent != 'balance_exit'}}
|
||||
{{* <ul class="sub">*}}
|
||||
<ul>
|
||||
<li {{if $subcurrent == 'encours'}}class="current"{{/if}}><a href="index.html?type_immo=encours">En cours</a></li>
|
||||
<li {{if $subcurrent == 'fini'}}class="current"{{/if}}><a href="index.html?type_immo=fini">Terminées</a></li>
|
||||
<li {{if $subcurrent == 'archive'}}class="current"{{/if}}><a href="index.html?type_immo=archive">Archivées</a></li>
|
||||
<li {{if $subcurrent == 'autres'}}class="current"{{/if}}><a href="index.html?type_immo=autres">Autres</a></li>
|
||||
</ul>
|
||||
{{/if}}
|
||||
|
||||
{{if $subsubcurrent == 'amortization'}}
|
||||
{{if $subsubcurrent == "amortization"}}
|
||||
<ul class="sub">
|
||||
<li class="title"><strong>Amortissements</strong></li>
|
||||
</ul>
|
||||
{{elseif $subsubcurrent == 'balance_exit'}}
|
||||
{{*
|
||||
<ul class="sub">
|
||||
<li class="title"><strong>Sortie du bilan</strong></li>
|
||||
{{elseif $subsubcurrent == "balance_exit"}}
|
||||
<ul class="sub">
|
||||
<li class="title"><strong>Sortie de bilan</strong></li>
|
||||
</ul>
|
||||
*}}
|
||||
{{/if}}
|
||||
</nav>
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
{{:read file="./defaut.json" assign="config_json"}}
|
||||
{{:assign config_defaut=$config_json|json_decode}}
|
||||
{{:assign var="prefix_array" value=$config_defaut.prefixes|keys}}
|
||||
|
||||
{{#years closed=false order="start_date" assign=years.}}
|
||||
{{:assign ts_debut=$start_date|strtotime}}
|
||||
|
@ -74,7 +73,7 @@
|
|||
file="_check_account.html"
|
||||
account=$debit_account
|
||||
chart_id=$selected_chart
|
||||
prefix_array=$prefix_array
|
||||
prefix_array=$config_defaut.prefixes
|
||||
keep="account_ok"
|
||||
}}
|
||||
|
||||
|
@ -117,11 +116,11 @@
|
|||
status=$status
|
||||
}}
|
||||
{{if $_POST.amortir}}
|
||||
{{:assign amort="encours"}}
|
||||
{{:assign type_immo="managed"}}
|
||||
{{else}}
|
||||
{{:assign amort="autres"}}
|
||||
{{:assign type_immo="other"}}
|
||||
{{/if}}
|
||||
{{:redirect force="index.html?ok=1&msg=immobilisation&amort=%s"|args:$amort}}
|
||||
{{:redirect force="index.html?ok=1&msg=immobilisation&type_immo=%s"|args:$type_immo}}
|
||||
{{/form}}
|
||||
|
||||
{{:admin_header title="Ajout immobilisation" current="module_amortissement"}}
|
||||
|
@ -134,16 +133,14 @@
|
|||
|
||||
{{* formulaire d'ajout d'immobilisation *}}
|
||||
|
||||
{{:assign var="immo_account.2" value="2 — Classe 2 — Comptes d'immobilisations"}}
|
||||
|
||||
{{#select id,label FROM acc_projects WHERE archived = 0;}}
|
||||
{{:assign var="projects.%d"|args:$id value=$label}}
|
||||
{{/select}}
|
||||
|
||||
{{#foreach from=$prefix_array item="code"}}
|
||||
{{#foreach from=$config_defaut.prefixes item="code"}}
|
||||
{{:assign var="pattern_array." value="%s*"|args:$code}}
|
||||
{{/foreach}}
|
||||
{{:assign patterns=$pattern_array|implode:"|"}}
|
||||
{{:assign var="patterns" value=$pattern_array|implode:"|"}}
|
||||
|
||||
<div id="erreur" class="hidden">
|
||||
<p class="block error">La date choisie n'est dans aucun exercice ouvert !</p>
|
||||
|
@ -182,7 +179,7 @@
|
|||
<fieldset>
|
||||
<legend>Amortissement</legend>
|
||||
<dl>
|
||||
{{:input id="amortir" type="checkbox" value=1 name="amortir" label="Amortir cette immobilisation sur plusieurs années" checked="cheched" help="Dé-cocher pour ne pas amortir"}}
|
||||
{{:input id="amortir" type="checkbox" value=1 name="amortir" label="Amortir cette immobilisation sur plusieurs années" checked="checked" help="Dé-cocher pour ne pas amortir"}}
|
||||
<div id="div_amort">
|
||||
{{:input type="number" name="duree" label="Durée d'amortissement" required=true min=0 default=1 suffix="année(s)"}}
|
||||
{{:input type="date" name="date_mes" label="Date de mise en service" help="C'est la date de première utilisation ; à renseigner uniquement si différente de la date d'acquisition"}}
|
||||
|
|
|
@ -2,18 +2,17 @@
|
|||
|
||||
{{*
|
||||
@param immo_id
|
||||
@param amort = 1 si immo amortissable, 0 si non
|
||||
@param op = new ou modif
|
||||
@param type_immo : encours, archive, fini, autre
|
||||
@param type_immo : managed, amortized, archived, other
|
||||
*}}
|
||||
|
||||
{{if $_GET.op == "modif"}}
|
||||
{{#load type="immo" assign="info_immo" where="$$.line = :line_id" :line_id=$_GET.immo_id|intval}}
|
||||
{{/load}}
|
||||
{{/if}}
|
||||
{{#load type="immo" assign="info_immo" where="$$.line = :line_id" :line_id=$_GET.immo_id|intval}}
|
||||
{{/load}}
|
||||
|
||||
{{* 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 +25,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,15 +38,20 @@
|
|||
{{: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}}
|
||||
{{:assign duration=$_POST.duree|intval}}
|
||||
{{if $duration <= 0}}
|
||||
{{:error message="Erreur : la durée d'amortissement doit être strictement positive"}}
|
||||
{{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}}
|
||||
{{:assign status="managed"}}
|
||||
{{/if}}
|
||||
|
||||
{{* enregistrer les infos de l'immobilisation *}}
|
||||
{{if $_GET.op == "new"}}
|
||||
{{if $info_immo == null}}
|
||||
{{:assign key=""|uuid}}
|
||||
{{else}}
|
||||
{{:assign key=$info_immo.key}}
|
||||
|
@ -62,8 +66,8 @@
|
|||
status=$status
|
||||
}}
|
||||
|
||||
{{if ! $_POST.amortir}}
|
||||
{{:assign type_immo="autres"}}
|
||||
{{if $_POST.classify == "managed" || $_POST.classify == "amortized"}}
|
||||
{{:assign type_immo=$_POST.classify}}
|
||||
{{else}}
|
||||
{{:assign type_immo=$_GET.type_immo}}
|
||||
{{/if}}
|
||||
|
@ -79,33 +83,41 @@
|
|||
{{:include file="_nav.html" current="index"}}
|
||||
{{/if}}
|
||||
|
||||
{{* 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}}
|
||||
{{if $info_immo == null}}
|
||||
{{:assign default=$_GET.type_immo}}
|
||||
{{else}}
|
||||
{{:assign checked=1}}
|
||||
{{:assign disabled=0}}
|
||||
{{:assign default=$info_immo.status}}
|
||||
{{/if}}
|
||||
|
||||
{{if $_GET.type_immo == "managed" || $_GET.type_immo == "amortized"}}
|
||||
{{:assign disabled=0}}
|
||||
{{else}}
|
||||
{{:assign disabled=1}}
|
||||
{{/if}}
|
||||
|
||||
{{*
|
||||
- classer l'immobilisation
|
||||
- renseigner ou modifier la date de mise en service et la durée d'amortissement
|
||||
*}}
|
||||
<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="Amortissement terminé" help="Cette immobilisation sera classée parmi les immobilisations amorties" default=$default 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" default=$default 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}}
|
||||
{{: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 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 +129,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);
|
||||
for (let field of fs.querySelectorAll("input")) {
|
||||
if (field == amortir) { continue }
|
||||
if (! amortir.checked) {
|
||||
field.setAttribute("disabled","disabled");
|
||||
}
|
||||
else {
|
||||
field.removeAttribute("disabled");
|
||||
}
|
||||
}
|
||||
}
|
||||
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 (! rb1.checked) {
|
||||
field.setAttribute("disabled","disabled");
|
||||
}
|
||||
else {
|
||||
field.removeAttribute("disabled");
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
{{:admin_footer}}
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
{{* -*- brindille -*- *}}
|
||||
|
||||
{{*
|
||||
Lister les écritures d'amortissement associées à une immobilisation
|
||||
@param immo_id : id de la ligne d'immo
|
||||
@param type_immo : managed, amortized, archived, others
|
||||
*}}
|
||||
|
||||
{{* récupérer les infos de l'immobilisation *}}
|
||||
{{#select
|
||||
line.id as immo_id,
|
||||
|
@ -18,10 +24,12 @@
|
|||
{{/select}}
|
||||
{{:assign date_debut=$ligne_immo.date}}
|
||||
{{:assign solde=$ligne_immo.montant}}
|
||||
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$ligne_immo.trans_id}}
|
||||
|
||||
{{#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 *}}
|
||||
|
@ -60,24 +68,70 @@
|
|||
{{/if}}
|
||||
{{/select}}
|
||||
|
||||
{{:assign valeur_residuelle=$ligne_immo.montant}}
|
||||
{{#foreach from=$linked_lines}}
|
||||
{{:assign valeur_residuelle="%d-%d"|math:$valeur_residuelle:$amort_amount}}
|
||||
{{/foreach}}
|
||||
{{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}}
|
||||
{{/if}}
|
||||
|
||||
{{* Autres amortissements non rattachés *}}
|
||||
{{#select
|
||||
line.id as l_id,
|
||||
line.id_transaction as t_id,
|
||||
line.credit as amort_amount,
|
||||
line.label as l_label,
|
||||
trans.date as t_date,
|
||||
trans.label as t_label,
|
||||
trans.id_year as amort_year,
|
||||
account.id as account_id,
|
||||
account.code as account_code,
|
||||
account.label as account_label
|
||||
FROM acc_transactions_lines AS line
|
||||
INNER JOIN acc_accounts AS account ON account.id = line.id_account
|
||||
INNER JOIN acc_transactions AS trans ON trans.id = line.id_transaction
|
||||
INNER JOIN acc_years AS y ON y.id = trans.id_year
|
||||
WHERE account.code LIKE "28%" AND credit > 0 AND (NOT trans.status & 16)
|
||||
ORDER BY trans.date, trans.label;
|
||||
assign=autre_amort
|
||||
}}
|
||||
{{#select
|
||||
id_transaction,
|
||||
id_related
|
||||
FROM acc_transactions_links
|
||||
WHERE id_transaction = :id_amort OR id_related = :id_amort;
|
||||
:id_amort=$t_id
|
||||
}}
|
||||
{{else}}
|
||||
{{:assign var="autres_amortissements." value=$autre_amort}}
|
||||
{{/select}}
|
||||
{{/select}}
|
||||
|
||||
|
||||
{{:admin_header title="Liste des amortissements" custom_css="./style.css" current="module_amortissement"}}
|
||||
|
||||
{{* barre de navigation *}}
|
||||
{{if $_GET.type_immo == "fini" || $valeur_residuelle== 0 }}
|
||||
{{:assign subcurrent="fini"}}
|
||||
{{elseif $_GET.type_immo == "archive"}}
|
||||
{{:assign subcurrent="archive"}}
|
||||
{{elseif $_GET.type_immo == null || $_GET.type_immo == "encours"}}
|
||||
{{:assign subcurrent="encours"}}
|
||||
{{if $_GET.type_immo == "amortized" || $valeur_residuelle== 0 }}
|
||||
{{:assign subcurrent="amortized"}}
|
||||
{{elseif $_GET.type_immo == "archived"}}
|
||||
{{:assign subcurrent="archived"}}
|
||||
{{elseif $_GET.type_immo == null || $_GET.type_immo == "managed"}}
|
||||
{{:assign subcurrent="managed"}}
|
||||
{{else}}
|
||||
{{:assign subcurrent="autres"}}
|
||||
{{:assign subcurrent="other"}}
|
||||
{{/if}}
|
||||
{{:include file="_nav.html" current="index" subcurrent="%s"|args:$subcurrent subsubcurrent="amortization"}}
|
||||
|
||||
{{:include
|
||||
file="_nav.html"
|
||||
current="index"
|
||||
subcurrent="%s"|args:$subcurrent
|
||||
subsubcurrent="amortization"
|
||||
type_immo=$_GET.type_immo
|
||||
autres_amort=$autres_amortissements
|
||||
}}
|
||||
|
||||
{{if $_GET.ok}}
|
||||
{{if $_GET.msg|match:"attach"}}
|
||||
|
@ -97,21 +151,13 @@
|
|||
<p class="block error">{{$msg}}</p>
|
||||
{{/if}}
|
||||
|
||||
{{if $valeur_residuelle > 0}}
|
||||
<nav class="tabs amort">
|
||||
<aside>
|
||||
{{:linkbutton label="Enregistrer un amortissement" shape="plus" href="save_amort.html?immo_id=%s"|args:$_GET.immo_id target="_dialog"}}
|
||||
</aside>
|
||||
</nav>
|
||||
{{/if}}
|
||||
|
||||
<form method="post" action="">
|
||||
<fieldset>
|
||||
<legend>Sortir l'immobilisation du bilan ?</legend>
|
||||
<p class="submit">
|
||||
{{:linkbutton
|
||||
label="Sortir du bilan"
|
||||
href="balance_sheet_exit.html?immo_id=%s"|args:$_GET.immo_id
|
||||
href="balance_sheet_exit.html?immo_id=%s&type_immo=%s"|args:$_GET.immo_id:$_GET.type_immo
|
||||
shape="export"
|
||||
class="main"
|
||||
}}
|
||||
|
@ -125,8 +171,8 @@
|
|||
</form>
|
||||
|
||||
<dl class="describe">
|
||||
<dt>Libellé</dt>
|
||||
<dd>{{$ligne_immo.label}}</dd>
|
||||
<dt>Immobilisation</dt>
|
||||
<dd><span class="num"><a href={{$trans_url}}>#{{$ligne_immo.trans_id}}</a></span> {{$ligne_immo.label}}</dd>
|
||||
<dt>Montant</dt>
|
||||
<dd><strong class="money">{{"%f"|math:$ligne_immo.montant|money_currency}}</strong></dd>
|
||||
<dt>Début d'amortissement</dt>
|
||||
|
@ -135,6 +181,16 @@
|
|||
<dt>Durée</dt>
|
||||
<dd>{{$duree}} ans</dd>
|
||||
{{/if}}
|
||||
{{if $valeur_residuelle > 0}}
|
||||
<dt>Montant déjà amorti</dt>
|
||||
<dd>{{"%d-%d"|math:$ligne_immo.montant:$valeur_residuelle|money_currency:false}}</dd>
|
||||
<dt>Valeur résiduelle</dt>
|
||||
<dd>{{$valeur_residuelle|money_currency}}</dd>
|
||||
{{/if}}
|
||||
{{if $duree != null && $valeur_residuelle > 0}}
|
||||
<dt>Annuité estimée</dt>
|
||||
<dd>{{"%f/%d"|math:$ligne_immo.montant:$duree|money_currency}}</dd>
|
||||
{{/if}}
|
||||
</dl>
|
||||
|
||||
<h3 class="center-block ruler">Amortissements enregistrés</h3>
|
||||
|
@ -185,79 +241,15 @@
|
|||
<p class="block alert">Aucun amortissement enregistré pour cette immobilisation</p>
|
||||
{{/if}}
|
||||
|
||||
{{if $_GET.type_immo == null || $_GET.type_immo != "fini"}}
|
||||
{{if $_GET.type_immo == null || $_GET.type_immo != "amortized"}}
|
||||
|
||||
{{* Autres amortissements non rattachés *}}
|
||||
{{#select
|
||||
line.id as l_id,
|
||||
line.id_transaction as t_id,
|
||||
line.credit as amort_amount,
|
||||
line.label as l_label,
|
||||
trans.date as t_date,
|
||||
trans.label as t_label,
|
||||
trans.id_year as amort_year,
|
||||
account.id as account_id,
|
||||
account.code as account_code,
|
||||
account.label as account_label
|
||||
FROM acc_transactions_lines AS line
|
||||
INNER JOIN acc_accounts AS account ON account.id = line.id_account
|
||||
INNER JOIN acc_transactions AS trans ON trans.id = line.id_transaction
|
||||
INNER JOIN acc_years AS y ON y.id = trans.id_year
|
||||
WHERE account.code LIKE "28%" AND credit > 0 AND (NOT trans.status & 16)
|
||||
ORDER BY trans.date, trans.label;
|
||||
assign=autre_amort
|
||||
}}
|
||||
{{#select
|
||||
id_transaction,
|
||||
id_related
|
||||
FROM acc_transactions_links
|
||||
WHERE id_transaction = :id_amort OR id_related = :id_amort;
|
||||
:id_amort=$t_id
|
||||
}}
|
||||
{{else}}
|
||||
{{:assign var="autres_amortissements." value=$autre_amort}}
|
||||
{{/select}}
|
||||
{{/select}}
|
||||
|
||||
{{if $autres_amortissements != null}}
|
||||
<section class="amortissement">
|
||||
<h3 class="center-block ruler">Amortissements non rattachés</h3>
|
||||
<table class="list">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>N°</th>
|
||||
<th>Date</th>
|
||||
<th class="nombre">Montant</th>
|
||||
<th>Libellé</th>
|
||||
<th>N° compte</th>
|
||||
<th>Compte</th>
|
||||
<th class="actions"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#foreach from=$autres_amortissements item="line"}}
|
||||
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$line.t_id}}
|
||||
{{:assign compte_url="%s/acc/accounts/journal.php?id=%s&year=%s"|args:$admin_url:$line.account_id:$line.amort_year}}
|
||||
<tr>
|
||||
<td class="num"><a href={{$trans_url}}>#{{$line.t_id}}</a></td>
|
||||
<td>{{$line.t_date|date_short}}</td>
|
||||
<td class="money">{{"%f"|math:$line.amort_amount|money}}</td>
|
||||
<td>{{if $line.l_label == null}}
|
||||
{{$line.t_label}}
|
||||
{{else}}
|
||||
{{$line.l_label}}
|
||||
{{/if}}
|
||||
</td>
|
||||
<td><a href={{$compte_url}}>{{$line.account_code}}</a></td>
|
||||
<td>{{$line.account_label}}</td>
|
||||
<td>
|
||||
{{:linkbutton label="Attacher" href="attach_amort.html?amort_id=%d&immo_id=%d"|args:$line.l_id:$ligne_immo.immo_id shape="plus"}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/foreach}}
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<p class="block alert">
|
||||
Il existe des écritures d'amortissement qui ne sont pas rattachés à une immobilisation ! <br />
|
||||
Utilisez le bouton « Attacher un amortissement » pour les afficher ; vous pourrez choisir d'en attacher certaines à cette immobilisation.
|
||||
</p>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{:form_errors}}
|
||||
|
|
|
@ -53,4 +53,4 @@
|
|||
assign_code="result_code"
|
||||
transactions=$linked_transactions
|
||||
}}
|
||||
{{:redirect to="amortization.html?immo_id=%s&ok=1&msg=attach&trans_id=%s"|args:$_GET.immo_id:$amort_id}}
|
||||
{{:redirect force="amortization.html?immo_id=%s&ok=1&msg=attach&trans_id=%s"|args:$_GET.immo_id:$amort_id}}
|
||||
|
|
|
@ -57,7 +57,11 @@
|
|||
{{/select}}
|
||||
|
||||
{{if $amort_line.amort_number == 0}}
|
||||
{{:assign amort_amount=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}}
|
||||
|
@ -67,19 +71,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 +148,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,10 +157,20 @@
|
|||
{{:break}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
{{* voir si des amortissements ont été oubliés *}}
|
||||
{{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}}
|
||||
{{/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}}
|
||||
|
@ -160,7 +178,7 @@
|
|||
{{: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="balance_exit"}}
|
||||
{{:include file="_nav.html" current="index" subcurrent="%s"|args:$_GET.type_immo subsubcurrent="balance_exit"}}
|
||||
{{/if}}
|
||||
{{:form_errors}}
|
||||
|
||||
|
|
|
@ -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}}
|
||||
|
|
247
config.html
Normal file
247
config.html
Normal file
|
@ -0,0 +1,247 @@
|
|||
{{* -*- brindille -*- *}}
|
||||
{{:admin_header title="Configuration" custom_css="./style.css" current="module_amortissement"}}
|
||||
{{* barre de navigation *}}
|
||||
{{:include file="_nav.html" current="config"}}
|
||||
{{if $_GET.ok == 1}}
|
||||
<p class="block confirm">Configuration enregistrée.</p>
|
||||
{{/if}}
|
||||
|
||||
{{* lecture config (défaut ou enregistrée) *}}
|
||||
{{:include file="./_get_config.html" keep="config"}}
|
||||
|
||||
{{*:debug prefixes=$config.prefixes*}}
|
||||
|
||||
{{#form on="save"}}
|
||||
{{*:debug post=$_POST*}}
|
||||
{{:assign ok=0}}
|
||||
{{*
|
||||
TODO ? gérer le cas d'un compte qui englobe un autre...
|
||||
ex : 27 21 273 ou 20 21 27 2
|
||||
*}}
|
||||
{{#foreach from=$_POST.immo_accounts item="line"}}
|
||||
{{:assign elem=$line|values}}
|
||||
{{:assign elem=$elem.0}}
|
||||
{{*:debug elem=$elem*}}
|
||||
{{:assign var="fields" value=$elem|explode:" "}}
|
||||
{{*if ! $account_codes|has:$fields.0*}}
|
||||
{{:assign present=false}}
|
||||
{{* ne pas garder si préfixe d'un compte déjà présent => voir commentaire précédent *}}
|
||||
{{#foreach from=$account_codes item="code"}}
|
||||
{{:assign pos=$code|strpos:$fields.0}}
|
||||
{{*:debug code=$code pos=$pos*}}
|
||||
{{if $pos !== false}}
|
||||
{{:assign present=true}}
|
||||
{{:break}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
{{if ! $present}}
|
||||
{{:assign var="account_codes." value=$fields.0}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
{{*:debug codes=$account_codes*}}
|
||||
|
||||
{{:save
|
||||
key="config"
|
||||
prefixes=$account_codes|sort
|
||||
}}
|
||||
{{:assign ok=1}}
|
||||
|
||||
{{:redirect to="./config.html?ok=%d"|args:$ok}}
|
||||
{{/form}}
|
||||
|
||||
{{* récupérer l'exercice courant *}}
|
||||
{{:assign var="selected_year" from="logged_user.preferences.accounting_year}}
|
||||
{{if $selected_year == null}}
|
||||
{{* sélectionner l'exercice le plus probable *}}
|
||||
{{#years closed=false order="start_date"}}
|
||||
{{:assign var="open_years.%d"|args:$id value=$label}}
|
||||
{{if $start_date|strtotime <= $now && $end_date|strtotime >= $now}}
|
||||
{{:assign selected_year=$id}}
|
||||
{{:break}}
|
||||
{{/if}}
|
||||
{{/years}}
|
||||
{{/if}}
|
||||
|
||||
|
||||
{{*
|
||||
{{#select
|
||||
year.id,
|
||||
year.label as year_label,
|
||||
year.start_date,
|
||||
year.end_date,
|
||||
chart.id as chart_id,
|
||||
chart.label AS chart_label
|
||||
FROM acc_years AS year
|
||||
INNER JOIN acc_charts AS chart ON chart.id = year.id_chart
|
||||
WHERE year.id = :year_id;
|
||||
:year_id = $selected_year
|
||||
}}
|
||||
*}}
|
||||
{{*:debug year=$year_label chart=$chart_label*}}
|
||||
{{*
|
||||
{{/select}}
|
||||
*}}
|
||||
|
||||
{{* libellés des comptes d'immobilisation *}}
|
||||
{{:assign condition="("}}
|
||||
{{#foreach from=$config.prefixes item="code"}}
|
||||
{{:assign code=$code|quote_sql}}
|
||||
{{:assign condition=$condition|cat:" account.code = "|cat:$code|cat:" OR "}}
|
||||
{{/foreach}}
|
||||
{{:assign condition=$condition|cat:"0)"}}
|
||||
{{:assign condition=$condition|cat:" AND year.id = %s"|args:$selected_year}}
|
||||
{{*:debug cond=$condition*}}
|
||||
|
||||
{{#select
|
||||
account.id as account_id,
|
||||
account.code,
|
||||
account.id_chart,
|
||||
account.label,
|
||||
year.label as year_label,
|
||||
chart.label as chart_label
|
||||
FROM acc_accounts AS account
|
||||
INNER JOIN acc_charts AS chart ON chart.id = account.id_chart
|
||||
INNER JOIN acc_years AS year ON year.id_chart = chart.id
|
||||
WHERE !condition
|
||||
;
|
||||
!condition=$condition
|
||||
}}
|
||||
{{:assign var="accounts.%s"|args:$code label=$label id=$account_id}}
|
||||
{{*:debug acc_id=$account_id code=$code label=$label year_label=$year_label chart_label=$chart_label*}}
|
||||
{{/select}}
|
||||
{{*:debug accounts=$accounts*}}
|
||||
|
||||
{{*
|
||||
<form method="post" action="">
|
||||
*}}
|
||||
<h3>Comptes d'immobilisation</h3>
|
||||
<form method="post" action="">
|
||||
<table class="list transaction-lines" id="asset_prefixes">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>Compte</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#foreach from=$accounts key=code item=elem}}
|
||||
<tr>
|
||||
<td>
|
||||
{{:assign var="immo_account.%s.%s"|args:$code:$code value="%s — "|args:$code|cat:$elem.label}}
|
||||
{{:assign var="current_account" from="immo_account.%s"|args:$code}}
|
||||
{{*:debug immo_account=$immo_account current_account=$current_account*}}
|
||||
{{:input
|
||||
type="list"
|
||||
name="immo_accounts[]"
|
||||
target="!acc/charts/accounts/selector.php?codes=%s&id_year=%d"|args:$code::$selected_year
|
||||
default=$current_account
|
||||
}}
|
||||
</td>
|
||||
<td class="actions">
|
||||
{{:button
|
||||
label="Enlever"
|
||||
title="Enlever une ligne"
|
||||
shape="minus"
|
||||
min="1"
|
||||
name="remove_line"
|
||||
}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/foreach}}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td class="actions">{{:button shape="plus" label="Ajouter" title="Ajouter un compte"}}</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
{{*
|
||||
<p class="actions">
|
||||
{{:button shape="plus" label="Ajouter" title="Ajouter un compte"}}
|
||||
*}}
|
||||
{{*:button shape="plus" label="Ajouter un compte" onclick="var a = $('#asset_prefixes tbody')[0].lastElementChild; var b = a.cloneNode(true); b.querySelectorAll('input, select').forEach((e) => e.value = null); a.parentNode.append(b);"*}}
|
||||
{{*
|
||||
</p>
|
||||
*}}
|
||||
|
||||
{{*
|
||||
<fieldset>
|
||||
<dl>
|
||||
{{:input
|
||||
type="list"
|
||||
name="immo_account"
|
||||
label="Ajouter un compte d'immobilisation"
|
||||
target="!acc/charts/accounts/selector.php?codes=2*&year=%s"|args:$selected_year
|
||||
}}
|
||||
*}}
|
||||
{{*:input type="checkbox" name="tva" value=1 label="TVA" source=$config help="Cocher si l'asso est assujettie à la TVA"*}}
|
||||
{{*
|
||||
</dl>
|
||||
</fieldset>
|
||||
*}}
|
||||
|
||||
<p class="submit">
|
||||
{{:button type="submit" name="save" label="Enregistrer" shape="right" class="main"}}
|
||||
</p>
|
||||
</form>
|
||||
|
||||
<script type="text/javascript" src="scripts.js"></script>
|
||||
<script type="text/javascript">
|
||||
function remove_line(idtable, code) {
|
||||
let trouve = false, row = null;
|
||||
const table = document.getElementById(idtable);
|
||||
for (let i = 0; i < table.rows.length; ++i) {
|
||||
row = table.rows[i];
|
||||
for (let j = 0; j < row.cells.length; ++j) {
|
||||
const col = row.cells[j];
|
||||
if (col.innerText == code) {
|
||||
trouve = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (trouve) { break; }
|
||||
}
|
||||
if (row != null) {
|
||||
row.parentNode.removeChild(row);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<script type="text/javascript" async="async">
|
||||
|
||||
// bouton - : supprimer une ligne
|
||||
var lines = $('.transaction-lines tbody tr');
|
||||
lines.forEach(initLine);
|
||||
|
||||
// bouton + : dupliquer une ligne
|
||||
$('.transaction-lines tfoot button')[0].onclick = () => {
|
||||
let lines = $('.transaction-lines tbody tr');
|
||||
var line = lines[lines.length - 1];
|
||||
var n = line.cloneNode(true);
|
||||
|
||||
// Réinitialiser le sélecteur de compte
|
||||
let b = n.querySelector('.input-list button');
|
||||
let url = b.value;
|
||||
let new_url = url.replace(/codes=[0-9]+\*?/, "codes=2*");
|
||||
b.value = new_url;
|
||||
|
||||
// gestionnaire d'événement
|
||||
b.onclick = () => {
|
||||
g.current_list_input = b.parentNode;
|
||||
let url = b.value + (b.value.indexOf('?') > 0 ? '&' : '?') + '_dialog';
|
||||
g.openFrameDialog(url);
|
||||
return false;
|
||||
};
|
||||
|
||||
// réinitialiser le label
|
||||
let l = n.querySelector('.input-list span.label');
|
||||
console.log("label=" + l.innerText);
|
||||
l.innerText = '';
|
||||
|
||||
line.parentNode.appendChild(n);
|
||||
initLine(n);
|
||||
|
||||
};
|
||||
</script>
|
||||
|
10
defaut.json
10
defaut.json
|
@ -1,8 +1,8 @@
|
|||
{
|
||||
"tva": false,
|
||||
"prefixes": {
|
||||
"20": "Immobilisations incorporelles",
|
||||
"21": "Immobilisations corporelles",
|
||||
"27": "Immobilisations financières"
|
||||
}
|
||||
"prefixes": [
|
||||
"20",
|
||||
"21",
|
||||
"27"
|
||||
]
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
{{* barre de navigation *}}
|
||||
{{if $_GET.type_immo == null}}
|
||||
{{:assign type_immo="encours"}}
|
||||
{{:assign type_immo="managed"}}
|
||||
{{else}}
|
||||
{{:assign type_immo=$_GET.type_immo}}
|
||||
{{/if}}
|
||||
|
@ -34,11 +34,11 @@
|
|||
{{/select}}
|
||||
{{/load}}
|
||||
|
||||
{{if $type_immo == "autres"}}
|
||||
{{if $type_immo == "other"}}
|
||||
{{:include file="_immobilisations_autres.html"}}
|
||||
{{elseif $type_immo == "archive"}}
|
||||
{{elseif $type_immo == "archived"}}
|
||||
{{:include file="_archives.html"}}
|
||||
{{elseif $type_immo == "encours" || $type_immo == "fini"}}
|
||||
{{elseif $type_immo == "managed" || $type_immo == "amortized"}}
|
||||
{{:include file="_immobilisations.html"}}
|
||||
{{/if}}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
name="Amortissements"
|
||||
description="Gestion des amortissements pour le logiciel de comptabilité Paheko"
|
||||
description="Immobilisations et amortissements"
|
||||
author="Jean-Christophe Engel"
|
||||
author_url="https://gitea.zaclys.com/lesanges"
|
||||
home_button=false
|
||||
|
|
112
other_amortizations.html
Normal file
112
other_amortizations.html
Normal file
|
@ -0,0 +1,112 @@
|
|||
{{* -*- brindille -*- *}}
|
||||
|
||||
{{*
|
||||
Lister les écritures d'amortissement indépendantes
|
||||
et proposer des les attacher à l'immo sélectionnée
|
||||
@param immo_id = id de la ligne d'immo
|
||||
*}}
|
||||
|
||||
{{* récupérer les infos de l'immobilisation *}}
|
||||
{{#select
|
||||
line.id as immo_id,
|
||||
line.debit as montant,
|
||||
trans.id as trans_id,
|
||||
trans.label as label,
|
||||
trans.date
|
||||
FROM acc_transactions_lines AS line
|
||||
INNER JOIN acc_transactions AS trans ON line.id_transaction = trans.id
|
||||
WHERE line.id = :line_id;
|
||||
:line_id = $_GET.immo_id|intval
|
||||
assign=ligne_immo
|
||||
}}
|
||||
{{else}}
|
||||
{{:error message="Immobilisation %s non trouvée"|args:$_GET.immo_id}}
|
||||
{{/select}}
|
||||
|
||||
{{#select
|
||||
line.id as l_id,
|
||||
line.id_transaction as t_id,
|
||||
line.credit as amort_amount,
|
||||
line.label as l_label,
|
||||
trans.date as t_date,
|
||||
trans.label as t_label,
|
||||
trans.id_year as amort_year,
|
||||
account.id as account_id,
|
||||
account.code as account_code,
|
||||
account.label as account_label
|
||||
FROM acc_transactions_lines AS line
|
||||
INNER JOIN acc_accounts AS account ON account.id = line.id_account
|
||||
INNER JOIN acc_transactions AS trans ON trans.id = line.id_transaction
|
||||
INNER JOIN acc_years AS y ON y.id = trans.id_year
|
||||
WHERE account.code LIKE "28%" AND credit > 0 AND (NOT trans.status & 16)
|
||||
ORDER BY trans.date, trans.label;
|
||||
assign=autre_amort
|
||||
}}
|
||||
{{#select
|
||||
id_transaction,
|
||||
id_related
|
||||
FROM acc_transactions_links
|
||||
WHERE id_transaction = :id_amort OR id_related = :id_amort;
|
||||
:id_amort=$t_id
|
||||
}}
|
||||
{{else}}
|
||||
{{:assign var="autres_amortissements." value=$autre_amort}}
|
||||
{{/select}}
|
||||
{{/select}}
|
||||
|
||||
{{:admin_header title="Amortissements non rattachés" custom_css="./style.css" current="module_amortissement"}}
|
||||
|
||||
{{* barre de navigation *}}
|
||||
{{if ! $dialog}}
|
||||
{{:include
|
||||
file="_nav.html"
|
||||
current="index"
|
||||
subcurrent="other"
|
||||
subsubcurrent="amortization"
|
||||
type_immo="other"
|
||||
autres_amort=$autres_amortissements
|
||||
}}
|
||||
{{/if}}
|
||||
|
||||
{{if $autres_amortissements != null}}
|
||||
<section class="amortissement">
|
||||
<h3 class="center-block ruler">Immobilisation « {{$ligne_immo.label}} »</h3>
|
||||
<table class="list">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>N°</th>
|
||||
<th>Date</th>
|
||||
<th class="nombre">Montant</th>
|
||||
<th>Libellé</th>
|
||||
<th>N° compte</th>
|
||||
<th>Compte</th>
|
||||
<th class="actions"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#foreach from=$autres_amortissements item="line"}}
|
||||
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$line.t_id}}
|
||||
{{:assign compte_url="%s/acc/accounts/journal.php?id=%s&year=%s"|args:$admin_url:$line.account_id:$line.amort_year}}
|
||||
<tr>
|
||||
<td class="num"><a href={{$trans_url}}>#{{$line.t_id}}</a></td>
|
||||
<td>{{$line.t_date|date_short}}</td>
|
||||
<td class="money">{{"%f"|math:$line.amort_amount|money}}</td>
|
||||
<td>{{if $line.l_label == null}}
|
||||
{{$line.t_label}}
|
||||
{{else}}
|
||||
{{$line.l_label}}
|
||||
{{/if}}
|
||||
</td>
|
||||
<td><a href={{$compte_url}}>{{$line.account_code}}</a></td>
|
||||
<td>{{$line.account_label}}</td>
|
||||
<td>
|
||||
{{:linkbutton label="Attacher" href="attach_amort.html?amort_id=%d&immo_id=%d"|args:$line.l_id:$_GET.immo_id shape="plus"}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/foreach}}
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
{{/if}}
|
||||
{{:form_errors}}
|
||||
{{:admin_footer}}
|
|
@ -149,8 +149,7 @@
|
|||
*}}
|
||||
{{:read file="./defaut.json" assign="config_json"}}
|
||||
{{:assign config_defaut=$config_json|json_decode}}
|
||||
{{:assign var="prefix_array" value=$config_defaut.prefixes|keys}}
|
||||
{{#foreach from=$prefix_array item="code"}}
|
||||
{{#foreach from=$config_defaut.prefixes item="code"}}
|
||||
{{* déterminer le numéro du compte d'amortissement associé au compte d'immobilisation *}}
|
||||
{{:include
|
||||
file="./_get_amort_code.html"
|
||||
|
@ -214,7 +213,7 @@
|
|||
|
||||
{{* barre de navigation *}}
|
||||
{{if ! $dialog}}
|
||||
{{:include file="_nav.html" current="index" subcurrent="encours" subsubcurrent="amortization"}}
|
||||
{{:include file="_nav.html" current="index" subcurrent="managed" subsubcurrent="amortization"}}
|
||||
{{/if}}
|
||||
|
||||
{{:form_errors}}
|
||||
|
@ -254,7 +253,7 @@
|
|||
{{:input
|
||||
type="list"
|
||||
name="credit_account"
|
||||
label="Compte d'amortissement (280xx ou 281xx)"
|
||||
label="Compte d'amortissement (28xx)"
|
||||
required=true
|
||||
target="!acc/charts/accounts/selector.php?codes=%s&id_year=%d"|args:"28*":$selected_year
|
||||
default=$credit_account
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
},
|
||||
"status" : {
|
||||
"type" : ["string", "null"],
|
||||
"enum" : ["managed", "archived", "ignored"]
|
||||
"enum" : ["managed", "amortized", "archived", "ignored"]
|
||||
}
|
||||
},
|
||||
"required": ["type", "line", "duration", "date"]
|
||||
|
|
18
scripts.js
18
scripts.js
|
@ -139,3 +139,21 @@ function setSelectorYear(button_names, f_years_selector) {
|
|||
const selected_year = document.getElementById(f_years_selector).value;
|
||||
setAccountYear(button_names, selected_year);
|
||||
}
|
||||
|
||||
// config : gestion des ajouts/suppression comptes immo
|
||||
|
||||
function initLine(row) {
|
||||
var removeBtn = row.querySelector('button[name="remove_line"]');
|
||||
removeBtn.onclick = () => {
|
||||
var count = $('.transaction-lines tbody tr').length;
|
||||
var min = removeBtn.getAttribute('min');
|
||||
|
||||
if (count <= min) {
|
||||
alert("Il n'est pas possible d'avoir moins de " + min + " compte(s).");
|
||||
return false;
|
||||
}
|
||||
|
||||
row.parentNode.removeChild(row);
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -41,3 +41,7 @@ h2[class="aide"], h3[class="aide"] {
|
|||
nav.amort aside {
|
||||
margin-top : 0;
|
||||
}
|
||||
|
||||
.describe dt::after {
|
||||
content: ' :';
|
||||
}
|
||||
|
|
|
@ -260,7 +260,7 @@
|
|||
}}
|
||||
{{/if}}
|
||||
|
||||
{{:redirect to="index.html?amort=archive"}}
|
||||
{{:redirect to="index.html?type_immo=archived"}}
|
||||
{{/form}}
|
||||
|
||||
{{:admin_header title="Sortie du bilan" custom_css="./style.css" current="module_amortissement"}}
|
||||
|
@ -311,9 +311,8 @@
|
|||
|
||||
{{:read file="./defaut.json" assign="config_json"}}
|
||||
{{:assign config_defaut=$config_json|json_decode}}
|
||||
{{:assign var="prefix_array" value=$config_defaut.prefixes|keys}}
|
||||
|
||||
{{#foreach from=$prefix_array item="code"}}
|
||||
{{#foreach from=$config_defaut.prefixes item="code"}}
|
||||
{{:assign var="pattern_array." value="%s*"|args:$code}}
|
||||
{{/foreach}}
|
||||
{{:assign patterns=$pattern_array|implode:"|"}}
|
||||
|
|
Loading…
Add table
Reference in a new issue