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.date as trans_date,
|
||||
trans.id_year as trans_id_year,
|
||||
line.id as immo_line_id,
|
||||
line.label as line_label,
|
||||
line.id as immo_id,
|
||||
line.debit AS debit,
|
||||
account.id as account_id,
|
||||
account.code as account_code,
|
||||
|
|
@ -67,10 +66,12 @@
|
|||
!condition=$condition
|
||||
}}
|
||||
{{:assign montant_immo=$debit}}
|
||||
|
||||
{{* 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}}
|
||||
{{if $amount != null}}
|
||||
{{:assign montant_immo=$amount}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{:assign amortissable="nsp"}}
|
||||
{{:assign status="unknown"}}
|
||||
|
|
@ -79,48 +80,32 @@
|
|||
{{:continue}}
|
||||
{{/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 solde_immo=$montant_immo}}
|
||||
{{:assign credit_immo=null}}
|
||||
{{* voir s'il existe une écriture liée qui solde l'immobilisation *}}
|
||||
{{#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,
|
||||
MAX(trans2.date) as exit_date
|
||||
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
|
||||
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
|
||||
trans.date as exit_date
|
||||
FROM acc_transactions_links AS link
|
||||
INNER JOIN acc_transactions AS trans ON
|
||||
(CASE
|
||||
WHEN link.id_transaction = :trans_id THEN link.id_related
|
||||
WHEN link.id_related = :trans_id THEN link.id_transaction
|
||||
END) = trans.id
|
||||
INNER JOIN acc_transactions_lines AS line ON line.id_transaction = trans.id
|
||||
INNER JOIN acc_accounts AS acc on line.id_account=acc.id
|
||||
WHERE line.credit = :montant_immo
|
||||
AND acc.code = :account_code
|
||||
;
|
||||
:immo_trans_id=$trans_id
|
||||
:account=$account_code
|
||||
assign="credit_immo."
|
||||
:trans_id = $trans_id
|
||||
:montant_immo = $montant_immo
|
||||
:account_code = $account_code
|
||||
}}
|
||||
{{:assign solde_immo="%d-%d"|math:$solde_immo:$credit}}
|
||||
{{:assign status="archived"}}
|
||||
{{:assign exit_date=$exit_date}}
|
||||
{{/select}}
|
||||
|
||||
{{if $solde_immo == 0}}
|
||||
{{:assign status="archived"}}
|
||||
{{/if}}
|
||||
|
||||
{{if $status != "archived"}}
|
||||
{{:continue}}
|
||||
{{/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 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}}
|
||||
|
|
@ -131,7 +116,12 @@
|
|||
{{* voir s'il y a une écriture de cession associée à cette immo *}}
|
||||
{{#select
|
||||
trans.id,
|
||||
line.debit
|
||||
trans.label,
|
||||
trans.date,
|
||||
line.id,
|
||||
line.debit,
|
||||
acc.code,
|
||||
acc.label
|
||||
FROM acc_transactions_links AS link
|
||||
INNER JOIN acc_transactions AS trans ON (CASE
|
||||
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>{{$trans_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><a href={{$compte_url}}>{{$account_code}}</a></td>
|
||||
<td>{{$account_label}}</td>
|
||||
|
|
@ -164,9 +154,6 @@
|
|||
</tbody>
|
||||
<tfoot>
|
||||
{{if $total_immo != 0}}
|
||||
<tr>
|
||||
<td colspan="9">
|
||||
</tr>
|
||||
{{#foreach from=$sommes_immo|ksort key="code" item="value"}}
|
||||
<tr>
|
||||
<td></td>
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
{{/foreach}}
|
||||
{{:assign condition=$condition|cat:"0)"}}
|
||||
|
||||
{{:assign account_code=$account|keys|value:0}}
|
||||
{{:assign account_code=$account|keys|key:0}}
|
||||
{{#sql
|
||||
select="code"
|
||||
tables="acc_accounts"
|
||||
|
|
|
|||
|
|
@ -7,8 +7,7 @@
|
|||
la forme : code — libellé
|
||||
*}}
|
||||
|
||||
{{:assign values=$account|values}}
|
||||
{{:assign label=$values.0}}
|
||||
{{:assign label=$account|values|key:0}}
|
||||
{{:assign pos=$label|strpos:" "}}
|
||||
{{:assign account_code=$label|substr:0:$pos}}
|
||||
{{:assign var="account_code.%s"|args:$account_code value=$label}}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
{{* -*- 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">
|
||||
|
||||
<p class="help">
|
||||
|
|
@ -29,190 +28,145 @@
|
|||
</thead>
|
||||
<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 *}}
|
||||
{{:include file="_get_config.html" keep="module.config"}}
|
||||
|
||||
{{:assign account_condition="("}}
|
||||
{{#foreach from=$module.config.prefixes item="code"}}
|
||||
{{:assign code=$code|cat:"%"|quote_sql}}
|
||||
{{:assign account_condition=$account_condition|cat:" account.code LIKE "|cat:$code|cat:" OR "}}
|
||||
{{/foreach}}
|
||||
{{:assign account_condition=$account_condition|cat:"0)"}}
|
||||
{{:assign doc_condition="($$.status <> 'ignored' AND $$.status <> 'archived')"}}
|
||||
|
||||
{{:assign filter_condition="NOT ("}}
|
||||
{{:assign filter_condition=" AND NOT ("}}
|
||||
{{#foreach from=$module.config.filters item="filter"}}
|
||||
{{:assign filter="%"|cat:$filter|cat:"%"|quote_sql}}
|
||||
{{:assign filter_condition=$filter_condition|cat:" trans_label LIKE "|cat:$filter|cat:" OR "}}
|
||||
{{/foreach}}
|
||||
{{:assign filter_condition=$filter_condition|cat:"0)"}}
|
||||
{{:assign 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 total_immo = 0}}
|
||||
{{#select
|
||||
trans.id as immo_trans_id,
|
||||
trans.id as trans_id,
|
||||
trans.label as trans_label,
|
||||
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.code as account_code,
|
||||
trans.id_year as trans_id_year,
|
||||
$$.duration as duration,
|
||||
$$.status as status
|
||||
account.label as account_label,
|
||||
trans.id_year as trans_id_year
|
||||
FROM acc_transactions AS trans
|
||||
INNER JOIN acc_transactions_lines AS line ON line.id_transaction = trans.id
|
||||
INNER JOIN acc_accounts AS account ON line.id_account = account.id
|
||||
INNER JOIN acc_years AS years ON trans.id_year = years.id
|
||||
LEFT JOIN !table AS info ON $$.line = line.id
|
||||
WHERE !condition
|
||||
ORDER BY trans.date DESC;
|
||||
!table=$module.table
|
||||
!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 duration=$duration}}
|
||||
{{:assign duration=null}}
|
||||
{{:assign montant_immo=$debit}}
|
||||
{{if $status == null}}
|
||||
{{:assign status="unknown"}}
|
||||
|
||||
{{* 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}}
|
||||
|
||||
{{* 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}}
|
||||
{{else}}
|
||||
{{:assign amortissable="nsp"}}
|
||||
{{:assign status="unknown"}}
|
||||
{{/load}}
|
||||
{{if $status == "ignored"}}
|
||||
{{:continue}}
|
||||
{{/if}}
|
||||
|
||||
{{* lister les lignes des écritures d'amortissement liées à l'immobilisation *}}
|
||||
{{:assign amort_lines=null}}
|
||||
{{* voir s'il existe une écriture qui solde l'immobilisation *}}
|
||||
{{#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
|
||||
WHEN true THEN links.id_transaction
|
||||
WHEN false THEN links.id_related
|
||||
END as amort_trans_id,
|
||||
l_amort.id AS amort_line_id
|
||||
END as amort_trans_id
|
||||
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_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_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%';
|
||||
:line_id = $immo_line_id|intval
|
||||
assign="line"
|
||||
WHERE
|
||||
l_immo.id = :line_id
|
||||
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}}
|
||||
{{/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}}
|
||||
{{if $amort_amount == null}}
|
||||
{{:assign exist_amort=false}}
|
||||
{{:assign amort_amount=0}}
|
||||
{{else}}
|
||||
{{:assign exist_amort=true}}
|
||||
{{:assign amort_amount=$amort_amount}}
|
||||
{{/if}}
|
||||
{{/select}}
|
||||
|
||||
{{* classement par onglet *}}
|
||||
{{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 $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 total_immo="%d+%d"|math:$total_immo:$montant_immo}}
|
||||
{{:assign var="montant" from="sommes_immo.%s"|args:$account_code}}
|
||||
{{:assign var="sommes_immo.%s"|args:$account_code value="%d+%d"|math:$montant:$montant_immo}}
|
||||
<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_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">{{if $duration != null}}{{$duration}}{{/if}}</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><a href={{$compte_url}}>{{$account_code}}</a></td>
|
||||
<td class="actions">
|
||||
{{if ! $exist_amort || $status == "unknown"}}
|
||||
{{:linkbutton
|
||||
label="Paramètres"
|
||||
href="add_infos.html?immo_line_id=%s&type_immo=%s"|args:$immo_line_id:$type_immo
|
||||
href="add_infos.html?immo_id=%s&type_immo=%s"|args:$immo_id:$type_immo
|
||||
shape="settings"
|
||||
target="_dialog"
|
||||
}}
|
||||
{{* target="_dialog"*}}
|
||||
{{/if}}
|
||||
{{:linkbutton
|
||||
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"
|
||||
}}
|
||||
</td>
|
||||
|
|
@ -221,9 +175,6 @@
|
|||
</tbody>
|
||||
<tfoot>
|
||||
{{if $total_immo != 0}}
|
||||
<tr>
|
||||
<td colspan="9">
|
||||
</tr>
|
||||
{{#foreach from=$sommes_immo|ksort key="code" item="value"}}
|
||||
<tr>
|
||||
<td></td>
|
||||
|
|
@ -250,9 +201,8 @@
|
|||
</tr>
|
||||
{{/if}}
|
||||
</tfoot>
|
||||
{{/if}}
|
||||
</table>
|
||||
{{if $nb_immo == 0 || ! $table_presente}}
|
||||
{{if $nb_immo == 0}}
|
||||
<p class="block alert">Aucune immobilisation</p>
|
||||
{{/if}}
|
||||
</section>
|
||||
|
|
|
|||
|
|
@ -2,27 +2,22 @@
|
|||
|
||||
{{* Liste des immobilisations non amortissables ou non (encore) gérées *}}
|
||||
|
||||
{{:include file="_get_config.html" keep="module.config"}}
|
||||
<section class="immobilisation">
|
||||
|
||||
<p class="help">
|
||||
Cette page liste les écritures pas (encore) prises en charge par le module et sans écriture d'amortissement associée.
|
||||
</p>
|
||||
|
||||
{{:assign saved_hides=$module.config.hides}}
|
||||
{{:assign var="user_hides" from="saved_hides.%s"|args:$logged_user.id}}
|
||||
|
||||
{{:include file="_get_config.html" keep="module.config"}}
|
||||
{{if $_POST|count == 0}}
|
||||
{{:assign unhide=$user_hides.unhide_other}}
|
||||
{{:assign unhide=$module.config.unhide_other}}
|
||||
{{else}}
|
||||
{{if $_POST.unhide == null}}
|
||||
{{:assign unhide=0}}
|
||||
{{else}}
|
||||
{{:assign unhide=1}}
|
||||
{{/if}}
|
||||
{{:assign var="user_hides.unhide_other" value=$unhide"}}
|
||||
{{:assign var="saved_hides.%s"|args:$logged_user.id value=$user_hides}}
|
||||
{{:save key="config" hides=$saved_hides}}
|
||||
{{:save key="config" unhide_other=$unhide}}
|
||||
{{/if}}
|
||||
{{if $unhide}}
|
||||
{{:assign checked="checked"}}
|
||||
|
|
@ -30,14 +25,14 @@
|
|||
|
||||
<form method="post" action="">
|
||||
<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>
|
||||
</form>
|
||||
|
||||
<table class="list">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="num">N°</th>
|
||||
<th>N°</th>
|
||||
<th>Date</th>
|
||||
<th>Libellé</th>
|
||||
<th class="nombre">Montant</th>
|
||||
|
|
@ -48,72 +43,55 @@
|
|||
</thead>
|
||||
<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 *}}
|
||||
{{:assign account_condition="("}}
|
||||
{{:assign condition="("}}
|
||||
{{#foreach from=$module.config.prefixes item="code"}}
|
||||
{{:assign code=$code|cat:"%"|quote_sql}}
|
||||
{{:assign account_condition=$account_condition|cat:" account.code LIKE "|cat:$code|cat:" OR "}}
|
||||
{{:assign condition=$condition|cat:" account.code LIKE "|cat:$code|cat:" OR "}}
|
||||
{{/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}}
|
||||
{{:assign filter_condition="NOT ("}}
|
||||
{{*:assign condition=$condition|cat:" AND NOT (trans.status & 16)"*}}
|
||||
|
||||
{{: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"}}
|
||||
{{:assign condition=$condition|cat:" AND "|cat:$filter_condition}}
|
||||
{{/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}}
|
||||
{{#select
|
||||
trans.id as immo_trans_id,
|
||||
trans.id as trans_id,
|
||||
trans.label as trans_label,
|
||||
trans.date as trans_date,
|
||||
line.id as immo_line_id,
|
||||
line.debit AS debit,
|
||||
line.label AS line_label,
|
||||
line.id as immo_id,
|
||||
account.id as account_id,
|
||||
account.code as account_code,
|
||||
account.label as account_label,
|
||||
!columns
|
||||
line.debit AS debit,
|
||||
trans.id_year as trans_id_year
|
||||
FROM acc_transactions AS trans
|
||||
INNER JOIN acc_transactions_lines AS line ON line.id_transaction = trans.id
|
||||
INNER JOIN acc_accounts AS account ON line.id_account = account.id
|
||||
INNER JOIN acc_years AS years ON trans.id_year = years.id
|
||||
!table_join
|
||||
WHERE !condition
|
||||
ORDER BY trans.date DESC;
|
||||
!columns=$columns
|
||||
!table_join=$table_join
|
||||
!table=$module.table
|
||||
!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}}
|
||||
|
||||
{{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"}}
|
||||
{{/if}}
|
||||
{{/load}}
|
||||
|
||||
{{if $unhide == null}}
|
||||
{{if $status != "unknown"}}
|
||||
|
|
@ -131,60 +109,62 @@
|
|||
{{/foreach}}
|
||||
{{/if}}
|
||||
|
||||
{{* lister les lignes des écritures d'amortissement liées à l'immobilisation *}}
|
||||
{{:assign amort_lines=null}}
|
||||
{{* voir s'il existe des écritures d'amortissement associées *}}
|
||||
{{#select
|
||||
l_amort.credit as amort_amount,
|
||||
sum(l_amort.credit) as amort_amount,
|
||||
CASE links.id_related = t_immo.id
|
||||
WHEN true THEN links.id_transaction
|
||||
WHEN false THEN links.id_related
|
||||
END as amort_trans_id,
|
||||
l_amort.id AS amort_line_id
|
||||
END as amort_trans_id
|
||||
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_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_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%';
|
||||
:line_id = $immo_line_id|intval
|
||||
assign="amort_lines."
|
||||
WHERE
|
||||
l_immo.id = :line_id
|
||||
AND
|
||||
l_amort.credit <> 0
|
||||
AND
|
||||
account.code LIKE '28%';
|
||||
:line_id = $immo_id|intval
|
||||
}}
|
||||
{{/select}}
|
||||
{{:assign amort_amount=0}}
|
||||
{{#foreach from=$amort_lines item="line"}}
|
||||
{{* voir s'il existe un doc associé à l'écriture d'amortissement *}}
|
||||
{{#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 = $immo_line_id
|
||||
:amort_trans_id = $line.amort_trans_id
|
||||
:amort_line_id = $line.amort_line_id
|
||||
}}
|
||||
{{:assign amort_amount="%d+%d"|math:$amort_amount:$line.amount}}
|
||||
{{if $amort_amount != null}}
|
||||
{{:assign ignore=true}}
|
||||
{{else}}
|
||||
{{* TODO À VÉRIFIER (cas multi-lignes) *}}
|
||||
{{:assign amort_amount="%d+%d"|math:$amort_amount:$line.amount}}
|
||||
{{/load}}
|
||||
{{/foreach}}
|
||||
{{if $amort_amount != 0}}
|
||||
{{:assign ignore=false}}
|
||||
{{/if}}
|
||||
{{/select}}
|
||||
|
||||
{{if $ignore}}
|
||||
{{:continue}}
|
||||
{{/if}}
|
||||
|
||||
{{:assign nb_immo="%d+1"|math:$nb_immo}}
|
||||
|
||||
<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_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><a href={{$compte_url}}>{{$account_code}}</a></td>
|
||||
<td>{{$account_label}}</td>
|
||||
<td class="actions">
|
||||
{{:linkbutton
|
||||
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"
|
||||
target="_dialog"
|
||||
}}
|
||||
{{:linkbutton
|
||||
label="Amortissements"
|
||||
href="amortization.html?immo_id=%s&type_immo=other"|args:$immo_id
|
||||
shape="table"
|
||||
}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/select}}
|
||||
|
|
|
|||
|
|
@ -3,15 +3,15 @@
|
|||
<nav class="tabs">
|
||||
{{if $current == "index" && $subsubcurrent == null}}
|
||||
<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>
|
||||
{{elseif $subsubcurrent == "amortization" && $type_immo == null || $type_immo == "managed" || $type_immo == "other"}}
|
||||
<aside>
|
||||
{{if $autres_amort}}
|
||||
{{:linkbutton label="Rattacher une écriture" href="other_amortizations.html?immo_line_id=%s"|args:$_GET.immo_line_id shape="link" target="_dialog"}}
|
||||
{{if $autres_amort != null}}
|
||||
{{:linkbutton label="Rattacher une écriture" href="other_amortizations.html?immo_id=%s"|args:$_GET.immo_id shape="link" target="_dialog"}}
|
||||
{{/if}}
|
||||
{{: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>
|
||||
{{/if}}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,20 +9,15 @@
|
|||
</p>
|
||||
|
||||
{{: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}}
|
||||
{{:assign unhide=$user_hides.unhide_unfinished}}
|
||||
{{:assign unhide=$module.config.unhide_unfinished}}
|
||||
{{else}}
|
||||
{{if $_POST.unhide == null}}
|
||||
{{:assign unhide=0}}
|
||||
{{else}}
|
||||
{{:assign unhide=1}}
|
||||
{{/if}}
|
||||
{{:assign var="user_hides.unhide_unfinished" value=$unhide"}}
|
||||
{{:assign var="saved_hides.%s"|args:$logged_user.id value=$user_hides}}
|
||||
{{:save key="config" hides=$saved_hides}}
|
||||
{{:save key="config" unhide_unfinished=$unhide}}
|
||||
{{/if}}
|
||||
{{if $unhide}}
|
||||
{{:assign checked="checked"}}
|
||||
|
|
@ -32,7 +27,7 @@
|
|||
<fieldset class="shortFormLeft">
|
||||
<legend>Transférer une ou plusieurs lignes vers une immobilisation amortissable</legend>
|
||||
<p class="help">
|
||||
Cocher les lignes concernées
|
||||
Cocher les lignes concernées ; les montants seront additionnés par numéro de compte
|
||||
</p>
|
||||
<div class="shortFormRight informations" id="total_amount">
|
||||
<legend>Montants sélectionnés</legend>
|
||||
|
|
@ -55,7 +50,7 @@
|
|||
</div>
|
||||
</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>
|
||||
</form>
|
||||
|
||||
|
|
@ -102,7 +97,7 @@
|
|||
trans.id as trans_id,
|
||||
trans.label as trans_label,
|
||||
trans.date as trans_date,
|
||||
line.id as immo_line_id,
|
||||
line.id as immo_id,
|
||||
account.id as account_id,
|
||||
account.code as account_code,
|
||||
account.label as account_label,
|
||||
|
|
@ -119,7 +114,7 @@
|
|||
}}
|
||||
{{* voir si l'écriture a été marquée ignorée *}}
|
||||
{{: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}}
|
||||
{{/load}}
|
||||
{{if $ignore && $unhide == null}}
|
||||
|
|
@ -163,7 +158,7 @@
|
|||
<td class="actions">
|
||||
{{:linkbutton
|
||||
label="Modifier"
|
||||
href="ignore.html?immo_line_id=%s"|args:$immo_line_id
|
||||
href="ignore.html?immo_id=%s"|args:$immo_id
|
||||
shape="edit"
|
||||
target="_dialog"
|
||||
}}
|
||||
|
|
|
|||
|
|
@ -75,11 +75,11 @@
|
|||
|
||||
{{if $account_ok == null}}
|
||||
{{: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}}
|
||||
|
||||
{{:assign debit_account=$debit_account|keys|value:0}}
|
||||
{{:assign credit_account=$credit_account|keys|value:0}}
|
||||
{{:assign debit_account=$debit_account|keys|key:0}}
|
||||
{{:assign credit_account=$credit_account|keys|key:0}}
|
||||
|
||||
{{* déterminer si le compte d'immo est un compte d'immo en cours *}}
|
||||
{{#foreach from=$module.config.unfinished item="elem"}}
|
||||
|
|
@ -127,8 +127,8 @@
|
|||
|
||||
{{if $status != "unfinished"}}
|
||||
{{* 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}}
|
||||
{{#load where="$$.line = :line_id" :line_id=$immo_line_id}}
|
||||
{{:assign var="immo_id" value=$result.lines.1.id}}
|
||||
{{#load where="$$.line = :line_id" :line_id=$immo_id}}
|
||||
{{:assign key=$key}}
|
||||
{{else}}
|
||||
{{:assign key=""|uuid}}
|
||||
|
|
@ -139,7 +139,7 @@
|
|||
key=$key
|
||||
validate_schema="schema.json"
|
||||
type="immo"
|
||||
line=$immo_line_id
|
||||
line=$immo_id
|
||||
duration=$duration
|
||||
date=$date_debut
|
||||
status=$status
|
||||
|
|
@ -160,7 +160,7 @@
|
|||
{{:admin_header title="Ajout immobilisation" current="module_amortization"}}
|
||||
{{* barre de navigation *}}
|
||||
{{if ! $dialog}}
|
||||
{{:include file="_nav.html" current="index" subcurrent="managed"}}
|
||||
{{:include file="_nav.html" current="index"}}
|
||||
{{/if}}
|
||||
|
||||
{{:form_errors}}
|
||||
|
|
|
|||
|
|
@ -1,52 +1,27 @@
|
|||
{{* -*- brindille -*- *}}
|
||||
|
||||
{{*
|
||||
@param immo_line_id
|
||||
@param immo_id
|
||||
@param type_immo : managed, amortized, archived, other
|
||||
*}}
|
||||
|
||||
{{* 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}}
|
||||
{{#select
|
||||
trans.id as immo_trans_id,
|
||||
trans.label,
|
||||
trans.date as date_achat,
|
||||
line.debit as montant,
|
||||
line.label as line_label,
|
||||
acc.code
|
||||
line.debit as montant
|
||||
FROM acc_transactions_lines AS line
|
||||
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;
|
||||
:line_id = $_GET.immo_line_id
|
||||
:line_id = $_GET.immo_id
|
||||
assign=ligne_immo
|
||||
}}
|
||||
{{else}}
|
||||
{{:error message="Aucune immobilisation trouvée"}}
|
||||
{{/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 *}}
|
||||
{{#form on="save"}}
|
||||
|
||||
{{if $_POST.classify == null}}
|
||||
{{:error message="Vous devez choisir une action"}}
|
||||
{{/if}}
|
||||
|
|
@ -54,6 +29,7 @@
|
|||
{{if $_POST.classify == "ignored"}}
|
||||
{{* ne pas amortir *}}
|
||||
{{:assign duration=0}}
|
||||
{{:assign montant=0}}
|
||||
{{:assign date_debut=$ligne_immo.date_achat|parse_date}}
|
||||
{{:assign status="ignored"}}
|
||||
{{else}}
|
||||
|
|
@ -86,6 +62,7 @@
|
|||
{{/if}}
|
||||
{{:assign status="managed"}}
|
||||
{{/if}}
|
||||
{{:assign montant="%d*100"|math:$_POST.montant}}
|
||||
{{/if}}
|
||||
|
||||
{{* enregistrer les infos de l'immobilisation *}}
|
||||
|
|
@ -99,38 +76,13 @@
|
|||
key=$key
|
||||
validate_schema="schema.json"
|
||||
type="immo"
|
||||
line=$_GET.immo_line_id|intval
|
||||
line=$_GET.immo_id|intval
|
||||
duration=$duration
|
||||
amount=$montant|intval
|
||||
date=$date_debut
|
||||
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"}}
|
||||
{{:assign type_immo=$_POST.classify}}
|
||||
{{elseif $_POST.classify == "ignored"}}
|
||||
|
|
@ -139,14 +91,15 @@
|
|||
{{:assign type_immo=$_GET.type_immo}}
|
||||
{{/if}}
|
||||
{{:redirect force="index.html?ok=1&msg=infos&type_immo=%s"|args:$type_immo}}
|
||||
{{else}}
|
||||
{{:form_errors}}
|
||||
{{/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 *}}
|
||||
{{if ! $dialog}}
|
||||
{{:include file="_nav.html" current="index" subcurrent="%s"|args:$_GET.type_immo subsubcurrent="parameter"}}
|
||||
{{:include file="_nav.html" current="index"}}
|
||||
{{/if}}
|
||||
|
||||
{{:assign choix_defaut=$_GET.type_immo}}
|
||||
|
|
@ -154,32 +107,17 @@
|
|||
{{if $info_immo != null}}
|
||||
{{:assign date_defaut=$info_immo.date}}
|
||||
{{:assign duree_defaut=$info_immo.duration}}
|
||||
{{:assign choix_defaut=$info_immo.status}}
|
||||
{{:assign montant_defaut=$info_immo.amount}}
|
||||
{{else}}
|
||||
{{:assign duree_defaut=null}}
|
||||
{{:assign montant_defaut=null}}
|
||||
{{/if}}
|
||||
|
||||
{{*
|
||||
- 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="">
|
||||
<fieldset>
|
||||
<legend>Classement</legend>
|
||||
|
|
@ -196,7 +134,7 @@
|
|||
<legend>Informations</legend>
|
||||
<dl>
|
||||
{{: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"}}
|
||||
</dl>
|
||||
</fieldset>
|
||||
|
|
|
|||
|
|
@ -2,77 +2,50 @@
|
|||
|
||||
{{*
|
||||
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
|
||||
*}}
|
||||
|
||||
{{* récupérer les infos de l'immobilisation *}}
|
||||
{{#select
|
||||
line.id as immo_line_id,
|
||||
line.id as immo_id,
|
||||
line.debit as montant,
|
||||
line.label as line_label,
|
||||
trans.id as immo_trans_id,
|
||||
trans.id as trans_id,
|
||||
trans.label as label,
|
||||
trans.date,
|
||||
account.code as account_code
|
||||
trans.date
|
||||
FROM acc_transactions_lines AS line
|
||||
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;
|
||||
:line_id = $_GET.immo_line_id|intval
|
||||
:line_id = $_GET.immo_id|intval
|
||||
assign=ligne_immo
|
||||
}}
|
||||
{{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}}
|
||||
{{: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 date_debut=$date}}
|
||||
{{:assign status=$status}}
|
||||
{{if $amount != null}}
|
||||
{{:assign var="ligne_immo.montant" value=$amount}}
|
||||
{{/if}}
|
||||
{{/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}}
|
||||
|
||||
{{* lister les lignes des écritures d'amortissement liées à l'immobilisation *}}
|
||||
{{* chercher des écritures d'amortissement liées à l'immobilisation *}}
|
||||
{{#select
|
||||
l_amort.credit as amort_amount,
|
||||
l_amort.label as amort_line_label,
|
||||
l_amort.id as amort_line_id,
|
||||
l_amort.label as amort_label,
|
||||
l_amort.id as amort_line,
|
||||
CASE WHEN links.id_related = t_immo.id
|
||||
THEN links.id_transaction
|
||||
ELSE links.id_related
|
||||
END as amort_trans_id,
|
||||
trans.date as amort_date,
|
||||
trans.label as amort_trans_label,
|
||||
trans.label as trans_label,
|
||||
trans.id_year as amort_year,
|
||||
account.id as account_id,
|
||||
account.code as account_code,
|
||||
|
|
@ -80,25 +53,19 @@
|
|||
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_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 as trans on l_amort.id_transaction = trans.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;
|
||||
:line_id = $_GET.immo_line_id|intval
|
||||
assign="amort_line"
|
||||
:line_id = $_GET.immo_id|intval
|
||||
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}}
|
||||
{{:assign date_debut=$amort_date}}
|
||||
{{/if}}
|
||||
|
|
@ -109,7 +76,7 @@
|
|||
{{:assign valeur_residuelle=0}}
|
||||
{{else}}
|
||||
{{:assign valeur_residuelle=$ligne_immo.montant}}
|
||||
{{#foreach from=$linked_amort}}
|
||||
{{#foreach from=$linked_lines}}
|
||||
{{:assign valeur_residuelle="%d-%d"|math:$valeur_residuelle:$amort_amount}}
|
||||
{{/foreach}}
|
||||
{{/if}}
|
||||
|
|
@ -123,9 +90,17 @@
|
|||
{{/foreach}}
|
||||
{{:assign filter_condition=$filter_condition|cat:"0)"}}
|
||||
|
||||
{{:assign autres_amortissements=false}}
|
||||
{{#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
|
||||
INNER JOIN acc_accounts AS account ON account.id = line.id_account
|
||||
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
|
||||
ORDER BY trans.date, trans.label;
|
||||
!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
|
||||
links.id_transaction,
|
||||
links.id_related,
|
||||
trans.id AS trans_id
|
||||
FROM acc_transactions_links AS links
|
||||
INNER JOIN acc_transactions AS trans ON (
|
||||
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
|
||||
id_transaction,
|
||||
id_related
|
||||
FROM acc_transactions_links
|
||||
WHERE id_transaction = :id_amort OR id_related = :id_amort;
|
||||
:id_amort=$t_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}}
|
||||
{{:assign autres_amortissements=true}}
|
||||
{{:assign var="autres_amortissements." value=$autre_amort}}
|
||||
{{/select}}
|
||||
{{/select}}
|
||||
|
||||
|
|
@ -222,7 +168,7 @@
|
|||
<p class="submit">
|
||||
{{:linkbutton
|
||||
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"
|
||||
class="main"
|
||||
}}
|
||||
|
|
@ -238,7 +184,7 @@
|
|||
<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>
|
||||
<dd><span class="num"><a href={{$trans_url}}>#{{$ligne_immo.trans_id}}</a></span> {{$ligne_immo.label}}</dd>
|
||||
<dt>Montant</dt>
|
||||
<dd class="money strong">{{"%f"|math:$ligne_immo.montant|money_currency_html:false|raw}}</dd>
|
||||
<dt>Début d'amortissement</dt>
|
||||
|
|
@ -261,12 +207,12 @@
|
|||
</div>
|
||||
|
||||
<h3 class="ruler">Amortissements enregistrés</h3>
|
||||
{{if $linked_amort != null}}
|
||||
{{if $linked_lines != null}}
|
||||
<section class="amortissement">
|
||||
<table class="list">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="num">N°</th>
|
||||
<th>N°</th>
|
||||
<th>Date</th>
|
||||
<th class="nombre">Montant</th>
|
||||
<th class="nombre">Valeur nette</th>
|
||||
|
|
@ -277,7 +223,7 @@
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#foreach from=$linked_amort item="line"}}
|
||||
{{#foreach from=$linked_lines item="line"}}
|
||||
{{* données de l'écriture *}}
|
||||
{{: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}}
|
||||
|
|
@ -288,15 +234,16 @@
|
|||
<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>
|
||||
{{$line.amort_trans_label}}
|
||||
{{if $line.amort_line_label != null && $line.amort_line_label != $line.amort_trans_label}}
|
||||
— {{$line.amort_line_label}}
|
||||
{{if $line.amort_label == null}}
|
||||
{{$line.trans_label}}
|
||||
{{else}}
|
||||
{{$line.amort_label}}
|
||||
{{/if}}
|
||||
</td>
|
||||
<td><a href={{$compte_url}}>{{$line.account_code}}</a></td>
|
||||
<td>{{$line.account_label}}</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>
|
||||
</tr>
|
||||
{{/foreach}}
|
||||
|
|
@ -311,9 +258,9 @@
|
|||
|
||||
{{* Autres amortissements non rattachés *}}
|
||||
|
||||
{{if $autres_amortissements}}
|
||||
{{if $autres_amortissements != null}}
|
||||
<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.
|
||||
</p>
|
||||
{{/if}}
|
||||
|
|
|
|||
|
|
@ -10,11 +10,11 @@
|
|||
id_transaction
|
||||
FROM acc_transactions_lines
|
||||
WHERE id = :line_id;
|
||||
:line_id = $_GET.immo_line_id|intval
|
||||
:line_id = $_GET.immo_id|intval
|
||||
}}
|
||||
{{:assign immo_trans_id=$id_transaction}}
|
||||
{{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}}
|
||||
|
||||
{{* chercher l'écriture d'amortissement *}}
|
||||
|
|
@ -22,11 +22,11 @@
|
|||
id_transaction
|
||||
FROM acc_transactions_lines
|
||||
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}}
|
||||
{{: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}}
|
||||
|
||||
{{* chercher les liaisons de l'écriture d'immobilisation *}}
|
||||
|
|
@ -43,7 +43,9 @@
|
|||
{{/select}}
|
||||
|
||||
{{* ajouter la nouvelle liaison *}}
|
||||
{{:assign var="linked_transactions." value=$amort_trans_id}}
|
||||
{{:assign var="linked_transactions." value=$amort_id}}
|
||||
|
||||
{{* Enregistrer les liaisons *}}
|
||||
{{:api
|
||||
method="POST"
|
||||
path="accounting/transaction/%s/transactions"|args:$immo_trans_id
|
||||
|
|
@ -51,24 +53,4 @@
|
|||
assign_code="result_code"
|
||||
transactions=$linked_transactions
|
||||
}}
|
||||
|
||||
{{* 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}}
|
||||
{{:redirect force="amortization.html?immo_id=%s&ok=1&msg=attach&trans_id=%s"|args:$_GET.immo_id:$amort_id}}
|
||||
|
|
|
|||
|
|
@ -2,129 +2,76 @@
|
|||
|
||||
{{*
|
||||
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 *}}
|
||||
{{#select
|
||||
line.debit as montant,
|
||||
trans.id AS trans_id,
|
||||
trans.date as date_achat,
|
||||
trans.label,
|
||||
account.code as account_code
|
||||
trans.label
|
||||
FROM acc_transactions_lines AS line
|
||||
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;
|
||||
:line_id = $_GET.immo_line_id|intval
|
||||
:line_id = $_GET.immo_id|intval
|
||||
assign="ligne_immo"
|
||||
}}
|
||||
{{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}}
|
||||
|
||||
{{:assign date_debut=$ligne_immo.date_achat}}
|
||||
{{: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 date_debut=$date}}
|
||||
{{:assign duree_amort=$duration}}
|
||||
{{if $amount != null}}
|
||||
{{:assign var="ligne_immo.montant" value=$amount}}
|
||||
{{/if}}
|
||||
{{/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 *}}
|
||||
{{:assign total_amort=0}}
|
||||
{{:assign amort_number=0}}
|
||||
{{#select
|
||||
l_amort.credit as amort_amount,
|
||||
l_amort.id as amort_line_id,
|
||||
SUM(l_amort.credit) as amort_amount,
|
||||
CASE
|
||||
WHEN links.id_related = t_immo.id
|
||||
THEN links.id_transaction
|
||||
ELSE links.id_related
|
||||
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
|
||||
INNER JOIN acc_transactions as t_immo on t_immo.id = l_immo.id_transaction
|
||||
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 as trans on l_amort.id_transaction = trans.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%'
|
||||
;
|
||||
:line_id = $_GET.immo_line_id|intval
|
||||
assign="amort_line"
|
||||
LIMIT 1;
|
||||
:line_id = $_GET.immo_id|intval
|
||||
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}}
|
||||
|
||||
{{if $total_amort == 0}}
|
||||
{{if $amort_line.amort_number == 0}}
|
||||
{{if $info_immo.status == "amortized"}}
|
||||
{{:assign total_amort=$ligne_immo.montant}}
|
||||
{{:assign amort_amount=$ligne_immo.montant}}
|
||||
{{else}}
|
||||
{{:assign amort_amount=0}}
|
||||
{{/if}}
|
||||
{{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"}}
|
||||
{{/if}}
|
||||
{{: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
|
||||
|
|
@ -157,9 +104,9 @@
|
|||
{{* vérifier la validité de la date de mise en service *}}
|
||||
{{if $_POST.date_mes != null}}
|
||||
{{: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 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}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
|
@ -169,8 +116,8 @@
|
|||
{{if $info_immo.duration == null}}
|
||||
{{if $_POST.duree == null}}
|
||||
{{:error message="Vous devez renseigner la durée de l'immobilisation"}}
|
||||
{{elseif $_POST.duree < $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}}
|
||||
{{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_line.amort_number}}
|
||||
{{else}}
|
||||
{{:assign duree_amort=$_POST.duree}}
|
||||
{{/if}}
|
||||
|
|
@ -191,9 +138,9 @@
|
|||
{{: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}}
|
||||
{{/if}}
|
||||
{{if $amort_number != 0 && $_POST.date_sortie|parse_date <= $last_amort_date}}
|
||||
{{:assign last_amort_date=$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}}
|
||||
{{if $amort_line.amort_number != 0 && $_POST.date_sortie|parse_date <= $amort_line.last_amort_date}}
|
||||
{{:assign last_amort_date=$amort_line.last_amort_date|date_short}}
|
||||
{{:error message="La date de sortie doit être postérieure à la date de la dernière immobilisation (%s)"|args:$last_amort_date}}
|
||||
{{/if}}
|
||||
|
||||
{{* vérifier que la date de sortie est située dans un exercice ouvert *}}
|
||||
|
|
@ -210,7 +157,7 @@
|
|||
{{/if}}
|
||||
|
||||
{{* 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 fin=$end_date|date_short}}
|
||||
{{: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}}
|
||||
{{/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}}
|
||||
|
||||
{{: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>
|
||||
{{/if}}
|
||||
<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>
|
||||
<dd class="money">{{$valeur_nette|money_currency_html:false|raw}} <span class="help">(à la date de début de l'exercice)</span></dd>
|
||||
</dl>
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
{{*
|
||||
Calculer les valeurs de la sortie et saisir le montant de la cession (optionnel)
|
||||
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
|
||||
- year : exercice de la date de sortie de l'immobilisation
|
||||
- date_mes : datede mise en service de l'immobilisation
|
||||
|
|
@ -14,43 +14,22 @@
|
|||
|
||||
{{#select
|
||||
line.debit as montant,
|
||||
trans.id AS trans_id,
|
||||
trans.date as date_achat,
|
||||
trans.label,
|
||||
account.code as account_code
|
||||
trans.label
|
||||
FROM acc_transactions_lines AS line
|
||||
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;
|
||||
:line_id = $_GET.immo_line_id|intval
|
||||
:line_id = $_GET.immo_id|intval
|
||||
assign="ligne_immo"
|
||||
}}
|
||||
{{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}}
|
||||
|
||||
{{* 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}}
|
||||
{{#load type="immo" where="$$.line = :line_id" :line_id=$_GET.immo_id|intval}}
|
||||
{{if $amount != null}}
|
||||
{{:assign var="ligne_immo.montant" value=$amount}}
|
||||
{{/if}}
|
||||
{{/load}}
|
||||
|
||||
{{:assign valeur_nette="%f-%f"|math:$ligne_immo.montant:$_GET.amort_amount}}
|
||||
{{:assign amort_comp=0}} {{* amortissement complémentaire jqà date sortie *}}
|
||||
|
|
@ -69,7 +48,7 @@
|
|||
{{/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}}
|
||||
{{:admin_header title="Sortie du bilan" custom_css="./style.css" current="module_amortization"}}
|
||||
|
|
|
|||
|
|
@ -10,11 +10,11 @@
|
|||
id_transaction
|
||||
FROM acc_transactions_lines
|
||||
WHERE id = :line_id;
|
||||
:line_id = $_GET.immo_line_id|intval
|
||||
:line_id = $_GET.immo_id|intval
|
||||
}}
|
||||
{{:assign immo_trans_id=$id_transaction}}
|
||||
{{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}}
|
||||
|
||||
{{* chercher l'écriture d'amortissement *}}
|
||||
|
|
@ -22,11 +22,11 @@
|
|||
id_transaction
|
||||
FROM acc_transactions_lines
|
||||
WHERE id = :line_id;
|
||||
:line_id = $_GET.amort_line_id|intval
|
||||
:line_id = $_GET.amort_id|intval
|
||||
}}
|
||||
{{:assign amort_id=$id_transaction}}
|
||||
{{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}}
|
||||
|
||||
{{*
|
||||
|
|
@ -55,17 +55,4 @@
|
|||
assign_code="result_code"
|
||||
transactions=$linked_transactions
|
||||
}}
|
||||
|
||||
{{* 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}}
|
||||
{{:redirect to="amortization.html?immo_id=%s&ok=1&msg=detach&trans_id=%s"|args:$_GET.immo_id:$amort_id}}
|
||||
|
|
|
|||
10
ignore.html
10
ignore.html
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
{{*
|
||||
Marquer la ligne d'écriture « à ignorer »
|
||||
@param immo_line_id : numéro de ligne
|
||||
@param immo_id : numéro de ligne
|
||||
*}}
|
||||
|
||||
{{#select
|
||||
|
|
@ -14,13 +14,13 @@
|
|||
INNER JOIN acc_transactions AS trans ON line.id_transaction = trans.id
|
||||
WHERE line.id = :line_id
|
||||
;
|
||||
:line_id = $_GET.immo_line_id
|
||||
:line_id = $_GET.immo_id
|
||||
assign=ligne_immo
|
||||
}}
|
||||
{{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}}
|
||||
{{#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 *}}
|
||||
{{#form on="proceed"}}
|
||||
|
|
@ -32,7 +32,7 @@
|
|||
key=""|uuid
|
||||
validate_schema="schema.json"
|
||||
type="immo"
|
||||
line=$_GET.immo_line_id|intval
|
||||
line=$_GET.immo_id|intval
|
||||
duration=$duration
|
||||
date=$ligne_immo.date
|
||||
status=$status
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
name="Amortissements"
|
||||
description="Immobilisations et amortissements\nversion 0.32"
|
||||
description="Immobilisations et amortissements\nversion 0.28"
|
||||
author="Jean-Christophe Engel"
|
||||
author_url="https://gitea.zaclys.com/lesanges"
|
||||
home_button=false
|
||||
|
|
|
|||
|
|
@ -3,44 +3,41 @@
|
|||
{{*
|
||||
Lister les écritures d'amortissement indépendantes
|
||||
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 *}}
|
||||
{{#select
|
||||
line.id as immo_id,
|
||||
line.debit as montant,
|
||||
trans.id as trans_id,
|
||||
trans.label as label,
|
||||
line.label as line_label
|
||||
trans.date
|
||||
FROM acc_transactions_lines AS line
|
||||
INNER JOIN acc_transactions AS trans ON line.id_transaction = trans.id
|
||||
WHERE line.id = :line_id;
|
||||
:line_id = $_GET.immo_line_id|intval
|
||||
:line_id = $_GET.immo_id|intval
|
||||
assign=ligne_immo
|
||||
}}
|
||||
{{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}}
|
||||
|
||||
{{:include file="_get_config.html" keep="module.config"}}
|
||||
|
||||
{{if $_POST.unhide == null}}
|
||||
{{:assign filter_condition=" NOT ("}}
|
||||
{{#foreach from=$module.config.filters item="filter"}}
|
||||
{{: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}}
|
||||
{{/foreach}}
|
||||
{{:assign filter_condition=$filter_condition|cat:"0)"}}
|
||||
|
||||
{{* lister les écritures d'amortissement *}}
|
||||
{{#select
|
||||
line.id as amort_line_id,
|
||||
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 line_label,
|
||||
trans.date as trans_date,
|
||||
trans.label as trans_label,
|
||||
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,
|
||||
|
|
@ -52,47 +49,17 @@
|
|||
WHERE account.code LIKE "28%" AND credit > 0 AND (NOT trans.status & 16) AND !filter_condition
|
||||
ORDER BY trans.date, trans.label;
|
||||
!filter_condition=$filter_condition
|
||||
assign="amort"
|
||||
}}
|
||||
|
||||
{{* voir s'il existe des écritures liées avec un numéro de compte d'immobilisation *}}
|
||||
assign=autre_amort
|
||||
}}
|
||||
{{#select
|
||||
links.id_transaction,
|
||||
links.id_related,
|
||||
trans.id AS trans_id
|
||||
FROM acc_transactions_links AS links
|
||||
INNER JOIN acc_transactions AS trans ON (
|
||||
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
|
||||
id_transaction,
|
||||
id_related
|
||||
FROM acc_transactions_links
|
||||
WHERE id_transaction = :id_amort OR id_related = :id_amort;
|
||||
:id_amort=$t_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}}
|
||||
{{:assign var="autres_amortissements." value=$amort}}
|
||||
{{:assign var="autres_amortissements." value=$autre_amort}}
|
||||
{{/select}}
|
||||
{{/select}}
|
||||
|
||||
|
|
@ -110,19 +77,9 @@
|
|||
}}
|
||||
{{/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}}
|
||||
<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">
|
||||
<thead>
|
||||
<tr>
|
||||
|
|
@ -137,19 +94,22 @@
|
|||
</thead>
|
||||
<tbody>
|
||||
{{#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}}
|
||||
<tr>
|
||||
<td class="num"><a href={{$trans_url}}>#{{$line.amort_trans_id}}</a></td>
|
||||
<td>{{$line.trans_date|date_short}}</td>
|
||||
<td class="num"><a href={{$trans_url}}>#{{$line.t_id}}</a></td>
|
||||
<td>{{$line.t_date|date_short}}</td>
|
||||
<td class="money">{{"%f"|math:$line.amort_amount|money_html:false|raw}}</td>
|
||||
<td>{{$line.trans_label}}
|
||||
{{if $line.line_label != null && $line.line_label != $line.trans_label}} - {{$line.line_label}}{{/if}}
|
||||
<td>{{if $line.l_label == null}}
|
||||
{{$line.t_label}}
|
||||
{{else}}
|
||||
{{$line.l_label}}
|
||||
{{/if}}
|
||||
</td>
|
||||
<td><a href={{$compte_url}}>{{$line.account_code}}</a></td>
|
||||
<td>{{$line.account_label}}</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>
|
||||
</tr>
|
||||
{{/foreach}}
|
||||
|
|
@ -159,15 +119,3 @@
|
|||
{{/if}}
|
||||
{{:form_errors}}
|
||||
{{: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
|
||||
@param immo_line_id : id de la ligne d'immobilisation
|
||||
@param immo_id : id de la ligne d'immobilisation
|
||||
*}}
|
||||
|
||||
{{* Infos de l'immobilisation *}}
|
||||
{{#select
|
||||
line.id as immo_id,
|
||||
line.id_account as account_id,
|
||||
line.debit as montant,
|
||||
line.id_project as project_id,
|
||||
line.label as line_label,
|
||||
trans.id as trans_id,
|
||||
trans.label,
|
||||
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
|
||||
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
|
||||
WHERE line.id = :line_id;
|
||||
:line_id = $_GET.immo_line_id|intval
|
||||
:line_id = $_GET.immo_id|intval
|
||||
assign=ligne_immo
|
||||
}}
|
||||
{{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}}
|
||||
{{: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 date_debut=$date}}
|
||||
{{:assign status=$status}}
|
||||
{{if $amount != null}}
|
||||
{{:assign var="ligne_immo.montant" value=$amount}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{:error message="Vous devez renseigner la date de mise en service et la durée d'immobilisation"}}
|
||||
{{/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 *}}
|
||||
{{#select
|
||||
l_amort.credit as amort_amount,
|
||||
SUM(l_amort.credit) as amort_amount,
|
||||
l_amort.label as amort_label,
|
||||
l_amort.id as amort_line_id,
|
||||
CASE WHEN links.id_related = t_immo.id
|
||||
THEN links.id_transaction
|
||||
ELSE links.id_related
|
||||
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.id_year as amort_year,
|
||||
account.id as account_id,
|
||||
|
|
@ -86,48 +60,20 @@
|
|||
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_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 as trans on l_amort.id_transaction = trans.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%'
|
||||
ORDER BY trans.date;
|
||||
:line_id = $_GET.immo_line_id|intval
|
||||
assign="amort_line"
|
||||
WHERE l_immo.id = :line_id AND account.code LIKE '28%'
|
||||
ORDER BY trans.date DESC LIMIT 1;
|
||||
:line_id = $_GET.immo_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}}
|
||||
|
||||
|
||||
{{: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}}
|
||||
{{if $amort_line.amort_number == 0}}
|
||||
{{* 1er amortissement *}}
|
||||
{{* 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}}
|
||||
|
|
@ -137,12 +83,15 @@
|
|||
code_immo=$amort_account.code
|
||||
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}}
|
||||
{{else}}
|
||||
{{* 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 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}}
|
||||
|
||||
{{*
|
||||
|
|
@ -152,7 +101,7 @@
|
|||
{{:assign msg_years=""}}
|
||||
{{#years closed=false order="start_date" where="start_date <= :debut AND :debut <= end_date"
|
||||
:debut=$date_debut assign=years.}}
|
||||
{{if $total_amort == 0}}
|
||||
{{if $amort_line.amort_number == 0}}
|
||||
{{:assign ts_debut=$date_debut|strtotime}}
|
||||
{{else}}
|
||||
{{:assign ts_debut=$start_date|strtotime}}
|
||||
|
|
@ -221,11 +170,11 @@
|
|||
}}
|
||||
{{if $account_ok == null}}
|
||||
{{: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}}
|
||||
|
||||
{{* 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}}
|
||||
{{:assign solde=$solde|money_raw}}
|
||||
{{:error message="Le montant indiqué « %s » dépasse le solde à amortir « %s »"|args:$_POST.montant:$solde}}
|
||||
|
|
@ -235,15 +184,15 @@
|
|||
{{:assign
|
||||
var="lines."
|
||||
debit=$_POST.montant
|
||||
account=$debit_account|keys|value:0
|
||||
id_project=$ligne_immo.project_id
|
||||
account=$debit_account|keys|key:0
|
||||
id_project=$_GET.project_id
|
||||
label=$_POST.designation
|
||||
}}
|
||||
{{:assign
|
||||
var="lines."
|
||||
credit=$_POST.montant
|
||||
account=$credit_account|keys|value:0
|
||||
id_project=$ligne_immo.project_id
|
||||
account=$credit_account|keys|key:0
|
||||
id_project=$_GET.project_id
|
||||
label=$_POST.designation
|
||||
}}
|
||||
{{:api
|
||||
|
|
@ -259,33 +208,10 @@
|
|||
linked_transactions=$ligne_immo.trans_id|intval
|
||||
}}
|
||||
|
||||
{{* enregistrer la liaison des lignes *}}
|
||||
{{#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}}
|
||||
{{:redirect force="amortization.html?immo_id=%s&ok=1&msg=amortissement"|args:$_GET.immo_id}}
|
||||
{{/form}}
|
||||
|
||||
{{:admin_header title="Ajout amortissement" custom_css="./style.css" current="module_amortization"}}
|
||||
{{:admin_header title="Ajout amortissement" current="module_amortization"}}
|
||||
|
||||
{{* barre de navigation *}}
|
||||
{{if ! $dialog}}
|
||||
|
|
@ -300,9 +226,9 @@
|
|||
|
||||
{{* montant de l'amortissement *}}
|
||||
{{: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="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>
|
||||
{{: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="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="list"
|
||||
|
|
@ -337,7 +263,7 @@
|
|||
<div id="donnees" class="hidden">
|
||||
{{:input type="text" name="montant_immo" default=$ligne_immo.montant}}
|
||||
{{: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}}
|
||||
</div>
|
||||
</dl>
|
||||
|
|
|
|||
|
|
@ -76,7 +76,3 @@ table.list tbody tr.ignored:nth-child(even) {
|
|||
font-style: italic;
|
||||
background: rgba(255, 255, 200, 0.5);
|
||||
}
|
||||
|
||||
html.dialog.dark {
|
||||
filter: none !important;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
{{* -*- 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"}}
|
||||
|
||||
{{#years closed=false order="start_date" assign=years.}}
|
||||
|
|
@ -109,7 +110,7 @@
|
|||
account=$elem
|
||||
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="label" from="_POST.line_labels.%s"|args:$rang}}
|
||||
{{:assign
|
||||
|
|
@ -126,7 +127,7 @@
|
|||
account=$_POST.debit_account
|
||||
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 count=$_POST.line_labels|count}}
|
||||
{{:assign count="%d-1"|math:$count}}
|
||||
|
|
@ -157,7 +158,7 @@
|
|||
{{/if}}
|
||||
|
||||
{{* écritures liées *}}
|
||||
{{:assign var="linked_transactions" value=$transactions|keys}}
|
||||
{{:assign var="linked_transactions" value=$_GET.trans|explode:","}}
|
||||
|
||||
{{* enregistrer l'écriture *}}
|
||||
{{:api
|
||||
|
|
@ -174,13 +175,13 @@
|
|||
|
||||
{{:assign lines_count=$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 *}}
|
||||
{{:save
|
||||
key=""|uuid
|
||||
validate_schema="schema.json"
|
||||
type="immo"
|
||||
line=$immo_line_id
|
||||
line=$immo_id
|
||||
duration=$duration
|
||||
date=$date_debut
|
||||
status=$status
|
||||
|
|
@ -193,7 +194,7 @@
|
|||
{{:redirect force="index.html?ok=1&msg=immobilisation&type_immo=%s"|args:$type_immo}}
|
||||
{{/form}}
|
||||
|
||||
{{:admin_header title="Transfert d'immobilisation en cours" custom_css="./style.css" current="module_amortization"}}
|
||||
{{* barre de navigation *}}
|
||||
{{if ! $dialog}}
|
||||
{{:include file="_nav.html" current="index" subcurrent="unfinished" subsubcurrent="transfer"}}
|
||||
{{/if}}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
{{*
|
||||
Enregistrer les écritures de sortie du bilan
|
||||
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
|
||||
- year : exercice de la date de sortie de l'immobilisation
|
||||
- date_mes : date de mise en service de l'immobilisation
|
||||
|
|
@ -16,42 +16,25 @@
|
|||
{{#select
|
||||
line.debit as montant,
|
||||
line.id_transaction,
|
||||
trans.id AS trans_id,
|
||||
line.id_account,
|
||||
trans.date as date_achat,
|
||||
trans.label,
|
||||
acc.code as account_code,
|
||||
acc.code,
|
||||
id_project
|
||||
FROM acc_transactions_lines AS line
|
||||
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 = :immo_line_id;
|
||||
:immo_line_id = $_GET.immo_line_id|intval
|
||||
WHERE line.id = :immo_id;
|
||||
:immo_id = $_GET.immo_id|intval
|
||||
assign="ligne_immo"
|
||||
}}
|
||||
{{/select}}
|
||||
|
||||
{{* 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}}
|
||||
{{#load type="immo" assign="info_immo" where="$$.line = :line_id" :line_id=$_GET.immo_id|intval}}
|
||||
{{if $amount != null}}
|
||||
{{:assign var="ligne_immo.montant" value=$amount}}
|
||||
{{/if}}
|
||||
{{/load}}
|
||||
|
||||
{{:assign valeur_nette="%f-%f"|math:$ligne_immo.montant:$_GET.amort_amount}}
|
||||
{{:assign amort_comp=0}} {{* amortissement complémentaire jqà date sortie *}}
|
||||
|
|
@ -93,7 +76,7 @@
|
|||
account=$account
|
||||
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}}
|
||||
{{* immo non totalement amortie *}}
|
||||
|
|
@ -104,7 +87,7 @@
|
|||
account=$_POST.comp_account
|
||||
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
|
||||
|
|
@ -130,7 +113,7 @@
|
|||
account=$_POST.except_account
|
||||
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
|
||||
var="lines."
|
||||
|
|
@ -170,7 +153,7 @@
|
|||
account=$_POST.immo_account
|
||||
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
|
||||
var="lines."
|
||||
|
|
@ -192,7 +175,7 @@
|
|||
account=$_POST.vnc_account
|
||||
keep="account_code"
|
||||
}}
|
||||
{{:assign vnc_account_code=$account_code|keys|value:0}}
|
||||
{{:assign vnc_account_code=$account_code|keys|key:0}}
|
||||
{{:assign
|
||||
var="lines."
|
||||
account=$vnc_account_code
|
||||
|
|
@ -223,13 +206,13 @@
|
|||
account=$_POST.creance_account
|
||||
keep="account_code"
|
||||
}}
|
||||
{{:assign creance_account=$account_code|keys|value:0}}
|
||||
{{:assign creance_account=$account_code|keys|key:0}}
|
||||
{{:include
|
||||
file="_get_codes.html"
|
||||
account=$_POST.cession_account
|
||||
keep="account_code"
|
||||
}}
|
||||
{{:assign cession_account=$account_code|keys|value:0}}
|
||||
{{:assign cession_account=$account_code|keys|key:0}}
|
||||
{{:api
|
||||
method="POST"
|
||||
path="accounting/transaction"
|
||||
|
|
@ -258,7 +241,7 @@
|
|||
key=""|uuid
|
||||
validate_schema="schema.json"
|
||||
type="immo"
|
||||
line=$_GET.immo_line_id|intval
|
||||
line=$_GET.immo_id|intval
|
||||
duration=$_GET.duree_amort|intval
|
||||
date=$_GET.date_mes|date:"Y-m-d"
|
||||
status="archived"
|
||||
|
|
@ -282,11 +265,14 @@
|
|||
|
||||
{{:include
|
||||
file="./_get_amort_code.html"
|
||||
code_immo=$ligne_immo.account_code
|
||||
code_immo=$ligne_immo.code
|
||||
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 cession_code="757"}}
|
||||
|
||||
|
|
@ -294,7 +280,7 @@
|
|||
{{:assign var="liste_codes.687" name="except_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:$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:$cession_code name="cession_account"}}
|
||||
{{:assign condition=$liste_codes|keys|implode:","}}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue