Compare commits
1 commit
main
...
compat_131
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
379f523eaa |
21 changed files with 425 additions and 877 deletions
|
|
@ -50,8 +50,7 @@
|
||||||
trans.label as trans_label,
|
trans.label as trans_label,
|
||||||
trans.date as trans_date,
|
trans.date as trans_date,
|
||||||
trans.id_year as trans_id_year,
|
trans.id_year as trans_id_year,
|
||||||
line.id as immo_line_id,
|
line.id as immo_id,
|
||||||
line.label as line_label,
|
|
||||||
line.debit AS debit,
|
line.debit AS debit,
|
||||||
account.id as account_id,
|
account.id as account_id,
|
||||||
account.code as account_code,
|
account.code as account_code,
|
||||||
|
|
@ -67,10 +66,12 @@
|
||||||
!condition=$condition
|
!condition=$condition
|
||||||
}}
|
}}
|
||||||
{{:assign montant_immo=$debit}}
|
{{:assign montant_immo=$debit}}
|
||||||
|
|
||||||
{{* voir si l'immo est prise en charge *}}
|
{{* voir si l'immo est prise en charge *}}
|
||||||
{{#load type="immo" where="$$.line = :line_id" :line_id=$immo_line_id|intval}}
|
{{#load type="immo" where="$$.line = :line_id" :line_id=$immo_id|intval}}
|
||||||
{{:assign status=$status}}
|
{{:assign status=$status}}
|
||||||
|
{{if $amount != null}}
|
||||||
|
{{:assign montant_immo=$amount}}
|
||||||
|
{{/if}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{:assign amortissable="nsp"}}
|
{{:assign amortissable="nsp"}}
|
||||||
{{:assign status="unknown"}}
|
{{:assign status="unknown"}}
|
||||||
|
|
@ -79,48 +80,32 @@
|
||||||
{{:continue}}
|
{{:continue}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{* chercher des écritures liées à l'immo courante au crédit du même compte
|
{{* voir s'il existe une écriture liée qui solde l'immobilisation *}}
|
||||||
et déduire leur montant de celui de l'immo
|
|
||||||
*}}
|
|
||||||
{{:assign solde_immo=$montant_immo}}
|
|
||||||
{{:assign credit_immo=null}}
|
|
||||||
{{#select
|
{{#select
|
||||||
CASE links.id_related = :immo_trans_id
|
trans.date as exit_date
|
||||||
WHEN true THEN links.id_transaction
|
FROM acc_transactions_links AS link
|
||||||
WHEN false THEN links.id_related
|
INNER JOIN acc_transactions AS trans ON
|
||||||
END as other_id,
|
(CASE
|
||||||
line.credit,
|
WHEN link.id_transaction = :trans_id THEN link.id_related
|
||||||
MAX(trans2.date) as exit_date
|
WHEN link.id_related = :trans_id THEN link.id_transaction
|
||||||
FROM acc_transactions AS trans
|
END) = trans.id
|
||||||
INNER JOIN acc_transactions_links as links
|
INNER JOIN acc_transactions_lines AS line ON line.id_transaction = trans.id
|
||||||
ON (trans.id = links.id_transaction OR trans.id = links.id_related)
|
INNER JOIN acc_accounts AS acc on line.id_account=acc.id
|
||||||
INNER JOIN acc_transactions_lines AS line on line.id_transaction = other_id
|
WHERE line.credit = :montant_immo
|
||||||
INNER JOIN acc_accounts AS acc ON line.id_account = acc.id
|
AND acc.code = :account_code
|
||||||
INNER JOIN acc_transactions AS trans2 ON trans2.id = other_id
|
|
||||||
WHERE trans.id = :immo_trans_id AND line.credit > 0 AND acc.code = :account
|
|
||||||
ORDER BY trans2.date, trans2.id
|
|
||||||
;
|
;
|
||||||
:immo_trans_id=$trans_id
|
:trans_id = $trans_id
|
||||||
:account=$account_code
|
:montant_immo = $montant_immo
|
||||||
assign="credit_immo."
|
:account_code = $account_code
|
||||||
}}
|
}}
|
||||||
{{:assign solde_immo="%d-%d"|math:$solde_immo:$credit}}
|
{{:assign status="archived"}}
|
||||||
{{:assign exit_date=$exit_date}}
|
{{:assign exit_date=$exit_date}}
|
||||||
{{/select}}
|
{{/select}}
|
||||||
|
|
||||||
{{if $solde_immo == 0}}
|
|
||||||
{{:assign status="archived"}}
|
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
{{if $status != "archived"}}
|
{{if $status != "archived"}}
|
||||||
{{:continue}}
|
{{:continue}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{:assign nb=$credit_immo|count}}
|
|
||||||
{{:assign nb="%d-1"|math:$nb}}
|
|
||||||
{{:assign var="last_credit" from="credit_immo.%d"|args:$nb}}
|
|
||||||
{{:assign montant_immo=$last_credit.credit}}
|
|
||||||
|
|
||||||
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$trans_id}}
|
{{: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 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 nb_immo="%d+1"|math:$nb_immo}}
|
||||||
|
|
@ -131,7 +116,12 @@
|
||||||
{{* voir s'il y a une écriture de cession associée à cette immo *}}
|
{{* voir s'il y a une écriture de cession associée à cette immo *}}
|
||||||
{{#select
|
{{#select
|
||||||
trans.id,
|
trans.id,
|
||||||
line.debit
|
trans.label,
|
||||||
|
trans.date,
|
||||||
|
line.id,
|
||||||
|
line.debit,
|
||||||
|
acc.code,
|
||||||
|
acc.label
|
||||||
FROM acc_transactions_links AS link
|
FROM acc_transactions_links AS link
|
||||||
INNER JOIN acc_transactions AS trans ON (CASE
|
INNER JOIN acc_transactions AS trans ON (CASE
|
||||||
WHEN link.id_transaction = :trans_id THEN link.id_related
|
WHEN link.id_transaction = :trans_id THEN link.id_related
|
||||||
|
|
@ -152,7 +142,7 @@
|
||||||
<td class="num"><a href={{$trans_url}}>#{{$trans_id}}</a></td>
|
<td class="num"><a href={{$trans_url}}>#{{$trans_id}}</a></td>
|
||||||
<td>{{$trans_date|date_short}}</td>
|
<td>{{$trans_date|date_short}}</td>
|
||||||
<td>{{$exit_date|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>{{$trans_label}}</td>
|
||||||
<td class="money">{{"%f"|math:$montant_immo|money_html:false|raw}}</td>
|
<td class="money">{{"%f"|math:$montant_immo|money_html:false|raw}}</td>
|
||||||
<td><a href={{$compte_url}}>{{$account_code}}</a></td>
|
<td><a href={{$compte_url}}>{{$account_code}}</a></td>
|
||||||
<td>{{$account_label}}</td>
|
<td>{{$account_label}}</td>
|
||||||
|
|
@ -164,9 +154,6 @@
|
||||||
</tbody>
|
</tbody>
|
||||||
<tfoot>
|
<tfoot>
|
||||||
{{if $total_immo != 0}}
|
{{if $total_immo != 0}}
|
||||||
<tr>
|
|
||||||
<td colspan="9">
|
|
||||||
</tr>
|
|
||||||
{{#foreach from=$sommes_immo|ksort key="code" item="value"}}
|
{{#foreach from=$sommes_immo|ksort key="code" item="value"}}
|
||||||
<tr>
|
<tr>
|
||||||
<td></td>
|
<td></td>
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
{{/foreach}}
|
{{/foreach}}
|
||||||
{{:assign condition=$condition|cat:"0)"}}
|
{{:assign condition=$condition|cat:"0)"}}
|
||||||
|
|
||||||
{{:assign account_code=$account|keys|value:0}}
|
{{:assign account_code=$account|keys|key:0}}
|
||||||
{{#sql
|
{{#sql
|
||||||
select="code"
|
select="code"
|
||||||
tables="acc_accounts"
|
tables="acc_accounts"
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,7 @@
|
||||||
la forme : code — libellé
|
la forme : code — libellé
|
||||||
*}}
|
*}}
|
||||||
|
|
||||||
{{:assign values=$account|values}}
|
{{:assign label=$account|values|key:0}}
|
||||||
{{:assign label=$values.0}}
|
|
||||||
{{:assign pos=$label|strpos:" "}}
|
{{:assign pos=$label|strpos:" "}}
|
||||||
{{:assign account_code=$label|substr:0:$pos}}
|
{{:assign account_code=$label|substr:0:$pos}}
|
||||||
{{:assign var="account_code.%s"|args:$account_code value=$label}}
|
{{:assign var="account_code.%s"|args:$account_code value=$label}}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
{{* -*- brindille -*- *}}
|
{{* -*- brindille -*- *}}
|
||||||
|
|
||||||
{{* Liste des immobilisations en cours d'amortissement ou amorties *}}
|
{{* Liste des immobilisations en cours ou amorties *}}
|
||||||
|
|
||||||
{{:include file="_get_config.html" keep="module.config"}}
|
|
||||||
<section class="immobilisation">
|
<section class="immobilisation">
|
||||||
|
|
||||||
<p class="help">
|
<p class="help">
|
||||||
|
|
@ -29,190 +28,145 @@
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
|
||||||
{{* vérifier l'existence de la table du module *}}
|
|
||||||
{{#load limit="1"}}
|
|
||||||
{{:assign table_presente=true}}
|
|
||||||
{{else}}
|
|
||||||
{{:assign table_presente=false}}
|
|
||||||
{{/load}}
|
|
||||||
|
|
||||||
{{if $table_presente}}
|
|
||||||
{{* lister les immobilisations *}}
|
{{* lister les immobilisations *}}
|
||||||
|
{{:include file="_get_config.html" keep="module.config"}}
|
||||||
|
|
||||||
{{:assign account_condition="("}}
|
{{:assign account_condition="("}}
|
||||||
{{#foreach from=$module.config.prefixes item="code"}}
|
{{#foreach from=$module.config.prefixes item="code"}}
|
||||||
{{:assign code=$code|cat:"%"|quote_sql}}
|
{{:assign code=$code|cat:"%"|quote_sql}}
|
||||||
{{:assign account_condition=$account_condition|cat:" account.code LIKE "|cat:$code|cat:" OR "}}
|
{{:assign account_condition=$account_condition|cat:" account.code LIKE "|cat:$code|cat:" OR "}}
|
||||||
{{/foreach}}
|
{{/foreach}}
|
||||||
{{:assign account_condition=$account_condition|cat:"0)"}}
|
{{:assign account_condition=$account_condition|cat:"0)"}}
|
||||||
{{:assign doc_condition="($$.status <> 'ignored' AND $$.status <> 'archived')"}}
|
|
||||||
|
|
||||||
{{:assign filter_condition="NOT ("}}
|
{{:assign filter_condition=" AND NOT ("}}
|
||||||
{{#foreach from=$module.config.filters item="filter"}}
|
{{#foreach from=$module.config.filters item="filter"}}
|
||||||
{{:assign filter="%"|cat:$filter|cat:"%"|quote_sql}}
|
{{:assign filter="%"|cat:$filter|cat:"%"|quote_sql}}
|
||||||
{{:assign filter_condition=$filter_condition|cat:" trans_label LIKE "|cat:$filter|cat:" OR "}}
|
{{:assign filter_condition=$filter_condition|cat:" trans_label LIKE "|cat:$filter|cat:" OR "}}
|
||||||
{{/foreach}}
|
{{/foreach}}
|
||||||
{{:assign filter_condition=$filter_condition|cat:"0)"}}
|
{{:assign filter_condition=$filter_condition|cat:"0)"}}
|
||||||
{{:assign filter_condition="($$.status IS NULL AND NOT (trans.status & 16) AND "|cat:$filter_condition|cat:")"}}
|
|
||||||
|
|
||||||
{{:assign condition=$account_condition|cat:" AND debit > 0 AND ("|cat:$filter_condition|cat:" OR "|cat:$doc_condition|cat:")"}}
|
|
||||||
|
|
||||||
|
{{:assign condition=$account_condition|cat:" AND debit > 0 AND NOT (trans.status & 16)"|cat:$filter_condition}}
|
||||||
{{:assign nb_immo=0}}
|
{{:assign nb_immo=0}}
|
||||||
{{:assign total_immo = 0}}
|
{{:assign total_immo = 0}}
|
||||||
{{#select
|
{{#select
|
||||||
trans.id as immo_trans_id,
|
trans.id as trans_id,
|
||||||
trans.label as trans_label,
|
trans.label as trans_label,
|
||||||
trans.date as trans_date,
|
trans.date as trans_date,
|
||||||
line.id as immo_line_id,
|
line.id as immo_id,
|
||||||
line.debit AS debit,
|
line.debit AS debit,
|
||||||
line.label AS line_label,
|
|
||||||
account.id as account_id,
|
account.id as account_id,
|
||||||
account.code as account_code,
|
account.code as account_code,
|
||||||
trans.id_year as trans_id_year,
|
account.label as account_label,
|
||||||
$$.duration as duration,
|
trans.id_year as trans_id_year
|
||||||
$$.status as status
|
|
||||||
FROM acc_transactions AS trans
|
FROM acc_transactions AS trans
|
||||||
INNER JOIN acc_transactions_lines AS line ON line.id_transaction = trans.id
|
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_accounts AS account ON line.id_account = account.id
|
||||||
INNER JOIN acc_years AS years ON trans.id_year = years.id
|
INNER JOIN acc_years AS years ON trans.id_year = years.id
|
||||||
LEFT JOIN !table AS info ON $$.line = line.id
|
|
||||||
WHERE !condition
|
WHERE !condition
|
||||||
ORDER BY trans.date DESC;
|
ORDER BY trans.date DESC;
|
||||||
!table=$module.table
|
|
||||||
!condition=$condition
|
!condition=$condition
|
||||||
}}
|
}}
|
||||||
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$immo_trans_id}}
|
{{: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 compte_url="%s/acc/accounts/journal.php?id=%s&year=%s"|args:$admin_url:$account_id:$trans_id_year}}
|
||||||
{{:assign duration=$duration}}
|
{{:assign duration=null}}
|
||||||
{{:assign montant_immo=$debit}}
|
{{:assign montant_immo=$debit}}
|
||||||
{{if $status == null}}
|
|
||||||
|
{{* voir si l'immo est prise en charge *}}
|
||||||
|
{{#load type="immo" where="$$.line = :line_id" :line_id=$immo_id|intval}}
|
||||||
|
{{:assign duration=$duration}}
|
||||||
|
{{:assign status=$status}}
|
||||||
|
{{if $amount != null}}
|
||||||
|
{{:assign montant_immo=$amount}}
|
||||||
|
{{/if}}
|
||||||
|
{{else}}
|
||||||
|
{{:assign amortissable="nsp"}}
|
||||||
{{:assign status="unknown"}}
|
{{:assign status="unknown"}}
|
||||||
{{/if}}
|
{{/load}}
|
||||||
|
{{if $status == "ignored"}}
|
||||||
{{* chercher des écritures liées à l'immo courante au crédit du même compte
|
|
||||||
et déduire leur montant de celui de l'immo
|
|
||||||
*}}
|
|
||||||
{{#select
|
|
||||||
CASE links.id_related = :immo_trans_id
|
|
||||||
WHEN true THEN links.id_transaction
|
|
||||||
WHEN false THEN links.id_related
|
|
||||||
END as other_id,
|
|
||||||
line.credit
|
|
||||||
FROM acc_transactions AS trans
|
|
||||||
INNER JOIN acc_transactions_links as links
|
|
||||||
ON (trans.id = links.id_transaction OR trans.id = links.id_related)
|
|
||||||
INNER JOIN acc_transactions_lines AS line on line.id_transaction = other_id
|
|
||||||
INNER JOIN acc_accounts AS acc ON line.id_account = acc.id
|
|
||||||
WHERE trans.id = :immo_trans_id AND line.credit > 0 AND acc.code = :account;
|
|
||||||
:immo_trans_id=$immo_trans_id
|
|
||||||
:account=$account_code
|
|
||||||
}}
|
|
||||||
{{:assign montant_immo="%d-%d"|math:$montant_immo:$credit}}
|
|
||||||
{{/select}}
|
|
||||||
|
|
||||||
{{* Immobilisation soldée ? *}}
|
|
||||||
{{* TODO marquer archivée *}}
|
|
||||||
{{if $montant_immo == 0}}
|
|
||||||
{{:continue}}
|
{{:continue}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{* lister les lignes des écritures d'amortissement liées à l'immobilisation *}}
|
{{* voir s'il existe une écriture qui solde l'immobilisation *}}
|
||||||
{{:assign amort_lines=null}}
|
|
||||||
{{#select
|
{{#select
|
||||||
l_amort.credit as amount,
|
line.id AS line
|
||||||
|
FROM acc_transactions_lines AS line
|
||||||
|
INNER JOIN acc_accounts AS acc ON acc.id = line.id_account
|
||||||
|
INNER JOIN acc_transactions_lines AS line2 ON line2.id_account = acc.id
|
||||||
|
WHERE
|
||||||
|
line.id = :line_id
|
||||||
|
AND line2.credit = :montant_immo;
|
||||||
|
:line_id = $immo_id|intval
|
||||||
|
:montant_immo = $montant_immo
|
||||||
|
}}
|
||||||
|
{{:assign status="archived"}}
|
||||||
|
{{/select}}
|
||||||
|
{{if $status == "archived"}}
|
||||||
|
{{:continue}}
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{* voir s'il existe des écritures d'amortissement associées *}}
|
||||||
|
{{#select
|
||||||
|
sum(l_amort.credit) as amort_amount,
|
||||||
CASE links.id_related = t_immo.id
|
CASE links.id_related = t_immo.id
|
||||||
WHEN true THEN links.id_transaction
|
WHEN true THEN links.id_transaction
|
||||||
WHEN false THEN links.id_related
|
WHEN false THEN links.id_related
|
||||||
END as amort_trans_id,
|
END as amort_trans_id
|
||||||
l_amort.id AS amort_line_id
|
|
||||||
FROM acc_transactions_lines as l_immo
|
FROM acc_transactions_lines as l_immo
|
||||||
INNER JOIN acc_transactions as t_immo on t_immo.id = l_immo.id_transaction
|
INNER JOIN acc_transactions as t_immo on t_immo.id = l_immo.id_transaction
|
||||||
INNER JOIN acc_transactions_links as links
|
INNER JOIN acc_transactions_links as links
|
||||||
ON (t_immo.id = links.id_transaction OR t_immo.id = links.id_related)
|
ON (
|
||||||
|
t_immo.id = links.id_transaction
|
||||||
|
OR
|
||||||
|
t_immo.id = links.id_related
|
||||||
|
)
|
||||||
INNER JOIN acc_transactions_lines as l_amort on amort_trans_id = l_amort.id_transaction
|
INNER JOIN acc_transactions_lines as l_amort on amort_trans_id = l_amort.id_transaction
|
||||||
INNER JOIN acc_accounts AS account ON l_amort.id_account = account.id
|
INNER JOIN acc_accounts AS account ON l_amort.id_account = account.id
|
||||||
WHERE l_immo.id = :line_id AND l_amort.credit <> 0 AND account.code LIKE '28%';
|
WHERE
|
||||||
:line_id = $immo_line_id|intval
|
l_immo.id = :line_id
|
||||||
assign="line"
|
AND
|
||||||
|
l_amort.credit <> 0
|
||||||
|
AND
|
||||||
|
account.code LIKE '28%';
|
||||||
|
:line_id = $immo_id|intval
|
||||||
}}
|
}}
|
||||||
{{:assign var="amort_lines.%d."|args:$amort_trans_id value=$line}}
|
{{if $amort_amount == null}}
|
||||||
|
{{:assign exist_amort=false}}
|
||||||
|
{{:assign amort_amount=0}}
|
||||||
|
{{else}}
|
||||||
|
{{:assign exist_amort=true}}
|
||||||
|
{{:assign amort_amount=$amort_amount}}
|
||||||
|
{{/if}}
|
||||||
{{/select}}
|
{{/select}}
|
||||||
|
|
||||||
{{:assign amort_amount=0}}
|
|
||||||
{{#foreach from=$amort_lines key="amort_trans_id" item="lines"}}
|
|
||||||
{{:assign nb=$lines|count}}
|
|
||||||
{{* lister les docs de liaison de l'écriture d'amortissement *}}
|
|
||||||
{{:assign links=null}}
|
|
||||||
{{#load type="link"
|
|
||||||
where="$$.immo_line_id = :immo_line_id AND $$.amort_trans_id = :amort_trans_id"
|
|
||||||
:immo_line_id = $immo_line_id
|
|
||||||
:amort_trans_id = $amort_trans_id
|
|
||||||
assign="links."
|
|
||||||
}}
|
|
||||||
{{/load}}
|
|
||||||
|
|
||||||
{{#foreach from=$lines item="line"}}
|
|
||||||
{{* voir s'il existe une ligne associée à l'écriture d'amortissement *}}
|
|
||||||
{{:assign line_link_exist=false}}
|
|
||||||
{{#foreach from=$links item="link"}}
|
|
||||||
{{if $link.amort_line_id == $line.amort_line_id}}
|
|
||||||
{{:assign amort_amount="%d+%d"|math:$amort_amount:$line.amount}}
|
|
||||||
{{:assign line_link_exist=true}}
|
|
||||||
{{/if}}
|
|
||||||
{{/foreach}}
|
|
||||||
{{if ! $line_link_exist}}
|
|
||||||
{{if $nb == 1}}
|
|
||||||
{{* créer la liaison ligne immo <-> ligne amort *}}
|
|
||||||
{{*:debug lier_immo_line_id=$immo_line_id lier_amort_trans_id=$amort_trans_id avec_amort_line_id=$amort_line_id*}}
|
|
||||||
{{:save
|
|
||||||
key=""|uuid
|
|
||||||
type="link"
|
|
||||||
immo_line_id=$immo_line_id
|
|
||||||
amort_line_id=$amort_line_id
|
|
||||||
amort_trans_id=$amort_trans_id
|
|
||||||
}}
|
|
||||||
{{:assign amort_amount="%d+%d"|math:$amort_amount:$line.amount}}
|
|
||||||
{{/if}}
|
|
||||||
{{/if}}
|
|
||||||
{{/foreach}}
|
|
||||||
{{/foreach}}
|
|
||||||
|
|
||||||
{{if $amort_amount == 0}}
|
|
||||||
{{:assign exist_amort=false}}
|
|
||||||
{{else}}
|
|
||||||
{{:assign exist_amort=true}}
|
|
||||||
{{:assign amort_amount=$amort_amount}}
|
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
{{* classement par onglet *}}
|
{{* classement par onglet *}}
|
||||||
{{if $type_immo == "managed" && $amort_amount >= $montant_immo}}{{:continue}}{{/if}}
|
{{if $type_immo == "managed" && $amort_amount >= $montant_immo}}{{:continue}}{{/if}}
|
||||||
|
{{if $type_immo == "managed" && $status == "amortized"}}{{:continue}}{{/if}}
|
||||||
{{if $status == "unknown" && ! $exist_amort}}{{:continue}}{{/if}}
|
{{if $status == "unknown" && ! $exist_amort}}{{:continue}}{{/if}}
|
||||||
{{if $type_immo == "amortized" && $amort_amount < $montant_immo}}{{:continue}}{{/if}} {{* ?? *}}
|
{{if $type_immo == "amortized" && $amort_amount < $montant_immo && $status != "amortized"}}{{:continue}}{{/if}}
|
||||||
|
|
||||||
{{:assign nb_immo="%d+1"|math:$nb_immo}}
|
{{:assign nb_immo="%d+1"|math:$nb_immo}}
|
||||||
{{:assign total_immo="%d+%d"|math:$total_immo:$montant_immo}}
|
{{:assign total_immo="%d+%d"|math:$total_immo:$montant_immo}}
|
||||||
{{:assign var="montant" from="sommes_immo.%s"|args:$account_code}}
|
{{: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}}
|
{{:assign var="sommes_immo.%s"|args:$account_code value="%d+%d"|math:$montant:$montant_immo}}
|
||||||
<tr>
|
<tr>
|
||||||
<td class="num"><a href={{$trans_url}}>#{{$immo_trans_id}}</a></td>
|
<td class="num"><a href={{$trans_url}}>#{{$trans_id}}</a></td>
|
||||||
<td>{{$trans_date|date_short}}</td>
|
<td>{{$trans_date|date_short}}</td>
|
||||||
<td>{{$trans_label}}{{if $line_label != null && $line_label != $trans_label}} — {{$line_label}}{{/if}}</td>
|
<td>{{$trans_label}}</td>
|
||||||
<td class="money">{{$montant_immo|money_html:false|raw}}</td>
|
<td class="money">{{$montant_immo|money_html:false|raw}}</td>
|
||||||
<td class="money">{{if $duration != null}}{{$duration}}{{/if}}</td>
|
<td class="money">{{if $duration != null}}{{$duration}}{{/if}}</td>
|
||||||
<td class="money">{{$amort_amount|money_html:false|raw}}</td>
|
<td class="money">{{$amort_amount|money_html:false|raw}}</td>
|
||||||
<td class="money">{{"%d-%d"|math:$montant_immo:$amort_amount|money_html:false|raw}}</td>
|
<td class="money">{{"%d-%d"|math:$montant_immo:$amort_amount|money_html:false|raw}}</td>
|
||||||
<td><a href={{$compte_url}}>{{$account_code}}</a></td>
|
<td><a href={{$compte_url}}>{{$account_code}}</a></td>
|
||||||
<td class="actions">
|
<td class="actions">
|
||||||
{{if ! $exist_amort || $status == "unknown"}}
|
{{:linkbutton
|
||||||
{{:linkbutton
|
label="Paramètres"
|
||||||
label="Paramètres"
|
href="add_infos.html?immo_id=%s&type_immo=%s"|args:$immo_id:$type_immo
|
||||||
href="add_infos.html?immo_line_id=%s&type_immo=%s"|args:$immo_line_id:$type_immo
|
shape="settings"
|
||||||
shape="settings"
|
target="_dialog"
|
||||||
}}
|
}}
|
||||||
{{* target="_dialog"*}}
|
|
||||||
{{/if}}
|
|
||||||
{{:linkbutton
|
{{:linkbutton
|
||||||
label="Amortissements"
|
label="Amortissements"
|
||||||
href="amortization.html?immo_line_id=%s&type_immo=%s"|args:$immo_line_id:$type_immo
|
href="amortization.html?immo_id=%s&type_immo=%s"|args:$immo_id:$type_immo
|
||||||
shape="table"
|
shape="table"
|
||||||
}}
|
}}
|
||||||
</td>
|
</td>
|
||||||
|
|
@ -221,9 +175,6 @@
|
||||||
</tbody>
|
</tbody>
|
||||||
<tfoot>
|
<tfoot>
|
||||||
{{if $total_immo != 0}}
|
{{if $total_immo != 0}}
|
||||||
<tr>
|
|
||||||
<td colspan="9">
|
|
||||||
</tr>
|
|
||||||
{{#foreach from=$sommes_immo|ksort key="code" item="value"}}
|
{{#foreach from=$sommes_immo|ksort key="code" item="value"}}
|
||||||
<tr>
|
<tr>
|
||||||
<td></td>
|
<td></td>
|
||||||
|
|
@ -250,9 +201,8 @@
|
||||||
</tr>
|
</tr>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</tfoot>
|
</tfoot>
|
||||||
{{/if}}
|
|
||||||
</table>
|
</table>
|
||||||
{{if $nb_immo == 0 || ! $table_presente}}
|
{{if $nb_immo == 0}}
|
||||||
<p class="block alert">Aucune immobilisation</p>
|
<p class="block alert">Aucune immobilisation</p>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</section>
|
</section>
|
||||||
|
|
|
||||||
|
|
@ -2,27 +2,22 @@
|
||||||
|
|
||||||
{{* Liste des immobilisations non amortissables ou non (encore) gérées *}}
|
{{* Liste des immobilisations non amortissables ou non (encore) gérées *}}
|
||||||
|
|
||||||
{{:include file="_get_config.html" keep="module.config"}}
|
|
||||||
<section class="immobilisation">
|
<section class="immobilisation">
|
||||||
|
|
||||||
<p class="help">
|
<p class="help">
|
||||||
Cette page liste les écritures pas (encore) prises en charge par le module et sans écriture d'amortissement associée.
|
Cette page liste les écritures pas (encore) prises en charge par le module et sans écriture d'amortissement associée.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
{{:assign saved_hides=$module.config.hides}}
|
{{:include file="_get_config.html" keep="module.config"}}
|
||||||
{{:assign var="user_hides" from="saved_hides.%s"|args:$logged_user.id}}
|
|
||||||
|
|
||||||
{{if $_POST|count == 0}}
|
{{if $_POST|count == 0}}
|
||||||
{{:assign unhide=$user_hides.unhide_other}}
|
{{:assign unhide=$module.config.unhide_other}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{if $_POST.unhide == null}}
|
{{if $_POST.unhide == null}}
|
||||||
{{:assign unhide=0}}
|
{{:assign unhide=0}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{:assign unhide=1}}
|
{{:assign unhide=1}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{:assign var="user_hides.unhide_other" value=$unhide"}}
|
{{:save key="config" unhide_other=$unhide}}
|
||||||
{{:assign var="saved_hides.%s"|args:$logged_user.id value=$user_hides}}
|
|
||||||
{{:save key="config" hides=$saved_hides}}
|
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{if $unhide}}
|
{{if $unhide}}
|
||||||
{{:assign checked="checked"}}
|
{{:assign checked="checked"}}
|
||||||
|
|
@ -30,14 +25,14 @@
|
||||||
|
|
||||||
<form method="post" action="">
|
<form method="post" action="">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
{{:input type="checkbox" value=1 name="unhide" checked="%s"|args:$checked label="Afficher toutes les écritures" }}
|
{{:input type="checkbox" value=1 name="unhide" checked="%s"|args:$checked label="Afficher les écritures marquées ignorées" }}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<table class="list">
|
<table class="list">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="num">N°</th>
|
<th>N°</th>
|
||||||
<th>Date</th>
|
<th>Date</th>
|
||||||
<th>Libellé</th>
|
<th>Libellé</th>
|
||||||
<th class="nombre">Montant</th>
|
<th class="nombre">Montant</th>
|
||||||
|
|
@ -48,72 +43,55 @@
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
|
||||||
{{* vérifier l'existence de la table du module *}}
|
|
||||||
{{#load limit="1"}}
|
|
||||||
{{:assign columns="$$.duration as duration, $$.status as status,"}}
|
|
||||||
{{:assign table_join="LEFT JOIN !table AS info ON $$.line = line.id"}}
|
|
||||||
{{:assign doc_condition1="($$.status == 'ignored')"}}
|
|
||||||
{{:assign doc_condition2="$$.status IS NULL"}}
|
|
||||||
{{else}}
|
|
||||||
{{:assign columns=""}}
|
|
||||||
{{:assign table_join=""}}
|
|
||||||
{{:assign doc_condition1="0"}}
|
|
||||||
{{:assign doc_condition2="1"}}
|
|
||||||
{{/load}}
|
|
||||||
|
|
||||||
{{* lister les immobilisations *}}
|
{{* lister les immobilisations *}}
|
||||||
{{:assign account_condition="("}}
|
{{:assign condition="("}}
|
||||||
{{#foreach from=$module.config.prefixes item="code"}}
|
{{#foreach from=$module.config.prefixes item="code"}}
|
||||||
{{:assign code=$code|cat:"%"|quote_sql}}
|
{{:assign code=$code|cat:"%"|quote_sql}}
|
||||||
{{:assign account_condition=$account_condition|cat:" account.code LIKE "|cat:$code|cat:" OR "}}
|
{{:assign condition=$condition|cat:" account.code LIKE "|cat:$code|cat:" OR "}}
|
||||||
{{/foreach}}
|
{{/foreach}}
|
||||||
{{:assign account_condition=$account_condition|cat:"0)"}}
|
{{:assign condition=$condition|cat:"0)"}}
|
||||||
|
{{:assign condition=$condition|cat:" AND debit > 0 AND NOT (trans.status & 16)"}}
|
||||||
|
|
||||||
{{if $unhide == null}}
|
{{if $unhide == null}}
|
||||||
{{:assign filter_condition="NOT ("}}
|
{{*:assign condition=$condition|cat:" AND NOT (trans.status & 16)"*}}
|
||||||
|
|
||||||
|
{{:assign filter_condition=" NOT ("}}
|
||||||
{{#foreach from=$module.config.filters item="filter"}}
|
{{#foreach from=$module.config.filters item="filter"}}
|
||||||
{{:assign filter="%"|cat:$filter|cat:"%"|quote_sql}}
|
{{:assign filter="%"|cat:$filter|cat:"%"|quote_sql}}
|
||||||
{{:assign filter_condition=$filter_condition|cat:" trans_label LIKE "|cat:$filter|cat:" OR "}}
|
{{:assign filter_condition=$filter_condition|cat:" trans_label LIKE "|cat:$filter|cat:" OR "}}
|
||||||
{{/foreach}}
|
{{/foreach}}
|
||||||
{{:assign filter_condition=$filter_condition|cat:"0)"}}
|
{{:assign filter_condition=$filter_condition|cat:"0)"}}
|
||||||
{{else}}
|
{{:assign condition=$condition|cat:" AND "|cat:$filter_condition}}
|
||||||
{{:assign filter_condition="1"}}
|
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{:assign filter_condition="("|cat:$doc_condition2|cat:" AND NOT (trans.status & 16) AND "|cat:$filter_condition|cat:")"}}
|
|
||||||
|
|
||||||
{{:assign condition=$account_condition|cat:" AND debit > 0 AND ("|cat:$filter_condition|cat:" OR "|cat:$doc_condition1|cat:")"}}
|
|
||||||
|
|
||||||
{{:assign nb_immo=0}}
|
{{:assign nb_immo=0}}
|
||||||
{{#select
|
{{#select
|
||||||
trans.id as immo_trans_id,
|
trans.id as trans_id,
|
||||||
trans.label as trans_label,
|
trans.label as trans_label,
|
||||||
trans.date as trans_date,
|
trans.date as trans_date,
|
||||||
line.id as immo_line_id,
|
line.id as immo_id,
|
||||||
line.debit AS debit,
|
|
||||||
line.label AS line_label,
|
|
||||||
account.id as account_id,
|
account.id as account_id,
|
||||||
account.code as account_code,
|
account.code as account_code,
|
||||||
account.label as account_label,
|
account.label as account_label,
|
||||||
!columns
|
line.debit AS debit,
|
||||||
trans.id_year as trans_id_year
|
trans.id_year as trans_id_year
|
||||||
FROM acc_transactions AS trans
|
FROM acc_transactions AS trans
|
||||||
INNER JOIN acc_transactions_lines AS line ON line.id_transaction = trans.id
|
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_accounts AS account ON line.id_account = account.id
|
||||||
INNER JOIN acc_years AS years ON trans.id_year = years.id
|
INNER JOIN acc_years AS years ON trans.id_year = years.id
|
||||||
!table_join
|
|
||||||
WHERE !condition
|
WHERE !condition
|
||||||
ORDER BY trans.date DESC;
|
ORDER BY trans.date DESC;
|
||||||
!columns=$columns
|
|
||||||
!table_join=$table_join
|
|
||||||
!table=$module.table
|
|
||||||
!condition=$condition
|
!condition=$condition
|
||||||
}}
|
}}
|
||||||
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$immo_trans_id}}
|
{{: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 compte_url="%s/acc/accounts/journal.php?id=%s&year=%s"|args:$admin_url:$account_id:$trans_id_year}}
|
||||||
|
|
||||||
{{if $status == null}}
|
{{* voir si l'immo est prise en charge *}}
|
||||||
|
{{#load type="immo" where="$$.line = :line_id" :line_id=$immo_id|intval}}
|
||||||
|
{{:assign status=$status}}
|
||||||
|
{{else}}
|
||||||
{{:assign status="unknown"}}
|
{{:assign status="unknown"}}
|
||||||
{{/if}}
|
{{/load}}
|
||||||
|
|
||||||
{{if $unhide == null}}
|
{{if $unhide == null}}
|
||||||
{{if $status != "unknown"}}
|
{{if $status != "unknown"}}
|
||||||
|
|
@ -131,60 +109,62 @@
|
||||||
{{/foreach}}
|
{{/foreach}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{* lister les lignes des écritures d'amortissement liées à l'immobilisation *}}
|
{{* voir s'il existe des écritures d'amortissement associées *}}
|
||||||
{{:assign amort_lines=null}}
|
|
||||||
{{#select
|
{{#select
|
||||||
l_amort.credit as amort_amount,
|
sum(l_amort.credit) as amort_amount,
|
||||||
CASE links.id_related = t_immo.id
|
CASE links.id_related = t_immo.id
|
||||||
WHEN true THEN links.id_transaction
|
WHEN true THEN links.id_transaction
|
||||||
WHEN false THEN links.id_related
|
WHEN false THEN links.id_related
|
||||||
END as amort_trans_id,
|
END as amort_trans_id
|
||||||
l_amort.id AS amort_line_id
|
|
||||||
FROM acc_transactions_lines as l_immo
|
FROM acc_transactions_lines as l_immo
|
||||||
INNER JOIN acc_transactions as t_immo on t_immo.id = l_immo.id_transaction
|
INNER JOIN acc_transactions as t_immo on t_immo.id = l_immo.id_transaction
|
||||||
INNER JOIN acc_transactions_links as links
|
INNER JOIN acc_transactions_links as links
|
||||||
ON (t_immo.id = links.id_transaction OR t_immo.id = links.id_related)
|
ON (
|
||||||
|
t_immo.id = links.id_transaction
|
||||||
|
OR
|
||||||
|
t_immo.id = links.id_related
|
||||||
|
)
|
||||||
INNER JOIN acc_transactions_lines as l_amort on amort_trans_id = l_amort.id_transaction
|
INNER JOIN acc_transactions_lines as l_amort on amort_trans_id = l_amort.id_transaction
|
||||||
INNER JOIN acc_accounts AS account ON l_amort.id_account = account.id
|
INNER JOIN acc_accounts AS account ON l_amort.id_account = account.id
|
||||||
WHERE l_immo.id = :line_id AND l_amort.credit <> 0 AND account.code LIKE '28%';
|
WHERE
|
||||||
:line_id = $immo_line_id|intval
|
l_immo.id = :line_id
|
||||||
assign="amort_lines."
|
AND
|
||||||
|
l_amort.credit <> 0
|
||||||
|
AND
|
||||||
|
account.code LIKE '28%';
|
||||||
|
:line_id = $immo_id|intval
|
||||||
}}
|
}}
|
||||||
{{/select}}
|
{{if $amort_amount != null}}
|
||||||
{{:assign amort_amount=0}}
|
{{:assign ignore=true}}
|
||||||
{{#foreach from=$amort_lines item="line"}}
|
{{else}}
|
||||||
{{* voir s'il existe un doc associé à l'écriture d'amortissement *}}
|
{{:assign ignore=false}}
|
||||||
{{#load type="link"
|
{{/if}}
|
||||||
where="$$.immo_line_id = :immo_line_id AND $$.amort_trans_id = :amort_trans_id AND $$.amort_line_id = :amort_line_id"
|
{{/select}}
|
||||||
:immo_line_id = $immo_line_id
|
|
||||||
:amort_trans_id = $line.amort_trans_id
|
{{if $ignore}}
|
||||||
:amort_line_id = $line.amort_line_id
|
{{:continue}}
|
||||||
}}
|
{{/if}}
|
||||||
{{:assign amort_amount="%d+%d"|math:$amort_amount:$line.amount}}
|
{{:assign nb_immo="%d+1"|math:$nb_immo}}
|
||||||
{{else}}
|
|
||||||
{{* TODO À VÉRIFIER (cas multi-lignes) *}}
|
|
||||||
{{:assign amort_amount="%d+%d"|math:$amort_amount:$line.amount}}
|
|
||||||
{{/load}}
|
|
||||||
{{/foreach}}
|
|
||||||
{{if $amort_amount != 0}}
|
|
||||||
{{:continue}}
|
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
{{:assign nb_immo="%d+1"|math:$nb_immo}}
|
|
||||||
<tr {{if $status == "ignored"}}class="ignored"{{/if}}>
|
<tr {{if $status == "ignored"}}class="ignored"{{/if}}>
|
||||||
<td class="num"><a href={{$trans_url}}>#{{$immo_trans_id}}</a></td>
|
<td class="num"><a href={{$trans_url}}>#{{$trans_id}}</a></td>
|
||||||
<td>{{$trans_date|date_short}}</td>
|
<td>{{$trans_date|date_short}}</td>
|
||||||
<td>{{$trans_label}}{{if $line_label != null && $line_label != $trans_label}} — {{$line_label}}{{/if}}</td>
|
<td>{{$trans_label}}</td>
|
||||||
<td class="money">{{"%f"|math:$debit|money_html:false|raw}}</td>
|
<td class="money">{{"%f"|math:$debit|money_html:false|raw}}</td>
|
||||||
<td><a href={{$compte_url}}>{{$account_code}}</a></td>
|
<td><a href={{$compte_url}}>{{$account_code}}</a></td>
|
||||||
<td>{{$account_label}}</td>
|
<td>{{$account_label}}</td>
|
||||||
<td class="actions">
|
<td class="actions">
|
||||||
{{:linkbutton
|
{{:linkbutton
|
||||||
label="Paramètres"
|
label="Paramètres"
|
||||||
href="add_infos.html?immo_line_id=%s&type_immo=other"|args:$immo_line_id
|
href="add_infos.html?immo_id=%s&type_immo=other"|args:$immo_id
|
||||||
shape="settings"
|
shape="settings"
|
||||||
target="_dialog"
|
target="_dialog"
|
||||||
}}
|
}}
|
||||||
|
{{:linkbutton
|
||||||
|
label="Amortissements"
|
||||||
|
href="amortization.html?immo_id=%s&type_immo=other"|args:$immo_id
|
||||||
|
shape="table"
|
||||||
|
}}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{/select}}
|
{{/select}}
|
||||||
|
|
|
||||||
|
|
@ -3,15 +3,15 @@
|
||||||
<nav class="tabs">
|
<nav class="tabs">
|
||||||
{{if $current == "index" && $subsubcurrent == null}}
|
{{if $current == "index" && $subsubcurrent == null}}
|
||||||
<aside>
|
<aside>
|
||||||
{{:linkbutton label="Ajouter une immobilisation" shape="plus" href="add_asset.html"}}
|
{{:linkbutton label="Ajouter une immobilisation" shape="plus" href="add_asset.html" target="_dialog"}}
|
||||||
</aside>
|
</aside>
|
||||||
{{elseif $subsubcurrent == "amortization" && $type_immo == null || $type_immo == "managed" || $type_immo == "other"}}
|
{{elseif $subsubcurrent == "amortization" && $type_immo == null || $type_immo == "managed" || $type_immo == "other"}}
|
||||||
<aside>
|
<aside>
|
||||||
{{if $autres_amort}}
|
{{if $autres_amort != null}}
|
||||||
{{:linkbutton label="Rattacher une écriture" href="other_amortizations.html?immo_line_id=%s"|args:$_GET.immo_line_id shape="link" target="_dialog"}}
|
{{:linkbutton label="Rattacher une écriture" href="other_amortizations.html?immo_id=%s"|args:$_GET.immo_id shape="link" target="_dialog"}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{:linkbutton label="Enregistrer un amortissement" shape="plus"
|
{{:linkbutton label="Enregistrer un amortissement" shape="plus"
|
||||||
href="save_amort.html?immo_line_id=%s"|args:$_GET.immo_line_id}}
|
href="save_amort.html?immo_id=%s"|args:$_GET.immo_id target="_dialog"}}
|
||||||
</aside>
|
</aside>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,20 +9,15 @@
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
{{:include file="_get_config.html" keep="module.config"}}
|
{{:include file="_get_config.html" keep="module.config"}}
|
||||||
{{:assign saved_hides=$module.config.hides}}
|
|
||||||
{{:assign var="user_hides" from="saved_hides.%s"|args:$logged_user.id}}
|
|
||||||
|
|
||||||
{{if $_POST|count == 0}}
|
{{if $_POST|count == 0}}
|
||||||
{{:assign unhide=$user_hides.unhide_unfinished}}
|
{{:assign unhide=$module.config.unhide_unfinished}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{if $_POST.unhide == null}}
|
{{if $_POST.unhide == null}}
|
||||||
{{:assign unhide=0}}
|
{{:assign unhide=0}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{:assign unhide=1}}
|
{{:assign unhide=1}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{:assign var="user_hides.unhide_unfinished" value=$unhide"}}
|
{{:save key="config" unhide_unfinished=$unhide}}
|
||||||
{{:assign var="saved_hides.%s"|args:$logged_user.id value=$user_hides}}
|
|
||||||
{{:save key="config" hides=$saved_hides}}
|
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{if $unhide}}
|
{{if $unhide}}
|
||||||
{{:assign checked="checked"}}
|
{{:assign checked="checked"}}
|
||||||
|
|
@ -32,7 +27,7 @@
|
||||||
<fieldset class="shortFormLeft">
|
<fieldset class="shortFormLeft">
|
||||||
<legend>Transférer une ou plusieurs lignes vers une immobilisation amortissable</legend>
|
<legend>Transférer une ou plusieurs lignes vers une immobilisation amortissable</legend>
|
||||||
<p class="help">
|
<p class="help">
|
||||||
Cocher les lignes concernées
|
Cocher les lignes concernées ; les montants seront additionnés par numéro de compte
|
||||||
</p>
|
</p>
|
||||||
<div class="shortFormRight informations" id="total_amount">
|
<div class="shortFormRight informations" id="total_amount">
|
||||||
<legend>Montants sélectionnés</legend>
|
<legend>Montants sélectionnés</legend>
|
||||||
|
|
@ -55,7 +50,7 @@
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
{{:input type="checkbox" value=1 name="unhide" checked="%s"|args:$checked label="Afficher toutes les écritures" }}
|
{{:input type="checkbox" value=1 name="unhide" checked="%s"|args:$checked label="Afficher les écritures marquées ignorées" }}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
@ -102,7 +97,7 @@
|
||||||
trans.id as trans_id,
|
trans.id as trans_id,
|
||||||
trans.label as trans_label,
|
trans.label as trans_label,
|
||||||
trans.date as trans_date,
|
trans.date as trans_date,
|
||||||
line.id as immo_line_id,
|
line.id as immo_id,
|
||||||
account.id as account_id,
|
account.id as account_id,
|
||||||
account.code as account_code,
|
account.code as account_code,
|
||||||
account.label as account_label,
|
account.label as account_label,
|
||||||
|
|
@ -119,7 +114,7 @@
|
||||||
}}
|
}}
|
||||||
{{* voir si l'écriture a été marquée ignorée *}}
|
{{* voir si l'écriture a été marquée ignorée *}}
|
||||||
{{:assign ignore=false}}
|
{{:assign ignore=false}}
|
||||||
{{#load type="immo" assign="info_immo" where="$$.line = :line_id AND $$.status = 'ignored'" :line_id=$immo_line_id|intval}}
|
{{#load type="immo" assign="info_immo" where="$$.line = :line_id AND $$.status = 'ignored'" :line_id=$immo_id|intval}}
|
||||||
{{:assign ignore=true}}
|
{{:assign ignore=true}}
|
||||||
{{/load}}
|
{{/load}}
|
||||||
{{if $ignore && $unhide == null}}
|
{{if $ignore && $unhide == null}}
|
||||||
|
|
@ -163,7 +158,7 @@
|
||||||
<td class="actions">
|
<td class="actions">
|
||||||
{{:linkbutton
|
{{:linkbutton
|
||||||
label="Modifier"
|
label="Modifier"
|
||||||
href="ignore.html?immo_line_id=%s"|args:$immo_line_id
|
href="ignore.html?immo_id=%s"|args:$immo_id
|
||||||
shape="edit"
|
shape="edit"
|
||||||
target="_dialog"
|
target="_dialog"
|
||||||
}}
|
}}
|
||||||
|
|
|
||||||
|
|
@ -75,11 +75,11 @@
|
||||||
|
|
||||||
{{if $account_ok == null}}
|
{{if $account_ok == null}}
|
||||||
{{:assign compte=$debit_account|implode:""}}
|
{{:assign compte=$debit_account|implode:""}}
|
||||||
{{:redirect url="add_account.html?account=%s&chart=%s&immo_line_id=%s"|args:$compte:$selected_chart:$_GET.immo_line_id}}
|
{{:redirect url="add_account.html?account=%s&chart=%s&immo_id=%s"|args:$compte:$selected_chart:$_GET.immo_id}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{:assign debit_account=$debit_account|keys|value:0}}
|
{{:assign debit_account=$debit_account|keys|key:0}}
|
||||||
{{:assign credit_account=$credit_account|keys|value:0}}
|
{{:assign credit_account=$credit_account|keys|key:0}}
|
||||||
|
|
||||||
{{* déterminer si le compte d'immo est un compte d'immo en cours *}}
|
{{* déterminer si le compte d'immo est un compte d'immo en cours *}}
|
||||||
{{#foreach from=$module.config.unfinished item="elem"}}
|
{{#foreach from=$module.config.unfinished item="elem"}}
|
||||||
|
|
@ -127,8 +127,8 @@
|
||||||
|
|
||||||
{{if $status != "unfinished"}}
|
{{if $status != "unfinished"}}
|
||||||
{{* vérifier s'il y a déjà un document avec le même numéro de ligne *}}
|
{{* vérifier s'il y a déjà un document avec le même numéro de ligne *}}
|
||||||
{{:assign var="immo_line_id" value=$result.lines.1.id}}
|
{{:assign var="immo_id" value=$result.lines.1.id}}
|
||||||
{{#load where="$$.line = :line_id" :line_id=$immo_line_id}}
|
{{#load where="$$.line = :line_id" :line_id=$immo_id}}
|
||||||
{{:assign key=$key}}
|
{{:assign key=$key}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{:assign key=""|uuid}}
|
{{:assign key=""|uuid}}
|
||||||
|
|
@ -139,7 +139,7 @@
|
||||||
key=$key
|
key=$key
|
||||||
validate_schema="schema.json"
|
validate_schema="schema.json"
|
||||||
type="immo"
|
type="immo"
|
||||||
line=$immo_line_id
|
line=$immo_id
|
||||||
duration=$duration
|
duration=$duration
|
||||||
date=$date_debut
|
date=$date_debut
|
||||||
status=$status
|
status=$status
|
||||||
|
|
@ -160,7 +160,7 @@
|
||||||
{{:admin_header title="Ajout immobilisation" current="module_amortization"}}
|
{{:admin_header title="Ajout immobilisation" current="module_amortization"}}
|
||||||
{{* barre de navigation *}}
|
{{* barre de navigation *}}
|
||||||
{{if ! $dialog}}
|
{{if ! $dialog}}
|
||||||
{{:include file="_nav.html" current="index" subcurrent="managed"}}
|
{{:include file="_nav.html" current="index"}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{:form_errors}}
|
{{:form_errors}}
|
||||||
|
|
|
||||||
|
|
@ -1,52 +1,27 @@
|
||||||
{{* -*- brindille -*- *}}
|
{{* -*- brindille -*- *}}
|
||||||
|
|
||||||
{{*
|
{{*
|
||||||
@param immo_line_id
|
@param immo_id
|
||||||
@param type_immo : managed, amortized, archived, other
|
@param type_immo : managed, amortized, archived, other
|
||||||
*}}
|
*}}
|
||||||
|
|
||||||
{{* données de l'immobilisaion *}}
|
{{* données de l'immobilisaion *}}
|
||||||
{{#load type="immo" assign="info_immo" where="$$.line = :line_id" :line_id=$_GET.immo_line_id|intval}}
|
{{#load type="immo" assign="info_immo" where="$$.line = :line_id" :line_id=$_GET.immo_id|intval}}
|
||||||
{{/load}}
|
{{/load}}
|
||||||
{{#select
|
{{#select
|
||||||
trans.id as immo_trans_id,
|
|
||||||
trans.label,
|
|
||||||
trans.date as date_achat,
|
trans.date as date_achat,
|
||||||
line.debit as montant,
|
line.debit as montant
|
||||||
line.label as line_label,
|
|
||||||
acc.code
|
|
||||||
FROM acc_transactions_lines AS line
|
FROM acc_transactions_lines AS line
|
||||||
INNER join acc_transactions AS trans ON line.id_transaction = trans.id
|
INNER join acc_transactions AS trans ON line.id_transaction = trans.id
|
||||||
INNER JOIN acc_accounts AS acc ON line.id_account = acc.id
|
|
||||||
WHERE line.id = :line_id;
|
WHERE line.id = :line_id;
|
||||||
:line_id = $_GET.immo_line_id
|
:line_id = $_GET.immo_id
|
||||||
assign=ligne_immo
|
assign=ligne_immo
|
||||||
}}
|
}}
|
||||||
{{else}}
|
|
||||||
{{:error message="Aucune immobilisation trouvée"}}
|
|
||||||
{{/select}}
|
{{/select}}
|
||||||
|
|
||||||
{{* chercher les liaisons de l'écriture d'immobilisation *}}
|
|
||||||
{{#select
|
|
||||||
CASE links.id_related = :immo_trans_id
|
|
||||||
WHEN true THEN links.id_transaction
|
|
||||||
WHEN false THEN links.id_related
|
|
||||||
END as linked_id,
|
|
||||||
acc.code
|
|
||||||
FROM acc_transactions_links as links
|
|
||||||
INNER JOIN acc_transactions_lines AS line on line.id_transaction = linked_id
|
|
||||||
INNER JOIN acc_accounts AS acc ON line.id_account = acc.id
|
|
||||||
WHERE (links.id_transaction = :immo_trans_id or links.id_related = :immo_trans_id)
|
|
||||||
AND line.credit > 0
|
|
||||||
;
|
|
||||||
:immo_trans_id = $ligne_immo.immo_trans_id
|
|
||||||
}}
|
|
||||||
{{:assign var="linked_transactions.%d."|args:$code value=$linked_id}}
|
|
||||||
{{/select}}
|
|
||||||
{{:assign var="immo_transactions" from="linked_transactions.%d"|args:$ligne_immo.code}}
|
|
||||||
|
|
||||||
{{* Traiter l'envoi du formulaire *}}
|
{{* Traiter l'envoi du formulaire *}}
|
||||||
{{#form on="save"}}
|
{{#form on="save"}}
|
||||||
|
|
||||||
{{if $_POST.classify == null}}
|
{{if $_POST.classify == null}}
|
||||||
{{:error message="Vous devez choisir une action"}}
|
{{:error message="Vous devez choisir une action"}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
@ -54,6 +29,7 @@
|
||||||
{{if $_POST.classify == "ignored"}}
|
{{if $_POST.classify == "ignored"}}
|
||||||
{{* ne pas amortir *}}
|
{{* ne pas amortir *}}
|
||||||
{{:assign duration=0}}
|
{{:assign duration=0}}
|
||||||
|
{{:assign montant=0}}
|
||||||
{{:assign date_debut=$ligne_immo.date_achat|parse_date}}
|
{{:assign date_debut=$ligne_immo.date_achat|parse_date}}
|
||||||
{{:assign status="ignored"}}
|
{{:assign status="ignored"}}
|
||||||
{{else}}
|
{{else}}
|
||||||
|
|
@ -86,6 +62,7 @@
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{:assign status="managed"}}
|
{{:assign status="managed"}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
{{:assign montant="%d*100"|math:$_POST.montant}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{* enregistrer les infos de l'immobilisation *}}
|
{{* enregistrer les infos de l'immobilisation *}}
|
||||||
|
|
@ -99,38 +76,13 @@
|
||||||
key=$key
|
key=$key
|
||||||
validate_schema="schema.json"
|
validate_schema="schema.json"
|
||||||
type="immo"
|
type="immo"
|
||||||
line=$_GET.immo_line_id|intval
|
line=$_GET.immo_id|intval
|
||||||
duration=$duration
|
duration=$duration
|
||||||
|
amount=$montant|intval
|
||||||
date=$date_debut
|
date=$date_debut
|
||||||
status=$status
|
status=$status
|
||||||
}}
|
}}
|
||||||
|
|
||||||
{{* copier les autres liaisons *}}
|
|
||||||
{{#foreach from=$linked_transactions key="code" item="liaisons"}}
|
|
||||||
{{if $code != $ligne_immo.code}}
|
|
||||||
{{:debug code=$code liaisons=$liaisons}}
|
|
||||||
{{#foreach from=$liaisons item="elem"}}
|
|
||||||
{{:assign var="new_transactions." value=$elem}}
|
|
||||||
{{/foreach}}
|
|
||||||
{{/if}}
|
|
||||||
{{/foreach}}
|
|
||||||
|
|
||||||
{{* nouvelles liaisons *}}
|
|
||||||
{{#foreach from=$_POST.transactions key="key" item="elem"}}
|
|
||||||
{{:assign var="new_transactions." value=$elem|intval}}
|
|
||||||
{{/foreach}}
|
|
||||||
|
|
||||||
{{* Enregistrer les liaisons *}}
|
|
||||||
{{if $new_transactions != null}}
|
|
||||||
{{:api
|
|
||||||
method="POST"
|
|
||||||
path="accounting/transaction/%s/transactions"|args:$ligne_immo.immo_trans_id
|
|
||||||
assign="result"
|
|
||||||
assign_code="result_code"
|
|
||||||
transactions=$new_transactions
|
|
||||||
}}
|
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
{{if $_POST.classify == "managed" || $_POST.classify == "amortized"}}
|
{{if $_POST.classify == "managed" || $_POST.classify == "amortized"}}
|
||||||
{{:assign type_immo=$_POST.classify}}
|
{{:assign type_immo=$_POST.classify}}
|
||||||
{{elseif $_POST.classify == "ignored"}}
|
{{elseif $_POST.classify == "ignored"}}
|
||||||
|
|
@ -139,14 +91,15 @@
|
||||||
{{:assign type_immo=$_GET.type_immo}}
|
{{:assign type_immo=$_GET.type_immo}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{:redirect force="index.html?ok=1&msg=infos&type_immo=%s"|args:$type_immo}}
|
{{:redirect force="index.html?ok=1&msg=infos&type_immo=%s"|args:$type_immo}}
|
||||||
|
{{else}}
|
||||||
|
{{:form_errors}}
|
||||||
{{/form}}
|
{{/form}}
|
||||||
{{:form_errors}}
|
|
||||||
|
|
||||||
{{:admin_header title="Classer l'immobilisation" custom_css="./style.css" current="module_amortization"}}
|
{{:admin_header title="Classer l'immobilisation" custom_css=$custom_css current="module_amortization"}}
|
||||||
|
|
||||||
{{* barre de navigation *}}
|
{{* barre de navigation *}}
|
||||||
{{if ! $dialog}}
|
{{if ! $dialog}}
|
||||||
{{:include file="_nav.html" current="index" subcurrent="%s"|args:$_GET.type_immo subsubcurrent="parameter"}}
|
{{:include file="_nav.html" current="index"}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{:assign choix_defaut=$_GET.type_immo}}
|
{{:assign choix_defaut=$_GET.type_immo}}
|
||||||
|
|
@ -154,32 +107,17 @@
|
||||||
{{if $info_immo != null}}
|
{{if $info_immo != null}}
|
||||||
{{:assign date_defaut=$info_immo.date}}
|
{{:assign date_defaut=$info_immo.date}}
|
||||||
{{:assign duree_defaut=$info_immo.duration}}
|
{{:assign duree_defaut=$info_immo.duration}}
|
||||||
{{:assign choix_defaut=$info_immo.status}}
|
{{:assign montant_defaut=$info_immo.amount}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{:assign duree_defaut=null}}
|
{{:assign duree_defaut=null}}
|
||||||
|
{{:assign montant_defaut=null}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{*
|
{{*
|
||||||
- classer l'immobilisation
|
- classer l'immobilisation
|
||||||
- renseigner ou modifier la date de mise en service, les écritures associées ou la durée d'amortissement
|
- renseigner ou modifier la date de mise en service, le montant de
|
||||||
|
l'immobilisation et la durée d'amortissement
|
||||||
*}}
|
*}}
|
||||||
|
|
||||||
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$ligne_immo.immo_trans_id}}
|
|
||||||
<h3 class="ruler">
|
|
||||||
Paramètres de l'immobilisation
|
|
||||||
<span class="num"><a href="{{$trans_url}}">#{{$ligne_immo.immo_trans_id}}</a></span>
|
|
||||||
</h3>
|
|
||||||
<div class="informations">
|
|
||||||
<dl class="describe">
|
|
||||||
<dt>Immobilisation</dt>
|
|
||||||
<dd><span class="num"><a href={{$trans_url}}>#{{$ligne_immo.immo_trans_id}}</a></span> {{$ligne_immo.label}}{{if $ligne_immo.line_label != null && $ligne_immo.line_label != $ligne_immo.label}} — {{$ligne_immo.line_label}}{{/if}}</dd>
|
|
||||||
<dt>Montant</dt>
|
|
||||||
<dd class="money strong">{{"%f"|math:$ligne_immo.montant|money_currency_html:false|raw}}</dd>
|
|
||||||
<dt>Date de l'écriture d'immobilisation</dt>
|
|
||||||
<dd>{{$ligne_immo.date_achat|date_short}}</dd>
|
|
||||||
</dl>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<form method="post" action="">
|
<form method="post" action="">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>Classement</legend>
|
<legend>Classement</legend>
|
||||||
|
|
@ -196,7 +134,7 @@
|
||||||
<legend>Informations</legend>
|
<legend>Informations</legend>
|
||||||
<dl>
|
<dl>
|
||||||
{{:input type="number" name="duree" label="Durée d'amortissement" default=$duree_defaut required=true min=1}}
|
{{:input type="number" name="duree" label="Durée d'amortissement" default=$duree_defaut required=true min=1}}
|
||||||
{{:input type="list" name="transactions" default=$immo_transactions label="Écritures liées au crédit du compte d'immobilisation" target="!acc/transactions/selector.php" multiple=true help="par exemple écriture d'avoir ou autre réduction du montant de l'acquisition"}}
|
{{:input type="money" name="montant" label="Montant" default=$montant_defaut help="à renseigner uniquement si différent du montant de l'acquisition"}}
|
||||||
{{:input type="date" name="date_mes" label="Date de mise en service" default=$date_defaut help="à renseigner uniquement si différente de la date d'acquisition"}}
|
{{:input type="date" name="date_mes" label="Date de mise en service" default=$date_defaut help="à renseigner uniquement si différente de la date d'acquisition"}}
|
||||||
</dl>
|
</dl>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
|
||||||
|
|
@ -2,77 +2,50 @@
|
||||||
|
|
||||||
{{*
|
{{*
|
||||||
Lister les écritures d'amortissement associées à une immobilisation
|
Lister les écritures d'amortissement associées à une immobilisation
|
||||||
@param immo_line_id : id de la ligne d'immo
|
@param immo_id : id de la ligne d'immo
|
||||||
@param type_immo : managed, amortized, archived, others
|
@param type_immo : managed, amortized, archived, others
|
||||||
*}}
|
*}}
|
||||||
|
|
||||||
{{* récupérer les infos de l'immobilisation *}}
|
{{* récupérer les infos de l'immobilisation *}}
|
||||||
{{#select
|
{{#select
|
||||||
line.id as immo_line_id,
|
line.id as immo_id,
|
||||||
line.debit as montant,
|
line.debit as montant,
|
||||||
line.label as line_label,
|
trans.id as trans_id,
|
||||||
trans.id as immo_trans_id,
|
|
||||||
trans.label as label,
|
trans.label as label,
|
||||||
trans.date,
|
trans.date
|
||||||
account.code as account_code
|
|
||||||
FROM acc_transactions_lines AS line
|
FROM acc_transactions_lines AS line
|
||||||
INNER JOIN acc_transactions AS trans ON line.id_transaction = trans.id
|
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 = :line_id;
|
WHERE line.id = :line_id;
|
||||||
:line_id = $_GET.immo_line_id|intval
|
:line_id = $_GET.immo_id|intval
|
||||||
assign=ligne_immo
|
assign=ligne_immo
|
||||||
}}
|
}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{:error message="Immobilisation %s non trouvée"|args:$_GET.immo_line_id}}
|
{{:error message="Immobilisation %s non trouvée"|args:$_GET.immo_id}}
|
||||||
{{/select}}
|
{{/select}}
|
||||||
{{:assign date_debut=$ligne_immo.date}}
|
{{:assign date_debut=$ligne_immo.date}}
|
||||||
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$ligne_immo.immo_trans_id}}
|
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$ligne_immo.trans_id}}
|
||||||
|
|
||||||
{{#load type="immo" where="$$.line = :line_id" :line_id=$_GET.immo_line_id|intval}}
|
{{#load type="immo" where="$$.line = :line_id" :line_id=$_GET.immo_id|intval}}
|
||||||
{{:assign duree=$duration}}
|
{{:assign duree=$duration}}
|
||||||
{{:assign date_debut=$date}}
|
{{:assign date_debut=$date}}
|
||||||
{{:assign status=$status}}
|
{{:assign status=$status}}
|
||||||
|
{{if $amount != null}}
|
||||||
|
{{:assign var="ligne_immo.montant" value=$amount}}
|
||||||
|
{{/if}}
|
||||||
{{/load}}
|
{{/load}}
|
||||||
|
|
||||||
{{if $status == 'ignored'}}
|
|
||||||
{{:error message="Cette immobilisation ne doit pas être amortie"}}
|
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
{{* chercher des écritures liées à l'immo courante au crédit du même compte
|
|
||||||
et déduire leur montant de celui de l'immo
|
|
||||||
*}}
|
|
||||||
{{:assign total_credits=0}}
|
|
||||||
{{#select
|
|
||||||
CASE links.id_related = :immo_trans_id
|
|
||||||
WHEN true THEN links.id_transaction
|
|
||||||
WHEN false THEN links.id_related
|
|
||||||
END as other_id,
|
|
||||||
line.credit
|
|
||||||
FROM acc_transactions AS trans
|
|
||||||
INNER JOIN acc_transactions_links as links
|
|
||||||
ON (trans.id = links.id_transaction OR trans.id = links.id_related)
|
|
||||||
INNER JOIN acc_transactions_lines AS line on line.id_transaction = other_id
|
|
||||||
INNER JOIN acc_accounts AS acc ON line.id_account = acc.id
|
|
||||||
WHERE trans.id = :immo_trans_id AND line.credit > 0 AND acc.code = :account;
|
|
||||||
:immo_trans_id=$ligne_immo.immo_trans_id
|
|
||||||
:account=$ligne_immo.account_code
|
|
||||||
}}
|
|
||||||
{{:assign total_credits="%d+%d"|math:$total_credits:$credit}}
|
|
||||||
{{/select}}
|
|
||||||
{{:assign var="ligne_immo.montant" value="%d-%d"|math:$ligne_immo.montant:$total_credits}}
|
|
||||||
{{:assign solde=$ligne_immo.montant}}
|
{{:assign solde=$ligne_immo.montant}}
|
||||||
|
|
||||||
{{* lister les lignes des écritures d'amortissement liées à l'immobilisation *}}
|
{{* chercher des écritures d'amortissement liées à l'immobilisation *}}
|
||||||
{{#select
|
{{#select
|
||||||
l_amort.credit as amort_amount,
|
l_amort.credit as amort_amount,
|
||||||
l_amort.label as amort_line_label,
|
l_amort.label as amort_label,
|
||||||
l_amort.id as amort_line_id,
|
l_amort.id as amort_line,
|
||||||
CASE WHEN links.id_related = t_immo.id
|
CASE WHEN links.id_related = t_immo.id
|
||||||
THEN links.id_transaction
|
THEN links.id_transaction
|
||||||
ELSE links.id_related
|
ELSE links.id_related
|
||||||
END as amort_trans_id,
|
END as amort_trans_id,
|
||||||
trans.date as amort_date,
|
trans.date as amort_date,
|
||||||
trans.label as amort_trans_label,
|
trans.label as trans_label,
|
||||||
trans.id_year as amort_year,
|
trans.id_year as amort_year,
|
||||||
account.id as account_id,
|
account.id as account_id,
|
||||||
account.code as account_code,
|
account.code as account_code,
|
||||||
|
|
@ -80,25 +53,19 @@
|
||||||
FROM acc_transactions_lines as l_immo
|
FROM acc_transactions_lines as l_immo
|
||||||
INNER JOIN acc_transactions as t_immo on t_immo.id = l_immo.id_transaction
|
INNER JOIN acc_transactions as t_immo on t_immo.id = l_immo.id_transaction
|
||||||
INNER JOIN acc_transactions_links as links
|
INNER JOIN acc_transactions_links as links
|
||||||
ON (t_immo.id = links.id_transaction OR t_immo.id = links.id_related)
|
ON (t_immo.id = links.id_transaction
|
||||||
|
OR
|
||||||
|
t_immo.id = links.id_related)
|
||||||
INNER JOIN acc_transactions_lines as l_amort on amort_trans_id = l_amort.id_transaction
|
INNER JOIN acc_transactions_lines as l_amort on amort_trans_id = l_amort.id_transaction
|
||||||
INNER join acc_transactions as trans on l_amort.id_transaction = trans.id
|
INNER join acc_transactions as trans on l_amort.id_transaction = trans.id
|
||||||
INNER join acc_accounts as account on l_amort.id_account = account.id
|
INNER join acc_accounts as account on l_amort.id_account = account.id
|
||||||
WHERE l_immo.id = :line_id AND account.code LIKE '28%'
|
WHERE
|
||||||
|
l_immo.id = :line_id
|
||||||
|
AND account.code LIKE '28%'
|
||||||
ORDER BY trans.date;
|
ORDER BY trans.date;
|
||||||
:line_id = $_GET.immo_line_id|intval
|
:line_id = $_GET.immo_id|intval
|
||||||
assign="amort_line"
|
assign=linked_lines.
|
||||||
}}
|
}}
|
||||||
{{* lister les lignes d'amortissement liées à la ligne d'immobilisation *}}
|
|
||||||
{{#load type="link"
|
|
||||||
where="$$.immo_line_id = :immo_line_id AND $$.amort_trans_id = :amort_trans_id AND $$.amort_line_id = :amort_line_id"
|
|
||||||
assign="line"
|
|
||||||
:immo_line_id=$_GET.immo_line_id|intval
|
|
||||||
:amort_trans_id=$amort_line.amort_trans_id
|
|
||||||
:amort_line_id = $amort_line.amort_line_id
|
|
||||||
}}
|
|
||||||
{{:assign var="linked_amort." value=$amort_line}}
|
|
||||||
{{/load}}
|
|
||||||
{{if $date_debut == null}}
|
{{if $date_debut == null}}
|
||||||
{{:assign date_debut=$amort_date}}
|
{{:assign date_debut=$amort_date}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
@ -109,7 +76,7 @@
|
||||||
{{:assign valeur_residuelle=0}}
|
{{:assign valeur_residuelle=0}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{:assign valeur_residuelle=$ligne_immo.montant}}
|
{{:assign valeur_residuelle=$ligne_immo.montant}}
|
||||||
{{#foreach from=$linked_amort}}
|
{{#foreach from=$linked_lines}}
|
||||||
{{:assign valeur_residuelle="%d-%d"|math:$valeur_residuelle:$amort_amount}}
|
{{:assign valeur_residuelle="%d-%d"|math:$valeur_residuelle:$amort_amount}}
|
||||||
{{/foreach}}
|
{{/foreach}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
@ -123,9 +90,17 @@
|
||||||
{{/foreach}}
|
{{/foreach}}
|
||||||
{{:assign filter_condition=$filter_condition|cat:"0)"}}
|
{{:assign filter_condition=$filter_condition|cat:"0)"}}
|
||||||
|
|
||||||
{{:assign autres_amortissements=false}}
|
|
||||||
{{#select
|
{{#select
|
||||||
line.id_transaction AS amort_trans_id
|
line.id as l_id,
|
||||||
|
line.id_transaction as t_id,
|
||||||
|
line.credit as amort_amount,
|
||||||
|
line.label as l_label,
|
||||||
|
trans.date as t_date,
|
||||||
|
trans.label as t_label,
|
||||||
|
trans.id_year as amort_year,
|
||||||
|
account.id as account_id,
|
||||||
|
account.code as account_code,
|
||||||
|
account.label as account_label
|
||||||
FROM acc_transactions_lines AS line
|
FROM acc_transactions_lines AS line
|
||||||
INNER JOIN acc_accounts AS account ON account.id = line.id_account
|
INNER JOIN acc_accounts AS account ON account.id = line.id_account
|
||||||
INNER JOIN acc_transactions AS trans ON trans.id = line.id_transaction
|
INNER JOIN acc_transactions AS trans ON trans.id = line.id_transaction
|
||||||
|
|
@ -133,46 +108,17 @@
|
||||||
WHERE account.code LIKE "28%" AND credit > 0 AND (NOT trans.status & 16) AND !filter_condition
|
WHERE account.code LIKE "28%" AND credit > 0 AND (NOT trans.status & 16) AND !filter_condition
|
||||||
ORDER BY trans.date, trans.label;
|
ORDER BY trans.date, trans.label;
|
||||||
!filter_condition=$filter_condition
|
!filter_condition=$filter_condition
|
||||||
assign="amort"
|
assign=autre_amort
|
||||||
}}
|
}}
|
||||||
{{* voir s'il existe des écritures liées avec un numéro de compte d'immobilisation *}}
|
|
||||||
{{#select
|
{{#select
|
||||||
links.id_transaction,
|
id_transaction,
|
||||||
links.id_related,
|
id_related
|
||||||
trans.id AS trans_id
|
FROM acc_transactions_links
|
||||||
FROM acc_transactions_links AS links
|
WHERE id_transaction = :id_amort OR id_related = :id_amort;
|
||||||
INNER JOIN acc_transactions AS trans ON (
|
:id_amort=$t_id
|
||||||
CASE
|
|
||||||
WHEN links.id_transaction = :id_amort THEN links.id_related
|
|
||||||
WHEN links.id_related = :id_amort THEN links.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
|
|
||||||
links.id_transaction = :id_amort OR links.id_related = :id_amort
|
|
||||||
AND acc.code LIKE '21%'
|
|
||||||
LIMIT 1
|
|
||||||
;
|
|
||||||
:id_amort=$amort.amort_trans_id
|
|
||||||
}}
|
}}
|
||||||
{{* voir s'il existe un doc associé à une ligne de l'amortissement *}}
|
|
||||||
{{:assign keep=true}}
|
|
||||||
{{#load type="link"
|
|
||||||
where="$$.amort_trans_id = :amort_trans_id"
|
|
||||||
:amort_trans_id = $amort.amort_trans_id
|
|
||||||
}}
|
|
||||||
{{if $amort_line_id == $amort.amort_line_id}}
|
|
||||||
{{:assign keep=false}}
|
|
||||||
{{:break}}
|
|
||||||
{{/if}}
|
|
||||||
{{else}}
|
|
||||||
{{:assign keep=false}}
|
|
||||||
{{/load}}
|
|
||||||
{{if $keep}}
|
|
||||||
{{:assign autres_amortissements=true}}
|
|
||||||
{{/if}}
|
|
||||||
{{else}}
|
{{else}}
|
||||||
{{:assign autres_amortissements=true}}
|
{{:assign var="autres_amortissements." value=$autre_amort}}
|
||||||
{{/select}}
|
{{/select}}
|
||||||
{{/select}}
|
{{/select}}
|
||||||
|
|
||||||
|
|
@ -222,7 +168,7 @@
|
||||||
<p class="submit">
|
<p class="submit">
|
||||||
{{:linkbutton
|
{{:linkbutton
|
||||||
label="Sortir du bilan"
|
label="Sortir du bilan"
|
||||||
href="balance_sheet_exit.html?immo_line_id=%s&type_immo=%s"|args:$_GET.immo_line_id:$_GET.type_immo
|
href="balance_sheet_exit.html?immo_id=%s&type_immo=%s"|args:$_GET.immo_id:$_GET.type_immo
|
||||||
shape="export"
|
shape="export"
|
||||||
class="main"
|
class="main"
|
||||||
}}
|
}}
|
||||||
|
|
@ -238,7 +184,7 @@
|
||||||
<div class="informations">
|
<div class="informations">
|
||||||
<dl class="describe">
|
<dl class="describe">
|
||||||
<dt>Immobilisation</dt>
|
<dt>Immobilisation</dt>
|
||||||
<dd><span class="num"><a href={{$trans_url}}>#{{$ligne_immo.immo_trans_id}}</a></span> {{$ligne_immo.label}}{{if $ligne_immo.line_label != null && $ligne_immo.line_label != $ligne_immo.label}} — {{$ligne_immo.line_label}}{{/if}}</dd>
|
<dd><span class="num"><a href={{$trans_url}}>#{{$ligne_immo.trans_id}}</a></span> {{$ligne_immo.label}}</dd>
|
||||||
<dt>Montant</dt>
|
<dt>Montant</dt>
|
||||||
<dd class="money strong">{{"%f"|math:$ligne_immo.montant|money_currency_html:false|raw}}</dd>
|
<dd class="money strong">{{"%f"|math:$ligne_immo.montant|money_currency_html:false|raw}}</dd>
|
||||||
<dt>Début d'amortissement</dt>
|
<dt>Début d'amortissement</dt>
|
||||||
|
|
@ -261,12 +207,12 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h3 class="ruler">Amortissements enregistrés</h3>
|
<h3 class="ruler">Amortissements enregistrés</h3>
|
||||||
{{if $linked_amort != null}}
|
{{if $linked_lines != null}}
|
||||||
<section class="amortissement">
|
<section class="amortissement">
|
||||||
<table class="list">
|
<table class="list">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="num">N°</th>
|
<th>N°</th>
|
||||||
<th>Date</th>
|
<th>Date</th>
|
||||||
<th class="nombre">Montant</th>
|
<th class="nombre">Montant</th>
|
||||||
<th class="nombre">Valeur nette</th>
|
<th class="nombre">Valeur nette</th>
|
||||||
|
|
@ -277,7 +223,7 @@
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{{#foreach from=$linked_amort item="line"}}
|
{{#foreach from=$linked_lines item="line"}}
|
||||||
{{* données de l'écriture *}}
|
{{* données de l'écriture *}}
|
||||||
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$line.amort_trans_id}}
|
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$line.amort_trans_id}}
|
||||||
{{:assign compte_url="%s/acc/accounts/journal.php?id=%s&year=%s"|args:$admin_url:$line.account_id:$line.amort_year}}
|
{{:assign compte_url="%s/acc/accounts/journal.php?id=%s&year=%s"|args:$admin_url:$line.account_id:$line.amort_year}}
|
||||||
|
|
@ -288,15 +234,16 @@
|
||||||
<td class="money">{{"%f"|math:$line.amort_amount|money_html:false|raw}}</td>
|
<td class="money">{{"%f"|math:$line.amort_amount|money_html:false|raw}}</td>
|
||||||
<td class="money">{{"%f"|math:$solde|money_html:false|raw}}</td>
|
<td class="money">{{"%f"|math:$solde|money_html:false|raw}}</td>
|
||||||
<td>
|
<td>
|
||||||
{{$line.amort_trans_label}}
|
{{if $line.amort_label == null}}
|
||||||
{{if $line.amort_line_label != null && $line.amort_line_label != $line.amort_trans_label}}
|
{{$line.trans_label}}
|
||||||
— {{$line.amort_line_label}}
|
{{else}}
|
||||||
|
{{$line.amort_label}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</td>
|
</td>
|
||||||
<td><a href={{$compte_url}}>{{$line.account_code}}</a></td>
|
<td><a href={{$compte_url}}>{{$line.account_code}}</a></td>
|
||||||
<td>{{$line.account_label}}</td>
|
<td>{{$line.account_label}}</td>
|
||||||
<td>
|
<td>
|
||||||
{{:linkbutton label="Détacher" href="detach_amort.html?amort_line_id=%d&immo_line_id=%d"|args:$line.amort_line_id:$ligne_immo.immo_line_id shape="minus"}}
|
{{:linkbutton label="Détacher" href="detach_amort.html?amort_id=%d&immo_id=%d"|args:$line.amort_line:$ligne_immo.immo_id shape="minus"}}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{/foreach}}
|
{{/foreach}}
|
||||||
|
|
@ -311,9 +258,9 @@
|
||||||
|
|
||||||
{{* Autres amortissements non rattachés *}}
|
{{* Autres amortissements non rattachés *}}
|
||||||
|
|
||||||
{{if $autres_amortissements}}
|
{{if $autres_amortissements != null}}
|
||||||
<p class="block alert">
|
<p class="block alert">
|
||||||
Il existe des écritures d'amortissement qui ne sont pas rattachées à une immobilisation ! <br />
|
Il existe des écritures d'amortissement qui ne sont pas rattachés à une immobilisation ! <br />
|
||||||
Utilisez le bouton « Rattacher une écriture » pour les afficher ; vous pourrez choisir d'en attacher certaines à cette immobilisation.
|
Utilisez le bouton « Rattacher une écriture » pour les afficher ; vous pourrez choisir d'en attacher certaines à cette immobilisation.
|
||||||
</p>
|
</p>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
|
||||||
|
|
@ -10,11 +10,11 @@
|
||||||
id_transaction
|
id_transaction
|
||||||
FROM acc_transactions_lines
|
FROM acc_transactions_lines
|
||||||
WHERE id = :line_id;
|
WHERE id = :line_id;
|
||||||
:line_id = $_GET.immo_line_id|intval
|
:line_id = $_GET.immo_id|intval
|
||||||
}}
|
}}
|
||||||
{{:assign immo_trans_id=$id_transaction}}
|
{{:assign immo_trans_id=$id_transaction}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{:error message="Impossible de trouver l'écriture d'immobilisation de la ligne « %s »"|args:$_GET.immo_line_id}}
|
{{:error message="Impossible de trouver l'écriture d'immobilisation de la ligne « %s »"|args:$_GET.immo_id}}
|
||||||
{{/select}}
|
{{/select}}
|
||||||
|
|
||||||
{{* chercher l'écriture d'amortissement *}}
|
{{* chercher l'écriture d'amortissement *}}
|
||||||
|
|
@ -22,11 +22,11 @@
|
||||||
id_transaction
|
id_transaction
|
||||||
FROM acc_transactions_lines
|
FROM acc_transactions_lines
|
||||||
WHERE id = :line_id;
|
WHERE id = :line_id;
|
||||||
:line_id = $_GET.amort_line_id|intval
|
:line_id = $_GET.amort_id|intval
|
||||||
}}
|
}}
|
||||||
{{:assign amort_trans_id=$id_transaction}}
|
{{:assign amort_id=$id_transaction}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{:error message="Impossible de trouver l'écriture d'amortissement de la ligne « %s »"|args:$_GET.amort_line_id}}
|
{{:error message="Impossible de trouver l'écriture d'amortissement de la ligne « %s »"|args:$_GET.amort_id}}
|
||||||
{{/select}}
|
{{/select}}
|
||||||
|
|
||||||
{{* chercher les liaisons de l'écriture d'immobilisation *}}
|
{{* chercher les liaisons de l'écriture d'immobilisation *}}
|
||||||
|
|
@ -43,7 +43,9 @@
|
||||||
{{/select}}
|
{{/select}}
|
||||||
|
|
||||||
{{* ajouter la nouvelle liaison *}}
|
{{* ajouter la nouvelle liaison *}}
|
||||||
{{:assign var="linked_transactions." value=$amort_trans_id}}
|
{{:assign var="linked_transactions." value=$amort_id}}
|
||||||
|
|
||||||
|
{{* Enregistrer les liaisons *}}
|
||||||
{{:api
|
{{:api
|
||||||
method="POST"
|
method="POST"
|
||||||
path="accounting/transaction/%s/transactions"|args:$immo_trans_id
|
path="accounting/transaction/%s/transactions"|args:$immo_trans_id
|
||||||
|
|
@ -51,24 +53,4 @@
|
||||||
assign_code="result_code"
|
assign_code="result_code"
|
||||||
transactions=$linked_transactions
|
transactions=$linked_transactions
|
||||||
}}
|
}}
|
||||||
|
{{:redirect force="amortization.html?immo_id=%s&ok=1&msg=attach&trans_id=%s"|args:$_GET.immo_id:$amort_id}}
|
||||||
{{* vérifier si cette liaison est déjà présente dans les documents pour éviter les doublons *}}
|
|
||||||
{{#load type="link"
|
|
||||||
where="$$.immo_line_id = :immo_line_id AND
|
|
||||||
$$.amort_trans_id = :amort_trans_id AND
|
|
||||||
$$.amort_line_id = :amort_line_id"
|
|
||||||
:immo_line_id=$_GET.immo_line_id|intval
|
|
||||||
:amort_trans_id = $amort_trans_id
|
|
||||||
:amort_line_id = $_GET.amort_line_id|intval
|
|
||||||
limit=1
|
|
||||||
}}
|
|
||||||
{{else}}
|
|
||||||
{{:save
|
|
||||||
key=""|uuid
|
|
||||||
type="link"
|
|
||||||
immo_line_id=$_GET.immo_line_id|intval
|
|
||||||
amort_line_id=$_GET.amort_line_id|intval
|
|
||||||
amort_trans_id=$amort_trans_id
|
|
||||||
}}
|
|
||||||
{{/load}}
|
|
||||||
{{:redirect force="amortization.html?immo_line_id=%s&ok=1&msg=attach&trans_id=%s"|args:$_GET.immo_line_id:$amort_trans_id}}
|
|
||||||
|
|
|
||||||
|
|
@ -2,129 +2,76 @@
|
||||||
|
|
||||||
{{*
|
{{*
|
||||||
Sortir une immobilisation du bilan
|
Sortir une immobilisation du bilan
|
||||||
@param immo_line_id : id de la ligne d'immobilisation
|
@param immo_id : id de la ligne d'immobilisation
|
||||||
*}}
|
*}}
|
||||||
|
|
||||||
{{* Infos de l'immobilisation *}}
|
{{* Infos de l'immobilisation *}}
|
||||||
{{#select
|
{{#select
|
||||||
line.debit as montant,
|
line.debit as montant,
|
||||||
trans.id AS trans_id,
|
|
||||||
trans.date as date_achat,
|
trans.date as date_achat,
|
||||||
trans.label,
|
trans.label
|
||||||
account.code as account_code
|
|
||||||
FROM acc_transactions_lines AS line
|
FROM acc_transactions_lines AS line
|
||||||
INNER JOIN acc_transactions AS trans ON line.id_transaction = trans.id
|
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 = :line_id;
|
WHERE line.id = :line_id;
|
||||||
:line_id = $_GET.immo_line_id|intval
|
:line_id = $_GET.immo_id|intval
|
||||||
assign="ligne_immo"
|
assign="ligne_immo"
|
||||||
}}
|
}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{:error message="Immobilisation %s non trouvée"|args:$_GET.immo_line_id}}
|
{{:error message="Immobilisation %s non trouvée"|args:$_GET.immo_id}}
|
||||||
{{/select}}
|
{{/select}}
|
||||||
|
|
||||||
{{:assign date_debut=$ligne_immo.date_achat}}
|
{{:assign date_debut=$ligne_immo.date_achat}}
|
||||||
{{:assign ts_mes=$ligne_immo.date_achat|strtotime}}
|
{{:assign ts_mes=$ligne_immo.date_achat|strtotime}}
|
||||||
|
|
||||||
{{#load type="immo" assign="info_immo" where="$$.line = :line_id" :line_id=$_GET.immo_line_id|intval}}
|
{{#load type="immo" assign="info_immo" where="$$.line = :line_id" :line_id=$_GET.immo_id|intval}}
|
||||||
{{:assign ts_mes=$date|strtotime}}
|
{{:assign ts_mes=$date|strtotime}}
|
||||||
{{:assign date_debut=$date}}
|
{{:assign date_debut=$date}}
|
||||||
{{:assign duree_amort=$duration}}
|
{{:assign duree_amort=$duration}}
|
||||||
|
{{if $amount != null}}
|
||||||
|
{{:assign var="ligne_immo.montant" value=$amount}}
|
||||||
|
{{/if}}
|
||||||
{{/load}}
|
{{/load}}
|
||||||
|
|
||||||
{{* chercher des écritures liées à l'immo courante au crédit du même compte
|
|
||||||
et déduire leur montant de celui de l'immo
|
|
||||||
*}}
|
|
||||||
{{:assign total_credits=0}}
|
|
||||||
{{#select
|
|
||||||
CASE links.id_related = :immo_trans_id
|
|
||||||
WHEN true THEN links.id_transaction
|
|
||||||
WHEN false THEN links.id_related
|
|
||||||
END as other_id,
|
|
||||||
line.credit
|
|
||||||
FROM acc_transactions AS trans
|
|
||||||
INNER JOIN acc_transactions_links as links
|
|
||||||
ON (trans.id = links.id_transaction OR trans.id = links.id_related)
|
|
||||||
INNER JOIN acc_transactions_lines AS line on line.id_transaction = other_id
|
|
||||||
INNER JOIN acc_accounts AS acc ON line.id_account = acc.id
|
|
||||||
WHERE trans.id = :immo_trans_id AND line.credit > 0 AND acc.code = :account;
|
|
||||||
:immo_trans_id=$ligne_immo.trans_id
|
|
||||||
:account=$ligne_immo.account_code
|
|
||||||
}}
|
|
||||||
{{:assign total_credits="%d+%d"|math:$total_credits:$credit}}
|
|
||||||
{{/select}}
|
|
||||||
{{:assign var="ligne_immo.montant" value="%d-%d"|math:$ligne_immo.montant:$total_credits}}
|
|
||||||
|
|
||||||
{{* chercher des écritures d'amortissement liées à l'immobilisation *}}
|
{{* chercher des écritures d'amortissement liées à l'immobilisation *}}
|
||||||
{{:assign total_amort=0}}
|
|
||||||
{{:assign amort_number=0}}
|
|
||||||
{{#select
|
{{#select
|
||||||
l_amort.credit as amort_amount,
|
SUM(l_amort.credit) as amort_amount,
|
||||||
l_amort.id as amort_line_id,
|
|
||||||
CASE
|
CASE
|
||||||
WHEN links.id_related = t_immo.id
|
WHEN links.id_related = t_immo.id
|
||||||
THEN links.id_transaction
|
THEN links.id_transaction
|
||||||
ELSE links.id_related
|
ELSE links.id_related
|
||||||
END as amort_trans_id,
|
END as amort_trans_id,
|
||||||
trans.date
|
MAX(trans.date) as last_amort_date,
|
||||||
|
MIN(trans.date) as first_amort_date,
|
||||||
|
COUNT(trans.id) as amort_number
|
||||||
FROM acc_transactions_lines as l_immo
|
FROM acc_transactions_lines as l_immo
|
||||||
INNER JOIN acc_transactions as t_immo on t_immo.id = l_immo.id_transaction
|
INNER JOIN acc_transactions as t_immo on t_immo.id = l_immo.id_transaction
|
||||||
INNER JOIN acc_transactions_links as links
|
INNER JOIN acc_transactions_links as links
|
||||||
ON (t_immo.id = links.id_transaction OR t_immo.id = links.id_related)
|
ON (t_immo.id = links.id_transaction
|
||||||
|
OR
|
||||||
|
t_immo.id = links.id_related)
|
||||||
INNER JOIN acc_transactions_lines as l_amort on amort_trans_id = l_amort.id_transaction
|
INNER JOIN acc_transactions_lines as l_amort on amort_trans_id = l_amort.id_transaction
|
||||||
INNER join acc_transactions as trans on l_amort.id_transaction = trans.id
|
INNER join acc_transactions as trans on l_amort.id_transaction = trans.id
|
||||||
INNER JOIN acc_accounts AS account ON l_amort.id_account = account.id
|
INNER JOIN acc_accounts AS account ON l_amort.id_account = account.id
|
||||||
WHERE l_immo.id = :line_id AND account.code LIKE '28%'
|
WHERE l_immo.id = :line_id AND account.code LIKE '28%'
|
||||||
;
|
LIMIT 1;
|
||||||
:line_id = $_GET.immo_line_id|intval
|
:line_id = $_GET.immo_id|intval
|
||||||
assign="amort_line"
|
assign=amort_line
|
||||||
}}
|
}}
|
||||||
|
|
||||||
{{#load type="link"
|
|
||||||
where="$$.immo_line_id = :immo_line_id AND $$.amort_trans_id = :amort_trans_id"
|
|
||||||
assign="line"
|
|
||||||
:immo_line_id=$_GET.immo_line_id|intval :amort_trans_id=$amort_line.amort_trans_id
|
|
||||||
}}
|
|
||||||
{{if $line.amort_line_id == $amort_line.amort_line_id}}
|
|
||||||
{{:assign amort_number="%d+1"|math:$amort_number}}
|
|
||||||
{{:assign total_amort="%d+%d"|math:$total_amort:$amort_line.amort_amount}}
|
|
||||||
{{if $first_amort_date == null}}
|
|
||||||
{{:assign first_amort_date=$amort_line.date}}
|
|
||||||
{{elseif $amort_line.date < $first_amort_date}}
|
|
||||||
{{:assign first_amort_date=$amort_line.date}}
|
|
||||||
{{/if}}
|
|
||||||
{{if $last_amort_date == null}}
|
|
||||||
{{:assign last_amort_date=$amort_line.date}}
|
|
||||||
{{elseif $amort_line.date > $last_amort_date}}
|
|
||||||
{{:assign last_amort_date=$amort_line.date}}
|
|
||||||
{{/if}}
|
|
||||||
{{/if}}
|
|
||||||
{{else}}
|
|
||||||
{{:assign amort_number="%d+1"|math:$amort_number}}
|
|
||||||
{{:assign total_amort="%d+%d"|math:$total_amort:$amort_line.amort_amount}}
|
|
||||||
{{if $first_amort_date == null}}
|
|
||||||
{{:assign first_amort_date=$amort_line.date}}
|
|
||||||
{{elseif $amort_line.date < $first_amort_date}}
|
|
||||||
{{:assign first_amort_date=$amort_line.date}}
|
|
||||||
{{/if}}
|
|
||||||
{{if $last_amort_date == null}}
|
|
||||||
{{:assign last_amort_date=$amort_line.date}}
|
|
||||||
{{elseif $amort_line.date > $last_amort_date}}
|
|
||||||
{{:assign last_amort_date=$amort_line.date}}
|
|
||||||
{{/if}}
|
|
||||||
{{/load}}
|
|
||||||
{{/select}}
|
{{/select}}
|
||||||
|
|
||||||
{{if $total_amort == 0}}
|
{{if $amort_line.amort_number == 0}}
|
||||||
{{if $info_immo.status == "amortized"}}
|
{{if $info_immo.status == "amortized"}}
|
||||||
{{:assign total_amort=$ligne_immo.montant}}
|
{{:assign amort_amount=$ligne_immo.montant}}
|
||||||
{{/if}}
|
{{else}}
|
||||||
|
{{:assign amort_amount=0}}
|
||||||
|
{{/if}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{:assign date_debut=$last_amort_date|strtotime}}
|
{{:assign amort_amount=$amort_line.amort_amount}}
|
||||||
|
{{:assign date_debut=$amort_line.last_amort_date|strtotime}}
|
||||||
{{:assign date_debut="%d+(60*60*24)"|math:$date_debut|date:"Y-m-d"}}
|
{{:assign date_debut="%d+(60*60*24)"|math:$date_debut|date:"Y-m-d"}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{:assign ts_debut=$date_debut|strtotime}}
|
{{:assign ts_debut=$date_debut|strtotime}}
|
||||||
{{:assign valeur_nette="%f-%f"|math:$ligne_immo.montant:$total_amort}}
|
{{:assign valeur_nette="%f-%f"|math:$ligne_immo.montant:$amort_amount}}
|
||||||
|
|
||||||
{{*
|
{{*
|
||||||
lister les exercices ouverts dont la date de fin est postérieure à la date du dernier amortissment
|
lister les exercices ouverts dont la date de fin est postérieure à la date du dernier amortissment
|
||||||
|
|
@ -157,9 +104,9 @@
|
||||||
{{* vérifier la validité de la date de mise en service *}}
|
{{* vérifier la validité de la date de mise en service *}}
|
||||||
{{if $_POST.date_mes != null}}
|
{{if $_POST.date_mes != null}}
|
||||||
{{:assign ts_mes=$_POST.date_mes|parse_date|strtotime}}
|
{{:assign ts_mes=$_POST.date_mes|parse_date|strtotime}}
|
||||||
{{if $ts_mes < $ligne_immo.date_achat|strtotime || $ts_mes > $first_amort_date|strtotime}}
|
{{if $ts_mes < $ligne_immo.date_achat|strtotime || $ts_mes > $amort_line.first_amort_date|strtotime}}
|
||||||
{{:assign immo_date=$ligne_immo.date_achat|date_short}}
|
{{:assign immo_date=$ligne_immo.date_achat|date_short}}
|
||||||
{{:assign amort_date=$first_amort_date|date_short}}
|
{{:assign amort_date=$amort_line.first_amort_date|date_short}}
|
||||||
{{:error message="La date de mise en service doit être postérieure à la date d'acquisition de l'immobilisation (%s) et antérieure à la date du premier amortissement (%s)"|args:$immo_date:$amort_date}}
|
{{:error message="La date de mise en service doit être postérieure à la date d'acquisition de l'immobilisation (%s) et antérieure à la date du premier amortissement (%s)"|args:$immo_date:$amort_date}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
@ -169,8 +116,8 @@
|
||||||
{{if $info_immo.duration == null}}
|
{{if $info_immo.duration == null}}
|
||||||
{{if $_POST.duree == null}}
|
{{if $_POST.duree == null}}
|
||||||
{{:error message="Vous devez renseigner la durée de l'immobilisation"}}
|
{{:error message="Vous devez renseigner la durée de l'immobilisation"}}
|
||||||
{{elseif $_POST.duree < $amort_number}}
|
{{elseif $_POST.duree < $amort_line.amort_number}}
|
||||||
{{:error message="La durée de l'amortissement ne peut être inférieure au nombre d'écritures d'amortissement (%d)"|args:$amort_number}}
|
{{:error message="La durée de l'amortissement ne peut être inférieure au nombre d'écritures d'amortissement (%d)"|args:$amort_line.amort_number}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{:assign duree_amort=$_POST.duree}}
|
{{:assign duree_amort=$_POST.duree}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
@ -191,9 +138,9 @@
|
||||||
{{:assign immo_date=$ligne_immo.date_achat|date_short}}
|
{{:assign immo_date=$ligne_immo.date_achat|date_short}}
|
||||||
{{:error message="La date de sortie doit être postérieure à la date d'acquisition de l'immobilisation (%s)"|args:$immo_date}}
|
{{:error message="La date de sortie doit être postérieure à la date d'acquisition de l'immobilisation (%s)"|args:$immo_date}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{if $amort_number != 0 && $_POST.date_sortie|parse_date <= $last_amort_date}}
|
{{if $amort_line.amort_number != 0 && $_POST.date_sortie|parse_date <= $amort_line.last_amort_date}}
|
||||||
{{:assign last_amort_date=$last_amort_date|date_short}}
|
{{:assign last_amort_date=$amort_line.last_amort_date|date_short}}
|
||||||
{{:error message="La date de sortie doit être postérieure à la date du dernier amortissement (%s)"|args:$last_amort_date}}
|
{{:error message="La date de sortie doit être postérieure à la date de la dernière immobilisation (%s)"|args:$last_amort_date}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{* vérifier que la date de sortie est située dans un exercice ouvert *}}
|
{{* vérifier que la date de sortie est située dans un exercice ouvert *}}
|
||||||
|
|
@ -210,7 +157,7 @@
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{* voir si des amortissements ont été oubliés *}}
|
{{* voir si des amortissements ont été oubliés *}}
|
||||||
{{if $valeur_nette > 0 && $info_immo.status != "amortized" && $start_date|strtotime > $last_amort_date|strtotime && $end_date|strtotime < $now}}
|
{{if $valeur_nette > 0 && $info_immo.status != "amortized" && $start_date|strtotime > $amort_line.last_amort_date|strtotime && $end_date|strtotime < $now}}
|
||||||
{{:assign debut=$start_date|date_short}}
|
{{:assign debut=$start_date|date_short}}
|
||||||
{{:assign fin=$end_date|date_short}}
|
{{:assign fin=$end_date|date_short}}
|
||||||
{{:assign msg_amort=$msg_amort|cat:"\n"|cat:" - "|cat:$label|cat:" : du "|cat:$debut|cat:" au "|cat:$fin}}
|
{{:assign msg_amort=$msg_amort|cat:"\n"|cat:" - "|cat:$label|cat:" : du "|cat:$debut|cat:" au "|cat:$fin}}
|
||||||
|
|
@ -223,7 +170,7 @@
|
||||||
{{:error message="Vous devez d'abord enregistrer les amortissements des exercices suivants : %s"|args:$msg_amort}}
|
{{:error message="Vous devez d'abord enregistrer les amortissements des exercices suivants : %s"|args:$msg_amort}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{:redirect to="compute_exit_data.html?immo_line_id=%s&amort_amount=%s&year=%s&date_mes=%s&date_debut=%s&exit_date=%s&duree_amort=%s"|args:$_GET.immo_line_id:$total_amort:$selected_year:$ts_mes:$ts_debut:$ts_exit:$duree_amort}}
|
{{:redirect to="compute_exit_data.html?immo_id=%s&amort_amount=%s&year=%s&date_mes=%s&date_debut=%s&exit_date=%s&duree_amort=%s"|args:$_GET.immo_id:$amort_amount:$selected_year:$ts_mes:$ts_debut:$ts_exit:$duree_amort}}
|
||||||
{{/form}}
|
{{/form}}
|
||||||
|
|
||||||
{{:admin_header title="Sortie de bilan" custom_css="./style.css" current="module_amortization"}}
|
{{:admin_header title="Sortie de bilan" custom_css="./style.css" current="module_amortization"}}
|
||||||
|
|
@ -253,7 +200,7 @@
|
||||||
<dd id="duree_amort" class="num">{{$info_immo.duration}} ans</dd>
|
<dd id="duree_amort" class="num">{{$info_immo.duration}} ans</dd>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<dt>Montant des amortissements</dt>
|
<dt>Montant des amortissements</dt>
|
||||||
<dd id="montant_amort" class="money">{{$total_amort|money_currency_html:false|raw}} <span class="help">(à la date de début de l'exercice)</span></dd>
|
<dd id="montant_amort" class="money">{{$amort_amount|money_currency_html:false|raw}} <span class="help">(à la date de début de l'exercice)</span></dd>
|
||||||
<dt>Valeur nette résiduelle</dt>
|
<dt>Valeur nette résiduelle</dt>
|
||||||
<dd class="money">{{$valeur_nette|money_currency_html:false|raw}} <span class="help">(à la date de début de l'exercice)</span></dd>
|
<dd class="money">{{$valeur_nette|money_currency_html:false|raw}} <span class="help">(à la date de début de l'exercice)</span></dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
{{*
|
{{*
|
||||||
Calculer les valeurs de la sortie et saisir le montant de la cession (optionnel)
|
Calculer les valeurs de la sortie et saisir le montant de la cession (optionnel)
|
||||||
paramètres :
|
paramètres :
|
||||||
- immo_line_id : numéro de ligne de l'écriture d'immobilisation
|
- immo_id : numéro de ligne de l'écriture d'immobilisation
|
||||||
- amort_amount : montant des amortissements
|
- amort_amount : montant des amortissements
|
||||||
- year : exercice de la date de sortie de l'immobilisation
|
- year : exercice de la date de sortie de l'immobilisation
|
||||||
- date_mes : datede mise en service de l'immobilisation
|
- date_mes : datede mise en service de l'immobilisation
|
||||||
|
|
@ -14,43 +14,22 @@
|
||||||
|
|
||||||
{{#select
|
{{#select
|
||||||
line.debit as montant,
|
line.debit as montant,
|
||||||
trans.id AS trans_id,
|
|
||||||
trans.date as date_achat,
|
trans.date as date_achat,
|
||||||
trans.label,
|
trans.label
|
||||||
account.code as account_code
|
|
||||||
FROM acc_transactions_lines AS line
|
FROM acc_transactions_lines AS line
|
||||||
INNER JOIN acc_transactions AS trans ON line.id_transaction = trans.id
|
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 = :line_id;
|
WHERE line.id = :line_id;
|
||||||
:line_id = $_GET.immo_line_id|intval
|
:line_id = $_GET.immo_id|intval
|
||||||
assign="ligne_immo"
|
assign="ligne_immo"
|
||||||
}}
|
}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{:error message="Immobilisation %s non trouvée"|args:$_GET.immo_line_id}}
|
{{:error message="Immobilisation %s non trouvée"|args:$_GET.immo_id}}
|
||||||
{{/select}}
|
{{/select}}
|
||||||
|
{{#load type="immo" where="$$.line = :line_id" :line_id=$_GET.immo_id|intval}}
|
||||||
{{* chercher des écritures liées à l'immo courante au crédit du même compte
|
{{if $amount != null}}
|
||||||
et déduire leur montant de celui de l'immo
|
{{:assign var="ligne_immo.montant" value=$amount}}
|
||||||
*}}
|
{{/if}}
|
||||||
{{:assign total_credits=0}}
|
{{/load}}
|
||||||
{{#select
|
|
||||||
CASE links.id_related = :immo_trans_id
|
|
||||||
WHEN true THEN links.id_transaction
|
|
||||||
WHEN false THEN links.id_related
|
|
||||||
END as other_id,
|
|
||||||
line.credit
|
|
||||||
FROM acc_transactions AS trans
|
|
||||||
INNER JOIN acc_transactions_links as links
|
|
||||||
ON (trans.id = links.id_transaction OR trans.id = links.id_related)
|
|
||||||
INNER JOIN acc_transactions_lines AS line on line.id_transaction = other_id
|
|
||||||
INNER JOIN acc_accounts AS acc ON line.id_account = acc.id
|
|
||||||
WHERE trans.id = :immo_trans_id AND line.credit > 0 AND acc.code = :account;
|
|
||||||
:immo_trans_id=$ligne_immo.trans_id
|
|
||||||
:account=$ligne_immo.account_code
|
|
||||||
}}
|
|
||||||
{{:assign total_credits="%d+%d"|math:$total_credits:$credit}}
|
|
||||||
{{/select}}
|
|
||||||
{{:assign var="ligne_immo.montant" value="%d-%d"|math:$ligne_immo.montant:$total_credits}}
|
|
||||||
|
|
||||||
{{:assign valeur_nette="%f-%f"|math:$ligne_immo.montant:$_GET.amort_amount}}
|
{{:assign valeur_nette="%f-%f"|math:$ligne_immo.montant:$_GET.amort_amount}}
|
||||||
{{:assign amort_comp=0}} {{* amortissement complémentaire jqà date sortie *}}
|
{{:assign amort_comp=0}} {{* amortissement complémentaire jqà date sortie *}}
|
||||||
|
|
@ -69,7 +48,7 @@
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{:redirect to="write_exit.html?immo_line_id=%s&amort_amount=%s&year=%s&date_mes=%s&date_debut=%s&exit_date=%s&duree_amort=%s&cession=%s"|args:$_GET.immo_line_id:$_GET.amort_amount:$_GET.year:$_GET.date_mes:$_GET.date_debut:$_GET.exit_date:$_GET.duree_amort:$_POST.montant_cession}}
|
{{:redirect to="write_exit.html?immo_id=%s&amort_amount=%s&year=%s&date_mes=%s&date_debut=%s&exit_date=%s&duree_amort=%s&cession=%s"|args:$_GET.immo_id:$_GET.amort_amount:$_GET.year:$_GET.date_mes:$_GET.date_debut:$_GET.exit_date:$_GET.duree_amort:$_POST.montant_cession}}
|
||||||
|
|
||||||
{{/form}}
|
{{/form}}
|
||||||
{{:admin_header title="Sortie du bilan" custom_css="./style.css" current="module_amortization"}}
|
{{:admin_header title="Sortie du bilan" custom_css="./style.css" current="module_amortization"}}
|
||||||
|
|
|
||||||
|
|
@ -10,11 +10,11 @@
|
||||||
id_transaction
|
id_transaction
|
||||||
FROM acc_transactions_lines
|
FROM acc_transactions_lines
|
||||||
WHERE id = :line_id;
|
WHERE id = :line_id;
|
||||||
:line_id = $_GET.immo_line_id|intval
|
:line_id = $_GET.immo_id|intval
|
||||||
}}
|
}}
|
||||||
{{:assign immo_trans_id=$id_transaction}}
|
{{:assign immo_trans_id=$id_transaction}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{:error message="Impossible de trouver l'écriture d'immobilisation de la ligne « %s »"|args:$_GET.immo_line_id}}
|
{{:error message="Impossible de trouver l'écriture d'immobilisation de la ligne « %s »"|args:$_GET.immo_id}}
|
||||||
{{/select}}
|
{{/select}}
|
||||||
|
|
||||||
{{* chercher l'écriture d'amortissement *}}
|
{{* chercher l'écriture d'amortissement *}}
|
||||||
|
|
@ -22,11 +22,11 @@
|
||||||
id_transaction
|
id_transaction
|
||||||
FROM acc_transactions_lines
|
FROM acc_transactions_lines
|
||||||
WHERE id = :line_id;
|
WHERE id = :line_id;
|
||||||
:line_id = $_GET.amort_line_id|intval
|
:line_id = $_GET.amort_id|intval
|
||||||
}}
|
}}
|
||||||
{{:assign amort_id=$id_transaction}}
|
{{:assign amort_id=$id_transaction}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{:error message="Impossible de trouver l'écriture d'amortissement de la ligne « %s »"|args:$_GET.amort_line_id}}
|
{{:error message="Impossible de trouver l'écriture d'amortissement de la ligne « %s »"|args:$_GET.amort_id}}
|
||||||
{{/select}}
|
{{/select}}
|
||||||
|
|
||||||
{{*
|
{{*
|
||||||
|
|
@ -55,17 +55,4 @@
|
||||||
assign_code="result_code"
|
assign_code="result_code"
|
||||||
transactions=$linked_transactions
|
transactions=$linked_transactions
|
||||||
}}
|
}}
|
||||||
|
{{:redirect to="amortization.html?immo_id=%s&ok=1&msg=detach&trans_id=%s"|args:$_GET.immo_id:$amort_id}}
|
||||||
{{* supprimer le doc de liaison entre les lignes *}}
|
|
||||||
{{#load type="link"
|
|
||||||
where="$$.immo_line_id = :immo_line_id AND
|
|
||||||
$$.amort_trans_id = :amort_trans_id AND
|
|
||||||
$$.amort_line_id = :amort_line_id"
|
|
||||||
:immo_line_id=$_GET.immo_line_id|intval
|
|
||||||
:amort_trans_id = $amort_id|intval
|
|
||||||
:amort_line_id = $_GET.amort_line_id|intval
|
|
||||||
}}
|
|
||||||
{{:delete id=$id}}
|
|
||||||
{{/load}}
|
|
||||||
|
|
||||||
{{:redirect to="amortization.html?immo_line_id=%s&ok=1&msg=detach&trans_id=%s"|args:$_GET.immo_line_id:$amort_id}}
|
|
||||||
|
|
|
||||||
10
ignore.html
10
ignore.html
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
{{*
|
{{*
|
||||||
Marquer la ligne d'écriture « à ignorer »
|
Marquer la ligne d'écriture « à ignorer »
|
||||||
@param immo_line_id : numéro de ligne
|
@param immo_id : numéro de ligne
|
||||||
*}}
|
*}}
|
||||||
|
|
||||||
{{#select
|
{{#select
|
||||||
|
|
@ -14,13 +14,13 @@
|
||||||
INNER JOIN acc_transactions AS trans ON line.id_transaction = trans.id
|
INNER JOIN acc_transactions AS trans ON line.id_transaction = trans.id
|
||||||
WHERE line.id = :line_id
|
WHERE line.id = :line_id
|
||||||
;
|
;
|
||||||
:line_id = $_GET.immo_line_id
|
:line_id = $_GET.immo_id
|
||||||
assign=ligne_immo
|
assign=ligne_immo
|
||||||
}}
|
}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{:error message="Il n'y a aucune écriture avec le numéro de ligne %s !"|args:$_GET.immo_line_id}}
|
{{:error message="Il n'y a aucune écriture avec le numéro de ligne %s !"|args:$_GET.immo_id}}
|
||||||
{{/select}}
|
{{/select}}
|
||||||
{{#load type="immo" assign="info_immo" where="$$.line = :line_id" :line_id=$_GET.immo_line_id|intval}}{{/load}}
|
{{#load type="immo" assign="info_immo" where="$$.line = :line_id" :line_id=$_GET.immo_id|intval}}{{/load}}
|
||||||
|
|
||||||
{{* Traiter l'envoi du formulaire *}}
|
{{* Traiter l'envoi du formulaire *}}
|
||||||
{{#form on="proceed"}}
|
{{#form on="proceed"}}
|
||||||
|
|
@ -32,7 +32,7 @@
|
||||||
key=""|uuid
|
key=""|uuid
|
||||||
validate_schema="schema.json"
|
validate_schema="schema.json"
|
||||||
type="immo"
|
type="immo"
|
||||||
line=$_GET.immo_line_id|intval
|
line=$_GET.immo_id|intval
|
||||||
duration=$duration
|
duration=$duration
|
||||||
date=$ligne_immo.date
|
date=$ligne_immo.date
|
||||||
status=$status
|
status=$status
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
name="Amortissements"
|
name="Amortissements"
|
||||||
description="Immobilisations et amortissements\nversion 0.32"
|
description="Immobilisations et amortissements\nversion 0.28"
|
||||||
author="Jean-Christophe Engel"
|
author="Jean-Christophe Engel"
|
||||||
author_url="https://gitea.zaclys.com/lesanges"
|
author_url="https://gitea.zaclys.com/lesanges"
|
||||||
home_button=false
|
home_button=false
|
||||||
|
|
|
||||||
|
|
@ -3,44 +3,41 @@
|
||||||
{{*
|
{{*
|
||||||
Lister les écritures d'amortissement indépendantes
|
Lister les écritures d'amortissement indépendantes
|
||||||
et proposer des les attacher à l'immo sélectionnée
|
et proposer des les attacher à l'immo sélectionnée
|
||||||
@param immo_line_id = id de la ligne d'immo
|
@param immo_id = id de la ligne d'immo
|
||||||
*}}
|
*}}
|
||||||
|
|
||||||
{{* récupérer les infos de l'immobilisation *}}
|
{{* récupérer les infos de l'immobilisation *}}
|
||||||
{{#select
|
{{#select
|
||||||
|
line.id as immo_id,
|
||||||
|
line.debit as montant,
|
||||||
|
trans.id as trans_id,
|
||||||
trans.label as label,
|
trans.label as label,
|
||||||
line.label as line_label
|
trans.date
|
||||||
FROM acc_transactions_lines AS line
|
FROM acc_transactions_lines AS line
|
||||||
INNER JOIN acc_transactions AS trans ON line.id_transaction = trans.id
|
INNER JOIN acc_transactions AS trans ON line.id_transaction = trans.id
|
||||||
WHERE line.id = :line_id;
|
WHERE line.id = :line_id;
|
||||||
:line_id = $_GET.immo_line_id|intval
|
:line_id = $_GET.immo_id|intval
|
||||||
assign=ligne_immo
|
assign=ligne_immo
|
||||||
}}
|
}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{:error message="Immobilisation %s non trouvée"|args:$_GET.immo_line_id}}
|
{{:error message="Immobilisation %s non trouvée"|args:$_GET.immo_id}}
|
||||||
{{/select}}
|
{{/select}}
|
||||||
|
|
||||||
{{:include file="_get_config.html" keep="module.config"}}
|
{{:include file="_get_config.html" keep="module.config"}}
|
||||||
|
{{:assign filter_condition=" 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)"}}
|
||||||
|
|
||||||
{{if $_POST.unhide == null}}
|
|
||||||
{{:assign filter_condition=" 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)"}}
|
|
||||||
{{else}}
|
|
||||||
{{:assign filter_condition="1"}}
|
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
{{* lister les écritures d'amortissement *}}
|
|
||||||
{{#select
|
{{#select
|
||||||
line.id as amort_line_id,
|
line.id as l_id,
|
||||||
line.id_transaction as amort_trans_id,
|
line.id_transaction as t_id,
|
||||||
line.credit as amort_amount,
|
line.credit as amort_amount,
|
||||||
line.label as line_label,
|
line.label as l_label,
|
||||||
trans.date as trans_date,
|
trans.date as t_date,
|
||||||
trans.label as trans_label,
|
trans.label as t_label,
|
||||||
trans.id_year as amort_year,
|
trans.id_year as amort_year,
|
||||||
account.id as account_id,
|
account.id as account_id,
|
||||||
account.code as account_code,
|
account.code as account_code,
|
||||||
|
|
@ -52,47 +49,17 @@
|
||||||
WHERE account.code LIKE "28%" AND credit > 0 AND (NOT trans.status & 16) AND !filter_condition
|
WHERE account.code LIKE "28%" AND credit > 0 AND (NOT trans.status & 16) AND !filter_condition
|
||||||
ORDER BY trans.date, trans.label;
|
ORDER BY trans.date, trans.label;
|
||||||
!filter_condition=$filter_condition
|
!filter_condition=$filter_condition
|
||||||
assign="amort"
|
assign=autre_amort
|
||||||
}}
|
}}
|
||||||
|
|
||||||
{{* voir s'il existe des écritures liées avec un numéro de compte d'immobilisation *}}
|
|
||||||
{{#select
|
{{#select
|
||||||
links.id_transaction,
|
id_transaction,
|
||||||
links.id_related,
|
id_related
|
||||||
trans.id AS trans_id
|
FROM acc_transactions_links
|
||||||
FROM acc_transactions_links AS links
|
WHERE id_transaction = :id_amort OR id_related = :id_amort;
|
||||||
INNER JOIN acc_transactions AS trans ON (
|
:id_amort=$t_id
|
||||||
CASE
|
|
||||||
WHEN links.id_transaction = :id_amort THEN links.id_related
|
|
||||||
WHEN links.id_related = :id_amort THEN links.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
|
|
||||||
links.id_transaction = :id_amort OR links.id_related = :id_amort
|
|
||||||
AND acc.code LIKE '21%'
|
|
||||||
LIMIT 1
|
|
||||||
;
|
|
||||||
:id_amort=$amort.amort_trans_id
|
|
||||||
}}
|
}}
|
||||||
{{* voir s'il existe un doc associé à une ligne de l'amortissement *}}
|
|
||||||
{{:assign keep=true}}
|
|
||||||
{{#load type="link"
|
|
||||||
where="$$.amort_trans_id = :amort_trans_id"
|
|
||||||
:amort_trans_id = $amort.amort_trans_id
|
|
||||||
}}
|
|
||||||
{{if $amort_line_id == $amort.amort_line_id}}
|
|
||||||
{{:assign keep=false}}
|
|
||||||
{{:break}}
|
|
||||||
{{/if}}
|
|
||||||
{{else}}
|
|
||||||
{{:assign keep=false}}
|
|
||||||
{{/load}}
|
|
||||||
{{if $keep}}
|
|
||||||
{{:assign var="autres_amortissements." value=$amort}}
|
|
||||||
{{/if}}
|
|
||||||
{{else}}
|
{{else}}
|
||||||
{{:assign var="autres_amortissements." value=$amort}}
|
{{:assign var="autres_amortissements." value=$autre_amort}}
|
||||||
{{/select}}
|
{{/select}}
|
||||||
{{/select}}
|
{{/select}}
|
||||||
|
|
||||||
|
|
@ -110,19 +77,9 @@
|
||||||
}}
|
}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{if $_POST.unhide != null}}
|
|
||||||
{{:assign checked="checked"}}
|
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
<form method="post" action="">
|
|
||||||
<fieldset>
|
|
||||||
{{:input type="checkbox" value=1 name="unhide" checked="%s"|args:$checked label="Afficher toutes les écritures" }}
|
|
||||||
</fieldset>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
{{if $autres_amortissements != null}}
|
{{if $autres_amortissements != null}}
|
||||||
<section class="amortissement">
|
<section class="amortissement">
|
||||||
<h3 class="ruler">Immobilisation « {{$ligne_immo.label}}{{if $ligne_immo.line_label != null && $ligne_immo.line_label != $ligne_immo.label}} — {{$ligne_immo.line_label}}{{/if}} »</h3>
|
<h3 class="ruler">Immobilisation « {{$ligne_immo.label}} »</h3>
|
||||||
<table class="list">
|
<table class="list">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
@ -137,19 +94,22 @@
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{{#foreach from=$autres_amortissements item="line"}}
|
{{#foreach from=$autres_amortissements item="line"}}
|
||||||
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$line.amort_trans_id}}
|
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$line.t_id}}
|
||||||
{{:assign compte_url="%s/acc/accounts/journal.php?id=%s&year=%s"|args:$admin_url:$line.account_id:$line.amort_year}}
|
{{:assign compte_url="%s/acc/accounts/journal.php?id=%s&year=%s"|args:$admin_url:$line.account_id:$line.amort_year}}
|
||||||
<tr>
|
<tr>
|
||||||
<td class="num"><a href={{$trans_url}}>#{{$line.amort_trans_id}}</a></td>
|
<td class="num"><a href={{$trans_url}}>#{{$line.t_id}}</a></td>
|
||||||
<td>{{$line.trans_date|date_short}}</td>
|
<td>{{$line.t_date|date_short}}</td>
|
||||||
<td class="money">{{"%f"|math:$line.amort_amount|money_html:false|raw}}</td>
|
<td class="money">{{"%f"|math:$line.amort_amount|money_html:false|raw}}</td>
|
||||||
<td>{{$line.trans_label}}
|
<td>{{if $line.l_label == null}}
|
||||||
{{if $line.line_label != null && $line.line_label != $line.trans_label}} - {{$line.line_label}}{{/if}}
|
{{$line.t_label}}
|
||||||
|
{{else}}
|
||||||
|
{{$line.l_label}}
|
||||||
|
{{/if}}
|
||||||
</td>
|
</td>
|
||||||
<td><a href={{$compte_url}}>{{$line.account_code}}</a></td>
|
<td><a href={{$compte_url}}>{{$line.account_code}}</a></td>
|
||||||
<td>{{$line.account_label}}</td>
|
<td>{{$line.account_label}}</td>
|
||||||
<td>
|
<td>
|
||||||
{{:linkbutton label="Attacher" href="attach_amort.html?amort_line_id=%d&immo_line_id=%d"|args:$line.amort_line_id:$_GET.immo_line_id shape="plus"}}
|
{{:linkbutton label="Attacher" href="attach_amort.html?amort_id=%d&immo_id=%d"|args:$line.l_id:$_GET.immo_id shape="plus"}}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{/foreach}}
|
{{/foreach}}
|
||||||
|
|
@ -159,15 +119,3 @@
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{:form_errors}}
|
{{:form_errors}}
|
||||||
{{:admin_footer}}
|
{{:admin_footer}}
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
function changeVisibility(evt, idcheck = 'f_unhide_1') {
|
|
||||||
this.form.dispatchEvent(new Event('submit'));
|
|
||||||
this.form.submit();
|
|
||||||
}
|
|
||||||
|
|
||||||
(function () {
|
|
||||||
document.getElementById('f_unhide_1').onclick = changeVisibility;
|
|
||||||
})();
|
|
||||||
|
|
||||||
</script>
|
|
||||||
|
|
|
||||||
158
save_amort.html
158
save_amort.html
|
|
@ -2,82 +2,56 @@
|
||||||
|
|
||||||
{{*
|
{{*
|
||||||
Créer une écriture d'amortissement
|
Créer une écriture d'amortissement
|
||||||
@param immo_line_id : id de la ligne d'immobilisation
|
@param immo_id : id de la ligne d'immobilisation
|
||||||
*}}
|
*}}
|
||||||
|
|
||||||
{{* Infos de l'immobilisation *}}
|
{{* Infos de l'immobilisation *}}
|
||||||
{{#select
|
{{#select
|
||||||
|
line.id as immo_id,
|
||||||
line.id_account as account_id,
|
line.id_account as account_id,
|
||||||
line.debit as montant,
|
line.debit as montant,
|
||||||
line.id_project as project_id,
|
line.id_project as project_id,
|
||||||
line.label as line_label,
|
|
||||||
trans.id as trans_id,
|
trans.id as trans_id,
|
||||||
trans.label,
|
trans.label,
|
||||||
trans.date,
|
trans.date,
|
||||||
account.code as account_code
|
y.id as year_id,
|
||||||
|
y.start_date,
|
||||||
|
y.end_date,
|
||||||
|
project.label as project_label
|
||||||
FROM acc_transactions_lines AS line
|
FROM acc_transactions_lines AS line
|
||||||
INNER JOIN acc_transactions AS trans ON line.id_transaction = trans.id
|
INNER JOIN acc_transactions AS trans ON line.id_transaction = trans.id
|
||||||
INNER JOIN acc_accounts AS account ON line.id_account = account.id
|
INNER JOIN acc_years AS y ON trans.id_year = y.id
|
||||||
LEFT JOIN acc_projects AS project ON line.id_project = project.id
|
LEFT JOIN acc_projects AS project ON line.id_project = project.id
|
||||||
WHERE line.id = :line_id;
|
WHERE line.id = :line_id;
|
||||||
:line_id = $_GET.immo_line_id|intval
|
:line_id = $_GET.immo_id|intval
|
||||||
assign=ligne_immo
|
assign=ligne_immo
|
||||||
}}
|
}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{:error message="Immobilisation %s non trouvée"|args:$_GET.immo_line_id}}
|
{{:error message="Immobilisation %s non trouvée"|args:$_GET.immo_id}}
|
||||||
{{/select}}
|
{{/select}}
|
||||||
{{:assign date_debut=$ligne_immo.date}}
|
{{:assign date_debut=$ligne_immo.date}}
|
||||||
{{:assign var="amort_label" value="Amortissement %s"|args:$ligne_immo.label}}
|
|
||||||
{{if $ligne_immo.line_label != null && $ligne_immo.line_label != $ligne_immo.label}}
|
|
||||||
{{:assign amort_label=$amort_label|cat:" — "|cat:$ligne_immo.line_label}}
|
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
{{#load type="immo" where="$$.line = :line_id" :line_id=$_GET.immo_line_id|intval}}
|
{{#load type="immo" where="$$.line = :line_id" :line_id=$_GET.immo_id|intval}}
|
||||||
{{:assign duree=$duration}}
|
{{:assign duree=$duration}}
|
||||||
{{:assign date_debut=$date}}
|
{{:assign date_debut=$date}}
|
||||||
{{:assign status=$status}}
|
{{if $amount != null}}
|
||||||
|
{{:assign var="ligne_immo.montant" value=$amount}}
|
||||||
|
{{/if}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{:error message="Vous devez renseigner la date de mise en service et la durée d'immobilisation"}}
|
{{:error message="Vous devez renseigner la date de mise en service et la durée d'immobilisation"}}
|
||||||
{{/load}}
|
{{/load}}
|
||||||
|
|
||||||
{{if $status == "amortized" || $status == "archived"}}
|
|
||||||
{{:error message="Cette immobilisation est complètement amortie ; il est impossible d'ajouter une écriture d'amortissement"}}
|
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
{{* chercher des écritures liées à l'immo courante au crédit du même compte
|
|
||||||
et déduire leur montant de celui de l'immo
|
|
||||||
*}}
|
|
||||||
{{:assign total_credits=0}}
|
|
||||||
{{#select
|
|
||||||
CASE links.id_related = :immo_trans_id
|
|
||||||
WHEN true THEN links.id_transaction
|
|
||||||
WHEN false THEN links.id_related
|
|
||||||
END as other_id,
|
|
||||||
line.credit
|
|
||||||
FROM acc_transactions AS trans
|
|
||||||
INNER JOIN acc_transactions_links as links
|
|
||||||
ON (trans.id = links.id_transaction OR trans.id = links.id_related)
|
|
||||||
INNER JOIN acc_transactions_lines AS line on line.id_transaction = other_id
|
|
||||||
INNER JOIN acc_accounts AS acc ON line.id_account = acc.id
|
|
||||||
WHERE trans.id = :immo_trans_id AND line.credit > 0 AND acc.code = :account;
|
|
||||||
:immo_trans_id=$ligne_immo.trans_id
|
|
||||||
:account=$ligne_immo.account_code
|
|
||||||
}}
|
|
||||||
{{:assign total_credits="%d+%d"|math:$total_credits:$credit}}
|
|
||||||
{{/select}}
|
|
||||||
{{:assign var="ligne_immo.montant" value="%d-%d"|math:$ligne_immo.montant:$total_credits}}
|
|
||||||
{{:assign solde=$ligne_immo.montant}}
|
|
||||||
|
|
||||||
{{* chercher des écritures d'amortissement liées à l'immobilisation *}}
|
{{* chercher des écritures d'amortissement liées à l'immobilisation *}}
|
||||||
{{#select
|
{{#select
|
||||||
l_amort.credit as amort_amount,
|
SUM(l_amort.credit) as amort_amount,
|
||||||
l_amort.label as amort_label,
|
l_amort.label as amort_label,
|
||||||
l_amort.id as amort_line_id,
|
l_amort.id as amort_line_id,
|
||||||
CASE WHEN links.id_related = t_immo.id
|
CASE WHEN links.id_related = t_immo.id
|
||||||
THEN links.id_transaction
|
THEN links.id_transaction
|
||||||
ELSE links.id_related
|
ELSE links.id_related
|
||||||
END as amort_trans_id,
|
END as amort_trans_id,
|
||||||
trans.date as amort_date,
|
MAX(trans.date) as amort_date,
|
||||||
|
COUNT(trans.id) as amort_number,
|
||||||
trans.label as trans_label,
|
trans.label as trans_label,
|
||||||
trans.id_year as amort_year,
|
trans.id_year as amort_year,
|
||||||
account.id as account_id,
|
account.id as account_id,
|
||||||
|
|
@ -86,48 +60,20 @@
|
||||||
FROM acc_transactions_lines as l_immo
|
FROM acc_transactions_lines as l_immo
|
||||||
INNER JOIN acc_transactions as t_immo on t_immo.id = l_immo.id_transaction
|
INNER JOIN acc_transactions as t_immo on t_immo.id = l_immo.id_transaction
|
||||||
INNER JOIN acc_transactions_links as links
|
INNER JOIN acc_transactions_links as links
|
||||||
ON (t_immo.id = links.id_transaction OR t_immo.id = links.id_related)
|
ON (t_immo.id = links.id_transaction
|
||||||
|
OR
|
||||||
|
t_immo.id = links.id_related)
|
||||||
INNER JOIN acc_transactions_lines as l_amort on amort_trans_id = l_amort.id_transaction
|
INNER JOIN acc_transactions_lines as l_amort on amort_trans_id = l_amort.id_transaction
|
||||||
INNER join acc_transactions as trans on l_amort.id_transaction = trans.id
|
INNER join acc_transactions as trans on l_amort.id_transaction = trans.id
|
||||||
INNER join acc_accounts as account on l_amort.id_account = account.id
|
INNER join acc_accounts as account on l_amort.id_account = account.id
|
||||||
WHERE
|
WHERE l_immo.id = :line_id AND account.code LIKE '28%'
|
||||||
l_immo.id = :line_id
|
ORDER BY trans.date DESC LIMIT 1;
|
||||||
AND account.code LIKE '28%'
|
:line_id = $_GET.immo_id|intval
|
||||||
ORDER BY trans.date;
|
assign=amort_line
|
||||||
:line_id = $_GET.immo_line_id|intval
|
|
||||||
assign="amort_line"
|
|
||||||
}}
|
}}
|
||||||
{{#load type="link"
|
|
||||||
where="$$.immo_line_id = :immo_line_id AND $$.amort_trans_id = :amort_trans_id"
|
|
||||||
order="$$.date"
|
|
||||||
assign="line"
|
|
||||||
:immo_line_id=$_GET.immo_line_id|intval :amort_trans_id=$amort_line.amort_trans_id
|
|
||||||
}}
|
|
||||||
{{if $line.amort_line_id == $amort_line.amort_line_id}}
|
|
||||||
{{:assign var="linked_amort." value=$amort_line}}
|
|
||||||
{{/if}}
|
|
||||||
{{else}}
|
|
||||||
{{:assign var="linked_amort." value=$amort_line}}
|
|
||||||
{{/load}}
|
|
||||||
{{/select}}
|
{{/select}}
|
||||||
|
|
||||||
|
{{if $amort_line.amort_number == 0}}
|
||||||
{{:assign total_amort=0}}
|
|
||||||
{{:assign valeur_residuelle=$ligne_immo.montant}}
|
|
||||||
{{#foreach from=$linked_amort}}
|
|
||||||
{{:assign valeur_residuelle="%d-%d"|math:$valeur_residuelle:$amort_amount}}
|
|
||||||
{{:assign total_amort="%d+%d"|math:$total_amort:$amort_amount}}
|
|
||||||
{{:assign date_debut=$amort_date}}
|
|
||||||
{{:assign code_amort=$account_code}}
|
|
||||||
{{:assign amort_account_label=$account_label}}
|
|
||||||
{{:assign amort_label=$amort_label}}
|
|
||||||
{{/foreach}}
|
|
||||||
|
|
||||||
{{if $valeur_residuelle == 0}}
|
|
||||||
{{:error message="Cette immobilisation est complètement amortie ; il est impossible d'ajouter une écriture d'amortissement"}}
|
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
{{if $total_amort == 0}}
|
|
||||||
{{* 1er amortissement *}}
|
{{* 1er amortissement *}}
|
||||||
{{* déterminer le compte d'amortissement en fonction du compte d'immobilisation *}}
|
{{* déterminer le compte d'amortissement en fonction du compte d'immobilisation *}}
|
||||||
{{#select code, label from acc_accounts where id = :id; :id=$ligne_immo.account_id assign=amort_account}}
|
{{#select code, label from acc_accounts where id = :id; :id=$ligne_immo.account_id assign=amort_account}}
|
||||||
|
|
@ -137,12 +83,15 @@
|
||||||
code_immo=$amort_account.code
|
code_immo=$amort_account.code
|
||||||
keep="code_amort"
|
keep="code_amort"
|
||||||
}}
|
}}
|
||||||
{{:assign var="amort_account_label" value="Amortissement %s"|args:$amort_account.label}}
|
{{:assign var=amort_label value="Amortissement %s"|args:$amort_account.label}}
|
||||||
{{:assign var=libelle value="Amortissement %s"|args:$ligne_immo.label}}
|
{{:assign var=libelle value="Amortissement %s"|args:$ligne_immo.label}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{* amortissements suivants *}}
|
{{* amortissements suivants *}}
|
||||||
{{:assign date_debut=$date_debut|strtotime}}
|
{{:assign date_debut=$amort_line.amort_date|strtotime}}
|
||||||
{{:assign date_debut="%d+(60*60*24)"|math:$date_debut|date:"Y-m-d"}}
|
{{:assign date_debut="%d+(60*60*24)"|math:$date_debut|date:"Y-m-d"}}
|
||||||
|
{{:assign var=code_amort value=$amort_line.account_code}}
|
||||||
|
{{:assign var=amort_label value=$amort_line.account_label}}
|
||||||
|
{{:assign var=libelle value=$amort_line.amort_label}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{*
|
{{*
|
||||||
|
|
@ -152,7 +101,7 @@
|
||||||
{{:assign msg_years=""}}
|
{{:assign msg_years=""}}
|
||||||
{{#years closed=false order="start_date" where="start_date <= :debut AND :debut <= end_date"
|
{{#years closed=false order="start_date" where="start_date <= :debut AND :debut <= end_date"
|
||||||
:debut=$date_debut assign=years.}}
|
:debut=$date_debut assign=years.}}
|
||||||
{{if $total_amort == 0}}
|
{{if $amort_line.amort_number == 0}}
|
||||||
{{:assign ts_debut=$date_debut|strtotime}}
|
{{:assign ts_debut=$date_debut|strtotime}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{:assign ts_debut=$start_date|strtotime}}
|
{{:assign ts_debut=$start_date|strtotime}}
|
||||||
|
|
@ -221,11 +170,11 @@
|
||||||
}}
|
}}
|
||||||
{{if $account_ok == null}}
|
{{if $account_ok == null}}
|
||||||
{{:assign compte=$credit_account|implode:""}}
|
{{:assign compte=$credit_account|implode:""}}
|
||||||
{{:redirect url="add_account.html?account=%s&chart=%s&immo_line_id=%s"|args:$compte:$selected_chart:$_GET.immo_line_id}}
|
{{:redirect url="add_account.html?account=%s&chart=%s&immo_id=%s"|args:$compte:$selected_chart:$_GET.immo_id}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{* vérifier que le montant ne dépasse pas le solde restant *}}
|
{{* vérifier que le montant ne dépasse pas le solde restant *}}
|
||||||
{{:assign solde="%d-%d"|math:$ligne_immo.montant:$total_amort}}
|
{{:assign solde="%d-%d"|math:$ligne_immo.montant:$amort_line.amort_amount}}
|
||||||
{{if $_POST.montant|trim|money_int > $solde|intval}}
|
{{if $_POST.montant|trim|money_int > $solde|intval}}
|
||||||
{{:assign solde=$solde|money_raw}}
|
{{:assign solde=$solde|money_raw}}
|
||||||
{{:error message="Le montant indiqué « %s » dépasse le solde à amortir « %s »"|args:$_POST.montant:$solde}}
|
{{:error message="Le montant indiqué « %s » dépasse le solde à amortir « %s »"|args:$_POST.montant:$solde}}
|
||||||
|
|
@ -235,15 +184,15 @@
|
||||||
{{:assign
|
{{:assign
|
||||||
var="lines."
|
var="lines."
|
||||||
debit=$_POST.montant
|
debit=$_POST.montant
|
||||||
account=$debit_account|keys|value:0
|
account=$debit_account|keys|key:0
|
||||||
id_project=$ligne_immo.project_id
|
id_project=$_GET.project_id
|
||||||
label=$_POST.designation
|
label=$_POST.designation
|
||||||
}}
|
}}
|
||||||
{{:assign
|
{{:assign
|
||||||
var="lines."
|
var="lines."
|
||||||
credit=$_POST.montant
|
credit=$_POST.montant
|
||||||
account=$credit_account|keys|value:0
|
account=$credit_account|keys|key:0
|
||||||
id_project=$ligne_immo.project_id
|
id_project=$_GET.project_id
|
||||||
label=$_POST.designation
|
label=$_POST.designation
|
||||||
}}
|
}}
|
||||||
{{:api
|
{{:api
|
||||||
|
|
@ -259,33 +208,10 @@
|
||||||
linked_transactions=$ligne_immo.trans_id|intval
|
linked_transactions=$ligne_immo.trans_id|intval
|
||||||
}}
|
}}
|
||||||
|
|
||||||
{{* enregistrer la liaison des lignes *}}
|
{{:redirect force="amortization.html?immo_id=%s&ok=1&msg=amortissement"|args:$_GET.immo_id}}
|
||||||
{{#select
|
|
||||||
trans.id AS trans_id,
|
|
||||||
line.id AS line_id
|
|
||||||
FROM acc_transactions AS trans
|
|
||||||
INNER JOIN acc_transactions_lines AS line ON line.id_transaction = trans.id
|
|
||||||
WHERE trans.id = :trans_id
|
|
||||||
;
|
|
||||||
:trans_id = $result.id
|
|
||||||
}}
|
|
||||||
{{:assign amort_trans_id=$trans_id}}
|
|
||||||
{{:assign amort_line_id=$line_id}}
|
|
||||||
{{/select}}
|
|
||||||
{{if $amort_trans_id != null}}
|
|
||||||
{{:save
|
|
||||||
key=""|uuid
|
|
||||||
type="link"
|
|
||||||
immo_line_id=$_GET.immo_line_id|intval
|
|
||||||
amort_line_id=$amort_line_id|intval
|
|
||||||
amort_trans_id=$result.id
|
|
||||||
}}
|
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
{{:redirect force="amortization.html?immo_line_id=%s&ok=1&msg=amortissement"|args:$_GET.immo_line_id}}
|
|
||||||
{{/form}}
|
{{/form}}
|
||||||
|
|
||||||
{{:admin_header title="Ajout amortissement" custom_css="./style.css" current="module_amortization"}}
|
{{:admin_header title="Ajout amortissement" current="module_amortization"}}
|
||||||
|
|
||||||
{{* barre de navigation *}}
|
{{* barre de navigation *}}
|
||||||
{{if ! $dialog}}
|
{{if ! $dialog}}
|
||||||
|
|
@ -300,9 +226,9 @@
|
||||||
|
|
||||||
{{* montant de l'amortissement *}}
|
{{* montant de l'amortissement *}}
|
||||||
{{:assign montant_amort="%f/%f/365*%d"|math:$ligne_immo.montant:$duree:$nbjours|intval}}
|
{{:assign montant_amort="%f/%f/365*%d"|math:$ligne_immo.montant:$duree:$nbjours|intval}}
|
||||||
{{:assign montant_amort="min(%f, %d-%d)"|math:$montant_amort:$ligne_immo.montant:$total_amort}}
|
{{:assign montant_amort="min(%f, %d-%d)"|math:$montant_amort:$ligne_immo.montant:$amort_line.amort_amount}}
|
||||||
{{:assign var="debit_account.6811" value="6811 — Dot. aux amortissements des immobilisations"}}
|
{{:assign var="debit_account.6811" value="6811 — Dot. aux amortissements des immobilisations"}}
|
||||||
{{:assign var="credit_account.%s"|args:$code_amort value="%s — "|args:$code_amort|cat:$amort_account_label}}
|
{{:assign var="credit_account.%s"|args:$code_amort value="%s — "|args:$code_amort|cat:$amort_label}}
|
||||||
|
|
||||||
{{* -------------------------------------------------------------------------------- *}}
|
{{* -------------------------------------------------------------------------------- *}}
|
||||||
|
|
||||||
|
|
@ -316,7 +242,7 @@
|
||||||
<dl>
|
<dl>
|
||||||
{{:input type="select" default=$selected_year name="id_year" label="Exercice" required=true default_empty="— Faire un choix —" options=$open_years}}
|
{{:input type="select" default=$selected_year name="id_year" label="Exercice" required=true default_empty="— Faire un choix —" options=$open_years}}
|
||||||
{{:input type="date" name="date_amort" label="Date" required=true default=$date_amort|date_short}}
|
{{:input type="date" name="date_amort" label="Date" required=true default=$date_amort|date_short}}
|
||||||
{{:input type="text" name="designation" label="Libellé" required=true default=$amort_label size="50"}}
|
{{:input type="text" name="designation" label="Libellé" required=true default=$libelle}}
|
||||||
{{:input type="money" name="montant" label="Montant" required=true default=$montant_amort}}
|
{{:input type="money" name="montant" label="Montant" required=true default=$montant_amort}}
|
||||||
{{:input
|
{{:input
|
||||||
type="list"
|
type="list"
|
||||||
|
|
@ -337,7 +263,7 @@
|
||||||
<div id="donnees" class="hidden">
|
<div id="donnees" class="hidden">
|
||||||
{{:input type="text" name="montant_immo" default=$ligne_immo.montant}}
|
{{:input type="text" name="montant_immo" default=$ligne_immo.montant}}
|
||||||
{{:input type="text" name="duree_amort" default=$duree}}
|
{{:input type="text" name="duree_amort" default=$duree}}
|
||||||
{{:input type="text" name="somme_amort" default=$total_amort}}
|
{{:input type="text" name="somme_amort" default=$amort_line.amort_amount}}
|
||||||
{{:input type="select" name="years_data" options=$years_data}}
|
{{:input type="select" name="years_data" options=$years_data}}
|
||||||
</div>
|
</div>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,3 @@ table.list tbody tr.ignored:nth-child(even) {
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
background: rgba(255, 255, 200, 0.5);
|
background: rgba(255, 255, 200, 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
html.dialog.dark {
|
|
||||||
filter: none !important;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
{{* -*- brindille -*- *}}
|
{{* -*- brindille -*- *}}
|
||||||
|
|
||||||
|
{{:admin_header title="Transfert d'immobilisation en cours" custom_css="./style.css" current="module_amortization"}}
|
||||||
{{:include file="_get_config.html" keep="module.config.prefixes"}}
|
{{:include file="_get_config.html" keep="module.config.prefixes"}}
|
||||||
|
|
||||||
{{#years closed=false order="start_date" assign=years.}}
|
{{#years closed=false order="start_date" assign=years.}}
|
||||||
|
|
@ -109,7 +110,7 @@
|
||||||
account=$elem
|
account=$elem
|
||||||
keep="account_code"
|
keep="account_code"
|
||||||
}}
|
}}
|
||||||
{{:assign debit_account=$account_code|keys|value:0}}
|
{{:assign debit_account=$account_code|keys|key:0}}
|
||||||
{{:assign var="amount" from="_POST.credit_lines.%s"|args:$rang}}
|
{{:assign var="amount" from="_POST.credit_lines.%s"|args:$rang}}
|
||||||
{{:assign var="label" from="_POST.line_labels.%s"|args:$rang}}
|
{{:assign var="label" from="_POST.line_labels.%s"|args:$rang}}
|
||||||
{{:assign
|
{{:assign
|
||||||
|
|
@ -126,7 +127,7 @@
|
||||||
account=$_POST.debit_account
|
account=$_POST.debit_account
|
||||||
keep="account_code"
|
keep="account_code"
|
||||||
}}
|
}}
|
||||||
{{:assign credit_account=$account_code|keys|value:0}}
|
{{:assign credit_account=$account_code|keys|key:0}}
|
||||||
{{:assign var="amount" from="_POST.debit_lines.%s"|args:0}}
|
{{:assign var="amount" from="_POST.debit_lines.%s"|args:0}}
|
||||||
{{:assign count=$_POST.line_labels|count}}
|
{{:assign count=$_POST.line_labels|count}}
|
||||||
{{:assign count="%d-1"|math:$count}}
|
{{:assign count="%d-1"|math:$count}}
|
||||||
|
|
@ -157,7 +158,7 @@
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{* écritures liées *}}
|
{{* écritures liées *}}
|
||||||
{{:assign var="linked_transactions" value=$transactions|keys}}
|
{{:assign var="linked_transactions" value=$_GET.trans|explode:","}}
|
||||||
|
|
||||||
{{* enregistrer l'écriture *}}
|
{{* enregistrer l'écriture *}}
|
||||||
{{:api
|
{{:api
|
||||||
|
|
@ -174,13 +175,13 @@
|
||||||
|
|
||||||
{{:assign lines_count=$lines|count}}
|
{{:assign lines_count=$lines|count}}
|
||||||
{{:assign lines_count="%d-1"|math:$lines_count}}
|
{{:assign lines_count="%d-1"|math:$lines_count}}
|
||||||
{{:assign var="immo_line_id" from="result.lines.%s.id"|args:$lines_count}}
|
{{:assign var="immo_id" from="result.lines.%s.id"|args:$lines_count}}
|
||||||
{{* enregistrer les infos de l'immobilisation *}}
|
{{* enregistrer les infos de l'immobilisation *}}
|
||||||
{{:save
|
{{:save
|
||||||
key=""|uuid
|
key=""|uuid
|
||||||
validate_schema="schema.json"
|
validate_schema="schema.json"
|
||||||
type="immo"
|
type="immo"
|
||||||
line=$immo_line_id
|
line=$immo_id
|
||||||
duration=$duration
|
duration=$duration
|
||||||
date=$date_debut
|
date=$date_debut
|
||||||
status=$status
|
status=$status
|
||||||
|
|
@ -193,7 +194,7 @@
|
||||||
{{:redirect force="index.html?ok=1&msg=immobilisation&type_immo=%s"|args:$type_immo}}
|
{{:redirect force="index.html?ok=1&msg=immobilisation&type_immo=%s"|args:$type_immo}}
|
||||||
{{/form}}
|
{{/form}}
|
||||||
|
|
||||||
{{:admin_header title="Transfert d'immobilisation en cours" custom_css="./style.css" current="module_amortization"}}
|
{{* barre de navigation *}}
|
||||||
{{if ! $dialog}}
|
{{if ! $dialog}}
|
||||||
{{:include file="_nav.html" current="index" subcurrent="unfinished" subsubcurrent="transfer"}}
|
{{:include file="_nav.html" current="index" subcurrent="unfinished" subsubcurrent="transfer"}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
{{*
|
{{*
|
||||||
Enregistrer les écritures de sortie du bilan
|
Enregistrer les écritures de sortie du bilan
|
||||||
paramètres :
|
paramètres :
|
||||||
- immo_line_id : numéro de ligne de l'écriture d'immobilisation
|
- immo_id : numéro de ligne de l'écriture d'immobilisation
|
||||||
- amort_amount : montant des amortissements
|
- amort_amount : montant des amortissements
|
||||||
- year : exercice de la date de sortie de l'immobilisation
|
- year : exercice de la date de sortie de l'immobilisation
|
||||||
- date_mes : date de mise en service de l'immobilisation
|
- date_mes : date de mise en service de l'immobilisation
|
||||||
|
|
@ -16,42 +16,25 @@
|
||||||
{{#select
|
{{#select
|
||||||
line.debit as montant,
|
line.debit as montant,
|
||||||
line.id_transaction,
|
line.id_transaction,
|
||||||
trans.id AS trans_id,
|
line.id_account,
|
||||||
trans.date as date_achat,
|
trans.date as date_achat,
|
||||||
trans.label,
|
trans.label,
|
||||||
acc.code as account_code,
|
acc.code,
|
||||||
id_project
|
id_project
|
||||||
FROM acc_transactions_lines AS line
|
FROM acc_transactions_lines AS line
|
||||||
INNER JOIN acc_transactions AS trans ON line.id_transaction = trans.id
|
INNER JOIN acc_transactions AS trans ON line.id_transaction = trans.id
|
||||||
INNER JOIN acc_accounts AS acc ON line.id_account = acc.id
|
INNER JOIN acc_accounts AS acc ON line.id_account = acc.id
|
||||||
WHERE line.id = :immo_line_id;
|
WHERE line.id = :immo_id;
|
||||||
:immo_line_id = $_GET.immo_line_id|intval
|
:immo_id = $_GET.immo_id|intval
|
||||||
assign="ligne_immo"
|
assign="ligne_immo"
|
||||||
}}
|
}}
|
||||||
{{/select}}
|
{{/select}}
|
||||||
|
|
||||||
{{* chercher des écritures liées à l'immo courante au crédit du même compte
|
{{#load type="immo" assign="info_immo" where="$$.line = :line_id" :line_id=$_GET.immo_id|intval}}
|
||||||
et déduire leur montant de celui de l'immo
|
{{if $amount != null}}
|
||||||
*}}
|
{{:assign var="ligne_immo.montant" value=$amount}}
|
||||||
{{:assign total_credits=0}}
|
{{/if}}
|
||||||
{{#select
|
{{/load}}
|
||||||
CASE links.id_related = :immo_trans_id
|
|
||||||
WHEN true THEN links.id_transaction
|
|
||||||
WHEN false THEN links.id_related
|
|
||||||
END as other_id,
|
|
||||||
line.credit
|
|
||||||
FROM acc_transactions AS trans
|
|
||||||
INNER JOIN acc_transactions_links as links
|
|
||||||
ON (trans.id = links.id_transaction OR trans.id = links.id_related)
|
|
||||||
INNER JOIN acc_transactions_lines AS line on line.id_transaction = other_id
|
|
||||||
INNER JOIN acc_accounts AS acc ON line.id_account = acc.id
|
|
||||||
WHERE trans.id = :immo_trans_id AND line.credit > 0 AND acc.code = :account;
|
|
||||||
:immo_trans_id=$ligne_immo.trans_id
|
|
||||||
:account=$ligne_immo.account_code
|
|
||||||
}}
|
|
||||||
{{:assign total_credits="%d+%d"|math:$total_credits:$credit}}
|
|
||||||
{{/select}}
|
|
||||||
{{:assign var="ligne_immo.montant" value="%d-%d"|math:$ligne_immo.montant:$total_credits}}
|
|
||||||
|
|
||||||
{{:assign valeur_nette="%f-%f"|math:$ligne_immo.montant:$_GET.amort_amount}}
|
{{:assign valeur_nette="%f-%f"|math:$ligne_immo.montant:$_GET.amort_amount}}
|
||||||
{{:assign amort_comp=0}} {{* amortissement complémentaire jqà date sortie *}}
|
{{:assign amort_comp=0}} {{* amortissement complémentaire jqà date sortie *}}
|
||||||
|
|
@ -93,7 +76,7 @@
|
||||||
account=$account
|
account=$account
|
||||||
keep="account_code"
|
keep="account_code"
|
||||||
}}
|
}}
|
||||||
{{:assign amort_account_code=$account_code|keys|value:0}}
|
{{:assign amort_account_code=$account_code|keys|key:0}}
|
||||||
|
|
||||||
{{if $valeur_nette > 0}}
|
{{if $valeur_nette > 0}}
|
||||||
{{* immo non totalement amortie *}}
|
{{* immo non totalement amortie *}}
|
||||||
|
|
@ -104,7 +87,7 @@
|
||||||
account=$_POST.comp_account
|
account=$_POST.comp_account
|
||||||
keep="account_code"
|
keep="account_code"
|
||||||
}}
|
}}
|
||||||
{{:assign comp_account_code=$account_code|keys|value:0}}
|
{{:assign comp_account_code=$account_code|keys|key:0}}
|
||||||
|
|
||||||
{{:assign libelle="Amortissement complémentaire "|cat:$ligne_immo.label}}
|
{{:assign libelle="Amortissement complémentaire "|cat:$ligne_immo.label}}
|
||||||
{{:assign
|
{{:assign
|
||||||
|
|
@ -130,7 +113,7 @@
|
||||||
account=$_POST.except_account
|
account=$_POST.except_account
|
||||||
keep="account_code"
|
keep="account_code"
|
||||||
}}
|
}}
|
||||||
{{:assign except_account_code=$account_code|keys|value:0}}
|
{{:assign except_account_code=$account_code|keys|key:0}}
|
||||||
{{:assign libelle="Amortissement exceptionnel "|cat:$ligne_immo.label}}
|
{{:assign libelle="Amortissement exceptionnel "|cat:$ligne_immo.label}}
|
||||||
{{:assign
|
{{:assign
|
||||||
var="lines."
|
var="lines."
|
||||||
|
|
@ -170,7 +153,7 @@
|
||||||
account=$_POST.immo_account
|
account=$_POST.immo_account
|
||||||
keep="account_code"
|
keep="account_code"
|
||||||
}}
|
}}
|
||||||
{{:assign immo_account_code=$account_code|keys|value:0}}
|
{{:assign immo_account_code=$account_code|keys|key:0}}
|
||||||
{{:assign libelle="Sortie du bilan de "|cat:$ligne_immo.label}}
|
{{:assign libelle="Sortie du bilan de "|cat:$ligne_immo.label}}
|
||||||
{{:assign
|
{{:assign
|
||||||
var="lines."
|
var="lines."
|
||||||
|
|
@ -192,7 +175,7 @@
|
||||||
account=$_POST.vnc_account
|
account=$_POST.vnc_account
|
||||||
keep="account_code"
|
keep="account_code"
|
||||||
}}
|
}}
|
||||||
{{:assign vnc_account_code=$account_code|keys|value:0}}
|
{{:assign vnc_account_code=$account_code|keys|key:0}}
|
||||||
{{:assign
|
{{:assign
|
||||||
var="lines."
|
var="lines."
|
||||||
account=$vnc_account_code
|
account=$vnc_account_code
|
||||||
|
|
@ -223,13 +206,13 @@
|
||||||
account=$_POST.creance_account
|
account=$_POST.creance_account
|
||||||
keep="account_code"
|
keep="account_code"
|
||||||
}}
|
}}
|
||||||
{{:assign creance_account=$account_code|keys|value:0}}
|
{{:assign creance_account=$account_code|keys|key:0}}
|
||||||
{{:include
|
{{:include
|
||||||
file="_get_codes.html"
|
file="_get_codes.html"
|
||||||
account=$_POST.cession_account
|
account=$_POST.cession_account
|
||||||
keep="account_code"
|
keep="account_code"
|
||||||
}}
|
}}
|
||||||
{{:assign cession_account=$account_code|keys|value:0}}
|
{{:assign cession_account=$account_code|keys|key:0}}
|
||||||
{{:api
|
{{:api
|
||||||
method="POST"
|
method="POST"
|
||||||
path="accounting/transaction"
|
path="accounting/transaction"
|
||||||
|
|
@ -258,7 +241,7 @@
|
||||||
key=""|uuid
|
key=""|uuid
|
||||||
validate_schema="schema.json"
|
validate_schema="schema.json"
|
||||||
type="immo"
|
type="immo"
|
||||||
line=$_GET.immo_line_id|intval
|
line=$_GET.immo_id|intval
|
||||||
duration=$_GET.duree_amort|intval
|
duration=$_GET.duree_amort|intval
|
||||||
date=$_GET.date_mes|date:"Y-m-d"
|
date=$_GET.date_mes|date:"Y-m-d"
|
||||||
status="archived"
|
status="archived"
|
||||||
|
|
@ -282,11 +265,14 @@
|
||||||
|
|
||||||
{{:include
|
{{:include
|
||||||
file="./_get_amort_code.html"
|
file="./_get_amort_code.html"
|
||||||
code_immo=$ligne_immo.account_code
|
code_immo=$ligne_immo.code
|
||||||
keep="code_amort"
|
keep="code_amort"
|
||||||
}}
|
}}
|
||||||
|
|
||||||
{{* numéros de comptes ; voir info.org *}}
|
{{*
|
||||||
|
Utilisation des « anciens » numéros de comptes because conflit
|
||||||
|
avec les nouveaux numéros ; voir info.org
|
||||||
|
*}}
|
||||||
{{:assign vnc_code="652"}}
|
{{:assign vnc_code="652"}}
|
||||||
{{:assign cession_code="757"}}
|
{{:assign cession_code="757"}}
|
||||||
|
|
||||||
|
|
@ -294,7 +280,7 @@
|
||||||
{{:assign var="liste_codes.687" name="except_account"}}
|
{{:assign var="liste_codes.687" name="except_account"}}
|
||||||
{{:assign var="liste_codes.462" name="creance_account"}}
|
{{:assign var="liste_codes.462" name="creance_account"}}
|
||||||
{{:assign var="liste_codes.%s"|args:$code_amort name="amort_account"}}
|
{{:assign var="liste_codes.%s"|args:$code_amort name="amort_account"}}
|
||||||
{{:assign var="liste_codes.%s"|args:$ligne_immo.account_code name="immo_account"}}
|
{{:assign var="liste_codes.%s"|args:$ligne_immo.code name="immo_account"}}
|
||||||
{{:assign var="liste_codes.%s"|args:$vnc_code name="vnc_account"}}
|
{{:assign var="liste_codes.%s"|args:$vnc_code name="vnc_account"}}
|
||||||
{{:assign var="liste_codes.%s"|args:$cession_code name="cession_account"}}
|
{{:assign var="liste_codes.%s"|args:$cession_code name="cession_account"}}
|
||||||
{{:assign condition=$liste_codes|keys|implode:","}}
|
{{:assign condition=$liste_codes|keys|implode:","}}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue