536 lines
15 KiB
HTML
536 lines
15 KiB
HTML
{{* -*- 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,
|
|
id_project
|
|
FROM acc_transactions_lines AS line
|
|
INNER JOIN acc_transactions AS trans ON line.id_transaction = trans.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}}
|
|
{{*:assign date_debut=$start_date*}}
|
|
{{/select}}
|
|
|
|
{{*if $date_debut < "2025-01-01"*}}
|
|
{{:assign vnc_code=675}}
|
|
{{:assign cession_code=775}}
|
|
{{*
|
|
{{else}}
|
|
{{:assign vnc_code=657}}
|
|
{{:assign cession_code=757}}
|
|
{{/if}}
|
|
*}}
|
|
|
|
{{: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=$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=$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
|
|
id_project=$ligne_immo.id_project
|
|
label=$libelle
|
|
}}
|
|
{{:assign
|
|
var="lines."
|
|
credit="%f/100"|math:$amort_comp
|
|
account=$amort_account
|
|
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=$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
|
|
id_project=$ligne_immo.id_project
|
|
label=$libelle
|
|
}}
|
|
{{:assign
|
|
var="lines."
|
|
credit="%f/100"|math:$amort_except
|
|
account=$amort_account
|
|
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 libelle="Sortie du bilan de "|cat:$ligne_immo.label}}
|
|
{{:assign lines=null}}
|
|
{{:assign
|
|
var="lines."
|
|
id_account=$ligne_immo.id_account
|
|
credit="%f/100"|math:$ligne_immo.montant
|
|
id_project=$ligne_immo.id_project
|
|
label=$libelle
|
|
}}
|
|
{{:assign
|
|
var="lines."
|
|
account=$amort_account
|
|
debit="(%f-%f)/100"|math:$ligne_immo.montant:$valeur_nette
|
|
id_project=$ligne_immo.id_project
|
|
label=$libelle
|
|
}}
|
|
{{if $valeur_nette > 0}}
|
|
{{:assign
|
|
var="lines."
|
|
account=$vnc_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" subsubcurrent="balance_exit"}}
|
|
{{/if}}
|
|
{{:form_errors}}
|
|
|
|
{{* Préparer les infos pour le formulaire *}}
|
|
|
|
{{* déterminer les comptes pour les différentes écritures *}}
|
|
{{:assign var="comp_account.6811" value="6811 — Dot. aux amortissements des immobilisations"}}
|
|
{{:assign var="except_account.687" value="687 — Dot. aux amortissements & provisions - Charges exceptionnelles"}}
|
|
|
|
{{#select code, label from acc_accounts where id = :id;
|
|
:id=$ligne_immo.id_account
|
|
assign=immo_account_info
|
|
}}
|
|
{{/select}}
|
|
|
|
{{:include
|
|
file="./_get_amort_code.html"
|
|
code_immo=$immo_account_info.code
|
|
keep="code_amort"
|
|
}}
|
|
{{:assign
|
|
var="amort_account.%s"|args:$code_amort
|
|
value="%s — Amortissements "|args:$code_amort|cat:$immo_account_info.label}}
|
|
{{:assign
|
|
var="immo_account.%s"|args:$immo_account_info.code
|
|
value="%s — Immobilisation "|args::$immo_account_info.code|cat:$immo_account_info.label}}
|
|
{{:assign
|
|
var="vnc_account.%s"|args:$vnc_code
|
|
value="%s — Valeurs comptables des éléments d'actifs cédés"|args:$vnc_code}}
|
|
{{:assign
|
|
var="cession_account.%s"|args:$cession_code
|
|
value="%s — Produits des cessions d'actif"|args:$cession_code}}
|
|
{{:assign var="creance_account.462" value="462 — Créances sur cessions d'immobilisations"}}
|
|
|
|
{{: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}}
|