Compare commits
No commits in common. "main" and "classification_initiale" have entirely different histories.
main
...
classifica
48 changed files with 1684 additions and 2230 deletions
|
|
@ -4,14 +4,15 @@ Ce module permet de gérer les écritures d'amortissements pour les immobilisati
|
|||
|
||||
- lister les immobilisations
|
||||
- ajouter une nouvelle immobilisation
|
||||
- lister les amortissements d'une immobilisation
|
||||
- lister les amortissements d'une immobilisation :
|
||||
- amortissements déjà enregistrés
|
||||
- amortissements à venir
|
||||
- associer une écriture d'amortissement à une immobilisation
|
||||
- enregistrer un nouvel amortissement
|
||||
- incorporer d'anciennes immobilisations et leurs amortisements
|
||||
|
||||
## Installation
|
||||
- télécharger [l'archive zip](https://link.infini.fr/amortissement)
|
||||
- cliquer « Configuration » puis « Extensions »
|
||||
- en bas de la page, cliquer « Importer un module »
|
||||
- sélectionner l'archive téléchargée ci-dessus
|
||||
- activer le module
|
||||
|
||||
- activer le module qui est maintenant présent dans la liste des extensions inactives
|
||||
|
|
|
|||
245
_archives.html
245
_archives.html
|
|
@ -1,128 +1,29 @@
|
|||
{{* -*- brindille -*- *}}
|
||||
|
||||
{{* Liste des immobilisations sorties du bilan *}}
|
||||
<p class="block help">
|
||||
Cet onglet liste les immobilisations sorties du bilan car elles ne
|
||||
sont plus utilisées dans l'association (vétusté, fin de vie,
|
||||
vente...).
|
||||
<p class="help">
|
||||
Cette page liste les immobilisations sorties du bilan
|
||||
</p>
|
||||
|
||||
{{:include file="_get_config.html" keep="module.config"}}
|
||||
|
||||
{{if $module.table != null}}
|
||||
|
||||
{{* lister les immobilisations *}}
|
||||
{{:assign account_condition="("}}
|
||||
{{#foreach from=$module.config.prefixes item="code"}}
|
||||
{{* lister les immobilisations *}}
|
||||
{{:assign account_condition="("}}
|
||||
{{#foreach from=$module.config.prefixes item="code"}}
|
||||
{{:assign code=$code|cat:"%"|quote_sql}}
|
||||
{{:assign account_condition=$account_condition|cat:"account.code LIKE "|cat:$code|cat:" OR "}}
|
||||
{{/foreach}}
|
||||
{{:assign account_condition=$account_condition|cat:"0)"}}
|
||||
{{:assign status_condition="($$.status = 'archived')"}}
|
||||
{{/foreach}}
|
||||
{{:assign account_condition=$account_condition|cat:"0)"}}
|
||||
|
||||
{{:assign filter_condition=" ("}}
|
||||
{{#foreach from=$module.config.filters item="filter"}}
|
||||
{{:assign filter_condition=" AND NOT ("}}
|
||||
{{#foreach from=$module.config.filters item="filter"}}
|
||||
{{:assign filter="%"|cat:$filter|cat:"%"|quote_sql}}
|
||||
{{:assign filter_condition=$filter_condition|cat:" trans_label LIKE "|cat:$filter|cat:" OR "}}
|
||||
{{/foreach}}
|
||||
{{:assign filter_condition=$filter_condition|cat:"0)"}}
|
||||
{{:assign condition=$account_condition|cat:" AND debit > 0 AND NOT "|cat:$filter_condition|cat:" AND "|cat:$status_condition}}
|
||||
{{/foreach}}
|
||||
{{:assign filter_condition=$filter_condition|cat:"0)"}}
|
||||
{{:assign condition=$account_condition|cat:" AND debit > 0 AND NOT (trans.status & 16)"|cat:$filter_condition}}
|
||||
|
||||
{{:assign total_cessions = 0}}
|
||||
|
||||
{{#select
|
||||
trans.id as trans_id,
|
||||
trans.label as trans_label,
|
||||
trans.date as trans_date,
|
||||
trans.id_year as trans_id_year,
|
||||
line.id as immo_line_id,
|
||||
line.label as line_label,
|
||||
line.debit AS debit,
|
||||
account.id as account_id,
|
||||
account.code as account_code,
|
||||
account.label as account_label,
|
||||
info.id as immo_doc_id,
|
||||
$$.label as doc_label,
|
||||
$$.amount as doc_amount,
|
||||
$$.date_achat as doc_date_achat,
|
||||
$$.date_mes as doc_date_mes,
|
||||
$$.status as status
|
||||
FROM acc_transactions AS trans
|
||||
INNER JOIN acc_transactions_lines AS line ON line.id_transaction = trans.id
|
||||
INNER JOIN acc_accounts AS account ON line.id_account = account.id
|
||||
INNER JOIN acc_years AS years ON trans.id_year = years.id
|
||||
INNER JOIN !table AS info ON $$.line = line.id
|
||||
WHERE !condition
|
||||
ORDER BY trans.date DESC;
|
||||
!table=$module.table
|
||||
!condition=$condition
|
||||
assign="immo_line"
|
||||
}}
|
||||
|
||||
{{:assign var="immo_line.date_mes" value=$doc_date_mes|or:$doc_date_achat|or:$trans_date}}
|
||||
{{:assign var="immo_line.montant_immo" value=$doc_amount|or:$debit}}
|
||||
|
||||
{{* chercher le doc de sortie du bilan *}}
|
||||
{{:assign var="immo_line.exit_date" value=null}}
|
||||
{{#load type="exit_link" where="$$.immo_doc_id = :immo_doc_id" :immo_doc_id=$immo_doc_id}}
|
||||
{{:assign exit_line_id=$exit_line_id}}
|
||||
{{#select
|
||||
trans.date
|
||||
FROM acc_transactions_lines AS line
|
||||
INNER JOIN acc_transactions AS trans ON line.id_transaction = trans.id
|
||||
WHERE line.id = :exit_line_id;
|
||||
:exit_line_id=$exit_line_id
|
||||
}}
|
||||
{{:assign var="immo_line.exit_date" value=$date}}
|
||||
{{/select}}
|
||||
{{/load}}
|
||||
|
||||
{{* déduire le montant des écritures liées à l'immo courante au crédit du même compte *}}
|
||||
{{:assign credit_immo=null}}
|
||||
{{:assign total_credits=0}}
|
||||
{{#load
|
||||
type="credit_link"
|
||||
where="$$.immo_doc_id = :immo_doc_id" :immo_doc_id = $immo_doc_id
|
||||
}}
|
||||
{{if $amount == null}}
|
||||
{{#select credit FROM acc_transactions_lines WHERE id = :credit_line_id;
|
||||
:credit_line_id=$credit_line_id
|
||||
}}
|
||||
{{:assign total_credits="%d+%d"|math:$total_credits:$credit}}
|
||||
{{/select}}
|
||||
{{else}}
|
||||
{{:assign total_credits="%d+%d"|math:$total_credits:$amount}}
|
||||
{{/if}}
|
||||
{{/load}}
|
||||
{{:assign solde_immo="%d-%d"|math:$immo_line.montant_immo:$total_credits}}
|
||||
{{:assign var="montant" from="sommes_immo.%s"|args:$account_code}}
|
||||
{{:assign var="sommes_immo.%s"|args:$account_code value="%d+%d"|math:$montant:$immo_line.montant_immo}}
|
||||
|
||||
{{* voir s'il y a une écriture de cession associée à cette immo *}}
|
||||
{{#select
|
||||
trans.id as cession_id,
|
||||
trans.label,
|
||||
line.id as line_id,
|
||||
line.credit
|
||||
FROM acc_transactions_lines AS line
|
||||
INNER JOIN acc_transactions AS trans ON line.id_transaction = trans.id
|
||||
INNER JOIN !table AS cession_link ON json_extract(cession_link.document, '$.cession_line_id') = line.id
|
||||
INNER JOIN !table AS immo_doc ON json_extract(cession_link.document, '$.immo_doc_id') = immo_doc.id
|
||||
WHERE json_extract(immo_doc.document, '$.line') = :immo_line_id
|
||||
;
|
||||
!table=$module.table
|
||||
:immo_line_id = $immo_line.immo_line_id
|
||||
assign="cession_line"
|
||||
}}
|
||||
{{:assign var="montant" from="montant_cessions.%d"|args:$account_code}}
|
||||
{{:assign var="montant_cessions.%d"|args:$account_code value="%d+%d"|math:$montant:$credit}}
|
||||
{{:assign total_cessions="%d+%d"|math:$total_cessions:$credit}}
|
||||
{{/select}}
|
||||
{{:assign var="immo_lines." value=$immo_line}}
|
||||
{{/select}}
|
||||
|
||||
{{if $immo_lines|count > 0}}
|
||||
<section class="immobilisation">
|
||||
<section class="immobilisation">
|
||||
<table class="list">
|
||||
<thead>
|
||||
<tr>
|
||||
|
|
@ -138,28 +39,124 @@
|
|||
</thead>
|
||||
<tbody>
|
||||
|
||||
{{:assign nb_immo=0}}
|
||||
{{:assign total_immo = 0}}
|
||||
{{#foreach from=$immo_lines}}
|
||||
{{:assign total_cessions = 0}}
|
||||
|
||||
{{#select
|
||||
trans.id as trans_id,
|
||||
trans.label as trans_label,
|
||||
trans.date as trans_date,
|
||||
trans.id_year as trans_id_year,
|
||||
line.id as immo_line_id,
|
||||
line.label as line_label,
|
||||
line.debit AS debit,
|
||||
account.id as account_id,
|
||||
account.code as account_code,
|
||||
account.label as account_label
|
||||
FROM acc_transactions AS trans
|
||||
INNER JOIN acc_transactions_lines AS line ON line.id_transaction = trans.id
|
||||
INNER JOIN acc_accounts AS account ON line.id_account = account.id
|
||||
INNER JOIN acc_years AS years ON trans.id_year = years.id
|
||||
WHERE !condition
|
||||
ORDER BY trans.date DESC;
|
||||
!condition=$condition
|
||||
}}
|
||||
|
||||
{{* voir si l'immo est prise en charge *}}
|
||||
{{#load type="immo" where="$$.line = :line_id" :line_id=$immo_line_id assign="info_immo"}}
|
||||
{{:assign status=$status}}
|
||||
{{else}}
|
||||
{{:assign status=null}}
|
||||
{{/load}}
|
||||
{{if $status != "archived"}}
|
||||
{{:continue}}
|
||||
{{/if}}
|
||||
{{:assign date_mes=$info_immo.date_mes|or:$trans_date}}
|
||||
{{:assign montant_immo=$debit}}
|
||||
|
||||
{{* chercher le doc de sortie du bilan *}}
|
||||
{{:assign exit_date=null}}
|
||||
{{#load type="exit_link" where="$$.immo_doc_id = :immo_doc_id" :immo_doc_id=$info_immo.id}}
|
||||
{{:assign exit_line_id=$exit_line_id}}
|
||||
{{#select
|
||||
trans.date
|
||||
FROM acc_transactions_lines AS line
|
||||
INNER JOIN acc_transactions AS trans ON line.id_transaction = trans.id
|
||||
WHERE line.id = :exit_line_id;
|
||||
:exit_line_id=$exit_line_id
|
||||
}}
|
||||
{{:assign exit_date=$date}}
|
||||
{{/select}}
|
||||
{{/load}}
|
||||
|
||||
{{* déduire le montant des écritures liées à l'immo courante au crédit du même compte *}}
|
||||
{{:assign credit_immo=null}}
|
||||
{{:assign total_credits=0}}
|
||||
{{#load
|
||||
type="credit_link"
|
||||
where="$$.immo_doc_id = :immo_doc_id" :immo_doc_id = $info_immo.id
|
||||
}}
|
||||
{{if $amount == null}}
|
||||
{{#select credit FROM acc_transactions_lines WHERE id = :credit_line_id;
|
||||
:credit_line_id=$credit_line_id
|
||||
}}
|
||||
{{:assign total_credits="%d+%d"|math:$total_credits:$credit}}
|
||||
{{/select}}
|
||||
{{else}}
|
||||
{{:assign total_credits="%d+%d"|math:$total_credits:$amount}}
|
||||
{{/if}}
|
||||
{{/load}}
|
||||
{{:assign solde_immo="%d-%d"|math:$montant_immo:$total_credits}}
|
||||
|
||||
{{if $solde_immo == 0}}
|
||||
{{:assign status="archived"}}
|
||||
{{/if}}
|
||||
|
||||
{{if $status != "archived"}}
|
||||
{{:continue}}
|
||||
{{/if}}
|
||||
|
||||
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$trans_id}}
|
||||
{{:assign compte_url="%s/acc/accounts/journal.php?id=%s&year=%s"|args:$admin_url:$account_id:$trans_id_year}}
|
||||
{{:assign nb_immo="%d+1"|math:$nb_immo}}
|
||||
{{:assign total_immo="%d+%d"|math:$total_immo:$montant_immo}}
|
||||
{{:assign label_immo=$doc_label|or:$trans_label}}
|
||||
{{if $label_immo|strpos:$line_label === false}}
|
||||
{{:assign label_immo=$label_immo|cat:" — "|cat:$line_label}}
|
||||
{{/if}}
|
||||
{{: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}}
|
||||
|
||||
{{* voir s'il y a une écriture de cession associée à cette immo *}}
|
||||
{{#select
|
||||
trans.id,
|
||||
line.debit
|
||||
FROM acc_transactions_links AS link
|
||||
INNER JOIN acc_transactions AS trans ON (CASE
|
||||
WHEN link.id_transaction = :trans_id THEN link.id_related
|
||||
WHEN link.id_related = :trans_id THEN link.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 (link.id_transaction = :trans_id OR link.id_related = :trans_id) AND acc.code = 462
|
||||
;
|
||||
:trans_id = $trans_id
|
||||
}}
|
||||
{{:assign var="montant" from="montant_cessions.%d"|args:$account_code}}
|
||||
{{:assign var="montant_cessions.%d"|args:$account_code value="%d+%d"|math:$montant:$debit}}
|
||||
{{:assign total_cessions="%d+%d"|math:$total_cessions:$debit}}
|
||||
{{/select}}
|
||||
|
||||
<tr>
|
||||
<td class="num"><a href="{{$trans_url}}">#{{$trans_id}}</a></td>
|
||||
<td>{{$date_mes|date_short}}</td>
|
||||
<td>{{$exit_date|date_short}}</td>
|
||||
<td>{{$label_immo}}</td>
|
||||
<td>{{$trans_label}}{{if $line_label != null && $line_label != $trans_label}} — {{$line_label}}{{/if}}</td>
|
||||
<td class="money">{{"%f"|math:$montant_immo|money_html:false|raw}}</td>
|
||||
<td><a href="{{$compte_url}}">{{$account_code}}</a></td>
|
||||
<td>{{$account_label}}</td>
|
||||
<td class="actions">
|
||||
{{:linkbutton label="Modifier" href="exit_step1.html?immo_doc_id=%s&from=exit"|args:$immo_doc_id shape="edit"}}
|
||||
{{:linkbutton label="Modifier" href="exit_step4.html?immo_doc_id=%s"|args:$info_immo.id shape="edit"}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/foreach}}
|
||||
{{/select}}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
{{if $total_immo != 0}}
|
||||
|
|
@ -218,9 +215,7 @@
|
|||
{{/if}}
|
||||
</tfoot>
|
||||
</table>
|
||||
</section>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{if $immo_lines|count == 0 || $module.table == null}}
|
||||
{{if $nb_immo == 0}}
|
||||
<p class="block alert">Aucune immobilisation</p>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
</section>
|
||||
|
|
|
|||
|
|
@ -9,4 +9,4 @@
|
|||
|
||||
{{:assign ts_debut=$date_debut|strtotime}}
|
||||
{{:assign ts_fin=$date_fin|strtotime}}
|
||||
{{:assign nbjours="round(1+abs(%d-%d)/(60*60*24), 0)"|math:$ts_fin:$ts_debut}}
|
||||
{{:assign nbjours="1+abs(%d-%d)/(60*60*24)"|math:$ts_fin:$ts_debut}}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,12 @@
|
|||
{{* -*- brindille -*- *}}
|
||||
|
||||
{{*
|
||||
Supprimer l'association entre une ligne d'immo et une autre ligne (amort, credit, cession, sortie)
|
||||
Supprimer l'association entre deux lignes
|
||||
@param immo_doc_id : id du doc associé à la ligne d'immobilisation
|
||||
@param line_id : id de la ligne à détacher
|
||||
*}}
|
||||
|
||||
{{* données de l'immobilisation *}}
|
||||
{{:include file="_get_immo_data.html" immo_doc_id=$immo_doc_id|intval keep="info_immo, ligne_immo, message"}}
|
||||
{{:include file="_get_immo_data.html" immo_doc_id=$immo_doc_id|intval keep="ligne_immo, message"}}
|
||||
{{if $message != null}}
|
||||
{{:error message=$message}}
|
||||
{{/if}}
|
||||
|
|
@ -17,7 +16,7 @@
|
|||
id_transaction
|
||||
FROM acc_transactions_lines
|
||||
WHERE id = :line_id;
|
||||
:line_id = $line_id
|
||||
:line_id = $line_id|intval
|
||||
}}
|
||||
{{:assign trans_id=$id_transaction}}
|
||||
{{else}}
|
||||
|
|
|
|||
|
|
@ -1,34 +0,0 @@
|
|||
{{* -*- brindille -*- *}}
|
||||
|
||||
{{*
|
||||
Comparer deux numéros de version n1.n2[.n3]
|
||||
@param nv1
|
||||
@param nv2
|
||||
@result comp : -1 si nv1 < nv2, 0 si nv1 = nv2, 1 si nv1 > nv2
|
||||
*}}
|
||||
|
||||
{{:assign nv1=$nv1|cat:"."}}
|
||||
{{:assign nv2=$nv2|cat:"."}}
|
||||
{{:assign var="tv1" value=$nv1|explode:"."}}
|
||||
{{:assign var="tv2" value=$nv2|explode:"."}}
|
||||
|
||||
{{:assign comp=0}}
|
||||
{{:assign i=0}}
|
||||
{{#foreach from=$tv1 item="e1"}}
|
||||
{{:assign var="e2" from="tv2.%d"|args:$i}}
|
||||
{{if $e1 < $e2}}
|
||||
{{:assign comp=-1}}
|
||||
{{:break}}
|
||||
{{elseif $e1 > $e2}}
|
||||
{{:assign comp=1}}
|
||||
{{:break}}
|
||||
{{/if}}
|
||||
{{:assign i="%d+1"|math:$i}}
|
||||
{{/foreach}}
|
||||
{{*
|
||||
cas où le premier tableau a moins d'éléments que le 2ème
|
||||
et où les éléments présents dans les deux tableaux sont identiques
|
||||
*}}
|
||||
{{if $comp == 0 && $tv1|count < $tv2|count}}
|
||||
{{:assign comp = -1}}
|
||||
{{/if}}
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
{{* -*- brindille -*- *}}
|
||||
|
||||
{{*
|
||||
Supprimer l'association entre une écriture d'amortissement et
|
||||
une écriture d'immobilisation
|
||||
@param immo_doc_id : id du doc associé à l'immo
|
||||
@param amort_line_id : id de la ligne d'amortissement
|
||||
*}}
|
||||
|
||||
{{:include file="_common_detach.html" immo_doc_id=$immo_doc_id line_id=$amort_line_id keep="info_immo"}}
|
||||
|
||||
{{* supprimer le doc de liaison entre les lignes *}}
|
||||
{{#load type="amort_link"
|
||||
where="$$.immo_doc_id = :immo_doc_id AND $$.amort_line_id = :amort_line_id"
|
||||
:immo_doc_id=$immo_doc_id|intval
|
||||
:amort_line_id = $amort_line_id|intval
|
||||
}}
|
||||
{{:delete id=$id}}
|
||||
{{/load}}
|
||||
|
||||
{{* marquer immo non soldée *}}
|
||||
{{if $info_immo.status == "amortized"}}
|
||||
{{:save
|
||||
key=$info_immo.key
|
||||
status="managed"
|
||||
}}
|
||||
{{/if}}
|
||||
|
|
@ -4,7 +4,6 @@
|
|||
lister les lignes d'amortissement liées à la ligne d'immobilisation
|
||||
@param immo_doc_id : id du doc associé à l'immobilisation
|
||||
@result linked_amort : lignes d'amortissement liées à la ligne d'immobilisation
|
||||
@result sommes_amort : montant des amortissements par compte d'amortissement
|
||||
@result total_amort : montant total des amortissements de l'immobilisation
|
||||
@result created_amort : vrai s'il y a au moins un amortissement créé par le module dans la liste
|
||||
*}}
|
||||
|
|
@ -40,8 +39,6 @@
|
|||
{{:assign var="created_amort" value=true}}
|
||||
{{/if}}
|
||||
{{:assign var="linked_amort.%s_%d"|args:$amort_line.date:$amort_info.id value=$amort_line}}
|
||||
{{:assign var="montant" from="sommes_amort.%s"|args:$account_code}}
|
||||
{{:assign var="sommes_amort.%s"|args:$account_code value="%d+%d"|math:$montant:$amort_line.amount}}
|
||||
{{:assign total_amort="%d+%d"|math:$total_amort:$amort_line.amount}}
|
||||
{{/select}}
|
||||
{{/load}}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
{{*
|
||||
lister les amortissement non rattachés à une immo
|
||||
@param condition
|
||||
@param filter_condition
|
||||
*}}
|
||||
{{#select
|
||||
line.id as line_id,
|
||||
|
|
@ -18,9 +18,9 @@
|
|||
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
|
||||
WHERE credit > 0 AND !condition
|
||||
WHERE credit > 0 AND (NOT trans.status & 16) AND !filter_condition
|
||||
ORDER BY trans.date, trans.label;
|
||||
!condition=$condition
|
||||
!filter_condition=$filter_condition
|
||||
assign="amort_line"
|
||||
}}
|
||||
{{* voir s'il existe des lignes d'immo liées à cette ligne d'amortissement *}}
|
||||
|
|
|
|||
|
|
@ -4,18 +4,31 @@
|
|||
|
||||
{{:include file="_get_config.html" keep="module.config"}}
|
||||
|
||||
<p class="block help">
|
||||
<p class="help">
|
||||
{{if $type_immo == "managed"}}
|
||||
Cet onglet liste les immobilisations en cours d'amortissement.
|
||||
Cette page liste les immobilisations en cours d'amortissement
|
||||
{{elseif $type_immo == "amortized"}}
|
||||
Cet onglet liste les
|
||||
immobilisations dont l'amortissement est terminé mais qui sont
|
||||
encore utilisées dans l'association, donc encore présentes au
|
||||
bilan.
|
||||
Cette page liste les immobilisations dont l'amortissement est terminé
|
||||
{{/if}}
|
||||
</p>
|
||||
|
||||
{{if $module.table != null}}
|
||||
<table class="list">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="num">N°</th>
|
||||
<th>Date</th>
|
||||
<th>Libellé</th>
|
||||
<th class="nombre">Montant</th>
|
||||
<th class="nombre">Durée</th>
|
||||
<th class="nombre">Amortissements</th>
|
||||
<th class="nombre">Valeur nette</th>
|
||||
<th>N° compte</th>
|
||||
<th class="actions"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
{{* lister les immobilisations *}}
|
||||
{{:assign account_condition="("}}
|
||||
{{#foreach from=$module.config.prefixes item="code"}}
|
||||
|
|
@ -26,6 +39,8 @@
|
|||
{{:assign status_condition="($$.status = 'managed' OR $$.status = 'amortized')"}}
|
||||
{{:assign condition=$account_condition|cat:" AND line.debit > 0 AND "|cat:$status_condition}}
|
||||
|
||||
{{:assign nb_immo=0}}
|
||||
{{:assign total_immo = 0}}
|
||||
{{#select
|
||||
trans.id as immo_trans_id,
|
||||
trans.label as trans_label,
|
||||
|
|
@ -52,9 +67,19 @@
|
|||
ORDER BY COALESCE(doc_date_achat, trans_date) DESC;
|
||||
!table=$module.table
|
||||
!condition=$condition
|
||||
assign="immo_line"
|
||||
}}
|
||||
{{if $status != "managed" && $status != "amortized"}}
|
||||
{{:continue}}
|
||||
{{/if}}
|
||||
{{: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 montant_immo=$doc_amount|or:$debit}}
|
||||
{{:assign immo_date = $doc_date_achat|or:$trans_date}}
|
||||
{{:assign label_immo=$doc_label|or:$trans_label}}
|
||||
{{if $line_label != null && $line_label != $label_immo}}
|
||||
{{:assign label_immo=$label_immo|cat:" — "|cat:$line_label}}
|
||||
{{/if}}
|
||||
|
||||
{{* déduire le montant des écritures liées à l'immo courante au crédit du même compte *}}
|
||||
{{#load
|
||||
type="credit_link"
|
||||
|
|
@ -74,8 +99,6 @@
|
|||
{{if $montant_immo == 0}}
|
||||
{{* Immobilisation soldée *}}
|
||||
{{:continue}}
|
||||
{{else}}
|
||||
{{:assign var="immo_line.montant_immo" value=$montant_immo}}
|
||||
{{/if}}
|
||||
|
||||
{{* montant des amortissements liés à l'immobilisation *}}
|
||||
|
|
@ -85,42 +108,11 @@
|
|||
{{* classement par onglet *}}
|
||||
{{if $type_immo == "managed" && $amort_amount >= $montant_immo}}{{:continue}}{{/if}}
|
||||
{{if $type_immo == "amortized" && $amort_amount < $montant_immo}}{{:continue}}{{/if}}
|
||||
{{:assign var="immo_line.amort_amount" value=$amort_amount}}
|
||||
|
||||
{{:assign var="immo_lines." value=$immo_line}}
|
||||
{{/select}}
|
||||
|
||||
{{if $immo_lines|count > 0}}
|
||||
<table class="list">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="num">N°</th>
|
||||
<th>Date</th>
|
||||
<th>Libellé</th>
|
||||
<th class="nombre">Montant</th>
|
||||
<th class="nombre">Durée</th>
|
||||
<th class="nombre">Amortissements</th>
|
||||
<th class="nombre">Valeur nette</th>
|
||||
<th>N° compte</th>
|
||||
<th class="actions"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
{{:assign total_immo = 0}}
|
||||
{{#foreach from=$immo_lines}}
|
||||
{{: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 immo_date = $doc_date_achat|or:$trans_date}}
|
||||
{{:assign label_immo=$doc_label|or:$trans_label}}
|
||||
{{if $label_immo|strpos:$line_label === false}}
|
||||
{{:assign label_immo=$label_immo|cat:" — "|cat:$line_label}}
|
||||
{{/if}}
|
||||
|
||||
{{:assign nb_immo="%d+1"|math:$nb_immo}}
|
||||
{{:assign total_immo="%d+%d"|math:$total_immo:$montant_immo}}
|
||||
{{: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}}">#{{$immo_trans_id}}</a></td>
|
||||
<td>{{$immo_date|date_short}}</td>
|
||||
|
|
@ -137,9 +129,7 @@
|
|||
}}
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
{{/foreach}}
|
||||
|
||||
{{/select}}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
{{if $total_immo != 0}}
|
||||
|
|
@ -173,8 +163,7 @@
|
|||
{{/if}}
|
||||
</tfoot>
|
||||
</table>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{if $immo_lines|count == 0 || $module.table == null}}
|
||||
{{if $nb_immo == 0 || $module.table == null}}
|
||||
<p class="block alert">Aucune immobilisation</p>
|
||||
{{/if}}
|
||||
|
|
|
|||
|
|
@ -3,11 +3,10 @@
|
|||
{{* Liste des immobilisations non gérées ou non entièrement affectées *}}
|
||||
|
||||
{{:include file="_get_config.html" keep="module.config"}}
|
||||
<p class="block help">
|
||||
Cet onglet liste les immobilisations créées en dehors du module et
|
||||
pas encore prises en charge par le module ou les écritures de la
|
||||
balance d'ouverture initiale dont le montant n'est pas encore
|
||||
totalement affecté
|
||||
<p class="help">
|
||||
Cette page liste les immobilisations pas encore prises en charge
|
||||
par le module ou les écritures de la balance d'ouverture initiale
|
||||
dont le montant n'est pas encore totalement affecté
|
||||
</p>
|
||||
|
||||
{{:assign saved_hides=$module.config.hides}}
|
||||
|
|
@ -33,7 +32,7 @@
|
|||
{{if $module.table != null}}
|
||||
{{:assign columns="$$.status as status, SUM($$.amount) as amount,"}}
|
||||
{{:assign table_join="LEFT JOIN !table AS info ON $$.line = line.id"}}
|
||||
{{:assign doc_condition="($$.status IS NULL OR $$.status == 'managed' OR $$.status == 'ignored' OR $$.status == 'amortized')"}}
|
||||
{{:assign doc_condition="($$.status IS NULL OR $$.status == 'managed' OR $$.status == 'ignored')"}}
|
||||
{{else}}
|
||||
{{:assign columns=""}}
|
||||
{{:assign table_join=""}}
|
||||
|
|
@ -50,9 +49,24 @@
|
|||
{{:assign account_condition=$account_condition|cat:" account.code LIKE "|cat:$code|cat:" OR "}}
|
||||
{{/foreach}}
|
||||
{{:assign account_condition=$account_condition|cat:"0)"}}
|
||||
{{:assign condition=$account_condition|cat:" AND debit > 0 AND "|cat:$doc_condition}}
|
||||
|
||||
{{if $unhide == null}}
|
||||
{{:assign filter_condition="NOT ("}}
|
||||
{{#foreach from=$module.config.filters item="filter"}}
|
||||
{{:assign filter="%"|cat:$filter|cat:"%"|quote_sql}}
|
||||
{{:assign filter_condition=$filter_condition|cat:" trans_label LIKE "|cat:$filter|cat:" OR "}}
|
||||
{{/foreach}}
|
||||
{{:assign filter_condition=$filter_condition|cat:"0)"}}
|
||||
{{else}}
|
||||
{{:assign filter_condition="1"}}
|
||||
{{/if}}
|
||||
|
||||
{{:assign condition=$account_condition|cat:" AND debit > 0 AND NOT (trans.status & 16) AND "|cat:$filter_condition|cat:" AND "|cat:$doc_condition}}
|
||||
|
||||
{{:assign nb_managed=0}}
|
||||
{{:assign nb_ignored=0}}
|
||||
{{:assign nb_null=0}}
|
||||
{{:assign nb_other=0}}
|
||||
{{#select
|
||||
trans.id as immo_trans_id,
|
||||
trans.label as trans_label,
|
||||
|
|
@ -72,51 +86,43 @@
|
|||
!table_join
|
||||
WHERE !condition
|
||||
GROUP BY immo_line_id
|
||||
ORDER BY trans.date;
|
||||
ORDER BY trans.date DESC;
|
||||
!columns=$columns
|
||||
!table_join=$table_join
|
||||
!table=$module.table
|
||||
!condition=$condition
|
||||
assign="immo_line"
|
||||
}}
|
||||
{{if $immo_line.status == 'managed' || $immo_line.status == 'amortized'}}
|
||||
}}
|
||||
{{*
|
||||
parmi les immos gérées, ne conserver que celles dont le montant dans le doc est non nul
|
||||
et inférieur au montant de l'écriture d'immo
|
||||
*}}
|
||||
{{if $immo_line.status == 'managed'}}
|
||||
{{if $immo_line.amount == null || $immo_line.amount == 0 || $immo_line.amount == $immo_line.debit}}
|
||||
{{:continue}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
{{if $immo_line.status == 'ignored'}}
|
||||
{{if $status == null}}
|
||||
{{:assign nb_null="%d+1"|math:$nb_null}}
|
||||
{{elseif $status == 'managed'}}
|
||||
{{:assign nb_managed="%d+1"|math:$nb_managed}}
|
||||
{{elseif $status == 'ignored'}}
|
||||
{{:assign nb_ignored="%d+1"|math:$nb_ignored}}
|
||||
{{else}}
|
||||
{{:assign nb_other="%d+1"|math:$nb_other}}
|
||||
{{/if}}
|
||||
|
||||
{{if $unhide == null && $immo_line.status == "ignored"}}
|
||||
{{:continue}}
|
||||
{{/if}}
|
||||
|
||||
{{* vérifier si le libellé aurait pu être filtré *}}
|
||||
{{#foreach from=$module.config.filters item="filter"}}
|
||||
{{if $trans_label|strpos:$filter !== false}}
|
||||
{{:assign var="immo_line.status" value="ignored"}}
|
||||
{{:assign nb_ignored="%d+1"|math:$nb_ignored}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
|
||||
{{if $unhide == null && $immo_line.status == "ignored"}}
|
||||
{{:continue}}
|
||||
{{/if}}
|
||||
{{:assign var="immo_lines." value=$immo_line}}
|
||||
{{/select}}
|
||||
|
||||
{{if $nb_ignored > 0}}
|
||||
<form method="post" action="">
|
||||
<form method="post" action="">
|
||||
<fieldset>
|
||||
{{:input type="checkbox" value=1 name="unhide" checked="%s"|args:$checked label="Afficher les écritures ignorées" }}
|
||||
</fieldset>
|
||||
</form>
|
||||
{{/if}}
|
||||
</form>
|
||||
|
||||
{{if $immo_lines|count > 0}}
|
||||
<table class="list">
|
||||
<table class="list">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="num">N°</th>
|
||||
|
|
@ -133,6 +139,20 @@
|
|||
</thead>
|
||||
<tbody>
|
||||
{{#foreach from=$immo_lines item="line"}}
|
||||
|
||||
{{if $unhide == null}}
|
||||
{{if $status == "ignored"}}
|
||||
{{:continue}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{* vérifier si le libellé aurait pu être filtré *}}
|
||||
{{#foreach from=$module.config.filters item="filter"}}
|
||||
{{if $trans_label|strpos:$filter !== false}}
|
||||
{{:assign status="ignored"}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
{{/if}}
|
||||
|
||||
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$line.immo_trans_id}}
|
||||
{{:assign compte_url="%s/acc/accounts/journal.php?id=%s&year=%s"|args:$admin_url:$line.account_id:$line.trans_id_year}}
|
||||
{{:assign reste="%d-%d"|math:$line.debit:$line.amount}}
|
||||
|
|
@ -157,7 +177,7 @@
|
|||
</tr>
|
||||
{{/foreach}}
|
||||
</tbody>
|
||||
</table>
|
||||
</table>
|
||||
{{else}}
|
||||
<p class="block alert">Aucune immobilisation</p>
|
||||
{{/if}}
|
||||
|
|
@ -169,10 +189,7 @@ function changeVisibility(evt, idcheck = 'f_unhide_1') {
|
|||
}
|
||||
|
||||
(function () {
|
||||
let unhide_button = document.getElementById('f_unhide_1');
|
||||
if (unhide_button != null) {
|
||||
unhide_button.onclick = changeVisibility;
|
||||
}
|
||||
document.getElementById('f_unhide_1').onclick = changeVisibility;
|
||||
})();
|
||||
|
||||
</script>
|
||||
|
|
|
|||
50
_nav.html
50
_nav.html
|
|
@ -1,31 +1,55 @@
|
|||
{{* -*- brindille -*- *}}
|
||||
|
||||
<nav class="tabs">
|
||||
{{if $subcurrent == null}}
|
||||
{{if $current == "managed" || $current == "amortized" || $current == "archived"}}
|
||||
{{if $current == "index" && $subcurrent != "unfinished" && $subsubcurrent == null}}
|
||||
<aside>
|
||||
{{:linkbutton label="Ajouter une immobilisation" shape="plus" href="add_asset.html"}}
|
||||
</aside>
|
||||
{{elseif $current == "index" && $subcurrent == "details"}}
|
||||
<aside>
|
||||
{{if $subsubcurrent|match:"credit"}}
|
||||
{{:linkbutton label="Rattacher une écriture d'immobilisation" href="link_immo.html?immo_doc_id=%s"|args:$_GET.immo_doc_id shape="link" target="_dialog"}}
|
||||
{{/if}}
|
||||
{{if $subsubcurrent|match:"modif"}}
|
||||
{{:linkbutton label="Modifier" href="modify_infos.html?immo_doc_id=%s"|args:$_GET.immo_doc_id shape="edit" target="_dialog"}}
|
||||
{{/if}}
|
||||
</aside>
|
||||
{{elseif $subsubcurrent == "amortization" && $type_immo == null || $type_immo == "managed" || $type_immo == "other"}}
|
||||
<aside>
|
||||
{{if $autres_amort}}
|
||||
{{:linkbutton
|
||||
label="Rattacher un amortissement"
|
||||
title="Rattacher un amortissement existant"
|
||||
href="other_amortizations.html?immo_doc_id=%s"|args:$_GET.immo_doc_id
|
||||
shape="link"
|
||||
target="_dialog"}}
|
||||
{{/if}}
|
||||
{{:linkbutton
|
||||
label="Enregistrer un amortissement"
|
||||
title="Enregistrer un nouvel amortissement"
|
||||
href="save_amort.html?immo_doc_id=%s"|args:$_GET.immo_doc_id target="_dialog"
|
||||
shape="plus"
|
||||
}}
|
||||
</aside>
|
||||
{{/if}}
|
||||
|
||||
<ul>
|
||||
<li {{if $current == "managed"}}class="current"{{/if}}><a href="index.html?type_immo=managed">Amortissables</a></li>
|
||||
<li {{if $current == "amortized"}}class="current"{{/if}}><a href="index.html?type_immo=amortized">Amorties</a></li>
|
||||
<li {{if $current == "archived"}}class="current"{{/if}}><a href="index.html?type_immo=archived">Sorties du bilan</a></li>
|
||||
<li {{if $current == "unfinished"}}class="current"{{/if}}><a href="index.html?type_immo=unfinished">En cours de constitution</a></li>
|
||||
<li {{if $current == "other"}}class="current"{{/if}}><a href="index.html?type_immo=other">À classer</a></li>
|
||||
<li {{if $subcurrent == "managed"}}class="current"{{/if}}><a href="index.html?type_immo=managed">Amortissables</a></li>
|
||||
<li {{if $subcurrent == "amortized"}}class="current"{{/if}}><a href="index.html?type_immo=amortized">Amorties</a></li>
|
||||
<li {{if $subcurrent == "archived"}}class="current"{{/if}}><a href="index.html?type_immo=archived">Sorties du bilan</a></li>
|
||||
<li {{if $subcurrent == "unfinished"}}class="current"{{/if}}><a href="index.html?type_immo=unfinished">En cours</a></li>
|
||||
<li {{if $subcurrent == "other"}}class="current"{{/if}}><a href="index.html?type_immo=other">À classer</a></li>
|
||||
<li {{if $current == "config"}} class="current"{{/if}}><a href="config.html">Configuration</a></li>
|
||||
</ul>
|
||||
|
||||
{{if $subcurrent != null}}
|
||||
{{if $subsubcurrent != null}}
|
||||
<ul class="sub">
|
||||
{{if $subcurrent == "transfer"}}
|
||||
<li class="title strong">Transfert d'immobilisations</li>
|
||||
{{elseif $subcurrent == "balance_exit"}}
|
||||
{{if $subsubcurrent == "amortization"}}
|
||||
<li class="title strong">Amortissements</li>
|
||||
{{elseif $subsubcurrent == "balance_exit"}}
|
||||
<li class="title strong">Sortie de bilan</li>
|
||||
{{elseif $subcurrent == "details"}}
|
||||
<li class="title strong">Détails</li>
|
||||
{{elseif $subsubcurrent == "transfer"}}
|
||||
<li class="title strong">Transfert d'immobilisations</li>
|
||||
{{/if}}
|
||||
</ul>
|
||||
{{/if}}
|
||||
|
|
|
|||
212
_unfinished.html
212
_unfinished.html
|
|
@ -2,20 +2,19 @@
|
|||
|
||||
{{* Liste des immobilisations en cours de constitution *}}
|
||||
|
||||
<p class="block help">
|
||||
Cet onglet liste les immobilisations en cours de
|
||||
constitution ; vous pouvez les sélectionner pour créer une
|
||||
immobilisation amortissable (exemple : achat de matériaux pour
|
||||
la construction d'un bâtiment destiné à être amorti)
|
||||
</p>
|
||||
<section class="immobilisation">
|
||||
|
||||
{{:include file="_get_config.html" keep="module.config"}}
|
||||
{{:assign saved_hides=$module.config.hides}}
|
||||
{{:assign var="user_hides" from="saved_hides.%s"|args:$logged_user.id}}
|
||||
<p class="help">
|
||||
Cette page liste les immobilisations en cours de constitution, donc non amortissables
|
||||
</p>
|
||||
|
||||
{{if $_POST|count == 0}}
|
||||
{{:include file="_get_config.html" keep="module.config"}}
|
||||
{{:assign saved_hides=$module.config.hides}}
|
||||
{{:assign var="user_hides" from="saved_hides.%s"|args:$logged_user.id}}
|
||||
|
||||
{{if $_POST|count == 0}}
|
||||
{{:assign unhide=$user_hides.unhide_unfinished}}
|
||||
{{else}}
|
||||
{{else}}
|
||||
{{if $_POST.unhide == null}}
|
||||
{{:assign unhide=0}}
|
||||
{{else}}
|
||||
|
|
@ -24,99 +23,12 @@
|
|||
{{:assign var="user_hides.unhide_unfinished" value=$unhide"}}
|
||||
{{:assign var="saved_hides.%s"|args:$logged_user.id value=$user_hides}}
|
||||
{{:save key="config" hides=$saved_hides}}
|
||||
{{/if}}
|
||||
{{if $unhide}}
|
||||
{{/if}}
|
||||
{{if $unhide}}
|
||||
{{:assign checked="checked"}}
|
||||
{{/if}}
|
||||
|
||||
{{* lister les immobilisations en cours de constitution *}}
|
||||
{{:assign first_code=null}}
|
||||
{{:assign accounts_condition="("}}
|
||||
{{#foreach from=$module.config.unfinished item="elem"}}
|
||||
{{if $elem.code != null}}
|
||||
{{:assign code=$elem.code}}
|
||||
{{else}}
|
||||
{{:assign code=$elem}}
|
||||
{{/if}}
|
||||
{{if $first_code == null}}
|
||||
{{:assign first_code=$code}}
|
||||
{{/if}}
|
||||
{{:assign code=$code|cat:"%"|quote_sql}}
|
||||
{{:assign accounts_condition=$accounts_condition|cat:" account.code LIKE "|cat:$code|cat:" OR "}}
|
||||
{{/foreach}}
|
||||
{{:assign accounts_condition=$accounts_condition|cat:"0)"}}
|
||||
{{:assign condition=$accounts_condition|cat:" AND debit > 0"}}
|
||||
|
||||
{{:assign filter_condition=" NOT ("}}
|
||||
{{#foreach from=$module.config.filters item="filter"}}
|
||||
{{:assign filter="%"|cat:$filter|cat:"%"|quote_sql}}
|
||||
{{:assign filter_condition=$filter_condition|cat:" trans_label LIKE "|cat:$filter|cat:" OR "}}
|
||||
{{/foreach}}
|
||||
{{:assign filter_condition=$filter_condition|cat:"0)"}}
|
||||
{{:assign condition=$condition|cat:" AND "|cat:$filter_condition}}
|
||||
|
||||
{{:assign nb_ignored=0}}
|
||||
{{#select
|
||||
trans.id as trans_id,
|
||||
trans.label as trans_label,
|
||||
trans.date as trans_date,
|
||||
line.id as immo_line_id,
|
||||
account.id as account_id,
|
||||
account.code as account_code,
|
||||
account.label as account_label,
|
||||
sum(line.debit) AS debit,
|
||||
trans.id_year as trans_id_year
|
||||
FROM acc_transactions AS trans
|
||||
INNER JOIN acc_transactions_lines AS line ON line.id_transaction = trans.id
|
||||
INNER JOIN acc_accounts AS account ON line.id_account = account.id
|
||||
INNER JOIN acc_years AS years ON trans.id_year = years.id
|
||||
WHERE !condition
|
||||
GROUP BY trans.id
|
||||
ORDER BY trans.date DESC;
|
||||
!condition=$condition
|
||||
assign="immo_line"
|
||||
}}
|
||||
{{* voir si l'écriture a été marquée ignorée *}}
|
||||
{{:assign var="immo_line.ignore" value=false}}
|
||||
{{#load type="immo" assign="info_immo" where="$$.line = :line_id AND $$.status = 'ignored'" :line_id=$immo_line_id|intval}}
|
||||
{{:assign var="immo_line.ignore" value=true}}
|
||||
{{/load}}
|
||||
{{if $immo_line.ignore}}
|
||||
{{:assign nb_ignored="%d + 1"|math:$nb_ignored}}
|
||||
{{/if}}
|
||||
{{if $immo_line.ignore && $unhide == null}}
|
||||
{{:continue}}
|
||||
{{/if}}
|
||||
|
||||
{{*
|
||||
TODO cas où :
|
||||
- il y a (au moins) une écriture d'avoir
|
||||
*}}
|
||||
|
||||
{{* voir s'il existe une écriture qui solde l'immobilisation (voir ci-dessus) *}}
|
||||
{{#select
|
||||
count(*) AS count
|
||||
FROM acc_transactions AS trans
|
||||
INNER JOIN acc_transactions_lines AS line ON line.id_transaction = trans.id
|
||||
INNER JOIN acc_accounts AS account ON line.id_account = account.id
|
||||
WHERE line.credit = :amount AND code = :account_code
|
||||
;
|
||||
:amount = $debit
|
||||
:account_code = $account_code
|
||||
}}
|
||||
{{:assign count=$count}}
|
||||
{{/select}}
|
||||
|
||||
{{* S'il y a plus d'une écriture de même montant on ne peut pas décider *}}
|
||||
{{if $count == 1}}
|
||||
{{:continue}}
|
||||
{{/if}}
|
||||
|
||||
{{:assign var="immo_lines." value=$immo_line}}
|
||||
{{/select}}
|
||||
|
||||
<form method="post" action="">
|
||||
{{if $immo_lines|count > 0}}
|
||||
<form method="post" action="">
|
||||
<fieldset class="shortFormLeft">
|
||||
<legend>Transférer une ou plusieurs lignes vers une immobilisation amortissable</legend>
|
||||
<p class="help">
|
||||
|
|
@ -142,16 +54,11 @@
|
|||
</p>
|
||||
</div>
|
||||
</fieldset>
|
||||
{{/if}}
|
||||
{{if $nb_ignored !== 0}}
|
||||
<fieldset>
|
||||
{{:input type="checkbox" value=1 name="unhide" checked="%s"|args:$checked label="Afficher les écritures ignorées" }}
|
||||
{{:input type="checkbox" value=1 name="unhide" checked="%s"|args:$checked label="Afficher toutes les écritures" }}
|
||||
</fieldset>
|
||||
{{/if}}
|
||||
</form>
|
||||
</form>
|
||||
|
||||
{{if $immo_lines|count > 0}}
|
||||
<section class="immobilisation">
|
||||
<table class="list">
|
||||
<thead>
|
||||
<tr>
|
||||
|
|
@ -167,10 +74,86 @@
|
|||
</thead>
|
||||
<tbody>
|
||||
|
||||
{{* lister les immobilisations en cours de constitution *}}
|
||||
|
||||
{{:assign accounts_condition="("}}
|
||||
{{#foreach from=$module.config.unfinished item="elem"}}
|
||||
{{if $elem.code != null}}
|
||||
{{:assign code=$elem.code}}
|
||||
{{else}}
|
||||
{{:assign code=$elem}}
|
||||
{{/if}}
|
||||
{{:assign code=$code|cat:"%"|quote_sql}}
|
||||
{{:assign accounts_condition=$accounts_condition|cat:" account.code LIKE "|cat:$code|cat:" OR "}}
|
||||
{{/foreach}}
|
||||
{{:assign accounts_condition=$accounts_condition|cat:"0)"}}
|
||||
{{:assign condition=$accounts_condition|cat:" AND debit > 0 AND NOT (trans.status & 16)"}}
|
||||
|
||||
{{:assign filter_condition=" NOT ("}}
|
||||
{{#foreach from=$module.config.filters item="filter"}}
|
||||
{{:assign filter="%"|cat:$filter|cat:"%"|quote_sql}}
|
||||
{{:assign filter_condition=$filter_condition|cat:" trans_label LIKE "|cat:$filter|cat:" OR "}}
|
||||
{{/foreach}}
|
||||
{{:assign filter_condition=$filter_condition|cat:"0)"}}
|
||||
{{:assign condition=$condition|cat:" AND "|cat:$filter_condition}}
|
||||
{{:assign nb_immo=0}}
|
||||
{{:assign total_immo = 0}}
|
||||
{{#foreach from=$immo_lines}}
|
||||
{{#select
|
||||
trans.id as trans_id,
|
||||
trans.label as trans_label,
|
||||
trans.date as trans_date,
|
||||
line.id as immo_line_id,
|
||||
account.id as account_id,
|
||||
account.code as account_code,
|
||||
account.label as account_label,
|
||||
sum(line.debit) AS debit,
|
||||
trans.id_year as trans_id_year
|
||||
FROM acc_transactions AS trans
|
||||
INNER JOIN acc_transactions_lines AS line ON line.id_transaction = trans.id
|
||||
INNER JOIN acc_accounts AS account ON line.id_account = account.id
|
||||
INNER JOIN acc_years AS years ON trans.id_year = years.id
|
||||
WHERE !condition
|
||||
GROUP BY trans.id
|
||||
ORDER BY trans.date DESC;
|
||||
!condition=$condition
|
||||
}}
|
||||
{{* voir si l'écriture a été marquée ignorée *}}
|
||||
{{:assign ignore=false}}
|
||||
{{#load type="immo" assign="info_immo" where="$$.line = :line_id AND $$.status = 'ignored'" :line_id=$immo_line_id|intval}}
|
||||
{{:assign ignore=true}}
|
||||
{{/load}}
|
||||
{{if $ignore && $unhide == null}}
|
||||
{{:continue}}
|
||||
{{/if}}
|
||||
|
||||
{{*
|
||||
TODO cas où :
|
||||
- il y a (au moins) une écriture d'avoir
|
||||
- il y a une écriture qui solde l'immo (montant = montant immo - avoir
|
||||
*}}
|
||||
|
||||
{{* voir s'il existe une écriture qui solde l'immobilisation (voir ci-dessus) *}}
|
||||
{{#select
|
||||
count(*) AS count
|
||||
FROM acc_transactions AS trans
|
||||
INNER JOIN acc_transactions_lines AS line ON line.id_transaction = trans.id
|
||||
INNER JOIN acc_accounts AS account ON line.id_account = account.id
|
||||
WHERE line.credit = :amount AND code = :account_code
|
||||
;
|
||||
:amount = $debit
|
||||
:account_code = $account_code
|
||||
}}
|
||||
{{:assign count=$count}}
|
||||
{{/select}}
|
||||
|
||||
{{* S'il y a plus d'une écriture de même montant on ne peut pas décider *}}
|
||||
{{if $count == 1}}
|
||||
{{:continue}}
|
||||
{{/if}}
|
||||
|
||||
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$trans_id}}
|
||||
{{:assign compte_url="%s/acc/accounts/journal.php?id=%s&year=%s"|args:$admin_url:$account_id:$trans_id_year}}
|
||||
{{:assign nb_immo="%d+1"|math:$nb_immo}}
|
||||
{{:assign total_immo="%d+%d"|math:$total_immo:$debit}}
|
||||
{{:assign var="montant" from="sommes_immo.%s"|args:$account_code}}
|
||||
{{:assign var="sommes_immo.%s"|args:$account_code value="%d+%d"|math:$montant:$debit}}
|
||||
|
|
@ -192,8 +175,7 @@
|
|||
}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/foreach}}
|
||||
|
||||
{{/select}}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
{{if $total_immo != 0}}
|
||||
|
|
@ -222,10 +204,10 @@
|
|||
{{/if}}
|
||||
</tfoot>
|
||||
</table>
|
||||
</section>
|
||||
{{else}}
|
||||
<p class="block alert">Aucune écriture d'immobilisation trouvée dans la comptabilité (compte {{$first_code}} et sous-comptes)</p>
|
||||
{{/if}}
|
||||
{{if $nb_immo == 0}}
|
||||
<p class="block alert">Aucune immobilisation</p>
|
||||
{{/if}}
|
||||
</section>
|
||||
|
||||
<script type="text/javascript" src="scripts.js"></script>
|
||||
<script type="text/javascript" async="async">
|
||||
|
|
|
|||
|
|
@ -1,41 +0,0 @@
|
|||
{{* -*- brindille -*- *}}
|
||||
|
||||
{{*
|
||||
mise à niveau des documents selon version
|
||||
*}}
|
||||
|
||||
{{* version 0.31 *}}
|
||||
{{:assign tag="0.31"}}
|
||||
|
||||
{{:include file="_compare_version.tpl" nv1=$module_version nv2=$tag keep="comp"}}
|
||||
{{:assign module_comp=$comp}}
|
||||
{{:include file="_compare_version.tpl" nv1=$module.config.version nv2=$tag keep="comp"}}
|
||||
{{:assign config_comp=$comp}}
|
||||
|
||||
{{if $module_comp >= 0 && $config_comp < 0}}
|
||||
{{* $module_version >= '0.31' && $module.config.version < '0.31' *}}
|
||||
|
||||
{{:include file="_upgrade_to031.tpl"}}
|
||||
<p class="block info">Mise à jour vers version {{$tag}} terminée</p>
|
||||
{{/if}}
|
||||
|
||||
{{* version 0.33 *}}
|
||||
{{:assign tag="0.33"}}
|
||||
|
||||
{{:include file="_compare_version.tpl" nv1=$module_version nv2=$tag keep="comp"}}
|
||||
{{:assign module_comp=$comp}}
|
||||
{{:include file="_compare_version.tpl" nv1=$module.config.version nv2=$tag keep="comp"}}
|
||||
{{:assign config_comp=$comp}}
|
||||
|
||||
{{if $module_comp >= 0 && $config_comp < 0}}
|
||||
{{* $module_version >= '0.33' && $module.config.version < '0.33' *}}
|
||||
|
||||
{{:include file="_upgrade_to033.tpl"}}
|
||||
<p class="block info">Mise à jour vers version {{$tag}} terminée</p>
|
||||
{{/if}}
|
||||
|
||||
{{* enregistrer le nouveau numéro de version dans la config du module *}}
|
||||
{{:include file="_compare_version.tpl" nv1=$module_version nv2=$module.config.version keep="comp"}}
|
||||
{{if $comp > 0}}
|
||||
{{:save key="config" version=$module_version}}
|
||||
{{/if}}
|
||||
|
|
@ -1,99 +0,0 @@
|
|||
{{* -*- brindille -*- *}}
|
||||
|
||||
{{*
|
||||
Mettre à niveau vers v0.31
|
||||
- créer un doc de liaison pour chaque amortissement lié à une immobilisation
|
||||
mais uniquement pour les immo déjà gérées, sinon l'upgrade
|
||||
vers 0.33 ne fonctionnera pas car on pourrait se retrouver avec
|
||||
des liaisons immo <-> amort sans doc associé à l'immo donc la
|
||||
transformation de link vers amort_link ne pourra se faire
|
||||
|
||||
- id ligne d'immobilisation
|
||||
- id ligne d'amortissement
|
||||
- id écriture d'amortissement
|
||||
*}}
|
||||
|
||||
{{* lister les immobilisations *}}
|
||||
{{:include file="_get_config.html" keep="module.config"}}
|
||||
|
||||
{{:assign account_condition="("}}
|
||||
{{#foreach from=$module.config.prefixes item="code"}}
|
||||
{{:assign code=$code|cat:"%"|quote_sql}}
|
||||
{{:assign account_condition=$account_condition|cat:" account.code LIKE "|cat:$code|cat:" OR "}}
|
||||
{{/foreach}}
|
||||
{{:assign account_condition=$account_condition|cat:"0)"}}
|
||||
|
||||
{{:assign filter_condition=" AND NOT ("}}
|
||||
{{#foreach from=$module.config.filters item="filter"}}
|
||||
{{:assign filter="%"|cat:$filter|cat:"%"|quote_sql}}
|
||||
{{:assign filter_condition=$filter_condition|cat:" trans.label LIKE "|cat:$filter|cat:" OR "}}
|
||||
{{/foreach}}
|
||||
{{:assign filter_condition=$filter_condition|cat:"0)"}}
|
||||
|
||||
{{:assign condition=$account_condition|cat:" AND debit > 0 AND NOT (trans.status & 16)"|cat:$filter_condition}}
|
||||
|
||||
{{#select
|
||||
line.id as immo_line_id
|
||||
FROM acc_transactions AS trans
|
||||
INNER JOIN acc_transactions_lines AS line ON line.id_transaction = trans.id
|
||||
INNER JOIN acc_accounts AS account ON line.id_account = account.id
|
||||
INNER JOIN acc_years AS years ON trans.id_year = years.id
|
||||
WHERE !condition
|
||||
ORDER BY trans.date DESC;
|
||||
!condition=$condition
|
||||
}}
|
||||
{{* voir si l'immo est prise en charge *}}
|
||||
{{#load type="immo" where="$$.line = :line_id" :line_id=$immo_line_id|intval}}
|
||||
{{:assign status=$status}}
|
||||
{{else}}
|
||||
{{:assign status="unknown"}}
|
||||
{{/load}}
|
||||
|
||||
{{* ne pas faire la liaison si pas de doc *}}
|
||||
{{if $status == "ignored" || $status == "unknown"}}
|
||||
{{:continue}}
|
||||
{{/if}}
|
||||
|
||||
{{* lister les écritures d'amortissement liées *}}
|
||||
{{:assign amort_lines=null}}
|
||||
{{#select
|
||||
CASE links.id_related = t_immo.id
|
||||
WHEN true THEN links.id_transaction
|
||||
WHEN false THEN links.id_related
|
||||
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)
|
||||
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_line_id|intval
|
||||
assign="amort_lines."
|
||||
}}
|
||||
{{/select}}
|
||||
|
||||
{{#foreach from=$amort_lines item="line"}}
|
||||
{{* chercher un doc associé *}}
|
||||
{{#load type="link"
|
||||
where="$$.immo_line_id = :immo_line_id
|
||||
AND $$.amort_line_id = :amort_line_id
|
||||
AND $$.amort_trans_id = :amort_trans_id"
|
||||
:immo_line_id = $immo_line_id
|
||||
:amort_line_id = $line.amort_line_id
|
||||
:amort_trans_id = $line.amort_trans_id
|
||||
assign="link"
|
||||
}}
|
||||
{{else}}
|
||||
{{* pas de doc => le créer *}}
|
||||
{{:save
|
||||
key=""|uuid
|
||||
type="link"
|
||||
immo_line_id=$immo_line_id
|
||||
amort_line_id=$line.amort_line_id
|
||||
amort_trans_id=$line.amort_trans_id
|
||||
}}
|
||||
{{/load}}
|
||||
{{/foreach}}
|
||||
{{/select}}
|
||||
|
|
@ -1,64 +0,0 @@
|
|||
{{* -*- brindille -*- *}}
|
||||
|
||||
{{*
|
||||
Mettre à niveau vers v0.33, pour gérer les écritures du bilan d'ouverture
|
||||
où le montant d'une ligne d'immo ou d'une ligne d'amort peut être
|
||||
réparti entre plusieurs immo et plusieurs amort
|
||||
|
||||
- modifier le doc d'immo
|
||||
- date => date_mes (date mise en service)
|
||||
|
||||
- modifier le doc de liaison d'amortissement
|
||||
- id ligne d'immobilisation => id doc immobilisation
|
||||
- id ligne d'amortissement
|
||||
- id écriture d'amortissement
|
||||
- ajouter montant amortissement
|
||||
*}}
|
||||
|
||||
{{* doc immo *}}
|
||||
{{#load type="immo" assign="elem"}}
|
||||
{{if $elem.date != null}}
|
||||
{{:assign var="elem.date_mes" value=$elem.date}}
|
||||
{{:assign var="docs." value=$elem}}
|
||||
{{:delete id=$elem.id}}
|
||||
{{/if}}
|
||||
{{/load}}
|
||||
|
||||
{{* créer les nouveaux documents *}}
|
||||
{{#foreach from=$docs item="doc"}}
|
||||
{{:save
|
||||
key=""|uuid
|
||||
type=$doc.type
|
||||
line=$doc.line
|
||||
duration=$doc.duration
|
||||
label=$doc.label
|
||||
amount=$doc.amount
|
||||
date_achat=$doc.date_achat
|
||||
date_mes=$doc.date_mes
|
||||
status=$doc.status
|
||||
}}
|
||||
{{/foreach}}
|
||||
|
||||
{{* lister les liaisons actuelles ligne amort => ligne immo *}}
|
||||
{{#load type="link" assign="link"}}
|
||||
{{#load type="immo" where="$$.line = :immo_line_id" :immo_line_id=$link.immo_line_id assign="immo"}}
|
||||
{{:assign link_doc=null}}
|
||||
{{:assign var="link_doc.immo_doc_id" value=$immo.id}}
|
||||
{{:assign var="link_doc.amort_line_id" value=$link.amort_line_id}}
|
||||
{{:assign var="link_docs." value=$link_doc}}
|
||||
{{else}}
|
||||
{{* liaison orpheline : ignorer *}}
|
||||
{{/load}}
|
||||
{{:delete id=$link.id}}
|
||||
{{/load}}
|
||||
|
||||
{{* créer les nouvelles liaisons *}}
|
||||
{{#foreach from=$link_docs item="link"}}
|
||||
{{:save
|
||||
key=""|uuid
|
||||
type="amort_link"
|
||||
immo_doc_id=$link.immo_doc_id
|
||||
amort_line_id=$link.amort_line_id
|
||||
amount=null
|
||||
}}
|
||||
{{/foreach}}
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
{{* -*- brindille -*- *}}
|
||||
|
||||
{{:admin_header title="Ajout immobilisation" current="module_amortization"}}
|
||||
{{:include file="_get_config.html" keep="module.config"}}
|
||||
|
||||
{{#years closed=false order="start_date" assign=years.}}
|
||||
|
|
@ -48,8 +47,6 @@
|
|||
keep="account_code"
|
||||
}}
|
||||
{{:assign credit_account=$account_code}}
|
||||
{{:assign debit_account_code=$debit_account|keys|value:0}}
|
||||
{{:assign credit_account_code=$credit_account|keys|value:0}}
|
||||
|
||||
{{* vérifier :
|
||||
- que le compte d'immo débute par un préfixe correct (20, 21, ...)
|
||||
|
|
@ -66,10 +63,6 @@
|
|||
{{:assign code=$elem}}
|
||||
{{/if}}
|
||||
{{:assign var="prefix_array." value=$code}}
|
||||
{{* déterminer si le compte d'immo est un compte d'immo en cours *}}
|
||||
{{if $debit_account_code|strpos:$code === 0}}
|
||||
{{:assign status="unfinished"}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
|
||||
{{:include
|
||||
|
|
@ -85,6 +78,21 @@
|
|||
{{:redirect url="add_account.html?account=%s&chart=%s"|args:$compte:$selected_chart}}
|
||||
{{/if}}
|
||||
|
||||
{{:assign debit_account=$debit_account|keys|value:0}}
|
||||
{{:assign credit_account=$credit_account|keys|value:0}}
|
||||
|
||||
{{* déterminer si le compte d'immo est un compte d'immo en cours *}}
|
||||
{{#foreach from=$module.config.unfinished item="elem"}}
|
||||
{{if $elem.code != null}}
|
||||
{{:assign code=$elem.code}}
|
||||
{{else}}
|
||||
{{:assign code=$elem}}
|
||||
{{/if}}
|
||||
{{if $debit_account|strpos:$code === 0}}
|
||||
{{:assign status="unfinished"}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
|
||||
{{if $status != "unfinished"}}
|
||||
{{* vérifier que la date d'acquisition est antérieure à la date de mise en service *}}
|
||||
{{:assign date_debut=$_POST.date_mes|or:$_POST.date_achat|parse_date}}
|
||||
|
|
@ -112,10 +120,11 @@
|
|||
date=$_POST.date_achat
|
||||
label=$_POST.designation
|
||||
amount=$_POST.montant
|
||||
debit=$debit_account_code
|
||||
credit=$credit_account_code
|
||||
debit=$debit_account
|
||||
credit=$credit_account
|
||||
id_project=$_POST.id_project
|
||||
}}
|
||||
|
||||
{{if $status != "unfinished"}}
|
||||
{{* vérifier s'il y a déjà un document avec le même numéro de ligne *}}
|
||||
{{:assign var="immo_line_id" value=$result.lines.1.id}}
|
||||
|
|
@ -149,9 +158,10 @@
|
|||
|
||||
{{/form}}
|
||||
|
||||
{{:admin_header title="Ajout immobilisation" current="module_amortization"}}
|
||||
{{* barre de navigation *}}
|
||||
{{if ! $dialog}}
|
||||
{{:linkbutton href="index.html" label="Retour" shape="left"}}
|
||||
{{:include file="_nav.html" current="index" subcurrent="managed"}}
|
||||
{{/if}}
|
||||
|
||||
{{:form_errors}}
|
||||
|
|
@ -211,11 +221,10 @@
|
|||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>Amortissement</legend>
|
||||
<span class="help">Informations non utilisées pour les immobilisations du compte 23 et ses sous-comptes</span>
|
||||
<dl>
|
||||
<div id="div_amort">
|
||||
{{:input type="number" name="duree" label="Durée d'amortissement" required=true min=0 default=1 suffix="année(s)"}}
|
||||
{{:input type="date" name="date_mes" label="Date de mise en service" default=$now|date_short help="C'est la date de première utilisation ; à modifier si différente de la date d'acquisition"}}
|
||||
{{:input type="date" name="date_mes" label="Date de mise en service" help="C'est la date de première utilisation ; à renseigner uniquement si différente de la date d'acquisition"}}
|
||||
</div>
|
||||
</dl>
|
||||
</fieldset>
|
||||
|
|
@ -236,8 +245,5 @@ function changeYear(evt, f_accounts = ['credit_account', 'debit_account'], f_yea
|
|||
|
||||
(function () {
|
||||
document.getElementById('f_id_year').onchange = changeYear;
|
||||
document.getElementById('f_date_achat').addEventListener("change", (e) => {
|
||||
document.getElementById('f_date_mes').value = document.getElementById('f_date_achat').value;
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -9,8 +9,14 @@
|
|||
{{:assign montant_affecte=0}}
|
||||
{{#load type="immo" where="$$.line = :line_id" :line_id=$_GET.immo_line_id|intval assign="info_immo"}}
|
||||
{{:assign montant_affecte="%d+%d"|math:$montant_affecte:$amount}}
|
||||
{{:assign choix_defaut=$info_immo.status}}
|
||||
{{/load}}
|
||||
{{if $info_immo != null}}
|
||||
{{:assign date_defaut=$info_immo.date}}
|
||||
{{:assign duree_defaut=$info_immo.duration}}
|
||||
{{:assign choix_defaut=$info_immo.status}}
|
||||
{{else}}
|
||||
{{:assign duree_defaut=null}}
|
||||
{{/if}}
|
||||
|
||||
{{#select
|
||||
trans.id as immo_trans_id,
|
||||
|
|
@ -31,12 +37,7 @@
|
|||
{{:error message="Immobilisation non trouvée"}}
|
||||
{{/select}}
|
||||
{{:assign reste="%d-%d"|math:$ligne_immo.montant:$montant_affecte}}
|
||||
{{:assign date_achat_defaut=$info_immo.date_achat|or:$ligne_immo.date_achat}}
|
||||
{{:assign date_mes_defaut=$info_immo.date_mes|or:$info_immo.date_achat|or:$ligne_immo.date_achat}}
|
||||
{{:assign immo_label=$ligne_immo.trans_label}}
|
||||
{{if $ligne_immo.line_label != null && $ligne_immo.line_label != $ligne_immo.trans_label}}
|
||||
{{:assign immo_label=$immo_label|cat:" — "|cat:$ligne_immo.line_label}}
|
||||
{{/if}}
|
||||
|
||||
|
||||
{{#form on="save"}}
|
||||
{{if $_POST.classify == null}}
|
||||
|
|
@ -52,25 +53,17 @@
|
|||
{{:assign date_mes=null}}
|
||||
{{:assign status="ignored"}}
|
||||
{{elseif $_POST.classify == "archived"}}
|
||||
{{* voir s'il y a déjà un doc associé à cette immo *}}
|
||||
{{#load type="immo" where="$$.line = :immo_line_id" :immo_line_id=$_GET.immo_line_id|intval}}
|
||||
{{:assign uuid=$key}}
|
||||
{{:assign immo_doc_id=$id}}
|
||||
{{else}}
|
||||
{{:assign uuid=""|uuid}}
|
||||
{{/load}}
|
||||
|
||||
{{* immobilisation sortie du bilan *}}
|
||||
{{:save
|
||||
key=$uuid
|
||||
key=""|uuid
|
||||
validate_schema="asset.schema.json"
|
||||
type="immo"
|
||||
line=$_GET.immo_line_id|intval
|
||||
duration=0
|
||||
status=null
|
||||
status="managed"
|
||||
assign_new_id="immo_doc_id"
|
||||
}}
|
||||
{{:redirect force="exit_step1.html?immo_doc_id=%s&from=exit"|args:$immo_doc_id}}
|
||||
{{:redirect force="exit_step1.html?immo_doc_id=%s"|args:$immo_doc_id}}
|
||||
{{else}}
|
||||
{{* immobilisation amortissable *}}
|
||||
{{if $_POST.date_achat|parse_date > $ligne_immo.date_achat}}
|
||||
|
|
@ -158,15 +151,10 @@
|
|||
{{:admin_header title="Classer l'immobilisation" custom_css="./style.css" current="module_amortization"}}
|
||||
{{* barre de navigation *}}
|
||||
{{if ! $dialog}}
|
||||
{{:include file="_nav.html" current="other" subcurrent="parameter"}}
|
||||
{{:include file="_nav.html" current="index" subcurrent="other" subsubcurrent="parameter"}}
|
||||
{{/if}}
|
||||
{{:form_errors}}
|
||||
|
||||
{{* date de début du 1er exercice dans paheko *}}
|
||||
{{#years order="start_date" limit=1}}
|
||||
{{:assign first_date=$start_date}}
|
||||
{{/years}}
|
||||
|
||||
{{*
|
||||
- classer l'immobilisation
|
||||
- renseigner ou modifier la date de mise en service, les écritures associées ou la durée d'amortissement
|
||||
|
|
@ -177,9 +165,7 @@
|
|||
<div class="informations">
|
||||
<dl class="describe">
|
||||
<dt>Immobilisation</dt>
|
||||
<dd>
|
||||
<span class="num"><a href="{{$trans_url}}">#{{$ligne_immo.immo_trans_id}}</a> </span>{{$immo_label}}
|
||||
</dd>
|
||||
<dd><span class="num"><a href="{{$trans_url}}">#{{$ligne_immo.immo_trans_id}}</a></span> {{$ligne_immo.trans_label}}{{if $ligne_immo.line_label != null && $ligne_immo.line_label != $ligne_immo.trans_label}} — {{$ligne_immo.line_label}}{{/if}}</dd>
|
||||
<dt>Montant</dt>
|
||||
<dd class="money strong">{{"%f"|math:$ligne_immo.montant|money_currency_html:false|raw}}</dd>
|
||||
{{if $montant_affecte > 0}}
|
||||
|
|
@ -200,22 +186,20 @@
|
|||
<legend>Classement</legend>
|
||||
<dl id="classement_immo">
|
||||
<dt><label>Faites un choix</label> <b>(obligatoire)</b></dt>
|
||||
{{:input type="radio-btn" name="classify" value="managed" label="Immobilisation à amortir" default=$choix_defaut}}
|
||||
{{if $ligne_immo.date_achat > $first_date}}
|
||||
{{:input type="radio-btn" name="classify" value="archived" label="Immobilisation sortie du bilan" default=$choix_defaut}}
|
||||
{{/if}}
|
||||
{{:input type="radio-btn" name="classify" value="ignored" label="Immobilisation à ignorer" help="L'écriture n'apparaitra plus dans la liste des immobilisations" default=$choix_defaut}}
|
||||
{{:input type="radio-btn" name="classify" value="managed" label="Immobilisation à amortir" help="Cette immobilisation sera classée parmi les immobilisations amortissables" default=$choix_defaut}}
|
||||
{{:input type="radio-btn" name="classify" value="archived" label="Immobilisation sortie du bilan" help="Cette immobilisation sera classée parmi les immobilisations sorties du bilan" default=$choix_defaut}}
|
||||
{{:input type="radio-btn" name="classify" value="ignored" label="Immobilisation à ignorer" help="Cette écriture n'apparaitra plus dans la liste des immobilisations" default=$choix_defaut}}
|
||||
</dl>
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="masquable">
|
||||
<legend>Informations</legend>
|
||||
<dl>
|
||||
{{:input type="date" name="date_achat" label="Date d'acquisition" default=$date_achat_defaut help="à modifier si nécessaire"}}
|
||||
{{:input type="text" name="libelle" label="Libellé" default=$immo_label help="à modifier si nécessaire"}}
|
||||
{{:input type="money" name="montant" label="Montant de l'immobilisation" required=true default=$reste help="à modifier si différent du montant de l'écriture d'immobilisation"}}
|
||||
{{:input type="number" name="duree" label="Durée d'amortissement" required=true min=1 suffix="année(s)"}}
|
||||
{{:input type="date" name="date_mes" label="Date de mise en service" default=$date_mes_defaut help="à modifier si différente de la date d'acquisition"}}
|
||||
{{:input type="money" name="montant" label="Montant de l'immobilisation" required=true default=$reste help="à modifier si différent du montant de l'écriture d'immobilisation"}}
|
||||
{{:input type="date" name="date_achat" label="Date d'acquisition" help="à renseigner uniquement si différente de la date de l'écriture d'immobilisation"}}
|
||||
{{:input type="date" name="date_mes" label="Date de mise en service" help="à renseigner uniquement si différente de la date d'acquisition"}}
|
||||
{{:input type="text" name="libelle" label="Libellé" help="à renseigner uniquement si différent du libellé de l'écriture d'immobilisation"}}
|
||||
</dl>
|
||||
</fieldset>
|
||||
|
||||
|
|
@ -236,6 +220,7 @@ function toggleInputs(event) {
|
|||
const managed = classement_immo.querySelector('input[type=radio][value=managed]');
|
||||
if (managed.checked) {
|
||||
g.toggle('.masquable', true);
|
||||
document.getElementById('f_duree').focus();
|
||||
} else {
|
||||
g.toggle('.masquable', false);
|
||||
}
|
||||
|
|
@ -247,9 +232,6 @@ toggleInputs();
|
|||
radios.forEach(radio => {
|
||||
radio.addEventListener("change", toggleInputs);
|
||||
});
|
||||
document.getElementById('f_date_achat').addEventListener("change", (e) => {
|
||||
document.getElementById('f_date_mes').value = document.getElementById('f_date_achat').value;
|
||||
});
|
||||
})();
|
||||
|
||||
</script>
|
||||
|
|
|
|||
163
aide.html
Normal file
163
aide.html
Normal file
|
|
@ -0,0 +1,163 @@
|
|||
{{* -*- brindille -*- *}}
|
||||
|
||||
{{:admin_header title="Aide" custom_css="./style.css" current="module_amortization"}}
|
||||
|
||||
{{* barre de navigation *}}
|
||||
{{:include file="_nav.html" current="aide"}}
|
||||
|
||||
<p class="aide">
|
||||
Ce module gère l'amortissement linéaire des immobilisations.
|
||||
</p>
|
||||
|
||||
<h2 class="aide">Immobilisations</h2>
|
||||
Elles sont classées dans plusieurs onglets :
|
||||
|
||||
<ul class="aide">
|
||||
<li><strong>En cours</strong> : immobilisations en cours d'amortissement.</li>
|
||||
<li><strong>Terminées</strong> : immobilisations dont l'amortissement est terminé.</li>
|
||||
<li><strong>Archivées</strong> : immobilisations qui ont été sortie du bilan.</li>
|
||||
<li><strong>Autres</strong> : immobilisations pour lesquelles le module n'a pas
|
||||
d'information ou qui ont été marquées non amortissables.</li>
|
||||
</ul>
|
||||
|
||||
<h3 class="aide">Ajouter une immobilisation</h3>
|
||||
|
||||
<div class="aide">
|
||||
<p class="aide">
|
||||
Il faut renseigner les informations de l'immobilisation.
|
||||
On peut indiquer qu'il s'agit d'une immobilisation qui ne doit
|
||||
pas être amortie ; dans le cas contraire, il faut renseigner
|
||||
les différents paramètres de l'immobilisation
|
||||
</p>
|
||||
<!--
|
||||
<ul class="aide">
|
||||
<li>Date d'acquisition du bien</li>
|
||||
<li>Date d'acquisition du bien</li>
|
||||
<li>Date de mise en service du bien : uniquement si différente de la précédente</li>
|
||||
<li>Libellé de l'immobilisation</li>
|
||||
<li>Montant</li>
|
||||
<li>Durée d'amortissement en années</li>
|
||||
<li>Compte de décaissement : à choisir dans la liste</li>
|
||||
<li>Compte d'immobilisation : doit débuter par <b>20</b>, <b>21</b> ou <b>27</b></li>
|
||||
<li>Projet analytique (optionnel)</li>
|
||||
</ul>
|
||||
<p>
|
||||
Après ajout, on se retrouve sur la page d'accueil des immobilisations.
|
||||
</p>
|
||||
-->
|
||||
</div>
|
||||
|
||||
<h3 class="aide">Amortissements</h2>
|
||||
|
||||
<div class="infos">
|
||||
<p class="aide">
|
||||
Le calcul de l'amortissement se fait par la <em>méthode linéaire</em>.
|
||||
</p>
|
||||
<p class="aide">
|
||||
La date de début du calcul est par défaut la <em>date d'achat</em> ; si la
|
||||
date de mise en service est <em>postérieure</em> à la date d'achat, c'est
|
||||
celle-ci qui est prise en compte.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<h3 class="aide">Liste des amortissements</h3>
|
||||
|
||||
<div class="aide">
|
||||
On trouve ici de une à trois listes, selon la situation :
|
||||
<ul class="aide">
|
||||
<li>
|
||||
<b>Amortissements enregistrés</b>
|
||||
<p>
|
||||
Ce sont des écritures d'amortissement déjà
|
||||
enregistrées et liées à l'écriture de
|
||||
l'immobilisation courante.
|
||||
</p>
|
||||
</li>
|
||||
<li>
|
||||
<b>Amortissements futurs</b>
|
||||
<p>
|
||||
Ce sont les écritures amortissement de
|
||||
l'immobilisation courante qui n'ont pas encore été
|
||||
enregistrées ; seuls les amortissements d'un
|
||||
exercice ouvert peuvent être enregistrés ; les
|
||||
autres sont présents pour information et pourront
|
||||
être enregistrés quand l'exercice correspondant
|
||||
aura été ouvert.
|
||||
</p>
|
||||
</li>
|
||||
<li>
|
||||
<b>Autres amortissement non rattachés</b>
|
||||
<p>
|
||||
Ce sont des écritures passées sur un compte
|
||||
d'amortissement (<b>28xx</b>) qui ne sont
|
||||
associées à aucune écriture d'immobilisation ; en
|
||||
cliquant le bouton « Attacher », on peut rattacher
|
||||
l'écriture d'amortissement sélectionnée à
|
||||
l'immobilisation courante.
|
||||
</p>
|
||||
<p>
|
||||
Si on a rattaché par erreur une écriture
|
||||
d'amortissement à une immobilisation, le bouton «
|
||||
Détacher » en face de l'écriture permettra de
|
||||
défaire l'opération.
|
||||
</p>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<h3 class="aide">Créer une écriture d'amortissement</h3>
|
||||
|
||||
<div class="aide">
|
||||
<p class=aide">
|
||||
Il faut renseigner les différents paramètres de l'amortissement :
|
||||
<ul class="aide">
|
||||
<li>Date ; par défaut, il s'agit de la date de fin d'exercice</li>
|
||||
<li>Libellé : déterminé à partir du libellé de l'immobilisation< ; il peut être modifié/li>
|
||||
<li>Montant : sa valeur est calculée par le module ; elle peut être modifiée</li>
|
||||
<li>
|
||||
Compte de débit : à choisir dans la liste ; par défaut
|
||||
c'est le compte <em>6811 : Dotation aux amortissements
|
||||
des immobilisations</em>
|
||||
</li>
|
||||
<li>
|
||||
Compte d'amortissement : à choisir dans la liste ; par
|
||||
défaut c'est le compte formé en intercalant un 8 après
|
||||
le 2 initial du compte d'immobilisation (exemple :
|
||||
2183 => 28183)
|
||||
</li>
|
||||
</ul>
|
||||
<!--
|
||||
<p class="aide">
|
||||
Après enregistrement, on se retrouve sur la page des amortissements
|
||||
</p>
|
||||
-->
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<h2 class="aide">Remarques</h2>
|
||||
|
||||
<ul class="aide">
|
||||
<li>
|
||||
Les écritures d'immobilisation et d'amortissement créées en
|
||||
dehors du module ne peuvent être associées automatiquement que
|
||||
si leurs écritures ont été liées ; dans le cas contraire, il
|
||||
faudra renseigner manuellement les infos de l'immobilisation.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p class="aide">
|
||||
Dans le deuxième cas, il faut cliquer sur le bouton « Ajouter
|
||||
infos » puis :
|
||||
<ul class="aide">
|
||||
<li>soit indiquer que l'immobilisation ne doit pas être amortie</li>
|
||||
<li>soit fournir la date de mise en service du bien (si différente de la date d'acquisition) ainsi
|
||||
que la durée en années de l'amortissement</li>
|
||||
</ul>
|
||||
</p>
|
||||
<p class="aide">
|
||||
Tant qu'une immobilisation ne possède pas d'amortissement, il est
|
||||
possible de modifier ses informations à l'aide du bouton «
|
||||
Modifier infos ».
|
||||
</p>
|
||||
|
||||
|
|
@ -12,28 +12,10 @@
|
|||
{{:error message=$message}}
|
||||
{{/if}}
|
||||
|
||||
{{*
|
||||
Supprimer l'association entre une écriture d'immobilisation et
|
||||
une écriture au crédit du compte d'immobilisation
|
||||
*}}
|
||||
{{#form on="detach_credit"}}
|
||||
{{:include file="_detach_credit.html" immo_doc_id=$_POST.immo_doc_id credit_line_id=$_POST.detach_credit}}
|
||||
{{:redirect to="?immo_doc_id=%s&ok=1&msg=detach_avoir"|args:$_POST.immo_doc_id}}
|
||||
{{/form}}
|
||||
|
||||
{{*
|
||||
Supprimer l'association entre une écriture d'amortissement et
|
||||
une écriture d'immobilisation
|
||||
*}}
|
||||
{{#form on="detach_amort"}}
|
||||
{{:include file="_detach_amort.html" immo_doc_id=$_POST.immo_doc_id amort_line_id=$_POST.detach_amort}}
|
||||
{{:redirect to="?immo_doc_id=%s&ok=1&msg=detach_amort"|args:$_POST.immo_doc_id:}}
|
||||
{{/form}}
|
||||
|
||||
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$ligne_immo.trans_id}}
|
||||
{{:assign date_debut=$info_immo.date_mes|or:$info_immo.date_achat|or:$ligne_immo.date_achat}}
|
||||
{{:assign label_immo=$info_immo.label|or:$ligne_immo.trans_label}}
|
||||
{{if $label_immo|strpos:$ligne_immo.line_label === false}}
|
||||
{{if $ligne_immo.line_label != null && $ligne_immo.line_label != $label_immo}}
|
||||
{{:assign label_immo=$label_immo|cat:" — "|cat:$ligne_immo.line_label}}
|
||||
{{/if}}
|
||||
{{if $info_immo.amount != null}}
|
||||
|
|
@ -57,30 +39,27 @@
|
|||
{{* lister les amortissements non attachés à une immo *}}
|
||||
{{:assign account_filter="28%"|quote_sql}}
|
||||
{{:assign filter_condition="account.code LIKE "|cat:$account_filter}}
|
||||
|
||||
{{:assign date_amort=$date_debut|quote_sql}}
|
||||
{{:assign date_condition="trans.date >= "|cat:$date_amort}}
|
||||
{{:assign condition=$date_condition|cat:" AND "|cat:$filter_condition}}
|
||||
{{:include file="./_get_free_amort.html" condition=$condition keep="free_amort_lines"}}
|
||||
{{:include file="./_get_free_amort.html" filter_condition=$filter_condition keep="free_amort_lines"}}
|
||||
{{/if}}
|
||||
|
||||
{{:admin_header title="Détails de l'immobilisation" custom_css="./style.css" current="module_amortization"}}
|
||||
{{:admin_header title="Liste des amortissements" custom_css="./style.css" current="module_amortization"}}
|
||||
|
||||
{{* barre de navigation *}}
|
||||
{{if $_GET.type_immo == "amortized" && $valeur_residuelle == 0}}
|
||||
{{:assign current="amortized"}}
|
||||
{{if $_GET.type_immo == "amortized" || $valeur_residuelle== 0 }}
|
||||
{{:assign subcurrent="amortized"}}
|
||||
{{elseif $_GET.type_immo == "archived"}}
|
||||
{{:assign current="archived"}}
|
||||
{{elseif $_GET.type_immo == null || $_GET.type_immo == "managed" || $valeur_residuelle > 0}}
|
||||
{{:assign current="managed"}}
|
||||
{{:assign subcurrent="archived"}}
|
||||
{{elseif $_GET.type_immo == null || $_GET.type_immo == "managed"}}
|
||||
{{:assign subcurrent="managed"}}
|
||||
{{else}}
|
||||
{{:assign current="other"}}
|
||||
{{:assign subcurrent="other"}}
|
||||
{{/if}}
|
||||
|
||||
{{:include
|
||||
file="_nav.html"
|
||||
current="%s"|args:$current
|
||||
subcurrent="details"
|
||||
current="index"
|
||||
subcurrent="%s"|args:$subcurrent
|
||||
subsubcurrent="amortization"
|
||||
type_immo=$_GET.type_immo
|
||||
autres_amort=$free_amort_lines
|
||||
}}
|
||||
|
|
@ -157,37 +136,27 @@
|
|||
<dt>Montant à amortir</dt>
|
||||
<dd class="money strong">{{"%f"|math:$solde|money_currency_html:false|raw}}</dd>
|
||||
{{/if}}
|
||||
{{if $valeur_residuelle > 0}}
|
||||
<dt>Montant des amortissements</dt>
|
||||
<dd>{{$total_amort|money_currency_html:false|raw}}</dd>
|
||||
<dt>Valeur nette résiduelle</dt>
|
||||
<dd>{{$valeur_residuelle|money_currency_html:false|raw}}</dd>
|
||||
{{if $info_immo.duration != null && $valeur_residuelle > 0}}
|
||||
{{:assign annuite="%f/%d"|math:$solde:$info_immo.duration}}
|
||||
<dt>Annuité estimée</dt>
|
||||
<dd>{{"min(%d, %d)"|math:$valeur_residuelle:$annuite|money_currency_html:false|raw}}
|
||||
{{if $annuite <= $valeur_residuelle}}
|
||||
<span class="help"> pour un exercice de 365 jours</span>
|
||||
{{/if}}
|
||||
</dd>
|
||||
{{if $info_immo.duration != null && $valeur_residuelle > 0}}
|
||||
<dt>Annuité estimée</dt>
|
||||
<dd>{{"min(%d, %f/%d)"|math:$valeur_residuelle:$solde:$info_immo.duration|money_currency_html:false|raw}}</dd>
|
||||
{{/if}}
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
{{if $valeur_residuelle > 0}}
|
||||
{{if ! $created_amort || $linked_immos != null}}
|
||||
<h3 class="ruler">Avoirs</h3>
|
||||
<h3 class="ruler">Avoirs</h3>
|
||||
<nav class="actions">
|
||||
{{if $total_amort == 0}}
|
||||
{{:linkbutton label="Attacher une écriture d'avoir" href="link_immo.html?immo_doc_id=%s"|args:$_GET.immo_doc_id shape="link" target="_dialog"}}
|
||||
{{/if}}
|
||||
{{if ! $created_amort}}
|
||||
<nav class="actions">
|
||||
{{:linkbutton label="Attacher une écriture d'avoir" href="link_immo.html?immo_doc_id=%s&filter=true"|args:$_GET.immo_doc_id shape="link" target="_dialog"}}
|
||||
</nav>
|
||||
{{/if}}
|
||||
{{elseif $linked_immos != null}}
|
||||
<h3 class="ruler">Avoirs</h3>
|
||||
{{/if}}
|
||||
</nav>
|
||||
|
||||
{{if $linked_immos != null}}
|
||||
<form method="post" action="">
|
||||
<table class="list">
|
||||
<thead>
|
||||
<th class="num">N°</th>
|
||||
|
|
@ -204,17 +173,15 @@
|
|||
<td>{{$line.date|date_short}}</td>
|
||||
<td>{{$line.label}}</td>
|
||||
<td class="money">{{"%f"|math:$line.amount|money_currency_html:false|raw}}</td>
|
||||
<td class="actions">
|
||||
{{if ! $created_amort}}
|
||||
{{:button type="submit" name="detach_credit" label="Détacher" shape="minus" value=$line.credit_line_id}}
|
||||
<td>
|
||||
{{if $total_amort == 0}}
|
||||
{{:linkbutton label="Détacher" href="detach_credit.html?immo_doc_id=%s&credit_line_id=%s"|args:$_GET.immo_doc_id:$line.credit_line_id shape="minus"}}
|
||||
{{/if}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/foreach}}
|
||||
</tbody>
|
||||
</table>
|
||||
<input type="hidden" id="immo_doc_id" name="immo_doc_id" value="{{$_GET.immo_doc_id}}">
|
||||
</form>
|
||||
{{/if}}
|
||||
|
||||
<h3 class="ruler">Amortissements</h3>
|
||||
|
|
@ -227,19 +194,16 @@
|
|||
shape="link"
|
||||
target="_dialog"}}
|
||||
{{/if}}
|
||||
{{if $valeur_residuelle > 0}}
|
||||
{{:linkbutton
|
||||
label="Enregistrer un amortissement"
|
||||
title="Enregistrer un nouvel amortissement"
|
||||
href="save_amort.html?immo_doc_id=%s"|args:$_GET.immo_doc_id target="_dialog"
|
||||
shape="plus"
|
||||
}}
|
||||
{{/if}}
|
||||
</nav>
|
||||
|
||||
{{if $linked_amort != null}}
|
||||
<section class="amortissement">
|
||||
<form method="post" action="">
|
||||
<table class="list">
|
||||
<thead>
|
||||
<tr>
|
||||
|
|
@ -272,17 +236,15 @@
|
|||
<td class="money">{{"%f"|math:$solde|money_html:false|raw}}</td>
|
||||
<td><a href="{{$compte_url}}">{{$line.account_code}}</a></td>
|
||||
<td>{{$line.account_label}}</td>
|
||||
<td class="actions">
|
||||
<td>
|
||||
{{if ! $created_amort}}
|
||||
{{:button type="submit" name="detach_amort" label="Détacher" shape="minus" value=$line.line_id}}
|
||||
{{:linkbutton label="Détacher" href="detach_amort.html?immo_doc_id=%s&amort_line_id=%s"|args:$_GET.immo_doc_id:$line.line_id shape="minus"}}
|
||||
{{/if}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/foreach}}
|
||||
</tbody>
|
||||
</table>
|
||||
<input type="hidden" id="immo_doc_id" name="immo_doc_id" value="{{$_GET.immo_doc_id}}">
|
||||
</form>
|
||||
</section>
|
||||
{{/if}}
|
||||
|
||||
|
|
@ -294,14 +256,7 @@
|
|||
{{/if}}
|
||||
|
||||
{{if $linked_amort == null}}
|
||||
<p class="block alert">Aucun amortissement enregistré pour cette
|
||||
immobilisation ; en fin d'exercice vous pouvez enregistrer un
|
||||
nouvel amortissement à l'aide du bouton « Enregistrer un
|
||||
amortissement »</p>
|
||||
{{elseif $_GET.type_immo == "managed"}}
|
||||
<p class="block alert">En fin d'exercice vous pouvez enregistrer
|
||||
un nouvel amortissement à l'aide du bouton « Enregistrer un
|
||||
amortissement »</p>
|
||||
<p class="block alert">Aucun amortissement enregistré pour cette immobilisation ; utilisez le bouton « Enregistrer un amortissement » pour enregistrer un nouvel amortissement</p>
|
||||
{{/if}}
|
||||
|
||||
{{:form_errors}}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
{{/if}}
|
||||
|
||||
{{:assign label_immo=$info_immo.label|or:$ligne_immo.trans_label}}
|
||||
{{if $label_immo|strpos:$ligne_immo.line_label === false}}
|
||||
{{if $ligne_immo.line_label != null && $ligne_immo.line_label != $label_immo}}
|
||||
{{:assign label_immo=$label_immo|cat:" — "|cat:$ligne_immo.line_label}}
|
||||
{{/if}}
|
||||
{{:assign montant_immo=$info_immo.amount|or:$ligne_immo.amount}}
|
||||
|
|
@ -93,12 +93,6 @@
|
|||
{{:error message="Le montant de l'amortissement (%s) dépasse la valeur résiduelle de l'immobilisation (%s)"|args:$ma:$vnc}}
|
||||
{{/if}}
|
||||
|
||||
{{*
|
||||
supprimer les documents qui pointent sur une ligne d'amortissement absente
|
||||
cas de la suppression manuelle d'un amortissement
|
||||
*}}
|
||||
{{:include file="_remove_orphan_docs.tpl"}}
|
||||
|
||||
{{* Lier l'écriture d'amortissement à l'écriture d'immobilisation *}}
|
||||
{{:include file="_common_attach.html" immo_doc_id=$_GET.immo_doc_id trans_id=$amort_line.trans_id}}
|
||||
|
||||
|
|
@ -120,8 +114,8 @@
|
|||
}}
|
||||
{{/load}}
|
||||
|
||||
{{* immo soldée ? *}}
|
||||
{{if $total_amort == $montant_immo && $_GET.from != "exit"}}
|
||||
{{* À VÉRIFIER immo soldée ? *}}
|
||||
{{if $total_amort == $montant_immo}}
|
||||
{{:assign status="amortized"}}
|
||||
{{:save
|
||||
key=$info_immo.key
|
||||
|
|
@ -130,7 +124,7 @@
|
|||
{{/if}}
|
||||
|
||||
{{if $_GET.from == "exit"}}
|
||||
{{:redirect force="exit_step2.html?immo_doc_id=%s&from=exit&ok=1&msg=attach_amort"|args:$_GET.immo_doc_id}}
|
||||
{{:redirect force="exit_step2.html?immo_doc_id=%s&ok=1&msg=attach_amort"|args:$_GET.immo_doc_id}}
|
||||
{{else}}
|
||||
{{:redirect force="amortization.html?immo_doc_id=%s&type_immo=%s&ok=1&msg=attach_amort"|args:$_GET.immo_doc_id:$status}}
|
||||
{{/if}}
|
||||
|
|
@ -140,7 +134,7 @@
|
|||
|
||||
{{* barre de navigation *}}
|
||||
{{if ! $dialog}}
|
||||
{{:include file="_nav.html" current="managed" subcurrent="attach_amort"}}
|
||||
{{:include file="_nav.html" current="config" subcurrent="init" subsubcurrent="parameter"}}
|
||||
{{/if}}
|
||||
{{:form_errors}}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
*}}
|
||||
|
||||
{{* données de l'immobilisation *}}
|
||||
{{:include file="_get_immo_data.html" immo_doc_id=$immo_doc_id keep="info_immo, ligne_immo, message"}}
|
||||
{{:include file="_get_immo_data.html" immo_doc_id=$_GET.immo_doc_id keep="info_immo, ligne_immo, message"}}
|
||||
{{if $message != null}}
|
||||
{{:error message=$message}}
|
||||
{{/if}}
|
||||
|
|
@ -18,7 +18,7 @@
|
|||
id_transaction
|
||||
FROM acc_transactions_lines
|
||||
WHERE id = :line_id;
|
||||
:line_id = $cession_line_id|intval
|
||||
:line_id = $_GET.cession_line_id|intval
|
||||
}}
|
||||
{{:assign cession_id=$id_transaction}}
|
||||
{{else}}
|
||||
|
|
@ -26,12 +26,14 @@
|
|||
{{/select}}
|
||||
|
||||
{{* Lier l'écriture de cession à l'écriture d'immobilisation *}}
|
||||
{{:include file="_common_attach.html" immo_doc_id=$immo_doc_id trans_id=$cession_id}}
|
||||
{{:include file="_common_attach.html" immo_doc_id=$_GET.immo_doc_id trans_id=$cession_id}}
|
||||
|
||||
{{* enregistrer la liaison de l'écriture de cession *}}
|
||||
{{:save
|
||||
key=""|uuid
|
||||
type="cession_link"
|
||||
immo_doc_id=$info_immo.id
|
||||
cession_line_id=$cession_line_id|intval
|
||||
cession_line_id=$_GET.cession_line_id|intval
|
||||
}}
|
||||
|
||||
{{:redirect force="exit_step3.html?immo_doc_id=%s&ok=1&msg=attach_cession"|args:$_GET.immo_doc_id}}
|
||||
|
|
@ -14,22 +14,13 @@
|
|||
{{/if}}
|
||||
|
||||
{{:assign label_immo=$info_immo.label|or:$ligne_immo.trans_label}}
|
||||
{{if $label_immo|strpos:$ligne_immo.line_label === false }}
|
||||
{{if $ligne_immo.line_label != null && $ligne_immo.line_label != $label_immo}}
|
||||
{{:assign label_immo=$label_immo|cat:" — "|cat:$ligne_immo.line_label}}
|
||||
{{/if}}
|
||||
|
||||
{{if $info_immo.amount != null}}
|
||||
{{:assign var="ligne_immo.amount" value=$info_immo.amount}}
|
||||
{{/if}}
|
||||
|
||||
{{* déduire le montant des écritures liées à l'immo courante au crédit du même compte *}}
|
||||
{{:include file="_get_credit_lines.html" immo_doc_id=$_GET.immo_doc_id keep="total_credits"}}
|
||||
{{:assign valeur_residuelle="%d-%d"|math:$ligne_immo.amount:$total_credits}}
|
||||
|
||||
{{* lister les amortissements liés à l'immobilisation *}}
|
||||
{{:include file="./_get_amort_lines.html" immo_doc_id=$_GET.immo_doc_id keep="linked_amort, total_amort, created_amort"}}
|
||||
{{:assign valeur_residuelle="%d-%d"|math:$valeur_residuelle:$total_amort}}
|
||||
|
||||
{{:assign solde_immo="%d-%d"|math:$ligne_immo.amount:$total_credits}}
|
||||
|
||||
{{* chercher l'écriture au crédit du compte d'immobilisation *}}
|
||||
{{#select
|
||||
|
|
@ -71,14 +62,11 @@
|
|||
{{/if}}
|
||||
{{else}}
|
||||
{{:assign montant_credit=$_POST.montant|money_int}}
|
||||
{{* vérifier que le montant saisi est inférieur au solde de l'écriture d'immobilisation *}}
|
||||
{{if $montant_credit > $solde_immo}}
|
||||
{{:assign solde_nb="%f"|math:$solde_immo|money_currency:false}}
|
||||
{{:error message="Le montant de l'avoir ne peut être supérieur au montant de l'immobilisation (%s)"|args:$solde_nb}}
|
||||
{{/if}}
|
||||
|
||||
{{* vérifier que le montant saisi est inférieur à la valeur nette de l'écriture d'immobilisation *}}
|
||||
{{if $montant_credit > $valeur_residuelle}}
|
||||
{{:assign solde_nb="%f"|math:$valeur_residuelle|money_currency:false}}
|
||||
{{:error message="Le montant de l'avoir ne peut être supérieur à la valeur nette de l'immobilisation (%s)"|args:$solde_nb}}
|
||||
{{/if}}
|
||||
|
||||
{{* vérifier que le montant saisi est inférieur au reste de l'écriture de crédit *}}
|
||||
{{if $montant_credit > $reste}}
|
||||
{{:assign reste_nb="%f"|math:$reste|money_currency:false}}
|
||||
|
|
@ -89,32 +77,47 @@
|
|||
{{else}}
|
||||
{{:assign saved_credit=$montant_credit}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
{{* Lier l'écriture de crédit à l'écriture d'immobilisation *}}
|
||||
{{:include file="_common_attach.html" immo_doc_id=$_GET.immo_doc_id trans_id=$credit_line.trans_id}}
|
||||
|
||||
{{* enregistrer la liaison des lignes d'immo *}}
|
||||
{{:save
|
||||
{{*
|
||||
TODO ? vérifier le succès avant d'enregistrer le doc ?
|
||||
*}}
|
||||
|
||||
{{* enregistrer la liaison des lignes d'immo *}}
|
||||
{{:save
|
||||
key=""|uuid
|
||||
type="credit_link"
|
||||
immo_doc_id=$_GET.immo_doc_id|intval
|
||||
credit_line_id=$_GET.credit_line_id|intval
|
||||
amount=$saved_credit
|
||||
}}
|
||||
}}
|
||||
|
||||
{{if $_GET.from == "exit"}}
|
||||
{{:redirect force="exit_step1.html?immo_doc_id=%s&from=%s&ok=1&msg=attach_avoir"|args:$_GET.immo_doc_id:$_GET.from}}
|
||||
{{else}}
|
||||
{{*
|
||||
{{if $montant_credit == $solde_immo}}
|
||||
{{:save
|
||||
id=$_GET.immo_doc_id
|
||||
status="archived"
|
||||
}}
|
||||
{{/if}}
|
||||
*}}
|
||||
|
||||
{{if $_GET.from == "exit"}}
|
||||
{{:redirect force="exit_step1.html?immo_doc_id=%s&ok=1&msg=attach_avoir"|args:$_GET.immo_doc_id}}
|
||||
{{else}}
|
||||
{{:redirect force="amortization.html?immo_doc_id=%s&ok=1&msg=attach_avoir"|args:$_GET.immo_doc_id}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{/form}}
|
||||
|
||||
{{:admin_header title="Écritures au crédit du compte d'immobilisation" custom_css="./style.css" current="module_amortization"}}
|
||||
{{if ! $dialog}}
|
||||
{{:include
|
||||
file="_nav.html"
|
||||
current="managed"
|
||||
subcurrent="attach_credit"
|
||||
current="config"
|
||||
subcurrent="other"
|
||||
subsubcurrent="immo"
|
||||
type_immo="other"
|
||||
}}
|
||||
{{/if}}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
*}}
|
||||
|
||||
{{* données de l'immobilisation *}}
|
||||
{{:include file="_get_immo_data.html" immo_doc_id=$immo_doc_id keep="info_immo, ligne_immo, message"}}
|
||||
{{:include file="_get_immo_data.html" immo_doc_id=$_GET.immo_doc_id keep="info_immo, ligne_immo, message"}}
|
||||
{{if $message != null}}
|
||||
{{:error message=$message}}
|
||||
{{/if}}
|
||||
|
|
@ -18,7 +18,7 @@
|
|||
id_transaction
|
||||
FROM acc_transactions_lines
|
||||
WHERE id = :line_id;
|
||||
:line_id = $exit_line_id|intval
|
||||
:line_id = $_GET.exit_line_id|intval
|
||||
}}
|
||||
{{:assign rebut_id=$id_transaction}}
|
||||
{{else}}
|
||||
|
|
@ -26,12 +26,14 @@
|
|||
{{/select}}
|
||||
|
||||
{{* Lier l'écriture de sortie à l'écriture d'immobilisation *}}
|
||||
{{:include file="_common_attach.html" immo_doc_id=$immo_doc_id trans_id=$rebut_id}}
|
||||
{{:include file="_common_attach.html" immo_doc_id=$_GET.immo_doc_id trans_id=$rebut_id}}
|
||||
|
||||
{{* enregistrer la liaison de l'écriture de sortie *}}
|
||||
{{:save
|
||||
key=""|uuid
|
||||
type="exit_link"
|
||||
immo_doc_id=$info_immo.id
|
||||
exit_line_id=$exit_line_id|intval
|
||||
exit_line_id=$_GET.exit_line_id|intval
|
||||
}}
|
||||
|
||||
{{:redirect to="exit_step4.html?immo_doc_id=%s&ok=1&msg=attach_exit"|args:$_GET.immo_doc_id}}
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
{{/if}}
|
||||
|
||||
{{:assign label_immo=$info_immo.label|or:$ligne_immo.trans_label}}
|
||||
{{if $label_immo|strpos:$ligne_immo.line_label === false}}
|
||||
{{if $ligne_immo.line_label != null && $ligne_immo.line_label != $label_immo}}
|
||||
{{:assign label_immo=$label_immo|cat:" — "|cat:$ligne_immo.line_label}}
|
||||
{{/if}}
|
||||
|
||||
|
|
@ -71,7 +71,7 @@
|
|||
{{:assign var="open_years.%d"|args:$id value=$label|cat:" (du "|cat:$debut|cat:" au "|cat:$fin|cat:")"}}
|
||||
{{else}}
|
||||
{{:assign debut=$date_debut|date_short}}
|
||||
{{:error message="Aucun exercice ouvert pour enregistrer la sortie de bilan à partir du %s"|args:$debut}}
|
||||
{{:error message="Aucun exercice ouvert pour enregistrer un amortissement à partir du %s"|args:$debut}}
|
||||
{{/years}}
|
||||
{{if $years|count == 1}}
|
||||
{{:assign default_year=$years.0.id}}
|
||||
|
|
@ -130,12 +130,12 @@
|
|||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
{{:redirect to="compute_exit_data.html?immo_doc_id=%s&year=%s&date_debut=%s&exit_date=%s"|args:$_GET.immo_doc_id:$selected_year:$ts_debut:$ts_exit}}
|
||||
{{:redirect to="compute_exit_data.html?immo_doc_id=%s&amort_amount=%s&year=%s&date_debut=%s&exit_date=%s"|args:$_GET.immo_doc_id:$total_amort:$selected_year:$ts_debut:$ts_exit}}
|
||||
{{/form}}
|
||||
|
||||
{{:admin_header title="Sortie de bilan" custom_css="./style.css" current="module_amortization"}}
|
||||
{{if ! $dialog}}
|
||||
{{:include file="_nav.html" current="%s"|args:$_GET.type_immo subcurrent="balance_exit"}}
|
||||
{{:include file="_nav.html" current="index" subcurrent="%s"|args:$_GET.type_immo subsubcurrent="balance_exit"}}
|
||||
{{/if}}
|
||||
{{:form_errors}}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,13 +4,12 @@
|
|||
Calculer les valeurs de la sortie et saisir le montant de la cession (optionnel)
|
||||
paramètres :
|
||||
@param immo_doc_id : id du doc associé à l'immo
|
||||
@param amort_amount : montant des amortissements
|
||||
@param year : exercice de la date de sortie de l'immobilisation
|
||||
@param date_debut : date de début de la période d'amortissement complémentaire
|
||||
@param exit_date : date de sortie de l'immobilisation
|
||||
*}}
|
||||
|
||||
{{* TODO boutons de navigation avant-arrière*}}
|
||||
|
||||
{{* TODO *}}
|
||||
{{* données de l'immobilisation *}}
|
||||
{{:include file="_get_immo_data.html" immo_doc_id=$_GET.immo_doc_id|intval keep="info_immo, ligne_immo, message"}}
|
||||
{{if $message != null}}
|
||||
|
|
@ -18,7 +17,7 @@
|
|||
{{/if}}
|
||||
|
||||
{{:assign label_immo=$info_immo.label|or:$ligne_immo.trans_label}}
|
||||
{{if $label_immo|strpos:$ligne_immo.line_label === false}}
|
||||
{{if $ligne_immo.line_label != null && $ligne_immo.line_label != $label_immo}}
|
||||
{{:assign label_immo=$label_immo|cat:" — "|cat:$ligne_immo.line_label}}
|
||||
{{/if}}
|
||||
|
||||
|
|
@ -34,10 +33,7 @@
|
|||
{{* déduire le montant des écritures liées à l'immo courante au crédit du même compte *}}
|
||||
{{:include file="_get_credit_lines.html" immo_doc_id=$_GET.immo_doc_id keep="total_credits"}}
|
||||
{{:assign var="ligne_immo.amount" value="%d-%d"|math:$ligne_immo.amount:$total_credits}}
|
||||
|
||||
{{* lister les amortissements liés à l'immobilisation *}}
|
||||
{{:include file="./_get_amort_lines.html" immo_doc_id=$_GET.immo_doc_id keep="linked_amort, total_amort"}}
|
||||
{{:assign valeur_nette="%f-%f"|math:$ligne_immo.amount:$total_amort}}
|
||||
{{:assign valeur_nette="%f-%f"|math:$ligne_immo.amount:$_GET.amort_amount}}
|
||||
|
||||
{{:assign amort_comp=0}} {{* amortissement complémentaire jqà date sortie *}}
|
||||
{{if $valeur_nette > 0}}
|
||||
|
|
@ -55,19 +51,14 @@
|
|||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
{{:redirect to="write_exit.html?immo_doc_id=%s&year=%s&date_debut=%s&exit_date=%s&cession=%s"|args:$_GET.immo_doc_id:$_GET.year:$_GET.date_debut:$_GET.exit_date:$_POST.montant_cession}}
|
||||
{{:redirect to="write_exit.html?immo_doc_id=%s&amort_amount=%s&year=%s&date_debut=%s&exit_date=%s&cession=%s"|args:$_GET.immo_doc_id:$_GET.amort_amount:$_GET.year:$_GET.date_debut:$_GET.exit_date:$_POST.montant_cession}}
|
||||
|
||||
{{/form}}
|
||||
{{:admin_header title="Sortie du bilan" custom_css="./style.css" current="module_amortization"}}
|
||||
|
||||
{{* barre de navigation *}}
|
||||
{{if ! $dialog}}
|
||||
{{if $valeur_nette > 0}}
|
||||
{{:assign type_immo="managed"}}
|
||||
{{else}}
|
||||
{{:assign type_immo="amortized"}}
|
||||
{{/if}}
|
||||
{{:include file="_nav.html" current="%s"|args:$type_immo subcurrent="balance_exit"}}
|
||||
{{:include file="_nav.html" current="index" subcurrent="balance_exit"}}
|
||||
{{/if}}
|
||||
|
||||
{{:form_errors}}
|
||||
|
|
@ -89,7 +80,7 @@
|
|||
<dt>Durée de l'amortissement</dt>
|
||||
<dd id="duree_amort" class="num">{{$info_immo.duration}} ans</dd>
|
||||
<dt>Montant des amortissements</dt>
|
||||
<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>
|
||||
<dd id="montant_amort" class="money">{{$_GET.amort_amount|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>
|
||||
<dt>Date de sortie</dt>
|
||||
|
|
@ -98,7 +89,7 @@
|
|||
<dt>Amortissement complémentaire</dt>
|
||||
<dd class="money">{{$amort_comp|money_currency_html:false|raw}} <span class="help">(jusqu'à la date de sortie)</span></dd>
|
||||
<dt>Total des amortissements</dt>
|
||||
<dd class="money">{{"%f+%f"|math:$total_amort:$amort_comp|money_currency_html:false|raw}} <span class="help">(à la date de sortie)</span></dd>
|
||||
<dd class="money">{{"%f+%f"|math:$_GET.amort_amount:$amort_comp|money_currency_html:false|raw}} <span class="help">(à la date de sortie)</span></dd>
|
||||
<dt>Valeur nette résiduelle</dt>
|
||||
<dd class="money">{{"%f-%f"|math:$valeur_nette:$amort_comp|money_currency_html:false|raw}} <span class="help">(à la date de sortie)</span></dd>
|
||||
{{/if}}
|
||||
|
|
|
|||
12
config.html
12
config.html
|
|
@ -46,7 +46,6 @@
|
|||
{{/form}}
|
||||
|
||||
{{:admin_header title="Configuration" custom_css="./style.css" current="module_amortization"}}
|
||||
|
||||
{{:include file="_nav.html" current="config"}}
|
||||
{{if $_GET.ok == 1}}
|
||||
<p class="block confirm">Configuration enregistrée.</p>
|
||||
|
|
@ -129,7 +128,6 @@
|
|||
{{/if}}
|
||||
|
||||
<form method="post" action="">
|
||||
|
||||
<h3>Comptes d'immobilisation amortissables</h3>
|
||||
<p class="help">
|
||||
Les immobilisations amortissables sont cherchées dans les comptes sélectionnés et leurs sous-comptes.
|
||||
|
|
@ -139,7 +137,7 @@
|
|||
<thead>
|
||||
<tr>
|
||||
<th>Compte</th>
|
||||
<th class="actions"></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
|
@ -156,14 +154,13 @@
|
|||
}}
|
||||
</td>
|
||||
<td class="actions">
|
||||
{{if ! $code|in:$config_defaut.prefixes}}
|
||||
{{:button
|
||||
label="Enlever"
|
||||
title="Enlever une ligne"
|
||||
shape="minus"
|
||||
min="1"
|
||||
name="remove_line"
|
||||
}}
|
||||
{{/if}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/foreach}}
|
||||
|
|
@ -185,12 +182,11 @@
|
|||
<thead>
|
||||
<tr>
|
||||
<th>Compte</th>
|
||||
<th class="actions"></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
{{:assign unfinished_lines=$config_defaut.unfinished|map:implode:"-"|implode:","}}
|
||||
{{#foreach from=$unfinished_accounts key=code item=elem}}
|
||||
<tr>
|
||||
<td>
|
||||
|
|
@ -204,7 +200,6 @@
|
|||
}}
|
||||
</td>
|
||||
<td class="actions">
|
||||
{{if $unfinished_lines|strpos:$code === false}}
|
||||
{{:button
|
||||
label="Enlever"
|
||||
title="Enlever une ligne"
|
||||
|
|
@ -212,7 +207,6 @@
|
|||
min="1"
|
||||
name="remove_line"
|
||||
}}
|
||||
{{/if}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/foreach}}
|
||||
|
|
|
|||
32
detach_amort.html
Normal file
32
detach_amort.html
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
{{* -*- brindille -*- *}}
|
||||
|
||||
{{*
|
||||
Supprimer l'association entre une écriture d'amortissement et
|
||||
une écriture d'immobilisation
|
||||
@param immo_doc_id : id du doc associé à l'immo
|
||||
@param amort_line_id : id de la ligne d'amortissement
|
||||
*}}
|
||||
|
||||
{{:include file="_common_detach.html" immo_doc_id=$_GET.immo_doc_id line_id=$_GET.amort_line_id}}
|
||||
|
||||
{{* supprimer le doc de liaison entre les lignes *}}
|
||||
{{#load type="amort_link"
|
||||
where="$$.immo_doc_id = :immo_doc_id AND $$.amort_line_id = :amort_line_id"
|
||||
:immo_doc_id=$_GET.immo_doc_id|intval
|
||||
:amort_line_id = $_GET.amort_line_id|intval
|
||||
}}
|
||||
{{:delete id=$id}}
|
||||
{{/load}}
|
||||
|
||||
{{* marquer immo non soldée *}}
|
||||
{{* TODO : À VÉRIFIER *}}
|
||||
{{:save
|
||||
key=$info_immo.key
|
||||
status="managed"
|
||||
}}
|
||||
|
||||
{{if $_GET.from == "exit"}}
|
||||
{{:redirect force="exit_step2.html?immo_doc_id=%s&ok=1&msg=detach_amort"|args:$_GET.immo_doc_id}}
|
||||
{{else}}
|
||||
{{:redirect force="amortization.html?immo_doc_id=%s&ok=1&msg=detach_amort"|args:$_GET.immo_doc_id:}}
|
||||
{{/if}}
|
||||
|
|
@ -7,13 +7,15 @@
|
|||
@param cession_line_id : id de la ligne de cession
|
||||
*}}
|
||||
|
||||
{{:include file="_common_detach.html" immo_doc_id=$immo_doc_id line_id=$cession_line_id}}
|
||||
{{:include file="_common_detach.html" immo_doc_id=$_GET.immo_doc_id line_id=$_GET.cession_line_id}}
|
||||
|
||||
{{* supprimer le doc de liaison entre les lignes *}}
|
||||
{{#load type="cession_link"
|
||||
where="$$.immo_doc_id = :immo_doc_id AND $$.cession_line_id = :cession_line_id"
|
||||
:immo_doc_id=$immo_doc_id|intval
|
||||
:cession_line_id = $cession_line_id|intval
|
||||
:immo_doc_id=$_GET.immo_doc_id|intval
|
||||
:cession_line_id = $_GET.cession_line_id|intval
|
||||
}}
|
||||
{{:delete id=$id}}
|
||||
{{/load}}
|
||||
|
||||
{{:redirect to="exit_step3.html?immo_doc_id=%s&ok=1&msg=detach_cession"|args:$_GET.immo_doc_id}}
|
||||
|
|
@ -7,13 +7,19 @@
|
|||
@param credit_line_id : id de la ligne de crédit
|
||||
*}}
|
||||
|
||||
{{:include file="_common_detach.html" immo_doc_id=$immo_doc_id line_id=$credit_line_id}}
|
||||
{{:include file="_common_detach.html" immo_doc_id=$_GET.immo_doc_id line_id=$_GET.credit_line_id}}
|
||||
|
||||
{{* 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=$immo_doc_id|intval
|
||||
:credit_line_id = $credit_line_id|intval
|
||||
:immo_doc_id=$_GET.immo_doc_id|intval
|
||||
:credit_line_id = $_GET.credit_line_id|intval
|
||||
}}
|
||||
{{:delete id=$id}}
|
||||
{{/load}}
|
||||
|
||||
{{if $_GET.from == "exit"}}
|
||||
{{:redirect force="exit_step1.html?immo_doc_id=%s&ok=1&msg=detach_avoir"|args:$_GET.immo_doc_id}}
|
||||
{{else}}
|
||||
{{:redirect force="amortization.html?immo_doc_id=%s&ok=1&msg=detach_avoir"|args:$_GET.immo_doc_id}}
|
||||
{{/if}}
|
||||
|
|
@ -7,13 +7,15 @@
|
|||
@param exit_line_id : id de la ligne de sortie de bilan
|
||||
*}}
|
||||
|
||||
{{:include file="_common_detach.html" immo_doc_id=$immo_doc_id line_id=$exit_line_id}}
|
||||
{{:include file="_common_detach.html" immo_doc_id=$_GET.immo_doc_id line_id=$_GET.exit_line_id}}
|
||||
|
||||
{{* supprimer le doc de liaison entre les lignes *}}
|
||||
{{#load type="exit_link"
|
||||
where="$$.immo_doc_id = :immo_doc_id AND $$.exit_line_id = :exit_line_id"
|
||||
:immo_doc_id=$immo_doc_id|intval
|
||||
:exit_line_id = $exit_line_id|intval
|
||||
:immo_doc_id=$_GET.immo_doc_id|intval
|
||||
:exit_line_id = $_GET.exit_line_id|intval
|
||||
}}
|
||||
{{:delete id=$id}}
|
||||
{{/load}}
|
||||
|
||||
{{:redirect to="exit_step4.html?immo_doc_id=%s&ok=1&msg=detach_exit"|args:$_GET.immo_doc_id}}
|
||||
|
|
@ -12,17 +12,8 @@
|
|||
{{:error message=$message}}
|
||||
{{/if}}
|
||||
|
||||
{{*
|
||||
Supprimer l'association entre une écriture d'immobilisation et
|
||||
une écriture au crédit du compte d'immobilisation
|
||||
*}}
|
||||
{{#form on="detach_credit"}}
|
||||
{{:include file="_detach_credit.html" immo_doc_id=$_POST.immo_doc_id credit_line_id=$_POST.detach_credit}}
|
||||
{{:redirect to="?immo_doc_id=%s&from=exit&ok=1&msg=detach_avoir"|args:$_POST.immo_doc_id}}
|
||||
{{/form}}
|
||||
|
||||
{{:assign label_immo=$info_immo.label|or:$ligne_immo.trans_label}}
|
||||
{{if $label_immo|strpos:$ligne_immo.line_label === false}}
|
||||
{{if $ligne_immo.line_label != null && $ligne_immo.line_label != $label_immo}}
|
||||
{{:assign label_immo=$label_immo|cat:" — "|cat:$ligne_immo.line_label}}
|
||||
{{/if}}
|
||||
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$ligne_immo.trans_id}}
|
||||
|
|
@ -41,7 +32,6 @@
|
|||
- line.credit < ligne_immo.amount => peut-être un avoir
|
||||
- line.credit = ligne_immo.amount - avoirs => écriture de sortie du bilan
|
||||
*}}
|
||||
{{:assign account_code=$ligne_immo.account_code|cat:"%"}}
|
||||
{{#select
|
||||
trans.id as trans_id,
|
||||
trans.label as trans_label,
|
||||
|
|
@ -50,15 +40,15 @@
|
|||
line.id as credit_line_id,
|
||||
line.label as line_label,
|
||||
line.credit as amount,
|
||||
account.id as account_id,
|
||||
account.code as account_code,
|
||||
account.label as account_label
|
||||
acc.id as account_id,
|
||||
acc.code as account_code,
|
||||
acc.label as account_label
|
||||
FROM acc_transactions AS trans
|
||||
INNER JOIN acc_transactions_lines AS line ON line.id_transaction = trans.id
|
||||
INNER JOIN acc_accounts AS account ON line.id_account = account.id
|
||||
INNER JOIN acc_accounts AS acc ON line.id_account = acc.id
|
||||
LEFT JOIN module_data_amortization AS mda ON json_extract(mda.document, '$.amort_line_id') = line.id
|
||||
WHERE
|
||||
account.code LIKE :account_code
|
||||
acc.code = :acc_code
|
||||
AND line.credit > 0
|
||||
AND credit_line_id NOT IN (
|
||||
SELECT json_extract(credit_link.document, '$.credit_line_id') AS line_id FROM !table as credit_link
|
||||
|
|
@ -68,7 +58,7 @@
|
|||
WHERE json_extract(exit_link.document, '$.type') == "exit_link"
|
||||
)
|
||||
;
|
||||
:account_code=$account_code
|
||||
:acc_code=$ligne_immo.account_code
|
||||
!table =$module.table
|
||||
assign="credit_line"
|
||||
}}
|
||||
|
|
@ -85,6 +75,7 @@
|
|||
}}
|
||||
|
||||
{{* chercher des écritures d'amortissement correspondant au compte d'une immo sans doc associé *}}
|
||||
{{* TODO écritures d'amort pas entièrement affectées *}}
|
||||
{{#select
|
||||
line.id as amort_line_id,
|
||||
line.credit as amort_amount,
|
||||
|
|
@ -102,6 +93,7 @@
|
|||
WHERE
|
||||
account.code = :code_amort
|
||||
AND line.credit > 0
|
||||
AND (NOT trans.status & 16)
|
||||
AND trans.date >= :immo_date
|
||||
;
|
||||
:code_amort = $code_amort
|
||||
|
|
@ -113,7 +105,7 @@
|
|||
{{:assign keep_amort=true}}
|
||||
{{#load type="amort_link"
|
||||
where="$$.amort_line_id = :amort_line_id"
|
||||
:amort_line_id=$amort_line.amort_line_id
|
||||
:amort_line_id=$amort_line.amort_line_id|intval
|
||||
assign="amort_link"
|
||||
}}
|
||||
{{if $amort_link.amount == null || $amort_link.amount == 0}}
|
||||
|
|
@ -132,12 +124,6 @@
|
|||
|
||||
{{:admin_header title="Immobilisation sortie du bilan" custom_css="./style.css" current="module_amortization"}}
|
||||
|
||||
{{if $_GET.from == "exit"}}
|
||||
{{:assign current="other"}}
|
||||
{{else}}
|
||||
{{:assign current="archived"}}
|
||||
{{/if}}
|
||||
|
||||
{{if $_GET.ok}}
|
||||
{{if $_GET.msg|match:"attach_avoir"}}
|
||||
{{:assign msg="Écriture d'avoir attachée"}}
|
||||
|
|
@ -147,8 +133,6 @@
|
|||
<p class="block confirm">{{$msg}}</p>
|
||||
{{/if}}
|
||||
|
||||
{{:form_errors}}
|
||||
|
||||
<div class="informations">
|
||||
<dl class="describe">
|
||||
<dt>Immobilisation</dt>
|
||||
|
|
@ -156,7 +140,7 @@
|
|||
<dt>Compte d'immobilisation</dt>
|
||||
<dd>{{$ligne_immo.account_code}} — {{$ligne_immo.account_label}}</dd>
|
||||
<dt>Montant de l'immobilisation</dt>
|
||||
<dd><span class="money">{{$montant_immo|money_currency_html:false|raw}}</dd>
|
||||
<dd><span class="money">{{$ligne_immo.amount|money_html|raw}}</dd>
|
||||
{{if $total_credits > 0}}
|
||||
<dt>Montant des avoirs</dt>
|
||||
<dd class="money">{{"%f"|math:$total_credits|money_currency_html:false|raw}}</dd>
|
||||
|
|
@ -172,18 +156,8 @@
|
|||
</dl>
|
||||
</div>
|
||||
|
||||
{{if $credit_lines}}
|
||||
<nav class="actions">
|
||||
{{:linkbutton
|
||||
label="Attacher une écriture d'avoir"
|
||||
href="link_immo.html?immo_doc_id=%s&filter=true&from=%s"|args:$_GET.immo_doc_id:$_GET.from shape="link"
|
||||
target="_dialog"}}
|
||||
</nav>
|
||||
{{/if}}
|
||||
|
||||
<h3 class="ruler">Écritures d'avoir attachées à l'immobilisation</h3>
|
||||
{{if $linked_immos != null}}
|
||||
<form method="post" action="">
|
||||
<h3 class="ruler">Écritures d'avoir attachées à l'immobilisation</h3>
|
||||
<table class="list">
|
||||
<thead>
|
||||
<td class="num">N°</td>
|
||||
|
|
@ -205,15 +179,13 @@
|
|||
<td class="money">{{"%f"|math:$line.amount|money_currency_html:false|raw}}</td>
|
||||
<td><a href="{{$compte_url}}">{{$line.account_code}}</a></td>
|
||||
<td>{{$line.account_label}}</td>
|
||||
<td class="actions">
|
||||
{{:button type="submit" name="detach_credit" label="Détacher" shape="minus" value=$line.credit_line_id}}
|
||||
<td>
|
||||
{{:linkbutton label="Détacher" href="detach_credit.html?immo_doc_id=%s&credit_line_id=%s&from=exit"|args:$_GET.immo_doc_id:$line.credit_line_id shape="minus"}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/foreach}}
|
||||
</tbody>
|
||||
</table>
|
||||
<input type="hidden" id="immo_doc_id" name="immo_doc_id" value="{{$_GET.immo_doc_id}}">
|
||||
</form>
|
||||
{{elseif $credit_lines}}
|
||||
<p class="block alert">
|
||||
Vous pouvez attacher une ou plusieurs écritures d'avoir à votre immobilisation
|
||||
|
|
@ -224,7 +196,43 @@
|
|||
</p>
|
||||
{{/if}}
|
||||
|
||||
<form method="post" action="exit_step2.html?immo_doc_id={{$_GET.immo_doc_id}}&from={{$_GET.from}}">
|
||||
{{if $credit_lines}}
|
||||
<h3 class="ruler">Autres écritures au crédit du compte d'immobilisation</h3>
|
||||
<table class="list">
|
||||
<thead>
|
||||
<tr>
|
||||
<td class="num">N°</td>
|
||||
<td>Date</td>
|
||||
<td>Libellé</td>
|
||||
<td>Montant</td>
|
||||
<td>N° compte</td>
|
||||
<td>Compte</td>
|
||||
<td class="actions"></td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#foreach from=$credit_lines}}
|
||||
{{:assign credit_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$trans_id}}
|
||||
{{:assign compte_url="%s/acc/accounts/journal.php?id=%s&year=%s"|args:$admin_url:$account_id:$year}}
|
||||
<tr>
|
||||
<td class="num"><a href="{{$credit_url}}">#{{$trans_id}}</a></td>
|
||||
<td>{{$date|date_short}}</td>
|
||||
<td>{{$trans_label}}
|
||||
{{if $line_label != null && $line_label != $trans_label}} — {{$line_label}}{{/if}}
|
||||
</td>
|
||||
<td class="money">{{$amount|money_html|raw}}</td>
|
||||
<td><a href="{{$compte_url}}">{{$account_code}}</a></td>
|
||||
<td>{{$account_label}}</td>
|
||||
<td>
|
||||
{{:linkbutton label="Attacher" href="attach_credit.html?immo_doc_id=%s&credit_line_id=%s&from=exit"|args:$_GET.immo_doc_id:$credit_line_id shape="plus" target="_dialog"}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/foreach}}
|
||||
</tbody>
|
||||
</table>
|
||||
{{/if}}
|
||||
|
||||
<form method="post" action="exit_step2.html?immo_doc_id={{$_GET.immo_doc_id}}">
|
||||
<p class="submit">
|
||||
{{:button type="submit" name="proceed" label="Poursuivre" shape="right" class="main"}}
|
||||
</p>
|
||||
|
|
|
|||
|
|
@ -13,24 +13,15 @@
|
|||
{{/if}}
|
||||
|
||||
{{#form on="backward"}}
|
||||
{{:redirect to="exit_step1.html?immo_doc_id=%s&from=%s"|args:$_GET.immo_doc_id:$_GET.from}}
|
||||
{{:redirect to="exit_step1.html?immo_doc_id=%s"|args:$_GET.immo_doc_id}}
|
||||
{{/form}}
|
||||
|
||||
{{#form on="forward"}}
|
||||
{{:redirect to="exit_step3.html?immo_doc_id=%s&from=%s"|args:$_GET.immo_doc_id:$_GET.from}}
|
||||
{{/form}}
|
||||
|
||||
{{*
|
||||
Supprimer l'association entre une écriture d'amortissement et
|
||||
une écriture d'immobilisation
|
||||
*}}
|
||||
{{#form on="detach_amort"}}
|
||||
{{:include file="_detach_amort.html" immo_doc_id=$_POST.immo_doc_id amort_line_id=$_POST.detach_amort}}
|
||||
{{:redirect to="?immo_doc_id=%s&from=exit&ok=1&msg=detach_amort"|args:$_POST.immo_doc_id}}
|
||||
{{:redirect to="exit_step3.html?immo_doc_id=%s"|args:$_GET.immo_doc_id}}
|
||||
{{/form}}
|
||||
|
||||
{{:assign label_immo=$info_immo.label|or:$ligne_immo.trans_label}}
|
||||
{{if $label_immo|strpos:$ligne_immo.line_label === false}}
|
||||
{{if $ligne_immo.line_label != null && $ligne_immo.line_label != $label_immo}}
|
||||
{{:assign label_immo=$label_immo|cat:" — "|cat:$ligne_immo.line_label}}
|
||||
{{/if}}
|
||||
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$ligne_immo.trans_id}}
|
||||
|
|
@ -43,7 +34,6 @@
|
|||
|
||||
{{* lister les amortissements liés à l'immobilisation *}}
|
||||
{{:include file="./_get_amort_lines.html" immo_doc_id=$_GET.immo_doc_id keep="linked_amort, total_amort"}}
|
||||
{{:assign vnr="%d-%d"|math:$solde:$total_amort}}
|
||||
|
||||
{{* déterminer le compte d'amortissement en fonction du compte d'immobilisation *}}
|
||||
{{:include
|
||||
|
|
@ -53,6 +43,7 @@
|
|||
}}
|
||||
|
||||
{{* chercher des écritures d'amortissement correspondant au compte d'une immo sans doc associé *}}
|
||||
{{* TODO écritures d'amort pas entièrement affectées *}}
|
||||
{{#select
|
||||
line.id as amort_line_id,
|
||||
line.credit as amort_amount,
|
||||
|
|
@ -70,6 +61,7 @@
|
|||
WHERE
|
||||
account.code = :code_amort
|
||||
AND line.credit > 0
|
||||
AND (NOT trans.status & 16)
|
||||
AND trans.date >= :immo_date
|
||||
;
|
||||
:code_amort = $code_amort
|
||||
|
|
@ -99,11 +91,6 @@
|
|||
{{/select}}
|
||||
|
||||
{{:admin_header title="Immobilisation sortie du bilan" custom_css="./style.css" current="module_amortization"}}
|
||||
{{if $_GET.from == "exit"}}
|
||||
{{:assign current="other"}}
|
||||
{{else}}
|
||||
{{:assign current="archived"}}
|
||||
{{/if}}
|
||||
|
||||
{{if $_GET.ok}}
|
||||
{{if $_GET.msg|match:"attach_amort"}}
|
||||
|
|
@ -121,7 +108,7 @@
|
|||
<dt>Compte d'immobilisation</dt>
|
||||
<dd>{{$ligne_immo.account_code}} — {{$ligne_immo.account_label}}</dd>
|
||||
<dt>Montant de l'immobilisation</dt>
|
||||
<dd><span class="money">{{$montant_immo|money_currency_html:false|raw}}</dd>
|
||||
<dd><span class="money">{{$ligne_immo.amount|money_html|raw}}</dd>
|
||||
{{if $total_credits > 0}}
|
||||
<dt>Montant des avoirs</dt>
|
||||
<dd class="money">{{"%f"|math:$total_credits|money_currency_html:false|raw}}</dd>
|
||||
|
|
@ -132,23 +119,13 @@
|
|||
<dt>Montant des amortissements</dt>
|
||||
<dd>{{$total_amort|money_currency_html:false|raw}}</dd>
|
||||
<dt>Valeur nette résiduelle</dt>
|
||||
<dd>{{$vnr|money_currency_html:false|raw}}</dd>
|
||||
<dd>{{"%d-%d"|math:$solde:$total_amort|money_currency_html:false|raw}}</dd>
|
||||
{{/if}}
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
{{if $free_amort_lines && $vnr > 0}}
|
||||
<nav class="actions">
|
||||
{{:linkbutton
|
||||
label="Attacher une écriture d'amortissement"
|
||||
href="other_amortizations.html?immo_doc_id=%s&filter=true&from=%s"|args:$_GET.immo_doc_id:$_GET.from shape="link"
|
||||
target="_dialog"}}
|
||||
</nav>
|
||||
{{/if}}
|
||||
|
||||
<h3 class="ruler">Écritures d'amortissement attachées à l'immobilisation</h3>
|
||||
{{if $linked_amort != null}}
|
||||
<form method="post" action="">
|
||||
<h3 class="ruler">Écritures d'amortissement attachées à l'immobilisation</h3>
|
||||
<table class="list">
|
||||
<thead>
|
||||
<tr>
|
||||
|
|
@ -182,15 +159,13 @@
|
|||
<td class="money">{{"%f"|math:$line.amount|money_html:false|raw}}</td>
|
||||
<td><a href="{{$compte_url}}">{{$line.account_code}}</a></td>
|
||||
<td>{{$line.account_label}}</td>
|
||||
<td class="actions">
|
||||
{{:button type="submit" name="detach_amort" label="Détacher" shape="minus" value=$line.line_id}}
|
||||
<td>
|
||||
{{:linkbutton label="Détacher" href="detach_amort.html?immo_doc_id=%s&amort_line_id=%s&from=exit"|args:$_GET.immo_doc_id:$line.line_id shape="minus"}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/foreach}}
|
||||
</tbody>
|
||||
</table>
|
||||
<input type="hidden" id="immo_doc_id" name="immo_doc_id" value="{{$_GET.immo_doc_id}}">
|
||||
</form>
|
||||
{{elseif $free_amort_lines}}
|
||||
<p class="block alert">
|
||||
Vous pouvez attacher une ou plusieurs écritures d'amortissement à l'immobilisation
|
||||
|
|
@ -201,6 +176,55 @@
|
|||
</p>
|
||||
{{/if}}
|
||||
|
||||
|
||||
{{if $free_amort_lines}}
|
||||
<h3 class="ruler">Autres écritures d'amortissements</h3>
|
||||
<table class="list">
|
||||
<thead>
|
||||
<tr>
|
||||
<td class="num">N°</td>
|
||||
<td>Date</td>
|
||||
<td>Libellé</td>
|
||||
<td class="nombre">Montant</td>
|
||||
<td>N° compte</td>
|
||||
<td>Compte</td>
|
||||
<td class="actions"></td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
{{#foreach from=$free_amort_lines item="line"}}
|
||||
{{:assign amort_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.year}}
|
||||
<tr>
|
||||
<td class="num"><a href="{{$amort_url}}">#{{$line.amort_trans_id}}</a></td>
|
||||
<td>{{$line.date|date_short}}</td>
|
||||
<td>
|
||||
{{if $line.line_label != null}}
|
||||
{{$line.line_label}}
|
||||
{{if $line.trans_label != $line.line_label}}
|
||||
— {{$line.trans_label}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{$line.trans_label}}
|
||||
{{/if}}
|
||||
{{*
|
||||
{{$line.trans_label}}
|
||||
{{if $line.line_label != null && $line.line_label != $line.trans_label}} — {{$line.line_label}}{{/if}}
|
||||
*}}
|
||||
</td>
|
||||
<td class="money">{{"%f"|math:$line.amort_amount|money_html:false|raw}}</td>
|
||||
<td><a href="{{$compte_url}}">{{$line.account_code}}</a></td>
|
||||
<td>{{$line.account_label}}</td>
|
||||
<td>
|
||||
{{:linkbutton label="Attacher" href="attach_amort.html?immo_doc_id=%s&amort_line_id=%s&from=exit"|args:$_GET.immo_doc_id:$line.amort_line_id shape="plus" target="_dialog"}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/foreach}}
|
||||
</tbody>
|
||||
</table>
|
||||
{{/if}}
|
||||
|
||||
<form method="post" action="">
|
||||
<p class="submit">
|
||||
{{:button type="submit" name="backward" label="Revenir à l'étape précédente" shape="left" class="main"}}
|
||||
|
|
|
|||
109
exit_step3.html
109
exit_step3.html
|
|
@ -1,5 +1,6 @@
|
|||
{{* -*- brindille -*- *}}
|
||||
|
||||
{{:admin_header title="Immobilisation sortie du bilan" custom_css="./style.css" current="module_amortization"}}
|
||||
{{*
|
||||
Associer une écriture de cession à une immo créée et sortie du
|
||||
bilan avant la mise en service du module
|
||||
|
|
@ -13,24 +14,15 @@
|
|||
{{/if}}
|
||||
|
||||
{{#form on="backward"}}
|
||||
{{:redirect to="exit_step2.html?immo_doc_id=%s&from=%s"|args:$_GET.immo_doc_id:$_GET.from}}
|
||||
{{:redirect to="exit_step2.html?immo_doc_id=%s"|args:$_GET.immo_doc_id}}
|
||||
{{/form}}
|
||||
|
||||
{{#form on="forward"}}
|
||||
{{:redirect to="exit_step4.html?immo_doc_id=%s&from=%s"|args:$_GET.immo_doc_id:$_GET.from}}
|
||||
{{/form}}
|
||||
|
||||
{{*
|
||||
Supprimer l'association entre une écriture d'immobilisation et
|
||||
une écriture de cession
|
||||
*}}
|
||||
{{#form on="detach_cession"}}
|
||||
{{:include file="_detach_cession.html" immo_doc_id=$_POST.immo_doc_id cession_line_id=$_POST.detach_cession}}
|
||||
{{:redirect to="exit_step3.html?immo_doc_id=%s&from=exit&ok=1&msg=detach_cession"|args:$_GET.immo_doc_id}}
|
||||
{{:redirect to="exit_step4.html?immo_doc_id=%s"|args:$_GET.immo_doc_id}}
|
||||
{{/form}}
|
||||
|
||||
{{:assign label_immo=$info_immo.label|or:$ligne_immo.trans_label}}
|
||||
{{if $label_immo|strpos:$ligne_immo.line_label === false}}
|
||||
{{if $ligne_immo.line_label != null && $ligne_immo.line_label != $label_immo}}
|
||||
{{:assign label_immo=$label_immo|cat:" — "|cat:$ligne_immo.line_label}}
|
||||
{{/if}}
|
||||
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$ligne_immo.trans_id}}
|
||||
|
|
@ -67,21 +59,6 @@
|
|||
assign="line"
|
||||
}}
|
||||
{{* voir si l'écriture de cession est déjà liée à une immo *}}
|
||||
{{* TODO VOIR SI UTILE
|
||||
{{#load type="cession_link"
|
||||
where="$$.cession_line_id = :cession_line_id"
|
||||
:cession_line_id = $line.line_id
|
||||
assign="cession_link"
|
||||
}}
|
||||
{{:debug line=$line cession_link=$cession_link}}
|
||||
{{:assign total_cession="%d+%d"|math:$total_cession:$line.amount}}
|
||||
{{:assign var="line.linked_id" value=$linked_id}}
|
||||
{{:assign var="linked_cessions." value=$line}}
|
||||
{{else}}
|
||||
{{:assign var="free_cessions." value=$line}}
|
||||
{{/load}}
|
||||
*}}
|
||||
|
||||
{{#select
|
||||
CASE WHEN links.id_related = :trans_id
|
||||
THEN links.id_transaction
|
||||
|
|
@ -101,14 +78,7 @@
|
|||
{{:assign var="free_cessions." value=$line}}
|
||||
{{/select}}
|
||||
{{/select}}
|
||||
|
||||
{{:admin_header title="Immobilisation sortie du bilan" custom_css="./style.css" current="module_amortization"}}
|
||||
|
||||
{{if $_GET.from == "exit"}}
|
||||
{{:assign current="other"}}
|
||||
{{else}}
|
||||
{{:assign current="archived"}}
|
||||
{{/if}}
|
||||
{{*:debug linked_cessions=$linked_cessions free_cessions=$free_cessions total_cession=$total_cession*}}
|
||||
|
||||
{{if $_GET.ok}}
|
||||
{{if $_GET.msg|match:"attach_cession"}}
|
||||
|
|
@ -119,8 +89,6 @@
|
|||
<p class="block confirm">{{$msg}}</p>
|
||||
{{/if}}
|
||||
|
||||
{{:form_errors}}
|
||||
|
||||
<div class="informations">
|
||||
<dl class="describe">
|
||||
<dt>Immobilisation</dt>
|
||||
|
|
@ -128,7 +96,7 @@
|
|||
<dt>Compte d'immobilisation</dt>
|
||||
<dd>{{$ligne_immo.account_code}} — {{$ligne_immo.account_label}}</dd>
|
||||
<dt>Montant de l'immobilisation</dt>
|
||||
<dd><span class="money">{{$montant_immo|money_currency_html:false|raw}}</dd>
|
||||
<dd><span class="money">{{$ligne_immo.amount|money_html|raw}}</dd>
|
||||
{{if $total_credits > 0}}
|
||||
<dt>Montant des avoirs</dt>
|
||||
<dd class="money">{{"%f"|math:$total_credits|money_currency_html:false|raw}}</dd>
|
||||
|
|
@ -148,18 +116,8 @@
|
|||
</dl>
|
||||
</div>
|
||||
|
||||
{{if $linked_cessions == null && $free_cessions != null}}
|
||||
<nav class="actions">
|
||||
{{:linkbutton
|
||||
label="Attacher une écriture de cession"
|
||||
href="list_cessions.html?immo_doc_id=%s&filter=true&from=%s"|args:$_GET.immo_doc_id:$_GET.from shape="link"
|
||||
target="_dialog"}}
|
||||
</nav>
|
||||
{{/if}}
|
||||
|
||||
<h3 class="ruler">Écriture de cession attachée à l'immobilisation</h3>
|
||||
{{if $linked_cessions != null}}
|
||||
<form method="post" action="">
|
||||
<h3 class="ruler">Écriture de cession attachée à l'immobilisation</h3>
|
||||
<table class="list">
|
||||
<thead>
|
||||
<tr>
|
||||
|
|
@ -193,25 +151,68 @@
|
|||
<td class="money">{{"%f"|math:$line.amount|money_html:false|raw}}</td>
|
||||
<td><a href="{{$compte_url}}">{{$line.account_code}}</a></td>
|
||||
<td>{{$line.account_label}}</td>
|
||||
<td class="actions">
|
||||
{{:button type="submit" name="detach_cession" label="Détacher" shape="minus" value=$line.line_id}}
|
||||
<td>
|
||||
{{:linkbutton label="Détacher" href="detach_cession.html?immo_doc_id=%s&cession_line_id=%s&from=exit"|args:$_GET.immo_doc_id:$line.line_id shape="minus"}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/foreach}}
|
||||
</tbody>
|
||||
</table>
|
||||
<input type="hidden" id="immo_doc_id" name="immo_doc_id" value="{{$_GET.immo_doc_id}}">
|
||||
</form>
|
||||
{{elseif $free_cessions}}
|
||||
<p class="block alert">
|
||||
Vous pouvez attacher une écriture de cession à l'immobilisation
|
||||
</p>
|
||||
{{else}}
|
||||
<p class="block alert">
|
||||
Aucune écriture de cession
|
||||
Aucune écriture de cession... que faire ?
|
||||
</p>
|
||||
{{/if}}
|
||||
|
||||
|
||||
{{if $free_cessions}}
|
||||
<h3 class="ruler">Autres écritures de cession</h3>
|
||||
<table class="list">
|
||||
<thead>
|
||||
<tr>
|
||||
<td class="num">N°</td>
|
||||
<td>Date</td>
|
||||
<td>Libellé</td>
|
||||
<td class="nombre">Montant</td>
|
||||
<td>N° compte</td>
|
||||
<td>Compte</td>
|
||||
<td class="actions"></td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
{{#foreach from=$free_cessions item="line"}}
|
||||
{{:assign cession_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$line.trans_id}}
|
||||
{{:assign compte_url="%s/acc/accounts/journal.php?id=%s&year=%s"|args:$admin_url:$line.account_id:$line.year}}
|
||||
<tr>
|
||||
<td class="num"><a href="{{$cession_url}}">#{{$line.trans_id}}</a></td>
|
||||
<td>{{$line.date|date_short}}</td>
|
||||
<td>
|
||||
{{if $line.line_label != null}}
|
||||
{{$line.line_label}}
|
||||
{{if $line.trans_label != $line.line_label}}
|
||||
— {{$line.trans_label}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{$line.trans_label}}
|
||||
{{/if}}
|
||||
</td>
|
||||
<td class="money">{{"%f"|math:$line.amount|money_html:false|raw}}</td>
|
||||
<td><a href="{{$compte_url}}">{{$line.account_code}}</a></td>
|
||||
<td>{{$line.account_label}}</td>
|
||||
<td>
|
||||
{{:linkbutton label="Attacher" href="attach_cession.html?immo_doc_id=%s&cession_line_id=%s&from=exit"|args:$_GET.immo_doc_id:$line.line_id shape="plus"}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/foreach}}
|
||||
</tbody>
|
||||
</table>
|
||||
{{/if}}
|
||||
|
||||
<form method="post" action="">
|
||||
<p class="submit">
|
||||
{{:button type="submit" name="backward" label="Revenir à l'étape précédente" shape="left" class="main"}}
|
||||
|
|
|
|||
231
exit_step4.html
231
exit_step4.html
|
|
@ -12,8 +12,25 @@
|
|||
{{:error message=$message}}
|
||||
{{/if}}
|
||||
|
||||
{{#form on="backward"}}
|
||||
{{:redirect to="exit_step3.html?immo_doc_id=%s"|args:$_GET.immo_doc_id}}
|
||||
{{/form}}
|
||||
|
||||
{{#form on="validate"}}
|
||||
{{* mettre à jour l'état de l'immobilisation *}}
|
||||
{{:save
|
||||
key=$info_immo.key
|
||||
status="archived"
|
||||
}}
|
||||
{{:redirect to="index.html?type_immo=archived"}}
|
||||
{{/form}}
|
||||
|
||||
{{#form on="finish"}}
|
||||
{{:redirect to="index.html?type_immo=managed"}}
|
||||
{{/form}}
|
||||
|
||||
{{:assign label_immo=$info_immo.label|or:$ligne_immo.trans_label}}
|
||||
{{if $label_immo|strpos:$ligne_immo.line_label === false}}
|
||||
{{if $ligne_immo.line_label != null && $ligne_immo.line_label != $label_immo}}
|
||||
{{:assign label_immo=$label_immo|cat:" — "|cat:$ligne_immo.line_label}}
|
||||
{{/if}}
|
||||
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$ligne_immo.trans_id}}
|
||||
|
|
@ -27,25 +44,6 @@
|
|||
{{* lister les amortissements liés à l'immobilisation *}}
|
||||
{{:include file="./_get_amort_lines.html" immo_doc_id=$_GET.immo_doc_id keep="linked_amort, total_amort"}}
|
||||
|
||||
{{* chercher une écriture de cession associée *}}
|
||||
{{#load type="cession_link"
|
||||
where="$$.immo_doc_id = :immo_doc_id"
|
||||
:immo_doc_id = $_GET.immo_doc_id|intval
|
||||
}}
|
||||
{{if $amount == null || $amount == 0}}
|
||||
{{#select credit
|
||||
FROM acc_transactions_lines
|
||||
WHERE id = :cession_line_id;
|
||||
:cession_line_id = $cession_line_id
|
||||
}}
|
||||
{{:assign montant_cession=$credit}}
|
||||
{{/select}}
|
||||
{{else}}
|
||||
{{:assign montant_cession=$amount}}
|
||||
{{/if}}
|
||||
{{:assign cession_doc_id=$id}}
|
||||
{{/load}}
|
||||
|
||||
{{* chercher une écriture de sortie de bilan associée *}}
|
||||
{{#load type="exit_link" where="$$.immo_doc_id = :immo_doc_id" :immo_doc_id=$info_immo.id assign="exit_info"}}
|
||||
{{/load}}
|
||||
|
|
@ -68,42 +66,6 @@
|
|||
assign="exit_line"
|
||||
}}
|
||||
{{/select}}
|
||||
|
||||
{{* lignes de l'écriture de sortie *}}
|
||||
{{:assign exit_amort=0}}
|
||||
{{#select
|
||||
line.label as line_label,
|
||||
line.credit,
|
||||
line.debit,
|
||||
acc.id as account_id,
|
||||
acc.code as account_code,
|
||||
acc.label as account_label
|
||||
FROM acc_transactions AS trans
|
||||
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 trans.id = :exit_trans_id;
|
||||
:exit_trans_id = $exit_line.trans_id
|
||||
assign="trans"
|
||||
}}
|
||||
{{:assign var="exit_trans.%s"|args:$account_code value=$trans}}
|
||||
{{if $account_code|strpos:"28" === 0}}
|
||||
{{:assign exit_amort="%d+%d"|math:$exit_amort:$debit}}
|
||||
{{/if}}
|
||||
{{/select}}
|
||||
|
||||
{{if $exit_amort != $total_amort}}
|
||||
{{:assign exit_amort_display=$exit_amort|money_currency:false|replace:" ":" "}}
|
||||
{{:assign total_amort_display=$total_amort|money_currency:false|replace:" ":" "}}
|
||||
{{:assign erreur=1}}
|
||||
{{:assign message="Le montant des amortissement dans l'écriture de sortie (%s) est différent du total des amortissements attachés à l'immobilisation (%s)."|args:$exit_amort_display:$total_amort_display}}
|
||||
{{/if}}
|
||||
|
||||
{{if $exit_line.amount != $solde}}
|
||||
{{:assign erreur=2}}
|
||||
{{:assign exit_line_amount=$exit_line.amount|money_currency:false|replace:" ":" "}}
|
||||
{{:assign solde_immo=$solde|money_currency:false|replace:" ":" "}}
|
||||
{{:assign message="Le montant de de l'immobilisation dans l'écriture de sortie (%s) est différent du montant à amortir (%s)."|args:$exit_line_amount:$solde_immo}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
{{*
|
||||
|
|
@ -154,6 +116,7 @@
|
|||
}}
|
||||
|
||||
{{* chercher des écritures d'amortissement correspondant au compte d'une immo sans doc associé *}}
|
||||
{{* TODO écritures d'amort pas entièrement affectées *}}
|
||||
{{#select
|
||||
line.id as amort_line_id,
|
||||
line.credit as amort_amount,
|
||||
|
|
@ -171,6 +134,7 @@
|
|||
WHERE
|
||||
account.code = :code_amort
|
||||
AND line.credit > 0
|
||||
AND (NOT trans.status & 16)
|
||||
AND trans.date >= :immo_date
|
||||
;
|
||||
:code_amort = $code_amort
|
||||
|
|
@ -199,41 +163,7 @@
|
|||
{{/if}}
|
||||
{{/select}}
|
||||
|
||||
{{#form on="backward"}}
|
||||
{{:redirect to="exit_step3.html?immo_doc_id=%s&from=%s"|args:$_GET.immo_doc_id:$_GET.from}}
|
||||
{{/form}}
|
||||
|
||||
{{#form on="validate"}}
|
||||
{{* mettre à jour l'état de l'immobilisation *}}
|
||||
{{:save
|
||||
key=$info_immo.key
|
||||
status="archived"
|
||||
}}
|
||||
{{:redirect to="index.html?type_immo=archived"}}
|
||||
{{/form}}
|
||||
|
||||
{{#form on="cancel"}}
|
||||
{{* supprimer les docs de cession et de sortie *}}
|
||||
{{if $cession_doc_id != null}}{{:delete id=$cession_doc_id}}{{/if}}
|
||||
{{if $exit_info != null}}{{:delete id=$exit_info.id}}{{/if}}
|
||||
{{:redirect to="index.html?type_immo=other"}}
|
||||
{{/form}}
|
||||
|
||||
{{*
|
||||
Supprimer l'association entre une écriture d'immobilisation et
|
||||
une écriture de sortie de bilan
|
||||
*}}
|
||||
{{#form on="detach_exit"}}
|
||||
{{:include file="_detach_exit.html" immo_doc_id=$_POST.immo_doc_id exit_line_id=$_POST.detach_exit}}
|
||||
{{:redirect to="?immo_doc_id=%s&from=exit&ok=1&msg=detach_exit"|args:$_POST.immo_doc_id}}
|
||||
{{/form}}
|
||||
|
||||
{{:admin_header title="Immobilisation sortie du bilan" custom_css="./style.css" current="module_amortization"}}
|
||||
{{if $_GET.from == "exit"}}
|
||||
{{:assign current="other"}}
|
||||
{{else}}
|
||||
{{:assign current="archived"}}
|
||||
{{/if}}
|
||||
|
||||
{{if $_GET.ok}}
|
||||
{{if $_GET.msg|match:"attach_exit"}}
|
||||
|
|
@ -251,7 +181,7 @@
|
|||
<dt>Compte d'immobilisation</dt>
|
||||
<dd>{{$ligne_immo.account_code}} — {{$ligne_immo.account_label}}</dd>
|
||||
<dt>Montant de l'immobilisation</dt>
|
||||
<dd><span class="money">{{$montant_immo|money_currency_html:false|raw}}</dd>
|
||||
<dd><span class="money">{{$ligne_immo.amount|money_html|raw}}</dd>
|
||||
{{if $total_credits > 0}}
|
||||
<dt>Montant des avoirs</dt>
|
||||
<dd class="money">{{"%f"|math:$total_credits|money_currency_html:false|raw}}</dd>
|
||||
|
|
@ -264,60 +194,11 @@
|
|||
<dt>Valeur nette résiduelle</dt>
|
||||
<dd>{{"%d-%d"|math:$solde:$total_amort|money_currency_html:false|raw}}</dd>
|
||||
{{/if}}
|
||||
{{if $montant_cession > 0}}
|
||||
<dt>Montant de la cession</dt>
|
||||
<dd>{{$montant_cession|money_currency_html:false|raw}}</dd>
|
||||
{{/if}}
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
{{if $erreur}}
|
||||
<p class="block error">{{$message}}<br />
|
||||
{{if $erreur == 1}}
|
||||
Vérifiez si vous avez correctement attaché les écritures d'amortissement.
|
||||
{{elseif $erreur == 2}}
|
||||
Vérifiez si vous avez correctement attaché d'éventuelles écritures d'avoir.
|
||||
{{/if}}
|
||||
</p>
|
||||
<table class="list error">
|
||||
<caption>Détails de l'écriture de sortie de bilan</caption>
|
||||
<thead class="error">
|
||||
<tr>
|
||||
<td class="num">Numéro</td>
|
||||
<td>Compte</td>
|
||||
<td class="nombre">Débit</td>
|
||||
<td class="nombre">Crédit</td>
|
||||
<td>Libellé</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#foreach from=$exit_trans key="account_code" item="line"}}
|
||||
{{:assign account_url="%s/acc/accounts/journal.php?id=%s&year=%s"|args:$admin_url:$line.account_id:$line.id_year}}
|
||||
<tr>
|
||||
<td class="num"><a href="{{$account_url}}">{{$line.account_code}}</a></td>
|
||||
<td>{{$line.account_label}}</td>
|
||||
<td class="money">{{$line.debit|money_currency:false}}</td>
|
||||
<td class="money">{{$line.credit|money_currency:false}}</td>
|
||||
<td>{{$line.line_label}}</td>
|
||||
</tr>
|
||||
{{/foreach}}
|
||||
</tbody>
|
||||
</table>
|
||||
{{/if}}
|
||||
|
||||
{{if $exit_lines}}
|
||||
<nav class="actions">
|
||||
{{:linkbutton
|
||||
label="Attacher une écriture de sortie de bilan"
|
||||
href="list_exit.html?immo_doc_id=%s&filter=true&from=%s"|args:$_GET.immo_doc_id:$_GET.from shape="link"
|
||||
target="_dialog"}}
|
||||
</nav>
|
||||
{{/if}}
|
||||
|
||||
<h3 class="ruler">Écriture de sortie de bilan attachée à l'immobilisation</h3>
|
||||
{{if $exit_line != null}}
|
||||
{{:assign exit_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$exit_line.trans_id}}
|
||||
<form method="post" action="">
|
||||
<h3 class="ruler">Écriture de sortie du bilan attachée à l'immobilisation</h3>
|
||||
<table class="list">
|
||||
<thead>
|
||||
<tr>
|
||||
|
|
@ -332,7 +213,7 @@
|
|||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="num"><a href="{{$exit_url}}">#{{$exit_line.trans_id}}</a></td>
|
||||
<td class="num"><a href="{{$trans_url}}">#{{$exit_line.trans_id}}</a></td>
|
||||
<td>{{$exit_line.date|date_short}}</td>
|
||||
<td>
|
||||
{{if $exit_line.line_label != null}}
|
||||
|
|
@ -344,46 +225,64 @@
|
|||
<td class="money">{{"%f"|math:$exit_line.amount|money_html:false|raw}}</td>
|
||||
<td><a href="{{$compte_url}}">{{$exit_line.account_code}}</a></td>
|
||||
<td>{{$exit_line.account_label}}</td>
|
||||
<td class="actions">
|
||||
{{if ! $erreur}}
|
||||
{{:button type="submit" name="detach_exit" label="Détacher" shape="minus" value=$exit_line.line_id}}
|
||||
{{/if}}
|
||||
<td>
|
||||
{{:linkbutton label="Détacher" href="detach_exit.html?immo_doc_id=%s&exit_line_id=%s&from=exit"|args:$_GET.immo_doc_id:$exit_line.line_id shape="minus"}}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<input type="hidden" id="immo_doc_id" name="immo_doc_id" value="{{$_GET.immo_doc_id}}">
|
||||
</form>
|
||||
{{elseif $exit_lines}}
|
||||
<p class="block alert">
|
||||
Vous pouvez attacher une écriture de sortie de bilan à l'immobilisation
|
||||
Vous pouvez attacher une écriture de sortie du bilan à l'immobilisation
|
||||
</p>
|
||||
{{/if}}
|
||||
|
||||
{{if $exit_lines == null && $exit_line == null}}
|
||||
<p class="block error">Aucune écriture de sortie de bilan avec un
|
||||
montant de {{$solde|money_currency_html:false|raw}} au crédit du
|
||||
compte {{$ligne_immo.account_code}} — {{$ligne_immo.account_label}} ;
|
||||
<br />
|
||||
Vérifiez si vous avez correctement attaché d'éventuelles écritures d'avoir.
|
||||
<br />
|
||||
Si vous avez supprimé l'écriture de sortie de bilan, il faut
|
||||
la recréer avant de pouvoir classer cette immobilisation
|
||||
« Sortie du bilan » !
|
||||
</p>
|
||||
{{:save
|
||||
key=$info_immo.key
|
||||
status=null
|
||||
}}
|
||||
{{if $exit_lines}}
|
||||
<h3 class="ruler">Écritures non rattachées</h3>
|
||||
<table class="list">
|
||||
<thead>
|
||||
<tr>
|
||||
<td class="num">N°</td>
|
||||
<td>Date</td>
|
||||
<td>Libellé</td>
|
||||
<td class="nombre">Montant</td>
|
||||
<td>N° compte</td>
|
||||
<td>Compte</td>
|
||||
<td class="actions"></td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
{{#foreach from=$exit_lines item="line"}}
|
||||
{{:assign exit_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$line.trans_id}}
|
||||
{{:assign compte_url="%s/acc/accounts/journal.php?id=%s&year=%s"|args:$admin_url:$line.account_id:$line.year}}
|
||||
<tr>
|
||||
<td class="num"><a href="{{$exit_url}}">#{{$line.trans_id}}</a></td>
|
||||
<td>{{$line.date|date_short}}</td>
|
||||
<td>{{$line.trans_label}}
|
||||
{{if $line.line_label != null && $line.line_label != $line.trans_label}} — {{$line.line_label}}{{/if}}
|
||||
</td>
|
||||
<td class="money">{{"%f"|math:$line.amount|money_html:false|raw}}</td>
|
||||
<td><a href="{{$compte_url}}">{{$line.account_code}}</a></td>
|
||||
<td>{{$line.account_label}}</td>
|
||||
<td>
|
||||
{{:linkbutton label="Attacher" href="attach_exit.html?immo_doc_id=%s&exit_line_id=%s&from=exit"|args:$_GET.immo_doc_id:$line.credit_line_id shape="plus"}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/foreach}}
|
||||
</tbody>
|
||||
</table>
|
||||
{{elseif $exit_line == null}}
|
||||
<p class="block alert">Aucune écriture de sortie du bilan. Vérifiez l'attachement d'écriture d'avoir.</p>
|
||||
{{/if}}
|
||||
|
||||
<form method="post" action="">
|
||||
<p class="submit">
|
||||
{{:button type="submit" name="backward" label="Revenir à l'étape précédente" shape="left" class="main"}}
|
||||
{{if $exit_line && ! $erreur}}
|
||||
{{if $exit_line}}
|
||||
{{:button type="submit" name="validate" label="Terminer" shape="check" class="main"}}
|
||||
{{else}}
|
||||
{{:button type="submit" name="cancel" label="Annuler" shape="delete" class="main"}}
|
||||
{{:button type="submit" name="finish" label="Terminer" shape="export" class="main"}}
|
||||
{{/if}}
|
||||
</p>
|
||||
</form>
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@
|
|||
<thead>
|
||||
<tr>
|
||||
<th>Libellé</th>
|
||||
<th class="actions"></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@
|
|||
{{:error message="Il n'y a aucune écriture avec le numéro de ligne %s !"|args:$_GET.immo_line_id}}
|
||||
{{/select}}
|
||||
{{#load type="immo" assign="info_immo" where="$$.line = :line_id" :line_id=$_GET.immo_line_id|intval}}{{/load}}
|
||||
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$ligne_immo.trans_id}}
|
||||
|
||||
{{* Traiter l'envoi du formulaire *}}
|
||||
{{#form on="proceed"}}
|
||||
|
|
|
|||
28
index.html
28
index.html
|
|
@ -7,39 +7,36 @@
|
|||
{{:assign type_immo=$_GET.type_immo}}
|
||||
{{/if}}
|
||||
|
||||
{{if $type_immo == "managed"}}
|
||||
{{if $type_immo == "managed"}}
|
||||
{{:admin_header title="Immobilisations en cours d'amortissement" custom_css="./style.css" current="module_amortization"}}
|
||||
{{elseif $type_immo == "amortized"}}
|
||||
{{elseif $type_immo == "amortized"}}
|
||||
{{:admin_header title="Immobilisations amorties" custom_css="./style.css" current="module_amortization"}}
|
||||
{{elseif $type_immo == "archived"}}
|
||||
{{elseif $type_immo == "archived"}}
|
||||
{{:admin_header title="Immobilisations archivées" custom_css="./style.css" current="module_amortization"}}
|
||||
{{elseif $type_immo == "other"}}
|
||||
{{elseif $type_immo == "other"}}
|
||||
{{:admin_header title="Immobilisations à classer" custom_css="./style.css" current="module_amortization"}}
|
||||
{{elseif $type_immo == "unfinished"}}
|
||||
{{elseif $type_immo == "unfinished"}}
|
||||
{{:admin_header title="Immobilisations en cours de constitution" custom_css="./style.css" current="module_amortization" subcurrent="unfinished"}}
|
||||
{{/if}}
|
||||
{{:include file="_nav.html" current=$type_immo}}
|
||||
{{/if}}
|
||||
|
||||
{{* Mise à niveau *}}
|
||||
{{:assign module_version="0.41"}}
|
||||
{{:include file="_upgrade.html" module_version=$module_version}}
|
||||
|
||||
{{* supprimer les documents sans écriture associée *}}
|
||||
{{:include file="_remove_orphan_docs.tpl"}}
|
||||
{{:include file="_nav.html" current="index" subcurrent=$type_immo}}
|
||||
|
||||
{{if $_GET.ok}}
|
||||
{{if $_GET.msg|match:"immobilisation"}}
|
||||
{{:assign msg="Immobilisation enregistrée"}}
|
||||
{{elseif $_GET.msg|match:"suppr_infos"}}
|
||||
{{:assign msg="Paramètres supprimés"}}
|
||||
{{:assign msg="Informations supprimées"}}
|
||||
{{elseif $_GET.msg|match:"infos"}}
|
||||
{{:assign msg="Paramètres enregistrés"}}
|
||||
{{:assign msg="Informations enregistrées"}}
|
||||
{{/if}}
|
||||
<p class="block confirm">{{$msg}}</p>
|
||||
{{elseif $_GET.err}}
|
||||
<p class="block error">Échec enregistrement immobilisation</p>
|
||||
{{/if}}
|
||||
|
||||
{{* supprimer les documents sans écriture associée *}}
|
||||
{{:include file="_remove_orphan_docs.tpl"}}
|
||||
|
||||
{{if $type_immo == "other"}}
|
||||
{{:include file="_immobilisations_autres.html"}}
|
||||
{{elseif $type_immo == "archived"}}
|
||||
|
|
@ -49,4 +46,5 @@
|
|||
{{elseif $type_immo == "managed" || $type_immo == "amortized"}}
|
||||
{{:include file="_immobilisations.html"}}
|
||||
{{/if}}
|
||||
|
||||
{{:admin_footer}}
|
||||
|
|
|
|||
|
|
@ -4,53 +4,20 @@
|
|||
Lister les écritures au crédit du compte de l'immobilisation
|
||||
paramètre et proposer de les attacher à l'immo paramètre
|
||||
@param immo_doc_id : document associé à l'immo
|
||||
@param filter : si vrai ne montrer que les écritures du compte de l'immobilisation (et sous-comptes)
|
||||
dans le cas contraire, montrer les écritures de tous les comptes d'immo
|
||||
*}}
|
||||
|
||||
{{:include file="_get_immo_data.html" immo_doc_id=$_GET.immo_doc_id|intval keep="info_immo, ligne_immo, message"}}
|
||||
{{if $message != null}}
|
||||
{{:error message=$message}}
|
||||
{{/if}}
|
||||
|
||||
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$ligne_immo.trans_id}}
|
||||
{{:assign date_immo=$info_immo.date_mes|or:$info_immo.date_achat|or:$ligne_immo.date_achat}}
|
||||
{{:assign montant_immo=$info_immo.amount|or:$ligne_immo.amount}}
|
||||
|
||||
{{:assign label_immo=$info_immo.label|or:$ligne_immo.trans_label}}
|
||||
{{if $label_immo|strpos:$ligne_immo.line_label ===false }}
|
||||
{{:assign label_immo=$ligne_immo.trans_label}}
|
||||
{{if $ligne_immo.line_label != null && $ligne_immo.line_label != $label_immo}}
|
||||
{{:assign label_immo=$label_immo|cat:" — "|cat:$ligne_immo.line_label}}
|
||||
{{/if}}
|
||||
{{if $info_immo.amount != null}}
|
||||
{{:assign var="ligne_immo.amount" value=$info_immo.amount}}
|
||||
{{/if}}
|
||||
|
||||
{{* déduire le montant des écritures liées à l'immo courante au crédit du même compte *}}
|
||||
{{:include file="_get_credit_lines.html" immo_doc_id=$_GET.immo_doc_id keep="linked_immos, total_credits"}}
|
||||
{{:assign solde="%d-%d"|math:$montant_immo:$total_credits}}
|
||||
|
||||
{{*
|
||||
lister les écritures au crédit du compte de l'immobilisation
|
||||
*}}
|
||||
{{:include file="_get_config.html" keep="module.config"}}
|
||||
{{if $_GET.filter}}
|
||||
{{:assign account_code=$ligne_immo.account_code|cat:"%"|quote_sql}}
|
||||
{{:assign account_condition="account.code LIKE "|cat:$account_code}}
|
||||
{{else}}
|
||||
{{:assign account_condition="("}}
|
||||
{{#foreach from=$module.config.prefixes item="account_code"}}
|
||||
{{:assign account_code=$account_code|cat:"%"|quote_sql}}
|
||||
{{:assign account_condition=$account_condition|cat:" account.code LIKE "|cat:$account_code|cat:" OR "}}
|
||||
{{/foreach}}
|
||||
{{#foreach from=$module.config.unfinished item="account_code"}}
|
||||
{{:assign account_code=$account_code|cat:"%"|quote_sql}}
|
||||
{{:assign account_condition=$account_condition|cat:" account.code LIKE "|cat:$account_code|cat:" OR "}}
|
||||
{{/foreach}}
|
||||
{{:assign account_condition=$account_condition|cat:"0)"}}
|
||||
{{/if}}
|
||||
|
||||
{{:assign date_immo=$info_immo.date_achat|or:$ligne_immo.date_achat}}
|
||||
|
||||
{{#select
|
||||
line.id as credit_line_id,
|
||||
line.id_transaction as credit_trans_id,
|
||||
|
|
@ -67,24 +34,15 @@
|
|||
INNER JOIN acc_transactions AS trans ON trans.id = line.id_transaction
|
||||
INNER JOIN acc_accounts AS account ON account.id = line.id_account
|
||||
INNER JOIN acc_years AS y ON y.id = trans.id_year
|
||||
WHERE !account_condition
|
||||
AND credit > 0
|
||||
AND trans.date > :date_immo
|
||||
WHERE account.code = :account_code AND credit > 0
|
||||
AND credit_line_id NOT IN (
|
||||
SELECT json_extract(link.document, '$.credit_line_id') AS credit_line_id FROM !table as link
|
||||
WHERE json_extract(link.document, '$.type') == "credit_link"
|
||||
UNION
|
||||
SELECT json_extract(exit_link.document, '$.exit_line_id') AS line_id FROM !table as exit_link
|
||||
WHERE json_extract(exit_link.document, '$.type') == "exit_link")
|
||||
WHERE json_extract(link.document, '$.type') == "credit_link")
|
||||
ORDER BY trans.date, trans.label;
|
||||
!account_condition = $account_condition
|
||||
!table = $module.table
|
||||
:date_immo = $date_immo
|
||||
assign="credit_line"
|
||||
:account_code = $ligne_immo.account_code
|
||||
!table =$module.table
|
||||
assign="other_immos."
|
||||
}}
|
||||
{{if $credit_line.credit_amount < $solde}}
|
||||
{{:assign var="other_immos." value=$credit_line}}
|
||||
{{/if}}
|
||||
{{/select}}
|
||||
|
||||
{{:admin_header title="Écritures au crédit du compte d'immobilisation" custom_css="./style.css" current="module_amortization"}}
|
||||
|
|
@ -93,38 +51,30 @@
|
|||
{{if ! $dialog}}
|
||||
{{:include
|
||||
file="_nav.html"
|
||||
current="managed"
|
||||
subcurrent="link_immo"
|
||||
current="config"
|
||||
subcurrent="other"
|
||||
subsubcurrent="immo"
|
||||
type_immo="other"
|
||||
}}
|
||||
{{/if}}
|
||||
|
||||
<nav class="tabs">
|
||||
<ul>
|
||||
<li {{if $_GET.filter}}class="current"{{/if}}>
|
||||
<a href="link_immo.html?immo_doc_id={{$_GET.immo_doc_id}}{{if $dialog}}&_dialog{{/if}}&filter=true&from={{$_GET.from}}">
|
||||
Compte {{$ligne_immo.account_code}} et sous-comptes
|
||||
</a>
|
||||
</li>
|
||||
<li {{if ! $_GET.filter}}class="current"{{/if}}>
|
||||
<a href="link_immo.html?immo_doc_id={{$_GET.immo_doc_id}}{{if $dialog}}&_dialog{{/if}}&from={{$_GET.from}}">
|
||||
Tous les comptes
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
<section class="immobilisation">
|
||||
<fieldset>
|
||||
<legend>
|
||||
Écritures au crédit du compte d'immobilisation « {{$ligne_immo.account_code}} »
|
||||
</legend>
|
||||
|
||||
<div class="informations">
|
||||
<dl class="describe">
|
||||
<dt>Immobilisation</dt>
|
||||
<dd><span class="num"><a href="{{$trans_url}}">#{{$ligne_immo.trans_id}}</a></span> {{$label_immo}}</dd>
|
||||
<dt>Montant</dt>
|
||||
<dd class="money strong">{{"%f"|math:$ligne_immo.amount|money_currency_html:false|raw}}</dd>
|
||||
<dt>Date de l'immobilisation</dt>
|
||||
<dd>{{$date_immo|date_short}}</dd>
|
||||
<dt>Date de l'écriture d'immobilisation</dt>
|
||||
<dd>{{$ligne_immo.date_achat|date_short}}</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
{{if $other_immos != null}}
|
||||
<table class="list">
|
||||
|
|
@ -152,20 +102,16 @@
|
|||
</td>
|
||||
<td><a href="{{$compte_url}}">{{$line.account_code}}</a></td>
|
||||
<td>{{$line.account_label}}</td>
|
||||
<td class="actions">
|
||||
{{:linkbutton label="Attacher" href="attach_credit.html?credit_line_id=%d&immo_doc_id=%s&from=%s"|args:$line.credit_line_id:$_GET.immo_doc_id:$_GET.from shape="plus"}}
|
||||
<td>
|
||||
{{:linkbutton label="Attacher" href="attach_credit.html?credit_line_id=%d&immo_doc_id=%s"|args:$line.credit_line_id:$_GET.immo_doc_id shape="plus"}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/foreach}}
|
||||
</tbody>
|
||||
<p class="help">Sélectionner une écriture d'avoir ou autre réduction du montant de l'acquisition pour l'associer à l'immobilisation</p>
|
||||
</table>
|
||||
<p class="help">Sélectionner une écriture d'avoir ou autre réduction du montant de l'acquisition pour l'associer à l'immobilisation</p>
|
||||
{{else}}
|
||||
{{if $_GET.filter}}
|
||||
<p class="block alert">Aucune écriture au crédit du compte {{$ligne_immo.account_code}} et sous-comptes</p>
|
||||
{{else}}
|
||||
<p class="block alert">Aucune écriture au crédit du compte {{$ligne_immo.account_code|substr:0:2}} et sous-comptes</p>
|
||||
{{/if}}
|
||||
<p class="block alert">Aucune écriture au crédit du compte « {{$ligne_immo.account_code}} »</p>
|
||||
{{/if}}
|
||||
</section>
|
||||
{{:form_errors}}
|
||||
|
|
|
|||
|
|
@ -1,133 +0,0 @@
|
|||
{{* -*- brindille -*- *}}
|
||||
|
||||
{{*
|
||||
Lister les écritures de cession du compte de l'immobilisation
|
||||
paramètre et proposer de les attacher à l'immo paramètre
|
||||
@param immo_doc_id : document associé à l'immo
|
||||
*}}
|
||||
{{:include file="_get_immo_data.html" immo_doc_id=$_GET.immo_doc_id|intval keep="info_immo, ligne_immo, message"}}
|
||||
{{if $message != null}}
|
||||
{{:error message=$message}}
|
||||
{{/if}}
|
||||
|
||||
{{*
|
||||
Enregistrer la liaison entre une écriture d'immobilisation et
|
||||
une écriture de cession
|
||||
*}}
|
||||
{{#form on="attach_cession"}}
|
||||
{{:include file="_attach_cession.html" immo_doc_id=$_POST.immo_doc_id cession_line_id=$_POST.attach_cession}}
|
||||
{{:redirect force="exit_step3.html?immo_doc_id=%s&from=exit&ok=1&msg=attach_cession"|args:$_POST.immo_doc_id}}
|
||||
{{/form}}
|
||||
|
||||
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$ligne_immo.trans_id}}
|
||||
{{:assign date_debut=$info_immo.date_mes|or:$info_immo.date_achat|or:$ligne_immo.date_achat}}
|
||||
{{:assign label_immo=$info_immo.label|or:$ligne_immo.trans_label}}
|
||||
{{if $label_immo|strpos:$ligne_immo.line_label ===false }}
|
||||
{{:assign label_immo=$label_immo|cat:" — "|cat:$ligne_immo.line_label}}
|
||||
{{/if}}
|
||||
{{if $info_immo.amount != null}}
|
||||
{{:assign var="ligne_immo.amount" value=$info_immo.amount}}
|
||||
{{/if}}
|
||||
|
||||
{{:assign total_cession=0}}
|
||||
{{#select
|
||||
line.id as line_id,
|
||||
line.credit as amount,
|
||||
line.label as line_label,
|
||||
trans.id as trans_id,
|
||||
trans.date as date,
|
||||
trans.label as trans_label,
|
||||
trans.id_year as year,
|
||||
account.id as account_id,
|
||||
account.code as account_code,
|
||||
account.label as account_label
|
||||
FROM acc_transactions_lines AS line
|
||||
INNER JOIN acc_accounts AS account ON line.id_account = account.id
|
||||
INNER JOIN acc_transactions AS trans ON line.id_transaction = trans.id
|
||||
WHERE account.code LIKE :code_cession_new OR account.code LIKE :code_cession_old
|
||||
;
|
||||
:code_cession_new = "757%"
|
||||
:code_cession_old = "775%"
|
||||
assign="line"
|
||||
}}
|
||||
{{#select
|
||||
CASE WHEN links.id_related = :trans_id
|
||||
THEN links.id_transaction
|
||||
ELSE links.id_related
|
||||
END as linked_id
|
||||
FROM acc_transactions_links as links
|
||||
WHERE links.id_transaction = :trans_id OR links.id_related = :trans_id
|
||||
;
|
||||
:trans_id = $line.trans_id
|
||||
}}
|
||||
{{if $linked_id == $ligne_immo.trans_id}}
|
||||
{{:assign total_cession="%d+%d"|math:$total_cession:$line.amount}}
|
||||
{{:assign var="line.linked_id" value=$linked_id}}
|
||||
{{:assign var="linked_cessions." value=$line}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{:assign var="free_cessions." value=$line}}
|
||||
{{/select}}
|
||||
{{/select}}
|
||||
|
||||
{{:admin_header title="Écritures de cession du compte d'immobilisation" custom_css="./style.css" current="module_amortization"}}
|
||||
|
||||
{{:form_errors}}
|
||||
|
||||
<div class="informations">
|
||||
<dl class="describe">
|
||||
<dt>Immobilisation</dt>
|
||||
<dd><span class="num"><a href="{{$trans_url}}">#{{$ligne_immo.trans_id}}</a></span> {{$label_immo}}</dd>
|
||||
<dt>Montant</dt>
|
||||
<dd class="money strong">{{"%f"|math:$ligne_immo.amount|money_currency_html:false|raw}}</dd>
|
||||
<dt>Date de l'immobilisation</dt>
|
||||
<dd>{{$date_debut|date_short}}</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
{{if $free_cessions}}
|
||||
<form method="post" action="">
|
||||
<table class="list">
|
||||
<thead>
|
||||
<tr>
|
||||
<td class="num">N°</td>
|
||||
<td>Date</td>
|
||||
<td>Libellé</td>
|
||||
<td class="nombre">Montant</td>
|
||||
<td>N° compte</td>
|
||||
<td>Compte</td>
|
||||
<td class="actions"></td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
{{#foreach from=$free_cessions item="line"}}
|
||||
{{:assign cession_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$line.trans_id}}
|
||||
{{:assign compte_url="%s/acc/accounts/journal.php?id=%s&year=%s"|args:$admin_url:$line.account_id:$line.year}}
|
||||
<tr>
|
||||
<td class="num"><a href="{{$cession_url}}">#{{$line.trans_id}}</a></td>
|
||||
<td>{{$line.date|date_short}}</td>
|
||||
<td>
|
||||
{{if $line.line_label != null}}
|
||||
{{$line.line_label}}
|
||||
{{if $line.trans_label != $line.line_label}}
|
||||
— {{$line.trans_label}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{$line.trans_label}}
|
||||
{{/if}}
|
||||
</td>
|
||||
<td class="money">{{"%f"|math:$line.amount|money_html:false|raw}}</td>
|
||||
<td><a href="{{$compte_url}}">{{$line.account_code}}</a></td>
|
||||
<td>{{$line.account_label}}</td>
|
||||
<td class="actions">
|
||||
{{:button type="submit" name="attach_cession" label="Attacher" shape="plus" value=$line.line_id}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/foreach}}
|
||||
</tbody>
|
||||
<p class="help">Sélectionner une écriture de cession pour l'associer à l'immobilisation</p>
|
||||
</table>
|
||||
<input type="hidden" id="immo_doc_id" name="immo_doc_id" value="{{$_GET.immo_doc_id}}">
|
||||
</form>
|
||||
{{/if}}
|
||||
123
list_exit.html
123
list_exit.html
|
|
@ -1,123 +0,0 @@
|
|||
{{* -*- brindille -*- *}}
|
||||
|
||||
{{*
|
||||
Lister les écritures de sortie de bilan du compte de l'immobilisation
|
||||
paramètre et proposer de les attacher à l'immo paramètre
|
||||
@param immo_doc_id : document associé à l'immo
|
||||
*}}
|
||||
{{:include file="_get_immo_data.html" immo_doc_id=$_GET.immo_doc_id|intval keep="info_immo, ligne_immo, message"}}
|
||||
{{if $message != null}}
|
||||
{{:error message=$message}}
|
||||
{{/if}}
|
||||
|
||||
{{*
|
||||
Enregistrer la liaison entre une écriture d'immobilisation et
|
||||
une écriture de sortie d'immobilisation
|
||||
*}}
|
||||
{{#form on="attach_exit"}}
|
||||
{{:include file="_attach_exit.html" immo_doc_id=$_POST.immo_doc_id exit_line_id=$_POST.attach_exit}}
|
||||
{{:redirect force="exit_step4.html?immo_doc_id=%s&from=exit&ok=1&msg=attach_exit"|args:$_POST.immo_doc_id}}
|
||||
{{/form}}
|
||||
|
||||
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$ligne_immo.trans_id}}
|
||||
{{:assign date_debut=$info_immo.date_mes|or:$info_immo.date_achat|or:$ligne_immo.date_achat}}
|
||||
{{:assign label_immo=$info_immo.label|or:$ligne_immo.trans_label}}
|
||||
{{if $label_immo|strpos:$ligne_immo.line_label ===false }}
|
||||
{{:assign label_immo=$label_immo|cat:" — "|cat:$ligne_immo.line_label}}
|
||||
{{/if}}
|
||||
{{if $info_immo.amount != null}}
|
||||
{{:assign var="ligne_immo.amount" value=$info_immo.amount}}
|
||||
{{/if}}
|
||||
|
||||
{{* déduire le montant des écritures liées à l'immo courante au crédit du même compte *}}
|
||||
{{:include file="_get_credit_lines.html" immo_doc_id=$_GET.immo_doc_id keep="linked_immos, total_credits"}}
|
||||
{{:assign solde="%d-%d"|math:$ligne_immo.amount:$total_credits}}
|
||||
|
||||
{{#select
|
||||
trans.id as trans_id,
|
||||
trans.label as trans_label,
|
||||
trans.date as date,
|
||||
trans.id_year as year,
|
||||
line.id as credit_line_id,
|
||||
line.label as line_label,
|
||||
line.credit as amount,
|
||||
acc.id as account_id,
|
||||
acc.code as account_code,
|
||||
acc.label as account_label
|
||||
FROM acc_transactions AS trans
|
||||
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
|
||||
LEFT JOIN module_data_amortization AS mda ON json_extract(mda.document, '$.amort_line_id') = line.id
|
||||
WHERE
|
||||
acc.code = :acc_code
|
||||
AND line.credit > 0
|
||||
AND credit_line_id NOT IN (
|
||||
SELECT json_extract(credit_link.document, '$.credit_line_id') AS line_id FROM !table as credit_link
|
||||
WHERE json_extract(credit_link.document, '$.type') == "credit_link"
|
||||
UNION
|
||||
SELECT json_extract(exit_link.document, '$.exit_line_id') AS line_id FROM !table as exit_link
|
||||
WHERE json_extract(exit_link.document, '$.type') == "exit_link"
|
||||
)
|
||||
;
|
||||
:acc_code=$ligne_immo.account_code
|
||||
!table =$module.table
|
||||
assign="credit_line"
|
||||
}}
|
||||
{{if $credit_line.amount == $solde}}
|
||||
{{:assign var="exit_lines." value=$credit_line}}
|
||||
{{/if}}
|
||||
{{/select}}
|
||||
|
||||
{{:admin_header title="Écritures de sortie du bilan" custom_css="./style.css" current="module_amortization"}}
|
||||
|
||||
{{:form_errors}}
|
||||
|
||||
<div class="informations">
|
||||
<dl class="describe">
|
||||
<dt>Immobilisation</dt>
|
||||
<dd><span class="num"><a href="{{$trans_url}}">#{{$ligne_immo.trans_id}}</a></span> {{$label_immo}}</dd>
|
||||
<dt>Montant</dt>
|
||||
<dd class="money strong">{{"%f"|math:$ligne_immo.amount|money_currency_html:false|raw}}</dd>
|
||||
<dt>Date de l'immobilisation</dt>
|
||||
<dd>{{$date_debut|date_short}}</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
{{if $exit_lines}}
|
||||
<form method="post" action="">
|
||||
<table class="list">
|
||||
<thead>
|
||||
<tr>
|
||||
<td class="num">N°</td>
|
||||
<td>Date</td>
|
||||
<td>Libellé</td>
|
||||
<td class="nombre">Montant</td>
|
||||
<td>N° compte</td>
|
||||
<td>Compte</td>
|
||||
<td class="actions"></td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#foreach from=$exit_lines item="line"}}
|
||||
{{:assign exit_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$line.trans_id}}
|
||||
{{:assign compte_url="%s/acc/accounts/journal.php?id=%s&year=%s"|args:$admin_url:$line.account_id:$line.year}}
|
||||
<tr>
|
||||
<td class="num"><a href="{{$exit_url}}">#{{$line.trans_id}}</a></td>
|
||||
<td>{{$line.date|date_short}}</td>
|
||||
<td>{{$line.trans_label}}
|
||||
{{if $line.line_label != null && $line.line_label != $line.trans_label}} — {{$line.line_label}}{{/if}}
|
||||
</td>
|
||||
<td class="money">{{"%f"|math:$line.amount|money_html:false|raw}}</td>
|
||||
<td><a href="{{$compte_url}}">{{$line.account_code}}</a></td>
|
||||
<td>{{$line.account_label}}</td>
|
||||
<td class="actions">
|
||||
{{:button type="submit" name="attach_exit" label="Attacher" shape="plus" value=$line.credit_line_id}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/foreach}}
|
||||
</tbody>
|
||||
<p class="help">Sélectionner une écriture de sortie de bilan pour l'associer à l'immobilisation</p>
|
||||
</table>
|
||||
<input type="hidden" id="immo_doc_id" name="immo_doc_id" value="{{$_GET.immo_doc_id}}">
|
||||
</form>
|
||||
{{/if}}
|
||||
|
|
@ -14,8 +14,6 @@
|
|||
{{if $ligne_immo.line_label != null && $ligne_immo.line_label != $immo_label}}
|
||||
{{:assign immo_label=$immo_label|cat:" — "|cat:$ligne_immo.line_label}}
|
||||
{{/if}}
|
||||
{{:assign date_achat_defaut=$info_immo.date_achat|or:$ligne_immo.date_achat}}
|
||||
{{:assign date_mes_defaut=$info_immo.date_mes|or:$info_immo.date_achat|or:$ligne_immo.date_achat}}
|
||||
|
||||
{{* déduire le montant des écritures liées à l'immo courante au crédit du même compte *}}
|
||||
{{:include file="_get_credit_lines.html" immo_doc_id=$_GET.immo_doc_id keep="linked_immos, total_credits"}}
|
||||
|
|
@ -95,6 +93,44 @@
|
|||
|
||||
{{:assign status="managed"}}
|
||||
|
||||
{{* écritures de crédit *}}
|
||||
{{#foreach from=$linked_immos item="line"}}
|
||||
{{if ! $_POST.credit_id|has:$line.trans_id}}
|
||||
{{:assign var="docs_to_remove." value=$line.doc}}
|
||||
{{:assign var="links_to_remove." value=$line.trans_id}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
|
||||
{{if $docs_to_remove != null}}
|
||||
{{:assign remove_set=$docs_to_remove|implode:","}}
|
||||
{{:assign remove_set="("|cat:$remove_set|cat:")"}}
|
||||
{{:delete where="id IN %s"|args:$remove_set}}
|
||||
|
||||
{{* idem avec acc_transactions_links *}}
|
||||
{{#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 = $ligne_immo.trans_id
|
||||
}}
|
||||
{{if ! $linked_id|in:$links_to_remove}}
|
||||
{{:assign var="linked_transactions." value=$linked_id}}
|
||||
{{/if}}
|
||||
{{/select}}
|
||||
|
||||
{{* Enregistrer les liaisons *}}
|
||||
{{:api
|
||||
method="POST"
|
||||
path="accounting/transaction/%s/transactions"|args:$ligne_immo.trans_id
|
||||
assign="result"
|
||||
assign_code="result_code"
|
||||
transactions=$linked_transactions
|
||||
}}
|
||||
{{/if}}
|
||||
|
||||
{{* enregistrer les infos de l'immobilisation *}}
|
||||
{{:save
|
||||
key=$info_immo.key
|
||||
|
|
@ -112,14 +148,17 @@
|
|||
|
||||
{{:assign type_immo="managed"}}
|
||||
{{:redirect force="amortization.html?immo_doc_id=%s&type_immo=%s&ok=1&msg=modif"|args:$_GET.immo_doc_id:$type_immo}}
|
||||
|
||||
{{/form}}
|
||||
|
||||
{{:admin_header title="Modifier l'immobilisation" custom_css="./style.css" current="module_amortization"}}
|
||||
{{if ! $dialog}}
|
||||
{{:include file="_nav.html" current="managed" subcurrent="modify_infos"}}
|
||||
{{:include file="_nav.html" current="index" subcurrent="%s"|args:$_GET.type_immo subsubcurrent="parameter"}}
|
||||
{{/if}}
|
||||
{{:form_errors}}
|
||||
|
||||
{{:assign choix_defaut=$_GET.type_immo}}
|
||||
|
||||
{{*
|
||||
modifier la date de mise en service, les écritures associées ou la durée d'amortissement
|
||||
*}}
|
||||
|
|
@ -147,16 +186,16 @@
|
|||
|
||||
<form method="post" action="">
|
||||
<fieldset>
|
||||
<legend>Informations</legend>
|
||||
<legend>Paramètres de l'amortissement</legend>
|
||||
<dl>
|
||||
{{:input type="number" name="duree" label="Durée d'amortissement" min=1 default=$info_immo.duration suffix="année(s)"}}
|
||||
{{if $info_immo.amount != null}}
|
||||
{{:assign max_aff="%f"|math:$max_disponible|money_currency:false}}
|
||||
{{:input type="money" name="montant" label="Montant de l'immobilisation" default=$montant_immo help="Montant maximum : %s"|args:$max_aff}}
|
||||
{{/if}}
|
||||
{{:input type="date" name="date_achat" label="Date d'acquisition" default=$date_achat_defaut help="si différente de la date de l'écriture d'immobilisation"}}
|
||||
{{:input type="date" name="date_mes" label="Date de mise en service" default=$date_mes_defaut help="si différente de la date d'acquisition"}}
|
||||
{{:input type="text" name="libelle" label="Libellé" default=$immo_label help="si différent du libellé de l'écriture d'immobilisation"}}
|
||||
{{:input type="date" name="date_achat" label="Date d'acquisition" default=$info_immo.date_achat help="si différente de la date de l'écriture d'immobilisation"}}
|
||||
{{:input type="date" name="date_mes" label="Date de mise en service" default=$info_immo.date_mes help="si différente de la date d'acquisition"}}
|
||||
{{:input type="text" name="libelle" label="Libellé" default=$info_immo.label help="si différent du libellé de l'écriture d'immobilisation"}}
|
||||
</dl>
|
||||
</fieldset>
|
||||
<p class="submit">
|
||||
|
|
@ -165,11 +204,3 @@
|
|||
</form>
|
||||
|
||||
{{:admin_footer}}
|
||||
|
||||
<script type="text/javascript">
|
||||
(function () {
|
||||
document.getElementById('f_date_achat').addEventListener("change", (e) => {
|
||||
document.getElementById('f_date_mes').value = document.getElementById('f_date_achat').value;
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
name="Amortissements"
|
||||
description="Immobilisations et amortissements\nversion 0.41.2"
|
||||
description="Immobilisations et amortissements\nversion 0.32"
|
||||
author="Jean-Christophe Engel"
|
||||
author_url="https://gitea.zaclys.com/lesanges"
|
||||
home_button=false
|
||||
|
|
|
|||
|
|
@ -11,37 +11,26 @@
|
|||
{{:error message=$message}}
|
||||
{{/if}}
|
||||
|
||||
{{:assign montant_immo=$info_immo.amount|or:$ligne_immo.amount}}
|
||||
{{:assign label_immo=$info_immo.label|or:$ligne_immo.trans_label}}
|
||||
{{if $label_immo|strpos:$ligne_immo.line_label === false}}
|
||||
{{if $ligne_immo.line_label != null && $ligne_immo.line_label != $label_immo}}
|
||||
{{:assign label_immo=$label_immo|cat:" — "|cat:$ligne_immo.line_label}}
|
||||
{{/if}}
|
||||
{{:assign date_mes=$info_immo.date_mes|or:$info_immo.date_achat|or:$ligne_immo.date_achat}}
|
||||
|
||||
{{* déduire le montant des écritures liées à l'immo courante au crédit du même compte *}}
|
||||
{{:include file="_get_credit_lines.html" immo_doc_id=$_GET.immo_doc_id keep="linked_immos, total_credits"}}
|
||||
{{:assign montant_immo="%d-%d"|math:$montant_immo:$total_credits}}
|
||||
|
||||
{{* déterminer le compte d'amortissement en fonction du compte d'immobilisation *}}
|
||||
{{:include
|
||||
{{if $_GET.filter}}
|
||||
{{* déterminer le compte d'amortissement en fonction du compte d'immobilisation *}}
|
||||
{{:include
|
||||
file="./_get_amort_code.html"
|
||||
code_immo=$ligne_immo.account_code
|
||||
keep="code_amort"
|
||||
}}
|
||||
{{if $_GET.filter}}
|
||||
{{:assign amort_account=$code_amort|quote_sql}}
|
||||
{{:assign filter_condition="account.code = "|cat:$amort_account}}
|
||||
}}
|
||||
{{:assign filter_condition="account.code = "|cat:$code_amort}}
|
||||
{{else}}
|
||||
{{:assign account_filter="28%"|quote_sql}}
|
||||
{{:assign filter_condition="account.code LIKE "|cat:$account_filter}}
|
||||
{{/if}}
|
||||
|
||||
{{:assign date_amort=$date_mes|quote_sql}}
|
||||
{{:assign date_condition="trans.date >= "|cat:$date_amort}}
|
||||
{{:assign condition=$date_condition|cat:" AND "|cat:$filter_condition}}
|
||||
|
||||
{{* lister les amortissements non rattachés à une immo *}}
|
||||
{{:include file="./_get_free_amort.html" condition=$condition keep="free_amort_lines"}}
|
||||
{{:include file="./_get_free_amort.html" filter_condition=$filter_condition keep="free_amort_lines"}}
|
||||
|
||||
{{:admin_header title="Amortissements non rattachés" custom_css="./style.css" current="module_amortization"}}
|
||||
|
||||
|
|
@ -49,8 +38,9 @@
|
|||
{{if ! $dialog}}
|
||||
{{:include
|
||||
file="_nav.html"
|
||||
current="managed"
|
||||
subcurrent="amortization"
|
||||
current="index"
|
||||
subcurrent="managed"
|
||||
subsubcurrent="amortization"
|
||||
type_immo="managed"
|
||||
autres_amort=$free_amort_lines
|
||||
}}
|
||||
|
|
@ -59,32 +49,21 @@
|
|||
<nav class="tabs">
|
||||
<ul>
|
||||
<li {{if $_GET.filter}}class="current"{{/if}}>
|
||||
<a href="other_amortizations.html?immo_doc_id={{$_GET.immo_doc_id}}{{if $dialog}}&_dialog{{/if}}&filter=true&from={{$_GET.from}}">
|
||||
<a href="other_amortizations.html?immo_doc_id={{$_GET.immo_doc_id}}{{if $dialog}}&_dialog{{/if}}&filter=true">
|
||||
Amortissements du compte {{$code_amort}}
|
||||
</a>
|
||||
</li>
|
||||
<li {{if ! $_GET.filter}}class="current"{{/if}}>
|
||||
<a href="other_amortizations.html?immo_doc_id={{$_GET.immo_doc_id}}{{if $dialog}}&_dialog{{/if}}&from={{$_GET.from}}">
|
||||
<a href="other_amortizations.html?immo_doc_id={{$_GET.immo_doc_id}}{{if $dialog}}&_dialog{{/if}}">
|
||||
Tous les amortissements
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$ligne_immo.trans_id}}
|
||||
<section class="amortissement">
|
||||
<div class="informations">
|
||||
<dl class="describe">
|
||||
<dt>Immobilisation</dt>
|
||||
<dd><span class="num"><a href="{{$trans_url}}">#{{$ligne_immo.trans_id}}</a></span> {{$label_immo}}</dd>
|
||||
<dt>Montant</dt>
|
||||
<dd class="money strong">{{"%f"|math:$montant_immo|money_currency_html:false|raw}}</dd>
|
||||
<dt>Début d'amortissement</dt>
|
||||
<dd>{{$date_mes|date_short}}</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
{{if $free_amort_lines != null}}
|
||||
{{if $free_amort_lines != null}}
|
||||
<section class="amortissement">
|
||||
<h3 class="ruler">Immobilisation « {{$label_immo}} »</h3>
|
||||
<table class="list">
|
||||
<thead>
|
||||
<tr>
|
||||
|
|
@ -99,6 +78,11 @@
|
|||
</thead>
|
||||
<tbody>
|
||||
{{#foreach from=$free_amort_lines item="line"}}
|
||||
{{*
|
||||
{{if $_GET.filter && $line.account_code != $code_amort}}
|
||||
{{:continue}}
|
||||
{{/if}}
|
||||
*}}
|
||||
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$line.trans_id}}
|
||||
{{:assign compte_url="%s/acc/accounts/journal.php?id=%s&year=%s"|args:$admin_url:$line.account_id:$line.year}}
|
||||
<tr>
|
||||
|
|
@ -117,18 +101,30 @@
|
|||
<td class="money">{{"%f"|math:$line.amount|money_html:false|raw}}</td>
|
||||
<td><a href="{{$compte_url}}">{{$line.account_code}}</a></td>
|
||||
<td>{{$line.account_label}}</td>
|
||||
<td class="actions">
|
||||
{{:linkbutton label="Attacher" href="attach_amort.html?immo_doc_id=%s&amort_line_id=%s&from=%s"|args:$_GET.immo_doc_id:$line.line_id:$_GET.from shape="plus"}}
|
||||
<td>
|
||||
{{:linkbutton label="Attacher" href="attach_amort.html?immo_doc_id=%s&amort_line_id=%s"|args:$_GET.immo_doc_id:$line.line_id shape="plus"}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/foreach}}
|
||||
</tbody>
|
||||
<p class="help">Sélectionner une écriture d'amortissement pour l'associer à l'immobilisation</p>
|
||||
</table>
|
||||
{{else}}
|
||||
</section>
|
||||
{{else}}
|
||||
<p class="block alert">Aucun amortissement pour le compte {{$code_amort}}</p>
|
||||
{{/if}}
|
||||
</section>
|
||||
{{/if}}
|
||||
|
||||
|
||||
{{:form_errors}}
|
||||
{{:admin_footer}}
|
||||
|
||||
<script type="text/javascript">
|
||||
function changeVisibility(evt, idcheck = 'f_unhide_1') {
|
||||
this.form.dispatchEvent(new Event('submit'));
|
||||
this.form.submit();
|
||||
}
|
||||
|
||||
(function () {
|
||||
document.getElementById('f_unhide_1').onclick = changeVisibility;
|
||||
})();
|
||||
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -41,11 +41,6 @@
|
|||
{{:assign amort_label=$line_label|or:$trans_label}}
|
||||
{{/foreach}}
|
||||
|
||||
{{* date de début du 1er exercice dans paheko *}}
|
||||
{{#years order="start_date" limit=1}}
|
||||
{{:assign first_date=$start_date}}
|
||||
{{/years}}
|
||||
|
||||
{{if $total_amort == 0}}
|
||||
{{* 1er amortissement *}}
|
||||
{{* déterminer le compte d'amortissement en fonction du compte d'immobilisation *}}
|
||||
|
|
@ -60,10 +55,8 @@
|
|||
{{:assign var=libelle value="Amortissement %s"|args:$ligne_immo.trans_label}}
|
||||
{{else}}
|
||||
{{* amortissements suivants *}}
|
||||
{{if $date_debut != $first_date}}
|
||||
{{:assign date_debut=$date_debut|strtotime}}
|
||||
{{:assign date_debut="%d+(60*60*24)"|math:$date_debut|date:"Y-m-d"}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
{{*
|
||||
|
|
@ -72,7 +65,7 @@
|
|||
*}}
|
||||
{{:assign msg_years=""}}
|
||||
{{#years closed=false order="start_date" where="start_date <= :debut AND :debut <= end_date"
|
||||
:debut=$date_debut assign="years."}}
|
||||
:debut=$date_debut assign=years.}}
|
||||
{{if $total_amort == 0}}
|
||||
{{:assign ts_debut=$date_debut|strtotime}}
|
||||
{{else}}
|
||||
|
|
@ -155,12 +148,6 @@
|
|||
{{:error message="Le montant indiqué « %s » dépasse le solde à amortir « %s »"|args:$montant:$solde}}
|
||||
{{/if}}
|
||||
|
||||
{{*
|
||||
supprimer les documents qui pointent sur une ligne d'amortissement absente
|
||||
cas de la suppression manuelle d'un amortissement
|
||||
*}}
|
||||
{{:include file="_remove_orphan_docs.tpl"}}
|
||||
|
||||
{{* enregistrer l'écriture *}}
|
||||
{{:assign
|
||||
var="lines."
|
||||
|
|
@ -174,6 +161,7 @@
|
|||
account=$credit_account|keys|value:0
|
||||
id_project=$ligne_immo.id_project
|
||||
}}
|
||||
|
||||
{{:api
|
||||
method="POST"
|
||||
path="accounting/transaction"
|
||||
|
|
@ -203,36 +191,32 @@
|
|||
|
||||
{{* immo soldée ? *}}
|
||||
{{if $_POST.montant|trim|money_int == $solde}}
|
||||
{{:assign status="amortized"}}
|
||||
{{:assign var="info_immo.status" value="amortized"}}
|
||||
{{:save
|
||||
key=$info_immo.key
|
||||
status=$status
|
||||
status=$info_immo.status
|
||||
}}
|
||||
{{/if}}
|
||||
|
||||
{{:redirect force="amortization.html?immo_doc_id=%s&type_immo=%s&ok=1&msg=amortissement"|args:$_GET.immo_doc_id:$status}}
|
||||
{{:redirect force="amortization.html?immo_doc_id=%s&type_immo=%s&ok=1&msg=amortissement"|args:$_GET.immo_doc_id:$info_immo.status}}
|
||||
{{/form}}
|
||||
|
||||
{{:assign label_immo=$info_immo.label|or:$ligne_immo.trans_label}}
|
||||
|
||||
{{:admin_header title="Amortissement pour « %s »"|args:$label_immo custom_css="./style.css" current="module_amortization"}}
|
||||
{{:admin_header title="Ajout amortissement" custom_css="./style.css" current="module_amortization"}}
|
||||
|
||||
{{* barre de navigation *}}
|
||||
{{if ! $dialog}}
|
||||
{{:include file="_nav.html" current="managed" subcurrent="amortization"}}
|
||||
{{:include file="_nav.html" current="index" subcurrent="managed" subsubcurrent="amortization"}}
|
||||
{{/if}}
|
||||
|
||||
{{:form_errors}}
|
||||
|
||||
{{if $years|count == 1}}
|
||||
{{:assign var=selected_year value=$years.0.id}}
|
||||
{{:assign var=date_amort value=$years.0.end_date}}
|
||||
{{:include file="_calcul_dates.html" date_debut=$date_debut date_fin=$date_amort keep="nbjours"}}
|
||||
{{* montant de l'amortissement *}}
|
||||
{{:assign montant_amort="%f/%f/365*%d"|math:$ligne_immo.amount:$info_immo.duration:$nbjours|intval}}
|
||||
{{:assign montant_amort="min(%f, %d-%d)"|math:$montant_amort:$ligne_immo.amount:$total_amort}}
|
||||
{{/if}}
|
||||
{{:assign var=selected_year value=$years.0.id}}
|
||||
{{:assign var=date_amort value=$years.0.end_date}}
|
||||
{{:include file="_calcul_dates.html" date_debut=$date_debut date_fin=$date_amort keep="nbjours"}}
|
||||
|
||||
{{* montant de l'amortissement *}}
|
||||
{{:assign montant_amort="%f/%f/365*%d"|math:$ligne_immo.amount:$info_immo.duration:$nbjours|intval}}
|
||||
{{:assign montant_amort="min(%f, %d-%d)"|math:$montant_amort:$ligne_immo.amount:$total_amort}}
|
||||
{{:assign var="debit_account.6811" value="6811 — Dot. aux amortissements des immobilisations"}}
|
||||
{{:assign var="credit_account.%s"|args:$code_amort value="%s — "|args:$code_amort|cat:$amort_account_label}}
|
||||
|
||||
|
|
@ -249,10 +233,7 @@
|
|||
{{:input type="select" default=$selected_year name="id_year" label="Exercice" required=true default_empty="— Faire un choix —" options=$open_years}}
|
||||
{{:input type="date" name="date_amort" label="Date" required=true default=$date_amort|date_short}}
|
||||
{{:input type="text" name="designation" label="Libellé" required=true default=$amort_label size="50"}}
|
||||
{{if $total_amort == 0 || $nbjours < 365 || $nbjours > 366}}
|
||||
{{:assign msg="Montant calculé au prorata du nombre de jours d'amortissement dans l'exercice"}}
|
||||
{{/if}}
|
||||
{{:input type="money" name="montant" label="Montant" required=true default=$montant_amort help=$msg}}
|
||||
{{:input type="money" name="montant" label="Montant" required=true default=$montant_amort}}
|
||||
{{:input
|
||||
type="list"
|
||||
name="debit_account"
|
||||
|
|
|
|||
33
scripts.js
33
scripts.js
|
|
@ -12,10 +12,9 @@ function toggleInputs(idcb, idfields) {
|
|||
}
|
||||
}
|
||||
|
||||
function toggleVisibility(id_check, fields) {
|
||||
const elem = document.getElementById(id_check);
|
||||
fields.forEach(function (id_field) {
|
||||
const field = document.getElementById(id_field);
|
||||
function toggleVisibility(idcheck, fields) {
|
||||
const elem = document.getElementById(idcheck);
|
||||
fields.forEach(function (field) {
|
||||
if (elem.checked) {
|
||||
field.classList.remove('hidden');
|
||||
} else {
|
||||
|
|
@ -145,8 +144,7 @@ function setSelectorYear(button_names, f_years_selector)
|
|||
|
||||
// Associer au bouton « Enlever » de chaque ligne l'action de suppression de la ligne
|
||||
function initLine(row) {
|
||||
let removeBtn = row.querySelector('button[name="remove_line"]');
|
||||
if (removeBtn != null) {
|
||||
var removeBtn = row.querySelector('button[name="remove_line"]');
|
||||
removeBtn.onclick = () => {
|
||||
let count = removeBtn.closest("table").querySelectorAll('tbody tr').length;
|
||||
var min = removeBtn.getAttribute('min');
|
||||
|
|
@ -159,7 +157,6 @@ function initLine(row) {
|
|||
row.parentNode.removeChild(row);
|
||||
return true;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Associer au bouton « Ajouter » de chaque table l'action d'ajouter une ligne
|
||||
|
|
@ -187,28 +184,6 @@ function addLine(button, codes) {
|
|||
let lib = newNode.querySelector('.input-list span.label');
|
||||
lib.innerText = '';
|
||||
|
||||
// si besoin, ajouter le bouton de suppression
|
||||
let action_cell = newNode.querySelector('td.actions');
|
||||
let removeBtn = newNode.querySelector('button[name="remove_line"]');
|
||||
if (removeBtn == null) {
|
||||
const attributs = {
|
||||
"title" : "Enlever une ligne",
|
||||
"min": "1",
|
||||
"name": "remove_line",
|
||||
"data-icon": "➖",
|
||||
"type": "button",
|
||||
"class": "icn-btn",
|
||||
"value": "1",
|
||||
"aria-label": "Enlever une ligne"
|
||||
};
|
||||
let new_button = document.createElement("button");
|
||||
new_button.appendChild(document.createTextNode("Enlever"));
|
||||
for (let attr in attributs) {
|
||||
new_button.setAttribute(attr, attributs[attr]);
|
||||
}
|
||||
action_cell.appendChild(new_button);
|
||||
}
|
||||
|
||||
// ajouter la nouvelle ligne
|
||||
line.parentNode.appendChild(newNode);
|
||||
initLine(newNode);
|
||||
|
|
|
|||
24
style.css
24
style.css
|
|
@ -74,13 +74,25 @@ table.list tbody tr.ignored:nth-child(even) {
|
|||
font-style: italic;
|
||||
background: rgba(255, 255, 200, 0.5);
|
||||
}
|
||||
|
||||
table.error {
|
||||
background-color: #fcc;
|
||||
html.dark table.list tbody tr.ignored:nth-child(odd) {
|
||||
font-style: italic;
|
||||
background: rgba(100, 100, 0, 0.4);
|
||||
}
|
||||
table.error tr, table.error td, table.error thead td {
|
||||
background-image : none;
|
||||
background-color: #fcc;
|
||||
html.dark table.list tbody tr.ignored:nth-child(even) {
|
||||
font-style: italic;
|
||||
background: rgba(100, 100, 0, 0.4);
|
||||
}
|
||||
|
||||
html.dialog.dark {
|
||||
filter: none !important;
|
||||
}
|
||||
|
||||
html.dialog.dark main {
|
||||
background-color : #ddd;
|
||||
}
|
||||
|
||||
html.dark .block.alert {
|
||||
background-color : rgba(87, 206, 235, 0.5);
|
||||
}
|
||||
|
||||
span.input-list.avoirs label {
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@
|
|||
{{:assign trans_list=$trans_list|implode:","}}
|
||||
{{:assign trans_list="("|cat:$trans_list|cat:")"}}
|
||||
{{:assign condition=$condition|cat:" AND trans.id IN "|cat:$trans_list}}
|
||||
{{:assign condition=$condition|cat:" AND NOT (trans.status & 16)"}}
|
||||
|
||||
{{#select
|
||||
trans.id as trans_id,
|
||||
|
|
@ -55,7 +56,6 @@
|
|||
}}
|
||||
{{:assign var="transactions.%s"|args:$trans_id
|
||||
amount=$line_debit
|
||||
line_label=$trans_label
|
||||
date=$trans_date
|
||||
code=$account_code
|
||||
label=$account_label
|
||||
|
|
@ -181,7 +181,6 @@
|
|||
duration=$duration
|
||||
date_mes=null
|
||||
status=$status
|
||||
created=true
|
||||
}}
|
||||
{{if $_POST.amortir}}
|
||||
{{:assign type_immo="managed"}}
|
||||
|
|
@ -193,7 +192,7 @@
|
|||
|
||||
{{:admin_header title="Transfert d'immobilisation en cours" custom_css="./style.css" current="module_amortization"}}
|
||||
{{if ! $dialog}}
|
||||
{{:include file="_nav.html" current="unfinished" subcurrent="transfer"}}
|
||||
{{:include file="_nav.html" current="index" subcurrent="unfinished" subsubcurrent="transfer"}}
|
||||
{{/if}}
|
||||
|
||||
{{:form_errors}}
|
||||
|
|
@ -265,7 +264,7 @@
|
|||
</td>
|
||||
<td>{{:input name="credit_lines[]" type="text" class="money" size="8" default=$amount|money}}</td>
|
||||
<td>{{:input name="debit_lines[]" type="text" class="money" size="8" disabled=true}}</td>
|
||||
<td>{{:input type="text" name="line_labels[]" size="40" default=$line_label}}</td>
|
||||
<td>{{:input type="text" name="line_labels[]" size="40"}}</td>
|
||||
<td>
|
||||
{{if $projects != null}}
|
||||
{{:input type="select" name="id_project" options=$projects default_empty="— Aucun —"}}
|
||||
|
|
|
|||
120
write_exit.html
120
write_exit.html
|
|
@ -4,6 +4,7 @@
|
|||
Enregistrer les écritures de sortie du bilan
|
||||
paramètres :
|
||||
- immo_doc_id : id du doc associé à l'immobilisation
|
||||
- amort_amount : montant des amortissements
|
||||
- year : exercice de la date de sortie de l'immobilisation
|
||||
- date_debut : date de début de la période d'amortissement complémentaire
|
||||
- exit_date : date de sortie de l'immobilisation
|
||||
|
|
@ -16,27 +17,10 @@
|
|||
{{:error message=$message}}
|
||||
{{/if}}
|
||||
|
||||
{{:assign label_immo=$info_immo.label|or:$ligne_immo.trans_label}}
|
||||
{{if $label_immo|strpos:$ligne_immo.line_label === false}}
|
||||
{{:assign label_immo=$label_immo|cat:" — "|cat:$ligne_immo.line_label}}
|
||||
{{/if}}
|
||||
|
||||
{{:assign date_achat=$info_immo.date_achat|or:$ligne_immo.date_achat}}
|
||||
{{if $info_immo.date_mes != null && $info_immo.date_mes != $date_achat}}
|
||||
{{:assign date_mes=$info_immo.date_mes}}
|
||||
{{/if}}
|
||||
|
||||
{{if $info_immo.amount != null}}
|
||||
{{:assign var="ligne_immo.amount" value=$info_immo.amount}}
|
||||
{{/if}}
|
||||
|
||||
{{* déduire le montant des écritures liées à l'immo courante au crédit du même compte *}}
|
||||
{{:include file="_get_credit_lines.html" immo_doc_id=$_GET.immo_doc_id keep="total_credits"}}
|
||||
{{:assign var="ligne_immo.amount" value="%d-%d"|math:$ligne_immo.amount:$total_credits}}
|
||||
|
||||
{{* lister les amortissements liés à l'immobilisation *}}
|
||||
{{:include file="./_get_amort_lines.html" immo_doc_id=$_GET.immo_doc_id keep="linked_amort, sommes_amort, total_amort"}}
|
||||
{{:assign valeur_nette="%f-%f"|math:$ligne_immo.amount:$total_amort}}
|
||||
{{:assign valeur_nette="%f-%f"|math:$ligne_immo.amount:$_GET.amort_amount}}
|
||||
|
||||
{{:assign amort_comp=0}} {{* amortissement complémentaire jqà date sortie *}}
|
||||
{{:assign amort_except=0}} {{* amortissement exceptionnel jqà date fin amortissement *}}
|
||||
|
|
@ -47,7 +31,7 @@
|
|||
{{:assign amort_comp="min(%f, %f)"|math:$valeur_nette:$amort_comp}}
|
||||
|
||||
{{if $_GET.cession == null}}
|
||||
{{:assign amort_except="%f-%f-%f"|math:$ligne_immo.amount:$total_amort:$amort_comp}}
|
||||
{{:assign amort_except="%f-%f-%f"|math:$ligne_immo.amount:$_GET.amort_amount:$amort_comp}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
|
|
@ -60,14 +44,20 @@
|
|||
{{* numéros de comptes ; voir info.org *}}
|
||||
{{:assign vnc_code="652"}}
|
||||
{{:assign cession_code="757"}}
|
||||
{{:include
|
||||
file="./_get_amort_code.html"
|
||||
code_immo=$ligne_immo.account_code
|
||||
keep="code_amort"
|
||||
}}
|
||||
|
||||
{{* TODO : faut-il forcer les 3 sélecteurs de compte d'amortissement à avoir toujours la même valeur ? *}}
|
||||
|
||||
{{* Traiter l'envoi du formulaire *}}
|
||||
{{#form on="save"}}
|
||||
{{*
|
||||
{{if $_POST.amort_comp_account != null}
|
||||
{{:assign account=$_POST.amort_comp_account}}
|
||||
{{elseif $_POST.amort_except_account != null}
|
||||
{{:assign account=$_POST.amort_except_account}}
|
||||
{{elseif $_POST.amort_sortie_account != null}
|
||||
{{:assign account=$_POST.amort_sortie_account}}
|
||||
{{/if}}
|
||||
*}}
|
||||
{{:assign account=$_POST.amort_sortie_account}}
|
||||
|
||||
{{:include
|
||||
|
|
@ -88,7 +78,7 @@
|
|||
}}
|
||||
{{:assign comp_account_code=$account_code|keys|value:0}}
|
||||
|
||||
{{:assign libelle="Amortissement complémentaire "|cat:$label_immo}}
|
||||
{{:assign libelle="Amortissement complémentaire "|cat:$ligne_immo.trans_label}}
|
||||
{{:assign
|
||||
var="lines."
|
||||
debit="%f/100"|math:$amort_comp
|
||||
|
|
@ -99,7 +89,7 @@
|
|||
{{:assign
|
||||
var="lines."
|
||||
credit="%f/100"|math:$amort_comp
|
||||
account=$code_amort|intval
|
||||
account=$amort_account_code
|
||||
id_project=$ligne_immo.id_project
|
||||
label=$libelle
|
||||
}}
|
||||
|
|
@ -113,7 +103,7 @@
|
|||
keep="account_code"
|
||||
}}
|
||||
{{:assign except_account_code=$account_code|keys|value:0}}
|
||||
{{:assign libelle="Amortissement exceptionnel "|cat:$label_immo}}
|
||||
{{:assign libelle="Amortissement exceptionnel "|cat:$ligne_immo.trans_label}}
|
||||
{{:assign
|
||||
var="lines."
|
||||
debit="%f/100"|math:$amort_except
|
||||
|
|
@ -124,7 +114,7 @@
|
|||
{{:assign
|
||||
var="lines."
|
||||
credit="%f/100"|math:$amort_except
|
||||
account=$code_amort|intval
|
||||
account=$amort_account_code
|
||||
id_project=$ligne_immo.id_project
|
||||
label=$libelle
|
||||
}}
|
||||
|
|
@ -139,20 +129,19 @@
|
|||
id_year=$_GET.year
|
||||
type="advanced"
|
||||
date=$_GET.exit_date
|
||||
label="Amortissement final "|cat:$label_immo
|
||||
label="Amortissement final "|cat:$ligne_immo.trans_label
|
||||
lines=$lines
|
||||
linked_transactions=$ligne_immo.trans_id
|
||||
}}
|
||||
|
||||
{{* liaisons lignes d'amortissement *}}
|
||||
{{#foreach from=$result.lines item="line"}}
|
||||
{{if $line.account_code == $code_amort}}
|
||||
{{if $line.account_code == $amort_account_code}}
|
||||
{{:save
|
||||
key=""|uuid
|
||||
type="amort_link"
|
||||
immo_doc_id=$info_immo.id
|
||||
amort_line_id=$line.id
|
||||
created=true
|
||||
}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
|
|
@ -166,7 +155,7 @@
|
|||
keep="account_code"
|
||||
}}
|
||||
{{:assign immo_account_code=$account_code|keys|value:0}}
|
||||
{{:assign libelle="Sortie du bilan de "|cat:$label_immo}}
|
||||
{{:assign libelle="Sortie du bilan de "|cat:$ligne_immo.trans_label}}
|
||||
{{:assign
|
||||
var="lines."
|
||||
account=$immo_account_code
|
||||
|
|
@ -174,20 +163,13 @@
|
|||
id_project=$ligne_immo.id_project
|
||||
label=$libelle
|
||||
}}
|
||||
{{* amortissements *}}
|
||||
{{#foreach from=$sommes_amort key="code" item="montant"}}
|
||||
{{if $code == $code_amort}}
|
||||
{{* amortissements complémentaire et exceptionnel *}}
|
||||
{{:assign montant="(%d+%d+%d)"|math:$montant:$amort_comp:$amort_except}}
|
||||
{{/if}}
|
||||
{{:assign
|
||||
var="lines."
|
||||
account=$code
|
||||
debit="%d/100"|math:$montant
|
||||
account=$amort_account_code
|
||||
debit="(%f-%f)/100"|math:$ligne_immo.amount:$valeur_nette
|
||||
id_project=$ligne_immo.id_project
|
||||
label=$libelle
|
||||
}}
|
||||
{{/foreach}}
|
||||
{{if $valeur_nette > 0}}
|
||||
{{:include
|
||||
file="_get_codes.html"
|
||||
|
|
@ -225,7 +207,6 @@
|
|||
type="exit_link"
|
||||
immo_doc_id=$info_immo.id
|
||||
exit_line_id=$line.id
|
||||
created=true
|
||||
}}
|
||||
{{:break}}
|
||||
{{/if}}
|
||||
|
|
@ -233,7 +214,7 @@
|
|||
|
||||
{{if $montant_cession > 0}}
|
||||
{{* Cession de l'immobilisation *}}
|
||||
{{:assign libelle="Cession "|cat:$label_immo}}
|
||||
{{:assign libelle="Produit cession "|cat:$ligne_immo.trans_label}}
|
||||
{{:include
|
||||
file="_get_codes.html"
|
||||
account=$_POST.creance_account
|
||||
|
|
@ -271,7 +252,6 @@
|
|||
type="cession_link"
|
||||
immo_doc_id=$info_immo.id
|
||||
cession_line_id=$line.id
|
||||
created=true
|
||||
}}
|
||||
{{:break}}
|
||||
{{/if}}
|
||||
|
|
@ -287,12 +267,7 @@
|
|||
|
||||
{{:admin_header title="Sortie du bilan" custom_css="./style.css" current="module_amortization"}}
|
||||
{{if ! $dialog}}
|
||||
{{if $valeur_nette > 0}}
|
||||
{{:assign type_immo="managed"}}
|
||||
{{else}}
|
||||
{{:assign type_immo="amortized"}}
|
||||
{{/if}}
|
||||
{{:include file="_nav.html" current="%s"|args:$type_immo subcurrent="balance_exit"}}
|
||||
{{:include file="_nav.html" current="index" subcurrent="balance_exit"}}
|
||||
{{/if}}
|
||||
|
||||
{{*
|
||||
|
|
@ -300,12 +275,16 @@
|
|||
déterminer les comptes pour les différentes écritures
|
||||
*}}
|
||||
|
||||
{{:include
|
||||
file="./_get_amort_code.html"
|
||||
code_immo=$ligne_immo.account_code
|
||||
keep="code_amort"
|
||||
}}
|
||||
|
||||
{{:assign var="liste_codes.6811" name="comp_account"}}
|
||||
{{:assign var="liste_codes.687" name="except_account"}}
|
||||
{{:assign var="liste_codes.462" name="creance_account"}}
|
||||
{{#foreach from=$sommes_amort key="code"}}
|
||||
{{:assign var="liste_codes.%s"|args:$code name="amort_account"}}
|
||||
{{/foreach}}
|
||||
{{:assign var="liste_codes.%s"|args:$code_amort name="amort_account"}}
|
||||
{{:assign var="liste_codes.%s"|args:$ligne_immo.account_code name="immo_account"}}
|
||||
{{:assign var="liste_codes.%s"|args:$vnc_code name="vnc_account"}}
|
||||
{{:assign var="liste_codes.%s"|args:$cession_code name="cession_account"}}
|
||||
|
|
@ -346,23 +325,24 @@
|
|||
{{/foreach}}
|
||||
{{:assign patterns=$pattern_array|implode:"|"}}
|
||||
|
||||
<h3>Sortir l'immobilisation « {{$label_immo}} » du bilan</h3>
|
||||
<h3>Sortir l'immobilisation « {{$ligne_immo.trans_label}} » du bilan</h3>
|
||||
<form method="post" action="">
|
||||
|
||||
<div class="informations">
|
||||
<legend>Données de l'imobilisation</legend>
|
||||
<dl class="describe">
|
||||
<dt>Montant</dt>
|
||||
<dd class="money">{{$ligne_immo.amount|money_currency_html:false|raw}}</dd>
|
||||
<dt>Date d'acquisition</dt>
|
||||
<dd >{{$date_achat|date_short}}</dd>
|
||||
{{if $date_mes != null}}
|
||||
<dd >{{$ligne_immo.date_achat|date_short}}</dd>
|
||||
{{if $info_immo.date_mes != null && $info_immo.date_mes != $ligne_immo.date_achat}}
|
||||
<dt>Date de mise en service</dt>
|
||||
<dd>{{$date_mes|date_short}}</dd>
|
||||
<dd>{{$info_immo.date_mes|date_short}}</dd>
|
||||
{{/if}}
|
||||
<dt>Durée de l'amortissement</dt>
|
||||
<dd class="num">{{$info_immo.duration}} ans</dd>
|
||||
<dt>Montant des amortissements</dt>
|
||||
<dd class="money">{{$total_amort|money_currency_html:false|raw}} <span class="help">(à la date de début de l'exercice)</span></dd>
|
||||
<dd class="money">{{$_GET.amort_amount|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>
|
||||
<dt>Date de sortie</dt>
|
||||
|
|
@ -372,7 +352,7 @@
|
|||
<dt>Amortissement complémentaire</dt>
|
||||
<dd class="money">{{$amort_comp|money_currency_html:false|raw}} <span class="help">(jusqu'à la date de sortie)</span></dd>
|
||||
<dt>Total des amortissements</dt>
|
||||
<dd class="money">{{"%f+%f"|math:$total_amort:$amort_comp|money_currency_html:false|raw}} <span class="help">(à la date de sortie)</span></dd>
|
||||
<dd class="money">{{"%f+%f"|math:$_GET.amort_amount:$amort_comp|money_currency_html:false|raw}} <span class="help">(à la date de sortie)</span></dd>
|
||||
<dt>Valeur nette résiduelle</dt>
|
||||
<dd class="money">{{$valeur_nette|money_currency_html:false|raw}} <span class="help">(à la date de sortie)</span></dd>
|
||||
{{/if}}
|
||||
|
|
@ -392,7 +372,6 @@
|
|||
<legend>Écritures de sortie du bilan</legend>
|
||||
{{* Amortissement complémentaire *}}
|
||||
{{if $amort_comp > 0}}
|
||||
{{:assign var="account.%s"|args:$code from="amort_account.%s"|args:$code_amort}}
|
||||
<table class="list">
|
||||
<thead>
|
||||
<tr>
|
||||
|
|
@ -427,7 +406,7 @@
|
|||
name="amort_comp_account"
|
||||
target="!acc/charts/accounts/selector.php?codes=%s&id_chart=%s"|args:"28*":$chart_id
|
||||
readonly=true
|
||||
default=$account
|
||||
default=$amort_account
|
||||
}}
|
||||
</td>
|
||||
<td></td>
|
||||
|
|
@ -435,12 +414,10 @@
|
|||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
{{:assign account=null}}
|
||||
{{/if}}
|
||||
|
||||
{{* Amortissement exceptionnel *}}
|
||||
{{if $montant_cession == 0 && $amort_except > 0}}
|
||||
{{:assign var="account.%s"|args:$code from="amort_account.%s"|args:$code_amort}}
|
||||
<table class="list">
|
||||
<thead>
|
||||
<tr>
|
||||
|
|
@ -475,7 +452,7 @@
|
|||
name="amort_except_account"
|
||||
target="!acc/charts/accounts/selector.php?codes=%s&id_chart=%s"|args:"28*":$chart_id
|
||||
readonly=true
|
||||
default=$account
|
||||
default=$amort_account
|
||||
}}
|
||||
</td>
|
||||
<td></td>
|
||||
|
|
@ -483,7 +460,6 @@
|
|||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
{{:assign account=null}}
|
||||
{{/if}}
|
||||
|
||||
{{* Sortie du bilan *}}
|
||||
|
|
@ -496,8 +472,6 @@
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#foreach from=$sommes_amort key="code" item="montant"}}
|
||||
{{:assign var="account.%s"|args:$code from="amort_account.%s"|args:$code}}
|
||||
<tr>
|
||||
<td>
|
||||
{{:input
|
||||
|
|
@ -505,23 +479,17 @@
|
|||
name="amort_sortie_account"
|
||||
target="!acc/charts/accounts/selector.php?codes=%s&id_chart=%s"|args:"28*":$chart_id
|
||||
readonly=true
|
||||
default=$account
|
||||
default=$amort_account
|
||||
}}
|
||||
</td>
|
||||
{{if $montant_cession == 0}}
|
||||
{{if $code == $code_amort}}
|
||||
{{:assign montant="%f+%f+%f"|math:$montant:$amort_comp:$amort_except}}
|
||||
{{/if}}
|
||||
{{:assign montant=$ligne_immo.amount}}
|
||||
{{else}}
|
||||
{{if $code == $code_amort}}
|
||||
{{:assign montant="%f+%f"|math:$montant:$amort_comp}}
|
||||
{{/if}}
|
||||
{{:assign montant="%f+%f"|math:$_GET.amort_amount:$amort_comp}}
|
||||
{{/if}}
|
||||
<td>{{$montant|money_currency_html:false|raw}}</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
{{:assign account=null}}
|
||||
{{/foreach}}
|
||||
{{if $montant_cession > 0 && $valeur_nette > 0}}
|
||||
<tr>
|
||||
<td>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue