Compare commits
No commits in common. "d189f6d4c4ce02e8b3fe61b6ca9311b9b2c5be30" and "77aac6fd4a079bae33d0ff3d3dc671c7f48d25ba" have entirely different histories.
d189f6d4c4
...
77aac6fd4a
@ -1,36 +0,0 @@
|
|||||||
{{* -*- brindille -*- *}}
|
|
||||||
|
|
||||||
{{*
|
|
||||||
vérifier :
|
|
||||||
- que le compte débute par le préfixe corect
|
|
||||||
(20 ou 21 pour un compte d'immo, 280 ou 281 pour un compte d'amortissement)
|
|
||||||
- est présent dans le PC indiqué
|
|
||||||
paramètres :
|
|
||||||
- account : tableau avec un identifiant de compte
|
|
||||||
- chart_id : identifiant de plan comptable
|
|
||||||
- prefix_array : tableau des préfixes
|
|
||||||
résultat :
|
|
||||||
- account_ok
|
|
||||||
*}}
|
|
||||||
|
|
||||||
{{#foreach from=$account key="account_code"}}
|
|
||||||
{{:assign account_code=$account_code}}
|
|
||||||
{{/foreach}}
|
|
||||||
|
|
||||||
{{:assign condition=" AND ("}}
|
|
||||||
{{#foreach from=$prefix_array item="code"}}
|
|
||||||
{{:assign condition=$condition|cat:" code LIKE "|cat:$code|cat:" OR "}}
|
|
||||||
{{/foreach}}
|
|
||||||
{{:assign condition=$condition|cat:"0)"}}
|
|
||||||
|
|
||||||
{{#sql
|
|
||||||
select="code"
|
|
||||||
tables="acc_accounts"
|
|
||||||
where="id_chart = :id_chart %s"|args:$condition
|
|
||||||
:id_chart = $selected_chart|intval
|
|
||||||
}}
|
|
||||||
{{if $account_code == $code}}
|
|
||||||
{{:assign account_ok=1}}
|
|
||||||
{{:break}}
|
|
||||||
{{/if}}
|
|
||||||
{{/sql}}
|
|
@ -1,23 +0,0 @@
|
|||||||
{{* -*- brindille -*- *}}
|
|
||||||
|
|
||||||
{{*
|
|
||||||
vérifier que la date est située dans un exercice ouvert
|
|
||||||
paramètres :
|
|
||||||
- date
|
|
||||||
résultat : open_years, selected_year, selected_chart
|
|
||||||
*}}
|
|
||||||
|
|
||||||
{{:assign open_years=""}}
|
|
||||||
{{#years closed=false}}
|
|
||||||
{{:assign open_years=$open_years|cat:"\n"|cat:" - "|cat:$label|cat:" : "}}
|
|
||||||
{{:assign debut=$start_date|date_short}}
|
|
||||||
{{:assign fin=$end_date|date_short}}
|
|
||||||
{{:assign open_years=$open_years|cat:$debut|cat:" à "|cat:$fin}}
|
|
||||||
{{if
|
|
||||||
$start_date|strtotime <= $date|parse_date|strtotime &&
|
|
||||||
$end_date|strtotime >= $date|parse_date|strtotime
|
|
||||||
}}
|
|
||||||
{{:assign selected_year=$id}}
|
|
||||||
{{:assign selected_chart=$id_chart}}
|
|
||||||
{{/if}}
|
|
||||||
{{/years}}
|
|
@ -10,8 +10,17 @@
|
|||||||
{{#form on="add"}}
|
{{#form on="add"}}
|
||||||
|
|
||||||
{{* vérifier que la date est située dans un exercice ouvert *}}
|
{{* vérifier que la date est située dans un exercice ouvert *}}
|
||||||
{{:include file="_check_date.html" date=$_POST.date keep="open_years, selected_year, selected_chart"}}
|
{{:assign open_years=""}}
|
||||||
|
{{#years closed=false}}
|
||||||
|
{{:assign open_years=$open_years|cat:"\n"|cat:" - "|cat:$label|cat:" : "}}
|
||||||
|
{{:assign debut=$start_date|date_short}}
|
||||||
|
{{:assign fin=$end_date|date_short}}
|
||||||
|
{{:assign open_years=$open_years|cat:$debut|cat:" à "|cat:$fin}}
|
||||||
|
{{if $start_date|strtotime <= $_POST.date|parse_date|strtotime && $end_date|strtotime >= $_POST.date|parse_date|strtotime}}
|
||||||
|
{{:assign selected_year=$id}}
|
||||||
|
{{:assign selected_chart=$id_chart}}
|
||||||
|
{{/if}}
|
||||||
|
{{/years}}
|
||||||
{{if $selected_year == null}}
|
{{if $selected_year == null}}
|
||||||
{{:assign message="La date choisie n'est dans aucun exercice ouvert !!\nExercices ouverts : %s"|args:$open_years}}
|
{{:assign message="La date choisie n'est dans aucun exercice ouvert !!\nExercices ouverts : %s"|args:$open_years}}
|
||||||
{{:error message=$message}}
|
{{:error message=$message}}
|
||||||
@ -21,15 +30,19 @@
|
|||||||
- que le compte d'immo débute par 20 ou 21
|
- que le compte d'immo débute par 20 ou 21
|
||||||
- est présent dans le PC de l'exercice correspondant à la date
|
- est présent dans le PC de l'exercice correspondant à la date
|
||||||
*}}
|
*}}
|
||||||
{{:assign var="prefix_array." value="'20%'"}}
|
{{#select
|
||||||
{{:assign var="prefix_array." value="'21%'"}}
|
code
|
||||||
{{:include
|
FROM acc_accounts
|
||||||
file="_check_account.html"
|
WHERE id_chart =:id_chart
|
||||||
account=$_POST.debit_account
|
AND
|
||||||
chart_id=$selected_chart
|
(code LIKE "20%" OR code LIKE "21%");
|
||||||
prefix_array=$prefix_array
|
:id_chart = $selected_chart|intval
|
||||||
keep="account_ok"
|
|
||||||
}}
|
}}
|
||||||
|
{{if $_POST.debit_account|has_key:$code}}
|
||||||
|
{{:assign account_ok=1}}
|
||||||
|
{{:break}}
|
||||||
|
{{/if}}
|
||||||
|
{{/select}}
|
||||||
|
|
||||||
{{if $account_ok == null}}
|
{{if $account_ok == null}}
|
||||||
{{:assign compte=$_POST.debit_account|implode:""}}
|
{{:assign compte=$_POST.debit_account|implode:""}}
|
||||||
@ -75,6 +88,11 @@
|
|||||||
{{* formulaire d'ajout d'immobilisation *}}
|
{{* formulaire d'ajout d'immobilisation *}}
|
||||||
{{:assign var="bank_account.512A" value="512A — Compte courant"}}
|
{{:assign var="bank_account.512A" value="512A — Compte courant"}}
|
||||||
|
|
||||||
|
{{*
|
||||||
|
TODO
|
||||||
|
- ajouter autres rubriques selon besoin
|
||||||
|
*}}
|
||||||
|
|
||||||
{{#select id,label FROM acc_projects WHERE archived = 0;}}
|
{{#select id,label FROM acc_projects WHERE archived = 0;}}
|
||||||
{{:assign var="projects.%d"|args:$id value=$label}}
|
{{:assign var="projects.%d"|args:$id value=$label}}
|
||||||
{{/select}}
|
{{/select}}
|
||||||
|
@ -25,6 +25,9 @@
|
|||||||
|
|
||||||
{{* récupérer les infos de l'immobilisation *}}
|
{{* récupérer les infos de l'immobilisation *}}
|
||||||
{{#load type="immo" assign="info_immo" where="$$.line = :line_id" :line_id=$_GET.immo_id|intval}}
|
{{#load type="immo" assign="info_immo" where="$$.line = :line_id" :line_id=$_GET.immo_id|intval}}
|
||||||
|
{{#foreach from=$amort item="elem"}}
|
||||||
|
{{:assign var="amort_associes." value=$elem"}}
|
||||||
|
{{/foreach}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{:assign message="Pas d'info concernant l'immobilisation %s"|args:$_GET.immo_id}}
|
{{:assign message="Pas d'info concernant l'immobilisation %s"|args:$_GET.immo_id}}
|
||||||
{{:error message=$message}}
|
{{:error message=$message}}
|
||||||
@ -91,9 +94,46 @@
|
|||||||
:line_id = $_GET.immo_id|intval
|
:line_id = $_GET.immo_id|intval
|
||||||
assign=linked_lines.
|
assign=linked_lines.
|
||||||
}}
|
}}
|
||||||
|
{{:assign var="amort_associes." value=$amort_line}}
|
||||||
{{:assign var="amort_years." value=$amort_year}}
|
{{:assign var="amort_years." value=$amort_year}}
|
||||||
{{/select}}
|
{{/select}}
|
||||||
|
|
||||||
|
{{* chercher parmi les associations *}}
|
||||||
|
{{#foreach from=$info_immo.amort item="id_amort"}}
|
||||||
|
{{#select
|
||||||
|
l_amort.id_transaction as amort_trans_id,
|
||||||
|
l_amort.credit as amort_amount,
|
||||||
|
l_amort.label as amort_label,
|
||||||
|
trans.date as amort_date,
|
||||||
|
trans.label as trans_label,
|
||||||
|
trans.id_year as amort_year,
|
||||||
|
acc.code as account_code,
|
||||||
|
acc.label as account_name,
|
||||||
|
project.label as project_label
|
||||||
|
from acc_transactions_lines as l_amort
|
||||||
|
inner join acc_transactions as trans on l_amort.id_transaction = trans.id
|
||||||
|
inner join acc_accounts as acc on l_amort.id_account = acc.id
|
||||||
|
inner join acc_projects AS project ON l_amort.id_project = project.id
|
||||||
|
where l_amort.id = :l_amort_id;
|
||||||
|
:l_amort_id = $id_amort
|
||||||
|
}}
|
||||||
|
{{:assign
|
||||||
|
var="linked_lines."
|
||||||
|
amort_line=$id_amort
|
||||||
|
amort_trans_id=$amort_trans_id
|
||||||
|
amort_amount=$amort_amount
|
||||||
|
amort_label=$amort_label
|
||||||
|
amort_date=$amort_date
|
||||||
|
amort_year=$amort_year
|
||||||
|
trans_label=$trans_label
|
||||||
|
account_code=$account_code
|
||||||
|
account_name=$account_name
|
||||||
|
project_label=$project_label
|
||||||
|
}}
|
||||||
|
{{:assign var="amort_years." value=$amort_year}}
|
||||||
|
{{/select}}
|
||||||
|
{{/foreach}}
|
||||||
|
|
||||||
{{* montant de l'annuité théorique *}}
|
{{* montant de l'annuité théorique *}}
|
||||||
{{:assign montant="%f"|math:$ligne_immo.montant}}
|
{{:assign montant="%f"|math:$ligne_immo.montant}}
|
||||||
{{:assign annuite="%f/%f"|math:$montant:$duree}}
|
{{:assign annuite="%f/%f"|math:$montant:$duree}}
|
||||||
@ -122,11 +162,12 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th>N°</th>
|
<th>N°</th>
|
||||||
<th>Date</th>
|
<th>Date</th>
|
||||||
<th class="nombre">Montant</th>
|
<th style="text-align: right;">Montant</th>
|
||||||
<th class="nombre"">Solde</th>
|
<th style="text-align: right;">Solde</th>
|
||||||
<th>Libellé</th>
|
<th>Libellé</th>
|
||||||
<th>N° compte</th>
|
<th>N° compte</th>
|
||||||
<th>Compte</th>
|
<th>Compte</th>
|
||||||
|
<th>Projet</th>
|
||||||
<th class="actions"></th>
|
<th class="actions"></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@ -151,6 +192,7 @@
|
|||||||
</td>
|
</td>
|
||||||
<td>{{$line.account_code}}</td>
|
<td>{{$line.account_code}}</td>
|
||||||
<td>{{$line.account_name}}</td>
|
<td>{{$line.account_name}}</td>
|
||||||
|
<td>{{$line.project_label}}</td>
|
||||||
<td>
|
<td>
|
||||||
{{if $line.linked == null}}
|
{{if $line.linked == null}}
|
||||||
{{:linkbutton label="Détacher" href="detach_amort.html?amort_id=%d&immo_id=%d"|args:$line.amort_line:$ligne_immo.immo_id shape="plus"}}
|
{{:linkbutton label="Détacher" href="detach_amort.html?amort_id=%d&immo_id=%d"|args:$line.amort_line:$ligne_immo.immo_id shape="plus"}}
|
||||||
@ -172,21 +214,23 @@
|
|||||||
</section>
|
</section>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{if $solde > 0}}
|
{{:assign project_id=$ligne_immo.project_id}}
|
||||||
{{:assign project_id=$ligne_immo.project_id}}
|
{{:assign project_label=$ligne_immo.project_label}}
|
||||||
{{:assign project_label=$ligne_immo.project_label}}
|
{{:assign nbamort="%d-%d"|math:$duree:$nbamort}}
|
||||||
{{:assign nbamort="%d-%d"|math:$duree:$nbamort}}
|
|
||||||
{{:assign annuite_courante="min(%f,%f)"|math:$annuite:$solde}}
|
<section class="amortissement">
|
||||||
<section class="amortissement">
|
|
||||||
<h3 class="ruler">Amortissements à enregistrer</h3>
|
<h3 class="ruler">Amortissements à enregistrer</h3>
|
||||||
<table class="list">
|
<table class="list">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>N°</th>
|
<th>N°</th>
|
||||||
<th>Date</th>
|
<th>Date</th>
|
||||||
<th class="nombre">Montant</th>
|
<th>Montant</th>
|
||||||
<th class="nombre">Solde</th>
|
<th>Solde</th>
|
||||||
<th>Libellé</th>
|
<th>Libellé</th>
|
||||||
|
<th>N° compte</th>
|
||||||
|
<th>Compte</th>
|
||||||
|
<th>Projet</th>
|
||||||
<th class="actions"></th>
|
<th class="actions"></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@ -210,11 +254,14 @@
|
|||||||
{{/if}}
|
{{/if}}
|
||||||
{{$libelle}}
|
{{$libelle}}
|
||||||
</td>
|
</td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
<td class="actions">
|
<td class="actions">
|
||||||
{{if $enregistrer == 1}}
|
{{if $enregistrer == 1}}
|
||||||
{{:linkbutton
|
{{:linkbutton
|
||||||
label="Enregistrer"
|
label="Enregistrer"
|
||||||
href="save_amort.html?amount=%d&account=%s&year=%s&trans_id=%d&immo_id=%s&project_id=%d&label=%s&solde=%d"|args:$annuite_courante:$ligne_immo.account_id:$current_year:$ligne_immo.trans_id:$_GET.immo_id:$project_id:$libelle:$solde
|
href="save_amort.html?amount=%d&account=%s&year=%s&trans_id=%d&immo_id=%s&project_id=%d&label=%s"|args:$annuite_courante:$ligne_immo.account_id:$current_year:$ligne_immo.trans_id:$_GET.immo_id:$project_id:$libelle
|
||||||
shape="right"
|
shape="right"
|
||||||
target="_dialog"
|
target="_dialog"
|
||||||
}}
|
}}
|
||||||
@ -233,16 +280,32 @@
|
|||||||
{{/foreach}}
|
{{/foreach}}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</section>
|
</section>
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
{{* Autres amortissements non rattachés *}}
|
<section class="amortissement">
|
||||||
{{#select
|
<h3 class="ruler">Autres amortissements non rattachés</h3>
|
||||||
|
<table class="list">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>N°</th>
|
||||||
|
<th>Date</th>
|
||||||
|
<th style="text-align: right;">Montant</th>
|
||||||
|
<th>Libellé</th>
|
||||||
|
<th>N° compte</th>
|
||||||
|
<th>Compte</th>
|
||||||
|
<th>Projet</th>
|
||||||
|
<th class="actions"></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
|
||||||
|
{{#select
|
||||||
li.id as l_id,
|
li.id as l_id,
|
||||||
li.id_transaction as t_id,
|
li.id_transaction as t_id,
|
||||||
li.credit as montant,
|
li.credit as montant,
|
||||||
li.reference,
|
li.reference,
|
||||||
li.label as l_label,
|
li.label as l_label,
|
||||||
|
pro.label as p_label,
|
||||||
trans.date as t_date,
|
trans.date as t_date,
|
||||||
trans.label as t_label,
|
trans.label as t_label,
|
||||||
acc.code as a_code,
|
acc.code as a_code,
|
||||||
@ -252,68 +315,48 @@
|
|||||||
inner join acc_accounts as acc on acc.id = li.id_account
|
inner join acc_accounts as acc on acc.id = li.id_account
|
||||||
inner join acc_transactions as trans on trans.id = li.id_transaction
|
inner join acc_transactions as trans on trans.id = li.id_transaction
|
||||||
inner join acc_years as y on y.id = trans.id_year
|
inner join acc_years as y on y.id = trans.id_year
|
||||||
|
inner join acc_projects as pro on li.id_project = pro.id
|
||||||
where acc.code like "28%"
|
where acc.code like "28%"
|
||||||
order by trans.date, trans.label;
|
order by trans.date, trans.label
|
||||||
assign=autre_amort
|
}}
|
||||||
}}
|
|
||||||
{{:assign linked="false"}}
|
{{:assign linked="false"}}
|
||||||
{{#select
|
{{#select
|
||||||
id_transaction,
|
id_transaction,
|
||||||
id_related
|
id_related
|
||||||
from acc_transactions_links
|
from acc_transactions_links
|
||||||
where id_transaction = :id_amort or id_related = :id_amort;
|
where id_transaction = :id_amort;
|
||||||
:id_amort=$t_id
|
:id_amort=$t_id}}
|
||||||
}}
|
{{:assign linked="true"}}
|
||||||
{{:assign var=autre_amort.linked value="true"}}
|
|
||||||
{{else}}
|
|
||||||
{{:assign var="autres_amortissements." value=$autre_amort}}
|
|
||||||
{{/select}}
|
{{/select}}
|
||||||
{{/select}}
|
|
||||||
|
|
||||||
{{if $autres_amortissements != null}}
|
{{if ! $l_id|in:$amort_associes && $linked != "true"}}
|
||||||
<section class="amortissement">
|
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$t_id}}
|
||||||
<h3 class="ruler">Autres amortissements non rattachés</h3>
|
|
||||||
<table class="list">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
<tr>
|
||||||
<th>N°</th>
|
<td class="num"><a href={{$trans_url}}>#{{$t_id}}</a></td>
|
||||||
<th>Date</th>
|
<td>{{$t_date|date_short}}</td>
|
||||||
<th class="nombre">Montant</th>
|
<td class="money">{{"%f"|math:$montant|money}}</td>
|
||||||
<th>Libellé</th>
|
<td>{{if $l_label == null}}
|
||||||
<th>N° compte</th>
|
{{$t_label}}
|
||||||
<th>Compte</th>
|
|
||||||
<th class="actions"></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
|
|
||||||
{{#foreach from=$autres_amortissements item="line"}}
|
|
||||||
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$line.t_id}}
|
|
||||||
<tr>
|
|
||||||
<td class="num"><a href={{$trans_url}}>#{{$line.t_id}}</a></td>
|
|
||||||
<td>{{$line.t_date|date_short}}</td>
|
|
||||||
<td class="money">{{"%f"|math:$line.montant|money}}</td>
|
|
||||||
<td>{{if $line.l_label == null}}
|
|
||||||
{{$line.t_label}}
|
|
||||||
{{else}}
|
{{else}}
|
||||||
{{$line.l_label}}
|
{{$l_label}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</td>
|
</td>
|
||||||
<td>{{$line.a_code}}</td>
|
<td>{{$a_code}}</td>
|
||||||
<td>{{$line.a_label}}</td>
|
<td>{{$a_label}}</td>
|
||||||
|
<td>{{$p_label}}</td>
|
||||||
<td>
|
<td>
|
||||||
{{if $linked != "true"}}
|
{{if $linked != "true"}}
|
||||||
{{:linkbutton label="Attacher" href="attach_amort.html?amort_id=%d&immo_id=%d"|args:$line.l_id:$ligne_immo.immo_id shape="plus"}}
|
{{:linkbutton label="Attacher" href="attach_amort.html?amort_id=%d&immo_id=%d"|args:$l_id:$ligne_immo.immo_id shape="plus"}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{:linkbutton label="Attacher" href="" shape="lock" class="disabled"}}
|
{{:linkbutton label="Attacher" href="" shape="lock" class="disabled"}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{/foreach}}
|
{{/if}}
|
||||||
|
{{/select}}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</section>
|
</section>
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
{{:form_errors}}
|
{{:form_errors}}
|
||||||
{{:admin_footer}}
|
{{:admin_footer}}
|
||||||
|
@ -1,61 +1,33 @@
|
|||||||
{{* -*- brindille -*- *}}
|
{{* -*- brindille -*- *}}
|
||||||
|
|
||||||
{{*
|
{{*
|
||||||
Enregistrer la liaison entre une écriture d'amortissement et
|
Enregistrer l'association entre une écriture d'amortissement et
|
||||||
l'écriture d'immobilisation correspondante
|
l'écriture d'immobilisation correspondante
|
||||||
|
Comme je ne sais pas créer une ligne dans acc_transactions_links
|
||||||
|
j'enregistre les associations dans un document json
|
||||||
*}}
|
*}}
|
||||||
|
|
||||||
{{* chercher l'écriture d'immobilisation *}}
|
{{* trouver l'entrée correspondant à l'immobilisation *}}
|
||||||
{{#select
|
|
||||||
id_transaction
|
{{* TODO : améliorer le message d'erreur *}}
|
||||||
FROM acc_transactions_lines
|
{{#load type="immo" assign="info_immo" where="$$.line = :line_id" :line_id=$_GET.immo_id|intval}}
|
||||||
WHERE id = :line_id;
|
|
||||||
:line_id = $_GET.immo_id|intval
|
|
||||||
}}
|
|
||||||
{{:assign immo_id=$id_transaction}}
|
|
||||||
{{else}}
|
{{else}}
|
||||||
{{* TODO : améliorer le message d'erreur *}}
|
{{:assign message="Pas d'info concernant l'immobilisation %s ; avez-vous renseigné la durée d'immobilisation ?"|args:$_GET.immo_id}}
|
||||||
{{:assign message="Impossible de trouver l'écriture d'immobilisation de la ligne « %s »"|args:$_GET.immo_id}}
|
|
||||||
{{:error message=$message}}
|
{{:error message=$message}}
|
||||||
{{/select}}
|
{{/load}}
|
||||||
|
|
||||||
{{* chercher l'écriture d'amortissement *}}
|
|
||||||
{{#select
|
{{* Ajouter la nouvelle ligne d'amortissement aux lignes existantes *}}
|
||||||
id_transaction
|
|
||||||
FROM acc_transactions_lines
|
{{:assign var="assoc." value=$_GET.amort_id|intval}}
|
||||||
WHERE id = :line_id;
|
|
||||||
:line_id = $_GET.amort_id|intval
|
{{* Enregistrer les infos *}}
|
||||||
|
{{:save
|
||||||
|
key=$info_immo.key
|
||||||
|
validate_schema="schema.json"
|
||||||
|
type="immo"
|
||||||
|
line=$info_immo.line
|
||||||
|
duration=$info_immo.duration
|
||||||
|
amort=$assoc
|
||||||
}}
|
}}
|
||||||
{{:assign amort_id=$id_transaction}}
|
|
||||||
{{else}}
|
|
||||||
{{* TODO : améliorer le message d'erreur *}}
|
|
||||||
{{:assign message="Impossible de trouver l'écriture d'amortissement de la ligne « %s »"|args:$_GET.amort_id}}
|
|
||||||
{{:error message=$message}}
|
|
||||||
{{/select}}
|
|
||||||
|
|
||||||
{{* checher les liaisons de l'écriture d'immobilisation *}}
|
|
||||||
{{#select
|
|
||||||
CASE links.id_related = :immo_id
|
|
||||||
WHEN true THEN links.id_transaction
|
|
||||||
WHEN false THEN links.id_related
|
|
||||||
END as linked_id
|
|
||||||
FROM acc_transactions_links as links
|
|
||||||
WHERE id_transaction = :immo_id or id_related = :immo_id;
|
|
||||||
:immo_id = $immo_id
|
|
||||||
}}
|
|
||||||
{{:assign var="linked_transactions." value=$linked_id}}
|
|
||||||
{{/select}}
|
|
||||||
|
|
||||||
{{* ajouter la nouvelle liaison *}}
|
|
||||||
{{:assign var="linked_transactions." value=$amort_id}}
|
|
||||||
|
|
||||||
{{* Enregistrer les liaisons *}}
|
|
||||||
{{:api
|
|
||||||
method="POST"
|
|
||||||
path="accounting/transaction/%s/transactions"|args:$immo_id
|
|
||||||
assign="result"
|
|
||||||
assign_code="result_code"
|
|
||||||
linked_transactions=$linked_transactions
|
|
||||||
}}
|
|
||||||
|
|
||||||
{{:redirect to="amortization.html?immo_id=%s&ok=1&msg=attach"|args:$_GET.immo_id}}
|
{{:redirect to="amortization.html?immo_id=%s&ok=1&msg=attach"|args:$_GET.immo_id}}
|
||||||
|
@ -58,11 +58,12 @@
|
|||||||
}}
|
}}
|
||||||
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$trans_id}}
|
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$trans_id}}
|
||||||
{{#load type="immo" where="$$.line = :line_id" :line_id=$immo_id|intval}}
|
{{#load type="immo" where="$$.line = :line_id" :line_id=$immo_id|intval}}
|
||||||
|
{{*:debug info_immo=$info_immo*}}
|
||||||
{{:assign duration=$duration}}
|
{{:assign duration=$duration}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{:assign duration=null}}
|
{{:assign duration=null}}
|
||||||
{{/load}}
|
{{/load}}
|
||||||
|
{{*:debug duration=$duration*}}
|
||||||
<tr>
|
<tr>
|
||||||
<td class="num"><a href={{$trans_url}}>#{{$trans_id}}</a></td>
|
<td class="num"><a href={{$trans_url}}>#{{$trans_id}}</a></td>
|
||||||
<td>{{$trans_date|date_short}}</td>
|
<td>{{$trans_date|date_short}}</td>
|
||||||
|
@ -9,40 +9,6 @@
|
|||||||
|
|
||||||
{{* Traiter l'envoi du formulaire *}}
|
{{* Traiter l'envoi du formulaire *}}
|
||||||
{{#form on="save"}}
|
{{#form on="save"}}
|
||||||
|
|
||||||
{{* vérifier que la date est située dans un exercice ouvert *}}
|
|
||||||
{{:include file="_check_date.html" date=$_POST.date keep="open_years, selected_year, selected_chart"}}
|
|
||||||
|
|
||||||
{{if $selected_year == null}}
|
|
||||||
{{:assign message="La date choisie n'est dans aucun exercice ouvert !!\nExercices ouverts : %s"|args:$open_years}}
|
|
||||||
{{:error message=$message}}
|
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
{{* vérifier :
|
|
||||||
- que le compte d'amortissement débute par 280 ou 281
|
|
||||||
- est présent dans le PC de l'exercice correspondant à la date
|
|
||||||
*}}
|
|
||||||
{{:assign var="prefix_array." value="'280%'"}}
|
|
||||||
{{:assign var="prefix_array." value="'281%'"}}
|
|
||||||
{{:include
|
|
||||||
file="_check_account.html"
|
|
||||||
account=$_POST.credit_account
|
|
||||||
chart_id=$selected_chart
|
|
||||||
prefix_array=$prefix_array
|
|
||||||
keep="account_ok"
|
|
||||||
}}
|
|
||||||
|
|
||||||
{{if $account_ok == null}}
|
|
||||||
{{:assign compte=$_POST.credit_account|implode:""}}
|
|
||||||
{{:error message="Le compte « %s » n'est pas un compte d'immobilisation ou n'est pas dans le plan comptable de l'exercice choisi"|args:$compte}}
|
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
{{* vérifier que le montant ne dépasse pas le solde restant *}}
|
|
||||||
{{:assign solde="%f/100"|math:$_GET.solde}}
|
|
||||||
{{if $_POST.montant > $solde}}
|
|
||||||
{{:error message="Le montant indiqué « %s » dépasse le solde à amortir « %s »"|args:$_POST.montant:$solde}}
|
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
{{* enregistrer l'écriture *}}
|
{{* enregistrer l'écriture *}}
|
||||||
{{:assign var="linked_transactions." value=$_GET.trans_id}}
|
{{:assign var="linked_transactions." value=$_GET.trans_id}}
|
||||||
|
|
||||||
@ -66,7 +32,7 @@
|
|||||||
path="accounting/transaction"
|
path="accounting/transaction"
|
||||||
assign="result"
|
assign="result"
|
||||||
assign_code="result_code"
|
assign_code="result_code"
|
||||||
id_year=$selected_year
|
id_year=$_POST.id_year|intval
|
||||||
type="advanced"
|
type="advanced"
|
||||||
date=$_POST.date
|
date=$_POST.date
|
||||||
label=$_POST.designation
|
label=$_POST.designation
|
||||||
@ -77,8 +43,6 @@
|
|||||||
{{:redirect force="amortization.html?immo_id=%s&ok=1&msg=amortissement"|args:$_GET.immo_id}}
|
{{:redirect force="amortization.html?immo_id=%s&ok=1&msg=amortissement"|args:$_GET.immo_id}}
|
||||||
{{/form}}
|
{{/form}}
|
||||||
|
|
||||||
{{:form_errors}}
|
|
||||||
|
|
||||||
{{* Préparer les infos pour le formulaire *}}
|
{{* Préparer les infos pour le formulaire *}}
|
||||||
{{:assign var="debit_account.6811" value="6811 — Dot. aux amortissements des immobilisations"}}
|
{{:assign var="debit_account.6811" value="6811 — Dot. aux amortissements des immobilisations"}}
|
||||||
|
|
||||||
@ -109,6 +73,7 @@
|
|||||||
<fieldset class="ajout_amort">
|
<fieldset class="ajout_amort">
|
||||||
<legend>Ajouter une écriture d'amortissement</legend>
|
<legend>Ajouter une écriture d'amortissement</legend>
|
||||||
<dl>
|
<dl>
|
||||||
|
{{:input type="select" default=$year.id name="id_year" label="Exercice" required=true options=$open_years}}
|
||||||
{{:input type="date" name="date" label="Date" required=true default=$year.date_amort|date_short}}
|
{{:input type="date" name="date" label="Date" required=true default=$year.date_amort|date_short}}
|
||||||
{{:input type="text" name="designation" label="Désignation" required=true default=$_GET.label}}
|
{{:input type="text" name="designation" label="Désignation" required=true default=$_GET.label}}
|
||||||
{{:input type="money" name="montant" label="Montant" required=true default=$_GET.amount}}
|
{{:input type="money" name="montant" label="Montant" required=true default=$_GET.amount}}
|
||||||
|
@ -13,6 +13,13 @@
|
|||||||
"duration" : {
|
"duration" : {
|
||||||
"description": "durée de l'amortissement en années",
|
"description": "durée de l'amortissement en années",
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"amort" : {
|
||||||
|
"description": "id lignes écritures amortissements",
|
||||||
|
"type": ["array", "null"],
|
||||||
|
"items": {
|
||||||
|
"type": "integer"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["type", "line", "duration"]
|
"required": ["type", "line", "duration"]
|
||||||
|
Loading…
Reference in New Issue
Block a user