From 275a7a18ca549995b59686a43e0a5a6701fc1a12 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Engel Date: Tue, 13 Oct 2026 10:19:15 +0200 Subject: [PATCH 1/4] Mutualisation _detach_xxx --- _archives.html | 7 ++--- _attach_cession.html | 6 ++-- _attach_exit.html | 10 +++--- _detach_amort.html | 27 ---------------- _detach_cession.html | 19 ----------- _detach_credit.html | 19 ----------- _detach_exit.html | 19 ----------- _common_detach.html => _detach_line.html | 27 ++++++++++++++-- _get_amort_lines.html | 3 +- _get_credit_lines.html | 6 ++-- _get_free_amort.html | 2 +- _immobilisations.html | 2 +- _remove_orphan_docs.tpl | 8 ++--- amortization.html | 4 +-- attach_amort.html | 6 ++-- attach_credit.html | 4 +-- delete_infos.html | 2 +- exit_step1.html | 10 +++--- exit_step2.html | 4 +-- exit_step3.html | 4 +-- exit_step4.html | 14 ++++----- link.schema.json | 40 +++++------------------- link_immo.html | 6 ++-- list_cessions.html | 2 +- list_exit.html | 8 ++--- save_amort.html | 2 +- write_exit.html | 6 ++-- 27 files changed, 88 insertions(+), 179 deletions(-) delete mode 100644 _detach_amort.html delete mode 100644 _detach_cession.html delete mode 100644 _detach_credit.html delete mode 100644 _detach_exit.html rename _common_detach.html => _detach_line.html (63%) diff --git a/_archives.html b/_archives.html index b53260c..8d408a7 100644 --- a/_archives.html +++ b/_archives.html @@ -65,13 +65,12 @@ {{* chercher le doc de sortie du bilan *}} {{:assign var="immo_line.exit_date" value=null}} {{#load type="exit_link" where="$$.immo_doc_id = :immo_doc_id" :immo_doc_id=$immo_doc_id}} - {{:assign exit_line_id=$exit_line_id}} {{#select trans.date FROM acc_transactions_lines AS line INNER JOIN acc_transactions AS trans ON line.id_transaction = trans.id WHERE line.id = :exit_line_id; - :exit_line_id=$exit_line_id + :exit_line_id=$line_id }} {{:assign var="immo_line.exit_date" value=$date}} {{/select}} @@ -86,7 +85,7 @@ }} {{if $amount == null}} {{#select credit FROM acc_transactions_lines WHERE id = :credit_line_id; - :credit_line_id=$credit_line_id + :credit_line_id=$line_id }} {{:assign total_credits="%d+%d"|math:$total_credits:$credit}} {{/select}} @@ -106,7 +105,7 @@ line.credit FROM acc_transactions_lines AS line INNER JOIN acc_transactions AS trans ON line.id_transaction = trans.id - INNER JOIN !table AS cession_link ON json_extract(cession_link.document, '$.cession_line_id') = line.id + INNER JOIN !table AS cession_link ON json_extract(cession_link.document, '$.line_id') = line.id INNER JOIN !table AS immo_doc ON json_extract(cession_link.document, '$.immo_doc_id') = immo_doc.id WHERE json_extract(immo_doc.document, '$.line') = :immo_line_id ; diff --git a/_attach_cession.html b/_attach_cession.html index 6216bf6..4defc98 100644 --- a/_attach_cession.html +++ b/_attach_cession.html @@ -4,7 +4,7 @@ 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 + @param line_id : ligne de l'écriture de cession *}} {{* données de l'immobilisation *}} @@ -18,7 +18,7 @@ id_transaction FROM acc_transactions_lines WHERE id = :line_id; - :line_id = $cession_line_id|intval + :line_id = $line_id|intval }} {{:assign cession_id=$id_transaction}} {{else}} @@ -33,5 +33,5 @@ key=""|uuid type="cession_link" immo_doc_id=$info_immo.id - cession_line_id=$cession_line_id|intval + line_id=$line_id|intval }} diff --git a/_attach_exit.html b/_attach_exit.html index e4aa5c8..f1e99b7 100644 --- a/_attach_exit.html +++ b/_attach_exit.html @@ -4,7 +4,7 @@ Enregistrer la liaison entre une écriture d'immobilisation et une écriture de sortie d'immobilisation @param immo_doc_id : id du document associé à l'immobilisation - @param exit_line_id : ligne de l'écriture de sortie d'immobilisation + @param line_id : ligne de l'écriture de sortie d'immobilisation *}} {{* données de l'immobilisation *}} @@ -18,20 +18,20 @@ id_transaction FROM acc_transactions_lines WHERE id = :line_id; - :line_id = $exit_line_id|intval + :line_id = $line_id|intval }} - {{:assign rebut_id=$id_transaction}} + {{:assign exit_id=$id_transaction}} {{else}} {{:error message="Impossible de trouver l'écriture de sortie d'immobilisation"}} {{/select}} {{* Lier l'écriture de sortie à l'écriture d'immobilisation *}} -{{:include file="_common_attach.html" immo_doc_id=$immo_doc_id trans_id=$rebut_id}} +{{:include file="_common_attach.html" immo_doc_id=$immo_doc_id trans_id=$exit_id}} {{* enregistrer la liaison de l'écriture de sortie *}} {{:save key=""|uuid type="exit_link" immo_doc_id=$info_immo.id - exit_line_id=$exit_line_id|intval + line_id=$line_id|intval }} diff --git a/_detach_amort.html b/_detach_amort.html deleted file mode 100644 index 1ceed6a..0000000 --- a/_detach_amort.html +++ /dev/null @@ -1,27 +0,0 @@ -{{* -*- brindille -*- *}} - -{{* - Supprimer l'association entre une écriture d'amortissement et - une écriture d'immobilisation - @param immo_doc_id : id du doc associé à l'immo - @param amort_line_id : id de la ligne d'amortissement -*}} - -{{:include file="_common_detach.html" immo_doc_id=$immo_doc_id line_id=$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" - :immo_doc_id=$immo_doc_id|intval - :amort_line_id = $amort_line_id|intval -}} - {{:delete id=$id}} -{{/load}} - -{{* marquer immo non soldée *}} -{{if $info_immo.status == "amortized"}} - {{:save - key=$info_immo.key - status="managed" - }} -{{/if}} diff --git a/_detach_cession.html b/_detach_cession.html deleted file mode 100644 index 0f230f0..0000000 --- a/_detach_cession.html +++ /dev/null @@ -1,19 +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=$immo_doc_id line_id=$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=$immo_doc_id|intval - :cession_line_id = $cession_line_id|intval -}} - {{:delete id=$id}} -{{/load}} diff --git a/_detach_credit.html b/_detach_credit.html deleted file mode 100644 index 2c36f1d..0000000 --- a/_detach_credit.html +++ /dev/null @@ -1,19 +0,0 @@ -{{* -*- brindille -*- *}} - -{{* - Supprimer l'association entre une écriture d'immobilisation et - une écriture au crédit du compte d'immobilisation - @param immo_doc_id : id du doc associé à l'immo - @param credit_line_id : id de la ligne de crédit -*}} - -{{:include file="_common_detach.html" immo_doc_id=$immo_doc_id line_id=$credit_line_id}} - -{{* supprimer le doc de liaison entre les lignes *}} -{{#load type="credit_link" - where="$$.immo_doc_id = :immo_doc_id AND $$.credit_line_id = :credit_line_id" - :immo_doc_id=$immo_doc_id|intval - :credit_line_id = $credit_line_id|intval -}} - {{:delete id=$id}} -{{/load}} diff --git a/_detach_exit.html b/_detach_exit.html deleted file mode 100644 index b811cde..0000000 --- a/_detach_exit.html +++ /dev/null @@ -1,19 +0,0 @@ -{{* -*- brindille -*- *}} - -{{* - Supprimer l'association entre une écriture d'immobilisation et - une écriture de sortie de bilan - @param immo_doc_id : id du doc associé à l'immo - @param exit_line_id : id de la ligne de sortie de bilan -*}} - -{{:include file="_common_detach.html" immo_doc_id=$immo_doc_id line_id=$exit_line_id}} - -{{* supprimer le doc de liaison entre les lignes *}} -{{#load type="exit_link" - where="$$.immo_doc_id = :immo_doc_id AND $$.exit_line_id = :exit_line_id" - :immo_doc_id=$immo_doc_id|intval - :exit_line_id = $exit_line_id|intval -}} - {{:delete id=$id}} -{{/load}} diff --git a/_common_detach.html b/_detach_line.html similarity index 63% rename from _common_detach.html rename to _detach_line.html index e7b6c7a..0c552c9 100644 --- a/_common_detach.html +++ b/_detach_line.html @@ -1,9 +1,10 @@ {{* -*- brindille -*- *}} {{* - Supprimer l'association entre une ligne d'immo et une autre ligne (amort, credit, cession, sortie) - @param immo_doc_id : id du doc associé à la ligne d'immobilisation - @param line_id : id de la ligne à détacher + Supprimer l'association entre une ligne d'immobilisation et une ligne associée + @param immo_doc_id : id du doc associé à l'immo + @param line_id : id de la ligne associée + @param type : type de ligne associée (amort, credit, cession, exit, ...) *}} {{* données de l'immobilisation *}} @@ -50,3 +51,23 @@ assign_code="result_code" transactions=$linked_transactions }} + +{{* supprimer le doc de liaison entre les lignes *}} +{{:assign link_type=$type|cat:"_link"}} +{{#load type=$link_type + where="$$.immo_doc_id = :immo_doc_id AND $$.line_id = :line_id" + :immo_doc_id=$immo_doc_id|intval + :line_id = $line_id|intval +}} + {{:delete id=$id}} +{{/load}} + +{{if $type == "amort"}} + {{if $info_immo.status == "amortized"}} + {{* marquer immo non soldée *}} + {{:save + key=$info_immo.key + status="managed" + }} + {{/if}} +{{/if}} diff --git a/_get_amort_lines.html b/_get_amort_lines.html index cfa070a..f054afa 100644 --- a/_get_amort_lines.html +++ b/_get_amort_lines.html @@ -8,7 +8,6 @@ @result total_amort : montant total des amortissements de l'immobilisation @result created_amort : vrai s'il y a au moins un amortissement créé par le module dans la liste *}} - {{:assign total_amort=0}} {{#load type="amort_link" where="$$.immo_doc_id = :immo_doc_id" @@ -31,7 +30,7 @@ INNER join acc_accounts AS account on line.id_account = account.id WHERE line.id = :amort_line_id ; - :amort_line_id = $amort_line_id + :amort_line_id = $amort_info.line_id assign="amort_line" }} {{:assign var="amort_line.amount" value=$amort_info.amount|or:$amort_line.amount}} diff --git a/_get_credit_lines.html b/_get_credit_lines.html index c06adc5..36bf72e 100644 --- a/_get_credit_lines.html +++ b/_get_credit_lines.html @@ -8,7 +8,7 @@ *}} {{:assign linked_immos=null}} {{:assign total_credits=0}} -{{#load type="credit_link" where="$$.immo_doc_id=:immo_doc_id" :immo_doc_id=$immo_doc_id|intval}} +{{#load type="credit_link" where="$$.immo_doc_id=:immo_doc_id" :immo_doc_id=$immo_doc_id|intval assign="credit_info"}} {{#select line.credit, line.id as line_id, @@ -23,8 +23,8 @@ INNER JOIN acc_transactions AS trans ON line.id_transaction = trans.id INNER join acc_accounts AS account on line.id_account = account.id WHERE line.id = :credit_line_id; - :credit_line_id=$credit_line_id - }} + :credit_line_id=$credit_info.line_id + }} {{:assign credit=$credit}} {{:assign var="linked_immos." doc=$id trans_id=$trans_id credit_line_id=$line_id label=$label amount=$credit date=$date account_id=$account_id account_code=$account_code account_label=$account_label year=$year}} {{/select}} diff --git a/_get_free_amort.html b/_get_free_amort.html index e71ec16..646288d 100644 --- a/_get_free_amort.html +++ b/_get_free_amort.html @@ -27,7 +27,7 @@ {{:assign amort_amount=0}} {{:assign keep_amort=true}} {{#load type="amort_link" - where="$$.amort_line_id = :amort_line_id" + where="$$.line_id = :amort_line_id" :amort_line_id=$amort_line.line_id|intval assign="amort_link" }} diff --git a/_immobilisations.html b/_immobilisations.html index cc0fc76..51f9f1c 100644 --- a/_immobilisations.html +++ b/_immobilisations.html @@ -62,7 +62,7 @@ }} {{if $amount == null}} {{#select credit FROM acc_transactions_lines WHERE id = :credit_line_id; - :credit_line_id=$credit_line_id + :credit_line_id=$line_id }} {{:assign montant_immo="%d-%d"|math:$montant_immo:$credit}} {{/select}} diff --git a/_remove_orphan_docs.tpl b/_remove_orphan_docs.tpl index 2514171..a2ba62a 100644 --- a/_remove_orphan_docs.tpl +++ b/_remove_orphan_docs.tpl @@ -2,10 +2,10 @@ {{if $module.table}} {{* supprimer les documents sans écriture associée *}} - {{:assign var="docs." type="amort_link" field="amort_line_id"}} - {{:assign var="docs." type="credit_link" field="credit_line_id"}} - {{:assign var="docs." type="cession_link" field="cession_line_id"}} - {{:assign var="docs." type="exit_link" field="exit_line_id"}} + {{:assign var="docs." type="amort_link" field="line_id"}} + {{:assign var="docs." type="credit_link" field="line_id"}} + {{:assign var="docs." type="cession_link" field="line_id"}} + {{:assign var="docs." type="exit_link" field="line_id"}} {{:assign var="docs." type="immo" field="line"}} {{#foreach from=$docs}} diff --git a/amortization.html b/amortization.html index 35af614..02963f7 100644 --- a/amortization.html +++ b/amortization.html @@ -17,7 +17,7 @@ une écriture au crédit du compte d'immobilisation *}} {{#form on="detach_credit"}} - {{:include file="_detach_credit.html" immo_doc_id=$_POST.immo_doc_id credit_line_id=$_POST.detach_credit}} + {{:include file="_detach_line.html" immo_doc_id=$_POST.immo_doc_id line_id=$_POST.detach_credit type="credit"}} {{:redirect to="?immo_doc_id=%s&ok=1&msg=detach_avoir"|args:$_POST.immo_doc_id}} {{/form}} @@ -26,7 +26,7 @@ une écriture d'immobilisation *}} {{#form on="detach_amort"}} - {{:include file="_detach_amort.html" immo_doc_id=$_POST.immo_doc_id amort_line_id=$_POST.detach_amort}} + {{:include file="_detach_line.html" immo_doc_id=$_POST.immo_doc_id line_id=$_POST.detach_amort type="amort"}} {{:redirect to="?immo_doc_id=%s&ok=1&msg=detach_amort"|args:$_POST.immo_doc_id:}} {{/form}} diff --git a/attach_amort.html b/attach_amort.html index c03821b..eaf3600 100644 --- a/attach_amort.html +++ b/attach_amort.html @@ -47,7 +47,7 @@ {{* montant de l'écriture d'amortissement déjà affecté *}} {{:assign montant_affecte=0}} {{#load type="amort_link" - where="$$.amort_line_id = :amort_line_id" + where="$$.line_id = :amort_line_id" :amort_line_id = $_GET.amort_line_id|intval }} {{:assign montant_affecte="%d+%d"|math:$montant_affecte:$amount}} @@ -105,7 +105,7 @@ {{* vérifier si cette liaison est déjà présente dans les documents pour éviter les doublons *}} {{* TODO voir si nécessaire ? *}} {{#load type="amort_link" - where="$$.immo_doc_id = :immo_doc_id AND $$.amort_line_id = :amort_line_id" + where="$$.immo_doc_id = :immo_doc_id AND $$.line_id = :amort_line_id" :immo_doc_id=$_GET.immo_doc_id|intval :amort_line_id = $_GET.amort_line_id|intval limit=1 @@ -115,7 +115,7 @@ key=""|uuid type="amort_link" immo_doc_id=$_GET.immo_doc_id|intval - amort_line_id=$_GET.amort_line_id|intval + line_id=$_GET.amort_line_id|intval amount=$saved_amount }} {{/load}} diff --git a/attach_credit.html b/attach_credit.html index 59cc802..1d3db8e 100644 --- a/attach_credit.html +++ b/attach_credit.html @@ -51,7 +51,7 @@ {{* montant de l'écriture de crédit déjà affecté *}} {{:assign montant_affecte=0}} {{#load type="credit_link" - where="$$.credit_line_id = :credit_line_id" + where="$$.line_id = :credit_line_id" :credit_line_id = $_GET.credit_line_id|intval }} {{:assign montant_affecte="%d+%d"|math:$montant_affecte:$amount}} @@ -98,7 +98,7 @@ key=""|uuid type="credit_link" immo_doc_id=$_GET.immo_doc_id|intval - credit_line_id=$_GET.credit_line_id|intval + line_id=$_GET.credit_line_id|intval amount=$saved_credit }} diff --git a/delete_infos.html b/delete_infos.html index 8af819c..3d0de9f 100644 --- a/delete_infos.html +++ b/delete_infos.html @@ -20,7 +20,7 @@ {{#select trans.id FROM acc_transactions_lines AS line - INNER JOIN !table AS credit_link ON $$.credit_line_id = line.id + INNER JOIN !table AS credit_link ON $$.line_id = line.id INNER JOIN acc_transactions AS trans ON line.id_transaction = trans.id WHERE $$.type = "credit_link" AND $$.immo_doc_id = :immo_doc_id ; diff --git a/exit_step1.html b/exit_step1.html index f47333e..de1e539 100644 --- a/exit_step1.html +++ b/exit_step1.html @@ -17,7 +17,7 @@ une écriture au crédit du compte d'immobilisation *}} {{#form on="detach_credit"}} - {{:include file="_detach_credit.html" immo_doc_id=$_POST.immo_doc_id credit_line_id=$_POST.detach_credit}} + {{:include file="_detach_line.html" immo_doc_id=$_POST.immo_doc_id line_id=$_POST.detach_credit type="credit"}} {{:redirect to="?immo_doc_id=%s&from=exit&ok=1&msg=detach_avoir"|args:$_POST.immo_doc_id}} {{/form}} @@ -56,15 +56,15 @@ 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 - LEFT JOIN module_data_amortization AS mda ON json_extract(mda.document, '$.amort_line_id') = line.id + LEFT JOIN module_data_amortization AS mda ON json_extract(mda.document, '$.line_id') = line.id WHERE account.code LIKE :account_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 + SELECT json_extract(credit_link.document, '$.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 + SELECT json_extract(exit_link.document, '$.line_id') AS line_id FROM !table as exit_link WHERE json_extract(exit_link.document, '$.type') == "exit_link" ) ; @@ -112,7 +112,7 @@ {{:assign amort_amount=0}} {{:assign keep_amort=true}} {{#load type="amort_link" - where="$$.amort_line_id = :amort_line_id" + where="$$.line_id = :amort_line_id" :amort_line_id=$amort_line.amort_line_id assign="amort_link" }} diff --git a/exit_step2.html b/exit_step2.html index 8eab21f..462d4a3 100644 --- a/exit_step2.html +++ b/exit_step2.html @@ -25,7 +25,7 @@ une écriture d'immobilisation *}} {{#form on="detach_amort"}} - {{:include file="_detach_amort.html" immo_doc_id=$_POST.immo_doc_id amort_line_id=$_POST.detach_amort}} + {{:include file="_detach_line.html" immo_doc_id=$_POST.immo_doc_id line_id=$_POST.detach_amort type="amort"}} {{:redirect to="?immo_doc_id=%s&from=exit&ok=1&msg=detach_amort"|args:$_POST.immo_doc_id}} {{/form}} @@ -80,7 +80,7 @@ {{:assign amort_amount=0}} {{:assign keep_amort=true}} {{#load type="amort_link" - where="$$.amort_line_id = :amort_line_id" + where="$$.line_id = :amort_line_id" :amort_line_id=$amort_line.amort_line_id|intval assign="amort_link" }} diff --git a/exit_step3.html b/exit_step3.html index e77a5f7..d0498c8 100644 --- a/exit_step3.html +++ b/exit_step3.html @@ -25,7 +25,7 @@ une écriture de cession *}} {{#form on="detach_cession"}} - {{:include file="_detach_cession.html" immo_doc_id=$_POST.immo_doc_id cession_line_id=$_POST.detach_cession}} + {{:include file="_detach_line.html" immo_doc_id=$_POST.immo_doc_id line_id=$_POST.detach_cession type="cession"}} {{:redirect to="exit_step3.html?immo_doc_id=%s&from=exit&ok=1&msg=detach_cession"|args:$_GET.immo_doc_id}} {{/form}} @@ -69,7 +69,7 @@ {{* voir si l'écriture de cession est déjà liée à une immo *}} {{* TODO VOIR SI UTILE {{#load type="cession_link" - where="$$.cession_line_id = :cession_line_id" + where="$$.line_id = :cession_line_id" :cession_line_id = $line.line_id assign="cession_link" }} diff --git a/exit_step4.html b/exit_step4.html index 26c5f71..62b6c7b 100644 --- a/exit_step4.html +++ b/exit_step4.html @@ -36,7 +36,7 @@ {{#select credit FROM acc_transactions_lines WHERE id = :cession_line_id; - :cession_line_id = $cession_line_id + :cession_line_id = $line_id }} {{:assign montant_cession=$credit}} {{/select}} @@ -64,7 +64,7 @@ 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 + :exit_line_id = $exit_info.line_id assign="exit_line" }} {{/select}} @@ -125,15 +125,15 @@ 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 + LEFT JOIN module_data_amortization AS mda ON json_extract(mda.document, '$.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 + SELECT json_extract(credit_link.document, '$.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 + SELECT json_extract(exit_link.document, '$.line_id') AS line_id FROM !table as exit_link WHERE json_extract(exit_link.document, '$.type') == "exit_link" ) ; @@ -181,7 +181,7 @@ {{:assign amort_amount=0}} {{:assign keep_amort=true}} {{#load type="amort_link" - where="$$.amort_line_id = :amort_line_id" + where="$$.line_id = :amort_line_id" :amort_line_id=$amort_line.amort_line_id|intval assign="amort_link" }} @@ -224,7 +224,7 @@ une écriture de sortie de bilan *}} {{#form on="detach_exit"}} - {{:include file="_detach_exit.html" immo_doc_id=$_POST.immo_doc_id exit_line_id=$_POST.detach_exit}} + {{:include file="_detach_line.html" immo_doc_id=$_POST.immo_doc_id line_id=$_POST.detach_exit type="exit"}} {{:redirect to="?immo_doc_id=%s&from=exit&ok=1&msg=detach_exit"|args:$_POST.immo_doc_id}} {{/form}} diff --git a/link.schema.json b/link.schema.json index 0160ff2..048e9d8 100644 --- a/link.schema.json +++ b/link.schema.json @@ -12,45 +12,19 @@ "type" : "integer", "exclusiveMinimum": 0 }, - "amort_line_id" : { - "description": "ligne d'amortissement associée à l'immobilisation", - "type": "integer", - "exclusiveMinimum": 0 - }, - "credit_line_id": { - "description": "ligne au crédit du compte de l'immobilisation", - "type": "integer", - "exclusiveMinimum": 0 - }, - "exit_line_id": { - "description": "ligne de sortie du bilan de l'immobilisation", - "type": "integer", - "exclusiveMinimum": 0 - }, - "cession_line_id": { - "description": "ligne de cession de l'immobilisation", + "line_id" : { + "description": "ligne associée à l'immobilisation", "type": "integer", "exclusiveMinimum": 0 }, "amount": { - "description": "montant de la ligne d'amortissement ou de crédit", + "description": "montant de la ligne associée à l'immobilisation", "type": ["number", "null"] }, "created" : { - "description" : "vrai si amortissement créé dans le module", + "description" : "vrai si ligne créée dans le module", "type" : ["boolean", "null"] - } - }, - "required": ["type", "immo_doc_id"], - "if": {"properties": {"type": {"const": "amort_link"}}, "required": ["type"]}, - "then": {"required": ["amort_line_id"]}, - "else": - "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"]}, + }, + "required": ["type", "immo_doc_id", "line_id"] + } } diff --git a/link_immo.html b/link_immo.html index 8f43243..c2295a4 100644 --- a/link_immo.html +++ b/link_immo.html @@ -76,10 +76,10 @@ WHERE !account_condition AND credit > 0 AND credit_line_id NOT IN ( - SELECT json_extract(link.document, '$.credit_line_id') AS credit_line_id FROM !table as link - WHERE json_extract(link.document, '$.type') == "credit_link" + SELECT json_extract(credit_link.document, '$.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 + SELECT json_extract(exit_link.document, '$.line_id') AS line_id FROM !table as exit_link WHERE json_extract(exit_link.document, '$.type') == "exit_link") ORDER BY trans.date, trans.label; !account_condition = $account_condition diff --git a/list_cessions.html b/list_cessions.html index 65a910d..87d35ff 100644 --- a/list_cessions.html +++ b/list_cessions.html @@ -15,7 +15,7 @@ une écriture de cession *}} {{#form on="attach_cession"}} - {{:include file="_attach_cession.html" immo_doc_id=$_POST.immo_doc_id cession_line_id=$_POST.attach_cession}} + {{:include file="_attach_cession.html" immo_doc_id=$_POST.immo_doc_id line_id=$_POST.attach_cession}} {{:redirect force="exit_step3.html?immo_doc_id=%s&from=exit&ok=1&msg=attach_cession"|args:$_POST.immo_doc_id}} {{/form}} diff --git a/list_exit.html b/list_exit.html index 1d60ea5..1a08fd7 100644 --- a/list_exit.html +++ b/list_exit.html @@ -15,7 +15,7 @@ une écriture de sortie d'immobilisation *}} {{#form on="attach_exit"}} - {{:include file="_attach_exit.html" immo_doc_id=$_POST.immo_doc_id exit_line_id=$_POST.attach_exit}} + {{:include file="_attach_exit.html" immo_doc_id=$_POST.immo_doc_id line_id=$_POST.attach_exit}} {{:redirect force="exit_step4.html?immo_doc_id=%s&from=exit&ok=1&msg=attach_exit"|args:$_POST.immo_doc_id}} {{/form}} @@ -47,15 +47,15 @@ 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 + LEFT JOIN module_data_amortization AS mda ON json_extract(mda.document, '$.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 + SELECT json_extract(credit_link.document, '$.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 + SELECT json_extract(exit_link.document, '$.line_id') AS line_id FROM !table as exit_link WHERE json_extract(exit_link.document, '$.type') == "exit_link" ) ; diff --git a/save_amort.html b/save_amort.html index 43cc871..468de09 100644 --- a/save_amort.html +++ b/save_amort.html @@ -194,7 +194,7 @@ key=""|uuid type="amort_link" immo_doc_id=$_GET.immo_doc_id|intval - amort_line_id=$line.id + line_id=$line.id created=true }} {{:break}} diff --git a/write_exit.html b/write_exit.html index 43df579..e9033d0 100644 --- a/write_exit.html +++ b/write_exit.html @@ -151,7 +151,7 @@ key=""|uuid type="amort_link" immo_doc_id=$info_immo.id - amort_line_id=$line.id + line_id=$line.id created=true }} {{/if}} @@ -224,7 +224,7 @@ key=""|uuid type="exit_link" immo_doc_id=$info_immo.id - exit_line_id=$line.id + line_id=$line.id created=true }} {{:break}} @@ -270,7 +270,7 @@ key=""|uuid type="cession_link" immo_doc_id=$info_immo.id - cession_line_id=$line.id + line_id=$line.id created=true }} {{:break}} From 895aa39c3fd3cc94ff332b6fb956bdbf6b85e867 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Engel Date: Tue, 13 Oct 2026 11:59:16 +0200 Subject: [PATCH 2/4] Mutualisation attachement ligne cession et sortie de bilan --- _attach_cession.html | 37 ------------------------------------- _attach_exit.html | 37 ------------------------------------- _attach_line.html | 43 +++++++++++++++++++++++++++++++++++++++++++ list_cessions.html | 2 +- list_exit.html | 2 +- 5 files changed, 45 insertions(+), 76 deletions(-) delete mode 100644 _attach_cession.html delete mode 100644 _attach_exit.html create mode 100644 _attach_line.html diff --git a/_attach_cession.html b/_attach_cession.html deleted file mode 100644 index 4defc98..0000000 --- a/_attach_cession.html +++ /dev/null @@ -1,37 +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 line_id : ligne de l'écriture de cession -*}} - -{{* données de l'immobilisation *}} -{{:include file="_get_immo_data.html" immo_doc_id=$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 = $line_id|intval -}} - {{:assign cession_id=$id_transaction}} -{{else}} - {{:error message="Impossible de trouver l'écriture de cession de l'immobilisation"}} -{{/select}} - -{{* Lier l'écriture de cession à l'écriture d'immobilisation *}} -{{:include file="_common_attach.html" immo_doc_id=$immo_doc_id trans_id=$cession_id}} - -{{* enregistrer la liaison de l'écriture de cession *}} -{{:save - key=""|uuid - type="cession_link" - immo_doc_id=$info_immo.id - line_id=$line_id|intval -}} diff --git a/_attach_exit.html b/_attach_exit.html deleted file mode 100644 index f1e99b7..0000000 --- a/_attach_exit.html +++ /dev/null @@ -1,37 +0,0 @@ -{{* -*- brindille -*- *}} - -{{* - Enregistrer la liaison entre une écriture d'immobilisation et - une écriture de sortie d'immobilisation - @param immo_doc_id : id du document associé à l'immobilisation - @param line_id : ligne de l'écriture de sortie d'immobilisation -*}} - -{{* données de l'immobilisation *}} -{{:include file="_get_immo_data.html" immo_doc_id=$immo_doc_id keep="info_immo, ligne_immo, message"}} -{{if $message != null}} - {{:error message=$message}} -{{/if}} - -{{* chercher l'écriture de sortie d'immobilisation *}} -{{#select - id_transaction - FROM acc_transactions_lines - WHERE id = :line_id; - :line_id = $line_id|intval -}} - {{:assign exit_id=$id_transaction}} -{{else}} - {{:error message="Impossible de trouver l'écriture de sortie d'immobilisation"}} -{{/select}} - -{{* Lier l'écriture de sortie à l'écriture d'immobilisation *}} -{{:include file="_common_attach.html" immo_doc_id=$immo_doc_id trans_id=$exit_id}} - -{{* enregistrer la liaison de l'écriture de sortie *}} -{{:save - key=""|uuid - type="exit_link" - immo_doc_id=$info_immo.id - line_id=$line_id|intval -}} diff --git a/_attach_line.html b/_attach_line.html new file mode 100644 index 0000000..c879445 --- /dev/null +++ b/_attach_line.html @@ -0,0 +1,43 @@ +{{* -*- brindille -*- *}} + +{{* + Enregistrer la liaison entre une ligne d'immobilisation et une ligne + @param immo_doc_id : id du document associé à l'immobilisation + @param line_id : ligne de l'écriture à associer + @param type : type de ligne à associer (cession, exit, ...) +*}} + +{{* données de l'immobilisation *}} +{{:include file="_get_immo_data.html" immo_doc_id=$immo_doc_id keep="info_immo, ligne_immo, message"}} +{{if $message != null}} + {{:error message=$message}} +{{/if}} + +{{* chercher l'écriture de la ligne à associer *}} +{{#select + id_transaction + FROM acc_transactions_lines + WHERE id = :line_id; + :line_id = $line_id|intval +}} + {{:assign trans_id=$id_transaction}} +{{else}} + {{if $type == "cession"}} + {{:assign mtype="cession"}} + {{elseif $type == "exit"}} + {{:assign mtype="sortie"}} + {{/if}} + {{:error message="Impossible de trouver l'écriture de %s de l'immobilisation"|args:$mtype}} +{{/select}} + +{{* Lier cette écriture à l'écriture d'immobilisation *}} +{{:include file="_common_attach.html" immo_doc_id=$immo_doc_id trans_id=$trans_id}} + +{{* enregistrer la liaison *}} +{{:assign link_type=$type|cat:"_link"}} +{{:save + key=""|uuid + type=$link_type + immo_doc_id=$info_immo.id + line_id=$line_id|intval +}} diff --git a/list_cessions.html b/list_cessions.html index 87d35ff..db85b97 100644 --- a/list_cessions.html +++ b/list_cessions.html @@ -15,7 +15,7 @@ une écriture de cession *}} {{#form on="attach_cession"}} - {{:include file="_attach_cession.html" immo_doc_id=$_POST.immo_doc_id line_id=$_POST.attach_cession}} + {{:include file="_attach_line.html" immo_doc_id=$_POST.immo_doc_id line_id=$_POST.attach_cession type="cession"}} {{:redirect force="exit_step3.html?immo_doc_id=%s&from=exit&ok=1&msg=attach_cession"|args:$_POST.immo_doc_id}} {{/form}} diff --git a/list_exit.html b/list_exit.html index 1a08fd7..7678294 100644 --- a/list_exit.html +++ b/list_exit.html @@ -15,7 +15,7 @@ une écriture de sortie d'immobilisation *}} {{#form on="attach_exit"}} - {{:include file="_attach_exit.html" immo_doc_id=$_POST.immo_doc_id line_id=$_POST.attach_exit}} + {{:include file="_attach_line.html" immo_doc_id=$_POST.immo_doc_id line_id=$_POST.attach_exit type="exit"}} {{:redirect force="exit_step4.html?immo_doc_id=%s&from=exit&ok=1&msg=attach_exit"|args:$_POST.immo_doc_id}} {{/form}} From bb7e5a2844e6042b06c456b1bd04c3f407a83f5c Mon Sep 17 00:00:00 2001 From: Jean-Christophe Engel Date: Mon, 26 Oct 2026 12:11:32 +0100 Subject: [PATCH 3/4] Incorporation modifications branche main --- _archives.html | 2 +- _immobilisations.html | 2 +- _immobilisations_autres.html | 8 ++++---- _unfinished.html | 4 ++-- add_infos.html | 2 +- amortization.html | 6 +++--- attach_amort.html | 2 +- attach_credit.html | 2 +- exit_step1.html | 4 ++-- exit_step2.html | 4 ++-- exit_step3.html | 4 ++-- exit_step4.html | 4 ++-- ignore.html | 2 +- link_immo.html | 4 ++-- list_cessions.html | 4 ++-- list_exit.html | 4 ++-- modify_infos.html | 2 +- other_amortizations.html | 4 ++-- save_amort.html | 2 +- scripts.js | 6 +++--- 20 files changed, 36 insertions(+), 36 deletions(-) diff --git a/_archives.html b/_archives.html index 8d408a7..92e10af 100644 --- a/_archives.html +++ b/_archives.html @@ -147,7 +147,7 @@ {{:assign label_immo=$label_immo|cat:" — "|cat:$line_label}} {{/if}} - #{{$trans_id}} + {{$trans_id}} {{$date_mes|date_short}} {{$exit_date|date_short}} {{$label_immo}} diff --git a/_immobilisations.html b/_immobilisations.html index 51f9f1c..8788cac 100644 --- a/_immobilisations.html +++ b/_immobilisations.html @@ -122,7 +122,7 @@ {{:assign var="sommes_immo.%s"|args:$account_code value="%d+%d"|math:$montant:$montant_immo}} - #{{$immo_trans_id}} + {{$immo_trans_id}} {{$immo_date|date_short}} {{$label_immo}} {{$montant_immo|money_html:false|raw}} diff --git a/_immobilisations_autres.html b/_immobilisations_autres.html index d80acee..7e43c0c 100644 --- a/_immobilisations_autres.html +++ b/_immobilisations_autres.html @@ -21,7 +21,7 @@ {{else}} {{:assign unhide=1}} {{/if}} - {{:assign var="user_hides.unhide_other" value=$unhide"}} + {{:assign var="user_hides.unhide_other" value=$unhide}} {{:assign var="saved_hides.%s"|args:$logged_user.id value=$user_hides}} {{:save key="config" hides=$saved_hides}} {{/if}} @@ -29,7 +29,7 @@ {{:assign checked="checked"}} {{/if}} -{{* vérifier l'existence de la table du module *}} +{{* vérifier l'existence de la table du module' *}} {{if $module.table != null}} {{:assign columns="$$.status as status, SUM($$.amount) as amount,"}} {{:assign table_join="LEFT JOIN !table AS info ON $$.line = line.id"}} @@ -42,7 +42,7 @@ {{* lister les immobilisations non prises en charge par le module - ou dont le montant n'a pas été totalement affecté + ou dont le montant n'a pas été totalement affecté' *}} {{:assign account_condition="("}} {{#foreach from=$module.config.prefixes item="code"}} @@ -137,7 +137,7 @@ {{:assign compte_url="%s/acc/accounts/journal.php?id=%s&year=%s"|args:$admin_url:$line.account_id:$line.trans_id_year}} {{:assign reste="%d-%d"|math:$line.debit:$line.amount}} - #{{$line.immo_trans_id}} + {{$line.immo_trans_id}} {{$line.immo_line_id}} {{$trans_date|date_short}} {{$line.trans_label}}{{if $line.line_label != null && $line.line_label != $line.trans_label}} — {{$line.line_label}}{{/if}} diff --git a/_unfinished.html b/_unfinished.html index 4c12d4d..3c9a1c4 100644 --- a/_unfinished.html +++ b/_unfinished.html @@ -21,7 +21,7 @@ {{else}} {{:assign unhide=1}} {{/if}} - {{:assign var="user_hides.unhide_unfinished" value=$unhide"}} + {{:assign var="user_hides.unhide_unfinished" value=$unhide}} {{:assign var="saved_hides.%s"|args:$logged_user.id value=$user_hides}} {{:save key="config" hides=$saved_hides}} {{/if}} @@ -177,7 +177,7 @@ {{:input type="checkbox" name="selected[]" value=$trans_id}} - #{{$trans_id}} + {{$trans_id}} {{$trans_date|date_short}} {{$trans_label}} {{"%f"|math:$debit|money_html:false|raw}} diff --git a/add_infos.html b/add_infos.html index 9a45878..d2a4874 100644 --- a/add_infos.html +++ b/add_infos.html @@ -178,7 +178,7 @@
Immobilisation
- #{{$ligne_immo.immo_trans_id}} {{$immo_label}} + {{$ligne_immo.immo_trans_id}} {{$immo_label}}
Montant
{{"%f"|math:$ligne_immo.montant|money_currency_html:false|raw}}
diff --git a/amortization.html b/amortization.html index 02963f7..c765722 100644 --- a/amortization.html +++ b/amortization.html @@ -140,7 +140,7 @@
Immobilisation
-
#{{$ligne_immo.trans_id}} {{$label_immo}}
+
{{$ligne_immo.trans_id}} {{$label_immo}}
Compte d'immobilisation
{{$ligne_immo.account_code}} — {{$ligne_immo.account_label}}
Début d'amortissement
@@ -200,7 +200,7 @@ {{#foreach from=$linked_immos item="line"}} {{:assign url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$line.trans_id}} - #{{$line.trans_id}} + {{$line.trans_id}} {{$line.date|date_short}} {{$line.label}} {{"%f"|math:$line.amount|money_currency_html:false|raw}} @@ -260,7 +260,7 @@ {{:assign compte_url="%s/acc/accounts/journal.php?id=%s&year=%s"|args:$admin_url:$line.account_id:$line.year}} {{:assign solde="%f-%d"|math:$solde:$line.amount}} - #{{$line.trans_id}} + {{$line.trans_id}} {{$line.date|date_short}} {{$line.trans_label}} diff --git a/attach_amort.html b/attach_amort.html index eaf3600..3d95188 100644 --- a/attach_amort.html +++ b/attach_amort.html @@ -149,7 +149,7 @@
Immobilisation
{{$label_immo}}
Amortissement
-
#{{$amort_line.trans_id}} {{$amort_label}}
+
{{$amort_line.trans_id}} {{$amort_label}}
Montant de l'écriture d'amortissement
{{$amort_line.amount|money_currency_html:false|raw}}
{{if $montant_affecte > 0}} diff --git a/attach_credit.html b/attach_credit.html index 1d3db8e..b1adb99 100644 --- a/attach_credit.html +++ b/attach_credit.html @@ -125,7 +125,7 @@
Immobilisation
{{$label_immo}}
Écriture au crédit du compte d'immobilisation
-
#{{$credit_line.trans_id}} {{$credit_line.trans_label}}{{if $credit_line.line_label != null && $credit_line.line_label != $credit_line.trans_label}} — {{$credit_line.line_label}}{{/if}}
+
{{$credit_line.trans_id}} {{$credit_line.trans_label}}{{if $credit_line.line_label != null && $credit_line.line_label != $credit_line.trans_label}} — {{$credit_line.line_label}}{{/if}}
Montant de l'écriture
{{$credit_line.amount|money_currency_html:false|raw}}
Montant déjà affecté
diff --git a/exit_step1.html b/exit_step1.html index de1e539..8e68c35 100644 --- a/exit_step1.html +++ b/exit_step1.html @@ -152,7 +152,7 @@
Immobilisation
-
#{{$ligne_immo.trans_id}} {{$label_immo}}
+
{{$ligne_immo.trans_id}} {{$label_immo}}
Compte d'immobilisation
{{$ligne_immo.account_code}} — {{$ligne_immo.account_label}}
Montant de l'immobilisation
@@ -199,7 +199,7 @@ {{:assign 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.trans_id}} {{$line.date|date_short}} {{$line.label}} {{"%f"|math:$line.amount|money_currency_html:false|raw}} diff --git a/exit_step2.html b/exit_step2.html index 462d4a3..e3ed8a5 100644 --- a/exit_step2.html +++ b/exit_step2.html @@ -117,7 +117,7 @@
Immobilisation
-
#{{$ligne_immo.trans_id}} {{$label_immo}}
+
{{$ligne_immo.trans_id}} {{$label_immo}}
Compte d'immobilisation
{{$ligne_immo.account_code}} — {{$ligne_immo.account_label}}
Montant de l'immobilisation
@@ -167,7 +167,7 @@ {{: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.trans_id}} {{$line.date|date_short}} {{if $line.line_label != null}} diff --git a/exit_step3.html b/exit_step3.html index d0498c8..c001827 100644 --- a/exit_step3.html +++ b/exit_step3.html @@ -124,7 +124,7 @@
Immobilisation
-
#{{$ligne_immo.trans_id}} {{$label_immo}}
+
{{$ligne_immo.trans_id}} {{$label_immo}}
Compte d'immobilisation
{{$ligne_immo.account_code}} — {{$ligne_immo.account_label}}
Montant de l'immobilisation
@@ -178,7 +178,7 @@ {{: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.trans_id}} {{$line.date|date_short}} {{if $line.line_label != null}} diff --git a/exit_step4.html b/exit_step4.html index 62b6c7b..d3df512 100644 --- a/exit_step4.html +++ b/exit_step4.html @@ -247,7 +247,7 @@
Immobilisation
-
#{{$ligne_immo.trans_id}} {{$label_immo}}
+
{{$ligne_immo.trans_id}} {{$label_immo}}
Compte d'immobilisation
{{$ligne_immo.account_code}} — {{$ligne_immo.account_label}}
Montant de l'immobilisation
@@ -332,7 +332,7 @@ - #{{$exit_line.trans_id}} + {{$exit_line.trans_id}} {{$exit_line.date|date_short}} {{if $exit_line.line_label != null}} diff --git a/ignore.html b/ignore.html index a721759..9dc3577 100644 --- a/ignore.html +++ b/ignore.html @@ -63,7 +63,7 @@
Écriture
-
#{{$ligne_immo.trans_id}} {{$ligne_immo.label}}
+
{{$ligne_immo.trans_id}} {{$ligne_immo.label}}
Montant
{{"%f"|math:$ligne_immo.amount|money_currency_html:false|raw}}
diff --git a/link_immo.html b/link_immo.html index c2295a4..adddc11 100644 --- a/link_immo.html +++ b/link_immo.html @@ -122,7 +122,7 @@
Immobilisation
-
#{{$ligne_immo.trans_id}} {{$label_immo}}
+
{{$ligne_immo.trans_id}} {{$label_immo}}
Montant
{{"%f"|math:$ligne_immo.amount|money_currency_html:false|raw}}
Date de l'immobilisation
@@ -148,7 +148,7 @@ {{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$line.credit_trans_id}} {{:assign compte_url="%s/acc/accounts/journal.php?id=%s&year=%s"|args:$admin_url:$line.account_id:$line.credit_year}} - #{{$line.credit_trans_id}} + {{$line.credit_trans_id}} {{$line.trans_date|date_short}} {{"%f"|math:$line.credit_amount|money_html:false|raw}} {{$line.trans_label}} diff --git a/list_cessions.html b/list_cessions.html index db85b97..ef4b96d 100644 --- a/list_cessions.html +++ b/list_cessions.html @@ -77,7 +77,7 @@
Immobilisation
-
#{{$ligne_immo.trans_id}} {{$label_immo}}
+
{{$ligne_immo.trans_id}} {{$label_immo}}
Montant
{{"%f"|math:$ligne_immo.amount|money_currency_html:false|raw}}
Date de l'immobilisation
@@ -105,7 +105,7 @@ {{: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.trans_id}} {{$line.date|date_short}} {{if $line.line_label != null}} diff --git a/list_exit.html b/list_exit.html index 7678294..bcc39e0 100644 --- a/list_exit.html +++ b/list_exit.html @@ -75,7 +75,7 @@
Immobilisation
-
#{{$ligne_immo.trans_id}} {{$label_immo}}
+
{{$ligne_immo.trans_id}} {{$label_immo}}
Montant
{{"%f"|math:$ligne_immo.amount|money_currency_html:false|raw}}
Date de l'immobilisation
@@ -102,7 +102,7 @@ {{: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.trans_id}} {{$line.date|date_short}} {{$line.trans_label}} {{if $line.line_label != null && $line.line_label != $line.trans_label}} — {{$line.line_label}}{{/if}} diff --git a/modify_infos.html b/modify_infos.html index c65194a..2e056e5 100644 --- a/modify_infos.html +++ b/modify_infos.html @@ -129,7 +129,7 @@
Immobilisation
-
#{{$ligne_immo.trans_id}} {{$immo_label}}
+
{{$ligne_immo.trans_id}} {{$immo_label}}
Compte d'immobilisation
{{$ligne_immo.account_code}} — {{$ligne_immo.account_label}}
Montant
diff --git a/other_amortizations.html b/other_amortizations.html index e3d8f9e..f43cbf1 100644 --- a/other_amortizations.html +++ b/other_amortizations.html @@ -76,7 +76,7 @@
Immobilisation
-
#{{$ligne_immo.trans_id}} {{$label_immo}}
+
{{$ligne_immo.trans_id}} {{$label_immo}}
Montant
{{"%f"|math:$montant_immo|money_currency_html:false|raw}}
Début d'amortissement
@@ -102,7 +102,7 @@ {{: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.trans_id}} {{$line.trans_date|date_short}} {{if $line.line_label != null}} diff --git a/save_amort.html b/save_amort.html index 468de09..0226760 100644 --- a/save_amort.html +++ b/save_amort.html @@ -229,7 +229,7 @@ {{: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.amount:$info_immo.duration:$nbjours|intval}} + {{:assign montant_amort="round(%f/%f/365*%d,2)"|math:$ligne_immo.amount:$info_immo.duration:$nbjours|intval}} {{:assign montant_amort="min(%f, %d-%d)"|math:$montant_amort:$ligne_immo.amount:$total_amort}} {{/if}} diff --git a/scripts.js b/scripts.js index 3def0ba..644ae39 100644 --- a/scripts.js +++ b/scripts.js @@ -93,7 +93,7 @@ function getNumber(text) { // @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); + const nbjours = Math.round(1 + Math.abs((date_fin - date_debut)) / (60*60*24)); return Math.round(Math.min(montant_immo / duree_immo / 365 * nbjours, montant_immo - somme_amort)); } @@ -131,7 +131,7 @@ function displayAmort(id_immo, id_duree, id_amort, id_years, id_exercices, id_mo 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; + case_montant.innerText = montant_amort/100; } function setSelectorYear(button_names, f_years_selector) @@ -249,7 +249,7 @@ function computeTotal(id_total, id_url) { total[code] = getNumber(money.innerText) * 100; } total_general += getNumber(money.innerText) * 100; - const number = line.querySelector('.num a').innerText.slice(1); + const number = line.querySelector('.num a').innerText; transactions.push(number); } } From 85303d94d23e6191ae5ab954ecfa0ed0b7fcb192 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Engel Date: Mon, 26 Oct 2026 12:15:26 +0100 Subject: [PATCH 4/4] =?UTF-8?q?Ajout=20mise=20=C3=A0=20jour=20des=20liens?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _remove_orphan_docs.tpl | 2 +- _upgrade.html | 15 +++++++++++++++ _upgrade_to042.tpl | 38 ++++++++++++++++++++++++++++++++++++++ index.html | 2 +- link.schema.json | 2 +- module.ini | 2 +- 6 files changed, 57 insertions(+), 4 deletions(-) create mode 100644 _upgrade_to042.tpl diff --git a/_remove_orphan_docs.tpl b/_remove_orphan_docs.tpl index a2ba62a..2f08dc3 100644 --- a/_remove_orphan_docs.tpl +++ b/_remove_orphan_docs.tpl @@ -2,11 +2,11 @@ {{if $module.table}} {{* supprimer les documents sans écriture associée *}} + {{:assign var="docs." type="immo" field="line"}} {{:assign var="docs." type="amort_link" field="line_id"}} {{:assign var="docs." type="credit_link" field="line_id"}} {{:assign var="docs." type="cession_link" field="line_id"}} {{:assign var="docs." type="exit_link" field="line_id"}} - {{:assign var="docs." type="immo" field="line"}} {{#foreach from=$docs}} diff --git a/_upgrade.html b/_upgrade.html index 54429ca..bec8d40 100644 --- a/_upgrade.html +++ b/_upgrade.html @@ -34,6 +34,21 @@

Mise à jour vers version {{$tag}} terminée

{{/if}} +{{* version 0.42 *}} +{{:assign tag="0.42"}} + +{{:include file="_compare_version.tpl" nv1=$module_version nv2=$tag keep="comp"}} +{{:assign module_comp=$comp}} +{{:include file="_compare_version.tpl" nv1=$module.config.version nv2=$tag keep="comp"}} +{{:assign config_comp=$comp}} + +{{if $module_comp >= 0 && $config_comp < 0}} +{{* $module_version >= '0.42' && $module.config.version < '0.42' *}} + + {{:include file="_upgrade_to042.tpl"}} +

Mise à jour vers version {{$tag}} terminée

+{{/if}} + {{* enregistrer le nouveau numéro de version dans la config du module *}} {{:include file="_compare_version.tpl" nv1=$module_version nv2=$module.config.version keep="comp"}} {{if $comp > 0}} diff --git a/_upgrade_to042.tpl b/_upgrade_to042.tpl new file mode 100644 index 0000000..445015d --- /dev/null +++ b/_upgrade_to042.tpl @@ -0,0 +1,38 @@ +{{* -*- brindille -*- *}} + +{{* remplacer xxx_line_id par line_id pour simplifier et mutualiser le code *}} + +{{:assign var="link_types." type="amort"}} +{{:assign var="link_types." type="credit"}} +{{:assign var="link_types." type="cession"}} +{{:assign var="link_types." type="exit"}} + +{{* lister les liens actuels *}} +{{#foreach from=$link_types}} + {{:assign link_type=$type|cat:"_link"}} + {{:assign line_id=$type|cat:"_line_id"}} + {{#load type=$link_type assign="link"}} + {{:assign new_link=null}} + {{:assign var="new_link.key value=$link.key}} + {{:assign var="new_link.type" value=$link.type}} + {{:assign var="new_link.immo_doc_id" value=$link.immo_doc_id}} + {{:assign var="new_link.line_id" from="link.%s"|args:$line_id}} + {{:assign var="new_link.amount" value=$link.amount}} + {{:assign var="new_link.created" value=$link.created}} + {{* mémoriser les infos des docs *}} + {{:assign var="new_links." value=$new_link}} + {{/load}} + {{:delete type=$link_type}} +{{/foreach}} + +{{* créer les nouveaux documents de liaisons *}} +{{#foreach from=$new_links item="link"}} + {{:save + key=$link.key + type=$link.type + immo_doc_id=$link.immo_doc_id + line_id=$link.line_id + amount=$link.amount + created=$link.created + }} +{{/foreach}} diff --git a/index.html b/index.html index 0bdbff8..06ab7e4 100644 --- a/index.html +++ b/index.html @@ -21,7 +21,7 @@ {{:include file="_nav.html" current=$type_immo}} {{* Mise à niveau *}} -{{:assign module_version="0.41"}} +{{:assign module_version="0.42"}} {{:include file="_upgrade.html" module_version=$module_version}} {{* supprimer les documents sans écriture associée *}} diff --git a/link.schema.json b/link.schema.json index 048e9d8..f9f21f6 100644 --- a/link.schema.json +++ b/link.schema.json @@ -13,7 +13,7 @@ "exclusiveMinimum": 0 }, "line_id" : { - "description": "ligne associée à l'immobilisation", + "description": "ligne d'écriture associée à l'immobilisation", "type": "integer", "exclusiveMinimum": 0 }, diff --git a/module.ini b/module.ini index d6cad20..73633af 100644 --- a/module.ini +++ b/module.ini @@ -1,5 +1,5 @@ name="Amortissements" -description="Immobilisations et amortissements\nversion 0.41.3" +description="Immobilisations et amortissements\nversion 0.42" author="Jean-Christophe Engel" author_url="https://gitea.zaclys.com/lesanges" home_button=false