Exclure les immo et amortissements de la balance d'ouverture

This commit is contained in:
Jean-Christophe Engel 2024-12-24 15:03:53 +01:00
parent d599d49e1a
commit 516021031d
4 changed files with 106 additions and 10 deletions

69
_amort_exclus.html Normal file
View File

@ -0,0 +1,69 @@
{{* -*- brindille -*- *}}
{{*
Trouver les lignes d'amortissement et d'immobilisation qui sont dans la même écriture
- param : aucun
- résultat : amort_exclus = tableau des amortissements à exclure
*}}
{{* lignes des immo non amorties *}}
{{#load type="immo" where="$$.noamort = true"}}
{{:assign var="lines." value="'%s'"|args:$line}}
{{/load}}
{{:assign lines=$lines|implode:","}}
{{:assign lines="("|cat:$lines|cat:")"}}
{{:assign condition="line.id IN %s"|args:$lines}}
{{*:debug condition=$condition*}}
{{* écritures et comptes associés *}}
{{#select
line.id as line_id,
line.id_transaction as trans_id,
account.id as account_id,
account.code as account_code,
account.id_chart as id_chart
FROM acc_transactions_lines AS line
INNER JOIN acc_transactions AS trans on trans.id = line.id_transaction
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;
!condition=$condition
assign="ecriture"
}}
{{:assign var="ecritures." value="'%s'"|args:$trans_id}}
{{* déterminer le numéro du compte d'amortissement associé au compte d'immobilisation *}}
{{:include
file="./_get_amort_code.html"
code_immo=$account_code
keep="code_amort"
}}
{{:assign var="accounts." value="'%s'"|args:$code_amort}}
{{/select}}
{{*:debug ecritures=$ecritures accounts=$accounts*}}
{{* écritures d'amortissement avec :
- numéro d'écritures obtenus ci-dessus
- numéros de comptes d'amortissement déduits des comptes d'immo ci-dessus
*}}
{{:assign ecritures=$ecritures|implode:","}}
{{:assign ecritures="("|cat:$ecritures|cat:")"}}
{{:assign accounts=$accounts|implode:","}}
{{:assign accounts="("|cat:$accounts|cat:")"}}
{{:assign condition="line.id_transaction IN %s AND account.code IN %s"|args:$ecritures:$accounts}}
{{#select
line.id as line_id,
line.id_transaction as trans_id,
account.id as account_id,
account.code as account_code
FROM acc_transactions_lines AS line
INNER JOIN acc_transactions AS trans on trans.id = line.id_transaction
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;
!condition=$condition
assign="amort"
}}
{{:assign var="amort_exclus." value=$trans_id}}
{{/select}}

14
_get_amort_code.html Normal file
View File

@ -0,0 +1,14 @@
{{* -*- brindille -*- *}}
{{*
déterminer le numéro du compte d'amortissement associé à un compte d'immobilisation
- param :
- code_immo : numéro du compte d'immobilisation
- résultat :
- code_amort : numéro du compte d'amortissement
*}}
{{:assign code_s=$code_immo|strval}}
{{:assign ch1=$code_s|substr:0:1}}
{{:assign reste=$code_s|substr:1}}
{{:assign code_amort=$ch1|cat:"8"|cat:$reste}}

View File

@ -229,6 +229,12 @@
</section> </section>
{{/if}} {{/if}}
{{* amortissement à exclure *}}
{{:include
file="_amort_exclus.html"
keep="amort_exclus"
}}
{{* Autres amortissements non rattachés *}} {{* Autres amortissements non rattachés *}}
{{#select {{#select
li.id as l_id, li.id as l_id,
@ -257,7 +263,10 @@
:id_amort=$t_id :id_amort=$t_id
}} }}
{{else}} {{else}}
{{:assign var="autres_amortissements." value=$autre_amort}} {{if $autre_amort.t_id|in:$amort_exclus}}
{{else}}
{{:assign var="autres_amortissements." value=$autre_amort}}
{{/if}}
{{/select}} {{/select}}
{{/select}} {{/select}}

View File

@ -43,11 +43,13 @@
{{:assign config_defaut=$config_json|json_decode}} {{:assign config_defaut=$config_json|json_decode}}
{{:assign var="prefix_array" value=$config_defaut.prefixes|keys}} {{:assign var="prefix_array" value=$config_defaut.prefixes|keys}}
{{#foreach from=$prefix_array item="code"}} {{#foreach from=$prefix_array item="code"}}
{{:assign code_s=$code|strval}} {{* déterminer le numéro du compte d'amortissement associé au compte d'immobilisation *}}
{{:assign ch1=$code_s|substr:0:1}} {{:include
{{:assign reste=$code_s|substr:1}} file="./_get_amort_code.html"
{{:assign code=$ch1|cat:"8"|cat:$reste}} code_immo=$code
{{:assign var="amort_array." value=$code|intval}} keep="code_amort"
}}
{{:assign var="amort_array." value=$code_amort|intval}}
{{/foreach}} {{/foreach}}
{{:include {{:include
@ -113,10 +115,12 @@
d'immobilisation => ajouter un 8 après le 2 de tête d'immobilisation => ajouter un 8 après le 2 de tête
*}} *}}
{{#select code, label from acc_accounts where id = :id; :id=$_GET.account assign=amort_account}}{{/select}} {{#select code, label from acc_accounts where id = :id; :id=$_GET.account assign=amort_account}}{{/select}}
{{:assign c1=$amort_account.code|substr:0:1}} {{:include
{{:assign reste=$amort_account.code|substr:1}} file="./_get_amort_code.html"
{{:assign amort_code=$c1|cat:8|cat:$reste}} code_immo=$amort_account.code
{{:assign var="credit_account.%s"|args:$amort_code value="%s — Amortissements "|args:$amort_code|cat:$amort_account.label}} keep="code_amort"
}}
{{:assign var="credit_account.%s"|args:$code_amort value="%s — Amortissements "|args:$code_amort|cat:$amort_account.label}}
{{#select {{#select
id, id,