Compare commits
1 commit
main
...
compat_131
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
379f523eaa |
19 changed files with 216 additions and 493 deletions
|
|
@ -66,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_id|intval}}
|
||||
{{:assign status=$status}}
|
||||
{{if $amount != null}}
|
||||
{{:assign montant_immo=$amount}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{:assign amortissable="nsp"}}
|
||||
{{:assign status="unknown"}}
|
||||
|
|
@ -78,46 +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_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
|
||||
INNER JOIN acc_transactions AS trans2 ON trans2.id = other_id
|
||||
WHERE trans.id = :immo_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_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}}
|
||||
{{/select}}
|
||||
|
||||
{{if $solde_immo == 0}}
|
||||
{{:assign status="archived"}}
|
||||
{{/if}}
|
||||
{{:assign exit_date=$exit_date}}
|
||||
{{/select}}
|
||||
|
||||
{{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}}
|
||||
|
|
@ -128,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
|
||||
|
|
@ -161,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}}
|
||||
|
|
|
|||
|
|
@ -49,13 +49,14 @@
|
|||
{{: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,
|
||||
account.id as account_id,
|
||||
account.code as account_code,
|
||||
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
|
||||
|
|
@ -65,15 +66,18 @@
|
|||
ORDER BY trans.date DESC;
|
||||
!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=null}}
|
||||
{{: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 duration=$duration}}
|
||||
{{:assign status=$status}}
|
||||
{{if $amount != null}}
|
||||
{{:assign montant_immo=$amount}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{:assign amortissable="nsp"}}
|
||||
{{:assign status="unknown"}}
|
||||
|
|
@ -82,77 +86,57 @@
|
|||
{{: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
|
||||
*}}
|
||||
{{* voir s'il existe une écriture 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
|
||||
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
|
||||
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 montant_immo="%d-%d"|math:$montant_immo:$credit}}
|
||||
{{/select}}
|
||||
{{if $montant_immo == 0}}
|
||||
{{:assign status="archived"}}
|
||||
{{/if}}
|
||||
{{/select}}
|
||||
{{if $status == "archived"}}
|
||||
{{:continue}}
|
||||
{{/if}}
|
||||
|
||||
{{* voir s'il existe des écritures d'amortissement associées *}}
|
||||
{{:assign amort_lines=null}}
|
||||
{{#select
|
||||
(l_amort.credit) as 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="elem"}}
|
||||
{{* voir s'il existe un doc associé *}}
|
||||
{{#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 = $elem.amort_trans_id
|
||||
assign="link"
|
||||
}}
|
||||
{{if $link.amort_line_id == $elem.amort_line_id}}
|
||||
{{:assign amort_amount="%d+%d"|math:$amort_amount:$amount}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{:assign amort_amount="%d+%d"|math:$amort_amount:$amount}}
|
||||
{{/load}}
|
||||
{{/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}}
|
||||
|
|
@ -165,7 +149,7 @@
|
|||
{{: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}}</td>
|
||||
<td class="money">{{$montant_immo|money_html:false|raw}}</td>
|
||||
|
|
@ -176,13 +160,13 @@
|
|||
<td class="actions">
|
||||
{{:linkbutton
|
||||
label="Paramètres"
|
||||
href="add_infos.html?immo_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"
|
||||
}}
|
||||
{{:linkbutton
|
||||
label="Amortissements"
|
||||
href="amortization.html?immo_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>
|
||||
|
|
@ -191,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>
|
||||
|
|
|
|||
|
|
@ -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_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"}}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
</aside>
|
||||
{{elseif $subsubcurrent == "amortization" && $type_immo == null || $type_immo == "managed" || $type_immo == "other"}}
|
||||
<aside>
|
||||
{{if $autres_amort}}
|
||||
{{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"
|
||||
|
|
|
|||
|
|
@ -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"}}
|
||||
|
|
|
|||
|
|
@ -78,8 +78,8 @@
|
|||
{{: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"}}
|
||||
|
|
|
|||
|
|
@ -9,42 +9,19 @@
|
|||
{{#load type="immo" assign="info_immo" where="$$.line = :line_id" :line_id=$_GET.immo_id|intval}}
|
||||
{{/load}}
|
||||
{{#select
|
||||
trans.id,
|
||||
trans.date as date_achat,
|
||||
line.debit as montant,
|
||||
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_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.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}}
|
||||
|
|
@ -52,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}}
|
||||
|
|
@ -84,6 +62,7 @@
|
|||
{{/if}}
|
||||
{{:assign status="managed"}}
|
||||
{{/if}}
|
||||
{{:assign montant="%d*100"|math:$_POST.montant}}
|
||||
{{/if}}
|
||||
|
||||
{{* enregistrer les infos de l'immobilisation *}}
|
||||
|
|
@ -99,36 +78,11 @@
|
|||
type="immo"
|
||||
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.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"}}
|
||||
|
|
@ -137,8 +91,9 @@
|
|||
{{:assign type_immo=$_GET.type_immo}}
|
||||
{{/if}}
|
||||
{{:redirect force="index.html?ok=1&msg=infos&type_immo=%s"|args:$type_immo}}
|
||||
{{/form}}
|
||||
{{else}}
|
||||
{{:form_errors}}
|
||||
{{/form}}
|
||||
|
||||
{{:admin_header title="Classer l'immobilisation" custom_css=$custom_css current="module_amortization"}}
|
||||
|
||||
|
|
@ -152,13 +107,16 @@
|
|||
{{if $info_immo != null}}
|
||||
{{:assign date_defaut=$info_immo.date}}
|
||||
{{:assign duree_defaut=$info_immo.duration}}
|
||||
{{: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
|
||||
*}}
|
||||
<form method="post" action="">
|
||||
<fieldset>
|
||||
|
|
@ -176,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>
|
||||
|
|
|
|||
|
|
@ -12,11 +12,9 @@
|
|||
line.debit as montant,
|
||||
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_id|intval
|
||||
assign=ligne_immo
|
||||
|
|
@ -31,37 +29,17 @@
|
|||
{{:assign duree=$duration}}
|
||||
{{:assign date_debut=$date}}
|
||||
{{:assign status=$status}}
|
||||
{{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_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_id AND line.credit > 0 AND acc.code = :account;
|
||||
:immo_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,
|
||||
l_amort.label as amort_label,
|
||||
l_amort.id as amort_line_id,
|
||||
l_amort.id as amort_line,
|
||||
CASE WHEN links.id_related = t_immo.id
|
||||
THEN links.id_transaction
|
||||
ELSE links.id_related
|
||||
|
|
@ -75,7 +53,9 @@
|
|||
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
|
||||
|
|
@ -84,20 +64,8 @@
|
|||
AND account.code LIKE '28%'
|
||||
ORDER BY trans.date;
|
||||
:line_id = $_GET.immo_id|intval
|
||||
assign="amort_line"
|
||||
assign=linked_lines.
|
||||
}}
|
||||
|
||||
{{#load type="link"
|
||||
where="$$.immo_line_id = :immo_line_id AND $$.amort_trans_id = :amort_trans_id"
|
||||
assign="line"
|
||||
:immo_line_id=$_GET.immo_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}}
|
||||
{{if $date_debut == null}}
|
||||
{{:assign date_debut=$amort_date}}
|
||||
{{/if}}
|
||||
|
|
@ -108,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}}
|
||||
|
|
@ -122,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
|
||||
|
|
@ -132,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}}
|
||||
|
||||
|
|
@ -260,7 +207,7 @@
|
|||
</div>
|
||||
|
||||
<h3 class="ruler">Amortissements enregistrés</h3>
|
||||
{{if $linked_amort != null}}
|
||||
{{if $linked_lines != null}}
|
||||
<section class="amortissement">
|
||||
<table class="list">
|
||||
<thead>
|
||||
|
|
@ -276,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}}
|
||||
|
|
@ -296,7 +243,7 @@
|
|||
<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_id=%d&immo_id=%d"|args:$line.amort_line_id:$ligne_immo.immo_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}}
|
||||
|
|
|
|||
|
|
@ -44,6 +44,8 @@
|
|||
|
||||
{{* ajouter la nouvelle liaison *}}
|
||||
{{: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_id|intval
|
||||
:amort_trans_id = $amort_id
|
||||
:amort_line_id = $_GET.amort_id|intval
|
||||
limit=1
|
||||
}}
|
||||
{{else}}
|
||||
{{:save
|
||||
key=""|uuid
|
||||
type="link"
|
||||
immo_line_id=$_GET.immo_id|intval
|
||||
amort_line_id=$_GET.amort_id|intval
|
||||
amort_trans_id=$amort_id
|
||||
}}
|
||||
{{/load}}
|
||||
{{:redirect force="amortization.html?immo_id=%s&ok=1&msg=attach&trans_id=%s"|args:$_GET.immo_id:$amort_id}}
|
||||
|
|
|
|||
|
|
@ -8,13 +8,10 @@
|
|||
{{* 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_id|intval
|
||||
assign="ligne_immo"
|
||||
|
|
@ -30,101 +27,51 @@
|
|||
{{: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_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_id AND line.credit > 0 AND acc.code = :account;
|
||||
:immo_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%'
|
||||
;
|
||||
LIMIT 1;
|
||||
:line_id = $_GET.immo_id|intval
|
||||
assign="amort_line"
|
||||
assign=amort_line
|
||||
}}
|
||||
|
||||
{{#load type="link"
|
||||
where="$$.immo_line_id = :immo_line_id AND $$.amort_trans_id = :amort_trans_id"
|
||||
assign="line"
|
||||
:immo_line_id=$_GET.immo_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_id=%s&amort_amount=%s&year=%s&date_mes=%s&date_debut=%s&exit_date=%s&duree_amort=%s"|args:$_GET.immo_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>
|
||||
|
|
|
|||
|
|
@ -14,13 +14,10 @@
|
|||
|
||||
{{#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_id|intval
|
||||
assign="ligne_immo"
|
||||
|
|
@ -28,29 +25,11 @@
|
|||
{{else}}
|
||||
{{: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_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_id AND line.credit > 0 AND acc.code = :account;
|
||||
:immo_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 *}}
|
||||
|
|
|
|||
|
|
@ -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_id|intval
|
||||
:amort_trans_id = $amort_id|intval
|
||||
:amort_line_id = $_GET.amort_id|intval
|
||||
}}
|
||||
{{:delete id=$id}}
|
||||
{{/load}}
|
||||
|
||||
{{:redirect to="amortization.html?immo_id=%s&ok=1&msg=detach&trans_id=%s"|args:$_GET.immo_id:$amort_id}}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
name="Amortissements"
|
||||
description="Immobilisations et amortissements\nversion 0.29"
|
||||
description="Immobilisations et amortissements\nversion 0.28"
|
||||
author="Jean-Christophe Engel"
|
||||
author_url="https://gitea.zaclys.com/lesanges"
|
||||
home_button=false
|
||||
|
|
|
|||
|
|
@ -8,7 +8,11 @@
|
|||
|
||||
{{* récupérer les infos de l'immobilisation *}}
|
||||
{{#select
|
||||
trans.label as label
|
||||
line.id as immo_id,
|
||||
line.debit as montant,
|
||||
trans.id as trans_id,
|
||||
trans.label as 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;
|
||||
|
|
@ -27,14 +31,13 @@
|
|||
{{/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,
|
||||
|
|
@ -46,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"
|
||||
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 var="autres_amortissements." value=$amort}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{:assign var="autres_amortissements." value=$amort}}
|
||||
{{:assign var="autres_amortissements." value=$autre_amort}}
|
||||
{{/select}}
|
||||
{{/select}}
|
||||
|
||||
|
|
@ -121,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}}{{/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_id=%d&immo_id=%d"|args:$line.amort_line_id:$_GET.immo_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}}
|
||||
|
|
|
|||
|
|
@ -184,14 +184,14 @@
|
|||
{{:assign
|
||||
var="lines."
|
||||
debit=$_POST.montant
|
||||
account=$debit_account|keys|value:0
|
||||
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
|
||||
account=$credit_account|keys|key:0
|
||||
id_project=$_GET.project_id
|
||||
label=$_POST.designation
|
||||
}}
|
||||
|
|
|
|||
|
|
@ -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}}
|
||||
|
|
@ -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}}
|
||||
|
|
|
|||
|
|
@ -16,10 +16,10 @@
|
|||
{{#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
|
||||
|
|
@ -30,28 +30,11 @@
|
|||
}}
|
||||
{{/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_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_id AND line.credit > 0 AND acc.code = :account;
|
||||
:immo_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"
|
||||
|
|
@ -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