Correction erreur traitement sortie du bilan des immo importées de la balance initiale
This commit is contained in:
parent
4f1b0ffead
commit
75cb25fbb9
3 changed files with 186 additions and 189 deletions
371
_archives.html
371
_archives.html
|
|
@ -4,226 +4,223 @@
|
|||
<p class="block help">
|
||||
Cet onglet liste les immobilisations sorties du bilan car elles ne
|
||||
sont plus utilisées dans l'association (vétusté, fin de vie,
|
||||
vente, cession...).
|
||||
vente...).
|
||||
</p>
|
||||
|
||||
{{:include file="_get_config.html" keep="module.config"}}
|
||||
|
||||
{{* 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)"}}
|
||||
{{if $module.table != null}}
|
||||
|
||||
{{:assign filter_condition=" AND NOT ("}}
|
||||
{{#foreach from=$module.config.filters item="filter"}}
|
||||
{{:assign filter="%"|cat:$filter|cat:"%"|quote_sql}}
|
||||
{{:assign filter_condition=$filter_condition|cat:" trans_label LIKE "|cat:$filter|cat:" OR "}}
|
||||
{{/foreach}}
|
||||
{{:assign filter_condition=$filter_condition|cat:"0)"}}
|
||||
{{:assign condition=$account_condition|cat:" AND debit > 0 AND NOT (trans.status & 16)"|cat:$filter_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 = 'archived')"}}
|
||||
|
||||
{{:assign nb_immo=0}}
|
||||
{{:assign total_cessions = 0}}
|
||||
{{:assign filter_condition=" ("}}
|
||||
{{#foreach from=$module.config.filters item="filter"}}
|
||||
{{:assign filter="%"|cat:$filter|cat:"%"|quote_sql}}
|
||||
{{:assign filter_condition=$filter_condition|cat:" trans_label LIKE "|cat:$filter|cat:" OR "}}
|
||||
{{/foreach}}
|
||||
{{:assign filter_condition=$filter_condition|cat:"0)"}}
|
||||
{{:assign condition=$account_condition|cat:" AND debit > 0 AND NOT (trans.status & 16) AND NOT "|cat:$filter_condition|cat:" AND "|cat:$status_condition}}
|
||||
|
||||
{{#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"
|
||||
}}
|
||||
{{:assign total_cessions = 0}}
|
||||
|
||||
{{* 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}}
|
||||
{{#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,
|
||||
info.id as immo_doc_id,
|
||||
$$.label as doc_label,
|
||||
$$.amount as doc_amount,
|
||||
$$.date_achat as doc_date_achat,
|
||||
$$.date_mes 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 trans.date DESC;
|
||||
!table=$module.table
|
||||
!condition=$condition
|
||||
assign="immo_line"
|
||||
}}
|
||||
|
||||
{{* 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}}
|
||||
{{:assign var="immo_line.date_mes" value=$doc_date_mes|or:$doc_date_achat|or:$trans_date}}
|
||||
{{:assign var="immo_line.montant_immo" value=$doc_amount|or:$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=$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
|
||||
}}
|
||||
{{: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 = $immo_doc_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}}
|
||||
{{: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.date
|
||||
trans.id as cession_id,
|
||||
trans.label,
|
||||
line.id as line_id,
|
||||
line.credit
|
||||
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
|
||||
INNER JOIN !table AS cession_link ON json_extract(cession_link.document, '$.cession_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
|
||||
;
|
||||
!table=$module.table
|
||||
:immo_line_id = $immo_line.immo_line_id
|
||||
assign="cession_line"
|
||||
}}
|
||||
{{:assign var="immo_line.exit_date" value=$date}}
|
||||
{{:assign var="montant" from="montant_cessions.%d"|args:$account_code}}
|
||||
{{:assign var="montant_cessions.%d"|args:$account_code value="%d+%d"|math:$montant:$credit}}
|
||||
{{:assign total_cessions="%d+%d"|math:$total_cessions:$credit}}
|
||||
{{/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}}
|
||||
{{:assign var="immo_lines." value=$immo_line}}
|
||||
{{/select}}
|
||||
{{:assign var="immo_lines." value=$immo_line}}
|
||||
{{/select}}
|
||||
|
||||
{{if $immo_lines|count > 0}}
|
||||
<section class="immobilisation">
|
||||
<table class="list">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>N°</th>
|
||||
<th>Mise en service</th>
|
||||
<th>Date sortie</th>
|
||||
<th>Libellé</th>
|
||||
<th class="nombre">Montant</th>
|
||||
<th>N° compte</th>
|
||||
<th>Compte</th>
|
||||
<th class="actions"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
{{: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}}
|
||||
|
||||
{{if $immo_lines|count > 0}}
|
||||
<section class="immobilisation">
|
||||
<table class="list">
|
||||
<thead>
|
||||
<tr>
|
||||
<td class="num"><a href="{{$trans_url}}">#{{$trans_id}}</a></td>
|
||||
<td>{{$date_mes|date_short}}</td>
|
||||
<td>{{$exit_date|date_short}}</td>
|
||||
<td>{{$trans_label}}{{if $line_label != null && $line_label != $trans_label}} — {{$line_label}}{{/if}}</td>
|
||||
<td class="money">{{"%f"|math:$montant_immo|money_html:false|raw}}</td>
|
||||
<td><a href="{{$compte_url}}">{{$account_code}}</a></td>
|
||||
<td>{{$account_label}}</td>
|
||||
<td class="actions">
|
||||
{{:linkbutton label="Modifier" href="exit_step1.html?immo_doc_id=%s&from=exit"|args:$info_immo.id shape="edit"}}
|
||||
</td>
|
||||
<th>N°</th>
|
||||
<th>Mise en service</th>
|
||||
<th>Date sortie</th>
|
||||
<th>Libellé</th>
|
||||
<th class="nombre">Montant</th>
|
||||
<th>N° compte</th>
|
||||
<th>Compte</th>
|
||||
<th class="actions"></th>
|
||||
</tr>
|
||||
{{/foreach}}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
{{if $total_immo != 0}}
|
||||
<tr>
|
||||
<td colspan="9">
|
||||
</tr>
|
||||
{{#foreach from=$sommes_immo|ksort key="code" item="value"}}
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
{{: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}}
|
||||
{{: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}}
|
||||
<tr>
|
||||
<td class="num"><a href="{{$trans_url}}">#{{$trans_id}}</a></td>
|
||||
<td>{{$date_mes|date_short}}</td>
|
||||
<td>{{$exit_date|date_short}}</td>
|
||||
<td>{{$label_immo}}</td>
|
||||
<td class="money">{{"%f"|math:$montant_immo|money_html:false|raw}}</td>
|
||||
<td><a href="{{$compte_url}}">{{$account_code}}</a></td>
|
||||
<td>{{$account_label}}</td>
|
||||
<td class="actions">
|
||||
{{:linkbutton label="Modifier" href="exit_step1.html?immo_doc_id=%s&from=exit"|args:$immo_doc_id shape="edit"}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/foreach}}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
{{if $total_immo != 0}}
|
||||
<tr>
|
||||
<td colspan="9">
|
||||
</tr>
|
||||
{{#foreach from=$sommes_immo|ksort key="code" item="value"}}
|
||||
<tr>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td>Total du compte {{$code}}</td>
|
||||
<td class="money">{{$value|money_html:false|raw}}</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td class="actions"></td>
|
||||
</tr>
|
||||
{{/foreach}}
|
||||
<tr>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td>Total du compte {{$code}}</td>
|
||||
<td class="money">{{$value|money_html:false|raw}}</td>
|
||||
<td class="strong">Total des immobilisations</td>
|
||||
<td class="money strong">{{$total_immo|money_html:false|raw}}</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td class="actions"></td>
|
||||
</tr>
|
||||
{{/foreach}}
|
||||
<tr>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td class="strong">Total des immobilisations</td>
|
||||
<td class="money strong">{{$total_immo|money_html:false|raw}}</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td class="actions"></td>
|
||||
</tr>
|
||||
{{/if}}
|
||||
{{if $total_cessions != 0}}
|
||||
<tr>
|
||||
<td colspan="9">
|
||||
</tr>
|
||||
{{#foreach from=$montant_cessions|ksort key="code" item="value"}}
|
||||
{{/if}}
|
||||
{{if $total_cessions != 0}}
|
||||
<tr>
|
||||
<td colspan="9">
|
||||
</tr>
|
||||
{{#foreach from=$montant_cessions|ksort key="code" item="value"}}
|
||||
<tr>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td>Cessions du compte {{$code}}</td>
|
||||
<td class="money">{{$value|money_html:false|raw}}</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td class="actions"></td>
|
||||
</tr>
|
||||
{{/foreach}}
|
||||
<tr>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td>Cessions du compte {{$code}}</td>
|
||||
<td class="money">{{$value|money_html:false|raw}}</td>
|
||||
<td class="strong">Total des cessions</td>
|
||||
<td class="money strong">{{$total_cessions|money_html:false|raw}}</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td class="actions"></td>
|
||||
</tr>
|
||||
{{/foreach}}
|
||||
<tr>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td class="strong">Total des cessions</td>
|
||||
<td class="money strong">{{$total_cessions|money_html:false|raw}}</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td class="actions"></td>
|
||||
</tr>
|
||||
{{/if}}
|
||||
</tfoot>
|
||||
</table>
|
||||
</section>
|
||||
{{else}}
|
||||
{{/if}}
|
||||
</tfoot>
|
||||
</table>
|
||||
</section>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{if $immo_lines|count == 0 || $module.table == null}}
|
||||
<p class="block alert">Aucune immobilisation</p>
|
||||
{{/if}}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
{{:include file="_nav.html" current=$type_immo}}
|
||||
|
||||
{{* Mise à niveau *}}
|
||||
{{:assign module_version="0.40.3"}}
|
||||
{{:assign module_version="0.40.4"}}
|
||||
{{:include file="upgrade.html" module_version=$module_version}}
|
||||
|
||||
{{* supprimer les documents sans écriture associée *}}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
name="Amortissements"
|
||||
description="Immobilisations et amortissements\nversion 0.40.3"
|
||||
description="Immobilisations et amortissements\nversion 0.40.4"
|
||||
author="Jean-Christophe Engel"
|
||||
author_url="https://gitea.zaclys.com/lesanges"
|
||||
home_button=false
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue