Gestion des attachements avec écritures liées
This commit is contained in:
parent
77aac6fd4a
commit
7d829bbf9c
@ -25,9 +25,6 @@
|
||||
|
||||
{{* récupérer les infos de l'immobilisation *}}
|
||||
{{#load type="immo" assign="info_immo" where="$$.line = :line_id" :line_id=$_GET.immo_id|intval}}
|
||||
{{#foreach from=$amort item="elem"}}
|
||||
{{:assign var="amort_associes." value=$elem"}}
|
||||
{{/foreach}}
|
||||
{{else}}
|
||||
{{:assign message="Pas d'info concernant l'immobilisation %s"|args:$_GET.immo_id}}
|
||||
{{:error message=$message}}
|
||||
@ -94,46 +91,9 @@
|
||||
:line_id = $_GET.immo_id|intval
|
||||
assign=linked_lines.
|
||||
}}
|
||||
{{:assign var="amort_associes." value=$amort_line}}
|
||||
{{:assign var="amort_years." value=$amort_year}}
|
||||
{{/select}}
|
||||
|
||||
{{* chercher parmi les associations *}}
|
||||
{{#foreach from=$info_immo.amort item="id_amort"}}
|
||||
{{#select
|
||||
l_amort.id_transaction as amort_trans_id,
|
||||
l_amort.credit as amort_amount,
|
||||
l_amort.label as amort_label,
|
||||
trans.date as amort_date,
|
||||
trans.label as trans_label,
|
||||
trans.id_year as amort_year,
|
||||
acc.code as account_code,
|
||||
acc.label as account_name,
|
||||
project.label as project_label
|
||||
from acc_transactions_lines as l_amort
|
||||
inner join acc_transactions as trans on l_amort.id_transaction = trans.id
|
||||
inner join acc_accounts as acc on l_amort.id_account = acc.id
|
||||
inner join acc_projects AS project ON l_amort.id_project = project.id
|
||||
where l_amort.id = :l_amort_id;
|
||||
:l_amort_id = $id_amort
|
||||
}}
|
||||
{{:assign
|
||||
var="linked_lines."
|
||||
amort_line=$id_amort
|
||||
amort_trans_id=$amort_trans_id
|
||||
amort_amount=$amort_amount
|
||||
amort_label=$amort_label
|
||||
amort_date=$amort_date
|
||||
amort_year=$amort_year
|
||||
trans_label=$trans_label
|
||||
account_code=$account_code
|
||||
account_name=$account_name
|
||||
project_label=$project_label
|
||||
}}
|
||||
{{:assign var="amort_years." value=$amort_year}}
|
||||
{{/select}}
|
||||
{{/foreach}}
|
||||
|
||||
{{* montant de l'annuité théorique *}}
|
||||
{{:assign montant="%f"|math:$ligne_immo.montant}}
|
||||
{{:assign annuite="%f/%f"|math:$montant:$duree}}
|
||||
@ -162,12 +122,11 @@
|
||||
<tr>
|
||||
<th>N°</th>
|
||||
<th>Date</th>
|
||||
<th style="text-align: right;">Montant</th>
|
||||
<th style="text-align: right;">Solde</th>
|
||||
<th class="nombre">Montant</th>
|
||||
<th class="nombre"">Solde</th>
|
||||
<th>Libellé</th>
|
||||
<th>N° compte</th>
|
||||
<th>Compte</th>
|
||||
<th>Projet</th>
|
||||
<th class="actions"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -192,7 +151,6 @@
|
||||
</td>
|
||||
<td>{{$line.account_code}}</td>
|
||||
<td>{{$line.account_name}}</td>
|
||||
<td>{{$line.project_label}}</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"}}
|
||||
@ -225,12 +183,9 @@
|
||||
<tr>
|
||||
<th>N°</th>
|
||||
<th>Date</th>
|
||||
<th>Montant</th>
|
||||
<th>Solde</th>
|
||||
<th class="nombre">Montant</th>
|
||||
<th class="nombre">Solde</th>
|
||||
<th>Libellé</th>
|
||||
<th>N° compte</th>
|
||||
<th>Compte</th>
|
||||
<th>Projet</th>
|
||||
<th class="actions"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -254,9 +209,6 @@
|
||||
{{/if}}
|
||||
{{$libelle}}
|
||||
</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td class="actions">
|
||||
{{if $enregistrer == 1}}
|
||||
{{:linkbutton
|
||||
@ -289,11 +241,10 @@
|
||||
<tr>
|
||||
<th>N°</th>
|
||||
<th>Date</th>
|
||||
<th style="text-align: right;">Montant</th>
|
||||
<th class="nombre">Montant</th>
|
||||
<th>Libellé</th>
|
||||
<th>N° compte</th>
|
||||
<th>Compte</th>
|
||||
<th>Projet</th>
|
||||
<th class="actions"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -305,7 +256,6 @@
|
||||
li.credit as montant,
|
||||
li.reference,
|
||||
li.label as l_label,
|
||||
pro.label as p_label,
|
||||
trans.date as t_date,
|
||||
trans.label as t_label,
|
||||
acc.code as a_code,
|
||||
@ -315,7 +265,6 @@
|
||||
inner join acc_accounts as acc on acc.id = li.id_account
|
||||
inner join acc_transactions as trans on trans.id = li.id_transaction
|
||||
inner join acc_years as y on y.id = trans.id_year
|
||||
inner join acc_projects as pro on li.id_project = pro.id
|
||||
where acc.code like "28%"
|
||||
order by trans.date, trans.label
|
||||
}}
|
||||
@ -324,12 +273,12 @@
|
||||
id_transaction,
|
||||
id_related
|
||||
from acc_transactions_links
|
||||
where id_transaction = :id_amort;
|
||||
where id_transaction = :id_amort or id_related = :id_amort;
|
||||
:id_amort=$t_id}}
|
||||
{{:assign linked="true"}}
|
||||
{{/select}}
|
||||
|
||||
{{if ! $l_id|in:$amort_associes && $linked != "true"}}
|
||||
{{if $linked != "true"}}
|
||||
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$t_id}}
|
||||
<tr>
|
||||
<td class="num"><a href={{$trans_url}}>#{{$t_id}}</a></td>
|
||||
@ -343,7 +292,6 @@
|
||||
</td>
|
||||
<td>{{$a_code}}</td>
|
||||
<td>{{$a_label}}</td>
|
||||
<td>{{$p_label}}</td>
|
||||
<td>
|
||||
{{if $linked != "true"}}
|
||||
{{:linkbutton label="Attacher" href="attach_amort.html?amort_id=%d&immo_id=%d"|args:$l_id:$ligne_immo.immo_id shape="plus"}}
|
||||
|
@ -1,33 +1,61 @@
|
||||
{{* -*- brindille -*- *}}
|
||||
|
||||
{{*
|
||||
Enregistrer l'association entre une écriture d'amortissement et
|
||||
Enregistrer la liaison entre une écriture d'amortissement et
|
||||
l'écriture d'immobilisation correspondante
|
||||
Comme je ne sais pas créer une ligne dans acc_transactions_links
|
||||
j'enregistre les associations dans un document json
|
||||
*}}
|
||||
|
||||
{{* trouver l'entrée correspondant à l'immobilisation *}}
|
||||
|
||||
{{* TODO : améliorer le message d'erreur *}}
|
||||
{{#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 ; avez-vous renseigné la durée d'immobilisation ?"|args:$_GET.immo_id}}
|
||||
{{:error message=$message}}
|
||||
{{/load}}
|
||||
|
||||
|
||||
{{* Ajouter la nouvelle ligne d'amortissement aux lignes existantes *}}
|
||||
|
||||
{{:assign var="assoc." value=$_GET.amort_id|intval}}
|
||||
|
||||
{{* Enregistrer les infos *}}
|
||||
{{:save
|
||||
key=$info_immo.key
|
||||
validate_schema="schema.json"
|
||||
type="immo"
|
||||
line=$info_immo.line
|
||||
duration=$info_immo.duration
|
||||
amort=$assoc
|
||||
{{* chercher l'écriture d'immobilisation *}}
|
||||
{{#select
|
||||
id_transaction
|
||||
FROM acc_transactions_lines
|
||||
WHERE id = :line_id;
|
||||
:line_id = $_GET.immo_id|intval
|
||||
}}
|
||||
{{:assign immo_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}}
|
||||
{{/select}}
|
||||
|
||||
{{* 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}}
|
||||
{{* 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}}
|
||||
{{/select}}
|
||||
|
||||
{{* checher les liaisons de l'écriture d'immobilisation *}}
|
||||
{{#select
|
||||
CASE links.id_related = :immo_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
|
||||
}}
|
||||
{{:assign var="linked_transactions." value=$linked_id}}
|
||||
{{/select}}
|
||||
|
||||
{{* ajouter la nouvelle liaison *}}
|
||||
{{:assign var="linked_transactions." value=$amort_id}}
|
||||
|
||||
{{* Enregistrer les liaisons *}}
|
||||
{{:api
|
||||
method="POST"
|
||||
path="accounting/transaction/%s/transactions"|args:$immo_id
|
||||
assign="result"
|
||||
assign_code="result_code"
|
||||
linked_transactions=$linked_transactions
|
||||
}}
|
||||
|
||||
{{:redirect to="amortization.html?immo_id=%s&ok=1&msg=attach"|args:$_GET.immo_id}}
|
||||
|
@ -13,13 +13,6 @@
|
||||
"duration" : {
|
||||
"description": "durée de l'amortissement en années",
|
||||
"type": "integer"
|
||||
},
|
||||
"amort" : {
|
||||
"description": "id lignes écritures amortissements",
|
||||
"type": ["array", "null"],
|
||||
"items": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": ["type", "line", "duration"]
|
||||
|
Loading…
Reference in New Issue
Block a user