Amélioration détection amortissements orphelins
This commit is contained in:
parent
a358858575
commit
2e8492b025
4 changed files with 50 additions and 12 deletions
|
|
@ -101,27 +101,40 @@
|
|||
{{/select}}
|
||||
{{/load}}
|
||||
|
||||
{{:assign autres_amortissements=false}}
|
||||
{{if $valeur_residuelle > 0}}
|
||||
{{* Chercher des amortissements non rattachés à une immo *}}
|
||||
{{#select
|
||||
line.id as amort_line_id,
|
||||
line.id_transaction AS amort_trans_id
|
||||
line.id_transaction AS amort_trans_id,
|
||||
line.credit as amort_amount
|
||||
FROM acc_transactions_lines AS line
|
||||
INNER JOIN acc_accounts AS account ON account.id = line.id_account
|
||||
INNER JOIN acc_transactions AS trans ON trans.id = line.id_transaction
|
||||
INNER JOIN acc_years AS y ON y.id = trans.id_year
|
||||
WHERE account.code LIKE "28%" AND credit > 0 AND (NOT trans.status & 16)
|
||||
ORDER BY trans.date, trans.label;
|
||||
assign="amort"
|
||||
}}
|
||||
{{* cette ligne d'amortissement a-t-elle un doc associé ? *}}
|
||||
{{* voir s'il existe des lignes d'immo liées à cette ligne d'amortissement *}}
|
||||
{{:assign amort_amount=0}}
|
||||
{{:assign keep_amort=true}}
|
||||
{{#load type="amort_link"
|
||||
where="$$.amort_line_id = :amort_line_id"
|
||||
:amort_line_id = $amort_line_id
|
||||
assign="amort_link"
|
||||
}}
|
||||
{{if $amort_link.amount == null || $amort_link.amount == 0}}
|
||||
{{:assign amort_amount=$amort.amort_amount}}
|
||||
{{:assign keep_amort=false}}
|
||||
{{else}}
|
||||
{{:assign amort_amount="%d+%d"|math:$amort_amount:$amort_link.amount}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{:assign autres_amortissements=true}}
|
||||
{{* pas de ligne d'immo liée à cette ligne d'amort => garder cette ligne d'amortissement *}}
|
||||
{{/load}}
|
||||
{{if $keep_amort && $amort_amount < $amort.amort_amount}}
|
||||
{{:assign var="free_amort_lines." value=$amort}}
|
||||
{{/if}}
|
||||
{{/select}}
|
||||
{{/if}}
|
||||
|
||||
|
|
@ -144,7 +157,7 @@
|
|||
subcurrent="%s"|args:$subcurrent
|
||||
subsubcurrent="amortization"
|
||||
type_immo=$_GET.type_immo
|
||||
autres_amort=$autres_amortissements
|
||||
autres_amort=$free_amort_lines
|
||||
}}
|
||||
|
||||
{{if $_GET.ok}}
|
||||
|
|
@ -263,7 +276,7 @@
|
|||
<p class="block alert">Aucun amortissement enregistré pour cette immobilisation</p>
|
||||
{{/if}}
|
||||
|
||||
{{if $autres_amortissements}}
|
||||
{{if $free_amort_lines}}
|
||||
<p class="block alert">
|
||||
Il y a des écritures d'amortissement qui ne sont pas rattachées à une immobilisation ! <br />
|
||||
Utilisez le bouton « Rattacher un amortissement » pour les afficher ; vous pourrez choisir d'en attacher certaines à cette immobilisation.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue