Compare commits
3 commits
3169fe9268
...
c07b77e942
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c07b77e942 | ||
|
|
a1ce03a7b4 | ||
|
|
4e131e1f5b |
4 changed files with 104 additions and 35 deletions
|
|
@ -63,15 +63,14 @@
|
|||
{{:assign total_credits="%d+%d"|math:$total_credits:$amount}}
|
||||
{{/if}}
|
||||
{{/load}}
|
||||
{{:assign var="ligne_immo.montant" value="%d-%d"|math:$ligne_immo.montant:$total_credits}}
|
||||
{{:assign solde=$ligne_immo.montant}}
|
||||
{{:assign solde="%d-%d"|math:$ligne_immo.montant:$total_credits}}
|
||||
{{*:debug info_immo=$info_immo ligne_immo=$ligne_immo total_credits=$total_credits solde=$solde*}}
|
||||
|
||||
{{if $info_immo.status == "amortized"}}
|
||||
{{:assign amort_amount=$ligne_immo.montant}}
|
||||
{{:assign amort_amount=$solde}}
|
||||
{{:assign valeur_residuelle=0}}
|
||||
{{else}}
|
||||
{{:assign valeur_residuelle=$ligne_immo.montant}}
|
||||
{{:assign valeur_residuelle=$solde}}
|
||||
{{/if}}
|
||||
|
||||
{{* lister les lignes des écritures d'amortissement liées à l'immobilisation *}}
|
||||
|
|
@ -208,13 +207,13 @@
|
|||
{{/if}}
|
||||
{{if $valeur_residuelle > 0}}
|
||||
<dt>Montant des amortissements</dt>
|
||||
<dd>{{"%d-%d"|math:$ligne_immo.montant:$valeur_residuelle|money_currency_html:false|raw}}</dd>
|
||||
<dd>{{"%d-%d"|math:$solde:$valeur_residuelle|money_currency_html:false|raw}}</dd>
|
||||
<dt>Valeur nette comptable</dt>
|
||||
<dd>{{$valeur_residuelle|money_currency_html:false|raw}}</dd>
|
||||
{{/if}}
|
||||
{{if $info_immo.duration != null && $valeur_residuelle > 0}}
|
||||
<dt>Annuité estimée</dt>
|
||||
<dd>{{"min(%d, %f/%d)"|math:$valeur_residuelle:$ligne_immo.montant:$info_immo.duration|money_currency_html:false|raw}}</dd>
|
||||
<dd>{{"min(%d, %f/%d)"|math:$valeur_residuelle:solde:$info_immo.duration|money_currency_html:false|raw}}</dd>
|
||||
{{/if}}
|
||||
</dl>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
{{* chercher l'écriture d'immobilisation *}}
|
||||
{{#select
|
||||
line.id_transaction as immo_trans_id,
|
||||
line.debit as montant,
|
||||
trans.label as trans_label,
|
||||
line.label as line_label
|
||||
FROM acc_transactions_lines as line
|
||||
|
|
@ -24,11 +25,12 @@
|
|||
{{/select}}
|
||||
|
||||
{{* chercher le doc associé à l'immo *}}
|
||||
{{#load id=$_GET.immo_doc_id|intval}}
|
||||
{{#load id=$_GET.immo_doc_id|intval assign="info_immo"}}
|
||||
{{:assign label_immo=$label|or:$ligne_immo.trans_label}}
|
||||
{{else}}
|
||||
{{:error message="Immobilisation non trouvée"}}
|
||||
{{/load}}
|
||||
{{:assign montant_immo=$info_immo.amount|or:$ligne_immo.montant}}
|
||||
|
||||
{{if $ligne_immo.line_label != null && $ligne_immo.line_label != $label_immo}}
|
||||
{{:assign label_immo=$label_immo|cat:" — "|cat:$ligne_immo.line_label}}
|
||||
|
|
@ -67,9 +69,9 @@
|
|||
|
||||
{{* Traiter l'envoi du formulaire *}}
|
||||
{{#form on="save"}}
|
||||
|
||||
{{* vérifier que le montant saisi est inférieur au reste *}}
|
||||
{{if $_POST.montant == null}}
|
||||
{{if $_POST.montant == null || $_POST.montant == 0}}
|
||||
{{:assign montant_amort=$reste}}
|
||||
{{if $montant_affecte == 0}}
|
||||
{{:assign saved_amount=null}}
|
||||
{{else}}
|
||||
|
|
@ -88,6 +90,57 @@
|
|||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
{{* vérifier que le montant total des amortissements ne dépasse pas la valeur de l'immo *}}
|
||||
{{* montant de l'immo *}}
|
||||
{{:assign total_credits=0}}
|
||||
{{#load
|
||||
type="credit_link"
|
||||
where="$$.immo_doc_id = :immo_doc_id" :immo_doc_id = $_GET.immo_doc_id|intval
|
||||
}}
|
||||
{{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}}
|
||||
{{/load}}
|
||||
{{:assign montant_immo="%d-%d"|math:$montant_immo:$total_credits}}
|
||||
|
||||
{{* montant des amortissements *}}
|
||||
{{:assign total_amort=0}}
|
||||
{{#load
|
||||
type="amort_link"
|
||||
where="$$.immo_doc_id = :immo_doc_id"
|
||||
:immo_doc_id=$_GET.immo_doc_id|intval
|
||||
}}
|
||||
{{if $amount == null || $amount == 0}}
|
||||
{{#select
|
||||
line.credit
|
||||
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 = :amort_line_id
|
||||
;
|
||||
:amort_line_id = $amort_line_id
|
||||
}}
|
||||
{{:assign total_amort="%d+%d"|math:$total_amort:$credit}}
|
||||
{{/select}}
|
||||
{{else}}
|
||||
{{:assign total_amort="%d+%d"|math:$total_amort:$amount}}
|
||||
{{/if}}
|
||||
{{/load}}
|
||||
|
||||
{{:assign vnc="%d-%d"|math:$montant_immo:$total_amort}}
|
||||
{{:assign total_amort="%d+%d"|math:$total_amort:$montant_amort}}
|
||||
{{if $total_amort > $montant_immo}}
|
||||
{{:assign ma="%f"|math:$montant_amort|money_currency:false}}
|
||||
{{:assign vnc="%f"|math:$vnc|money_currency:false}}
|
||||
{{:error message="Le montant de l'amortissement (%s) dépasse la valeur résiduelle de l'immobilisation (%s)"|args:$ma:$vnc}}
|
||||
{{/if}}
|
||||
|
||||
{{* chercher les liaisons de l'écriture d'immobilisation *}}
|
||||
{{#select
|
||||
CASE links.id_related = :immo_trans_id
|
||||
|
|
@ -129,7 +182,16 @@
|
|||
}}
|
||||
{{/load}}
|
||||
|
||||
{{:redirect force="amortization.html?immo_line_id=%s&immo_doc_id=%s&ok=1&msg=attach_amort"|args:$_GET.immo_line_id:$_GET.immo_doc_id}}
|
||||
{{* immo soldée ? *}}
|
||||
{{if $total_amort == $montant_immo}}
|
||||
{{:assign status="amortized"}}
|
||||
{{:save
|
||||
key=$info_immo.key
|
||||
status=$status
|
||||
}}
|
||||
{{/if}}
|
||||
|
||||
{{:redirect force="amortization.html?immo_line_id=%s&immo_doc_id=%s&type_immo=%s&ok=1&msg=attach_amort"|args:$_GET.immo_line_id:$_GET.immo_doc_id:$status}}
|
||||
{{/form}}
|
||||
|
||||
{{:admin_header title="Amortir l'immobilisation" custom_css="./style.css" current="module_amortization"}}
|
||||
|
|
@ -148,10 +210,12 @@
|
|||
<dd><span class="num"><a href="{{$trans_url}}">#{{$amort_line.trans_id}}</a></span> {{$label_immo}}</dd>
|
||||
<dt>Montant de l'écriture d'amortissement</dt>
|
||||
<dd>{{$amort_line.amount|money_currency_html:false|raw}}</dd>
|
||||
{{if $montant_affecte > 0}}
|
||||
<dt>Montant déjà affecté</dt>
|
||||
<dd class="money strong">{{"%f"|math:$montant_affecte|money_currency_html:false|raw}}</dd>
|
||||
<dt>Montant restant à affecter</dt>
|
||||
<dd class="money strong">{{"%f"|math:$reste|money_currency_html:false|raw}}</dd>
|
||||
{{/if}}
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -68,5 +68,12 @@
|
|||
{{:delete id=$id}}
|
||||
{{/load}}
|
||||
|
||||
{{* marquer immo non soldée *}}
|
||||
{{#load id=$_GET.immo_doc_id|intval assign="info_immo"}}{{/load}}
|
||||
{{:save
|
||||
key=$info_immo.key
|
||||
status="managed"
|
||||
}}
|
||||
|
||||
{{:redirect
|
||||
to="amortization.html?immo_line_id=%s&ok=1&msg=detach&immo_doc_id=%s"|args:$_GET.immo_line_id:$_GET.immo_doc_id}}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
{{/select}}
|
||||
{{:assign date_debut=$ligne_immo.date}}
|
||||
|
||||
{{#load id=$_GET.immo_doc_id|intval}}
|
||||
{{#load id=$_GET.immo_doc_id|intval assign="info_immo"}}
|
||||
{{:assign duree=$duration}}
|
||||
{{if $date_mes != null}}
|
||||
{{:assign date_debut=$date_mes}}
|
||||
|
|
@ -222,15 +222,14 @@
|
|||
debit=$_POST.montant
|
||||
account=$debit_account|keys|value:0
|
||||
id_project=$ligne_immo.project_id
|
||||
label=$_POST.designation
|
||||
}}
|
||||
{{:assign
|
||||
var="lines."
|
||||
credit=$_POST.montant
|
||||
account=$credit_account|keys|value:0
|
||||
id_project=$ligne_immo.project_id
|
||||
label=$_POST.designation
|
||||
}}
|
||||
|
||||
{{:api
|
||||
method="POST"
|
||||
path="accounting/transaction"
|
||||
|
|
@ -245,28 +244,28 @@
|
|||
}}
|
||||
|
||||
{{* 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}}
|
||||
{{#foreach from=$result.lines item="line"}}
|
||||
{{if $line.account_code == $credit_account|keys|value:0}}
|
||||
{{:save
|
||||
key=""|uuid
|
||||
type="amort_link"
|
||||
immo_doc_id=$_GET.immo_doc_id|intval
|
||||
amort_line_id=$amort_line_id|intval
|
||||
amort_line_id=$line.id
|
||||
}}
|
||||
{{:break}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
|
||||
{{* immo soldée ? *}}
|
||||
{{if $_POST.montant|trim|money_int == $solde}}
|
||||
{{:assign status="amortized"}}
|
||||
{{:save
|
||||
key=$info_immo.key
|
||||
status=$status
|
||||
}}
|
||||
{{/if}}
|
||||
|
||||
{{:redirect force="amortization.html?immo_line_id=%s&immo_doc_id=%s&ok=1&msg=amortissement"|args:$_GET.immo_line_id:$_GET.immo_doc_id}}
|
||||
{{:redirect force="amortization.html?immo_line_id=%s&immo_doc_id=%s&type_immo=%s&ok=1&msg=amortissement"|args:$_GET.immo_line_id:$_GET.immo_doc_id:$status}}
|
||||
{{/form}}
|
||||
|
||||
{{:admin_header title="Ajout amortissement" custom_css="./style.css" current="module_amortization"}}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue