2024-02-29 19:07:52 +01:00
|
|
|
{{* -*- brindille -*- *}}
|
|
|
|
|
|
|
|
{{*
|
|
|
|
Supprimer l'association entre une écriture d'amortissement et
|
|
|
|
une écriture d'immobilisation
|
|
|
|
*}}
|
|
|
|
|
2024-12-17 10:15:30 +01:00
|
|
|
{{* 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}}
|
2024-02-29 19:07:52 +01:00
|
|
|
{{else}}
|
2024-12-17 10:15:30 +01:00
|
|
|
{{:error message="Impossible de trouver l'écriture d'immobilisation de la ligne « %s »"|args:$_GET.immo_id}}
|
|
|
|
{{/select}}
|
2024-02-29 19:07:52 +01:00
|
|
|
|
2024-12-17 10:15:30 +01:00
|
|
|
{{* 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}}
|
2024-02-29 19:07:52 +01:00
|
|
|
|
2024-12-17 10:15:30 +01:00
|
|
|
{{*
|
|
|
|
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}}
|
2024-02-29 19:07:52 +01:00
|
|
|
{{/if}}
|
2024-12-17 10:15:30 +01:00
|
|
|
{{/select}}
|
2024-02-29 19:07:52 +01:00
|
|
|
|
2024-12-17 10:15:30 +01:00
|
|
|
{{* Enregistrer les liaisons *}}
|
|
|
|
{{:api
|
|
|
|
method="POST"
|
|
|
|
path="accounting/transaction/%s/transactions"|args:$immo_trans_id
|
|
|
|
assign="result"
|
|
|
|
assign_code="result_code"
|
|
|
|
transactions=$linked_transactions
|
2024-02-29 19:07:52 +01:00
|
|
|
}}
|
2024-12-18 15:11:28 +01:00
|
|
|
{{:redirect to="amortization.html?immo_id=%s&ok=1&msg=detach&trans_id=%s"|args:$_GET.immo_id:$amort_id}}
|