Ajout possibilité détachement écriture crédit
This commit is contained in:
parent
18ce7b0edd
commit
91ec943e6d
2 changed files with 118 additions and 38 deletions
73
detach_immo.html
Normal file
73
detach_immo.html
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
{{* -*- brindille -*- *}}
|
||||
|
||||
{{*
|
||||
Supprimer l'association entre une écriture d'immobilisation et
|
||||
une écriture au crédit du compte d'immobilisation
|
||||
@param immo_line_id : id de la ligne d'immo
|
||||
@param credit__line_id : id de la ligne de crédit
|
||||
@param immo_doc_id : id du doc associé à l'immo
|
||||
*}}
|
||||
|
||||
{{* chercher l'écriture d'immobilisation *}}
|
||||
{{#select
|
||||
id_transaction
|
||||
FROM acc_transactions_lines
|
||||
WHERE id = :line_id;
|
||||
:line_id = $_GET.immo_line_id|intval
|
||||
}}
|
||||
{{:assign immo_trans_id=$id_transaction}}
|
||||
{{else}}
|
||||
{{:error message="Immobilisation non trouvée"}}
|
||||
{{/select}}
|
||||
|
||||
{{* chercher l'écriture au crédit *}}
|
||||
{{#select
|
||||
id_transaction
|
||||
FROM acc_transactions_lines
|
||||
WHERE id = :line_id;
|
||||
:line_id = $_GET.credit_line_id|intval
|
||||
}}
|
||||
{{:assign credit_id=$id_transaction}}
|
||||
{{else}}
|
||||
{{:error message="Écriture au crédit non trouvée"}}
|
||||
{{/select}}
|
||||
|
||||
{{*
|
||||
chercher les liaisons de l'écriture d'immobilisation
|
||||
et supprimer la liaison avec l'écriture au crédit
|
||||
*}}
|
||||
{{#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 != $credit_id}}
|
||||
{{:assign var="linked_transactions." value=$linked_id}}
|
||||
{{/if}}
|
||||
{{/select}}
|
||||
|
||||
{{* Enregistrer les liaisons *}}
|
||||
{{:api
|
||||
method="POST"
|
||||
path="accounting/transaction/%s/transactions"|args:$immo_trans_id
|
||||
assign="result"
|
||||
assign_code="result_code"
|
||||
transactions=$linked_transactions
|
||||
}}
|
||||
|
||||
{{* supprimer le doc de liaison entre les lignes *}}
|
||||
{{#load type="credit_link"
|
||||
where="$$.immo_doc_id = :immo_doc_id AND $$.credit_line_id = :credit_line_id"
|
||||
:immo_doc_id=$_GET.immo_doc_id|intval
|
||||
:credit_line_id = $_GET.credit_line_id|intval
|
||||
}}
|
||||
{{:delete id=$id}}
|
||||
{{/load}}
|
||||
|
||||
{{:redirect
|
||||
to="details_immo.html?immo_doc_id=%s&ok=1&msg=detach&"|args:$_GET.immo_doc_id}}
|
||||
*}}
|
||||
Loading…
Add table
Add a link
Reference in a new issue