Sortie immobilisation du bilan
This commit is contained in:
parent
d669b5c95b
commit
ea8d805dba
8 changed files with 939 additions and 21 deletions
562
write_exit.html
Normal file
562
write_exit.html
Normal file
|
|
@ -0,0 +1,562 @@
|
|||
{{* -*- 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
|
||||
- exit_date : date de sortie de l'immobilisation
|
||||
- cession : montant de la cession (optionnel)
|
||||
- duree_amort : durée de l'amortiseement (optionnel)
|
||||
*}}
|
||||
|
||||
{{* TEMPORAIRE *}}
|
||||
{{:admin_header title="Sortie du bilan" custom_css="./style.css" current="module_amortissement"}}
|
||||
|
||||
{{* barre de navigation *}}
|
||||
{{if ! $dialog}}
|
||||
{{:include file="_nav.html" current="amortization"}}
|
||||
{{/if}}
|
||||
{{* /TEMPORAIRE *}}
|
||||
|
||||
{{#select
|
||||
id_transaction,
|
||||
id_account,
|
||||
debit,
|
||||
label,
|
||||
id_project
|
||||
FROM acc_transactions_lines
|
||||
WHERE id = :immo_id;
|
||||
:immo_id = $_GET.immo_id|intval
|
||||
assign="ligne_immo"
|
||||
}}
|
||||
{{/select}}
|
||||
|
||||
{{#select
|
||||
label,date
|
||||
FROM acc_transactions
|
||||
WHERE id = :trans_id;
|
||||
:trans_id = $ligne_immo.id_transaction
|
||||
assign="trans_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}}
|
||||
*}}
|
||||
|
||||
{{if $info_immo.duration == null}}
|
||||
{{:assign duree_amort=$_GET.duree_amort}}
|
||||
{{else}}
|
||||
{{:assign duree_amort=$info_immo.duration}}
|
||||
{{/if}}
|
||||
|
||||
{{:assign valeur_nette="%f-%f"|math:$ligne_immo.debit:$_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}}
|
||||
{{:include
|
||||
file="_calcul_dates.html"
|
||||
date_debut=$date_debut|parse_date
|
||||
date_fin=$_GET.exit_date|parse_date
|
||||
keep="nbjours"
|
||||
}}
|
||||
{{:debug nbjours=$nbjours}}
|
||||
{{:assign annuite="%f/%f"|math:$ligne_immo.debit:$duree_amort}}
|
||||
{{:assign amort_comp="round(%f/360*%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.debit:$_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}}
|
||||
|
||||
{{*:debug
|
||||
get=$_GET
|
||||
montant=$ligne_immo.debit
|
||||
amort_comp=$amort_comp
|
||||
amort_except=$amort_except
|
||||
montant_cession=$montant_cession
|
||||
*}}
|
||||
|
||||
{{* Traiter l'envoi du formulaire *}}
|
||||
{{#form on="save"}}
|
||||
{{*:debug post=$_POST*}}
|
||||
|
||||
{{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}}
|
||||
{{:include
|
||||
file="_get_codes.html"
|
||||
account=$_POST.amort_comp_account
|
||||
keep="account_code"
|
||||
}}
|
||||
{{:assign amort_account=$account_code|keys|key:0}}
|
||||
|
||||
{{* ? Faut-il vérifier la validité des comptes ? *}}
|
||||
|
||||
{{:assign libelle="Amortissement complémentaire "|cat:$trans_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}}
|
||||
{{* 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:$trans_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}}
|
||||
{{*:debug lines=$lines*}}
|
||||
|
||||
{{: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:$trans_immo.label
|
||||
lines=$lines
|
||||
linked_transactions=$ligne_immo.id_transaction
|
||||
}}
|
||||
{{/if}}
|
||||
|
||||
{{* écriture de sortie du bilan *}}
|
||||
{{*:debug valeur_nette=$valeur_nette*}}
|
||||
{{:assign libelle="Sortie du bilan de "|cat:$trans_immo.label}}
|
||||
{{:assign lines=null}}
|
||||
{{:assign
|
||||
var="lines."
|
||||
id_account=$ligne_immo.id_account
|
||||
credit="%f/100"|math:$ligne_immo.debit
|
||||
id_project=$ligne_immo.id_project
|
||||
label=$libelle
|
||||
}}
|
||||
{{:assign
|
||||
var="lines."
|
||||
account=$amort_account
|
||||
debit="(%f-%f)/100"|math:$ligne_immo.debit:$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}}
|
||||
{{*:debug lines=$lines*}}
|
||||
{{: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:$trans_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}}
|
||||
|
||||
{{* mettre à jour l'état de l'immobilisation *}}
|
||||
{{:save
|
||||
key=$info_immo.key
|
||||
status="archived"
|
||||
}}
|
||||
|
||||
{{:redirect to="index.html?amort=archive"}}
|
||||
|
||||
{{/form}}
|
||||
|
||||
{{:form_errors}}
|
||||
{{*:debug get=$_GET*}}
|
||||
|
||||
{{* 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}}
|
||||
{{*:debug immo_account_info=$immo_account_info*}}
|
||||
|
||||
{{: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"}}
|
||||
|
||||
{{*:debug
|
||||
comp_account=$comp_account
|
||||
except_account=$except_account
|
||||
amort_account=$amort_account
|
||||
immo_account=$immo_account
|
||||
vnc_account=$vnc_account
|
||||
*}}
|
||||
|
||||
{{#select * from acc_years where start_date <= :date AND :date <= end_date;
|
||||
:date=$_GET.exit_date|parse_date
|
||||
assign=year
|
||||
}}
|
||||
{{/select}}
|
||||
|
||||
{{: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:"|"}}
|
||||
|
||||
{{*:debug comp_account=$comp_account amort_account=$amort_account except_account=$except_account year=$year*}}
|
||||
|
||||
<h3>Sortir l'immobilisation « {{$trans_immo.label}} » du bilan</h3>
|
||||
<form method="post" action="">
|
||||
|
||||
<div class="informations">
|
||||
<legend>Données de l'imobilisation</legend>
|
||||
<dl class="describe">
|
||||
<dt><label>Montant</label></dt>
|
||||
<dd class="money">{{$ligne_immo.debit|money_currency:false}}</dd>
|
||||
<dt><label>Date d'acquisition</label></dt>
|
||||
<dd >{{$trans_immo.date|date_short}}</dd>
|
||||
{{if $info_immo.date != null && $info_immo.date != $trans_immo.date}}
|
||||
<dt><label>Date de mise en service</label></dt>
|
||||
<dd>{{$info_immo.date|date_short}}</dd>
|
||||
{{/if}}
|
||||
{{if $duree_amort != null}}
|
||||
<dt>Durée de l'amortissement</dt>
|
||||
<dd class="num">{{$duree_amort}} ans</dd>
|
||||
{{/if}}
|
||||
<dt><label>Montant des amortissements</label></dt>
|
||||
<dd class="money">{{$_GET.amort_amount|money_currency:false}} <span class="help">(à la date de début de l'exercice)</span></dd>
|
||||
<dt><label>Valeur nette résiduelle</label></dt>
|
||||
<dd class="money">{{$valeur_nette|money_currency:false}} <span class="help">(à la date de début de l'exercice)</span></dd>
|
||||
<dt><label>Date de sortie</label></dt>
|
||||
<dd>{{$_GET.exit_date}}</dd>
|
||||
{{if $amort_comp > 0}}
|
||||
<dt><label>Montant amortissement complémentaire</label></dt>
|
||||
<dd class="money">{{$amort_comp|money_currency:false}}</dd>
|
||||
<dt><label>Montant des amortissements</label></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><label>Valeur nette résiduelle</label></dt>
|
||||
<dd class="money">{{"%f-%f"|math:$valeur_nette:$amort_comp|money_currency:false}} <span class="help">(à la date de sortie)</span></dd>
|
||||
{{/if}}
|
||||
{{if $montant_cession == 0}}
|
||||
{{if $amort_except > 0}}
|
||||
<dt><label>Montant amortissement exceptionnel</label></dt>
|
||||
<dd class="money">{{$amort_except|money_currency:false}}</dd>
|
||||
{{/if}}
|
||||
{{else}}
|
||||
<dt><label>Montant de la cession</label></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 $valeur_nette > 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*":$year.id
|
||||
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*":$year.id
|
||||
default=$amort_account
|
||||
}}
|
||||
</td>
|
||||
<td></td>
|
||||
<td>{{$amort_comp|money_currency:false}}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
{{* Amortissement exceptionnel *}}
|
||||
{{if $montant_cession == 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*":$year.id
|
||||
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*":$year.id
|
||||
default=$amort_account
|
||||
}}
|
||||
</td>
|
||||
<td></td>
|
||||
<td>{{$amort_except|money_currency:false}}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
{{/if}}
|
||||
{{/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*":$year.id
|
||||
default=$amort_account
|
||||
}}
|
||||
</td>
|
||||
{{if $montant_cession == 0}}
|
||||
{{:assign montant=$ligne_immo.debit}}
|
||||
{{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}}
|
||||
<tr>
|
||||
<td>
|
||||
{{:input
|
||||
type="list"
|
||||
name="vnc_account"
|
||||
target="!acc/charts/accounts/selector.php?codes=%s*&year=%d"|args:$vnc_code:$year.id
|
||||
default=$vnc_account
|
||||
}}
|
||||
</td>
|
||||
{{:assign montant="%f-%f"|math:$valeur_nette:$amort_comp}}
|
||||
<td>{{$montant|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:$year.id
|
||||
default=$immo_account
|
||||
}}
|
||||
</td>
|
||||
<td></td>
|
||||
<td>{{$ligne_immo.debit|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*":$year.id
|
||||
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:$year.id
|
||||
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
Add a link
Reference in a new issue