diff --git a/_archives.html b/_archives.html
index ce92aff..8a8f8ad 100644
--- a/_archives.html
+++ b/_archives.html
@@ -153,7 +153,7 @@
{{$account_code}} |
{{$account_label}} |
- {{:linkbutton label="Modifier" href="exit_step4.html?immo_doc_id=%s"|args:$info_immo.id shape="edit"}}
+ {{:linkbutton label="Modifier" href="exit_step3.html?immo_doc_id=%s"|args:$info_immo.id shape="edit"}}
|
{{/select}}
@@ -172,6 +172,7 @@
{{$value|money_html:false|raw}} |
|
|
+ |
|
{{/foreach}}
@@ -183,6 +184,7 @@
{{$total_immo|money_html:false|raw}} |
|
|
+ |
|
{{/if}}
@@ -199,6 +201,7 @@
{{$value|money_html:false|raw}} |
|
|
+ |
|
{{/foreach}}
@@ -210,6 +213,7 @@
{{$total_cessions|money_html:false|raw}} |
|
|
+ |
|
{{/if}}
diff --git a/attach_cession.html b/attach_cession.html
deleted file mode 100644
index 008a4b0..0000000
--- a/attach_cession.html
+++ /dev/null
@@ -1,61 +0,0 @@
-{{* -*- brindille -*- *}}
-
-{{*
- Enregistrer la liaison entre une écriture d'immobilisation et
- une écriture de cession
- @param immo_doc_id : id du document associé à l'immobilisation
- @param cession_line_id : ligne de l'écriture de cession
-*}}
-
-{{* données de l'immobilisation *}}
-{{:include file="_get_immo_data.html" immo_doc_id=$_GET.immo_doc_id keep="info_immo, ligne_immo, message"}}
-{{if $message != null}}
- {{:error message=$message}}
-{{/if}}
-
-{{* chercher l'écriture de cession de l'immobilisation *}}
-{{#select
- id_transaction
- FROM acc_transactions_lines
- WHERE id = :line_id;
- :line_id = $_GET.cession_line_id|intval
-}}
- {{:assign rebut_id=$id_transaction}}
-{{else}}
- {{:error message="Impossible de trouver l'écriture de cession de l'immobilisation"}}
-{{/select}}
-
-{{* chercher les liaisons de l'écriture d'immobilisation *}}
-{{#select
- CASE links.id_related = :immo_trans_id
- WHEN true THEN links.id_transaction
- WHEN false THEN links.id_related
- END as linked_id
- FROM acc_transactions_links as links
- WHERE id_transaction = :immo_trans_id or id_related = :immo_trans_id;
- :immo_trans_id = $ligne_immo.trans_id
-}}
- {{:assign var="linked_transactions." value=$linked_id}}
-{{/select}}
-
-{{* ajouter la nouvelle liaison *}}
-{{:assign var="linked_transactions." value=$rebut_id}}
-
-{{* Enregistrer les liaisons *}}
-{{:api
- method="POST"
- path="accounting/transaction/%s/transactions"|args:$ligne_immo.trans_id
- assign="result"
- assign_code="result_code"
- transactions=$linked_transactions
-}}
-
-{{* enregistrer la liaison de l'écriture de cession *}}
-{{:save
- key=""|uuid
- type="cession_link"
- immo_doc_id=$info_immo.id
- cession_line_id=$_GET.cession_line_id|intval
-}}
-
-{{:redirect force="exit_step3.html?immo_doc_id=%s&ok=1&msg=attach_cession"|args:$_GET.immo_doc_id}}
diff --git a/attach_exit.html b/attach_exit.html
index d639722..11bc17c 100644
--- a/attach_exit.html
+++ b/attach_exit.html
@@ -58,4 +58,4 @@
exit_line_id=$_GET.exit_line_id|intval
}}
-{{:redirect to="exit_step4.html?immo_doc_id=%s&ok=1&msg=attach_exit"|args:$_GET.immo_doc_id}}
+{{:redirect to="exit_step3.html?immo_doc_id=%s&ok=1&msg=attach_exit"|args:$_GET.immo_doc_id}}
diff --git a/detach_cession.html b/detach_cession.html
deleted file mode 100644
index eab7863..0000000
--- a/detach_cession.html
+++ /dev/null
@@ -1,21 +0,0 @@
-{{* -*- brindille -*- *}}
-
-{{*
- Supprimer l'association entre une écriture d'immobilisation et
- une écriture de cession
- @param immo_doc_id : id du doc associé à l'immo
- @param cession_line_id : id de la ligne de cession
-*}}
-
-{{:include file="_common_detach.html" immo_doc_id=$_GET.immo_doc_id line_id=$_GET.cession_line_id}}
-
-{{* supprimer le doc de liaison entre les lignes *}}
-{{#load type="cession_link"
- where="$$.immo_doc_id = :immo_doc_id AND $$.cession_line_id = :cession_line_id"
- :immo_doc_id=$_GET.immo_doc_id|intval
- :cession_line_id = $_GET.cession_line_id|intval
-}}
- {{:delete id=$id}}
-{{/load}}
-
-{{:redirect to="exit_step3.html?immo_doc_id=%s&ok=1&msg=detach_cession"|args:$_GET.immo_doc_id}}
diff --git a/detach_exit.html b/detach_exit.html
index 1a71701..486fc7c 100644
--- a/detach_exit.html
+++ b/detach_exit.html
@@ -18,4 +18,4 @@
{{:delete id=$id}}
{{/load}}
-{{:redirect to="exit_step4.html?immo_doc_id=%s&ok=1&msg=detach_exit"|args:$_GET.immo_doc_id}}
+{{:redirect to="exit_step3.html?immo_doc_id=%s&ok=1&msg=detach_exit"|args:$_GET.immo_doc_id}}
diff --git a/exit_step1.html b/exit_step1.html
index 0fc2fb1..d3cc904 100644
--- a/exit_step1.html
+++ b/exit_step1.html
@@ -1,7 +1,7 @@
{{* -*- brindille -*- *}}
{{*
- Associer des écritures de crédit à une immo créée et sortie du
+ Associer les différentes écritures à une immo créée et sortie du
bilan avant la mise en service du module
@param immo_doc_id : id du doc associé à l'immobilisation
*}}
@@ -197,7 +197,7 @@
{{/if}}
{{if $credit_lines}}
- Autres écritures au crédit du compte d'immobilisation
+ Écritures au crédit du compte d'immobilisation
diff --git a/exit_step2.html b/exit_step2.html
index 8199426..699b947 100644
--- a/exit_step2.html
+++ b/exit_step2.html
@@ -1,7 +1,7 @@
{{* -*- brindille -*- *}}
{{*
- Associer des écritures d'amortissement à une immo créée et sortie du
+ Associer les différentes écritures à une immo créée et sortie du
bilan avant la mise en service du module
@param immo_doc_id : id du doc associé à l'immobilisation
*}}
diff --git a/exit_step3.html b/exit_step3.html
index 5d8ff0d..671b415 100644
--- a/exit_step3.html
+++ b/exit_step3.html
@@ -1,8 +1,7 @@
{{* -*- brindille -*- *}}
-{{:admin_header title="Immobilisation sortie du bilan" custom_css="./style.css" current="module_amortization"}}
{{*
- Associer une écriture de cession à une immo créée et sortie du
+ Associer les différentes écritures à une immo créée et sortie du
bilan avant la mise en service du module
@param immo_doc_id : id du doc associé à l'immobilisation
*}}
@@ -17,8 +16,17 @@
{{:redirect to="exit_step2.html?immo_doc_id=%s"|args:$_GET.immo_doc_id}}
{{/form}}
-{{#form on="forward"}}
- {{:redirect to="exit_step4.html?immo_doc_id=%s"|args:$_GET.immo_doc_id}}
+{{#form on="validate"}}
+ {{* mettre à jour l'état de l'immobilisation *}}
+ {{:save
+ key=$info_immo.key
+ status="archived"
+ }}
+ {{:redirect to="index.html?type_immo=archived"}}
+{{/form}}
+
+{{#form on="finish"}}
+ {{:redirect to="index.html?type_immo=managed"}}
{{/form}}
{{:assign label_immo=$info_immo.label|or:$ligne_immo.trans_label}}
@@ -36,13 +44,84 @@
{{* 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 des écritures de cession *}}
-{{:assign total_cession=0}}
+{{* 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}}
+{{if $exit_info != null}}
+ {{#select
+ trans.id as trans_id,
+ trans.label as trans_label,
+ trans.date as date,
+ line.id as line_id,
+ line.label as line_label,
+ line.credit as amount,
+ acc.id as account_id,
+ acc.code as account_code,
+ acc.label as account_label
+ FROM acc_transactions AS trans
+ INNER JOIN acc_transactions_lines AS line ON line.id_transaction = trans.id
+ INNER JOIN acc_accounts AS acc ON line.id_account = acc.id
+ WHERE line.id = :exit_line_id;
+ :exit_line_id = $exit_info.exit_line_id
+ assign="exit_line"
+ }}
+ {{/select}}
+{{/if}}
+
+{{*
+ chercher des écritures au crédit du compte de l'immo sans doc associé
+ - line.credit < ligne_immo.amount => peut-être un avoir
+ - line.credit = ligne_immo.amount - avoirs => écriture de sortie du bilan
+*}}
{{#select
- line.id as line_id,
- line.credit as amount,
- line.label as line_label,
trans.id as trans_id,
+ trans.label as trans_label,
+ trans.date as date,
+ trans.id_year as year,
+ line.id as credit_line_id,
+ line.label as line_label,
+ line.credit as amount,
+ acc.id as account_id,
+ acc.code as account_code,
+ acc.label as account_label
+ FROM acc_transactions AS trans
+ INNER JOIN acc_transactions_lines AS line ON line.id_transaction = trans.id
+ INNER JOIN acc_accounts AS acc ON line.id_account = acc.id
+ LEFT JOIN module_data_amortization AS mda ON json_extract(mda.document, '$.amort_line_id') = line.id
+ WHERE
+ acc.code = :acc_code
+ AND line.credit > 0
+ AND credit_line_id NOT IN (
+ SELECT json_extract(credit_link.document, '$.credit_line_id') AS line_id FROM !table as credit_link
+ WHERE json_extract(credit_link.document, '$.type') == "credit_link"
+ UNION
+ SELECT json_extract(exit_link.document, '$.exit_line_id') AS line_id FROM !table as exit_link
+ WHERE json_extract(exit_link.document, '$.type') == "exit_link"
+ )
+ ;
+ :acc_code=$ligne_immo.account_code
+ !table =$module.table
+ assign="credit_line"
+ }}
+ {{if $credit_line.amount == $solde}}
+ {{:assign var="exit_lines." value=$credit_line}}
+ {{/if}}
+{{/select}}
+
+{{* déterminer le compte d'amortissement en fonction du compte d'immobilisation *}}
+{{:include
+ file="./_get_amort_code.html"
+ code_immo=$ligne_immo.account_code
+ keep="code_amort"
+}}
+
+{{* chercher des écritures d'amortissement correspondant au compte d'une immo sans doc associé *}}
+{{* TODO écritures d'amort pas entièrement affectées *}}
+{{#select
+ line.id as amort_line_id,
+ line.credit as amort_amount,
+ line.label as line_label,
+ trans.id as amort_trans_id,
trans.date as date,
trans.label as trans_label,
trans.id_year as year,
@@ -52,39 +131,45 @@
FROM acc_transactions_lines AS line
INNER JOIN acc_accounts AS account ON line.id_account = account.id
INNER JOIN acc_transactions AS trans ON line.id_transaction = trans.id
- WHERE account.code LIKE :code_cession_new OR account.code LIKE :code_cession_old
+ WHERE
+ account.code = :code_amort
+ AND line.credit > 0
+ AND (NOT trans.status & 16)
+ AND trans.date >= :immo_date
;
- :code_cession_new = "757%"
- :code_cession_old = "775%"
- assign="line"
+ :code_amort = $code_amort
+ :immo_date=$date_immo
+ assign="amort_line"
}}
- {{* voir si l'écriture de cession est déjà liée à une immo *}}
- {{#select
- CASE WHEN links.id_related = :trans_id
- THEN links.id_transaction
- ELSE links.id_related
- END as linked_id
- FROM acc_transactions_links as links
- WHERE links.id_transaction = :trans_id OR links.id_related = :trans_id
- ;
- :trans_id = $line.trans_id
+ {{* voir s'il existe des lignes d'immo liées à cette ligne d'amortissement *}}
+ {{:assign amort_amount=0}}
+ {{:assign keep_amort=true}}
+ {{#load type="amort_link"
+ where="$$.amort_line_id = :amort_line_id"
+ :amort_line_id=$amort_line.amort_line_id|intval
+ assign="amort_link"
}}
- {{if $linked_id == $ligne_immo.trans_id}}
- {{:assign total_cession="%d+%d"|math:$total_cession:$line.amount}}
- {{:assign var="line.linked_id" value=$linked_id}}
- {{:assign var="linked_cessions." value=$line}}
+ {{if $amort_link.amount == null || $amort_link.amount == 0}}
+ {{:assign amort_amount=$amort_line.amort_amount}}
+ {{:assign keep_amort=false}}
+ {{else}}
+ {{:assign amort_amount="%d+%d"|math:$amort_amount:$amort_link.amount}}
{{/if}}
{{else}}
- {{:assign var="free_cessions." value=$line}}
- {{/select}}
+ {{* pas de ligne d'immo liée à cette ligne d'amort => garder cette ligne d'amortissement *}}
+ {{/load}}
+ {{if $keep_amort && $amort_amount < $amort_line.amort_amount}}
+ {{:assign var="free_amort_lines." value=$amort_line}}
+ {{/if}}
{{/select}}
-{{*:debug linked_cessions=$linked_cessions free_cessions=$free_cessions total_cession=$total_cession*}}
+
+{{:admin_header title="Immobilisation sortie du bilan" custom_css="./style.css" current="module_amortization"}}
{{if $_GET.ok}}
- {{if $_GET.msg|match:"attach_cession"}}
- {{:assign msg="Écriture de cession attachée"}}
- {{elseif $_GET.msg|match:"detach_cession"}}
- {{:assign msg="Écriture de cession détachée"}}
+ {{if $_GET.msg|match:"attach_exit"}}
+ {{:assign msg="Écriture de sortie de bilan attachée"}}
+ {{elseif $_GET.msg|match:"detach_exit"}}
+ {{:assign msg="Écriture de sortie de bilan détachée"}}
{{/if}}
{{$msg}}
{{/if}}
@@ -109,15 +194,11 @@
Valeur nette résiduelle
{{"%d-%d"|math:$solde:$total_amort|money_currency_html:false|raw}}
{{/if}}
- {{if $total_cession > 0}}
- Montant de la cession
- {{$total_cession|money_currency_html:false|raw}}
- {{/if}}
-{{if $linked_cessions != null}}
- Écriture de cession attachée à l'immobilisation
+{{if $exit_line != null}}
+ Écriture de sortie du bilan attachée à l'immobilisation
@@ -131,91 +212,77 @@
- {{#foreach from=$linked_cessions item="line"}}
- {{* données de l'écriture *}}
- {{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$line.trans_id}}
- {{:assign compte_url="%s/acc/accounts/journal.php?id=%s&year=%s"|args:$admin_url:$line.account_id:$line.year}}
-
- | #{{$line.trans_id}} |
- {{$line.date|date_short}} |
-
- {{if $line.line_label != null}}
- {{$line.line_label}}
- {{if $line.trans_label != $line.line_label}}
- — {{$line.trans_label}}
- {{/if}}
- {{else}}
- {{$line.trans_label}}
- {{/if}}
- |
- {{"%f"|math:$line.amount|money_html:false|raw}} |
- {{$line.account_code}} |
- {{$line.account_label}} |
-
- {{:linkbutton label="Détacher" href="detach_cession.html?immo_doc_id=%s&cession_line_id=%s&from=exit"|args:$_GET.immo_doc_id:$line.line_id shape="minus"}}
- |
-
- {{/foreach}}
+
+ | #{{$exit_line.trans_id}} |
+ {{$exit_line.date|date_short}} |
+
+ {{if $exit_line.line_label != null}}
+ {{$exit_line.line_label}}
+ {{else}}
+ {{$exit_line.trans_label}}
+ {{/if}}
+ |
+ {{"%f"|math:$exit_line.amount|money_html:false|raw}} |
+ {{$exit_line.account_code}} |
+ {{$exit_line.account_label}} |
+
+ {{:linkbutton label="Détacher" href="detach_exit.html?immo_doc_id=%s&exit_line_id=%s&from=exit"|args:$_GET.immo_doc_id:$exit_line.line_id shape="minus"}}
+ |
+
-{{elseif $free_cessions}}
+{{elseif $exit_lines}}
- Vous pouvez attacher une écriture de cession à l'immobilisation
-
-{{else}}
-
- Aucune écriture de cession... que faire ?
+ Vous pouvez attacher une écriture de sortie du bilan à l'immobilisation
{{/if}}
-
-{{if $free_cessions}}
- Autres écritures de cession
+{{if $exit_lines}}
+ Écritures non rattachées
-
- | N° |
- Date |
- Libellé |
- Montant |
- N° compte |
- Compte |
- |
-
-
-
-
- {{#foreach from=$free_cessions item="line"}}
- {{:assign cession_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$line.trans_id}}
- {{:assign compte_url="%s/acc/accounts/journal.php?id=%s&year=%s"|args:$admin_url:$line.account_id:$line.year}}
- | #{{$line.trans_id}} |
- {{$line.date|date_short}} |
-
- {{if $line.line_label != null}}
- {{$line.line_label}}
- {{if $line.trans_label != $line.line_label}}
- — {{$line.trans_label}}
- {{/if}}
- {{else}}
- {{$line.trans_label}}
- {{/if}}
- |
- {{"%f"|math:$line.amount|money_html:false|raw}} |
- {{$line.account_code}} |
- {{$line.account_label}} |
-
- {{:linkbutton label="Attacher" href="attach_cession.html?immo_doc_id=%s&cession_line_id=%s&from=exit"|args:$_GET.immo_doc_id:$line.line_id shape="plus"}}
- |
+ N° |
+ Date |
+ Libellé |
+ Montant |
+ N° compte |
+ Compte |
+ |
- {{/foreach}}
-
+
+
+
+ {{#foreach from=$exit_lines item="line"}}
+ {{:assign exit_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$line.trans_id}}
+ {{:assign compte_url="%s/acc/accounts/journal.php?id=%s&year=%s"|args:$admin_url:$line.account_id:$line.year}}
+
+ | #{{$line.trans_id}} |
+ {{$line.date|date_short}} |
+ {{$line.trans_label}}
+ {{if $line.line_label != null && $line.line_label != $line.trans_label}} — {{$line.line_label}}{{/if}}
+ |
+ {{"%f"|math:$line.amount|money_html:false|raw}} |
+ {{$line.account_code}} |
+ {{$line.account_label}} |
+
+ {{:linkbutton label="Attacher" href="attach_exit.html?immo_doc_id=%s&exit_line_id=%s&from=exit"|args:$_GET.immo_doc_id:$line.credit_line_id shape="plus"}}
+ |
+
+ {{/foreach}}
+
+{{elseif $exit_line == null}}
+ Aucune écriture de sortie du bilan. Vérifiez l'attachement d'écriture d'avoir.
{{/if}}
diff --git a/exit_step4.html b/exit_step4.html
deleted file mode 100644
index ccb6d7f..0000000
--- a/exit_step4.html
+++ /dev/null
@@ -1,288 +0,0 @@
-{{* -*- brindille -*- *}}
-
-{{*
- Associer les différentes écritures à une immo créée et sortie du
- bilan avant la mise en service du module
- @param immo_doc_id : id du doc associé à l'immobilisation
-*}}
-
-{{* données de l'immobilisation *}}
-{{:include file="_get_immo_data.html" immo_doc_id=$_GET.immo_doc_id keep="info_immo, ligne_immo, message"}}
-{{if $message != null}}
- {{:error message=$message}}
-{{/if}}
-
-{{#form on="backward"}}
- {{:redirect to="exit_step3.html?immo_doc_id=%s"|args:$_GET.immo_doc_id}}
-{{/form}}
-
-{{#form on="validate"}}
- {{* mettre à jour l'état de l'immobilisation *}}
- {{:save
- key=$info_immo.key
- status="archived"
- }}
- {{:redirect to="index.html?type_immo=archived"}}
-{{/form}}
-
-{{#form on="finish"}}
- {{:redirect to="index.html?type_immo=managed"}}
-{{/form}}
-
-{{:assign label_immo=$info_immo.label|or:$ligne_immo.trans_label}}
-{{if $ligne_immo.line_label != null && $ligne_immo.line_label != $label_immo}}
- {{:assign label_immo=$label_immo|cat:" — "|cat:$ligne_immo.line_label}}
-{{/if}}
-{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$ligne_immo.trans_id}}
-{{:assign date_immo=$info_immo.date_mes|or:$info_immo.date_achat|or:$ligne_immo.date_achat}}
-{{:assign montant_immo=$info_immo.amount|or:$ligne_immo.amount}}
-
-{{* déduire le montant des écritures liées à l'immo courante au crédit du même compte *}}
-{{:include file="_get_credit_lines.html" immo_doc_id=$_GET.immo_doc_id keep="linked_immos, total_credits"}}
-{{:assign solde="%d-%d"|math:$montant_immo:$total_credits}}
-
-{{* 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 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}}
-{{if $exit_info != null}}
- {{#select
- trans.id as trans_id,
- trans.label as trans_label,
- trans.date as date,
- line.id as line_id,
- line.label as line_label,
- line.credit as amount,
- acc.id as account_id,
- acc.code as account_code,
- acc.label as account_label
- FROM acc_transactions AS trans
- INNER JOIN acc_transactions_lines AS line ON line.id_transaction = trans.id
- INNER JOIN acc_accounts AS acc ON line.id_account = acc.id
- WHERE line.id = :exit_line_id;
- :exit_line_id = $exit_info.exit_line_id
- assign="exit_line"
- }}
- {{/select}}
-{{/if}}
-
-{{*
- chercher des écritures au crédit du compte de l'immo sans doc associé
- - line.credit < ligne_immo.amount => peut-être un avoir
- - line.credit = ligne_immo.amount - avoirs => écriture de sortie du bilan
-*}}
-{{#select
- trans.id as trans_id,
- trans.label as trans_label,
- trans.date as date,
- trans.id_year as year,
- line.id as credit_line_id,
- line.label as line_label,
- line.credit as amount,
- acc.id as account_id,
- acc.code as account_code,
- acc.label as account_label
- FROM acc_transactions AS trans
- INNER JOIN acc_transactions_lines AS line ON line.id_transaction = trans.id
- INNER JOIN acc_accounts AS acc ON line.id_account = acc.id
- LEFT JOIN module_data_amortization AS mda ON json_extract(mda.document, '$.amort_line_id') = line.id
- WHERE
- acc.code = :acc_code
- AND line.credit > 0
- AND credit_line_id NOT IN (
- SELECT json_extract(credit_link.document, '$.credit_line_id') AS line_id FROM !table as credit_link
- WHERE json_extract(credit_link.document, '$.type') == "credit_link"
- UNION
- SELECT json_extract(exit_link.document, '$.exit_line_id') AS line_id FROM !table as exit_link
- WHERE json_extract(exit_link.document, '$.type') == "exit_link"
- )
- ;
- :acc_code=$ligne_immo.account_code
- !table =$module.table
- assign="credit_line"
- }}
- {{if $credit_line.amount == $solde}}
- {{:assign var="exit_lines." value=$credit_line}}
- {{/if}}
-{{/select}}
-
-{{* déterminer le compte d'amortissement en fonction du compte d'immobilisation *}}
-{{:include
- file="./_get_amort_code.html"
- code_immo=$ligne_immo.account_code
- keep="code_amort"
-}}
-
-{{* chercher des écritures d'amortissement correspondant au compte d'une immo sans doc associé *}}
-{{* TODO écritures d'amort pas entièrement affectées *}}
-{{#select
- line.id as amort_line_id,
- line.credit as amort_amount,
- line.label as line_label,
- trans.id as amort_trans_id,
- trans.date as date,
- trans.label as trans_label,
- trans.id_year as 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 line.id_account = account.id
- INNER JOIN acc_transactions AS trans ON line.id_transaction = trans.id
- WHERE
- account.code = :code_amort
- AND line.credit > 0
- AND (NOT trans.status & 16)
- AND trans.date >= :immo_date
- ;
- :code_amort = $code_amort
- :immo_date=$date_immo
- assign="amort_line"
-}}
- {{* voir s'il existe des lignes d'immo liées à cette ligne d'amortissement *}}
- {{:assign amort_amount=0}}
- {{:assign keep_amort=true}}
- {{#load type="amort_link"
- where="$$.amort_line_id = :amort_line_id"
- :amort_line_id=$amort_line.amort_line_id|intval
- assign="amort_link"
- }}
- {{if $amort_link.amount == null || $amort_link.amount == 0}}
- {{:assign amort_amount=$amort_line.amort_amount}}
- {{:assign keep_amort=false}}
- {{else}}
- {{:assign amort_amount="%d+%d"|math:$amort_amount:$amort_link.amount}}
- {{/if}}
- {{else}}
- {{* pas de ligne d'immo liée à cette ligne d'amort => garder cette ligne d'amortissement *}}
- {{/load}}
- {{if $keep_amort && $amort_amount < $amort_line.amort_amount}}
- {{:assign var="free_amort_lines." value=$amort_line}}
- {{/if}}
-{{/select}}
-
-{{:admin_header title="Immobilisation sortie du bilan" custom_css="./style.css" current="module_amortization"}}
-
-{{if $_GET.ok}}
- {{if $_GET.msg|match:"attach_exit"}}
- {{:assign msg="Écriture de sortie de bilan attachée"}}
- {{elseif $_GET.msg|match:"detach_exit"}}
- {{:assign msg="Écriture de sortie de bilan détachée"}}
- {{/if}}
- {{$msg}}
-{{/if}}
-
-
-
-{{if $exit_line != null}}
- Écriture de sortie du bilan attachée à l'immobilisation
-
-
-
- | N° |
- Date |
- Libellé |
- Montant |
- N° compte |
- Compte |
- |
-
-
-
-
- | #{{$exit_line.trans_id}} |
- {{$exit_line.date|date_short}} |
-
- {{if $exit_line.line_label != null}}
- {{$exit_line.line_label}}
- {{else}}
- {{$exit_line.trans_label}}
- {{/if}}
- |
- {{"%f"|math:$exit_line.amount|money_html:false|raw}} |
- {{$exit_line.account_code}} |
- {{$exit_line.account_label}} |
-
- {{:linkbutton label="Détacher" href="detach_exit.html?immo_doc_id=%s&exit_line_id=%s&from=exit"|args:$_GET.immo_doc_id:$exit_line.line_id shape="minus"}}
- |
-
-
-
-{{elseif $exit_lines}}
-
- Vous pouvez attacher une écriture de sortie du bilan à l'immobilisation
-
-{{/if}}
-
-{{if $exit_lines}}
- Écritures non rattachées
-
-
-
- | N° |
- Date |
- Libellé |
- Montant |
- N° compte |
- Compte |
- |
-
-
-
-
- {{#foreach from=$exit_lines item="line"}}
- {{:assign exit_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$line.trans_id}}
- {{:assign compte_url="%s/acc/accounts/journal.php?id=%s&year=%s"|args:$admin_url:$line.account_id:$line.year}}
-
- | #{{$line.trans_id}} |
- {{$line.date|date_short}} |
- {{$line.trans_label}}
- {{if $line.line_label != null && $line.line_label != $line.trans_label}} — {{$line.line_label}}{{/if}}
- |
- {{"%f"|math:$line.amount|money_html:false|raw}} |
- {{$line.account_code}} |
- {{$line.account_label}} |
-
- {{:linkbutton label="Attacher" href="attach_exit.html?immo_doc_id=%s&exit_line_id=%s&from=exit"|args:$_GET.immo_doc_id:$line.credit_line_id shape="plus"}}
- |
-
- {{/foreach}}
-
-
-{{elseif $exit_line == null}}
- Aucune écriture de sortie du bilan. Vérifiez l'attachement d'écriture d'avoir.
-{{/if}}
-
-
diff --git a/link.schema.json b/link.schema.json
index 111d1bc..88968ed 100644
--- a/link.schema.json
+++ b/link.schema.json
@@ -5,7 +5,7 @@
"properties": {
"type": {
"type": "string",
- "enum": ["amort_link", "credit_link", "cession_link", "exit_link"]
+ "enum": ["amort_link", "credit_link", "exit_link"]
},
"immo_doc_id" : {
"description": "identifiant du document d'immobilisation associé",
@@ -27,11 +27,6 @@
"type": "integer",
"exclusiveMinimum": 0
},
- "cession_line_id": {
- "description": "ligne de cession de l'immobilisation",
- "type": "integer",
- "exclusiveMinimum": 0
- },
"amount": {
"description": "montant de la ligne d'amortissement ou de crédit",
"type": ["number", "null"]
@@ -44,9 +39,6 @@
"if": {"properties": {"type": {"const": "credit_link"}}, "required": ["type"]},
"then": {"required": ["credit_line_id"]},
"else":
- "if": {"properties": {"type": {"const": "cession_link"}}, "required": ["type"]},
- "then": {"required": ["cession_line_id"]},
- "else":
"if": {"properties": {"type": {"const": "exit_link"}}, "required": ["type"]},
"then": {"required": ["exit_line_id"]},
}
diff --git a/write_exit.html b/write_exit.html
index abbf883..ddc1ab0 100644
--- a/write_exit.html
+++ b/write_exit.html
@@ -41,10 +41,6 @@
{{:assign montant_cession="%f*100"|math:$_GET.cession}}
{{/if}}
-{{* numéros de comptes ; voir info.org *}}
-{{:assign vnc_code="652"}}
-{{:assign cession_code="757"}}
-
{{* TODO : faut-il forcer les 3 sélecteurs de compte d'amortissement à avoir toujours la même valeur ? *}}
{{* Traiter l'envoi du formulaire *}}
@@ -244,24 +240,12 @@
}}
{{/if}}
- {{* liaison écriture de cession *}}
- {{#foreach from=$result.lines item="line"}}
- {{if $line.account_code == $cession_code}}
- {{:save
- key=""|uuid
- type="cession_link"
- immo_doc_id=$info_immo.id
- cession_line_id=$line.id
- }}
- {{:break}}
- {{/if}}
- {{/foreach}}
-
{{* mettre à jour l'état de l'immobilisation *}}
{{:save
key=$info_immo.key
status="archived"
}}
+
{{:redirect to="index.html?type_immo=archived"}}
{{/form}}
@@ -281,6 +265,10 @@
keep="code_amort"
}}
+{{* numéros de comptes ; voir info.org *}}
+{{:assign vnc_code="652"}}
+{{:assign cession_code="757"}}
+
{{:assign var="liste_codes.6811" name="comp_account"}}
{{:assign var="liste_codes.687" name="except_account"}}
{{:assign var="liste_codes.462" name="creance_account"}}