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