diff --git a/_common_detach.html b/_common_detach.html
index 2c730c8..8c84736 100644
--- a/_common_detach.html
+++ b/_common_detach.html
@@ -7,7 +7,7 @@
*}}
{{* données de l'immobilisation *}}
-{{:include file="_get_immo_data.html" immo_doc_id=$immo_doc_id|intval keep="ligne_immo, message"}}
+{{:include file="_get_immo_data.html" immo_doc_id=$immo_doc_id|intval keep="info_immo, ligne_immo, message"}}
{{if $message != null}}
{{:error message=$message}}
{{/if}}
diff --git a/amortization.html b/amortization.html
index a3378b2..97ded50 100644
--- a/amortization.html
+++ b/amortization.html
@@ -151,7 +151,7 @@
Avoirs
diff --git a/detach_amort.html b/detach_amort.html
index eba97ee..b058716 100644
--- a/detach_amort.html
+++ b/detach_amort.html
@@ -7,8 +7,7 @@
@param amort_line_id : id de la ligne d'amortissement
*}}
-{{:include file="_common_detach.html" immo_doc_id=$_GET.immo_doc_id line_id=$_GET.amort_line_id}}
-
+{{:include file="_common_detach.html" immo_doc_id=$_GET.immo_doc_id line_id=$_GET.amort_line_id keep="info_immo"}}
{{* supprimer le doc de liaison entre les lignes *}}
{{#load type="amort_link"
where="$$.immo_doc_id = :immo_doc_id AND $$.amort_line_id = :amort_line_id"
@@ -19,11 +18,12 @@
{{/load}}
{{* marquer immo non soldée *}}
-{{* TODO : À VÉRIFIER *}}
-{{:save
- key=$info_immo.key
- status="managed"
-}}
+{{if $info_immo.status == "amortized"}}
+ {{:save
+ key=$info_immo.key
+ status="managed"
+ }}
+{{/if}}
{{if $_GET.from == "exit"}}
{{:redirect force="exit_step2.html?immo_doc_id=%s&ok=1&msg=detach_amort"|args:$_GET.immo_doc_id}}
diff --git a/exit_step4.html b/exit_step4.html
index f377496..7868913 100644
--- a/exit_step4.html
+++ b/exit_step4.html
@@ -44,6 +44,24 @@
{{* lister les amortissements liés à l'immobilisation *}}
{{:include file="./_get_amort_lines.html" immo_doc_id=$_GET.immo_doc_id keep="linked_amort, total_amort"}}
+{{* chercher une écriture de cession associée *}}
+{{#load type="cession_link"
+ where="$$.immo_doc_id = :immo_doc_id"
+ :immo_doc_id = $_GET.immo_doc_id|intval
+ }}
+ {{if $amount == null || $amount == 0}}
+ {{#select credit
+ FROM acc_transactions_lines
+ WHERE id = :cession_line_id;
+ :cession_line_id = $cession_line_id
+ }}
+ {{:assign montant_cession=$credit}}
+ {{/select}}
+ {{else}}
+ {{:assign montant_cession=$amount}}
+ {{/if}}
+{{/load}}
+
{{* chercher une écriture de sortie de bilan associée *}}
{{#load type="exit_link" where="$$.immo_doc_id = :immo_doc_id" :immo_doc_id=$info_immo.id assign="exit_info"}}
{{/load}}
@@ -200,6 +218,10 @@
Valeur nette résiduelle
{{"%d-%d"|math:$solde:$total_amort|money_currency_html:false|raw}}
{{/if}}
+ {{if $montant_cession > 0}}
+ Montant de la cession
+ {{$montant_cession|money_currency_html:false|raw}}
+ {{/if}}
diff --git a/link_immo.html b/link_immo.html
index 557b0e8..43be090 100644
--- a/link_immo.html
+++ b/link_immo.html
@@ -18,7 +18,11 @@
{{*
lister les écritures au crédit du compte de l'immobilisation
*}}
-{{:assign account_code=$ligne_immo.account_code|cat:"%"}}
+{{if $_GET.filter}}
+ {{:assign account_code=$ligne_immo.account_code|cat:"%"}}
+{{else}}
+ {{:assign account_code=$ligne_immo.account_code|substr:0:2|cat:"%"}}
+{{/if}}
{{#select
line.id as credit_line_id,
line.id_transaction as credit_trans_id,
@@ -61,23 +65,32 @@
}}
{{/if}}
-
-
{{if $other_immos != null}}
@@ -111,8 +124,8 @@
{{/foreach}}
+ Sélectionner une écriture d'avoir ou autre réduction du montant de l'acquisition pour l'associer à l'immobilisation
- Sélectionner une écriture d'avoir ou autre réduction du montant de l'acquisition pour l'associer à l'immobilisation
{{else}}
Aucune écriture au crédit du compte « {{$ligne_immo.account_code}} »
{{/if}}
diff --git a/other_amortizations.html b/other_amortizations.html
index 8716a25..45488ca 100644
--- a/other_amortizations.html
+++ b/other_amortizations.html
@@ -60,9 +60,19 @@
-{{if $free_amort_lines != null}}
-
- Immobilisation « {{$label_immo}} »
+
+
+
+ {{if $free_amort_lines != null}}
@@ -106,11 +116,12 @@
{{/foreach}}
+ Sélectionner une écriture d'amortissement pour l'associer à l'immobilisation
-
-{{else}}
- Aucun amortissement pour le compte {{$code_amort}}
-{{/if}}
+ {{else}}
+ Aucun amortissement pour le compte {{$code_amort}}
+ {{/if}}
+
{{:form_errors}}