Compare commits
No commits in common. "main" and "v0.13" have entirely different histories.
24 changed files with 737 additions and 1977 deletions
69
_amort_exclus.html
Normal file
69
_amort_exclus.html
Normal file
|
@ -0,0 +1,69 @@
|
|||
{{* -*- brindille -*- *}}
|
||||
|
||||
{{*
|
||||
Trouver les lignes d'amortissement et d'immobilisation qui sont dans la même écriture
|
||||
- param : aucun
|
||||
- résultat : amort_exclus = tableau des amortissements à exclure
|
||||
*}}
|
||||
|
||||
{{* lignes des immo non amorties *}}
|
||||
{{#load type="immo" where="$$.noamort = true"}}
|
||||
{{:assign var="lines." value="'%s'"|args:$line}}
|
||||
{{/load}}
|
||||
{{:assign lines=$lines|implode:","}}
|
||||
{{:assign lines="("|cat:$lines|cat:")"}}
|
||||
{{:assign condition="line.id IN %s"|args:$lines}}
|
||||
{{*:debug condition=$condition*}}
|
||||
|
||||
{{* écritures et comptes associés *}}
|
||||
{{#select
|
||||
line.id as line_id,
|
||||
line.id_transaction as trans_id,
|
||||
account.id as account_id,
|
||||
account.code as account_code,
|
||||
account.id_chart as id_chart
|
||||
FROM acc_transactions_lines AS line
|
||||
INNER JOIN acc_transactions AS trans on trans.id = line.id_transaction
|
||||
INNER JOIN acc_accounts AS account ON line.id_account = account.id
|
||||
INNER JOIN acc_years AS years ON trans.id_year = years.id
|
||||
WHERE !condition;
|
||||
!condition=$condition
|
||||
assign="ecriture"
|
||||
}}
|
||||
{{:assign var="ecritures." value="'%s'"|args:$trans_id}}
|
||||
{{* déterminer le numéro du compte d'amortissement associé au compte d'immobilisation *}}
|
||||
{{:include
|
||||
file="./_get_amort_code.html"
|
||||
code_immo=$account_code
|
||||
keep="code_amort"
|
||||
}}
|
||||
{{:assign var="accounts." value="'%s'"|args:$code_amort}}
|
||||
{{/select}}
|
||||
{{*:debug ecritures=$ecritures accounts=$accounts*}}
|
||||
|
||||
{{* écritures d'amortissement avec :
|
||||
- numéro d'écritures obtenus ci-dessus
|
||||
- numéros de comptes d'amortissement déduits des comptes d'immo ci-dessus
|
||||
*}}
|
||||
|
||||
{{:assign ecritures=$ecritures|implode:","}}
|
||||
{{:assign ecritures="("|cat:$ecritures|cat:")"}}
|
||||
{{:assign accounts=$accounts|implode:","}}
|
||||
{{:assign accounts="("|cat:$accounts|cat:")"}}
|
||||
{{:assign condition="line.id_transaction IN %s AND account.code IN %s"|args:$ecritures:$accounts}}
|
||||
|
||||
{{#select
|
||||
line.id as line_id,
|
||||
line.id_transaction as trans_id,
|
||||
account.id as account_id,
|
||||
account.code as account_code
|
||||
FROM acc_transactions_lines AS line
|
||||
INNER JOIN acc_transactions AS trans on trans.id = line.id_transaction
|
||||
INNER JOIN acc_accounts AS account ON line.id_account = account.id
|
||||
INNER JOIN acc_years AS years ON trans.id_year = years.id
|
||||
WHERE !condition;
|
||||
!condition=$condition
|
||||
assign="amort"
|
||||
}}
|
||||
{{:assign var="amort_exclus." value=$trans_id}}
|
||||
{{/select}}
|
120
_archives.html
120
_archives.html
|
@ -1,120 +0,0 @@
|
|||
{{* -*- brindille -*- *}}
|
||||
|
||||
{{* Liste des immobilisations archivées *}}
|
||||
|
||||
{{* Immobilisation archivées prises en charge *}}
|
||||
{{#load type="immo" where="$$.status = 'archived'"}}
|
||||
{{:assign var="lines." value="'%s'"|args:$line}}
|
||||
{{/load}}
|
||||
{{:assign lines=$lines|implode:","}}
|
||||
{{:assign lines="("|cat:$lines|cat:")"}}
|
||||
{{:assign condition="line.id IN %s"|args:$lines}}
|
||||
|
||||
{{#select
|
||||
trans.id as trans_id,
|
||||
trans.label as trans_label,
|
||||
trans.date as trans_date,
|
||||
line.id as immo_id,
|
||||
account.id as account_id,
|
||||
account.code as account_code,
|
||||
account.label as account_label,
|
||||
line.debit AS debit,
|
||||
project.label as project_label,
|
||||
trans.id_year as trans_id_year
|
||||
FROM acc_transactions AS trans
|
||||
INNER JOIN acc_transactions_lines AS line ON line.id_transaction = trans.id
|
||||
INNER JOIN acc_accounts AS account ON line.id_account = account.id
|
||||
INNER JOIN acc_years AS years ON trans.id_year = years.id
|
||||
LEFT JOIN acc_projects AS project ON line.id_project = project.id
|
||||
WHERE !condition
|
||||
ORDER BY trans.date DESC;
|
||||
!condition=$condition
|
||||
assign="immo_archivee"
|
||||
}}
|
||||
{{:assign var="immo_archivees.%s"|args:$trans_id value=$immo_archivee}}
|
||||
{{/select}}
|
||||
|
||||
{{* 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"}}
|
||||
{{:assign code=$code|cat:"%"|quote_sql}}
|
||||
{{:assign condition=$condition|cat:"account.code LIKE "|cat:$code|cat:" OR "}}
|
||||
{{/foreach}}
|
||||
{{:assign condition=$condition|cat:"0)"}}
|
||||
{{:assign cond2=$condition|replace:"account.":"acc2."}}
|
||||
{{:assign condition=$condition|cat:" AND "|cat:$cond2}}
|
||||
{{:assign condition=$condition|cat:" AND line.debit > 0 AND NOT (trans.status & 16)"}}
|
||||
|
||||
{{#select
|
||||
trans.id as trans_id,
|
||||
trans.label as trans_label,
|
||||
trans.date as trans_date,
|
||||
line.id as immo_id,
|
||||
account.id as account_id,
|
||||
account.code as account_code,
|
||||
account.label as account_label,
|
||||
line.debit AS debit,
|
||||
project.label as project_label,
|
||||
trans.id_year as trans_id_year
|
||||
FROM acc_transactions AS trans
|
||||
INNER JOIN acc_transactions_lines AS line ON line.id_transaction = trans.id
|
||||
INNER JOIN acc_accounts AS account ON line.id_account = account.id
|
||||
INNER JOIN acc_years AS years ON trans.id_year = years.id
|
||||
INNER JOIN acc_transactions_lines AS line2 ON line.debit = line2.credit
|
||||
INNER JOIN acc_transactions AS trans2 ON trans2.id = line2.id_transaction
|
||||
INNER JOIN acc_accounts AS acc2 ON acc2.id = line2.id_account
|
||||
LEFT JOIN acc_projects AS project ON line.id_project = project.id
|
||||
WHERE !condition
|
||||
ORDER BY trans.date DESC;
|
||||
!condition=$condition
|
||||
assign="immo_archivee"
|
||||
}}
|
||||
{{if ! $trans_id|key_in:$immo_archivees}}
|
||||
{{:assign var="immo_archivees.%s"|args:$trans_id value=$immo_archivee}}
|
||||
{{/if}}
|
||||
{{/select}}
|
||||
|
||||
<section class="immobilisation">
|
||||
<h2 class="ruler">Immobilisations archivées</h2>
|
||||
|
||||
{{:assign nb_immo=0}}
|
||||
<table class="list">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>N°</th>
|
||||
<th>Date</th>
|
||||
<th>Libellé</th>
|
||||
<th class="nombre">Montant</th>
|
||||
<th>N° compte</th>
|
||||
<th>Compte</th>
|
||||
<th>Projet</th>
|
||||
<th class="actions"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#foreach from=$immo_archivees}}
|
||||
{{: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 nb_immo="%d+1"|math:$nb_immo}}
|
||||
<tr>
|
||||
<td class="num"><a href={{$trans_url}}>#{{$trans_id}}</a></td>
|
||||
<td>{{$trans_date|date_short}}</td>
|
||||
<td>{{$trans_label}}</td>
|
||||
<td class="money">{{"%f"|math:$debit|money:false}}</td>
|
||||
<td><a href={{$compte_url}}>{{$account_code}}</a></td>
|
||||
<td>{{$account_label}}</td>
|
||||
<td>{{$project_label}}</td>
|
||||
<td class="actions">
|
||||
</td>
|
||||
</tr>
|
||||
{{/foreach}}
|
||||
</tbody>
|
||||
</table>
|
||||
{{if $nb_immo == 0}}
|
||||
<p class="block alert">Aucune immobilisation</p>
|
||||
{{/if}}
|
||||
</section>
|
|
@ -9,4 +9,13 @@
|
|||
|
||||
{{:assign ts_debut=$date_debut|strtotime}}
|
||||
{{:assign ts_fin=$date_fin|strtotime}}
|
||||
{{:assign nbjours="1+abs(%d-%d)/(60*60*24)"|math:$ts_fin:$ts_debut}}
|
||||
{{: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}}
|
||||
|
|
|
@ -12,10 +12,10 @@
|
|||
- account_ok
|
||||
*}}
|
||||
|
||||
{{:assign quote="'"}}
|
||||
{{:assign condition=" AND ("}}
|
||||
{{#foreach from=$prefix_array item="code"}}
|
||||
{{:assign code=$code|cat:"%"|quote_sql}}
|
||||
{{:assign condition=$condition|cat:" code LIKE "|cat:$code|cat:" OR "}}
|
||||
{{:assign condition=$condition|cat:" code LIKE "|cat:$quote|cat:$code|cat:"%"|cat:$quote|cat:" OR "}}
|
||||
{{/foreach}}
|
||||
{{:assign condition=$condition|cat:"0)"}}
|
||||
|
||||
|
@ -24,10 +24,11 @@
|
|||
select="code"
|
||||
tables="acc_accounts"
|
||||
where="id_chart = :id_chart %s"|args:$condition
|
||||
:id_chart = $chart_id|intval
|
||||
:id_chart = $selected_chart|intval
|
||||
}}
|
||||
{{if $account_code == $code}}
|
||||
{{:assign account_ok=1}}
|
||||
{{:break}}
|
||||
{{/if}}
|
||||
{{/sql}}
|
||||
|
||||
|
|
23
_check_date.html
Normal file
23
_check_date.html
Normal file
|
@ -0,0 +1,23 @@
|
|||
{{* -*- brindille -*- *}}
|
||||
|
||||
{{*
|
||||
vérifier que la date est située dans un exercice ouvert
|
||||
paramètres :
|
||||
- date
|
||||
résultat : open_years, selected_year, selected_chart
|
||||
*}}
|
||||
|
||||
{{:assign open_years=""}}
|
||||
{{#years status=false order="start_date"}}
|
||||
{{:assign open_years=$open_years|cat:"\n"|cat:" - "|cat:$label|cat:" : "}}
|
||||
{{:assign debut=$start_date|date_short}}
|
||||
{{:assign fin=$end_date|date_short}}
|
||||
{{:assign open_years=$open_years|cat:$debut|cat:" à "|cat:$fin}}
|
||||
{{if
|
||||
$start_date|strtotime <= $date|parse_date|strtotime &&
|
||||
$end_date|strtotime >= $date|parse_date|strtotime
|
||||
}}
|
||||
{{:assign selected_year=$id}}
|
||||
{{:assign selected_chart=$id_chart}}
|
||||
{{/if}}
|
||||
{{/years}}
|
|
@ -1,138 +0,0 @@
|
|||
{{* -*- brindille -*- *}}
|
||||
|
||||
{{* Liste des immobilisations non amortissables ou non (encore) gérées *}}
|
||||
|
||||
<section class="immobilisation">
|
||||
<h2 class="ruler">Autres immobilisations</h2>
|
||||
{{:assign nb_immo=0}}
|
||||
|
||||
<table class="list">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>N°</th>
|
||||
<th>Date</th>
|
||||
<th>Libellé</th>
|
||||
<th class="nombre">Montant</th>
|
||||
<th>N° compte</th>
|
||||
<th>Compte</th>
|
||||
<th class="actions"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
{{* 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"}}
|
||||
{{:assign code=$code|cat:"%"|quote_sql}}
|
||||
{{:assign condition=$condition|cat:" account.code LIKE "|cat:$code|cat:" OR "}}
|
||||
{{/foreach}}
|
||||
{{:assign condition=$condition|cat:"0)"}}
|
||||
{{:assign condition=$condition|cat:" AND debit > 0 AND NOT (trans.status & 16)"}}
|
||||
|
||||
{{#select
|
||||
trans.id as trans_id,
|
||||
trans.label as trans_label,
|
||||
trans.date as trans_date,
|
||||
line.id as immo_id,
|
||||
account.id as account_id,
|
||||
account.code as account_code,
|
||||
account.label as account_label,
|
||||
line.debit AS debit,
|
||||
trans.id_year as trans_id_year
|
||||
FROM acc_transactions AS trans
|
||||
INNER JOIN acc_transactions_lines AS line ON line.id_transaction = trans.id
|
||||
INNER JOIN acc_accounts AS account ON line.id_account = account.id
|
||||
INNER JOIN acc_years AS years ON trans.id_year = years.id
|
||||
WHERE !condition
|
||||
ORDER BY trans.date DESC;
|
||||
!condition=$condition
|
||||
}}
|
||||
{{: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"}}
|
||||
{{/load}}
|
||||
{{if $status != "ignored" && $status != "nsp"}}
|
||||
{{:continue}}
|
||||
{{/if}}
|
||||
|
||||
{{* voir s'il existe des écritures d'amortissement associées *}}
|
||||
{{#select
|
||||
sum(l_amort.credit) as amort_amount,
|
||||
CASE links.id_related = t_immo.id
|
||||
WHEN true THEN links.id_transaction
|
||||
WHEN false THEN links.id_related
|
||||
END as amort_trans_id
|
||||
FROM acc_transactions_lines as l_immo
|
||||
INNER JOIN acc_transactions as t_immo on t_immo.id = l_immo.id_transaction
|
||||
INNER JOIN acc_transactions_links as links
|
||||
ON (
|
||||
t_immo.id = links.id_transaction
|
||||
OR
|
||||
t_immo.id = links.id_related
|
||||
)
|
||||
INNER JOIN acc_transactions_lines as l_amort on amort_trans_id = l_amort.id_transaction
|
||||
INNER JOIN acc_accounts AS account ON l_amort.id_account = account.id
|
||||
WHERE
|
||||
l_immo.id = :line_id
|
||||
AND
|
||||
l_amort.credit <> 0
|
||||
AND
|
||||
account.code LIKE '28%';
|
||||
:line_id = $immo_id|intval
|
||||
}}
|
||||
{{if $status == "nsp" && $amort_amount != null}}
|
||||
{{:assign ignore=true}}
|
||||
{{else}}
|
||||
{{:assign ignore=false}}
|
||||
{{/if}}
|
||||
{{/select}}
|
||||
|
||||
{{if $ignore}}
|
||||
{{:continue}}
|
||||
{{/if}}
|
||||
{{:assign nb_immo="%d+1"|math:$nb_immo}}
|
||||
|
||||
<tr>
|
||||
<td class="num"><a href={{$trans_url}}>#{{$trans_id}}</a></td>
|
||||
<td>{{$trans_date|date_short}}</td>
|
||||
<td>{{$trans_label}}</td>
|
||||
<td class="money">{{"%f"|math:$debit|money:false}}</td>
|
||||
<td><a href={{$compte_url}}>{{$account_code}}</a></td>
|
||||
<td>{{$account_label}}</td>
|
||||
<td class="actions">
|
||||
{{if $status == "nsp"}}
|
||||
{{:linkbutton
|
||||
label="Paramètres"
|
||||
href="add_infos.html?immo_id=%s&amort=0&op=new&type_immo=autres"|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
|
||||
shape="settings"
|
||||
target="_dialog"
|
||||
}}
|
||||
{{/if}}
|
||||
{{:linkbutton
|
||||
label="Amortissements"
|
||||
href="amortization.html?immo_id=%s&type_immo=autres"|args:$immo_id
|
||||
shape="table"
|
||||
}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/select}}
|
||||
</tbody>
|
||||
</table>
|
||||
{{if $nb_immo == 0}}
|
||||
<p class="block alert">Aucune immobilisation</p>
|
||||
{{/if}}
|
||||
</section>
|
29
_nav.html
29
_nav.html
|
@ -1,38 +1,25 @@
|
|||
{{* -*- brindille -*- *}}
|
||||
|
||||
<nav class="tabs">
|
||||
{{if $current == 'index' && $subsubcurrent == null}}
|
||||
{{if $current == 'index'}}
|
||||
<aside>
|
||||
{{:linkbutton label="Ajouter une immobilisation" shape="plus" href="add_asset.html" 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>
|
||||
</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>
|
||||
{{if $current == 'index'}}
|
||||
<ul class="sub">
|
||||
<li {{if $subcurrent == 'amort'}}class="current"{{/if}}><a href="index.html?amort=amort">Amortissables</a></li>
|
||||
<li {{if $subcurrent == 'fini'}}class="current"{{/if}}><a href="index.html?amort=fini">Terminées</a></li>
|
||||
<li {{if $subcurrent == 'no_amort'}}class="current"{{/if}}><a href="index.html?amort=no_amort">Non amortissables</a></li>
|
||||
</ul>
|
||||
{{/if}}
|
||||
|
||||
{{if $subsubcurrent == 'amortization'}}
|
||||
<ul class="sub">
|
||||
<li class="title"><strong>Amortissements</strong></li>
|
||||
<li class="current"><a>Amortissements</a></li>
|
||||
</ul>
|
||||
{{elseif $subsubcurrent == 'balance_exit'}}
|
||||
{{*
|
||||
<ul class="sub">
|
||||
<li class="title"><strong>Sortie du bilan</strong></li>
|
||||
</ul>
|
||||
*}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
</nav>
|
||||
|
|
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}}
|
133
add_asset.html
133
add_asset.html
|
@ -1,44 +1,29 @@
|
|||
{{* -*- brindille -*- *}}
|
||||
{{:admin_header title="Ajout immobilisation" current="module_amortissement"}}
|
||||
|
||||
{{: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}}
|
||||
{{:assign ts_fin=$end_date|strtotime}}
|
||||
{{:assign debut=$start_date|date_short}}
|
||||
{{:assign fin=$end_date|date_short}}
|
||||
{{:assign var="years_data.%d"|args:$id value=$ts_debut|cat:" "|cat:$ts_fin}}
|
||||
{{:assign var="open_years.%d"|args:$id value=$label|cat:" ("|cat:$debut|cat:" - "|cat:$fin|cat:")"}}
|
||||
{{if $ts_debut <= $now && $now <= $ts_fin}}
|
||||
{{:assign selected_year=$id}}
|
||||
{{* barre de navigation *}}
|
||||
{{if ! $dialog}}
|
||||
{{:include file="_nav.html" current="index"}}
|
||||
{{/if}}
|
||||
{{/years}}
|
||||
|
||||
{{* Traiter l'envoi du formulaire *}}
|
||||
{{#form on="add"}}
|
||||
{{* vérifier que la date d'achat est située dans un l'exercice sélectionné *}}
|
||||
{{:assign ts_date = $_POST.date_achat|parse_date|strtotime}}
|
||||
{{:assign ok=false}}
|
||||
{{#foreach from=$years}}
|
||||
{{if $id == $_POST.id_year}}
|
||||
{{:assign selected_chart=$id_chart}}
|
||||
{{if $start_date|strtotime <= $ts_date && $ts_date <= $end_date|strtotime}}
|
||||
{{:assign ok=true}}
|
||||
{{:break}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
{{if ! $ok}}
|
||||
{{:error message="La date saisie n'est pas dans l'exercice choisi !"}}
|
||||
|
||||
{{* vérifier que la date est située dans un exercice ouvert *}}
|
||||
{{:include
|
||||
file="_check_date.html"
|
||||
date=$_POST.date_achat
|
||||
keep="open_years, selected_year, selected_chart"
|
||||
}}
|
||||
{{if $selected_year == null}}
|
||||
{{:error message="La date choisie n'est dans aucun exercice ouvert !!\nExercices ouverts : %s"|args:$open_years}}
|
||||
{{/if}}
|
||||
|
||||
{{if ! $_POST.amortir}}
|
||||
{{if $_POST.no_amort}}
|
||||
{{* ne pas amortir *}}
|
||||
{{:assign duration=0}}
|
||||
{{:assign date_debut=$_POST.date_achat|parse_date}}
|
||||
{{:assign status="ignored"}}
|
||||
{{:assign date_debut=$ligne_immo.date_achat|parse_date}}
|
||||
{{:assign noamort=true}}
|
||||
{{else}}
|
||||
{{* vérifier que la date d'acquisition est antérieure à la date de mise en service *}}
|
||||
{{:assign date_debut=$_POST.date_mes|or:$_POST.date_achat|parse_date}}
|
||||
|
@ -48,7 +33,7 @@
|
|||
{{: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}}
|
||||
{{:assign status="managed"}}
|
||||
{{:assign noamort=false}}
|
||||
{{/if}}
|
||||
|
||||
{{* déterminer le numéro des comptes au cas où la clé serait un identifiant *}}
|
||||
|
@ -70,6 +55,10 @@
|
|||
- est présent dans le PC de l'exercice correspondant à la date
|
||||
*}}
|
||||
|
||||
{{:read file="./defaut.json" assign="config_json"}}
|
||||
{{:assign config_defaut=$config_json|json_decode}}
|
||||
{{:assign var="prefix_array" value=$config_defaut.prefixes|keys}}
|
||||
|
||||
{{:include
|
||||
file="_check_account.html"
|
||||
account=$debit_account
|
||||
|
@ -88,7 +77,7 @@
|
|||
method="POST"
|
||||
path="accounting/transaction"
|
||||
assign="result"
|
||||
id_year=$_POST.id_year
|
||||
id_year=$selected_year
|
||||
type="revenue"
|
||||
date=$_POST.date_achat
|
||||
label=$_POST.designation
|
||||
|
@ -114,79 +103,55 @@
|
|||
line=$immo_id
|
||||
duration=$duration
|
||||
date=$date_debut
|
||||
status=$status
|
||||
noamort=$noamort
|
||||
}}
|
||||
{{if $_POST.amortir}}
|
||||
{{:assign amort="encours"}}
|
||||
{{if $_POST.no_amort}}
|
||||
{{:assign amort=0}}
|
||||
{{else}}
|
||||
{{:assign amort="autres"}}
|
||||
{{:assign amort=1}}
|
||||
{{/if}}
|
||||
{{:redirect force="index.html?ok=1&msg=immobilisation&amort=%s"|args:$amort}}
|
||||
{{/form}}
|
||||
|
||||
{{:admin_header title="Ajout immobilisation" current="module_amortissement"}}
|
||||
{{* barre de navigation *}}
|
||||
{{if ! $dialog}}
|
||||
{{:include file="_nav.html" current="index"}}
|
||||
{{/if}}
|
||||
|
||||
{{:form_errors}}
|
||||
|
||||
{{* formulaire d'ajout d'immobilisation *}}
|
||||
|
||||
{{:assign var="bank_account.512" value="512 — Banques"}}
|
||||
{{: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"}}
|
||||
{{:assign var="pattern_array." value="%s*"|args:$code}}
|
||||
{{/foreach}}
|
||||
{{:assign patterns=$pattern_array|implode:"|"}}
|
||||
|
||||
<div id="erreur" class="hidden">
|
||||
<p class="block error">La date choisie n'est dans aucun exercice ouvert !</p>
|
||||
</div>
|
||||
|
||||
<form method="post" action="">
|
||||
<fieldset>
|
||||
<legend>Données de l'immobilisation</legend>
|
||||
<legend>Ajouter une immobilisation</legend>
|
||||
<dl>
|
||||
{{:input type="select" name="id_year" label="Exercice" default=$selected_year required=true default_empty="— Faire un choix —" options=$open_years}}
|
||||
{{:input id="no_amort" type="checkbox" value=1 name="no_amort" label="Ne pas amortir" help="Cocher pour ne pas amortir" onclick="toggleInputs('f_no_amort_1', ['f_date_mes','f_duree'])"}}
|
||||
{{:input type="date" name="date_achat" label="Date d'acquisition" required=true default=$now|date_short}}
|
||||
{{:input type="date" name="date_mes" label="Date de mise en service" help="à renseigner uniquement si différente de la date d'acquisition"}}
|
||||
{{:input type="text" name="designation" label="Désignation" required=true}}
|
||||
{{:input type="money" name="montant" label="Montant" required=true}}
|
||||
{{:input type="number" name="duree" label="Durée d'amortissement" required=true min=0 default=1}}
|
||||
{{:input
|
||||
type="list"
|
||||
name="credit_account"
|
||||
label="Compte de décaissement"
|
||||
required=true
|
||||
target="!acc/charts/accounts/selector.php?types=%s&id_year=%d"|args:"1|2|3":$selected_year
|
||||
target="!acc/charts/accounts/selector.php?targets=1:2:3&key=code"
|
||||
default=$bank_account
|
||||
}}
|
||||
{{:input
|
||||
type="list"
|
||||
name="debit_account"
|
||||
label="Compte d'immobilisation"
|
||||
label="Compte d'immobilisation (20xx, 21xx, ...)"
|
||||
required=true
|
||||
target="!acc/charts/accounts/selector.php?codes=%s&id_year=%d"|args:$patterns:$selected_year
|
||||
target="!acc/charts/accounts/selector.php?key=code"
|
||||
default=$immo_account
|
||||
}}
|
||||
{{if $projects != null}}
|
||||
{{:input type="select" name="id_project" label="Projet (analytique)" options=$projects default_empty="— Aucun —"}}
|
||||
{{/if}}
|
||||
<div id="donnees" class="hidden">
|
||||
{{:input type="select" name="years_data" options=$years_data}}
|
||||
</div>
|
||||
</dl>
|
||||
</fieldset>
|
||||
<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"}}
|
||||
<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"}}
|
||||
</div>
|
||||
</dl>
|
||||
</fieldset>
|
||||
|
||||
|
@ -195,21 +160,21 @@
|
|||
</p>
|
||||
|
||||
</form>
|
||||
{{:admin_footer}}
|
||||
|
||||
<script type="text/javascript" src="scripts.js"></script>
|
||||
{{* activer/désactiver les champs passés en paramètres *}}
|
||||
<script type="text/javascript">
|
||||
|
||||
function changeYear(evt, f_accounts = ['credit_account', 'debit_account'], f_years_select = 'f_id_year') {
|
||||
setSelectorYear(f_accounts, f_years_select);
|
||||
function toggleInputs(idcb, idfields) {
|
||||
const noamort = document.getElementById(idcb);
|
||||
for (let id of idfields) {
|
||||
const field = document.getElementById(id);
|
||||
if (noamort.checked) {
|
||||
field.setAttribute("disabled","disabled");
|
||||
}
|
||||
else {
|
||||
field.removeAttribute("disabled");
|
||||
}
|
||||
}
|
||||
|
||||
function changeVisibility(evt, idcheck = 'f_amortir_1', fields = ['div_amort']) {
|
||||
toggleVisibility(idcheck, fields);
|
||||
}
|
||||
|
||||
(function () {
|
||||
document.getElementById('f_id_year').onchange = changeYear;
|
||||
document.getElementById('f_amortir_1').onclick = changeVisibility;
|
||||
})();
|
||||
</script>
|
||||
|
||||
{{:admin_footer}}
|
||||
|
|
|
@ -1,36 +1,32 @@
|
|||
{{* -*- brindille -*- *}}
|
||||
|
||||
{{*
|
||||
@param immo_id
|
||||
@param amort = 1 si immo amortissable, 0 si non
|
||||
@param op = new ou modif
|
||||
@param type_immo : encours, archive, fini, autre
|
||||
*}}
|
||||
{{:admin_header title="Renseigner informations amortissement" custom_css=$custom_css current="module_amortissement"}}
|
||||
|
||||
{{if $_GET.op == "modif"}}
|
||||
{{#load type="immo" assign="info_immo" where="$$.line = :line_id" :line_id=$_GET.immo_id|intval}}
|
||||
{{/load}}
|
||||
{{* barre de navigation *}}
|
||||
{{if ! $dialog}}
|
||||
{{:include file="_nav.html" current="index"}}
|
||||
{{/if}}
|
||||
|
||||
{{* Traiter l'envoi du formulaire *}}
|
||||
{{#form on="save"}}
|
||||
{{#form on="add"}}
|
||||
|
||||
{{* chercher la date d'acquisition de l'immobilisation *}}
|
||||
{{:assign var="immo_id" value=$_GET.immo_id|intval}}
|
||||
{{#select
|
||||
trans.date as date_achat
|
||||
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
|
||||
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 = $immo_id
|
||||
assign=ligne_immo
|
||||
}}
|
||||
{{/select}}
|
||||
|
||||
{{if ! $_POST.amortir}}
|
||||
{{if $_POST.no_amort}}
|
||||
{{* ne pas amortir *}}
|
||||
{{:assign duration=0}}
|
||||
{{:assign date_debut=$ligne_immo.date_achat|parse_date}}
|
||||
{{:assign status="ignored"}}
|
||||
{{:assign noamort=true}}
|
||||
{{else}}
|
||||
{{* vérifier que la date d'acquisition est antérieure à la date de mise en service *}}
|
||||
{{:assign date_debut=$_POST.date_mes|or:$ligne_immo.date_achat|parse_date}}
|
||||
|
@ -43,74 +39,51 @@
|
|||
{{if $duration <= 0}}
|
||||
{{:error message="Erreur : la durée d'amortissement doit être strictement positive"}}
|
||||
{{/if}}
|
||||
{{:assign status="managed"}}
|
||||
{{:assign noamort=false}}
|
||||
{{/if}}
|
||||
|
||||
{{* enregistrer les infos de l'immobilisation *}}
|
||||
{{if $_GET.op == "new"}}
|
||||
{{:assign key=""|uuid}}
|
||||
{{else}}
|
||||
{{:assign key=$info_immo.key}}
|
||||
{{/if}}
|
||||
{{:save
|
||||
key=$key
|
||||
validate_schema="schema.json"
|
||||
type="immo"
|
||||
line=$_GET.immo_id|intval
|
||||
line=$immo_id
|
||||
duration=$duration
|
||||
date=$date_debut
|
||||
status=$status
|
||||
noamort=$noamort
|
||||
}}
|
||||
|
||||
{{if ! $_POST.amortir}}
|
||||
{{:assign type_immo="autres"}}
|
||||
{{if $_POST.no_amort}}
|
||||
{{:assign amort=0}}
|
||||
{{else}}
|
||||
{{:assign type_immo=$_GET.type_immo}}
|
||||
{{:assign amort=1}}
|
||||
{{/if}}
|
||||
{{:redirect force="index.html?ok=1&msg=infos&type_immo=%s"|args:$type_immo}}
|
||||
{{:redirect force="index.html?ok=1&msg=infos&amort=%s"|args:$amort}}
|
||||
{{else}}
|
||||
{{:form_errors}}
|
||||
{{/form}}
|
||||
|
||||
{{:admin_header title="Renseigner informations amortissement" custom_css=$custom_css current="module_amortissement"}}
|
||||
|
||||
{{* barre de navigation *}}
|
||||
{{if ! $dialog}}
|
||||
{{:include file="_nav.html" current="index"}}
|
||||
{{/if}}
|
||||
|
||||
{{* renseigner ou modifier la date de mise en service et la durée d'amortissement *}}
|
||||
{{* renseigner la date de mise en service et durée d'amortissement *}}
|
||||
{{if $_GET.amort == 0}}
|
||||
{{:assign checked=0}}
|
||||
{{:assign checked=1}}
|
||||
{{:assign disabled=1}}
|
||||
{{else}}
|
||||
{{:assign checked=1}}
|
||||
{{:assign checked=0}}
|
||||
{{:assign disabled=0}}
|
||||
{{/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')"}}
|
||||
{{if $info_immo != null}}
|
||||
{{:assign date_defaut=$info_immo.date}}
|
||||
{{:assign duree_defaut=$info_immo.duration}}
|
||||
{{else}}
|
||||
{{:assign duree_defaut=1}}
|
||||
{{/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"}}
|
||||
{{: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="number" name="duree" label="Durée d'amortissement" required=true min=1 default=1 disabled=$disabled}}
|
||||
</dl>
|
||||
</fieldset>
|
||||
|
||||
<p class="submit">
|
||||
{{:button type="submit" name="save" label="Enregistrer" shape="right" class="main"}}
|
||||
{{:button type="submit" name="add" label="Ajouter" shape="right" class="main"}}
|
||||
</p>
|
||||
|
||||
</form>
|
||||
|
@ -118,11 +91,11 @@
|
|||
{{* activer/désactiver les champs de saisie *}}
|
||||
<script type="text/javascript">
|
||||
function toggleInputs(idfs, idcb) {
|
||||
const amortir = document.getElementById(idcb);
|
||||
const noamort = document.getElementById(idcb);
|
||||
const fs = document.getElementById(idfs);
|
||||
for (let field of fs.querySelectorAll("input")) {
|
||||
if (field == amortir) { continue }
|
||||
if (! amortir.checked) {
|
||||
if (field == noamort) { continue }
|
||||
if (noamort.checked) {
|
||||
field.setAttribute("disabled","disabled");
|
||||
}
|
||||
else {
|
||||
|
|
90
aide.html
90
aide.html
|
@ -10,28 +10,41 @@
|
|||
</p>
|
||||
|
||||
<h2 class="aide">Immobilisations</h2>
|
||||
Elles sont classées dans plusieurs onglets :
|
||||
Elles sont classées dans 3 onglets :
|
||||
|
||||
<h3 class="aide">Amortissables</h3>
|
||||
|
||||
On y trouve les immobilisations en cours et celles pour lesquelles le
|
||||
module n'a pas d'information.
|
||||
|
||||
<p class="aide">
|
||||
Dans le deuxième cas, il faut cliquer sur le bouton « Ajouter
|
||||
infos » puis :
|
||||
<ul class="aide">
|
||||
<li><strong>En cours</strong> : immobilisations en cours d'amortissement.</li>
|
||||
<li><strong>Terminées</strong> : immobilisations dont l'amortissement est terminé.</li>
|
||||
<li><strong>Archivées</strong> : immobilisations qui ont été sortie du bilan.</li>
|
||||
<li><strong>Autres</strong> : immobilisations pour lesquelles le module n'a pas
|
||||
d'information ou qui ont été marquées non amortissables.</li>
|
||||
<li>soit indiquer que l'immobilisation ne doit pas être amortie</li>
|
||||
<li>soit fournir la date de mise en service du bien (si différente de la date d'acquisition) ainsi
|
||||
que la durée en années de l'amortissement</li>
|
||||
</ul>
|
||||
</p>
|
||||
<p class="aide">
|
||||
Tant qu'une immobilisation ne possède pas d'amortissement, il est
|
||||
possible de modifier ses informations à l'aide du bouton «
|
||||
Modifier infos ».
|
||||
</p>
|
||||
|
||||
<h3 class="aide">Terminées</h3>
|
||||
|
||||
On y trouve les immobilisations dont l'amortissement est terminé
|
||||
|
||||
<h3 class="aide">Non amortissables</h3>
|
||||
|
||||
<h3 class="aide">Ajouter une immobilisation</h3>
|
||||
|
||||
<div class="aide">
|
||||
<p class="aide">
|
||||
Il faut renseigner les informations de l'immobilisation.
|
||||
On peut indiquer qu'il s'agit d'une immobilisation qui ne doit
|
||||
pas être amortie ; dans le cas contraire, il faut renseigner
|
||||
les différents paramètres de l'immobilisation
|
||||
On peut indiquer qu'il s'agit d'une immobilisation qui ne doit pas être amortie ; dans le cas contraire, il faut renseigner les différents paramètres de l'immobilisation :
|
||||
</p>
|
||||
<!--
|
||||
<ul class="aide">
|
||||
<li>Date d'acquisition du bien</li>
|
||||
<li>Date d'acquisition du bien</li>
|
||||
<li>Date de mise en service du bien : uniquement si différente de la précédente</li>
|
||||
<li>Désignation : c'est le libellé de l'immobilisation</li>
|
||||
|
@ -44,10 +57,9 @@ Elles sont classées dans plusieurs onglets :
|
|||
<p>
|
||||
Après ajout, on se retrouve sur la page d'accueil des immobilisations.
|
||||
</p>
|
||||
-->
|
||||
</div>
|
||||
|
||||
<h3 class="aide">Amortissements</h2>
|
||||
<h2 class="aide">Amortissements</h2>
|
||||
|
||||
<div class="infos">
|
||||
<p class="aide">
|
||||
|
@ -66,7 +78,7 @@ Elles sont classées dans plusieurs onglets :
|
|||
On trouve ici de une à trois listes, selon la situation :
|
||||
<ul class="aide">
|
||||
<li>
|
||||
<b>Amortissements enregistrés</b>
|
||||
<b>Écritures d'amortissement liées à l'immobilisation courante</b>
|
||||
<p>
|
||||
Ce sont des écritures d'amortissement déjà
|
||||
enregistrées et liées à l'écriture de
|
||||
|
@ -74,11 +86,11 @@ Elles sont classées dans plusieurs onglets :
|
|||
</p>
|
||||
</li>
|
||||
<li>
|
||||
<b>Amortissements futurs</b>
|
||||
<b>Écritures d'amortissements à enregistrer</b>
|
||||
<p>
|
||||
Ce sont les écritures amortissement de
|
||||
l'immobilisation courante qui n'ont pas encore été
|
||||
enregistrées ; seuls les amortissements d'un
|
||||
enregistrées ; seules les amortissements d'un
|
||||
exercice ouvert peuvent être enregistrés ; les
|
||||
autres sont présents pour information et pourront
|
||||
être enregistrés quand l'exercice correspondant
|
||||
|
@ -86,14 +98,13 @@ Elles sont classées dans plusieurs onglets :
|
|||
</p>
|
||||
</li>
|
||||
<li>
|
||||
<b>Autres amortissement non rattachés</b>
|
||||
<b>Écritures d'amortissement qui ne sont associées à aucune immobilisation</b>
|
||||
<p>
|
||||
Ce sont des écritures passées sur un compte
|
||||
d'amortissement (<b>28xx</b>) qui ne sont
|
||||
associées à aucune écriture d'immobilisation ; en
|
||||
cliquant le bouton « Attacher », on peut rattacher
|
||||
l'écriture d'amortissement sélectionnée à
|
||||
l'immobilisation courante.
|
||||
d'amortissement (<b>28xx</b>) ; en cliquant le
|
||||
bouton « Attacher », on peut rattacher l'écriture
|
||||
d'amortissement sélectionnée à l'immobilisation
|
||||
courante.
|
||||
</p>
|
||||
<p>
|
||||
Si on a rattaché par erreur une écriture
|
||||
|
@ -115,22 +126,15 @@ Elles sont classées dans plusieurs onglets :
|
|||
<li>Désignation : déterminée à partir du libellé de l'immobilisation< ; elle peut être modifiée/li>
|
||||
<li>Montant : sa valeur est calculée par le module ; elle peut être modifiée</li>
|
||||
<li>
|
||||
Compte de débit : à choisir dans la liste ; par défaut
|
||||
c'est le compte <em>6811 : Dotation aux amortissements
|
||||
des immobilisations</em>
|
||||
Compte de débit : à choisir dans la liste ; par défaut c'est le compte <em>6811 : Dotation aux amortissements des immobilisations</em>
|
||||
</li>
|
||||
<li>
|
||||
Compte d'amortissement : à choisir dans la liste ; par
|
||||
défaut c'est le compte formé en intercalant un 8 après
|
||||
le 2 initial du compte d'immobilisation (exemple :
|
||||
2183 => 28183)
|
||||
Compte d'amortissement : à choisir dans la liste ; par défaut c'est le compte formé en intercalant un 8 après le 2 initial du compte d'immobilisation (exemple : 2183 => 28183)
|
||||
</li>
|
||||
</ul>
|
||||
<!--
|
||||
<p class="aide">
|
||||
Après enregistrement, on se retrouve sur la page des amortissements
|
||||
</p>
|
||||
-->
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
@ -143,21 +147,9 @@ Elles sont classées dans plusieurs onglets :
|
|||
si leurs écritures ont été liées ; dans le cas contraire, il
|
||||
faudra renseigner manuellement les infos de l'immobilisation.
|
||||
</li>
|
||||
<li>
|
||||
Les écritures d'immobilisation de la balance d'ouverture ne
|
||||
peuvent être détectées automatiquement : il faudra indiquer
|
||||
manuellement qu'elles ne doivent pas être amorties.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p class="aide">
|
||||
Dans le deuxième cas, il faut cliquer sur le bouton « Ajouter
|
||||
infos » puis :
|
||||
<ul class="aide">
|
||||
<li>soit indiquer que l'immobilisation ne doit pas être amortie</li>
|
||||
<li>soit fournir la date de mise en service du bien (si différente de la date d'acquisition) ainsi
|
||||
que la durée en années de l'amortissement</li>
|
||||
</ul>
|
||||
</p>
|
||||
<p class="aide">
|
||||
Tant qu'une immobilisation ne possède pas d'amortissement, il est
|
||||
possible de modifier ses informations à l'aide du bouton «
|
||||
Modifier infos ».
|
||||
</p>
|
||||
|
||||
|
|
|
@ -1,89 +1,22 @@
|
|||
{{* -*- brindille -*- *}}
|
||||
|
||||
{{* 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}}
|
||||
{{:assign date_debut=$ligne_immo.date}}
|
||||
{{:assign solde=$ligne_immo.montant}}
|
||||
|
||||
{{#load type="immo" where="$$.line = :line_id" :line_id=$_GET.immo_id|intval}}
|
||||
{{:assign duree=$duration}}
|
||||
{{:assign date_debut=$date}}
|
||||
{{/load}}
|
||||
|
||||
{{* chercher des écritures d'amortissement liées à l'immobilisation *}}
|
||||
{{#select
|
||||
l_amort.credit as amort_amount,
|
||||
l_amort.label as amort_label,
|
||||
l_amort.id as amort_line,
|
||||
CASE WHEN links.id_related = t_immo.id
|
||||
THEN links.id_transaction
|
||||
ELSE links.id_related
|
||||
END as amort_trans_id,
|
||||
trans.date as amort_date,
|
||||
trans.label as trans_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 l_immo
|
||||
INNER JOIN acc_transactions as t_immo on t_immo.id = l_immo.id_transaction
|
||||
INNER JOIN acc_transactions_links as links
|
||||
ON (t_immo.id = links.id_transaction
|
||||
OR
|
||||
t_immo.id = links.id_related)
|
||||
INNER JOIN acc_transactions_lines as l_amort on amort_trans_id = l_amort.id_transaction
|
||||
INNER join acc_transactions as trans on l_amort.id_transaction = trans.id
|
||||
INNER join acc_accounts as account on l_amort.id_account = account.id
|
||||
WHERE
|
||||
l_immo.id = :line_id
|
||||
AND account.code LIKE '28%'
|
||||
ORDER BY trans.date;
|
||||
:line_id = $_GET.immo_id|intval
|
||||
assign=linked_lines.
|
||||
}}
|
||||
{{if $date_debut == null}}
|
||||
{{:assign date_debut=$amort_date}}
|
||||
{{/if}}
|
||||
{{/select}}
|
||||
|
||||
{{:assign valeur_residuelle=$ligne_immo.montant}}
|
||||
{{#foreach from=$linked_lines}}
|
||||
{{:assign valeur_residuelle="%d-%d"|math:$valeur_residuelle:$amort_amount}}
|
||||
{{/foreach}}
|
||||
|
||||
{{:admin_header title="Liste des amortissements" custom_css="./style.css" current="module_amortissement"}}
|
||||
|
||||
{{* barre de navigation *}}
|
||||
{{if $_GET.type_immo == "fini" || $valeur_residuelle== 0 }}
|
||||
{{if $_GET.amort == null || $_GET.amort == "amort"}}
|
||||
{{:assign subcurrent="amort"}}
|
||||
{{elseif $_GET.amort == "fini"}}
|
||||
{{:assign subcurrent="fini"}}
|
||||
{{elseif $_GET.type_immo == "archive"}}
|
||||
{{:assign subcurrent="archive"}}
|
||||
{{elseif $_GET.type_immo == null || $_GET.type_immo == "encours"}}
|
||||
{{:assign subcurrent="encours"}}
|
||||
{{else}}
|
||||
{{:assign subcurrent="autres"}}
|
||||
{{:assign subcurrent="no_amort"}}
|
||||
{{/if}}
|
||||
{{:include file="_nav.html" current="index" subcurrent="%s"|args:$subcurrent subsubcurrent="amortization"}}
|
||||
|
||||
{{if $_GET.ok}}
|
||||
{{if $_GET.msg|match:"attach"}}
|
||||
{{:assign msg="Attachement écriture %s effectué"|args:$_GET.trans_id}}
|
||||
{{:assign msg="Attachement effectué (écriture %s)"|args:$_GET.trans_id}}
|
||||
{{elseif $_GET.msg|match:"detach"}}
|
||||
{{:assign msg="Détachement écriture %s affectué"|args:$_GET.trans_id}}
|
||||
{{:assign msg="Attachement supprimé (écriture %s)"|args:$_GET.trans_id}}
|
||||
{{elseif $_GET.msg|match:"amortissement"}}
|
||||
{{:assign msg="Amortissement enregistré"}}
|
||||
{{/if}}
|
||||
|
@ -97,49 +30,104 @@
|
|||
<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
|
||||
shape="export"
|
||||
class="main"
|
||||
{{* récupérer les infos de l'immobilisation *}}
|
||||
{{#select
|
||||
line.id as immo_id,
|
||||
line.id_account as account_id,
|
||||
line.id_project as project_id,
|
||||
line.debit as montant,
|
||||
trans.id as trans_id,
|
||||
trans.label as label,
|
||||
y.id as year_id,
|
||||
y.end_date as date_amort,
|
||||
project.label as project_label
|
||||
from acc_transactions_lines as line
|
||||
inner join acc_transactions as trans on line.id_transaction = trans.id
|
||||
inner join acc_years as y on trans.id_year = y.id
|
||||
left join acc_projects AS project ON line.id_project = project.id
|
||||
where line.id = :line_id;
|
||||
:line_id = $_GET.immo_id|intval
|
||||
assign=ligne_immo
|
||||
}}
|
||||
</p>
|
||||
<p class="help">
|
||||
Il sera possible de choisir la date de sortie, d'indiquer
|
||||
le montant de la cession le cas échéant et de modifier les
|
||||
comptes associés.
|
||||
</p>
|
||||
</fieldset>
|
||||
</form>
|
||||
{{else}}
|
||||
{{:error message="Immobilisation %s non trouvée"|args:$_GET.immo_id}}
|
||||
{{/select}}
|
||||
|
||||
<dl class="describe">
|
||||
<dt>Libellé</dt>
|
||||
<dd>{{$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>
|
||||
<dd>{{$date_debut|date_short}}</dd>
|
||||
{{if $duree != null}}
|
||||
<dt>Durée</dt>
|
||||
<dd>{{$duree}} ans</dd>
|
||||
{{#load type="immo" assign="info_immo" where="$$.line = :line_id" :line_id=$_GET.immo_id|intval}}
|
||||
{{:assign var="duree" from="info_immo.duration"|args:$_GET.immo_id}}
|
||||
{{:assign date_debut=$info_immo.date}}
|
||||
{{/load}}
|
||||
|
||||
{{* chercher des écritures d'amortissement liées à l'immobilisation *}}
|
||||
{{#select
|
||||
l_amort.credit as amort_amount,
|
||||
l_amort.label as amort_label,
|
||||
l_amort.id as amort_line,
|
||||
CASE links.id_related = t_immo.id
|
||||
WHEN true THEN links.id_transaction
|
||||
WHEN false THEN links.id_related
|
||||
END as amort_trans_id,
|
||||
trans.date as amort_date,
|
||||
trans.label as trans_label,
|
||||
trans.id_year as amort_year,
|
||||
acc.id as account_id,
|
||||
acc.code as account_code,
|
||||
acc.label as account_name
|
||||
FROM
|
||||
acc_transactions_lines as l_immo
|
||||
INNER JOIN acc_transactions as t_immo on t_immo.id = l_immo.id_transaction
|
||||
INNER JOIN acc_transactions_links as links
|
||||
ON (
|
||||
t_immo.id = links.id_transaction
|
||||
OR
|
||||
t_immo.id = links.id_related
|
||||
)
|
||||
INNER JOIN acc_transactions_lines as l_amort on amort_trans_id = l_amort.id_transaction
|
||||
INNER join acc_transactions as trans on l_amort.id_transaction = trans.id
|
||||
INNER join acc_accounts as acc on l_amort.id_account = acc.id
|
||||
WHERE
|
||||
l_immo.id = :line_id
|
||||
AND
|
||||
l_amort.credit <> 0
|
||||
ORDER BY trans.date;
|
||||
:line_id = $_GET.immo_id|intval
|
||||
assign=linked_lines.
|
||||
}}
|
||||
{{:assign var="amort_years." value=$amort_year}}
|
||||
{{if $date_debut == null}}
|
||||
{{:assign date_debut=$amort_date}}
|
||||
{{/if}}
|
||||
</dl>
|
||||
{{/select}}
|
||||
|
||||
<h3 class="center-block ruler">Amortissements enregistrés</h3>
|
||||
<h2>Amortissement de « {{$ligne_immo.label}} » d'un montant de {{"%f"|math:$ligne_immo.montant|money_currency}} en date du {{$date_debut|date_short}}{{if $duree != null}} sur {{$duree}} ans{{/if}}</h2>
|
||||
|
||||
{{if $duree != null}}
|
||||
{{* 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}}
|
||||
{{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 nbamort=0}}
|
||||
{{/if}}
|
||||
|
||||
{{:assign solde=$ligne_immo.montant}}
|
||||
{{if $linked_lines != null}}
|
||||
<section class="amortissement">
|
||||
<h3 class="ruler">
|
||||
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|date_short}})
|
||||
</h3>
|
||||
<table class="list">
|
||||
<thead>
|
||||
<tr>
|
||||
|
@ -159,6 +147,8 @@
|
|||
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$line.amort_trans_id}}
|
||||
{{:assign compte_url="%s/acc/accounts/journal.php?id=%s&year=%s"|args:$admin_url:$line.account_id:$line.amort_year}}
|
||||
{{:assign solde="%f-%d"|math:$solde:$line.amort_amount}}
|
||||
{{:assign date_amort=$line.amort_date}}
|
||||
{{:assign current_year=$line.amort_year}}
|
||||
<tr>
|
||||
<td class="num"><a href={{$trans_url}}>#{{$line.amort_trans_id}}</a></td>
|
||||
<td>{{$line.amort_date|date_short}}</td>
|
||||
|
@ -172,56 +162,125 @@
|
|||
{{/if}}
|
||||
</td>
|
||||
<td><a href={{$compte_url}}>{{$line.account_code}}</a></td>
|
||||
<td>{{$line.account_label}}</td>
|
||||
<td>{{$line.account_name}}</td>
|
||||
<td>
|
||||
{{:linkbutton label="Détacher" href="detach_amort.html?amort_id=%d&immo_id=%d"|args:$line.amort_line:$ligne_immo.immo_id shape="minus"}}
|
||||
{{:linkbutton label="Détacher" href="detach_amort.html?amort_id=%d&immo_id=%d"|args:$line.amort_line:$ligne_immo.immo_id shape="plus"}}
|
||||
</td>
|
||||
</tr>
|
||||
{{:assign annuite_courante=$annuite}}
|
||||
{{:include file="_next_year.html" date=$date_amort keep="date_amort"}}
|
||||
{{:assign nbamort="%d+1"|math:$nbamort}}
|
||||
{{/foreach}}
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
{{else}}
|
||||
<p class="block alert">Aucun amortissement enregistré pour cette immobilisation</p>
|
||||
{{/if}}
|
||||
|
||||
{{if $_GET.type_immo == null || $_GET.type_immo != "fini"}}
|
||||
{{if $duree != null && $solde > 0}}
|
||||
{{:assign project_id=$ligne_immo.project_id}}
|
||||
{{:assign project_label=$ligne_immo.project_label}}
|
||||
{{:assign nbamort="%d-%d"|math:$duree:$nbamort}}
|
||||
{{:assign annuite_courante="min(%f,%f)"|math:$annuite_courante:$solde}}
|
||||
<section class="amortissement">
|
||||
<h3 class="ruler">Amortissements à enregistrer</h3>
|
||||
<table class="list">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>N°</th>
|
||||
<th>Date</th>
|
||||
<th class="nombre">Montant</th>
|
||||
<th class="nombre">Solde</th>
|
||||
<th>Libellé</th>
|
||||
<th class="actions"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#foreach count="%d+1"|math:$nbamort key="num"}}
|
||||
{{:assign solde_prec=$solde}}
|
||||
{{:assign solde="%f-%d"|math:$solde:$annuite_courante}}
|
||||
{{#select id from acc_years where :amort_date >= start_date and :amort_date <= end_date and status == 0; :amort_date=$date_amort|parse_date}}
|
||||
{{:assign enregistrer=1}}
|
||||
{{:assign current_year=$id}}
|
||||
{{else}}
|
||||
{{:assign enregistrer=0}}
|
||||
{{/select}}
|
||||
<tr>
|
||||
<td class="num">{{"%d+1"|math:$num}}</td>
|
||||
<td>{{$date_amort|date_short}}</td>
|
||||
<td class="money">{{"%f"|math:$annuite_courante|money}}</td>
|
||||
<td class="money">{{$solde|money:false}}</td>
|
||||
<td>
|
||||
{{if $libelle == null}}
|
||||
{{:assign libelle="Amortissement "|cat:$ligne_immo.label}}
|
||||
{{/if}}
|
||||
{{$libelle}}
|
||||
</td>
|
||||
<td class="actions">
|
||||
{{if $enregistrer == 1}}
|
||||
{{:linkbutton
|
||||
label="Créer l'écriture"
|
||||
href="save_amort.html?amount=%d&account=%s&year=%s&trans_id=%d&immo_id=%s&project_id=%d&label=%s&solde=%d"|args:$annuite_courante:$ligne_immo.account_id:$current_year:$ligne_immo.trans_id:$_GET.immo_id:$project_id:$libelle:$solde_prec
|
||||
shape="right"
|
||||
target="_dialog"
|
||||
}}
|
||||
{{/if}}
|
||||
</td>
|
||||
</tr>
|
||||
{{: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}}
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
{{/if}}
|
||||
|
||||
{{if $_GET.amort == null || $_GET.amort != "fini"}}
|
||||
|
||||
{{* amortissement à exclure *}}
|
||||
{{:include
|
||||
file="_amort_exclus.html"
|
||||
keep="amort_exclus"
|
||||
}}
|
||||
|
||||
{{* 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,
|
||||
li.id as l_id,
|
||||
li.id_transaction as t_id,
|
||||
li.credit as montant,
|
||||
li.reference,
|
||||
li.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;
|
||||
acc.code as a_code,
|
||||
acc.label as a_label,
|
||||
y.label as y_label
|
||||
from acc_transactions_lines as li
|
||||
inner join acc_accounts as acc on acc.id = li.id_account
|
||||
inner join acc_transactions as trans on trans.id = li.id_transaction
|
||||
inner join acc_years as y on y.id = trans.id_year
|
||||
where acc.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;
|
||||
from acc_transactions_links
|
||||
where id_transaction = :id_amort or id_related = :id_amort;
|
||||
:id_amort=$t_id
|
||||
}}
|
||||
{{else}}
|
||||
{{if $autre_amort.t_id|in:$amort_exclus}}
|
||||
{{else}}
|
||||
{{:assign var="autres_amortissements." value=$autre_amort}}
|
||||
{{/if}}
|
||||
{{/select}}
|
||||
{{/select}}
|
||||
|
||||
{{if $autres_amortissements != null}}
|
||||
<section class="amortissement">
|
||||
<h3 class="center-block ruler">Amortissements non rattachés</h3>
|
||||
<h3 class="ruler">Autres amortissements non rattachés</h3>
|
||||
<table class="list">
|
||||
<thead>
|
||||
<tr>
|
||||
|
@ -235,21 +294,21 @@
|
|||
</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 class="money">{{"%f"|math:$line.montant|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>{{$line.a_code}}</td>
|
||||
<td>{{$line.a_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>
|
||||
|
|
|
@ -1,220 +0,0 @@
|
|||
{{* -*- brindille -*- *}}
|
||||
|
||||
{{*
|
||||
Sortir une immobilisation du bilan
|
||||
@param immo_id : id de la ligne d'immobilisation
|
||||
*}}
|
||||
|
||||
{{* Infos de l'immobilisation *}}
|
||||
{{#select
|
||||
line.debit as montant,
|
||||
trans.date as date_achat,
|
||||
trans.label
|
||||
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}}
|
||||
|
||||
{{:assign date_debut=$ligne_immo.date_achat}}
|
||||
{{:assign ts_mes=$ligne_immo.date_achat|strtotime}}
|
||||
|
||||
{{#load type="immo" assign="info_immo" where="$$.line = :line_id" :line_id=$_GET.immo_id|intval}}
|
||||
{{:assign ts_mes=$date|strtotime}}
|
||||
{{:assign date_debut=$date}}
|
||||
{{:assign duree_amort=$duration}}
|
||||
{{/load}}
|
||||
|
||||
{{* chercher des écritures d'amortissement liées à l'immobilisation *}}
|
||||
{{#select
|
||||
SUM(l_amort.credit) as amort_amount,
|
||||
CASE
|
||||
WHEN links.id_related = t_immo.id
|
||||
THEN links.id_transaction
|
||||
ELSE links.id_related
|
||||
END as amort_trans_id,
|
||||
MAX(trans.date) as last_amort_date,
|
||||
MIN(trans.date) as first_amort_date,
|
||||
COUNT(trans.id) as amort_number
|
||||
FROM acc_transactions_lines as l_immo
|
||||
INNER JOIN acc_transactions as t_immo on t_immo.id = l_immo.id_transaction
|
||||
INNER JOIN acc_transactions_links as links
|
||||
ON (t_immo.id = links.id_transaction
|
||||
OR
|
||||
t_immo.id = links.id_related)
|
||||
INNER JOIN acc_transactions_lines as l_amort on amort_trans_id = l_amort.id_transaction
|
||||
INNER join acc_transactions as trans on l_amort.id_transaction = trans.id
|
||||
INNER JOIN acc_accounts AS account ON l_amort.id_account = account.id
|
||||
WHERE l_immo.id = :line_id AND account.code LIKE '28%'
|
||||
LIMIT 1;
|
||||
:line_id = $_GET.immo_id|intval
|
||||
assign=amort_line
|
||||
}}
|
||||
{{/select}}
|
||||
|
||||
{{if $amort_line.amort_number == 0}}
|
||||
{{:assign amort_amount=0}}
|
||||
{{else}}
|
||||
{{:assign amort_amount=$amort_line.amort_amount}}
|
||||
{{:assign date_debut=$amort_line.last_amort_date|strtotime}}
|
||||
{{:assign date_debut="%d+(60*60*24)"|math:$date_debut|date:"Y-m-d"}}
|
||||
{{/if}}
|
||||
{{:assign ts_debut=$date_debut|strtotime}}
|
||||
{{:assign valeur_nette="%f-%f"|math:$ligne_immo.montant:$amort_amount}}
|
||||
|
||||
{{*
|
||||
lister les exercices qui englobent la date de début du prochain amortissement
|
||||
*}}
|
||||
{{:assign default_exit_date=""}}
|
||||
{{#years closed=false order="start_date" where="start_date <= :debut AND :debut <= end_date"
|
||||
:debut=$date_debut assign=years.}}
|
||||
{{if $start_date|strtotime <= $now && $now <= $end_date|strtotime}}
|
||||
{{:assign default_exit_date=$now|date_short}}
|
||||
{{/if}}
|
||||
{{:assign ts_fin=$end_date|strtotime}}
|
||||
{{: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}}
|
||||
{{if $years|count == 1}}
|
||||
{{:assign default_year=$years.0.id}}
|
||||
{{else}}
|
||||
{{:assign default_year=""}}
|
||||
{{/if}}
|
||||
|
||||
{{* Traiter l'envoi du formulaire *}}
|
||||
{{#form on="proceed"}}
|
||||
|
||||
{{if $_POST.date_sortie == null}}
|
||||
{{:error message="Vous devez renseigner la date de sortie"}}
|
||||
{{/if}}
|
||||
|
||||
{{* vérifier la validité de la date de mise en service *}}
|
||||
{{if $_POST.date_mes != null}}
|
||||
{{:assign ts_mes=$_POST.date_mes|parse_date|strtotime}}
|
||||
{{if $ts_mes < $ligne_immo.date_achat|strtotime || $ts_mes > $amort_line.first_amort_date|strtotime}}
|
||||
{{:assign immo_date=$ligne_immo.date_achat|date_short}}
|
||||
{{:assign amort_date=$amort_line.first_amort_date|date_short}}
|
||||
{{:error message="La date de mise en service doit être postérieure à la date d'acquisition de l'immobilisation (%s) et antérieure à la date du premier amortissement (%s)"|args:$immo_date:$amort_date}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
{{* vérifier la validité de la durée d'immobilisation *}}
|
||||
{{if $valeur_nette > 0}}
|
||||
{{if $info_immo.duration == null}}
|
||||
{{if $_POST.duree == null}}
|
||||
{{:error message="Vous devez renseigner la durée de l'immobilisation"}}
|
||||
{{elseif $_POST.duree < $amort_line.amort_number}}
|
||||
{{:error message="La durée de l'amortissement ne peut être inférieure au nombre d'écritures d'amortissement (%d)"|args:$amort_line.amort_number}}
|
||||
{{else}}
|
||||
{{:assign duree_amort=$_POST.duree}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
{{* vérifier la validité de la date de sortie *}}
|
||||
{{if $info_immo.date != null}}
|
||||
{{if $_POST.date_sortie|parse_date < $info_immo.date}}
|
||||
{{:assign immo_date=$info_immo.date|date_short}}
|
||||
{{:error message="La date de sortie doit être postérieure à la date de mise en service de l'immobilisation (%s)"|args:$immo_date}}
|
||||
{{/if}}
|
||||
{{elseif $_POST.date_mes != null}}
|
||||
{{if $_POST.date_sortie|parse_date < $_POST.date_mes|parse_date}}
|
||||
{{:error message="La date de sortie doit être postérieure à la date de mise en service de l'immobilisation (%s)"|args:$_POST.date_mes}}
|
||||
{{/if}}
|
||||
{{elseif $_POST.date_sortie|parse_date < $ligne_immo.date_achat}}
|
||||
{{:assign immo_date=$ligne_immo.date_achat|date_short}}
|
||||
{{:error message="La date de sortie doit être postérieure à la date d'acquisition de l'immobilisation (%s)"|args:$immo_date}}
|
||||
{{/if}}
|
||||
{{if $amort_line.amort_number != 0 && $_POST.date_sortie|parse_date <= $amort_line.last_amort_date}}
|
||||
{{:assign last_amort_date=$amort_line.last_amort_date|date_short}}
|
||||
{{:error message="La date de sortie doit être postérieure à la date de la dernière immobilisation (%s)"|args:$last_amort_date}}
|
||||
{{/if}}
|
||||
|
||||
{{* 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}}
|
||||
{{#foreach from=$years}}
|
||||
{{if $id == $_POST.id_year}}
|
||||
{{:assign selected_year=$id}}
|
||||
{{if $start_date|strtotime <= $ts_exit && $ts_exit <= $end_date|strtotime}}
|
||||
{{:assign ok=true}}
|
||||
{{:break}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
{{if ! $ok}}
|
||||
{{:error message="La date choisie n'est pas dans l'exercice sélectionné !"}}
|
||||
{{/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="balance_exit"}}
|
||||
{{/if}}
|
||||
{{:form_errors}}
|
||||
|
||||
{{* formulaire de sortie du bilan *}}
|
||||
<h3>Sortir l'immobilisation « {{$ligne_immo.label}} » du bilan</h3>
|
||||
<form method="post" action="">
|
||||
|
||||
<div class="informations">
|
||||
<legend>Données de l'imobilisation</legend>
|
||||
<dl class="describe">
|
||||
<dt>Montant</dt>
|
||||
<dd id="montant_immo" class="money">{{$ligne_immo.montant|money_currency:false}}</dd>
|
||||
<dt>Date d'acquisition</dt>
|
||||
<dd >{{$ligne_immo.date_achat|date_short}}</dd>
|
||||
{{if $info_immo.date != null && $info_immo.date != $ligne_immo.date_achat}}
|
||||
<dt>Date de mise en service</dt>
|
||||
<dd>{{$info_immo.date|date_short}}</dd>
|
||||
{{/if}}
|
||||
{{if $info_immo.duration != null}}
|
||||
<dt>Durée de l'amortissement</dt>
|
||||
<dd id="duree_amort" class="num">{{$info_immo.duration}} ans</dd>
|
||||
{{/if}}
|
||||
<dt>Montant des amortissements</dt>
|
||||
<dd id="montant_amort" class="money">{{$amort_amount|money_currency:false}} <span class="help">(à la date de début de l'exercice)</span></dd>
|
||||
<dt>Valeur nette résiduelle</dt>
|
||||
<dd class="money">{{$valeur_nette|money_currency:false}} <span class="help">(à la date de début de l'exercice)</span></dd>
|
||||
</dl>
|
||||
</div>
|
||||
{{if $valeur_nette > 0}}
|
||||
{{if $info_immo.date == null || $info_immo.duration == null}}
|
||||
<fieldset>
|
||||
<legend>Informations sur l'immobilisation</legend>
|
||||
<dl>
|
||||
{{if $info_immo.date == null}}
|
||||
{{: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"}}
|
||||
{{/if}}
|
||||
{{if $info_immo.duration == null}}
|
||||
{{:input type="number" name="duree" label="Durée d'amortissement" required=true min=1 help="La durée est nécessaire pour calculer l'amortissement complémentaire"}}
|
||||
{{/if}}
|
||||
</dl>
|
||||
</fieldset>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
<fieldset>
|
||||
<legend>Informations de sortie</legend>
|
||||
<dl>
|
||||
{{:input type="select" default=$default_year name="id_year" label="Exercice" required=true default_empty="— Faire un choix —" options=$open_years}}
|
||||
{{:input type="date" name="date_sortie" label="Date de sortie du bilan" required=true default=$default_exit_date}}
|
||||
</dl>
|
||||
</fieldset>
|
||||
|
||||
<p class="submit">
|
||||
{{:button type="submit" name="proceed" label="Poursuivre" shape="right" class="main"}}
|
||||
</p>
|
||||
</form>
|
||||
|
||||
{{:admin_footer}}
|
|
@ -1,132 +0,0 @@
|
|||
{{* -*- brindille -*- *}}
|
||||
|
||||
{{*
|
||||
Calculer les valeurs de la sortie et saisir le montant de la cession (optionnel)
|
||||
paramètres :
|
||||
- immo_id : numéro de ligne de l'écriture d'immobilisation
|
||||
- amort_amount : montant des amortissements
|
||||
- year : exercice de la date de sortie de l'immobilisation
|
||||
- date_mes : datede mise en service de l'immobilisation
|
||||
- date_debut : date de début de la période d'amortissement complémentaire
|
||||
- exit_date : date de sortie de l'immobilisation
|
||||
- duree_amort : durée de l'amortiseement (optionnel)
|
||||
*}}
|
||||
|
||||
{{#select
|
||||
line.debit as montant,
|
||||
trans.date as date_achat,
|
||||
trans.label
|
||||
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}}
|
||||
|
||||
{{:assign valeur_nette="%f-%f"|math:$ligne_immo.montant:$_GET.amort_amount}}
|
||||
{{:assign amort_comp=0}} {{* amortissement complémentaire jqà date sortie *}}
|
||||
{{if $valeur_nette > 0}}
|
||||
{{:assign nbjours="1+(%d-%d)/(60*60*24)"|math:$_GET.exit_date:$_GET.date_debut}}
|
||||
{{:assign annuite="%f/%f"|math:$ligne_immo.montant:$_GET.duree_amort}}
|
||||
{{:assign amort_comp="round(%f/365*%f, 0)"|math:$annuite:$nbjours}}
|
||||
{{:assign amort_comp="min(%f, %f)"|math:$valeur_nette:$amort_comp}}
|
||||
{{/if}}
|
||||
|
||||
{{* Traiter l'envoi du formulaire *}}
|
||||
{{#form on="proceed"}}
|
||||
{{if $_POST.cession != null}}
|
||||
{{if $_POST.montant_cession == null}}
|
||||
{{:error message="Vous devez saisir le montant de la cession"}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
{{:redirect to="write_exit.html?immo_id=%s&amort_amount=%s&year=%s&date_mes=%s&date_debut=%s&exit_date=%s&duree_amort=%s&cession=%s"|args:$_GET.immo_id:$_GET.amort_amount:$_GET.year:$_GET.date_mes:$_GET.date_debut:$_GET.exit_date:$_GET.duree_amort:$_POST.montant_cession}}
|
||||
|
||||
{{/form}}
|
||||
{{:admin_header title="Sortie du bilan" custom_css="./style.css" current="module_amortissement"}}
|
||||
|
||||
{{* barre de navigation *}}
|
||||
{{if ! $dialog}}
|
||||
{{:include file="_nav.html" current="index" subcurrent="balance_exit"}}
|
||||
{{/if}}
|
||||
|
||||
{{:form_errors}}
|
||||
|
||||
<h3>Sortir l'immobilisation « {{$ligne_immo.label}} » du bilan</h3>
|
||||
<form method="post" action="">
|
||||
|
||||
<div class="informations">
|
||||
<legend>Données de l'imobilisation</legend>
|
||||
<dl class="describe">
|
||||
<dt>Montant</dt>
|
||||
<dd id="montant_immo" class="money">{{$ligne_immo.montant|money_currency:false}}</dd>
|
||||
<dt>Date d'acquisition</dt>
|
||||
<dd >{{$ligne_immo.date_achat|date_short}}</dd>
|
||||
{{if $_GET.date_mes != $ligne_immo.date_achat|strtotime}}
|
||||
<dt>Date de mise en service</dt>
|
||||
<dd>{{$_GET.date_mes|date:"d/m/Y"}}</dd>
|
||||
{{/if}}
|
||||
{{if $_GET.duree_amort != null}}
|
||||
<dt>Durée de l'amortissement</dt>
|
||||
<dd id="duree_amort" class="num">{{$_GET.duree_amort}} ans</dd>
|
||||
{{/if}}
|
||||
<dt>Montant des amortissements</dt>
|
||||
<dd id="montant_amort" class="money">{{$_GET.amort_amount|money_currency:false}} <span class="help">(à la date de début de l'exercice)</span></dd>
|
||||
<dt>Valeur nette résiduelle</dt>
|
||||
<dd class="money">{{$valeur_nette|money_currency:false}} <span class="help">(à la date de début de l'exercice)</span></dd>
|
||||
<dt>Date de sortie</dt>
|
||||
<dd>{{$_GET.exit_date|date:"d/m/Y"}}</dd>
|
||||
{{if $amort_comp > 0}}
|
||||
<dt>Amortissement complémentaire</dt>
|
||||
<dd class="money">{{$amort_comp|money_currency:false}} <span class="help">(jusqu'à la date de sortie)</span></dd>
|
||||
<dt>Total des amortissements</dt>
|
||||
<dd class="money">{{"%f+%f"|math:$_GET.amort_amount:$amort_comp|money_currency:false}} <span class="help">(à la date de sortie)</span></dd>
|
||||
<dt>Valeur nette résiduelle</dt>
|
||||
<dd class="money">{{"%f-%f"|math:$valeur_nette:$amort_comp|money_currency:false}} <span class="help">(à la date de sortie)</span></dd>
|
||||
{{/if}}
|
||||
</dl>
|
||||
</div>
|
||||
<fieldset>
|
||||
<legend>Informations de sortie</legend>
|
||||
<dl>
|
||||
{{:input type="checkbox" value=1 name="cession" label="Cession" help="Cocher si la sortie est due à une cession" onclick="toggleHiddenAndFocus('f_cession_1', ['infos_cession'], 'f_montant_cession')"}}
|
||||
<div id="infos_cession" class="hidden">
|
||||
{{:input type="money" name="montant_cession" label="Montant de la cession" required=true}}
|
||||
</div>
|
||||
</dl>
|
||||
</fieldset>
|
||||
|
||||
<p class="submit">
|
||||
{{:button type="submit" name="proceed" label="Poursuivre" shape="right" class="main"}}
|
||||
</p>
|
||||
|
||||
</form>
|
||||
|
||||
<script type="text/javascript">
|
||||
/*
|
||||
- activer/désactiver les champs passés en paramètres
|
||||
- donner le focus au champ de saisie du montant
|
||||
*/
|
||||
function toggleHiddenAndFocus(idcb, idfields, idinput) {
|
||||
const cession = document.getElementById(idcb);
|
||||
for (let id of idfields) {
|
||||
const field = document.getElementById(id);
|
||||
if (cession.checked) {
|
||||
field.setAttribute("class", "");
|
||||
document.getElementById(idinput).focus();
|
||||
}
|
||||
else {
|
||||
field.setAttribute("class","hidden")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
(function () {
|
||||
toggleHiddenAndFocus('f_cession_1', ['infos_cession'], 'f_montant_cession');
|
||||
})();
|
||||
</script>
|
||||
|
||||
{{:admin_footer}}
|
|
@ -3,12 +3,11 @@
|
|||
{{* Liste des immobilisations amortissable ou à définir *}}
|
||||
|
||||
<section class="immobilisation">
|
||||
{{if $type_immo == "encours"}}
|
||||
{{if $amort == "amort"}}
|
||||
<h2 class="ruler">Immobilisations en cours</h2>
|
||||
{{elseif $type_immo == "fini"}}
|
||||
{{else}}
|
||||
<h2 class="ruler">Immobilisations amorties</h2>
|
||||
{{/if}}
|
||||
{{:assign nb_immo=0}}
|
||||
|
||||
<table class="list">
|
||||
<thead>
|
||||
|
@ -20,6 +19,7 @@
|
|||
<th class="nombre">Durée</th>
|
||||
<th>N° compte</th>
|
||||
<th>Compte</th>
|
||||
<th>Projet</th>
|
||||
<th class="actions"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
@ -29,10 +29,10 @@
|
|||
{{:read file="./defaut.json" assign="config_json"}}
|
||||
{{:assign config_defaut=$config_json|json_decode}}
|
||||
{{:assign var="prefix_array" value=$config_defaut.prefixes|keys}}
|
||||
{{:assign quote="'"}}
|
||||
{{:assign condition="("}}
|
||||
{{#foreach from=$prefix_array item="code"}}
|
||||
{{:assign code=$code|cat:"%"|quote_sql}}
|
||||
{{:assign condition=$condition|cat:" account.code LIKE "|cat:$code|cat:" OR "}}
|
||||
{{:assign condition=$condition|cat:" account.code LIKE "|cat:$quote|cat:$code|cat:"%"|cat:$quote|cat:" OR "}}
|
||||
{{/foreach}}
|
||||
{{:assign condition=$condition|cat:"0)"}}
|
||||
{{:assign condition=$condition|cat:" AND debit > 0 AND NOT (trans.status & 16)"}}
|
||||
|
@ -46,11 +46,13 @@
|
|||
account.code as account_code,
|
||||
account.label as account_label,
|
||||
line.debit AS debit,
|
||||
project.label as project_label,
|
||||
trans.id_year as trans_id_year
|
||||
FROM acc_transactions AS trans
|
||||
INNER JOIN acc_transactions_lines AS line ON line.id_transaction = trans.id
|
||||
INNER JOIN acc_accounts AS account ON line.id_account = account.id
|
||||
INNER JOIN acc_years AS years ON trans.id_year = years.id
|
||||
LEFT JOIN acc_projects AS project ON line.id_project = project.id
|
||||
WHERE !condition
|
||||
ORDER BY trans.date DESC;
|
||||
!condition=$condition
|
||||
|
@ -61,7 +63,7 @@
|
|||
{{* 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"}}
|
||||
{{if $noamort}}
|
||||
{{:assign amortissable="non"}}
|
||||
{{else}}
|
||||
{{:assign amortissable="oui"}}
|
||||
|
@ -72,32 +74,6 @@
|
|||
{{if $amortissable == "non"}}
|
||||
{{:continue}}
|
||||
{{/if}}
|
||||
|
||||
{{* voir s'il existe une écriture qui solde l'immobilisation *}}
|
||||
{{:assign ignore=false}}
|
||||
{{#select
|
||||
line.id AS line,
|
||||
line.id_transaction AS trans,
|
||||
line.debit,
|
||||
line.label,
|
||||
line2.id AS line2,
|
||||
line2.id_transaction AS trans2,
|
||||
line2.credit,
|
||||
line2.label
|
||||
FROM acc_transactions_lines AS line
|
||||
INNER JOIN acc_accounts AS acc ON acc.id = line.id_account
|
||||
INNER JOIN acc_transactions_lines AS line2 ON line2.id_account = acc.id
|
||||
WHERE
|
||||
line.id = :line_id
|
||||
AND line2.credit = line.debit;
|
||||
:line_id = $immo_id|intval
|
||||
}}
|
||||
{{:assign ignore=true}}
|
||||
{{/select}}
|
||||
{{if $ignore}}
|
||||
{{:continue}}
|
||||
{{/if}}
|
||||
|
||||
{{* voir s'il existe des écritures d'amortissement associées *}}
|
||||
{{#select
|
||||
sum(l_amort.credit) as amort_amount,
|
||||
|
@ -114,13 +90,10 @@
|
|||
t_immo.id = links.id_related
|
||||
)
|
||||
INNER JOIN acc_transactions_lines as l_amort on amort_trans_id = l_amort.id_transaction
|
||||
INNER JOIN acc_accounts AS account ON l_amort.id_account = account.id
|
||||
WHERE
|
||||
l_immo.id = :line_id
|
||||
AND
|
||||
l_amort.credit <> 0
|
||||
AND
|
||||
account.code LIKE '28%';
|
||||
l_amort.credit <> 0;
|
||||
:line_id = $immo_id|intval
|
||||
}}
|
||||
{{if $amort_amount == null}}
|
||||
|
@ -131,15 +104,12 @@
|
|||
{{:assign exist_amort=true}}
|
||||
{{/if}}
|
||||
{{/select}}
|
||||
|
||||
{{* classement par onglet *}}
|
||||
{{if $type_immo == "encours" && $amort_amount >= $debit ||
|
||||
$type_immo == "fini" && $amort_amount < $debit ||
|
||||
$amortissable == "nsp" && ! $exist_amort
|
||||
{{* immo amortie ? *}}
|
||||
{{if $amort == "amort" && $amort_amount >= $debit ||
|
||||
$amort == "fini" && $amort_amount < $debit
|
||||
}}
|
||||
{{:continue}}
|
||||
{{/if}}
|
||||
{{:assign nb_immo="%d+1"|math:$nb_immo}}
|
||||
<tr>
|
||||
<td class="num"><a href={{$trans_url}}>#{{$trans_id}}</a></td>
|
||||
<td>{{$trans_date|date_short}}</td>
|
||||
|
@ -148,33 +118,33 @@
|
|||
<td class="money">{{if $duration != null}}{{$duration}}{{/if}}</td>
|
||||
<td><a href={{$compte_url}}>{{$account_code}}</a></td>
|
||||
<td>{{$account_label}}</td>
|
||||
<td>{{$project_label}}</td>
|
||||
<td class="actions">
|
||||
{{if ! $exist_amort}}
|
||||
{{if ! $exist_amort && $duration == null}}
|
||||
{{:linkbutton
|
||||
label="Paramètres"
|
||||
href="add_infos.html?immo_id=%s&amort=1&op=modif&type_immo=%s"|args:$immo_id:$type_immo
|
||||
shape="settings"
|
||||
label="Ajouter infos"
|
||||
href="add_infos.html?immo_id=%s&amort=1"|args:$immo_id
|
||||
shape="help"
|
||||
target="_dialog"
|
||||
}}
|
||||
{{elseif $amortissable == "nsp"}}
|
||||
{{else}}
|
||||
{{if ! $exist_amort}}
|
||||
{{:linkbutton
|
||||
label="Paramètres"
|
||||
href="add_infos.html?immo_id=%s&amort=1&op=new&type_immo=%s"|args:$immo_id:$type_immo
|
||||
shape="settings"
|
||||
label="Modifier infos"
|
||||
href="modif_infos.html?immo_id=%s&amort=1"|args:$immo_id
|
||||
shape="help"
|
||||
target="_dialog"
|
||||
}}
|
||||
{{/if}}
|
||||
{{:linkbutton
|
||||
label="Amortissements"
|
||||
href="amortization.html?immo_id=%s&type_immo=%s"|args:$immo_id:$type_immo
|
||||
href="amortization.html?immo_id=%s&amort=%s"|args:$immo_id:$amort
|
||||
shape="table"
|
||||
}}
|
||||
{{/if}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/select}}
|
||||
</tbody>
|
||||
</table>
|
||||
{{if $nb_immo == 0}}
|
||||
<p class="block alert">Aucune immobilisation</p>
|
||||
{{/if}}
|
||||
</section>
|
71
immobilisations_non.html
Normal file
71
immobilisations_non.html
Normal file
|
@ -0,0 +1,71 @@
|
|||
{{* -*- brindille -*- *}}
|
||||
|
||||
{{* Liste des immobilisations non amortissable *}}
|
||||
|
||||
<section class="immobilisation">
|
||||
<h2 class="ruler">Immobilisations non amortissables</h2>
|
||||
|
||||
<table class="list">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>N°</th>
|
||||
<th>Date</th>
|
||||
<th>Libellé</th>
|
||||
<th class="nombre">Montant</th>
|
||||
<th>N° compte</th>
|
||||
<th>Compte</th>
|
||||
<th>Projet</th>
|
||||
<th class="actions"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
{{#load type="immo" where="$$.noamort = true"}}
|
||||
{{:assign var="lines." value="'%s'"|args:$line}}
|
||||
{{/load}}
|
||||
{{:assign lines=$lines|implode:","}}
|
||||
{{:assign lines="("|cat:$lines|cat:")"}}
|
||||
{{:assign condition="line.id IN %s"|args:$lines}}
|
||||
{{#select
|
||||
trans.id as trans_id,
|
||||
trans.label as trans_label,
|
||||
trans.date as trans_date,
|
||||
line.id as immo_id,
|
||||
account.id as account_id,
|
||||
account.code as account_code,
|
||||
account.label as account_label,
|
||||
line.debit AS debit,
|
||||
project.label as project_label,
|
||||
trans.id_year as trans_id_year
|
||||
FROM acc_transactions AS trans
|
||||
INNER JOIN acc_transactions_lines AS line ON line.id_transaction = trans.id
|
||||
INNER JOIN acc_accounts AS account ON line.id_account = account.id
|
||||
INNER JOIN acc_years AS years ON trans.id_year = years.id
|
||||
LEFT JOIN acc_projects AS project ON line.id_project = project.id
|
||||
WHERE !condition
|
||||
ORDER BY trans.date DESC;
|
||||
!condition=$condition
|
||||
}}
|
||||
{{: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}}
|
||||
<tr>
|
||||
<td class="num"><a href={{$trans_url}}>#{{$trans_id}}</a></td>
|
||||
<td>{{$trans_date|date_short}}</td>
|
||||
<td>{{$trans_label}}</td>
|
||||
<td class="money">{{"%f"|math:$debit|money:false}}</td>
|
||||
<td><a href={{$compte_url}}>{{$account_code}}</a></td>
|
||||
<td>{{$account_label}}</td>
|
||||
<td>{{$project_label}}</td>
|
||||
<td class="actions">
|
||||
{{:linkbutton
|
||||
label="Modifier infos"
|
||||
href="modif_infos.html?immo_id=%s&amort=0"|args:$immo_id
|
||||
shape="help"
|
||||
target="_dialog"
|
||||
}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/select}}
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
23
index.html
23
index.html
|
@ -1,14 +1,14 @@
|
|||
{{* -*- brindille -*- *}}
|
||||
{{:admin_header title="Immobilisations et amortissements" custom_css="./style.css" current="module_amortization"}}
|
||||
{{:admin_header title="Gestion des amortissements" custom_css="./style.css" current="module_amortissement"}}
|
||||
|
||||
{{* barre de navigation *}}
|
||||
{{if $_GET.type_immo == null}}
|
||||
{{:assign type_immo="encours"}}
|
||||
{{if $_GET.amort == null}}
|
||||
{{:assign amort="amort"}}
|
||||
{{else}}
|
||||
{{:assign type_immo=$_GET.type_immo}}
|
||||
{{:assign amort=$_GET.amort}}
|
||||
{{/if}}
|
||||
|
||||
{{:include file="_nav.html" current="index" subcurrent="%s"|args:$type_immo}}
|
||||
{{:include file="_nav.html" current="index" subcurrent="%s"|args:$amort}}
|
||||
|
||||
{{if $_GET.ok}}
|
||||
{{if $_GET.msg|match:"immobilisation"}}
|
||||
|
@ -21,11 +21,12 @@
|
|||
<p class="block error">Échec enregistrement immobilisation</p>
|
||||
{{/if}}
|
||||
|
||||
{{#load type="immo"}}
|
||||
{{* supprimer les documents sans écriture associée *}}
|
||||
{{#load type="immo"}}
|
||||
{{#select
|
||||
line.id as line_id
|
||||
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 = $line
|
||||
}}
|
||||
|
@ -34,12 +35,10 @@
|
|||
{{/select}}
|
||||
{{/load}}
|
||||
|
||||
{{if $type_immo == "autres"}}
|
||||
{{:include file="_immobilisations_autres.html"}}
|
||||
{{elseif $type_immo == "archive"}}
|
||||
{{:include file="_archives.html"}}
|
||||
{{elseif $type_immo == "encours" || $type_immo == "fini"}}
|
||||
{{:include file="_immobilisations.html"}}
|
||||
{{if $amort == "no_amort"}}
|
||||
{{:include file="./immobilisations_non.html"}}
|
||||
{{else}}
|
||||
{{:include file="./immobilisations.html"}}
|
||||
{{/if}}
|
||||
|
||||
{{:admin_footer}}
|
||||
|
|
113
modif_infos.html
Normal file
113
modif_infos.html
Normal file
|
@ -0,0 +1,113 @@
|
|||
{{* -*- brindille -*- *}}
|
||||
|
||||
{{:admin_header title="Modifier informations amortissement" custom_css=$custom_css current="module_amortissement"}}
|
||||
|
||||
{{* barre de navigation *}}
|
||||
{{if ! $dialog}}
|
||||
{{:include file="_nav.html" current="index"}}
|
||||
{{/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 *}}
|
||||
{{#form on="change"}}
|
||||
|
||||
{{* chercher la date d'acquisition de l'immobilisation *}}
|
||||
{{#select
|
||||
trans.date as date_achat
|
||||
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 = $immo_id
|
||||
assign=ligne_immo
|
||||
}}
|
||||
{{/select}}
|
||||
|
||||
{{if $_POST.no_amort}}
|
||||
{{* ne pas amortir *}}
|
||||
{{:assign duration=0}}
|
||||
{{:assign date_debut=$ligne_immo.date_achat|parse_date}}
|
||||
{{:assign noamort=true}}
|
||||
{{else}}
|
||||
{{* vérifier que la date d'acquisition est antérieure à la date de mise en service *}}
|
||||
{{:assign date_debut=$_POST.date_mes|or:$ligne_immo.date_achat|parse_date}}
|
||||
{{if $date_debut|strtotime < $ligne_immo.date_achat|strtotime}}
|
||||
{{:assign dd=$date_debut|date_short}}
|
||||
{{: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}}
|
||||
{{:assign noamort=false}}
|
||||
{{/if}}
|
||||
|
||||
{{* enregistrer les infos modifiées de l'immobilisation *}}
|
||||
{{:save
|
||||
key=$info_immo.key
|
||||
validate_schema="schema.json"
|
||||
type="immo"
|
||||
line=$immo_id
|
||||
duration=$duration
|
||||
date=$date_debut
|
||||
noamort=$noamort
|
||||
}}
|
||||
|
||||
{{if $_POST.no_amort}}
|
||||
{{:assign amort=0}}
|
||||
{{else}}
|
||||
{{:assign amort=1}}
|
||||
{{/if}}
|
||||
{{:redirect force="index.html?ok=1&msg=infos&amort=%s"|args:$amort}}
|
||||
{{else}}
|
||||
{{:form_errors}}
|
||||
{{/form}}
|
||||
|
||||
{{* modifier la date de mise en service et durée d'amortissement *}}
|
||||
|
||||
{{if $_GET.amort == 0}}
|
||||
{{:assign checked=1}}
|
||||
{{:assign disabled=1}}
|
||||
{{else}}
|
||||
{{:assign checked=0}}
|
||||
{{:assign disabled=0}}
|
||||
{{/if}}
|
||||
|
||||
<form method="post" action="">
|
||||
<fieldset id="infos_immo">
|
||||
<legend></legend>
|
||||
<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 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" default=$info_immo.duration required=true min=1 disabled=$disabled}}
|
||||
</dl>
|
||||
</fieldset>
|
||||
|
||||
<p class="submit">
|
||||
{{:button type="submit" name="change" label="Modifier" shape="right" class="main"}}
|
||||
</p>
|
||||
|
||||
</form>
|
||||
|
||||
{{* activer/désactiver les champs de saisie *}}
|
||||
<script type="text/javascript">
|
||||
function toggleInputs(idfs, idcb) {
|
||||
const noamort = document.getElementById(idcb);
|
||||
const fs = document.getElementById(idfs);
|
||||
for (let field of fs.querySelectorAll("input")) {
|
||||
if (field == noamort) { continue }
|
||||
if (noamort.checked) {
|
||||
field.setAttribute("disabled","disabled");
|
||||
}
|
||||
else {
|
||||
field.removeAttribute("disabled");
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
{{:admin_footer}}
|
|
@ -1,7 +1,7 @@
|
|||
name="Amortissements"
|
||||
description="Gestion des amortissements pour le logiciel de comptabilité Paheko"
|
||||
description="Gestion des amortissements pour le logiciel de comptabilité Paheko (v0.12)"
|
||||
author="Jean-Christophe Engel"
|
||||
author_url="https://gitea.zaclys.com/lesanges"
|
||||
author_url="https://git.roflcopter.fr/lesanges"
|
||||
home_button=false
|
||||
menu=true
|
||||
restrict_section="accounting"
|
||||
|
|
260
save_amort.html
260
save_amort.html
|
@ -1,135 +1,26 @@
|
|||
{{* -*- brindille -*- *}}
|
||||
|
||||
{{*
|
||||
Créer une écriture d'amortissement
|
||||
@param immo_id : id de la ligne d'immobilisation
|
||||
*}}
|
||||
{{:admin_header title="Ajout amortissement" current="module_amortissement"}}
|
||||
|
||||
{{* Infos de l'immobilisation *}}
|
||||
{{#select
|
||||
line.id as immo_id,
|
||||
line.id_account as account_id,
|
||||
line.debit as montant,
|
||||
line.id_project as project_id,
|
||||
trans.id as trans_id,
|
||||
trans.label,
|
||||
trans.date,
|
||||
y.id as year_id,
|
||||
y.start_date,
|
||||
y.end_date,
|
||||
project.label as project_label
|
||||
FROM acc_transactions_lines AS line
|
||||
INNER JOIN acc_transactions AS trans ON line.id_transaction = trans.id
|
||||
INNER JOIN acc_years AS y ON trans.id_year = y.id
|
||||
LEFT JOIN acc_projects AS project ON line.id_project = project.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}}
|
||||
{{:assign date_debut=$ligne_immo.date}}
|
||||
|
||||
{{#load type="immo" where="$$.line = :line_id" :line_id=$_GET.immo_id|intval}}
|
||||
{{:assign duree=$duration}}
|
||||
{{:assign date_debut=$date}}
|
||||
{{else}}
|
||||
{{:error message="Vous devez renseigner la date de mise en service et la durée d'immobilisation"}}
|
||||
{{/load}}
|
||||
|
||||
{{* chercher des écritures d'amortissement liées à l'immobilisation *}}
|
||||
{{#select
|
||||
SUM(l_amort.credit) as amort_amount,
|
||||
l_amort.label as amort_label,
|
||||
l_amort.id as amort_line_id,
|
||||
CASE WHEN links.id_related = t_immo.id
|
||||
THEN links.id_transaction
|
||||
ELSE links.id_related
|
||||
END as amort_trans_id,
|
||||
MAX(trans.date) as amort_date,
|
||||
COUNT(trans.id) as amort_number,
|
||||
trans.label as trans_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 l_immo
|
||||
INNER JOIN acc_transactions as t_immo on t_immo.id = l_immo.id_transaction
|
||||
INNER JOIN acc_transactions_links as links
|
||||
ON (t_immo.id = links.id_transaction
|
||||
OR
|
||||
t_immo.id = links.id_related)
|
||||
INNER JOIN acc_transactions_lines as l_amort on amort_trans_id = l_amort.id_transaction
|
||||
INNER join acc_transactions as trans on l_amort.id_transaction = trans.id
|
||||
INNER join acc_accounts as account on l_amort.id_account = account.id
|
||||
WHERE l_immo.id = :line_id AND account.code LIKE '28%'
|
||||
ORDER BY trans.date DESC LIMIT 1;
|
||||
:line_id = $_GET.immo_id|intval
|
||||
assign=amort_line
|
||||
}}
|
||||
{{/select}}
|
||||
|
||||
{{if $amort_line.amort_number == 0}}
|
||||
{{* 1er amortissement *}}
|
||||
{{* déterminer le compte d'amortissement en fonction du compte d'immobilisation *}}
|
||||
{{#select code, label from acc_accounts where id = :id; :id=$ligne_immo.account_id assign=amort_account}}
|
||||
{{/select}}
|
||||
{{:include
|
||||
file="./_get_amort_code.html"
|
||||
code_immo=$amort_account.code
|
||||
keep="code_amort"
|
||||
}}
|
||||
{{:assign var=amort_label value="Amortissement %s"|args:$amort_account.label}}
|
||||
{{:assign var=libelle value="Amortissement %s"|args:$ligne_immo.label}}
|
||||
{{else}}
|
||||
{{* amortissements suivants *}}
|
||||
{{:assign date_debut=$amort_line.amort_date|strtotime}}
|
||||
{{:assign date_debut="%d+(60*60*24)"|math:$date_debut|date:"Y-m-d"}}
|
||||
{{:assign var=code_amort value=$amort_line.account_code}}
|
||||
{{:assign var=amort_label value=$amort_line.account_label}}
|
||||
{{:assign var=libelle value=$amort_line.amort_label}}
|
||||
{{* barre de navigation *}}
|
||||
{{if ! $dialog}}
|
||||
{{:include file="_nav.html" current="amortization"}}
|
||||
{{/if}}
|
||||
|
||||
{{*
|
||||
lister les exercices qui englobent la date de mise en service de l'immo
|
||||
ou la date du dernier amortissement
|
||||
*}}
|
||||
{{:assign msg_years=""}}
|
||||
{{#years closed=false order="start_date" where="start_date <= :debut AND :debut <= end_date"
|
||||
:debut=$date_debut assign=years.}}
|
||||
{{if $amort_line.amort_number == 0}}
|
||||
{{:assign ts_debut=$date_debut|strtotime}}
|
||||
{{else}}
|
||||
{{:assign ts_debut=$start_date|strtotime}}
|
||||
{{/if}}
|
||||
{{:assign ts_fin=$end_date|strtotime}}
|
||||
{{: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}}
|
||||
{{:assign msg_years=$msg_years|cat:"\n"|cat:" - "|cat:$label|cat:" : "|cat:$debut|cat:" à "|cat:$fin}}
|
||||
{{else}}
|
||||
{{:error message="Aucun exercice ouvert pour enregistrer un amortissement"}}
|
||||
{{/years}}
|
||||
|
||||
{{* Traiter l'envoi du formulaire *}}
|
||||
{{#form on="save"}}
|
||||
{{* vérifier que la date est située dans un exercice compatible *}}
|
||||
{{:assign ts_date = $_POST.date_amort|parse_date|strtotime}}
|
||||
{{:assign ok=false}}
|
||||
{{#foreach from=$years}}
|
||||
{{if $id == $_POST.id_year}}
|
||||
{{:assign selected_chart=$id_chart}}
|
||||
{{if $start_date|strtotime <= $ts_date && $ts_date <= $end_date|strtotime}}
|
||||
{{:assign ok=true}}
|
||||
{{:break}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
{{if ! $ok}}
|
||||
{{:error message="La date choisie n'est dans aucun exercice compatible !\nExercices compatibles : %s"|args:$msg_years}}
|
||||
|
||||
{{* vérifier que la date est située dans un exercice ouvert *}}
|
||||
{{:include
|
||||
file="_check_date.html"
|
||||
date=$_POST.date
|
||||
keep="open_years, selected_year, selected_chart"
|
||||
}}
|
||||
|
||||
{{if $selected_year == null}}
|
||||
{{:error message="La date choisie n'est dans aucun exercice ouvert !!\nExercices ouverts : %s"|args:$open_years}}
|
||||
{{/if}}
|
||||
|
||||
{{* déterminer le numéro des comptes au cas où la clé serait un identifiant *}}
|
||||
{{:include
|
||||
file="_get_codes.html"
|
||||
|
@ -143,6 +34,7 @@
|
|||
keep="account_code"
|
||||
}}
|
||||
{{:assign credit_account=$account_code}}
|
||||
|
||||
{{* vérifier :
|
||||
- que le compte d'amortissement débute par un préfixe correct (280, 281, ...)
|
||||
- est présent dans le PC de l'exercice correspondant à la date
|
||||
|
@ -167,19 +59,21 @@
|
|||
prefix_array=$amort_array
|
||||
keep="account_ok"
|
||||
}}
|
||||
|
||||
{{if $account_ok == null}}
|
||||
{{:assign compte=$credit_account|implode:""}}
|
||||
{{:redirect url="add_account.html?account=%s&chart=%s&immo_id=%s"|args:$compte:$selected_chart:$_GET.immo_id}}
|
||||
{{/if}}
|
||||
|
||||
{{* vérifier que le montant ne dépasse pas le solde restant *}}
|
||||
{{:assign solde="%d-%d"|math:$ligne_immo.montant:$amort_line.amort_amount}}
|
||||
{{if $_POST.montant|trim|money_int > $solde|intval}}
|
||||
{{:assign solde=$solde|money_raw}}
|
||||
{{if $_POST.montant|trim|money_int > $_GET.solde|intval}}
|
||||
{{:assign solde=$_GET.solde|money_raw}}
|
||||
{{:error message="Le montant indiqué « %s » dépasse le solde à amortir « %s »"|args:$_POST.montant:$solde}}
|
||||
{{/if}}
|
||||
|
||||
{{* enregistrer l'écriture *}}
|
||||
{{:assign var="linked_transactions." value=$_GET.trans_id}}
|
||||
|
||||
{{:assign
|
||||
var="lines."
|
||||
debit=$_POST.montant
|
||||
|
@ -194,61 +88,66 @@
|
|||
id_project=$_GET.project_id
|
||||
label=$_POST.designation
|
||||
}}
|
||||
|
||||
{{:api
|
||||
method="POST"
|
||||
path="accounting/transaction"
|
||||
assign="result"
|
||||
assign_code="result_code"
|
||||
id_year=$_POST.id_year
|
||||
id_year=$selected_year
|
||||
type="advanced"
|
||||
date=$_POST.date_amort
|
||||
date=$_POST.date
|
||||
label=$_POST.designation
|
||||
lines=$lines
|
||||
linked_transactions=$ligne_immo.trans_id|intval
|
||||
linked_transactions=$_GET.trans_id|intval
|
||||
}}
|
||||
|
||||
{{:redirect force="amortization.html?immo_id=%s&ok=1&msg=amortissement"|args:$_GET.immo_id}}
|
||||
{{/form}}
|
||||
|
||||
{{:admin_header title="Ajout amortissement" current="module_amortissement"}}
|
||||
|
||||
{{* barre de navigation *}}
|
||||
{{if ! $dialog}}
|
||||
{{:include file="_nav.html" current="index" subcurrent="encours" subsubcurrent="amortization"}}
|
||||
{{/if}}
|
||||
|
||||
{{:form_errors}}
|
||||
|
||||
{{:assign var=selected_year value=$years.0.id}}
|
||||
{{:assign var=date_amort value=$years.0.end_date}}
|
||||
{{:include file="_calcul_dates.html" date_debut=$date_debut date_fin=$date_amort keep="nbjours"}}
|
||||
|
||||
{{* montant de l'amortissement *}}
|
||||
{{:assign montant_amort="%f/%f/365*%d"|math:$ligne_immo.montant:$duree:$nbjours|intval}}
|
||||
{{:assign montant_amort="min(%f, %d-%d)"|math:$montant_amort:$ligne_immo.montant:$amort_line.amort_amount}}
|
||||
{{* Préparer les infos pour le formulaire *}}
|
||||
{{:assign var="debit_account.6811" value="6811 — Dot. aux amortissements des immobilisations"}}
|
||||
{{:assign var="credit_account.%s"|args:$code_amort value="%s — "|args:$code_amort|cat:$amort_label}}
|
||||
|
||||
{{* -------------------------------------------------------------------------------- *}}
|
||||
{{*
|
||||
déterminer le compte d'amortissement en fonction du compte
|
||||
d'immobilisation => ajouter un 8 après le 2 de tête
|
||||
*}}
|
||||
{{#select code, label from acc_accounts where id = :id; :id=$_GET.account assign=amort_account}}{{/select}}
|
||||
{{:include
|
||||
file="./_get_amort_code.html"
|
||||
code_immo=$amort_account.code
|
||||
keep="code_amort"
|
||||
}}
|
||||
{{:assign var="credit_account.%s"|args:$code_amort value="%s — Amortissements "|args:$code_amort|cat:$amort_account.label}}
|
||||
|
||||
<div id="f_erreur" class="hidden">
|
||||
<p class="block error">La date saisie n'est pas dans l'exercice choisi !</p>
|
||||
</div>
|
||||
{{#select
|
||||
id,
|
||||
label,
|
||||
end_date as date_amort
|
||||
from acc_years where id=:id;
|
||||
:id=$_GET.year assign=year
|
||||
}}
|
||||
{{/select}}
|
||||
|
||||
{{#years status=false}}
|
||||
{{:assign var="open_years.%d"|args:$id value=$label}}
|
||||
{{/years}}
|
||||
|
||||
<form method="post" action="">
|
||||
<fieldset class="ajout_amort">
|
||||
<legend>Ajouter une écriture d'amortissement</legend>
|
||||
<dl>
|
||||
{{:input type="select" default=$selected_year name="id_year" label="Exercice" required=true default_empty="— Faire un choix —" options=$open_years}}
|
||||
{{:input type="date" name="date_amort" label="Date" required=true default=$date_amort|date_short}}
|
||||
{{:input type="text" name="designation" label="Désignation" required=true default=$libelle}}
|
||||
{{:input type="money" name="montant" label="Montant" required=true default=$montant_amort}}
|
||||
{{:input type="date" name="date" label="Date" required=true default=$year.date_amort|date_short}}
|
||||
{{:input type="text" name="designation" label="Désignation" required=true default=$_GET.label}}
|
||||
{{:input type="money" name="montant" label="Montant" required=true default=$_GET.amount}}
|
||||
{{:input
|
||||
type="list"
|
||||
name="debit_account"
|
||||
label="Compte de débit"
|
||||
required=true
|
||||
target="!acc/charts/accounts/selector.php?codes=%s&id_year=%d"|args:"68*":$selected_year
|
||||
target="!acc/charts/accounts/selector.php?&key=code&year=%d"|args:$year.id
|
||||
default=$debit_account
|
||||
}}
|
||||
{{:input
|
||||
|
@ -256,15 +155,9 @@
|
|||
name="credit_account"
|
||||
label="Compte d'amortissement (280xx ou 281xx)"
|
||||
required=true
|
||||
target="!acc/charts/accounts/selector.php?codes=%s&id_year=%d"|args:"28*":$selected_year
|
||||
target="!acc/charts/accounts/selector.php?key=code&year=%d"|args:$year.id
|
||||
default=$credit_account
|
||||
}}
|
||||
<div id="donnees" class="hidden">
|
||||
{{:input type="text" name="montant_immo" default=$ligne_immo.montant}}
|
||||
{{:input type="text" name="duree_amort" default=$duree}}
|
||||
{{:input type="text" name="somme_amort" default=$amort_line.amort_amount}}
|
||||
{{:input type="select" name="years_data" options=$years_data}}
|
||||
</div>
|
||||
</dl>
|
||||
</fieldset>
|
||||
|
||||
|
@ -273,48 +166,3 @@
|
|||
</p>
|
||||
</form>
|
||||
{{:admin_footer}}
|
||||
|
||||
<script type="text/javascript" src="scripts.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
/*
|
||||
afficher la date de fin de l'exercice choisi
|
||||
mettre à jour le numéro d'exercice dans les sélecteur de comptes
|
||||
recalculer le montant de l'amortissement
|
||||
*/
|
||||
function redisplayData(evt,
|
||||
f_immo = 'f_montant_immo',
|
||||
f_duree = 'f_duree_amort',
|
||||
f_amort = 'f_somme_amort',
|
||||
f_years_data = 'f_years_data',
|
||||
f_years_select = 'f_id_year',
|
||||
f_date = 'f_date_amort',
|
||||
f_montant = 'f_montant',
|
||||
f_erreur = 'f_erreur'
|
||||
)
|
||||
{
|
||||
setDateEnd(f_years_select, f_date, f_years_data);
|
||||
setSelectorYear(['credit_account', 'debit_account'], f_years_select);
|
||||
displayAmort(f_immo, f_duree, f_amort, f_years_data, f_years_select, f_montant, f_erreur);
|
||||
}
|
||||
|
||||
function redisplayAmort(evt,
|
||||
f_immo = 'f_montant_immo',
|
||||
f_duree = 'f_duree_amort',
|
||||
f_amort = 'f_somme_amort',
|
||||
f_years_data = 'f_years_data',
|
||||
f_years_select = 'f_id_year',
|
||||
f_date = 'f_date_amort',
|
||||
f_montant = 'f_montant',
|
||||
f_erreur = 'f_erreur'
|
||||
)
|
||||
{
|
||||
displayAmort(f_immo, f_duree, f_amort, f_years_data, f_years_select, f_montant, f_erreur, f_date);
|
||||
}
|
||||
|
||||
(function () {
|
||||
setDateEnd('f_id_year', 'f_date_amort', 'f_years_data');
|
||||
document.getElementById('f_id_year').onchange = redisplayData;
|
||||
document.getElementById('f_date_amort').onchange = redisplayAmort;
|
||||
})();
|
||||
</script>
|
||||
|
|
|
@ -19,9 +19,8 @@
|
|||
"type" : ["string", "null"],
|
||||
"format" : "date"
|
||||
},
|
||||
"status" : {
|
||||
"type" : ["string", "null"],
|
||||
"enum" : ["managed", "archived", "ignored"]
|
||||
"noamort" : {
|
||||
"type" : ["null", "boolean"]
|
||||
}
|
||||
},
|
||||
"required": ["type", "line", "duration", "date"]
|
||||
|
|
141
scripts.js
141
scripts.js
|
@ -1,141 +0,0 @@
|
|||
// activer/désactiver les champs passés en paramètres
|
||||
function toggleInputs(idcb, idfields) {
|
||||
const elem = document.getElementById(idcb);
|
||||
for (let id of idfields) {
|
||||
const field = document.getElementById(id);
|
||||
if (elem.checked) {
|
||||
field.removeAttribute("disabled");
|
||||
}
|
||||
else {
|
||||
field.setAttribute("disabled","disabled");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function toggleVisibility(idcheck, fields) {
|
||||
const elem = document.getElementById(idcheck);
|
||||
for (let id of fields) {
|
||||
const field = document.getElementById(id);
|
||||
if (elem.checked) {
|
||||
field.setAttribute('class', '');
|
||||
} else {
|
||||
field.setAttribute('class', 'hidden');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// fixer l'exercice des sélecteurs de compte
|
||||
function setAccountYear(button_names, id_year) {
|
||||
for (const name of button_names) {
|
||||
const button = document.querySelector("button[data-name=" + name + "]");
|
||||
const b_value = button.value;
|
||||
const new_value = b_value.replace(/id_year=\d+/, 'id_year=' + id_year);
|
||||
button.setAttribute('value', new_value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* renvoyer la valeur en secondes d'une date au format j/m/a
|
||||
* @param {string} date
|
||||
*/
|
||||
function str2sec(date) {
|
||||
const jma = date.split('/');
|
||||
const dd = new Date(jma[2], jma[1]-1, jma[0]);
|
||||
return dd.getTime()/1000;
|
||||
}
|
||||
|
||||
// renvoyer la valeur en secondes d'un champ date
|
||||
function getDate(idelem) {
|
||||
return str2sec(document.getElementById(idelem).value);
|
||||
}
|
||||
|
||||
// (unused) désactiver les options du sélecteur qui ne sont pas dans un tableau de valeurs
|
||||
function disableOptions(idSelect, init, values) {
|
||||
for (let i = init; i < idSelect.options.length; ++i) {
|
||||
const choix = idSelect.options[i];
|
||||
if (! values.includes(choix.value)) {
|
||||
choix.setAttribute('disabled', 'true');
|
||||
choix.removeAttribute('selected');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// afficher la date de fin de l'exercice choisi
|
||||
function setDateEnd(id_exercices, id_date, id_years) {
|
||||
const selected_year = document.getElementById(id_exercices).value;
|
||||
if (selected_year == '') {
|
||||
document.getElementById(id_date).value = '';
|
||||
return;
|
||||
}
|
||||
const years_data = document.getElementById(id_years);
|
||||
for (const choix of years_data.options) {
|
||||
if (choix.value == selected_year) {
|
||||
const epox = choix.text.split(' ');
|
||||
const date_fin = new Date(epox[1] * 1000);
|
||||
document.getElementById(id_date).value = date_fin.toLocaleDateString();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// renvoyer la valeur numérique d'un montant formaté en €
|
||||
function getNumber(text) {
|
||||
return Number(text.replace(/ /g, '').replace(/,/, '.').replace(/€/, ''));
|
||||
}
|
||||
|
||||
// calculer le montant d'un amortissement
|
||||
// @param montant immo
|
||||
// @param durée immo (années)
|
||||
// @param somme amortissements
|
||||
// @param date début
|
||||
// @param date de fin
|
||||
// @result montant de l'amortissement
|
||||
function computeAmort(montant_immo, duree_immo, somme_amort, date_debut, date_fin) {
|
||||
const nbjours = 1 + (date_fin - date_debut) / (60*60*24);
|
||||
return Math.round(Math.min(montant_immo / duree_immo / 365 * nbjours, montant_immo - somme_amort));
|
||||
}
|
||||
|
||||
// calculer et afficher le montant de l'amortissement
|
||||
function displayAmort(id_immo, id_duree, id_amort, id_years, id_exercices, id_montant, id_erreur, id_date=null)
|
||||
{
|
||||
const div_erreur = document.getElementById(id_erreur);
|
||||
div_erreur.setAttribute('class', 'hidden');
|
||||
// document.getElementById(id_erreur).setAttribute('class', 'hidden');
|
||||
let case_montant = document.getElementById(id_montant);
|
||||
const selected_year = document.getElementById(id_exercices).value;
|
||||
if (selected_year == '') {
|
||||
case_montant.value = '';
|
||||
return;
|
||||
}
|
||||
const years_data = document.getElementById(id_years);
|
||||
let date_debut, date_fin;
|
||||
for (const choix of years_data.options) {
|
||||
if (choix.value == selected_year) {
|
||||
const epox = choix.text.split(' ');
|
||||
date_debut = epox[0];
|
||||
date_fin = epox[1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (id_date != null) {
|
||||
const date_choisie = str2sec(document.getElementById(id_date).value);
|
||||
console.log("date_choisie = " + date_choisie + ", date_debut=" + date_debut + ", date_fin = " + date_fin);
|
||||
if (date_debut <= date_choisie && date_choisie <= date_fin) {
|
||||
date_fin = date_choisie;
|
||||
} else {
|
||||
div_erreur.setAttribute('class', '');
|
||||
// document.getElementById(id_erreur).setAttribute('class', '');
|
||||
}
|
||||
}
|
||||
const montant_immo = Number(document.getElementById(id_immo).value);
|
||||
const duree_immo = Number(document.getElementById(id_duree).value);
|
||||
const somme_amort = Number(document.getElementById(id_amort).value);
|
||||
const montant_amort = computeAmort(montant_immo, duree_immo, somme_amort, date_debut, date_fin);
|
||||
case_montant.value = montant_amort/100;
|
||||
case_montant.innerText = montant_amort;
|
||||
}
|
||||
|
||||
function setSelectorYear(button_names, f_years_selector) {
|
||||
const selected_year = document.getElementById(f_years_selector).value;
|
||||
setAccountYear(button_names, selected_year);
|
||||
}
|
24
style.css
24
style.css
|
@ -17,27 +17,3 @@ h2[class="aide"], h3[class="aide"] {
|
|||
margin-top: 0.5em;
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
|
||||
.informations {
|
||||
margin-top : 0.5em;
|
||||
margin-bottom : 0.5em;
|
||||
padding : 0.5em;
|
||||
}
|
||||
|
||||
.informations legend {
|
||||
font-weight: bold;
|
||||
border-bottom : solid 1px var(--gLightBorderColor);
|
||||
margin-bottom : 0.5em;
|
||||
}
|
||||
|
||||
.informations dt::after {
|
||||
content: ' :';
|
||||
}
|
||||
|
||||
.informations dl.describe > dt {
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
nav.amort aside {
|
||||
margin-top : 0;
|
||||
}
|
||||
|
|
556
write_exit.html
556
write_exit.html
|
@ -1,556 +0,0 @@
|
|||
{{* -*- brindille -*- *}}
|
||||
|
||||
{{*
|
||||
Enregistrer les écritures de sortie du bilan
|
||||
paramètres :
|
||||
- immo_id : numéro de ligne de l'écriture d'immobilisation
|
||||
- amort_amount : montant des amortissements
|
||||
- year : exercice de la date de sortie de l'immobilisation
|
||||
- date_mes : date de mise en service de l'immobilisation
|
||||
- date_debut : date de début de la période d'amortissement complémentaire
|
||||
- exit_date : date de sortie de l'immobilisation
|
||||
- duree_amort : durée de l'amortiseement (optionnel)
|
||||
- cession : montant de la cession (optionnel)
|
||||
*}}
|
||||
|
||||
{{#select
|
||||
line.debit as montant,
|
||||
line.id_transaction,
|
||||
line.id_account,
|
||||
trans.date as date_achat,
|
||||
trans.label,
|
||||
acc.code,
|
||||
id_project
|
||||
FROM acc_transactions_lines AS line
|
||||
INNER JOIN acc_transactions AS trans ON line.id_transaction = trans.id
|
||||
INNER JOIN acc_accounts AS acc ON line.id_account = acc.id
|
||||
WHERE line.id = :immo_id;
|
||||
:immo_id = $_GET.immo_id|intval
|
||||
assign="ligne_immo"
|
||||
}}
|
||||
{{/select}}
|
||||
|
||||
{{#load type="immo" assign="info_immo" where="$$.line = :line_id" :line_id=$_GET.immo_id|intval}}
|
||||
{{/load}}
|
||||
|
||||
{{* date de début de l'exercice *}}
|
||||
{{#select start_date FROM acc_years WHERE id = :year_id; :year_id = $_GET.year}}
|
||||
{{*
|
||||
{{if $start_date < "2025-01-01"
|
||||
*}}
|
||||
{{:assign vnc_code="675"}}
|
||||
{{:assign cession_code="775"}}
|
||||
{{*
|
||||
{{else}}
|
||||
{{:assign vnc_code="657"}}
|
||||
{{:assign cession_code="757"}}
|
||||
{{/if}}
|
||||
*}}
|
||||
{{/select}}
|
||||
|
||||
{{:assign valeur_nette="%f-%f"|math:$ligne_immo.montant:$_GET.amort_amount}}
|
||||
{{:assign amort_comp=0}} {{* amortissement complémentaire jqà date sortie *}}
|
||||
{{:assign amort_except=0}} {{* amortissement exceptionnel jqà date fin amortissement *}}
|
||||
{{if $valeur_nette > 0}}
|
||||
{{:assign nbjours="1+(%d-%d)/(60*60*24)"|math:$_GET.exit_date:$_GET.date_debut}}
|
||||
{{:assign annuite="%f/%f"|math:$ligne_immo.montant:$_GET.duree_amort}}
|
||||
{{:assign amort_comp="round(%f/365*%f, 0)"|math:$annuite:$nbjours}}
|
||||
{{:assign amort_comp="min(%f, %f)"|math:$valeur_nette:$amort_comp}}
|
||||
|
||||
{{if $_GET.cession == null}}
|
||||
{{:assign amort_except="%f-%f-%f"|math:$ligne_immo.montant:$_GET.amort_amount:$amort_comp}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
{{if $_GET.cession == null}}
|
||||
{{:assign montant_cession=0}}
|
||||
{{else}}
|
||||
{{:assign montant_cession="%f*100"|math:$_GET.cession}}
|
||||
{{/if}}
|
||||
|
||||
{{* TODO : faut-il forcer les 3 sélecteurs de compte d'amortissement à avoir toujours la même valeur ? *}}
|
||||
|
||||
{{* Traiter l'envoi du formulaire *}}
|
||||
{{#form on="save"}}
|
||||
{{*
|
||||
{{if $_POST.amort_comp_account != null}
|
||||
{{:assign account=$_POST.amort_comp_account}}
|
||||
{{elseif $_POST.amort_except_account != null}
|
||||
{{:assign account=$_POST.amort_except_account}}
|
||||
{{elseif $_POST.amort_sortie_account != null}
|
||||
{{:assign account=$_POST.amort_sortie_account}}
|
||||
{{/if}}
|
||||
*}}
|
||||
{{:assign account=$_POST.amort_sortie_account}}
|
||||
|
||||
{{:include
|
||||
file="_get_codes.html"
|
||||
account=$account
|
||||
keep="account_code"
|
||||
}}
|
||||
{{:assign amort_account_code=$account_code|keys|key:0}}
|
||||
|
||||
{{if $valeur_nette > 0}}
|
||||
{{* immo non totalement amortie *}}
|
||||
|
||||
{{* lignes d'écriture de l'amortissement complémentaire *}}
|
||||
{{:include
|
||||
file="_get_codes.html"
|
||||
account=$_POST.comp_account
|
||||
keep="account_code"
|
||||
}}
|
||||
{{:assign comp_account_code=$account_code|keys|key:0}}
|
||||
|
||||
{{:assign libelle="Amortissement complémentaire "|cat:$ligne_immo.label}}
|
||||
{{:assign
|
||||
var="lines."
|
||||
debit="%f/100"|math:$amort_comp
|
||||
account=$comp_account_code
|
||||
id_project=$ligne_immo.id_project
|
||||
label=$libelle
|
||||
}}
|
||||
{{:assign
|
||||
var="lines."
|
||||
credit="%f/100"|math:$amort_comp
|
||||
account=$amort_account_code
|
||||
id_project=$ligne_immo.id_project
|
||||
label=$libelle
|
||||
}}
|
||||
{{:assign valeur_nette="%f-%f"|math:$valeur_nette:$amort_comp}}
|
||||
|
||||
{{if $_GET.cession == null && $amort_except > 0}}
|
||||
{{* lignes d'écriture de l'amortissement exceptionnel *}}
|
||||
{{:include
|
||||
file="_get_codes.html"
|
||||
account=$_POST.except_account
|
||||
keep="account_code"
|
||||
}}
|
||||
{{:assign except_account_code=$account_code|keys|key:0}}
|
||||
{{:assign libelle="Amortissement exceptionnel "|cat:$ligne_immo.label}}
|
||||
{{:assign
|
||||
var="lines."
|
||||
debit="%f/100"|math:$amort_except
|
||||
account=$except_account_code
|
||||
id_project=$ligne_immo.id_project
|
||||
label=$libelle
|
||||
}}
|
||||
{{:assign
|
||||
var="lines."
|
||||
credit="%f/100"|math:$amort_except
|
||||
account=$amort_account_code
|
||||
id_project=$ligne_immo.id_project
|
||||
label=$libelle
|
||||
}}
|
||||
{{:assign valeur_nette="%f-%f"|math:$valeur_nette:$amort_except}}
|
||||
{{/if}}
|
||||
|
||||
{{:api
|
||||
method="POST"
|
||||
path="accounting/transaction"
|
||||
assign="result"
|
||||
assign_code="result_code"
|
||||
id_year=$_GET.year
|
||||
type="advanced"
|
||||
date=$_GET.exit_date
|
||||
label="Amortissement final "|cat:$ligne_immo.label
|
||||
lines=$lines
|
||||
linked_transactions=$ligne_immo.id_transaction
|
||||
}}
|
||||
{{/if}}
|
||||
|
||||
{{* écriture de sortie du bilan *}}
|
||||
{{:assign lines=null}}
|
||||
{{:include
|
||||
file="_get_codes.html"
|
||||
account=$_POST.immo_account
|
||||
keep="account_code"
|
||||
}}
|
||||
{{:assign immo_account_code=$account_code|keys|key:0}}
|
||||
{{:assign libelle="Sortie du bilan de "|cat:$ligne_immo.label}}
|
||||
{{:assign
|
||||
var="lines."
|
||||
account=$immo_account_code
|
||||
credit="%f/100"|math:$ligne_immo.montant
|
||||
id_project=$ligne_immo.id_project
|
||||
label=$libelle
|
||||
}}
|
||||
{{:assign
|
||||
var="lines."
|
||||
account=$amort_account_code
|
||||
debit="(%f-%f)/100"|math:$ligne_immo.montant:$valeur_nette
|
||||
id_project=$ligne_immo.id_project
|
||||
label=$libelle
|
||||
}}
|
||||
{{if $valeur_nette > 0}}
|
||||
{{:include
|
||||
file="_get_codes.html"
|
||||
account=$_POST.vnc_account
|
||||
keep="account_code"
|
||||
}}
|
||||
{{:assign vnc_account_code=$account_code|keys|key:0}}
|
||||
{{:assign
|
||||
var="lines."
|
||||
account=$vnc_account_code
|
||||
debit="%f/100"|math:$valeur_nette
|
||||
id_project=$ligne_immo.id_project
|
||||
label=$libelle
|
||||
}}
|
||||
{{/if}}
|
||||
|
||||
{{:api
|
||||
method="POST"
|
||||
path="accounting/transaction"
|
||||
assign="result"
|
||||
assign_code="result_code"
|
||||
id_year=$_GET.year
|
||||
type="advanced"
|
||||
date=$_GET.exit_date
|
||||
label=$libelle
|
||||
lines=$lines
|
||||
linked_transactions=$ligne_immo.id_transaction
|
||||
}}
|
||||
|
||||
{{if $montant_cession > 0}}
|
||||
{{* Cession de l'immobilisation *}}
|
||||
{{:assign libelle="Produit cession "|cat:$ligne_immo.label}}
|
||||
{{:include
|
||||
file="_get_codes.html"
|
||||
account=$_POST.creance_account
|
||||
keep="account_code"
|
||||
}}
|
||||
{{:assign creance_account=$account_code|keys|key:0}}
|
||||
{{:include
|
||||
file="_get_codes.html"
|
||||
account=$_POST.cession_account
|
||||
keep="account_code"
|
||||
}}
|
||||
{{:assign cession_account=$account_code|keys|key:0}}
|
||||
{{:api
|
||||
method="POST"
|
||||
path="accounting/transaction"
|
||||
assign="result"
|
||||
assign_code="result_code"
|
||||
id_year=$_GET.year
|
||||
type="credit"
|
||||
date=$_GET.exit_date
|
||||
label=$libelle
|
||||
amount="%f/100"|math:$montant_cession
|
||||
debit=$creance_account
|
||||
credit=$cession_account
|
||||
id_project=$ligne_immo.id_project
|
||||
linked_transactions=$ligne_immo.id_transaction
|
||||
}}
|
||||
{{/if}}
|
||||
|
||||
{{if $info_immo != null}}
|
||||
{{* mettre à jour l'état de l'immobilisation *}}
|
||||
{{:save
|
||||
key=$info_immo.key
|
||||
status="archived"
|
||||
}}
|
||||
{{else}}
|
||||
{{:save
|
||||
key=""|uuid
|
||||
validate_schema="schema.json"
|
||||
type="immo"
|
||||
line=$_GET.immo_id|intval
|
||||
duration=$_GET.duree_amort|intval
|
||||
date=$_GET.date_mes|date:"Y-m-d"
|
||||
status="archived"
|
||||
}}
|
||||
{{/if}}
|
||||
|
||||
{{:redirect to="index.html?amort=archive"}}
|
||||
{{/form}}
|
||||
|
||||
{{:admin_header title="Sortie du bilan" custom_css="./style.css" current="module_amortissement"}}
|
||||
|
||||
{{* barre de navigation *}}
|
||||
{{if ! $dialog}}
|
||||
{{:include file="_nav.html" current="index" subcurrent="balance_exit"}}
|
||||
{{/if}}
|
||||
{{:form_errors}}
|
||||
|
||||
{{* Préparer les infos pour le formulaire *}}
|
||||
|
||||
{{* déterminer les comptes pour les différentes écritures *}}
|
||||
{{:include
|
||||
file="./_get_amort_code.html"
|
||||
code_immo=$ligne_immo.code
|
||||
keep="code_amort"
|
||||
}}
|
||||
{{:assign var="liste_codes.6811" name="comp_account"}}
|
||||
{{:assign var="liste_codes.687" name="except_account"}}
|
||||
{{:assign var="liste_codes.462" name="creance_account"}}
|
||||
{{:assign var="liste_codes.%s"|args:$code_amort name="amort_account"}}
|
||||
{{:assign var="liste_codes.%s"|args:$ligne_immo.code name="immo_account"}}
|
||||
{{:assign var="liste_codes.%s"|args:$vnc_code name="vnc_account"}}
|
||||
{{:assign var="liste_codes.%s"|args:$cession_code name="cession_account"}}
|
||||
{{:assign condition=$liste_codes|keys|implode:","}}
|
||||
{{:assign condition="acc.code IN ("|cat:$condition|cat:")"}}
|
||||
|
||||
{{#select
|
||||
acc.id,
|
||||
acc.code as acc_code,
|
||||
acc.label as acc_label,
|
||||
year.label as year_label
|
||||
FROM acc_accounts as acc
|
||||
INNER JOIN acc_charts as chart ON chart.id = acc.id_chart
|
||||
INNER JOIN acc_years as year ON chart.id = year.id_chart
|
||||
WHERE year.id = 1 AND !condition;
|
||||
!condition=$condition
|
||||
}}
|
||||
{{:assign var="liste_codes.%s.id"|args:$acc_code value=$id}}
|
||||
{{:assign var="liste_codes.%s.acc_label"|args:$acc_code value=$acc_label}}
|
||||
{{:assign var="liste_codes.%s.year_label"|args:$acc_code value=$year_label}}
|
||||
{{/select}}
|
||||
|
||||
{{#foreach from=$liste_codes key=code}}
|
||||
{{:assign var="%s.%s"|args:$name:$code value="%s — %s"|args:$code:$acc_label}}
|
||||
{{/foreach}}
|
||||
|
||||
{{: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"}}
|
||||
{{:assign var="pattern_array." value="%s*"|args:$code}}
|
||||
{{/foreach}}
|
||||
{{:assign patterns=$pattern_array|implode:"|"}}
|
||||
|
||||
<h3>Sortir l'immobilisation « {{$ligne_immo.label}} » du bilan</h3>
|
||||
<form method="post" action="">
|
||||
|
||||
<div class="informations">
|
||||
<legend>Données de l'imobilisation</legend>
|
||||
<dl class="describe">
|
||||
<dt>Montant</dt>
|
||||
<dd class="money">{{$ligne_immo.montant|money_currency:false}}</dd>
|
||||
<dt>Date d'acquisition</dt>
|
||||
<dd >{{$ligne_immo.date_achat|date_short}}</dd>
|
||||
{{if $_GET.date_mes != $ligne_immo.date_achat|strtotime}}
|
||||
<dt>Date de mise en service</dt>
|
||||
<dd>{{$_GET.date_mes|date:"d/m/Y"}}</dd>
|
||||
{{/if}}
|
||||
{{if $_GET.duree_amort != null}}
|
||||
<dt>Durée de l'amortissement</dt>
|
||||
<dd class="num">{{$_GET.duree_amort}} ans</dd>
|
||||
{{/if}}
|
||||
<dt>Montant des amortissements</dt>
|
||||
<dd class="money">{{$_GET.amort_amount|money_currency:false}} <span class="help">(à la date de début de l'exercice)</span></dd>
|
||||
<dt>Valeur nette résiduelle</dt>
|
||||
<dd class="money">{{$valeur_nette|money_currency:false}} <span class="help">(à la date de début de l'exercice)</span></dd>
|
||||
<dt>Date de sortie</dt>
|
||||
<dd>{{$_GET.exit_date|date:"d/m/Y"}}</dd>
|
||||
{{if $amort_comp > 0}}
|
||||
{{:assign valeur_nette="%f-%f"|math:$valeur_nette:$amort_comp}}
|
||||
<dt>Amortissement complémentaire</dt>
|
||||
<dd class="money">{{$amort_comp|money_currency:false}} <span class="help">(jusqu'à la date de sortie)</span></dd>
|
||||
<dt>Total des amortissements</dt>
|
||||
<dd class="money">{{"%f+%f"|math:$_GET.amort_amount:$amort_comp|money_currency:false}} <span class="help">(à la date de sortie)</span></dd>
|
||||
<dt>Valeur nette résiduelle</dt>
|
||||
<dd class="money">{{$valeur_nette|money_currency:false}} <span class="help">(à la date de sortie)</span></dd>
|
||||
{{/if}}
|
||||
{{if $montant_cession == 0}}
|
||||
{{if $amort_except > 0}}
|
||||
<dt>Amortissement exceptionnel</dt>
|
||||
<dd class="money">{{$amort_except|money_currency:false}}</dd>
|
||||
{{/if}}
|
||||
{{else}}
|
||||
<dt>Montant de la cession</dt>
|
||||
<dd class="money">{{$montant_cession|money_currency:false}}</dd>
|
||||
{{/if}}
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
<fieldset>
|
||||
<legend>Écritures de sortie du bilan</legend>
|
||||
{{* Amortissement complémentaire *}}
|
||||
{{if $amort_comp > 0}}
|
||||
<table class="list">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>Amortissement complémentaire</td>
|
||||
<td>Débit</td>
|
||||
<td>Crédit</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td colspan="3" class="help">
|
||||
Entre la date de début de l'exercice et la date de sortie du bilan
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{{:input
|
||||
type="list"
|
||||
name="comp_account"
|
||||
target="!acc/charts/accounts/selector.php?codes=%s&year=%d"|args:"68*":$_GET.year
|
||||
default=$comp_account
|
||||
}}
|
||||
</td>
|
||||
<td>{{$amort_comp|money_currency:false}}</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{{:input
|
||||
type="list"
|
||||
name="amort_comp_account"
|
||||
target="!acc/charts/accounts/selector.php?codes=%s&year=%d"|args:"28*":$_GET.year
|
||||
default=$amort_account
|
||||
}}
|
||||
</td>
|
||||
<td></td>
|
||||
<td>{{$amort_comp|money_currency:false}}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
{{/if}}
|
||||
|
||||
{{* Amortissement exceptionnel *}}
|
||||
{{if $montant_cession == 0 && $amort_except > 0}}
|
||||
<table class="list">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>Amortissement exceptionnel</td>
|
||||
<td>Débit</td>
|
||||
<td>Crédit</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td colspan="3" class="help">
|
||||
Montant de l'immobilisation non encore amortie (valeur nette résiduelle à la date de sortie)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{{:input
|
||||
type="list"
|
||||
name="except_account"
|
||||
target="!acc/charts/accounts/selector.php?codes=%s&year=%d"|args:"687*":$_GET.year
|
||||
default=$except_account
|
||||
}}
|
||||
</td>
|
||||
<td>{{$amort_except|money_currency:false}}</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{{:input
|
||||
type="list"
|
||||
name="amort_except_account"
|
||||
target="!acc/charts/accounts/selector.php?codes=%s&year=%d"|args:"28*":$_GET.year
|
||||
default=$amort_account
|
||||
}}
|
||||
</td>
|
||||
<td></td>
|
||||
<td>{{$amort_except|money_currency:false}}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
{{/if}}
|
||||
|
||||
{{* Sortie du bilan *}}
|
||||
<table class="list">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>Sortie du bilan</td>
|
||||
<td>Débit</td>
|
||||
<td>Crédit</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
{{:input
|
||||
type="list"
|
||||
name="amort_sortie_account"
|
||||
target="!acc/charts/accounts/selector.php?codes=%s&year=%d"|args:"28*":$_GET.year
|
||||
default=$amort_account
|
||||
}}
|
||||
</td>
|
||||
{{if $montant_cession == 0}}
|
||||
{{:assign montant=$ligne_immo.montant}}
|
||||
{{else}}
|
||||
{{:assign montant="%f+%f"|math:$_GET.amort_amount:$amort_comp}}
|
||||
{{/if}}
|
||||
<td>{{$montant|money_currency:false}}</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
{{if $montant_cession > 0 && $valeur_nette > 0}}
|
||||
<tr>
|
||||
<td>
|
||||
{{:input
|
||||
type="list"
|
||||
name="vnc_account"
|
||||
target="!acc/charts/accounts/selector.php?codes=%s*&year=%d"|args:$vnc_code:$_GET.year
|
||||
default=$vnc_account
|
||||
}}
|
||||
</td>
|
||||
<td>{{$valeur_nette|money_currency:false}}</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
{{/if}}
|
||||
<tr>
|
||||
<td> {{* style="pointer-events: none; opacity: 0.6;">*}}
|
||||
{{:input
|
||||
type="list"
|
||||
name="immo_account"
|
||||
target="!acc/charts/accounts/selector.php?codes=%s&year=%d"|args:$patterns:$_GET.year
|
||||
default=$immo_account
|
||||
}}
|
||||
</td>
|
||||
<td></td>
|
||||
<td>{{$ligne_immo.montant|money_currency:false}}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
{{* comptabilisation du produit de la cession *}}
|
||||
{{if $montant_cession > 0}}
|
||||
<table class="list">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>Comptabilisation de la cession</td>
|
||||
<td>Débit</td>
|
||||
<td>Crédit</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
{{:input
|
||||
type="list"
|
||||
name="creance_account"
|
||||
target="!acc/charts/accounts/selector.php?codes=%s&year=%d"|args:"462*":$_GET.year
|
||||
default=$creance_account
|
||||
}}
|
||||
</td>
|
||||
<td>{{$montant_cession|money_currency:false}}</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{{:input
|
||||
type="list"
|
||||
name="cession_account"
|
||||
target="!acc/charts/accounts/selector.php?codes=%s*&year=%d"|args:$cession_code:$_GET.year
|
||||
default=$cession_account
|
||||
}}
|
||||
</td>
|
||||
<td></td>
|
||||
<td>{{$montant_cession|money_currency:false}}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
{{/if}}
|
||||
</fieldset>
|
||||
|
||||
<p class="submit">
|
||||
{{:button type="submit" name="save" label="Enregistrer" shape="right" class="main"}}
|
||||
</p>
|
||||
</form>
|
||||
{{:admin_footer}}
|
Loading…
Add table
Reference in a new issue