Exclure les immo et amortissements de la balance d'ouverture
This commit is contained in:
parent
d599d49e1a
commit
516021031d
69
_amort_exclus.html
Normal file
69
_amort_exclus.html
Normal 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
14
_get_amort_code.html
Normal 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}}
|
@ -229,6 +229,12 @@
|
||||
</section>
|
||||
{{/if}}
|
||||
|
||||
{{* amortissement à exclure *}}
|
||||
{{:include
|
||||
file="_amort_exclus.html"
|
||||
keep="amort_exclus"
|
||||
}}
|
||||
|
||||
{{* Autres amortissements non rattachés *}}
|
||||
{{#select
|
||||
li.id as l_id,
|
||||
@ -256,8 +262,11 @@
|
||||
where id_transaction = :id_amort or id_related = :id_amort;
|
||||
:id_amort=$t_id
|
||||
}}
|
||||
{{else}}
|
||||
{{if $autre_amort.t_id|in:$amort_exclus}}
|
||||
{{else}}
|
||||
{{:assign var="autres_amortissements." value=$autre_amort}}
|
||||
{{/if}}
|
||||
{{/select}}
|
||||
{{/select}}
|
||||
|
||||
|
@ -43,11 +43,13 @@
|
||||
{{:assign config_defaut=$config_json|json_decode}}
|
||||
{{:assign var="prefix_array" value=$config_defaut.prefixes|keys}}
|
||||
{{#foreach from=$prefix_array item="code"}}
|
||||
{{:assign code_s=$code|strval}}
|
||||
{{:assign ch1=$code_s|substr:0:1}}
|
||||
{{:assign reste=$code_s|substr:1}}
|
||||
{{:assign code=$ch1|cat:"8"|cat:$reste}}
|
||||
{{:assign var="amort_array." value=$code|intval}}
|
||||
{{* déterminer le numéro du compte d'amortissement associé au compte d'immobilisation *}}
|
||||
{{:include
|
||||
file="./_get_amort_code.html"
|
||||
code_immo=$code
|
||||
keep="code_amort"
|
||||
}}
|
||||
{{:assign var="amort_array." value=$code_amort|intval}}
|
||||
{{/foreach}}
|
||||
|
||||
{{:include
|
||||
@ -113,10 +115,12 @@
|
||||
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}}
|
||||
{{:assign c1=$amort_account.code|substr:0:1}}
|
||||
{{:assign reste=$amort_account.code|substr:1}}
|
||||
{{:assign amort_code=$c1|cat:8|cat:$reste}}
|
||||
{{:assign var="credit_account.%s"|args:$amort_code value="%s — Amortissements "|args:$amort_code|cat:$amort_account.label}}
|
||||
{{:include
|
||||
file="./_get_amort_code.html"
|
||||
code_immo=$amort_account.code
|
||||
keep="code_amort"
|
||||
}}
|
||||
{{:assign var="credit_account.%s"|args:$code_amort value="%s — Amortissements "|args:$code_amort|cat:$amort_account.label}}
|
||||
|
||||
{{#select
|
||||
id,
|
||||
|
Loading…
Reference in New Issue
Block a user