Adaptation sortie bilan aux nouveaux documents
This commit is contained in:
parent
c427e8900f
commit
bb8d27b616
3 changed files with 138 additions and 160 deletions
|
|
@ -3,14 +3,18 @@
|
|||
{{*
|
||||
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
|
||||
- amort_amount : montant des amortissements
|
||||
- year : exercice de la date de sortie de l'immobilisation
|
||||
- date_mes : datede mise en service de l'immobilisation
|
||||
- date_debut : date de début de la période d'amortissement complémentaire
|
||||
- exit_date : date de sortie de l'immobilisation
|
||||
- duree_amort : durée de l'amortiseement (optionnel)
|
||||
@param immo_doc_id : id du doc associé à l'immo
|
||||
@param amort_amount : montant des amortissements
|
||||
@param year : exercice de la date de sortie de l'immobilisation
|
||||
@param date_debut : date de début de la période d'amortissement complémentaire
|
||||
@param exit_date : date de sortie de l'immobilisation
|
||||
*}}
|
||||
{{* TODO *}}
|
||||
{{* Infos de l'immobilisation *}}
|
||||
{{#load id=$_GET.immo_doc_id|intval assign="info_immo"}}
|
||||
{{else}}
|
||||
{{:error message="Immobilisation non trouvée"}}
|
||||
{{/load}}
|
||||
|
||||
{{#select
|
||||
line.debit as montant,
|
||||
|
|
@ -22,41 +26,62 @@
|
|||
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 = $info_immo.line
|
||||
assign="ligne_immo"
|
||||
}}
|
||||
{{else}}
|
||||
{{:error message="Immobilisation %s non trouvée"|args:$_GET.immo_line_id}}
|
||||
{{:error message="Immobilisation non trouvée"}}
|
||||
{{/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}}
|
||||
{{#load
|
||||
type="credit_link"
|
||||
where="$$.immo_doc_id = :immo_doc_id"
|
||||
:immo_doc_id = $info_immo.id
|
||||
assign="credit_link"
|
||||
}}
|
||||
{{if $amount == null}}
|
||||
{{#select credit FROM acc_transactions_lines WHERE id = :credit_line_id;
|
||||
:credit_line_id=$credit_line_id
|
||||
}}
|
||||
{{:assign total_credits="%d+%d"|math:$total_credits:$credit}}
|
||||
{{/select}}
|
||||
{{else}}
|
||||
{{:assign total_credits="%d+%d"|math:$total_credits:$amount}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{*
|
||||
TODO : à garder ?
|
||||
pas de doc => voir liaison écritures
|
||||
*}}
|
||||
{{#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}}
|
||||
{{/load}}
|
||||
{{:assign var="ligne_immo.montant" value="%d-%d"|math:$ligne_immo.montant:$total_credits}}
|
||||
|
||||
{{:assign valeur_nette="%f-%f"|math:$ligne_immo.montant:$_GET.amort_amount}}
|
||||
|
||||
{{:assign amort_comp=0}} {{* amortissement complémentaire jqà date sortie *}}
|
||||
{{if $valeur_nette > 0}}
|
||||
{{:assign nbjours="1+(%d-%d)/(60*60*24)"|math:$_GET.exit_date:$_GET.date_debut}}
|
||||
{{:assign annuite="%f/%f"|math:$ligne_immo.montant:$_GET.duree_amort}}
|
||||
{{:assign annuite="%f/%f"|math:$ligne_immo.montant:$info_immo.duration}}
|
||||
{{:assign amort_comp="round(%f/365*%f, 0)"|math:$annuite:$nbjours}}
|
||||
{{:assign amort_comp="min(%f, %f)"|math:$valeur_nette:$amort_comp}}
|
||||
{{/if}}
|
||||
|
|
@ -69,7 +94,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_doc_id=%s&amort_amount=%s&year=%s&date_debut=%s&exit_date=%s&cession=%s"|args:$_GET.immo_doc_id:$_GET.amort_amount:$_GET.year:$_GET.date_debut:$_GET.exit_date:$_POST.montant_cession}}
|
||||
|
||||
{{/form}}
|
||||
{{:admin_header title="Sortie du bilan" custom_css="./style.css" current="module_amortization"}}
|
||||
|
|
@ -91,14 +116,12 @@
|
|||
<dd id="montant_immo" class="money">{{$ligne_immo.montant|money_currency_html:false|raw}}</dd>
|
||||
<dt>Date d'acquisition</dt>
|
||||
<dd >{{$ligne_immo.date_achat|date_short}}</dd>
|
||||
{{if $_GET.date_mes != $ligne_immo.date_achat|strtotime}}
|
||||
{{if $info_immo.date_mes != null && $info_immo.date_mes != $ligne_immo.date_achat}}
|
||||
<dt>Date de mise en service</dt>
|
||||
<dd>{{$_GET.date_mes|date:"d/m/Y"}}</dd>
|
||||
{{/if}}
|
||||
{{if $_GET.duree_amort != null && $_GET.duree_amort != 0}}
|
||||
<dt>Durée de l'amortissement</dt>
|
||||
<dd id="duree_amort" class="num">{{$_GET.duree_amort}} ans</dd>
|
||||
<dd>{{$info_immo.date_mes|date_short}}</dd>
|
||||
{{/if}}
|
||||
<dt>Durée de l'amortissement</dt>
|
||||
<dd id="duree_amort" class="num">{{$info_immo.duration}} ans</dd>
|
||||
<dt>Montant des amortissements</dt>
|
||||
<dd id="montant_amort" class="money">{{$_GET.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>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue