Prise en compte écritures BOI avec montant immo subdivisé
This commit is contained in:
parent
f8f4da59b6
commit
d5c62b6ef3
4 changed files with 329 additions and 319 deletions
|
|
@ -1,12 +1,12 @@
|
||||||
{{* -*- brindille -*- *}}
|
{{* -*- brindille -*- *}}
|
||||||
|
|
||||||
{{* Liste des immobilisations non amortissables ou non (encore) gérées *}}
|
{{* Liste des immobilisations non gérées ou non entièrement affectées *}}
|
||||||
|
|
||||||
{{:include file="_get_config.html" keep="module.config"}}
|
{{:include file="_get_config.html" keep="module.config"}}
|
||||||
<section class="immobilisation">
|
|
||||||
|
|
||||||
<p class="help">
|
<p class="help">
|
||||||
Cette page liste les écritures pas (encore) prises en charge par le module et sans écriture d'amortissement associée.
|
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>
|
</p>
|
||||||
|
|
||||||
{{:assign saved_hides=$module.config.hides}}
|
{{:assign saved_hides=$module.config.hides}}
|
||||||
|
|
@ -28,40 +28,21 @@
|
||||||
{{:assign checked="checked"}}
|
{{:assign checked="checked"}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
<form method="post" action="">
|
|
||||||
<fieldset>
|
|
||||||
{{:input type="checkbox" value=1 name="unhide" checked="%s"|args:$checked label="Afficher toutes les écritures" }}
|
|
||||||
</fieldset>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<table class="list">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th class="num">N°</th>
|
|
||||||
<th>Date</th>
|
|
||||||
<th>Libellé</th>
|
|
||||||
<th class="nombre">Montant</th>
|
|
||||||
<th>N° compte</th>
|
|
||||||
<th>Compte</th>
|
|
||||||
<th class="actions"></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
|
|
||||||
{{* vérifier l'existence de la table du module *}}
|
{{* vérifier l'existence de la table du module *}}
|
||||||
{{#load limit="1"}}
|
{{if $module.table != null}}
|
||||||
{{:assign columns="$$.duration as duration, $$.status as status,"}}
|
{{:assign columns="$$.status as status, SUM($$.amount) as amount,"}}
|
||||||
{{:assign table_join="LEFT JOIN !table AS info ON $$.line = line.id"}}
|
{{:assign table_join="LEFT JOIN !table AS info ON $$.line = line.id"}}
|
||||||
{{:assign doc_condition1="($$.status == 'ignored')"}}
|
{{:assign doc_condition="($$.status IS NULL OR $$.status == 'managed' OR $$.status == 'ignored')"}}
|
||||||
{{:assign doc_condition2="$$.status IS NULL"}}
|
|
||||||
{{else}}
|
{{else}}
|
||||||
{{:assign columns=""}}
|
{{:assign columns=""}}
|
||||||
{{:assign table_join=""}}
|
{{:assign table_join=""}}
|
||||||
{{:assign doc_condition1="0"}}
|
{{:assign doc_condition="1"}}
|
||||||
{{:assign doc_condition2="1"}}
|
{{/if}}
|
||||||
{{/load}}
|
|
||||||
|
|
||||||
{{* lister les immobilisations *}}
|
{{*
|
||||||
|
lister les immobilisations non prises en charge par le module
|
||||||
|
ou dont le montant n'a pas été totalement affecté
|
||||||
|
*}}
|
||||||
{{:assign account_condition="("}}
|
{{:assign account_condition="("}}
|
||||||
{{#foreach from=$module.config.prefixes item="code"}}
|
{{#foreach from=$module.config.prefixes item="code"}}
|
||||||
{{:assign code=$code|cat:"%"|quote_sql}}
|
{{:assign code=$code|cat:"%"|quote_sql}}
|
||||||
|
|
@ -79,11 +60,13 @@
|
||||||
{{else}}
|
{{else}}
|
||||||
{{:assign filter_condition="1"}}
|
{{:assign filter_condition="1"}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{:assign filter_condition="("|cat:$doc_condition2|cat:" AND NOT (trans.status & 16) AND "|cat:$filter_condition|cat:")"}}
|
|
||||||
|
|
||||||
{{:assign condition=$account_condition|cat:" AND debit > 0 AND ("|cat:$filter_condition|cat:" OR "|cat:$doc_condition1|cat:")"}}
|
{{:assign condition=$account_condition|cat:" AND debit > 0 AND NOT (trans.status & 16) AND "|cat:$filter_condition|cat:" AND "|cat:$doc_condition}}
|
||||||
|
|
||||||
{{:assign nb_immo=0}}
|
{{:assign nb_managed=0}}
|
||||||
|
{{:assign nb_ignored=0}}
|
||||||
|
{{:assign nb_null=0}}
|
||||||
|
{{:assign nb_other=0}}
|
||||||
{{#select
|
{{#select
|
||||||
trans.id as immo_trans_id,
|
trans.id as immo_trans_id,
|
||||||
trans.label as trans_label,
|
trans.label as trans_label,
|
||||||
|
|
@ -102,27 +85,67 @@
|
||||||
INNER JOIN acc_years AS years ON trans.id_year = years.id
|
INNER JOIN acc_years AS years ON trans.id_year = years.id
|
||||||
!table_join
|
!table_join
|
||||||
WHERE !condition
|
WHERE !condition
|
||||||
|
GROUP BY immo_line_id
|
||||||
ORDER BY trans.date DESC;
|
ORDER BY trans.date DESC;
|
||||||
!columns=$columns
|
!columns=$columns
|
||||||
!table_join=$table_join
|
!table_join=$table_join
|
||||||
!table=$module.table
|
!table=$module.table
|
||||||
!condition=$condition
|
!condition=$condition
|
||||||
|
assign="immo_line"
|
||||||
}}
|
}}
|
||||||
{{: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}}
|
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 $status == null}}
|
{{if $status == null}}
|
||||||
{{:assign status="unknown"}}
|
{{: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}}
|
||||||
|
|
||||||
|
{{:assign var="immo_lines." value=$immo_line}}
|
||||||
|
{{/select}}
|
||||||
|
{{*:debug lines=$immo_lines nb_lines=$immo_lines|count nb_null=$nb_null nb_managed=$nb_managed nb_ignored=$nb_ignored nb_other=$nb_other unhide=$unhide*}}
|
||||||
|
|
||||||
|
<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 $immo_lines|count > 0}}
|
||||||
|
<table class="list">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th class="num">N°</th>
|
||||||
|
<th class="nombre">Ligne</th>
|
||||||
|
<th>Date</th>
|
||||||
|
<th>Libellé</th>
|
||||||
|
<th class="nombre">Montant</th>
|
||||||
|
<th class="nombre">Affecté</th>
|
||||||
|
<th class="nombre">Reste</th>
|
||||||
|
<th>N° compte</th>
|
||||||
|
<th>Compte</th>
|
||||||
|
<th class="actions"></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{{#foreach from=$immo_lines item="line"}}
|
||||||
|
|
||||||
{{if $unhide == null}}
|
{{if $unhide == null}}
|
||||||
{{if $status != "unknown"}}
|
{{if $status == "ignored"}}
|
||||||
{{:continue}}
|
{{:continue}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{if $status != "ignored" && $status != "unknown"}}
|
|
||||||
{{:continue}}
|
|
||||||
{{/if}}
|
|
||||||
{{* vérifier si le libellé aurait pu être filtré *}}
|
{{* vérifier si le libellé aurait pu être filtré *}}
|
||||||
{{#foreach from=$module.config.filters item="filter"}}
|
{{#foreach from=$module.config.filters item="filter"}}
|
||||||
{{if $filter|strpos:$trans_label !== false}}
|
{{if $filter|strpos:$trans_label !== false}}
|
||||||
|
|
@ -131,69 +154,34 @@
|
||||||
{{/foreach}}
|
{{/foreach}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{* lister les lignes des écritures d'amortissement liées à l'immobilisation *}}
|
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$line.immo_trans_id}}
|
||||||
{{:assign amort_lines=null}}
|
{{:assign compte_url="%s/acc/accounts/journal.php?id=%s&year=%s"|args:$admin_url:$line.account_id:$line.trans_id_year}}
|
||||||
{{#select
|
{{:assign reste="%d-%d"|math:$line.debit:$line.amount}}
|
||||||
l_amort.credit as amort_amount,
|
|
||||||
CASE links.id_related = t_immo.id
|
|
||||||
WHEN true THEN links.id_transaction
|
|
||||||
WHEN false THEN links.id_related
|
|
||||||
END as amort_trans_id,
|
|
||||||
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}}
|
|
||||||
{{:assign amort_amount=0}}
|
|
||||||
{{#foreach from=$amort_lines item="line"}}
|
|
||||||
{{* voir s'il existe un doc associé à l'écriture d'amortissement *}}
|
|
||||||
{{#load type="link"
|
|
||||||
where="$$.immo_line_id = :immo_line_id AND $$.amort_trans_id = :amort_trans_id AND $$.amort_line_id = :amort_line_id"
|
|
||||||
:immo_line_id = $immo_line_id
|
|
||||||
:amort_trans_id = $line.amort_trans_id
|
|
||||||
:amort_line_id = $line.amort_line_id
|
|
||||||
}}
|
|
||||||
{{:assign amort_amount="%d+%d"|math:$amort_amount:$line.amount}}
|
|
||||||
{{else}}
|
|
||||||
{{* TODO À VÉRIFIER (cas multi-lignes) *}}
|
|
||||||
{{:assign amort_amount="%d+%d"|math:$amort_amount:$line.amount}}
|
|
||||||
{{/load}}
|
|
||||||
{{/foreach}}
|
|
||||||
{{if $amort_amount != 0}}
|
|
||||||
{{:continue}}
|
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
{{:assign nb_immo="%d+1"|math:$nb_immo}}
|
|
||||||
<tr {{if $status == "ignored"}}class="ignored"{{/if}}>
|
<tr {{if $status == "ignored"}}class="ignored"{{/if}}>
|
||||||
<td class="num"><a href={{$trans_url}}>#{{$immo_trans_id}}</a></td>
|
<td class="num"><a href="{{$trans_url}}">#{{$line.immo_trans_id}}</a></td>
|
||||||
|
<td class="nombre">{{$line.immo_line_id}}</td>
|
||||||
<td>{{$trans_date|date_short}}</td>
|
<td>{{$trans_date|date_short}}</td>
|
||||||
<td>{{$trans_label}}{{if $line_label != null && $line_label != $trans_label}} — {{$line_label}}{{/if}}</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:$debit|money_html:false|raw}}</td>
|
<td class="money">{{"%f"|math:$line.debit|money_html:false|raw}}</td>
|
||||||
<td><a href={{$compte_url}}>{{$account_code}}</a></td>
|
<td class="money">{{"%f"|math:$line.amount|money_html:false|raw}}</td>
|
||||||
<td>{{$account_label}}</td>
|
<td class="money">{{"%f"|math:$reste|money_html:false|raw}}</td>
|
||||||
|
<td><a href="{{$compte_url}}">{{$line.account_code}}</a></td>
|
||||||
|
<td>{{$line.account_label}}</td>
|
||||||
<td class="actions">
|
<td class="actions">
|
||||||
{{:linkbutton
|
{{:linkbutton
|
||||||
label="Paramètres"
|
label="Paramètres"
|
||||||
href="add_infos.html?immo_line_id=%s&type_immo=other"|args:$immo_line_id
|
href="add_infos.html?immo_line_id=%s&type_immo=other"|args:$immo_line_id
|
||||||
shape="settings"
|
shape="settings"
|
||||||
target="_dialog"
|
|
||||||
}}
|
}}
|
||||||
|
{{* target="_dialog"*}}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{/select}}
|
{{/foreach}}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
{{if $nb_immo == 0}}
|
{{else}}
|
||||||
<p class="block alert">Aucune immobilisation</p>
|
<p class="block alert">Aucune immobilisation</p>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</section>
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function changeVisibility(evt, idcheck = 'f_unhide_1') {
|
function changeVisibility(evt, idcheck = 'f_unhide_1') {
|
||||||
|
|
|
||||||
243
add_infos.html
243
add_infos.html
|
|
@ -3,140 +3,137 @@
|
||||||
{{*
|
{{*
|
||||||
@param immo_line_id
|
@param immo_line_id
|
||||||
@param type_immo : managed, amortized, archived, other
|
@param type_immo : managed, amortized, archived, other
|
||||||
|
|
||||||
|
TODO :
|
||||||
|
- séparer les cas des immo simples et complexes (BOI)
|
||||||
|
par exemple pour la durée d'amort par défaut {{:input ...}}
|
||||||
|
- prise en charge immo => param = immo_line_id
|
||||||
|
- modif param immo => param = immo_doc_id
|
||||||
*}}
|
*}}
|
||||||
|
|
||||||
{{* données de l'immobilisaion *}}
|
{{* cas de la prise en charge *}}
|
||||||
{{#load type="immo" assign="info_immo" where="$$.line = :line_id" :line_id=$_GET.immo_line_id|intval}}
|
{{* données de l'immobilisation *}}
|
||||||
|
{{: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}}
|
||||||
{{/load}}
|
{{/load}}
|
||||||
|
|
||||||
{{#select
|
{{#select
|
||||||
trans.id as immo_trans_id,
|
trans.id as immo_trans_id,
|
||||||
trans.label,
|
trans.label as trans_label,
|
||||||
trans.date as date_achat,
|
trans.date as date_achat,
|
||||||
line.debit as montant,
|
line.debit as montant,
|
||||||
line.label as line_label,
|
line.label as line_label,
|
||||||
acc.code
|
acc.code,
|
||||||
|
acc.label as account_label
|
||||||
FROM acc_transactions_lines AS line
|
FROM acc_transactions_lines AS line
|
||||||
INNER join acc_transactions AS trans ON line.id_transaction = trans.id
|
INNER join acc_transactions AS trans ON line.id_transaction = trans.id
|
||||||
INNER JOIN acc_accounts AS acc ON line.id_account = acc.id
|
INNER JOIN acc_accounts AS acc ON line.id_account = acc.id
|
||||||
WHERE line.id = :line_id;
|
WHERE line.id = :line_id;
|
||||||
:line_id = $_GET.immo_line_id
|
:line_id = $_GET.immo_line_id|intval
|
||||||
assign=ligne_immo
|
assign="ligne_immo"
|
||||||
}}
|
}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{:error message="Aucune immobilisation trouvée"}}
|
{{:error message="Immobilisation non trouvée"}}
|
||||||
{{/select}}
|
{{/select}}
|
||||||
|
|
||||||
{{* chercher les liaisons de l'écriture d'immobilisation *}}
|
{{:assign reste="%d-%d"|math:$ligne_immo.montant:$montant_affecte}}
|
||||||
{{#select
|
{{*
|
||||||
CASE links.id_related = :immo_trans_id
|
{{if $info_immo != null}}
|
||||||
WHEN true THEN links.id_transaction
|
{{:assign date_defaut=$info_immo.date}}
|
||||||
WHEN false THEN links.id_related
|
{{:assign duree_defaut=$info_immo.duration}}
|
||||||
END as linked_id,
|
{{:assign choix_defaut=$info_immo.status}}
|
||||||
acc.code
|
{{else}}
|
||||||
FROM acc_transactions_links as links
|
{{:assign duree_defaut=null}}
|
||||||
INNER JOIN acc_transactions_lines AS line on line.id_transaction = linked_id
|
|
||||||
INNER JOIN acc_accounts AS acc ON line.id_account = acc.id
|
|
||||||
WHERE (links.id_transaction = :immo_trans_id or links.id_related = :immo_trans_id)
|
|
||||||
AND line.credit > 0
|
|
||||||
;
|
|
||||||
:immo_trans_id = $ligne_immo.immo_trans_id
|
|
||||||
}}
|
|
||||||
{{:assign var="linked_transactions.%d."|args:$code value=$linked_id}}
|
|
||||||
{{/select}}
|
|
||||||
{{:assign var="immo_transactions" from="linked_transactions.%d"|args:$ligne_immo.code}}
|
|
||||||
|
|
||||||
{{* Traiter l'envoi du formulaire *}}
|
|
||||||
{{#form on="save"}}
|
|
||||||
{{if $_POST.classify == null}}
|
|
||||||
{{:error message="Vous devez choisir une action"}}
|
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
*}}
|
||||||
|
|
||||||
{{if $_POST.classify == "ignored"}}
|
{{#form on="save"}}
|
||||||
|
|
||||||
|
{{if ! $_POST.amortir}}
|
||||||
{{* ne pas amortir *}}
|
{{* ne pas amortir *}}
|
||||||
{{:assign duration=0}}
|
{{:assign duration=0}}
|
||||||
{{:assign date_debut=$ligne_immo.date_achat|parse_date}}
|
{{:assign libelle=null}}
|
||||||
|
{{:assign montant=null}}
|
||||||
|
{{:assign date_achat=null}}
|
||||||
|
{{:assign date_mes=null}}
|
||||||
{{:assign status="ignored"}}
|
{{:assign status="ignored"}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{* vérifier que la date d'acquisition est antérieure à la date de mise en service *}}
|
|
||||||
{{:assign date_debut=$_POST.date_mes|or:$ligne_immo.date_achat|parse_date}}
|
{{* vérifier que la date de mise en service est postérieure à la date d'acquisition *}}
|
||||||
{{if $date_debut|strtotime < $ligne_immo.date_achat|strtotime}}
|
{{:assign d1=$_POST.date_achat|or:$ligne_immo.date_achat|parse_date}}
|
||||||
{{:assign dd=$date_debut|date_short}}
|
{{:assign d2=$_POST.date_mes|or:$d1|parse_date}}
|
||||||
{{:assign da=$ligne_immo.date_achat|date_short}}
|
{{if $d2 < $d1}}
|
||||||
{{:error message="Erreur : la date de mise en service (%s) ne peut être antérieure à la date d'acquisition (%s)"|args:$dd:$da}}
|
{{:assign da=$d1|date_short}}
|
||||||
|
{{:error message="Erreur : la date de mise en service (%s) ne peut être antérieure à la date d'acquisition (%s)"|args:$_POST.date_mes:$da}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{if $_POST.classify == "amortized"}}
|
|
||||||
{{if $info_immo.duration == null}}
|
|
||||||
{{:assign duration=0}}
|
|
||||||
{{else}}
|
|
||||||
{{:assign duration=$info_immo.duration}}
|
|
||||||
{{/if}}
|
|
||||||
{{:assign status="amortized"}}
|
|
||||||
{{elseif $_POST.classify == "archived"}}
|
|
||||||
{{if $info_immo.duration == null}}
|
|
||||||
{{:assign duration=0}}
|
|
||||||
{{else}}
|
|
||||||
{{:assign duration=$info_immo.duration}}
|
|
||||||
{{/if}}
|
|
||||||
{{:assign status="archived"}}
|
|
||||||
{{else}}
|
|
||||||
{{:assign duration=$_POST.duree|intval}}
|
{{:assign duration=$_POST.duree|intval}}
|
||||||
{{if $duration <= 0}}
|
{{if $duration <= 0}}
|
||||||
{{:error message="Erreur : la durée d'amortissement doit être strictement positive"}}
|
{{:error message="Erreur : la durée d'amortissement doit être strictement positive"}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{:assign status="managed"}}
|
|
||||||
|
{{if $_POST.libelle != $ligne_immo.line_label && $_POST.libelle != $ligne_immo.trans_label}}
|
||||||
|
{{:assign libelle=$_POST.libelle}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
|
{{if $_POST.montant == null || $_POST.montant|intval == 0 }}
|
||||||
|
{{if $montant_affecte > 0}}
|
||||||
|
{{:assign montant=$reste}}
|
||||||
|
{{else}}
|
||||||
|
{{:assign montant=null}}
|
||||||
|
{{/if}}
|
||||||
|
{{else}}
|
||||||
|
{{:assign montant=$_POST.montant|intval}}
|
||||||
|
{{:assign montant="%d*100"|math:$montant}}
|
||||||
|
{{if $montant == $reste}}
|
||||||
|
{{:assign montant=null}}
|
||||||
|
{{/if}}
|
||||||
|
{{/if}}
|
||||||
|
{{if $montant > $reste}}
|
||||||
|
{{:assign reste_nb="%f"|math:$reste|money_currency:false}}
|
||||||
|
{{:assign montant_nb="%f"|math:$montant|money_currency:false}}
|
||||||
|
{{:error message="Le montant (%s) ne peut être supérieur au reste (%s)"|args:$montant_nb:$reste_nb}}
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{if $_POST.date_achat == null || $_POST.date_achat|parse_date == $ligne_immo.date_achat}}
|
||||||
|
{{:assign date_achat=null}}
|
||||||
|
{{else}}
|
||||||
|
{{:assign date_achat=$_POST.date_achat|parse_date}}
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{if $_POST.date_mes == null || $_POST.date_mes == $_POST.date_achat || $_POST.date_mes|parse_date == $ligne_immo.date_achat}}
|
||||||
|
{{:assign date_mes=null}}
|
||||||
|
{{else}}
|
||||||
|
{{:assign date_mes=$_POST.date_mes|parse_date}}
|
||||||
|
{{/if}}
|
||||||
|
{{:assign status="managed"}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{* enregistrer les infos de l'immobilisation *}}
|
{{* enregistrer les infos de l'immobilisation *}}
|
||||||
{{if $info_immo == null}}
|
{{if $info_immo == null || $montant_affecte > 0}}
|
||||||
{{:assign key=""|uuid}}
|
{{:assign key=""|uuid}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{:assign key=$info_immo.key}}
|
{{:assign key=$info_immo.key}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{:save
|
{{:save
|
||||||
key=$key
|
key=$key
|
||||||
validate_schema="schema.json"
|
validate_schema="schema.json"
|
||||||
type="immo"
|
type="immo"
|
||||||
line=$_GET.immo_line_id|intval
|
line=$_GET.immo_line_id|intval
|
||||||
duration=$duration
|
duration=$duration
|
||||||
date=$date_debut
|
label=$libelle
|
||||||
|
amount=$montant
|
||||||
|
date_achat=$date_achat
|
||||||
|
date_mes=$date_mes
|
||||||
status=$status
|
status=$status
|
||||||
|
assign_new_id="new_id"
|
||||||
}}
|
}}
|
||||||
|
|
||||||
{{* copier les autres liaisons *}}
|
{{if $_POST.amortir}}
|
||||||
{{#foreach from=$linked_transactions key="code" item="liaisons"}}
|
{{:assign type_immo="managed"}}
|
||||||
{{if $code != $ligne_immo.code}}
|
|
||||||
{{:debug code=$code liaisons=$liaisons}}
|
|
||||||
{{#foreach from=$liaisons item="elem"}}
|
|
||||||
{{:assign var="new_transactions." value=$elem}}
|
|
||||||
{{/foreach}}
|
|
||||||
{{/if}}
|
|
||||||
{{/foreach}}
|
|
||||||
|
|
||||||
{{* nouvelles liaisons *}}
|
|
||||||
{{#foreach from=$_POST.transactions key="key" item="elem"}}
|
|
||||||
{{:assign var="new_transactions." value=$elem|intval}}
|
|
||||||
{{/foreach}}
|
|
||||||
|
|
||||||
{{* Enregistrer les liaisons *}}
|
|
||||||
{{if $new_transactions != null}}
|
|
||||||
{{:api
|
|
||||||
method="POST"
|
|
||||||
path="accounting/transaction/%s/transactions"|args:$ligne_immo.immo_trans_id
|
|
||||||
assign="result"
|
|
||||||
assign_code="result_code"
|
|
||||||
transactions=$new_transactions
|
|
||||||
}}
|
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
{{if $_POST.classify == "managed" || $_POST.classify == "amortized"}}
|
|
||||||
{{:assign type_immo=$_POST.classify}}
|
|
||||||
{{elseif $_POST.classify == "ignored"}}
|
|
||||||
{{:assign type_immo="other"}}
|
|
||||||
{{else}}
|
{{else}}
|
||||||
{{:assign type_immo=$_GET.type_immo}}
|
{{:assign type_immo="other"}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{:redirect force="index.html?ok=1&msg=infos&type_immo=%s"|args:$type_immo}}
|
{{:redirect force="index.html?ok=1&msg=infos&type_immo=%s"|args:$type_immo}}
|
||||||
{{/form}}
|
{{/form}}
|
||||||
|
|
@ -151,53 +148,46 @@
|
||||||
|
|
||||||
{{:assign choix_defaut=$_GET.type_immo}}
|
{{:assign choix_defaut=$_GET.type_immo}}
|
||||||
|
|
||||||
{{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}}
|
|
||||||
|
|
||||||
{{*
|
{{*
|
||||||
- classer l'immobilisation
|
- classer l'immobilisation
|
||||||
- renseigner ou modifier la date de mise en service, les écritures associées ou la durée d'amortissement
|
- renseigner ou modifier la date de mise en service, les écritures associées ou la durée d'amortissement
|
||||||
*}}
|
*}}
|
||||||
|
|
||||||
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$ligne_immo.immo_trans_id}}
|
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$ligne_immo.immo_trans_id}}
|
||||||
<h3 class="ruler">
|
<h3 class="ruler">Paramètres de l'immobilisation</h3>
|
||||||
Paramètres de l'immobilisation
|
|
||||||
<span class="num"><a href="{{$trans_url}}">#{{$ligne_immo.immo_trans_id}}</a></span>
|
|
||||||
</h3>
|
|
||||||
<div class="informations">
|
<div class="informations">
|
||||||
<dl class="describe">
|
<dl class="describe">
|
||||||
<dt>Immobilisation</dt>
|
<dt>Immobilisation</dt>
|
||||||
<dd><span class="num"><a href={{$trans_url}}>#{{$ligne_immo.immo_trans_id}}</a></span> {{$ligne_immo.label}}{{if $ligne_immo.line_label != null && $ligne_immo.line_label != $ligne_immo.label}} — {{$ligne_immo.line_label}}{{/if}}</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>
|
<dt>Montant</dt>
|
||||||
<dd class="money strong">{{"%f"|math:$ligne_immo.montant|money_currency_html:false|raw}}</dd>
|
<dd class="money strong">{{"%f"|math:$ligne_immo.montant|money_currency_html:false|raw}}</dd>
|
||||||
<dt>Date de l'écriture d'immobilisation</dt>
|
<dt>Montant déjà affecté</dt>
|
||||||
|
<dd class="money strong">{{"%f"|math:$montant_affecte|money_currency_html:false|raw}}</dd>
|
||||||
|
<dt>Montant restant à affecter</dt>
|
||||||
|
<dd class="money strong">{{"%f"|math:$reste|money_currency_html:false|raw}}</dd> <dt>Date de l'écriture d'immobilisation</dt>
|
||||||
<dd>{{$ligne_immo.date_achat|date_short}}</dd>
|
<dd>{{$ligne_immo.date_achat|date_short}}</dd>
|
||||||
|
<dt>Compte d'immobilisation</dt>
|
||||||
|
<dd>{{$ligne_immo.code}} — {{$ligne_immo.account_label}}
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form method="post" action="">
|
<form method="post" action="">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>Classement</legend>
|
<legend>Amortissement</legend>
|
||||||
<dl id="classement_immo">
|
<dl>
|
||||||
<dt><label>Faites un choix</label> <b>(obligatoire)</b></dt>
|
{{:input id="amortir" type="checkbox" value=1 name="amortir" label="Amortir cette immobilisation sur une ou plusieurs années" checked="checked" help="Dé-cocher pour ne pas amortir"}}
|
||||||
{{:input type="radio-btn" name="classify" value="managed" label="Immobilisation à amortir" help="Cette immobilisation sera classée parmi les immobilisations amortissables" default=$choix_defaut}}
|
<div class="masquable">
|
||||||
{{:input type="radio-btn" name="classify" value="amortized" label="Amortissement terminé" help="Cette immobilisation sera classée parmi les immobilisations amorties" default=$choix_defaut}}
|
{{:input type="number" name="duree" label="Durée d'amortissement" required=true min=1}}
|
||||||
{{: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}}
|
</div>
|
||||||
{{: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>
|
</dl>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
<fieldset class="masquable">
|
||||||
<fieldset id="infos_immo">
|
<legend>Informations facultatives</legend>
|
||||||
<legend>Informations</legend>
|
|
||||||
<dl>
|
<dl>
|
||||||
{{:input type="number" name="duree" label="Durée d'amortissement" default=$duree_defaut required=true min=1}}
|
{{: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="list" name="transactions" default=$immo_transactions label="Écritures liées au crédit du compte d'immobilisation" target="!acc/transactions/selector.php" multiple=true help="par exemple écriture d'avoir ou autre réduction du montant de l'acquisition"}}
|
{{: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="date" name="date_mes" label="Date de mise en service" default=$date_defaut 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"}}
|
||||||
|
{{:input type="money" name="montant" label="Montant de l'immobilisation" default=$reste}}
|
||||||
</dl>
|
</dl>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
|
|
@ -209,29 +199,16 @@
|
||||||
|
|
||||||
{{:admin_footer}}
|
{{:admin_footer}}
|
||||||
|
|
||||||
|
<script type="text/javascript" src="scripts.js"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var info_immo = {{$info_immo|json_encode|raw}};
|
|
||||||
|
|
||||||
// afficher/masquer les champs de saisie
|
function changeVisibility(evt, idcheck = 'f_amortir_1', hiddenclass = 'masquable')
|
||||||
function toggleInputs(event) {
|
{
|
||||||
const classement_immo = document.getElementById('classement_immo');
|
toggleVisibility(idcheck, document.querySelectorAll('.' + hiddenclass));
|
||||||
const managed = classement_immo.querySelector('input[type=radio][value=managed]');
|
|
||||||
const amortized = classement_immo.querySelector('input[type=radio][value=amortized]');
|
|
||||||
if (managed.checked) {
|
|
||||||
g.toggle('#infos_immo', true);
|
|
||||||
} else if (amortized.checked && info_immo != null && info_immo.duration != 0) {
|
|
||||||
g.toggle('#infos_immo', true);
|
|
||||||
} else {
|
|
||||||
g.toggle('#infos_immo', false);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
toggleInputs();
|
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
const radios = document.querySelectorAll('input[name="classify"]');
|
document.getElementById('f_amortir_1').onclick = changeVisibility;
|
||||||
radios.forEach(radio => {
|
|
||||||
radio.addEventListener("change", toggleInputs);
|
|
||||||
});
|
|
||||||
})();
|
})();
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
36
link.schema.json
Normal file
36
link.schema.json
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||||
|
"description": "Schéma des liens entre documents",
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": ["amort_link", "immo_link"]
|
||||||
|
},
|
||||||
|
"immo_doc_id" : {
|
||||||
|
"description": "identifiant du document d'immobilisation associé",
|
||||||
|
"type" : "integer",
|
||||||
|
"exclusiveMinimum": 0
|
||||||
|
},
|
||||||
|
"amort_line_id" : {
|
||||||
|
"description": "numéro de ligne d'amortissement associée à l'immobilisation",
|
||||||
|
"type": "integer",
|
||||||
|
"exclusiveMinimum": 0
|
||||||
|
},
|
||||||
|
"credit_line_id": {
|
||||||
|
"description": "numéro de ligne au crédit du compte de l'immobilisation",
|
||||||
|
"type": "integer",
|
||||||
|
"exclusiveMinimum": 0
|
||||||
|
},
|
||||||
|
"amount": {
|
||||||
|
"description": "montant de la ligne d'amortissement ou de crédit",
|
||||||
|
"type": ["number", "null"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": ["type", "immo_doc_id"],
|
||||||
|
"if": {"properties": {"type": {"const": "amort_link"}}, "required": ["type"]},
|
||||||
|
"then": {"required": ["amort_line_id"]},
|
||||||
|
"else":
|
||||||
|
"if": {"properties": {"type": {"const": "immo_link"}}, "required": ["type"]},
|
||||||
|
"then": {"required": ["credit_line_id"]},
|
||||||
|
}
|
||||||
13
schema.json
13
schema.json
|
|
@ -14,11 +14,20 @@
|
||||||
"description": "durée de l'amortissement en années",
|
"description": "durée de l'amortissement en années",
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
},
|
},
|
||||||
|
"label" : {
|
||||||
|
"description" : "libellé de l'immobilisation si besoin",
|
||||||
|
"type" : ["string", "null"]
|
||||||
|
},
|
||||||
"amount" : {
|
"amount" : {
|
||||||
"description": "montant de l'immobilisation si besoin",
|
"description": "montant de l'immobilisation si besoin",
|
||||||
"type": ["integer", "null"]
|
"type": ["integer", "null"]
|
||||||
},
|
},
|
||||||
"date" : {
|
"date_achat" : {
|
||||||
|
"description" : "date d'achat de l'immobilisation si besoin",
|
||||||
|
"type" : ["string", "null"],
|
||||||
|
"format" : "date"
|
||||||
|
},
|
||||||
|
"date_mes" : {
|
||||||
"description" : "date de mise en service de l'immobilisation",
|
"description" : "date de mise en service de l'immobilisation",
|
||||||
"type" : ["string", "null"],
|
"type" : ["string", "null"],
|
||||||
"format" : "date"
|
"format" : "date"
|
||||||
|
|
@ -28,5 +37,5 @@
|
||||||
"enum" : ["managed", "amortized", "archived", "ignored"]
|
"enum" : ["managed", "amortized", "archived", "ignored"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["type", "line", "duration", "date"]
|
"required": ["type", "line", "duration", "status"]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue