Compare commits
2 commits
fb9cb32a44
...
b215c05763
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b215c05763 | ||
|
|
a4b2115249 |
7 changed files with 243 additions and 100 deletions
|
|
@ -161,6 +161,9 @@
|
|||
</tbody>
|
||||
<tfoot>
|
||||
{{if $total_immo != 0}}
|
||||
<tr>
|
||||
<td colspan="9">
|
||||
</tr>
|
||||
{{#foreach from=$sommes_immo|ksort key="code" item="value"}}
|
||||
<tr>
|
||||
<td></td>
|
||||
|
|
|
|||
|
|
@ -49,10 +49,10 @@
|
|||
{{:assign nb_immo=0}}
|
||||
{{:assign total_immo = 0}}
|
||||
{{#select
|
||||
trans.id as trans_id,
|
||||
trans.id as immo_trans_id,
|
||||
trans.label as trans_label,
|
||||
trans.date as trans_date,
|
||||
line.id as immo_id,
|
||||
line.id as immo_line_id,
|
||||
line.debit AS debit,
|
||||
account.id as account_id,
|
||||
account.code as account_code,
|
||||
|
|
@ -65,13 +65,13 @@
|
|||
ORDER BY trans.date DESC;
|
||||
!condition=$condition
|
||||
}}
|
||||
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$trans_id}}
|
||||
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$immo_trans_id}}
|
||||
{{:assign compte_url="%s/acc/accounts/journal.php?id=%s&year=%s"|args:$admin_url:$account_id:$trans_id_year}}
|
||||
{{:assign duration=null}}
|
||||
{{:assign montant_immo=$debit}}
|
||||
|
||||
{{* voir si l'immo est prise en charge *}}
|
||||
{{#load type="immo" where="$$.line = :line_id" :line_id=$immo_id|intval}}
|
||||
{{#load type="immo" where="$$.line = :line_id" :line_id=$immo_line_id|intval}}
|
||||
{{:assign duration=$duration}}
|
||||
{{:assign status=$status}}
|
||||
{{else}}
|
||||
|
|
@ -86,7 +86,7 @@
|
|||
et déduire leur montant de celui de l'immo
|
||||
*}}
|
||||
{{#select
|
||||
CASE links.id_related = :immo_id
|
||||
CASE links.id_related = :immo_trans_id
|
||||
WHEN true THEN links.id_transaction
|
||||
WHEN false THEN links.id_related
|
||||
END as other_id,
|
||||
|
|
@ -96,12 +96,11 @@
|
|||
ON (trans.id = links.id_transaction OR trans.id = links.id_related)
|
||||
INNER JOIN acc_transactions_lines AS line on line.id_transaction = other_id
|
||||
INNER JOIN acc_accounts AS acc ON line.id_account = acc.id
|
||||
WHERE trans.id = :immo_id AND line.credit > 0 AND acc.code = :account;
|
||||
:immo_id=$trans_id
|
||||
WHERE trans.id = :immo_trans_id AND line.credit > 0 AND acc.code = :account;
|
||||
:immo_trans_id=$immo_trans_id
|
||||
:account=$account_code
|
||||
}}
|
||||
{{:assign montant_immo="%d-%d"|math:$montant_immo:$credit}}
|
||||
{{*:debug ligne=$ligne montant_immo=$montant_immo*}}
|
||||
{{/select}}
|
||||
{{if $montant_immo == 0}}
|
||||
{{:assign status="archived"}}
|
||||
|
|
@ -111,38 +110,49 @@
|
|||
{{/if}}
|
||||
|
||||
{{* voir s'il existe des écritures d'amortissement associées *}}
|
||||
{{:assign amort_lines=null}}
|
||||
{{#select
|
||||
sum(l_amort.credit) as amort_amount,
|
||||
(l_amort.credit) as amount,
|
||||
CASE links.id_related = t_immo.id
|
||||
WHEN true THEN links.id_transaction
|
||||
WHEN false THEN links.id_related
|
||||
END as amort_trans_id
|
||||
END as amort_trans_id,
|
||||
l_amort.id AS amort_line_id
|
||||
FROM 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_links as links
|
||||
ON (
|
||||
t_immo.id = links.id_transaction
|
||||
OR
|
||||
t_immo.id = links.id_related
|
||||
)
|
||||
ON (t_immo.id = links.id_transaction OR t_immo.id = links.id_related)
|
||||
INNER JOIN acc_transactions_lines as l_amort on amort_trans_id = l_amort.id_transaction
|
||||
INNER JOIN acc_accounts AS account ON l_amort.id_account = account.id
|
||||
WHERE
|
||||
l_immo.id = :line_id
|
||||
AND
|
||||
l_amort.credit <> 0
|
||||
AND
|
||||
account.code LIKE '28%';
|
||||
:line_id = $immo_id|intval
|
||||
WHERE l_immo.id = :line_id AND l_amort.credit <> 0 AND account.code LIKE '28%';
|
||||
:line_id = $immo_line_id|intval
|
||||
assign="amort_lines."
|
||||
}}
|
||||
{{if $amort_amount == null}}
|
||||
{{:assign exist_amort=false}}
|
||||
{{/select}}
|
||||
|
||||
{{:assign amort_amount=0}}
|
||||
{{#foreach from=$amort_lines item="elem"}}
|
||||
{{* voir s'il existe un doc associé *}}
|
||||
{{#load type="link"
|
||||
where="$$.immo_line_id = :immo_line_id AND $$.amort_trans_id = :amort_trans_id"
|
||||
:immo_line_id = $immo_line_id
|
||||
:amort_trans_id = $elem.amort_trans_id
|
||||
assign="link"
|
||||
}}
|
||||
{{if $link.amort_line_id == $elem.amort_line_id}}
|
||||
{{:assign amort_amount="%d+%d"|math:$amort_amount:$amount}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{:assign amort_amount="%d+%d"|math:$amort_amount:$amount}}
|
||||
{{/load}}
|
||||
{{/foreach}}
|
||||
|
||||
{{if $amort_amount == 0}}
|
||||
{{:assign exist_amort=false}}
|
||||
{{else}}
|
||||
{{:assign exist_amort=true}}
|
||||
{{:assign amort_amount=$amort_amount}}
|
||||
{{/if}}
|
||||
{{/select}}
|
||||
|
||||
{{* classement par onglet *}}
|
||||
{{if $type_immo == "managed" && $amort_amount >= $montant_immo}}{{:continue}}{{/if}}
|
||||
|
|
@ -155,7 +165,7 @@
|
|||
{{:assign var="montant" from="sommes_immo.%s"|args:$account_code}}
|
||||
{{:assign var="sommes_immo.%s"|args:$account_code value="%d+%d"|math:$montant:$montant_immo}}
|
||||
<tr>
|
||||
<td class="num"><a href={{$trans_url}}>#{{$trans_id}}</a></td>
|
||||
<td class="num"><a href={{$trans_url}}>#{{$immo_trans_id}}</a></td>
|
||||
<td>{{$trans_date|date_short}}</td>
|
||||
<td>{{$trans_label}}</td>
|
||||
<td class="money">{{$montant_immo|money_html:false|raw}}</td>
|
||||
|
|
@ -166,13 +176,13 @@
|
|||
<td class="actions">
|
||||
{{:linkbutton
|
||||
label="Paramètres"
|
||||
href="add_infos.html?immo_id=%s&type_immo=%s"|args:$immo_id:$type_immo
|
||||
href="add_infos.html?immo_id=%s&type_immo=%s"|args:$immo_line_id:$type_immo
|
||||
shape="settings"
|
||||
target="_dialog"
|
||||
}}
|
||||
{{:linkbutton
|
||||
label="Amortissements"
|
||||
href="amortization.html?immo_id=%s&type_immo=%s"|args:$immo_id:$type_immo
|
||||
href="amortization.html?immo_id=%s&type_immo=%s"|args:$immo_line_id:$type_immo
|
||||
shape="table"
|
||||
}}
|
||||
</td>
|
||||
|
|
@ -181,6 +191,9 @@
|
|||
</tbody>
|
||||
<tfoot>
|
||||
{{if $total_immo != 0}}
|
||||
<tr>
|
||||
<td colspan="9">
|
||||
</tr>
|
||||
{{#foreach from=$sommes_immo|ksort key="code" item="value"}}
|
||||
<tr>
|
||||
<td></td>
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@
|
|||
{{#select
|
||||
l_amort.credit as amort_amount,
|
||||
l_amort.label as amort_label,
|
||||
l_amort.id as amort_line,
|
||||
l_amort.id as amort_line_id,
|
||||
CASE WHEN links.id_related = t_immo.id
|
||||
THEN links.id_transaction
|
||||
ELSE links.id_related
|
||||
|
|
@ -84,8 +84,20 @@
|
|||
AND account.code LIKE '28%'
|
||||
ORDER BY trans.date;
|
||||
:line_id = $_GET.immo_id|intval
|
||||
assign=linked_lines.
|
||||
assign="amort_line"
|
||||
}}
|
||||
|
||||
{{#load type="link"
|
||||
where="$$.immo_line_id = :immo_line_id AND $$.amort_trans_id = :amort_trans_id"
|
||||
assign="line"
|
||||
:immo_line_id=$_GET.immo_id|intval :amort_trans_id=$amort_line.amort_trans_id
|
||||
}}
|
||||
{{if $line.amort_line_id == $amort_line.amort_line_id}}
|
||||
{{:assign var="linked_amort." value=$amort_line}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{:assign var="linked_amort." value=$amort_line}}
|
||||
{{/load}}
|
||||
{{if $date_debut == null}}
|
||||
{{:assign date_debut=$amort_date}}
|
||||
{{/if}}
|
||||
|
|
@ -96,7 +108,7 @@
|
|||
{{:assign valeur_residuelle=0}}
|
||||
{{else}}
|
||||
{{:assign valeur_residuelle=$ligne_immo.montant}}
|
||||
{{#foreach from=$linked_lines}}
|
||||
{{#foreach from=$linked_amort}}
|
||||
{{:assign valeur_residuelle="%d-%d"|math:$valeur_residuelle:$amort_amount}}
|
||||
{{/foreach}}
|
||||
{{/if}}
|
||||
|
|
@ -112,7 +124,7 @@
|
|||
|
||||
{{:assign autres_amortissements=false}}
|
||||
{{#select
|
||||
line.id_transaction as t_id
|
||||
line.id_transaction AS amort_trans_id
|
||||
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
|
||||
|
|
@ -120,16 +132,44 @@
|
|||
WHERE account.code LIKE "28%" AND credit > 0 AND (NOT trans.status & 16) AND !filter_condition
|
||||
ORDER BY trans.date, trans.label;
|
||||
!filter_condition=$filter_condition
|
||||
assign="amort"
|
||||
}}
|
||||
{{* voir s'il existe des écritures liées avec un numéro de compte d'immobilisation *}}
|
||||
{{#select
|
||||
id_transaction,
|
||||
id_related
|
||||
FROM acc_transactions_links
|
||||
WHERE id_transaction = :id_amort OR id_related = :id_amort
|
||||
links.id_transaction,
|
||||
links.id_related,
|
||||
trans.id AS trans_id
|
||||
FROM acc_transactions_links AS links
|
||||
INNER JOIN acc_transactions AS trans ON (
|
||||
CASE
|
||||
WHEN links.id_transaction = :id_amort THEN links.id_related
|
||||
WHEN links.id_related = :id_amort THEN links.id_transaction
|
||||
END) = trans.id
|
||||
INNER JOIN acc_transactions_lines AS line ON line.id_transaction = trans.id
|
||||
INNER JOIN acc_accounts AS acc ON line.id_account = acc.id
|
||||
WHERE
|
||||
links.id_transaction = :id_amort OR links.id_related = :id_amort
|
||||
AND acc.code LIKE '21%'
|
||||
LIMIT 1
|
||||
;
|
||||
:id_amort=$t_id
|
||||
:id_amort=$amort.amort_trans_id
|
||||
}}
|
||||
{{* voir s'il existe un doc associé à une ligne de l'amortissement *}}
|
||||
{{:assign keep=true}}
|
||||
{{#load type="link"
|
||||
where="$$.amort_trans_id = :amort_trans_id"
|
||||
:amort_trans_id = $amort.amort_trans_id
|
||||
}}
|
||||
{{if $amort_line_id == $amort.amort_line_id}}
|
||||
{{:assign keep=false}}
|
||||
{{:break}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{:assign keep=false}}
|
||||
{{/load}}
|
||||
{{if $keep}}
|
||||
{{:assign autres_amortissements=true}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{:assign autres_amortissements=true}}
|
||||
{{/select}}
|
||||
|
|
@ -220,7 +260,7 @@
|
|||
</div>
|
||||
|
||||
<h3 class="ruler">Amortissements enregistrés</h3>
|
||||
{{if $linked_lines != null}}
|
||||
{{if $linked_amort != null}}
|
||||
<section class="amortissement">
|
||||
<table class="list">
|
||||
<thead>
|
||||
|
|
@ -236,7 +276,7 @@
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#foreach from=$linked_lines item="line"}}
|
||||
{{#foreach from=$linked_amort item="line"}}
|
||||
{{* données de l'écriture *}}
|
||||
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$line.amort_trans_id}}
|
||||
{{:assign compte_url="%s/acc/accounts/journal.php?id=%s&year=%s"|args:$admin_url:$line.account_id:$line.amort_year}}
|
||||
|
|
@ -256,7 +296,7 @@
|
|||
<td><a href={{$compte_url}}>{{$line.account_code}}</a></td>
|
||||
<td>{{$line.account_label}}</td>
|
||||
<td>
|
||||
{{:linkbutton label="Détacher" href="detach_amort.html?amort_id=%d&immo_id=%d"|args:$line.amort_line:$ligne_immo.immo_id shape="minus"}}
|
||||
{{:linkbutton label="Détacher" href="detach_amort.html?amort_id=%d&immo_id=%d"|args:$line.amort_line_id:$ligne_immo.immo_id shape="minus"}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/foreach}}
|
||||
|
|
@ -273,7 +313,7 @@
|
|||
|
||||
{{if $autres_amortissements}}
|
||||
<p class="block alert">
|
||||
Il existe des écritures d'amortissement qui ne sont pas rattachés à une immobilisation ! <br />
|
||||
Il existe des écritures d'amortissement qui ne sont pas rattachées à une immobilisation ! <br />
|
||||
Utilisez le bouton « Rattacher une écriture » pour les afficher ; vous pourrez choisir d'en attacher certaines à cette immobilisation.
|
||||
</p>
|
||||
{{/if}}
|
||||
|
|
|
|||
|
|
@ -44,8 +44,6 @@
|
|||
|
||||
{{* ajouter la nouvelle liaison *}}
|
||||
{{:assign var="linked_transactions." value=$amort_id}}
|
||||
|
||||
{{* Enregistrer les liaisons *}}
|
||||
{{:api
|
||||
method="POST"
|
||||
path="accounting/transaction/%s/transactions"|args:$immo_trans_id
|
||||
|
|
@ -53,4 +51,24 @@
|
|||
assign_code="result_code"
|
||||
transactions=$linked_transactions
|
||||
}}
|
||||
|
||||
{{* vérifier si cette liaison est déjà présente dans les documents pour éviter les doublons *}}
|
||||
{{#load type="link"
|
||||
where="$$.immo_line_id = :immo_line_id AND
|
||||
$$.amort_trans_id = :amort_trans_id AND
|
||||
$$.amort_line_id = :amort_line_id"
|
||||
:immo_line_id=$_GET.immo_id|intval
|
||||
:amort_trans_id = $amort_id
|
||||
:amort_line_id = $_GET.amort_id|intval
|
||||
limit=1
|
||||
}}
|
||||
{{else}}
|
||||
{{:save
|
||||
key=""|uuid
|
||||
type="link"
|
||||
immo_line_id=$_GET.immo_id|intval
|
||||
amort_line_id=$_GET.amort_id|intval
|
||||
amort_trans_id=$amort_id
|
||||
}}
|
||||
{{/load}}
|
||||
{{:redirect force="amortization.html?immo_id=%s&ok=1&msg=attach&trans_id=%s"|args:$_GET.immo_id:$amort_id}}
|
||||
|
|
|
|||
|
|
@ -56,16 +56,17 @@
|
|||
{{:assign var="ligne_immo.montant" value="%d-%d"|math:$ligne_immo.montant:$total_credits}}
|
||||
|
||||
{{* chercher des écritures d'amortissement liées à l'immobilisation *}}
|
||||
{{:assign total_amort=0}}
|
||||
{{:assign amort_number=0}}
|
||||
{{#select
|
||||
SUM(l_amort.credit) as amort_amount,
|
||||
l_amort.credit as amort_amount,
|
||||
l_amort.id as amort_line_id,
|
||||
CASE
|
||||
WHEN links.id_related = t_immo.id
|
||||
THEN links.id_transaction
|
||||
ELSE links.id_related
|
||||
END as amort_trans_id,
|
||||
MAX(trans.date) as last_amort_date,
|
||||
MIN(trans.date) as first_amort_date,
|
||||
COUNT(trans.id) as amort_number
|
||||
trans.date
|
||||
FROM 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_links as links
|
||||
|
|
@ -74,25 +75,56 @@
|
|||
INNER join acc_transactions as trans on l_amort.id_transaction = trans.id
|
||||
INNER JOIN acc_accounts AS account ON l_amort.id_account = account.id
|
||||
WHERE l_immo.id = :line_id AND account.code LIKE '28%'
|
||||
LIMIT 1;
|
||||
;
|
||||
:line_id = $_GET.immo_id|intval
|
||||
assign=amort_line
|
||||
assign="amort_line"
|
||||
}}
|
||||
|
||||
{{#load type="link"
|
||||
where="$$.immo_line_id = :immo_line_id AND $$.amort_trans_id = :amort_trans_id"
|
||||
assign="line"
|
||||
:immo_line_id=$_GET.immo_id|intval :amort_trans_id=$amort_line.amort_trans_id
|
||||
}}
|
||||
{{if $line.amort_line_id == $amort_line.amort_line_id}}
|
||||
{{:assign amort_number="%d+1"|math:$amort_number}}
|
||||
{{:assign total_amort="%d+%d"|math:$total_amort:$amort_line.amort_amount}}
|
||||
{{if $first_amort_date == null}}
|
||||
{{:assign first_amort_date=$amort_line.date}}
|
||||
{{elseif $amort_line.date < $first_amort_date}}
|
||||
{{:assign first_amort_date=$amort_line.date}}
|
||||
{{/if}}
|
||||
{{if $last_amort_date == null}}
|
||||
{{:assign last_amort_date=$amort_line.date}}
|
||||
{{elseif $amort_line.date > $last_amort_date}}
|
||||
{{:assign last_amort_date=$amort_line.date}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{:assign amort_number="%d+1"|math:$amort_number}}
|
||||
{{:assign total_amort="%d+%d"|math:$total_amort:$amort_line.amort_amount}}
|
||||
{{if $first_amort_date == null}}
|
||||
{{:assign first_amort_date=$amort_line.date}}
|
||||
{{elseif $amort_line.date < $first_amort_date}}
|
||||
{{:assign first_amort_date=$amort_line.date}}
|
||||
{{/if}}
|
||||
{{if $last_amort_date == null}}
|
||||
{{:assign last_amort_date=$amort_line.date}}
|
||||
{{elseif $amort_line.date > $last_amort_date}}
|
||||
{{:assign last_amort_date=$amort_line.date}}
|
||||
{{/if}}
|
||||
{{/load}}
|
||||
{{/select}}
|
||||
|
||||
{{if $amort_line.amort_number == 0}}
|
||||
{{if $total_amort == 0}}
|
||||
{{if $info_immo.status == "amortized"}}
|
||||
{{:assign amort_amount=$ligne_immo.montant}}
|
||||
{{else}}
|
||||
{{:assign amort_amount=0}}
|
||||
{{:assign total_amort=$ligne_immo.montant}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{:assign amort_amount=$amort_line.amort_amount}}
|
||||
{{:assign date_debut=$amort_line.last_amort_date|strtotime}}
|
||||
{{:assign date_debut=$last_amort_date|strtotime}}
|
||||
{{:assign date_debut="%d+(60*60*24)"|math:$date_debut|date:"Y-m-d"}}
|
||||
{{/if}}
|
||||
{{:assign ts_debut=$date_debut|strtotime}}
|
||||
{{:assign valeur_nette="%f-%f"|math:$ligne_immo.montant:$amort_amount}}
|
||||
{{:assign valeur_nette="%f-%f"|math:$ligne_immo.montant:$total_amort}}
|
||||
|
||||
{{*
|
||||
lister les exercices ouverts dont la date de fin est postérieure à la date du dernier amortissment
|
||||
|
|
@ -125,9 +157,9 @@
|
|||
{{* vérifier la validité de la date de mise en service *}}
|
||||
{{if $_POST.date_mes != null}}
|
||||
{{:assign ts_mes=$_POST.date_mes|parse_date|strtotime}}
|
||||
{{if $ts_mes < $ligne_immo.date_achat|strtotime || $ts_mes > $amort_line.first_amort_date|strtotime}}
|
||||
{{if $ts_mes < $ligne_immo.date_achat|strtotime || $ts_mes > $first_amort_date|strtotime}}
|
||||
{{:assign immo_date=$ligne_immo.date_achat|date_short}}
|
||||
{{:assign amort_date=$amort_line.first_amort_date|date_short}}
|
||||
{{:assign amort_date=$first_amort_date|date_short}}
|
||||
{{:error message="La date de mise en service doit être postérieure à la date d'acquisition de l'immobilisation (%s) et antérieure à la date du premier amortissement (%s)"|args:$immo_date:$amort_date}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
|
@ -137,8 +169,8 @@
|
|||
{{if $info_immo.duration == null}}
|
||||
{{if $_POST.duree == null}}
|
||||
{{:error message="Vous devez renseigner la durée de l'immobilisation"}}
|
||||
{{elseif $_POST.duree < $amort_line.amort_number}}
|
||||
{{:error message="La durée de l'amortissement ne peut être inférieure au nombre d'écritures d'amortissement (%d)"|args:$amort_line.amort_number}}
|
||||
{{elseif $_POST.duree < $amort_number}}
|
||||
{{:error message="La durée de l'amortissement ne peut être inférieure au nombre d'écritures d'amortissement (%d)"|args:$amort_number}}
|
||||
{{else}}
|
||||
{{:assign duree_amort=$_POST.duree}}
|
||||
{{/if}}
|
||||
|
|
@ -159,9 +191,9 @@
|
|||
{{:assign immo_date=$ligne_immo.date_achat|date_short}}
|
||||
{{:error message="La date de sortie doit être postérieure à la date d'acquisition de l'immobilisation (%s)"|args:$immo_date}}
|
||||
{{/if}}
|
||||
{{if $amort_line.amort_number != 0 && $_POST.date_sortie|parse_date <= $amort_line.last_amort_date}}
|
||||
{{:assign last_amort_date=$amort_line.last_amort_date|date_short}}
|
||||
{{:error message="La date de sortie doit être postérieure à la date de la dernière immobilisation (%s)"|args:$last_amort_date}}
|
||||
{{if $amort_number != 0 && $_POST.date_sortie|parse_date <= $last_amort_date}}
|
||||
{{:assign last_amort_date=$last_amort_date|date_short}}
|
||||
{{:error message="La date de sortie doit être postérieure à la date du dernier amortissement (%s)"|args:$last_amort_date}}
|
||||
{{/if}}
|
||||
|
||||
{{* vérifier que la date de sortie est située dans un exercice ouvert *}}
|
||||
|
|
@ -178,7 +210,7 @@
|
|||
{{/if}}
|
||||
|
||||
{{* voir si des amortissements ont été oubliés *}}
|
||||
{{if $valeur_nette > 0 && $info_immo.status != "amortized" && $start_date|strtotime > $amort_line.last_amort_date|strtotime && $end_date|strtotime < $now}}
|
||||
{{if $valeur_nette > 0 && $info_immo.status != "amortized" && $start_date|strtotime > $last_amort_date|strtotime && $end_date|strtotime < $now}}
|
||||
{{:assign debut=$start_date|date_short}}
|
||||
{{:assign fin=$end_date|date_short}}
|
||||
{{:assign msg_amort=$msg_amort|cat:"\n"|cat:" - "|cat:$label|cat:" : du "|cat:$debut|cat:" au "|cat:$fin}}
|
||||
|
|
@ -191,7 +223,7 @@
|
|||
{{:error message="Vous devez d'abord enregistrer les amortissements des exercices suivants : %s"|args:$msg_amort}}
|
||||
{{/if}}
|
||||
|
||||
{{:redirect to="compute_exit_data.html?immo_id=%s&amort_amount=%s&year=%s&date_mes=%s&date_debut=%s&exit_date=%s&duree_amort=%s"|args:$_GET.immo_id:$amort_amount:$selected_year:$ts_mes:$ts_debut:$ts_exit:$duree_amort}}
|
||||
{{:redirect to="compute_exit_data.html?immo_id=%s&amort_amount=%s&year=%s&date_mes=%s&date_debut=%s&exit_date=%s&duree_amort=%s"|args:$_GET.immo_id:$total_amort:$selected_year:$ts_mes:$ts_debut:$ts_exit:$duree_amort}}
|
||||
{{/form}}
|
||||
|
||||
{{:admin_header title="Sortie de bilan" custom_css="./style.css" current="module_amortization"}}
|
||||
|
|
@ -221,7 +253,7 @@
|
|||
<dd id="duree_amort" class="num">{{$info_immo.duration}} ans</dd>
|
||||
{{/if}}
|
||||
<dt>Montant des amortissements</dt>
|
||||
<dd id="montant_amort" class="money">{{$amort_amount|money_currency_html:false|raw}} <span class="help">(à la date de début de l'exercice)</span></dd>
|
||||
<dd id="montant_amort" class="money">{{$total_amort|money_currency_html:false|raw}} <span class="help">(à la date de début de l'exercice)</span></dd>
|
||||
<dt>Valeur nette résiduelle</dt>
|
||||
<dd class="money">{{$valeur_nette|money_currency_html:false|raw}} <span class="help">(à la date de début de l'exercice)</span></dd>
|
||||
</dl>
|
||||
|
|
|
|||
|
|
@ -55,4 +55,17 @@
|
|||
assign_code="result_code"
|
||||
transactions=$linked_transactions
|
||||
}}
|
||||
|
||||
{{* supprimer le doc de liaison entre les lignes *}}
|
||||
{{#load type="link"
|
||||
where="$$.immo_line_id = :immo_line_id AND
|
||||
$$.amort_trans_id = :amort_trans_id AND
|
||||
$$.amort_line_id = :amort_line_id"
|
||||
:immo_line_id=$_GET.immo_id|intval
|
||||
:amort_trans_id = $amort_id|intval
|
||||
:amort_line_id = $_GET.amort_id|intval
|
||||
}}
|
||||
{{:delete id=$id}}
|
||||
{{/load}}
|
||||
|
||||
{{:redirect to="amortization.html?immo_id=%s&ok=1&msg=detach&trans_id=%s"|args:$_GET.immo_id:$amort_id}}
|
||||
|
|
|
|||
|
|
@ -8,11 +8,7 @@
|
|||
|
||||
{{* récupérer les infos de l'immobilisation *}}
|
||||
{{#select
|
||||
line.id as immo_id,
|
||||
line.debit as montant,
|
||||
trans.id as trans_id,
|
||||
trans.label as label,
|
||||
trans.date
|
||||
trans.label as label
|
||||
FROM acc_transactions_lines AS line
|
||||
INNER JOIN acc_transactions AS trans ON line.id_transaction = trans.id
|
||||
WHERE line.id = :line_id;
|
||||
|
|
@ -31,13 +27,14 @@
|
|||
{{/foreach}}
|
||||
{{:assign filter_condition=$filter_condition|cat:"0)"}}
|
||||
|
||||
{{* lister les écritures d'amortissement *}}
|
||||
{{#select
|
||||
line.id as l_id,
|
||||
line.id_transaction as t_id,
|
||||
line.id as amort_line_id,
|
||||
line.id_transaction as amort_trans_id,
|
||||
line.credit as amort_amount,
|
||||
line.label as l_label,
|
||||
trans.date as t_date,
|
||||
trans.label as t_label,
|
||||
line.label as line_label,
|
||||
trans.date as trans_date,
|
||||
trans.label as trans_label,
|
||||
trans.id_year as amort_year,
|
||||
account.id as account_id,
|
||||
account.code as account_code,
|
||||
|
|
@ -49,17 +46,47 @@
|
|||
WHERE account.code LIKE "28%" AND credit > 0 AND (NOT trans.status & 16) AND !filter_condition
|
||||
ORDER BY trans.date, trans.label;
|
||||
!filter_condition=$filter_condition
|
||||
assign=autre_amort
|
||||
}}
|
||||
{{#select
|
||||
id_transaction,
|
||||
id_related
|
||||
FROM acc_transactions_links
|
||||
WHERE id_transaction = :id_amort OR id_related = :id_amort;
|
||||
:id_amort=$t_id
|
||||
assign="amort"
|
||||
}}
|
||||
|
||||
{{* voir s'il existe des écritures liées avec un numéro de compte d'immobilisation *}}
|
||||
{{#select
|
||||
links.id_transaction,
|
||||
links.id_related,
|
||||
trans.id AS trans_id
|
||||
FROM acc_transactions_links AS links
|
||||
INNER JOIN acc_transactions AS trans ON (
|
||||
CASE
|
||||
WHEN links.id_transaction = :id_amort THEN links.id_related
|
||||
WHEN links.id_related = :id_amort THEN links.id_transaction
|
||||
END) = trans.id
|
||||
INNER JOIN acc_transactions_lines AS line ON line.id_transaction = trans.id
|
||||
INNER JOIN acc_accounts AS acc ON line.id_account = acc.id
|
||||
WHERE
|
||||
links.id_transaction = :id_amort OR links.id_related = :id_amort
|
||||
AND acc.code LIKE '21%'
|
||||
LIMIT 1
|
||||
;
|
||||
:id_amort=$amort.amort_trans_id
|
||||
}}
|
||||
{{* voir s'il existe un doc associé à une ligne de l'amortissement *}}
|
||||
{{:assign keep=true}}
|
||||
{{#load type="link"
|
||||
where="$$.amort_trans_id = :amort_trans_id"
|
||||
:amort_trans_id = $amort.amort_trans_id
|
||||
}}
|
||||
{{if $amort_line_id == $amort.amort_line_id}}
|
||||
{{:assign keep=false}}
|
||||
{{:break}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{:assign var="autres_amortissements." value=$autre_amort}}
|
||||
{{:assign keep=false}}
|
||||
{{/load}}
|
||||
{{if $keep}}
|
||||
{{:assign var="autres_amortissements." value=$amort}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{:assign var="autres_amortissements." value=$amort}}
|
||||
{{/select}}
|
||||
{{/select}}
|
||||
|
||||
|
|
@ -94,22 +121,19 @@
|
|||
</thead>
|
||||
<tbody>
|
||||
{{#foreach from=$autres_amortissements item="line"}}
|
||||
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$line.t_id}}
|
||||
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$line.amort_trans_id}}
|
||||
{{:assign compte_url="%s/acc/accounts/journal.php?id=%s&year=%s"|args:$admin_url:$line.account_id:$line.amort_year}}
|
||||
<tr>
|
||||
<td class="num"><a href={{$trans_url}}>#{{$line.t_id}}</a></td>
|
||||
<td>{{$line.t_date|date_short}}</td>
|
||||
<td class="num"><a href={{$trans_url}}>#{{$line.amort_trans_id}}</a></td>
|
||||
<td>{{$line.trans_date|date_short}}</td>
|
||||
<td class="money">{{"%f"|math:$line.amort_amount|money_html:false|raw}}</td>
|
||||
<td>{{if $line.l_label == null}}
|
||||
{{$line.t_label}}
|
||||
{{else}}
|
||||
{{$line.l_label}}
|
||||
{{/if}}
|
||||
<td>{{$line.trans_label}}
|
||||
{{if $line.line_label != null}} - {{$line.line_label}}{{/if}}
|
||||
</td>
|
||||
<td><a href={{$compte_url}}>{{$line.account_code}}</a></td>
|
||||
<td>{{$line.account_label}}</td>
|
||||
<td>
|
||||
{{:linkbutton label="Attacher" href="attach_amort.html?amort_id=%d&immo_id=%d"|args:$line.l_id:$_GET.immo_id shape="plus"}}
|
||||
{{:linkbutton label="Attacher" href="attach_amort.html?amort_id=%d&immo_id=%d"|args:$line.amort_line_id:$_GET.immo_id shape="plus"}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/foreach}}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue