refonte attachement/détachement écritures amortissement
This commit is contained in:
parent
59e6abe581
commit
10f2128b1b
@ -26,8 +26,7 @@
|
||||
{{* récupérer les infos de l'immobilisation *}}
|
||||
{{#load type="immo" assign="info_immo" where="$$.line = :line_id" :line_id=$_GET.immo_id|intval}}
|
||||
{{else}}
|
||||
{{:assign message="Pas d'info concernant l'immobilisation %s"|args:$_GET.immo_id}}
|
||||
{{:error message=$message}}
|
||||
{{:error message="Pas d'info concernant l'immobilisation %s"|args:$_GET.immo_id}}
|
||||
{{/load}}
|
||||
{{:assign var="duree" from="info_immo.duration"|args:$_GET.immo_id}}
|
||||
|
||||
@ -52,8 +51,7 @@
|
||||
}}
|
||||
<h2>Amortissement de « {{$label}} » d'un montant de {{"%f"|math:$montant|money_currency}} en date du {{$date_achat|date_short}} sur {{$duree}} ans</h2>
|
||||
{{else}}
|
||||
{{:assign message="Immobilisation %s non trouvée"|args:$_GET.immo_id}}
|
||||
{{:error message=$message}}
|
||||
{{:error message="Immobilisation %s non trouvée"|args:$_GET.immo_id}}
|
||||
{{/select}}
|
||||
|
||||
{{* chercher des écritures d'amortissement liées à l'immobilisation *}}
|
||||
@ -70,8 +68,7 @@
|
||||
trans.id_year as amort_year,
|
||||
acc.id as account_id,
|
||||
acc.code as account_code,
|
||||
acc.label as account_name,
|
||||
"vrai" as linked
|
||||
acc.label as account_name
|
||||
FROM
|
||||
acc_transactions_lines as l_immo
|
||||
INNER JOIN acc_transactions as t_immo on t_immo.id = l_immo.id_transaction
|
||||
@ -154,11 +151,7 @@
|
||||
<td><a href={{$compte_url}}>{{$line.account_code}}</a></td>
|
||||
<td>{{$line.account_name}}</td>
|
||||
<td>
|
||||
{{if $line.linked == null}}
|
||||
{{:linkbutton label="Détacher" href="detach_amort.html?amort_id=%d&immo_id=%d"|args:$line.amort_line:$ligne_immo.immo_id shape="plus"}}
|
||||
{{else}}
|
||||
{{*:linkbutton label="Détacher" href="" shape="lock" class="disabled"*}}
|
||||
{{/if}}
|
||||
{{:linkbutton label="Détacher" href="detach_amort.html?amort_id=%d&immo_id=%d"|args:$line.amort_line:$ligne_immo.immo_id shape="plus"}}
|
||||
</td>
|
||||
</tr>
|
||||
{{:assign annuite_courante=$annuite}}
|
||||
@ -221,8 +214,6 @@
|
||||
shape="right"
|
||||
target="_dialog"
|
||||
}}
|
||||
{{else}}
|
||||
{{*:linkbutton label="Créer l'écriture" href="" shape="lock" class="disabled"*}}
|
||||
{{/if}}
|
||||
</td>
|
||||
</tr>
|
||||
@ -259,7 +250,6 @@
|
||||
order by trans.date, trans.label;
|
||||
assign=autre_amort
|
||||
}}
|
||||
{{:assign linked="false"}}
|
||||
{{#select
|
||||
id_transaction,
|
||||
id_related
|
||||
@ -267,7 +257,6 @@
|
||||
where id_transaction = :id_amort or id_related = :id_amort;
|
||||
:id_amort=$t_id
|
||||
}}
|
||||
{{:assign var=autre_amort.linked value="true"}}
|
||||
{{else}}
|
||||
{{:assign var="autres_amortissements." value=$autre_amort}}
|
||||
{{/select}}
|
||||
@ -305,11 +294,7 @@
|
||||
<td>{{$line.a_code}}</td>
|
||||
<td>{{$line.a_label}}</td>
|
||||
<td>
|
||||
{{if $linked != "true"}}
|
||||
{{:linkbutton label="Attacher" href="attach_amort.html?amort_id=%d&immo_id=%d"|args:$line.l_id:$ligne_immo.immo_id shape="plus"}}
|
||||
{{else}}
|
||||
{{:linkbutton label="Attacher" href="" shape="lock" class="disabled"}}
|
||||
{{/if}}
|
||||
{{:linkbutton label="Attacher" href="attach_amort.html?amort_id=%d&immo_id=%d"|args:$line.l_id:$ligne_immo.immo_id shape="plus"}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/foreach}}
|
||||
|
@ -12,11 +12,9 @@
|
||||
WHERE id = :line_id;
|
||||
:line_id = $_GET.immo_id|intval
|
||||
}}
|
||||
{{:assign immo_id=$id_transaction}}
|
||||
{{:assign immo_trans_id=$id_transaction}}
|
||||
{{else}}
|
||||
{{* TODO : améliorer le message d'erreur *}}
|
||||
{{:assign message="Impossible de trouver l'écriture d'immobilisation de la ligne « %s »"|args:$_GET.immo_id}}
|
||||
{{:error message=$message}}
|
||||
{{:error message="Impossible de trouver l'écriture d'immobilisation de la ligne « %s »"|args:$_GET.immo_id}}
|
||||
{{/select}}
|
||||
|
||||
{{* chercher l'écriture d'amortissement *}}
|
||||
@ -28,20 +26,18 @@
|
||||
}}
|
||||
{{:assign amort_id=$id_transaction}}
|
||||
{{else}}
|
||||
{{* TODO : améliorer le message d'erreur *}}
|
||||
{{:assign message="Impossible de trouver l'écriture d'amortissement de la ligne « %s »"|args:$_GET.amort_id}}
|
||||
{{:error message=$message}}
|
||||
{{: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 *}}
|
||||
{{#select
|
||||
CASE links.id_related = :immo_id
|
||||
CASE links.id_related = :immo_trans_id
|
||||
WHEN true THEN links.id_transaction
|
||||
WHEN false THEN links.id_related
|
||||
END as linked_id
|
||||
FROM acc_transactions_links as links
|
||||
WHERE id_transaction = :immo_id or id_related = :immo_id;
|
||||
:immo_id = $immo_id
|
||||
WHERE id_transaction = :immo_trans_id or id_related = :immo_trans_id;
|
||||
:immo_trans_id = $immo_trans_id
|
||||
}}
|
||||
{{:assign var="linked_transactions." value=$linked_id}}
|
||||
{{/select}}
|
||||
@ -52,10 +48,9 @@
|
||||
{{* Enregistrer les liaisons *}}
|
||||
{{:api
|
||||
method="POST"
|
||||
path="accounting/transaction/%s/transactions"|args:$immo_id
|
||||
path="accounting/transaction/%s/transactions"|args:$immo_trans_id
|
||||
assign="result"
|
||||
assign_code="result_code"
|
||||
transactions=$linked_transactions
|
||||
}}
|
||||
|
||||
{{:redirect to="amortization.html?immo_id=%s&ok=1&msg=attach"|args:$_GET.immo_id}}
|
||||
|
@ -5,27 +5,54 @@
|
||||
une écriture d'immobilisation
|
||||
*}}
|
||||
|
||||
{{#load type="immo" assign="info_immo" where="$$.line = :line_id" :line_id=$_GET.immo_id|intval}}
|
||||
{{* chercher l'écriture d'immobilisation *}}
|
||||
{{#select
|
||||
id_transaction
|
||||
FROM acc_transactions_lines
|
||||
WHERE id = :line_id;
|
||||
:line_id = $_GET.immo_id|intval
|
||||
}}
|
||||
{{:assign immo_trans_id=$id_transaction}}
|
||||
{{else}}
|
||||
{{:assign message="Pas d'info concernant l'immobilisation %s"|args:$_GET.immo_id}}
|
||||
{{:error message=$message}}
|
||||
{{/load}}
|
||||
{{:error message="Impossible de trouver l'écriture d'immobilisation de la ligne « %s »"|args:$_GET.immo_id}}
|
||||
{{/select}}
|
||||
|
||||
{{:assign var="liste_amort" val=$info_immo.amort}}
|
||||
{{* chercher l'écriture d'amortissement *}}
|
||||
{{#select
|
||||
id_transaction
|
||||
FROM acc_transactions_lines
|
||||
WHERE id = :line_id;
|
||||
: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_id}}
|
||||
{{/select}}
|
||||
|
||||
{{#foreach from=$info_immo.amort item="amort_id"}}
|
||||
{{if $amort_id != $_GET.amort_id}}
|
||||
{{:assign var="t_amort." value=$amort_id}}
|
||||
{{*
|
||||
chercher les liaisons de l'écriture d'immobilisation
|
||||
et supprimer la liaison avec l'écriture d'amortissement
|
||||
*}}
|
||||
{{#select
|
||||
CASE links.id_related = :immo_trans_id
|
||||
WHEN true THEN links.id_transaction
|
||||
WHEN false THEN links.id_related
|
||||
END as linked_id
|
||||
FROM acc_transactions_links as links
|
||||
WHERE id_transaction = :immo_trans_id or id_related = :immo_trans_id;
|
||||
:immo_trans_id = $immo_trans_id
|
||||
}}
|
||||
{{if $linked_id != $amort_id}}
|
||||
{{:assign var="linked_transactions." value=$linked_id}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
{{/select}}
|
||||
|
||||
{{* Enregistrer les infos *}}
|
||||
{{:save
|
||||
key=$info_immo.key
|
||||
validate_schema="schema.json"
|
||||
type="immo"
|
||||
line=$info_immo.line
|
||||
duration=$info_immo.duration
|
||||
amort=$t_amort
|
||||
{{* Enregistrer les liaisons *}}
|
||||
{{:api
|
||||
method="POST"
|
||||
path="accounting/transaction/%s/transactions"|args:$immo_trans_id
|
||||
assign="result"
|
||||
assign_code="result_code"
|
||||
transactions=$linked_transactions
|
||||
}}
|
||||
{{:redirect to="amortization.html?immo_id=%s&ok=1&msg=detach"|args:$_GET.immo_id}}
|
||||
|
Loading…
Reference in New Issue
Block a user