From ba3081cf003569a343714e1118e2b15e566ea586 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Engel Date: Wed, 2 Sep 2026 10:03:03 +0200 Subject: [PATCH] Masquer titre tableau si aucune immobilisation --- _archives.html | 392 +++++++++++++++++++++--------------------- _immobilisations.html | 276 ++++++++++++++--------------- 2 files changed, 341 insertions(+), 327 deletions(-) diff --git a/_archives.html b/_archives.html index 6670beb..b53c237 100644 --- a/_archives.html +++ b/_archives.html @@ -25,199 +25,205 @@ {{:assign filter_condition=$filter_condition|cat:"0)"}} {{:assign condition=$account_condition|cat:" AND debit > 0 AND NOT (trans.status & 16)"|cat:$filter_condition}} -
- - - - - - - - - - - - - - +{{:assign nb_immo=0}} +{{:assign total_cessions = 0}} - {{:assign nb_immo=0}} - {{:assign total_immo = 0}} - {{:assign total_cessions = 0}} +{{#select + trans.id as trans_id, + trans.label as trans_label, + trans.date as trans_date, + trans.id_year as trans_id_year, + line.id as immo_line_id, + line.label as line_label, + line.debit AS debit, + account.id as account_id, + account.code as account_code, + account.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 account ON line.id_account = account.id + INNER JOIN acc_years AS years ON trans.id_year = years.id + WHERE !condition + ORDER BY trans.date DESC; + !condition=$condition + assign="immo_line" +}} - {{#select - trans.id as trans_id, - trans.label as trans_label, - trans.date as trans_date, - trans.id_year as trans_id_year, - line.id as immo_line_id, - line.label as line_label, - line.debit AS debit, - account.id as account_id, - account.code as account_code, - account.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 account ON line.id_account = account.id - INNER JOIN acc_years AS years ON trans.id_year = years.id - WHERE !condition - ORDER BY trans.date DESC; - !condition=$condition - }} - - {{* voir si l'immo est prise en charge *}} - {{#load type="immo" where="$$.line = :line_id" :line_id=$immo_line_id assign="info_immo"}} - {{:assign status=$status}} - {{else}} - {{:assign status=null}} - {{/load}} - {{if $status != "archived"}} - {{:continue}} - {{/if}} - {{:assign date_mes=$info_immo.date_mes|or:$trans_date}} - {{:assign montant_immo=$debit}} - - {{* chercher le doc de sortie du bilan *}} - {{:assign exit_date=null}} - {{#load type="exit_link" where="$$.immo_doc_id = :immo_doc_id" :immo_doc_id=$info_immo.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 - }} - {{:assign exit_date=$date}} - {{/select}} - {{/load}} - - {{* déduire le montant des écritures liées à l'immo courante au crédit du même compte *}} - {{:assign credit_immo=null}} - {{:assign total_credits=0}} - {{#load - type="credit_link" - where="$$.immo_doc_id = :immo_doc_id" :immo_doc_id = $info_immo.id - }} - {{if $amount == null}} - {{#select credit FROM acc_transactions_lines WHERE id = :credit_line_id; - :credit_line_id=$credit_line_id - }} - {{:assign total_credits="%d+%d"|math:$total_credits:$credit}} - {{/select}} - {{else}} - {{:assign total_credits="%d+%d"|math:$total_credits:$amount}} - {{/if}} - {{/load}} - {{:assign solde_immo="%d-%d"|math:$montant_immo:$total_credits}} - - {{if $solde_immo == 0}} - {{:assign status="archived"}} - {{/if}} - - {{if $status != "archived"}} - {{:continue}} - {{/if}} - - {{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$trans_id}} - {{:assign compte_url="%s/acc/accounts/journal.php?id=%s&year=%s"|args:$admin_url:$account_id:$trans_id_year}} - {{:assign nb_immo="%d+1"|math:$nb_immo}} - {{:assign total_immo="%d+%d"|math:$total_immo:$montant_immo}} - {{:assign var="montant" from="sommes_immo.%s"|args:$account_code}} - {{:assign var="sommes_immo.%s"|args:$account_code value="%d+%d"|math:$montant:$montant_immo}} - - {{* voir s'il y a une écriture de cession associée à cette immo *}} - {{#select - trans.id, - line.debit - FROM acc_transactions_links AS link - INNER JOIN acc_transactions AS trans ON (CASE - WHEN link.id_transaction = :trans_id THEN link.id_related - WHEN link.id_related = :trans_id THEN link.id_transaction - END) = trans.id - 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 (link.id_transaction = :trans_id OR link.id_related = :trans_id) AND acc.code = 462 - ; - :trans_id = $trans_id - }} - {{:assign var="montant" from="montant_cessions.%d"|args:$account_code}} - {{:assign var="montant_cessions.%d"|args:$account_code value="%d+%d"|math:$montant:$debit}} - {{:assign total_cessions="%d+%d"|math:$total_cessions:$debit}} - {{/select}} - - - - - - - - - - - - {{/select}} - - - {{if $total_immo != 0}} - - - {{#foreach from=$sommes_immo|ksort key="code" item="value"}} - - - - - - - - - - - {{/foreach}} - - - - - - - - - - - {{/if}} - {{if $total_cessions != 0}} - - - {{#foreach from=$montant_cessions|ksort key="code" item="value"}} - - - - - - - - - - - {{/foreach}} - - - - - - - - - - - {{/if}} - -
Mise en serviceDate sortieLibelléMontantN° compteCompte
#{{$trans_id}}{{$date_mes|date_short}}{{$exit_date|date_short}}{{$trans_label}}{{if $line_label != null && $line_label != $trans_label}} — {{$line_label}}{{/if}}{{"%f"|math:$montant_immo|money_html:false|raw}}{{$account_code}}{{$account_label}} - {{:linkbutton label="Modifier" href="exit_step1.html?immo_doc_id=%s&from=exit"|args:$info_immo.id shape="edit"}} -
-
Total du compte {{$code}}{{$value|money_html:false|raw}}
Total des immobilisations{{$total_immo|money_html:false|raw}}
-
Cessions du compte {{$code}}{{$value|money_html:false|raw}}
Total des cessions{{$total_cessions|money_html:false|raw}}
- {{if $nb_immo == 0}} -

Aucune immobilisation

+ {{* voir si l'immo est prise en charge *}} + {{#load type="immo" where="$$.line = :line_id" :line_id=$immo_line_id assign="info_immo"}} + {{:assign status=$status}} + {{else}} + {{:assign status=null}} + {{/load}} + {{if $status != "archived"}} + {{:continue}} {{/if}} -
+ {{:assign var="immo_line.date_mes" value=$info_immo.date_mes|or:$trans_date}} + {{:assign var="immo_line.montant_immo" value=$debit}} + + {{* 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=$info_immo.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 + }} + {{:assign var="immo_line.exit_date" value=$date}} + {{/select}} + {{/load}} + + {{* déduire le montant des écritures liées à l'immo courante au crédit du même compte *}} + {{:assign credit_immo=null}} + {{:assign total_credits=0}} + {{#load + type="credit_link" + where="$$.immo_doc_id = :immo_doc_id" :immo_doc_id = $info_immo.id + }} + {{if $amount == null}} + {{#select credit FROM acc_transactions_lines WHERE id = :credit_line_id; + :credit_line_id=$credit_line_id + }} + {{:assign total_credits="%d+%d"|math:$total_credits:$credit}} + {{/select}} + {{else}} + {{:assign total_credits="%d+%d"|math:$total_credits:$amount}} + {{/if}} + {{/load}} + {{:assign solde_immo="%d-%d"|math:$immo_line.montant_immo:$total_credits}} + + {{if $solde_immo == 0}} + {{:assign status="archived"}} + {{/if}} + + {{if $status != "archived"}} + {{:continue}} + {{/if}} + + {{:assign nb_immo="%d+1"|math:$nb_immo}} + {{:assign var="montant" from="sommes_immo.%s"|args:$account_code}} + {{:assign var="sommes_immo.%s"|args:$account_code value="%d+%d"|math:$montant:$immo_line.montant_immo}} + + {{* voir s'il y a une écriture de cession associée à cette immo *}} + {{#select + trans.id, + line.debit + FROM acc_transactions_links AS link + INNER JOIN acc_transactions AS trans ON (CASE + WHEN link.id_transaction = :trans_id THEN link.id_related + WHEN link.id_related = :trans_id THEN link.id_transaction + END) = trans.id + 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 (link.id_transaction = :trans_id OR link.id_related = :trans_id) AND acc.code = 462 + ; + :trans_id = $trans_id + }} + {{:assign var="montant" from="montant_cessions.%d"|args:$account_code}} + {{:assign var="montant_cessions.%d"|args:$account_code value="%d+%d"|math:$montant:$debit}} + {{:assign total_cessions="%d+%d"|math:$total_cessions:$debit}} + {{/select}} + {{:assign var="immo_lines." value=$immo_line}} +{{/select}} + +{{if $immo_lines|count > 0}} +
+ + + + + + + + + + + + + + + + {{:assign total_immo = 0}} + {{#foreach from=$immo_lines}} + {{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$trans_id}} + {{:assign compte_url="%s/acc/accounts/journal.php?id=%s&year=%s"|args:$admin_url:$account_id:$trans_id_year}} + {{:assign total_immo="%d+%d"|math:$total_immo:$montant_immo}} + + + + + + + + + + + + {{/foreach}} + + + {{if $total_immo != 0}} + + + {{#foreach from=$sommes_immo|ksort key="code" item="value"}} + + + + + + + + + + + {{/foreach}} + + + + + + + + + + + {{/if}} + {{if $total_cessions != 0}} + + + {{#foreach from=$montant_cessions|ksort key="code" item="value"}} + + + + + + + + + + + {{/foreach}} + + + + + + + + + + + {{/if}} + +
Mise en serviceDate sortieLibelléMontantN° compteCompte
#{{$trans_id}}{{$date_mes|date_short}}{{$exit_date|date_short}}{{$trans_label}}{{if $line_label != null && $line_label != $trans_label}} — {{$line_label}}{{/if}}{{"%f"|math:$montant_immo|money_html:false|raw}}{{$account_code}}{{$account_label}} + {{:linkbutton label="Modifier" href="exit_step1.html?immo_doc_id=%s&from=exit"|args:$info_immo.id shape="edit"}} +
+
Total du compte {{$code}}{{$value|money_html:false|raw}}
Total des immobilisations{{$total_immo|money_html:false|raw}}
+
Cessions du compte {{$code}}{{$value|money_html:false|raw}}
Total des cessions{{$total_cessions|money_html:false|raw}}
+
+{{else}} +

Aucune immobilisation

+{{/if}} diff --git a/_immobilisations.html b/_immobilisations.html index 403584c..cc0fc76 100644 --- a/_immobilisations.html +++ b/_immobilisations.html @@ -16,157 +16,165 @@

{{if $module.table != null}} - - - - - - - - - - - - - - - + {{* lister les immobilisations *}} + {{:assign account_condition="("}} + {{#foreach from=$module.config.prefixes item="code"}} + {{:assign code=$code|cat:"%"|quote_sql}} + {{:assign account_condition=$account_condition|cat:" account.code LIKE "|cat:$code|cat:" OR "}} + {{/foreach}} + {{:assign account_condition=$account_condition|cat:"0)"}} + {{:assign status_condition="($$.status = 'managed' OR $$.status = 'amortized')"}} + {{:assign condition=$account_condition|cat:" AND line.debit > 0 AND "|cat:$status_condition}} - {{* lister les immobilisations *}} - {{:assign account_condition="("}} - {{#foreach from=$module.config.prefixes item="code"}} - {{:assign code=$code|cat:"%"|quote_sql}} - {{:assign account_condition=$account_condition|cat:" account.code LIKE "|cat:$code|cat:" OR "}} - {{/foreach}} - {{:assign account_condition=$account_condition|cat:"0)"}} - {{:assign status_condition="($$.status = 'managed' OR $$.status = 'amortized')"}} - {{:assign condition=$account_condition|cat:" AND line.debit > 0 AND "|cat:$status_condition}} - - {{:assign nb_immo=0}} - {{:assign total_immo = 0}} - {{#select - trans.id as immo_trans_id, - trans.label as trans_label, - trans.date as trans_date, - line.id as immo_line_id, - line.debit AS debit, - line.label AS line_label, - account.id as account_id, - account.code as account_code, - trans.id_year as trans_id_year, - info.id as immo_doc_id, - $$.duration as duration, - $$.label as doc_label, - $$.amount as doc_amount, - $$.date_achat as doc_date_achat, - $$.date as doc_date_mes, - $$.status as status - 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 - INNER JOIN acc_years AS years ON trans.id_year = years.id - INNER JOIN !table AS info ON $$.line = line.id - WHERE !condition - ORDER BY COALESCE(doc_date_achat, trans_date) DESC; - !table=$module.table - !condition=$condition - }} - {{if $status != "managed" && $status != "amortized"}} - {{:continue}} - {{/if}} - {{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$immo_trans_id}} - {{:assign compte_url="%s/acc/accounts/journal.php?id=%s&year=%s"|args:$admin_url:$account_id:$trans_id_year}} - {{:assign montant_immo=$doc_amount|or:$debit}} - {{:assign immo_date = $doc_date_achat|or:$trans_date}} - {{:assign label_immo=$doc_label|or:$trans_label}} - {{if $label_immo|strpos:$line_label === false}} - {{:assign label_immo=$label_immo|cat:" — "|cat:$line_label}} - {{/if}} - - {{* déduire le montant des écritures liées à l'immo courante au crédit du même compte *}} - {{#load - type="credit_link" - where="$$.immo_doc_id = :immo_doc_id" :immo_doc_id = $immo_doc_id + {{#select + trans.id as immo_trans_id, + trans.label as trans_label, + trans.date as trans_date, + line.id as immo_line_id, + line.debit AS debit, + line.label AS line_label, + account.id as account_id, + account.code as account_code, + trans.id_year as trans_id_year, + info.id as immo_doc_id, + $$.duration as duration, + $$.label as doc_label, + $$.amount as doc_amount, + $$.date_achat as doc_date_achat, + $$.date as doc_date_mes, + $$.status as status + 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 + INNER JOIN acc_years AS years ON trans.id_year = years.id + INNER JOIN !table AS info ON $$.line = line.id + WHERE !condition + ORDER BY COALESCE(doc_date_achat, trans_date) DESC; + !table=$module.table + !condition=$condition + assign="immo_line" + }} + {{:assign montant_immo=$doc_amount|or:$debit}} + {{* déduire le montant des écritures liées à l'immo courante au crédit du même compte *}} + {{#load + type="credit_link" + where="$$.immo_doc_id = :immo_doc_id" :immo_doc_id = $immo_doc_id + }} + {{if $amount == null}} + {{#select credit FROM acc_transactions_lines WHERE id = :credit_line_id; + :credit_line_id=$credit_line_id }} - {{if $amount == null}} - {{#select credit FROM acc_transactions_lines WHERE id = :credit_line_id; - :credit_line_id=$credit_line_id - }} - {{:assign montant_immo="%d-%d"|math:$montant_immo:$credit}} - {{/select}} - {{else}} - {{:assign montant_immo="%d-%d"|math:$montant_immo:$amount}} - {{/if}} - {{/load}} + {{:assign montant_immo="%d-%d"|math:$montant_immo:$credit}} + {{/select}} + {{else}} + {{:assign montant_immo="%d-%d"|math:$montant_immo:$amount}} + {{/if}} + {{/load}} - {{if $montant_immo == 0}} - {{* Immobilisation soldée *}} - {{:continue}} - {{/if}} + {{if $montant_immo == 0}} + {{* Immobilisation soldée *}} + {{:continue}} + {{else}} + {{:assign var="immo_line.montant_immo" value=$montant_immo}} + {{/if}} - {{* montant des amortissements liés à l'immobilisation *}} - {{:include file="./_get_amort_lines.html" immo_doc_id=$immo_doc_id keep="total_amort"}} - {{:assign amort_amount=$total_amort}} + {{* montant des amortissements liés à l'immobilisation *}} + {{:include file="./_get_amort_lines.html" immo_doc_id=$immo_doc_id keep="total_amort"}} + {{:assign amort_amount=$total_amort}} - {{* classement par onglet *}} - {{if $type_immo == "managed" && $amort_amount >= $montant_immo}}{{:continue}}{{/if}} - {{if $type_immo == "amortized" && $amort_amount < $montant_immo}}{{:continue}}{{/if}} + {{* classement par onglet *}} + {{if $type_immo == "managed" && $amort_amount >= $montant_immo}}{{:continue}}{{/if}} + {{if $type_immo == "amortized" && $amort_amount < $montant_immo}}{{:continue}}{{/if}} + {{:assign var="immo_line.amort_amount" value=$amort_amount}} - {{:assign nb_immo="%d+1"|math:$nb_immo}} - {{:assign total_immo="%d+%d"|math:$total_immo:$montant_immo}} - {{:assign var="montant" from="sommes_immo.%s"|args:$account_code}} - {{:assign var="sommes_immo.%s"|args:$account_code value="%d+%d"|math:$montant:$montant_immo}} - - - - - - - - - - - - {{/select}} - - - {{if $total_immo != 0}} + {{:assign var="immo_lines." value=$immo_line}} + {{/select}} + + {{if $immo_lines|count > 0}} +
DateLibelléMontantDuréeAmortissementsValeur netteN° compte
#{{$immo_trans_id}}{{$immo_date|date_short}}{{$label_immo}}{{$montant_immo|money_html:false|raw}}{{if $duration != null}}{{$duration}}{{/if}}{{$amort_amount|money_html:false|raw}}{{"%d-%d"|math:$montant_immo:$amort_amount|money_html:false|raw}}{{$account_code}} - {{:linkbutton - label="Détails" - href="amortization.html?immo_doc_id=%s&type_immo=%s"|args:$immo_doc_id:$type_immo shape="eye" - }} -
+ - + + + + + + + + - {{#foreach from=$sommes_immo|ksort key="code" item="value"}} + + + + {{:assign total_immo = 0}} + {{#foreach from=$immo_lines}} + {{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$immo_trans_id}} + {{:assign compte_url="%s/acc/accounts/journal.php?id=%s&year=%s"|args:$admin_url:$account_id:$trans_id_year}} + {{:assign immo_date = $doc_date_achat|or:$trans_date}} + {{:assign label_immo=$doc_label|or:$trans_label}} + {{if $label_immo|strpos:$line_label === false}} + {{:assign label_immo=$label_immo|cat:" — "|cat:$line_label}} + {{/if}} + + {{:assign total_immo="%d+%d"|math:$total_immo:$montant_immo}} + {{:assign var="montant" from="sommes_immo.%s"|args:$account_code}} + {{:assign var="sommes_immo.%s"|args:$account_code value="%d+%d"|math:$montant:$montant_immo}} + + + + + + + + + + + + + + {{/foreach}} + + + + {{if $total_immo != 0}} + + + {{#foreach from=$sommes_immo|ksort key="code" item="value"}} + + + + + + + + + + + + {{/foreach}} - - + + - {{/foreach}} - - - - - - - - - - - - {{/if}} - -
+ DateLibelléMontantDuréeAmortissementsValeur netteN° compte
#{{$immo_trans_id}}{{$immo_date|date_short}}{{$label_immo}}{{$montant_immo|money_html:false|raw}}{{if $duration != null}}{{$duration}}{{/if}}{{$amort_amount|money_html:false|raw}}{{"%d-%d"|math:$montant_immo:$amort_amount|money_html:false|raw}}{{$account_code}} + {{:linkbutton + label="Détails" + href="amortization.html?immo_doc_id=%s&type_immo=%s"|args:$immo_doc_id:$type_immo shape="eye" + }} +
+
Total du compte {{$code}}{{$value|money_html:false|raw}}
Total du compte {{$code}}{{$value|money_html:false|raw}}Total des immobilisations{{$total_immo|money_html|raw}}
Total des immobilisations{{$total_immo|money_html|raw}}
+ {{/if}} + + + {{/if}} {{/if}} -{{if $nb_immo == 0 || $module.table == null}} +{{if $immo_lines|count == 0 || $module.table == null}}

Aucune immobilisation

{{/if}}