Compare commits
12 Commits
66859c550e
...
fa208c566f
Author | SHA1 | Date | |
---|---|---|---|
fa208c566f | |||
0160fef1c2 | |||
6e06d4f24f | |||
3738ea0721 | |||
a1bf1c485c | |||
b1a78a3047 | |||
f76c243b8c | |||
11be1386c2 | |||
4f1be445ff | |||
9d2c30f0eb | |||
516021031d | |||
d599d49e1a |
69
_amort_exclus.html
Normal file
69
_amort_exclus.html
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
{{* -*- brindille -*- *}}
|
||||||
|
|
||||||
|
{{*
|
||||||
|
Trouver les lignes d'amortissement et d'immobilisation qui sont dans la même écriture
|
||||||
|
- param : aucun
|
||||||
|
- résultat : amort_exclus = tableau des amortissements à exclure
|
||||||
|
*}}
|
||||||
|
|
||||||
|
{{* lignes des immo non amorties *}}
|
||||||
|
{{#load type="immo" where="$$.noamort = true"}}
|
||||||
|
{{:assign var="lines." value="'%s'"|args:$line}}
|
||||||
|
{{/load}}
|
||||||
|
{{:assign lines=$lines|implode:","}}
|
||||||
|
{{:assign lines="("|cat:$lines|cat:")"}}
|
||||||
|
{{:assign condition="line.id IN %s"|args:$lines}}
|
||||||
|
{{*:debug condition=$condition*}}
|
||||||
|
|
||||||
|
{{* écritures et comptes associés *}}
|
||||||
|
{{#select
|
||||||
|
line.id as line_id,
|
||||||
|
line.id_transaction as trans_id,
|
||||||
|
account.id as account_id,
|
||||||
|
account.code as account_code,
|
||||||
|
account.id_chart as id_chart
|
||||||
|
FROM acc_transactions_lines AS line
|
||||||
|
INNER JOIN acc_transactions AS trans on trans.id = line.id_transaction
|
||||||
|
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;
|
||||||
|
!condition=$condition
|
||||||
|
assign="ecriture"
|
||||||
|
}}
|
||||||
|
{{:assign var="ecritures." value="'%s'"|args:$trans_id}}
|
||||||
|
{{* déterminer le numéro du compte d'amortissement associé au compte d'immobilisation *}}
|
||||||
|
{{:include
|
||||||
|
file="./_get_amort_code.html"
|
||||||
|
code_immo=$account_code
|
||||||
|
keep="code_amort"
|
||||||
|
}}
|
||||||
|
{{:assign var="accounts." value="'%s'"|args:$code_amort}}
|
||||||
|
{{/select}}
|
||||||
|
{{*:debug ecritures=$ecritures accounts=$accounts*}}
|
||||||
|
|
||||||
|
{{* écritures d'amortissement avec :
|
||||||
|
- numéro d'écritures obtenus ci-dessus
|
||||||
|
- numéros de comptes d'amortissement déduits des comptes d'immo ci-dessus
|
||||||
|
*}}
|
||||||
|
|
||||||
|
{{:assign ecritures=$ecritures|implode:","}}
|
||||||
|
{{:assign ecritures="("|cat:$ecritures|cat:")"}}
|
||||||
|
{{:assign accounts=$accounts|implode:","}}
|
||||||
|
{{:assign accounts="("|cat:$accounts|cat:")"}}
|
||||||
|
{{:assign condition="line.id_transaction IN %s AND account.code IN %s"|args:$ecritures:$accounts}}
|
||||||
|
|
||||||
|
{{#select
|
||||||
|
line.id as line_id,
|
||||||
|
line.id_transaction as trans_id,
|
||||||
|
account.id as account_id,
|
||||||
|
account.code as account_code
|
||||||
|
FROM acc_transactions_lines AS line
|
||||||
|
INNER JOIN acc_transactions AS trans on trans.id = line.id_transaction
|
||||||
|
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;
|
||||||
|
!condition=$condition
|
||||||
|
assign="amort"
|
||||||
|
}}
|
||||||
|
{{:assign var="amort_exclus." value=$trans_id}}
|
||||||
|
{{/select}}
|
@ -6,23 +6,16 @@
|
|||||||
- date_fin
|
- date_fin
|
||||||
résultat : nbjours
|
résultat : nbjours
|
||||||
*}}
|
*}}
|
||||||
{{* pour simplifier : 30 jours par mois et 360 jours par an *}}
|
|
||||||
|
|
||||||
{{:assign jour_debut=$date_debut|date:"d"}}
|
{{:assign ts_debut=$date_debut|strtotime}}
|
||||||
{{:assign jour_debut="min(%d, 30)"|math:$jour_debut}}
|
{{:assign ts_fin=$date_fin|strtotime}}
|
||||||
{{:assign mois_debut=$date_debut|date:"m"}}
|
{{:assign nbjours="1+(%d-%d)/(60*60*24)"|math:$ts_fin:$ts_debut}}
|
||||||
{{:assign annee_debut=$date_debut|date:"Y"}}
|
|
||||||
|
|
||||||
{{:assign jour_fin=$date_fin|date:"d"}}
|
|
||||||
{{:assign jour_fin="min(%d, 30)"|math:$jour_fin}}
|
|
||||||
{{:assign mois_fin=$date_fin|date:"m"}}
|
|
||||||
{{:assign annee_fin=$date_fin|date:"Y"}}
|
|
||||||
|
|
||||||
{{:assign nbjours="%d-%d"|math:$jour_fin:$jour_debut}}
|
|
||||||
{{:assign nbjours="%d+(%d-%d)*30"|math:$nbjours:$mois_fin:$mois_debut}}
|
|
||||||
{{:assign nbjours="%d+(%d-%d)*360"|math:$nbjours:$annee_fin:$annee_debut}}
|
|
||||||
|
|
||||||
{{* au cas où les deux dates seraient inversées ... *}}
|
{{* au cas où les deux dates seraient inversées ... *}}
|
||||||
{{if $nbjours < 0}}
|
{{if $nbjours < 0}}
|
||||||
{{:assign nbjours="-1*%d"|math:$nbjours}}
|
{{:assign nbjours="-1*%d"|math:$nbjours}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
{{* pour simplifier : 360 jours par an *}}
|
||||||
|
{{if $nbjours > 360}}
|
||||||
|
{{:assign nbjours=360}}
|
||||||
|
{{/if}}
|
||||||
|
14
_get_amort_code.html
Normal file
14
_get_amort_code.html
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{{* -*- brindille -*- *}}
|
||||||
|
|
||||||
|
{{*
|
||||||
|
déterminer le numéro du compte d'amortissement associé à un compte d'immobilisation
|
||||||
|
- param :
|
||||||
|
- code_immo : numéro du compte d'immobilisation
|
||||||
|
- résultat :
|
||||||
|
- code_amort : numéro du compte d'amortissement
|
||||||
|
*}}
|
||||||
|
|
||||||
|
{{:assign code_s=$code_immo|strval}}
|
||||||
|
{{:assign ch1=$code_s|substr:0:1}}
|
||||||
|
{{:assign reste=$code_s|substr:1}}
|
||||||
|
{{:assign code_amort=$ch1|cat:"8"|cat:$reste}}
|
@ -6,9 +6,14 @@
|
|||||||
|
|
||||||
{{if $current == 'index'}}
|
{{if $current == 'index'}}
|
||||||
<ul class="sub">
|
<ul class="sub">
|
||||||
{{if $subcurrent == 'amortization'}}
|
<li {{if $subcurrent == 'amort'}}class="current"{{/if}}><a href="index.html?amort=1">Amortissables</a></li>
|
||||||
|
<li {{if $subcurrent == 'fini'}}class="current"{{/if}}><a href="index.html?amort=2">Terminées</a></li>
|
||||||
|
<li {{if $subcurrent == 'no_amort'}}class="current"{{/if}}><a href="index.html?amort=0">Non amortissables</a></li>
|
||||||
|
</ul>
|
||||||
|
{{if $subsubcurrent == 'amortization'}}
|
||||||
|
<ul class="sub">
|
||||||
<li class="current"><a>Amortissements</a></li>
|
<li class="current"><a>Amortissements</a></li>
|
||||||
{{/if}}
|
|
||||||
</ul>
|
</ul>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
{{/if}}
|
||||||
</nav>
|
</nav>
|
||||||
|
13
_next_year.html
Normal file
13
_next_year.html
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{{* -*- brindille -*- *}}
|
||||||
|
{{*
|
||||||
|
Rend une date située un an après la date paramètre
|
||||||
|
paramètres :
|
||||||
|
- date
|
||||||
|
résultat : date_amort
|
||||||
|
*}}
|
||||||
|
|
||||||
|
{{:assign jour=$date|date:"d"}}
|
||||||
|
{{:assign mois=$date|date:"m"}}
|
||||||
|
{{:assign annee=$date|date:"Y"}}
|
||||||
|
{{:assign annee="%d+1"|math:$annee}}
|
||||||
|
{{:assign date_amort="%s/%s/%s"|args:$jour:$mois:$annee}}
|
@ -15,7 +15,16 @@
|
|||||||
date=$_POST.date_achat
|
date=$_POST.date_achat
|
||||||
keep="open_years, selected_year, selected_chart"
|
keep="open_years, selected_year, selected_chart"
|
||||||
}}
|
}}
|
||||||
|
{{if $selected_year == null}}
|
||||||
|
{{:error message="La date choisie n'est dans aucun exercice ouvert !!\nExercices ouverts : %s"|args:$open_years}}
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{if $_POST.no_amort}}
|
||||||
|
{{* ne pas amortir *}}
|
||||||
|
{{:assign duration=0}}
|
||||||
|
{{:assign date_debut=$ligne_immo.date_achat|parse_date}}
|
||||||
|
{{:assign noamort=true}}
|
||||||
|
{{else}}
|
||||||
{{* vérifier que la date d'acquisition est antérieure à la date de mise en service *}}
|
{{* 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}}
|
{{:assign date_debut=$_POST.date_mes|or:$_POST.date_achat|parse_date}}
|
||||||
{{if $date_debut|strtotime < $_POST.date_achat|parse_date|strtotime}}
|
{{if $date_debut|strtotime < $_POST.date_achat|parse_date|strtotime}}
|
||||||
@ -23,9 +32,8 @@
|
|||||||
{{:assign da=$_POST.date_achat|date_short}}
|
{{:assign da=$_POST.date_achat|date_short}}
|
||||||
{{:error message="Erreur : la date de mise en service (%s) ne peut être antérieure à la date d'acquisition (%s)"|args:$dd:$da}}
|
{{:error message="Erreur : la date de mise en service (%s) ne peut être antérieure à la date d'acquisition (%s)"|args:$dd:$da}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
{{:assign duration=$_POST.duree|intval}}
|
||||||
{{if $selected_year == null}}
|
{{:assign noamort=false}}
|
||||||
{{:error message="La date choisie n'est dans aucun exercice ouvert !!\nExercices ouverts : %s"|args:$open_years}}
|
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{* déterminer le numéro des comptes au cas où la clé serait un identifiant *}}
|
{{* déterminer le numéro des comptes au cas où la clé serait un identifiant *}}
|
||||||
@ -93,10 +101,16 @@
|
|||||||
validate_schema="schema.json"
|
validate_schema="schema.json"
|
||||||
type="immo"
|
type="immo"
|
||||||
line=$immo_id
|
line=$immo_id
|
||||||
duration=$_POST.duree|intval
|
duration=$duration
|
||||||
date=$date_debut
|
date=$date_debut
|
||||||
|
noamort=$noamort
|
||||||
}}
|
}}
|
||||||
{{:redirect force="index.html?ok=1&msg=immobilisation"}}
|
{{if $_POST.no_amort}}
|
||||||
|
{{:assign amort=0}}
|
||||||
|
{{else}}
|
||||||
|
{{:assign amort=1}}
|
||||||
|
{{/if}}
|
||||||
|
{{:redirect force="index.html?ok=1&msg=immobilisation&amort=%s"|args:$amort}}
|
||||||
{{/form}}
|
{{/form}}
|
||||||
|
|
||||||
{{:form_errors}}
|
{{:form_errors}}
|
||||||
@ -110,14 +124,15 @@
|
|||||||
{{/select}}
|
{{/select}}
|
||||||
|
|
||||||
<form method="post" action="">
|
<form method="post" action="">
|
||||||
<fieldset class="ajout_immo">
|
<fieldset>
|
||||||
<legend>Ajouter une immobilisation</legend>
|
<legend>Ajouter une immobilisation</legend>
|
||||||
<dl>
|
<dl>
|
||||||
|
{{:input id="no_amort" type="checkbox" value=1 name="no_amort" label="Ne pas amortir" help="Cocher pour ne pas amortir" onclick="toggleInputs('f_no_amort_1', ['f_date_mes','f_duree'])"}}
|
||||||
{{:input type="date" name="date_achat" label="Date d'acquisition" required=true default=$now|date_short}}
|
{{:input type="date" name="date_achat" label="Date d'acquisition" required=true default=$now|date_short}}
|
||||||
{{: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" help="à renseigner uniquement si différente de la date d'acquisition"}}
|
||||||
{{:input type="text" name="designation" label="Désignation" required=true}}
|
{{:input type="text" name="designation" label="Désignation" required=true}}
|
||||||
{{:input type="money" name="montant" label="Montant" required=true}}
|
{{:input type="money" name="montant" label="Montant" required=true}}
|
||||||
{{:input type="number" name="duree" label="Durée d'amortissement" required=true default=1}}
|
{{:input type="number" name="duree" label="Durée d'amortissement" required=true min=0 default=1}}
|
||||||
{{:input
|
{{:input
|
||||||
type="list"
|
type="list"
|
||||||
name="credit_account"
|
name="credit_account"
|
||||||
@ -146,4 +161,20 @@
|
|||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
{{* activer/désactiver les champs passés en paramètres *}}
|
||||||
|
<script type="text/javascript">
|
||||||
|
function toggleInputs(idcb, idfields) {
|
||||||
|
const noamort = document.getElementById(idcb);
|
||||||
|
for (let id of idfields) {
|
||||||
|
const field = document.getElementById(id);
|
||||||
|
if (noamort.checked) {
|
||||||
|
field.setAttribute("disabled","disabled");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
field.removeAttribute("disabled");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
{{:admin_footer}}
|
{{:admin_footer}}
|
||||||
|
@ -1,63 +0,0 @@
|
|||||||
{{* -*- brindille -*- *}}
|
|
||||||
|
|
||||||
{{:admin_header title="Renseigner informations amortissement" custom_css=$custom_css current="module_amortissement"}}
|
|
||||||
|
|
||||||
{{* barre de navigation *}}
|
|
||||||
{{if ! $dialog}}
|
|
||||||
{{:include file="_nav.html" current="index"}}
|
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
{{* Traiter l'envoi du formulaire *}}
|
|
||||||
{{#form on="add"}}
|
|
||||||
{{* chercher la date d'achat de l'immobilisation *}}
|
|
||||||
{{:assign var="immo_id" value=$_GET.immo_id|intval}}
|
|
||||||
{{#select
|
|
||||||
trans.date as date_achat
|
|
||||||
from acc_transactions_lines as line
|
|
||||||
inner join acc_transactions as trans on line.id_transaction = trans.id
|
|
||||||
where line.id = :line_id;
|
|
||||||
:line_id = $immo_id
|
|
||||||
assign=ligne_immo
|
|
||||||
}}
|
|
||||||
{{/select}}
|
|
||||||
|
|
||||||
{{* 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}}
|
|
||||||
{{if $date_debut|strtotime < $ligne_immo.date_achat|strtotime}}
|
|
||||||
{{:assign dd=$date_debut|date_short}}
|
|
||||||
{{:assign da=$ligne_immo.date_achat|date_short}}
|
|
||||||
{{:error message="Erreur : la date de mise en service (%s) ne peut être antérieure à la date d'acquisition (%s)"|args:$dd:$da}}
|
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
{{:assign key=""|uuid}}
|
|
||||||
{{* enregistrer les infos de l'immobilisation *}}
|
|
||||||
{{:save
|
|
||||||
key=$key
|
|
||||||
validate_schema="schema.json"
|
|
||||||
type="immo"
|
|
||||||
line=$immo_id
|
|
||||||
duration=$_POST.duree|intval
|
|
||||||
date=$date_debut
|
|
||||||
}}
|
|
||||||
|
|
||||||
{{:redirect force="index.html?ok=1&msg=durée"}}
|
|
||||||
{{/form}}
|
|
||||||
|
|
||||||
{{* renseigner la date de mise en service et durée d'amortissement *}}
|
|
||||||
<form method="post" action="">
|
|
||||||
<fieldset class="ajout_duree">
|
|
||||||
<legend>Renseigner informations amortissement</legend>
|
|
||||||
<dl>
|
|
||||||
{{: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="number" name="duree" label="Durée d'amortissement" required=true default=1}}
|
|
||||||
</dl>
|
|
||||||
</fieldset>
|
|
||||||
|
|
||||||
<p class="submit">
|
|
||||||
{{:button type="submit" name="add" label="Ajouter" shape="right" class="main"}}
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</form>
|
|
||||||
|
|
||||||
{{:form_errors}}
|
|
||||||
{{:admin_footer}}
|
|
108
add_infos.html
Normal file
108
add_infos.html
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
{{* -*- brindille -*- *}}
|
||||||
|
|
||||||
|
{{:admin_header title="Renseigner informations amortissement" custom_css=$custom_css current="module_amortissement"}}
|
||||||
|
|
||||||
|
{{* barre de navigation *}}
|
||||||
|
{{if ! $dialog}}
|
||||||
|
{{:include file="_nav.html" current="index"}}
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{* Traiter l'envoi du formulaire *}}
|
||||||
|
{{#form on="add"}}
|
||||||
|
|
||||||
|
{{* chercher la date d'acquisition de l'immobilisation *}}
|
||||||
|
{{:assign var="immo_id" value=$_GET.immo_id|intval}}
|
||||||
|
{{#select
|
||||||
|
trans.date as date_achat
|
||||||
|
from acc_transactions_lines as line
|
||||||
|
inner join acc_transactions as trans on line.id_transaction = trans.id
|
||||||
|
where line.id = :line_id;
|
||||||
|
:line_id = $immo_id
|
||||||
|
assign=ligne_immo
|
||||||
|
}}
|
||||||
|
{{/select}}
|
||||||
|
|
||||||
|
{{if $_POST.no_amort}}
|
||||||
|
{{* ne pas amortir *}}
|
||||||
|
{{:assign duration=0}}
|
||||||
|
{{:assign date_debut=$ligne_immo.date_achat|parse_date}}
|
||||||
|
{{:assign noamort=true}}
|
||||||
|
{{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}}
|
||||||
|
{{if $date_debut|strtotime < $ligne_immo.date_achat|strtotime}}
|
||||||
|
{{:assign dd=$date_debut|date_short}}
|
||||||
|
{{:assign da=$ligne_immo.date_achat|date_short}}
|
||||||
|
{{:error message="Erreur : la date de mise en service (%s) ne peut être antérieure à la date d'acquisition (%s)"|args:$dd:$da}}
|
||||||
|
{{/if}}
|
||||||
|
{{:assign duration=$_POST.duree|intval}}
|
||||||
|
{{if $duration <= 0}}
|
||||||
|
{{:error message="Erreur : la durée d'amortissement doit être strictement positive"}}
|
||||||
|
{{/if}}
|
||||||
|
{{:assign noamort=false}}
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{* enregistrer les infos de l'immobilisation *}}
|
||||||
|
{{:assign key=""|uuid}}
|
||||||
|
{{:save
|
||||||
|
key=$key
|
||||||
|
validate_schema="schema.json"
|
||||||
|
type="immo"
|
||||||
|
line=$immo_id
|
||||||
|
duration=$duration
|
||||||
|
date=$date_debut
|
||||||
|
noamort=$noamort
|
||||||
|
}}
|
||||||
|
|
||||||
|
{{if $_POST.no_amort}}
|
||||||
|
{{:assign amort=0}}
|
||||||
|
{{else}}
|
||||||
|
{{:assign amort=1}}
|
||||||
|
{{/if}}
|
||||||
|
{{:redirect force="index.html?ok=1&msg=infos&amort=%s"|args:$amort}}
|
||||||
|
{{else}}
|
||||||
|
{{:form_errors}}
|
||||||
|
{{/form}}
|
||||||
|
|
||||||
|
{{* renseigner la date de mise en service et durée d'amortissement *}}
|
||||||
|
{{if $_GET.amort == 0}}
|
||||||
|
{{:assign checked=1}}
|
||||||
|
{{:assign disabled=1}}
|
||||||
|
{{else}}
|
||||||
|
{{:assign checked=0}}
|
||||||
|
{{:assign disabled=0}}
|
||||||
|
{{/if}}
|
||||||
|
<form method="post" action="">
|
||||||
|
<fieldset id="infos_immo">
|
||||||
|
<legend></legend>
|
||||||
|
<dl>
|
||||||
|
{{:input id="no_amort" type="checkbox" value=1 name="no_amort" label="Ne pas amortir" default=$checked help="Cocher pour ne pas amortir" onclick="toggleInputs('infos_immo','f_no_amort_1')"}}
|
||||||
|
{{:input type="date" name="date_mes" label="Date de mise en service" disabled=$disabled help="à renseigner uniquement si différente de la date d'acquisition"}}
|
||||||
|
{{:input type="number" name="duree" label="Durée d'amortissement" required=true min=1 default=1 disabled=$disabled}}
|
||||||
|
</dl>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<p class="submit">
|
||||||
|
{{:button type="submit" name="add" label="Ajouter" shape="right" class="main"}}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
{{* activer/désactiver les champs de saisie *}}
|
||||||
|
<script type="text/javascript">
|
||||||
|
function toggleInputs(idfs, idcb) {
|
||||||
|
const noamort = document.getElementById(idcb);
|
||||||
|
const fs = document.getElementById(idfs);
|
||||||
|
for (let field of fs.querySelectorAll("input")) {
|
||||||
|
if (field == noamort) { continue }
|
||||||
|
if (noamort.checked) {
|
||||||
|
field.setAttribute("disabled","disabled");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
field.removeAttribute("disabled");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{{:admin_footer}}
|
@ -3,7 +3,14 @@
|
|||||||
{{:admin_header title="Liste des amortissements" custom_css="./style.css" current="module_amortissement"}}
|
{{:admin_header title="Liste des amortissements" custom_css="./style.css" current="module_amortissement"}}
|
||||||
|
|
||||||
{{* barre de navigation *}}
|
{{* barre de navigation *}}
|
||||||
{{:include file="_nav.html" current="index" subcurrent="amortization"}}
|
{{if $_GET.fini == null || $_GET.fini == 0}}
|
||||||
|
{{:assign subcurrent="amort"}}
|
||||||
|
{{elseif $_GET.fini == 1}}
|
||||||
|
{{:assign subcurrent="fini"}}
|
||||||
|
{{else}}
|
||||||
|
{{:assign subcurrent="no_amort"}}
|
||||||
|
{{/if}}
|
||||||
|
{{:include file="_nav.html" current="index" subcurrent="%s"|args:$subcurrent subsubcurrent="amortization"}}
|
||||||
|
|
||||||
{{if $_GET.ok}}
|
{{if $_GET.ok}}
|
||||||
{{if $_GET.msg|match:"attach"}}
|
{{if $_GET.msg|match:"attach"}}
|
||||||
@ -29,7 +36,7 @@
|
|||||||
{{:error message="Pas d'info concernant l'immobilisation %s"|args:$_GET.immo_id}}
|
{{:error message="Pas d'info concernant l'immobilisation %s"|args:$_GET.immo_id}}
|
||||||
{{/load}}
|
{{/load}}
|
||||||
{{:assign var="duree" from="info_immo.duration"|args:$_GET.immo_id}}
|
{{:assign var="duree" from="info_immo.duration"|args:$_GET.immo_id}}
|
||||||
{{:assign date_debut=$info_immo.date|date_short}}
|
{{:assign date_debut=$info_immo.date}}
|
||||||
|
|
||||||
{{#select
|
{{#select
|
||||||
line.id as immo_id,
|
line.id as immo_id,
|
||||||
@ -49,7 +56,7 @@
|
|||||||
:line_id = $_GET.immo_id|intval
|
:line_id = $_GET.immo_id|intval
|
||||||
assign=ligne_immo
|
assign=ligne_immo
|
||||||
}}
|
}}
|
||||||
<h2>Amortissement de « {{$label}} » d'un montant de {{"%f"|math:$montant|money_currency}} en date du {{$date_debut}} sur {{$duree}} ans</h2>
|
<h2>Amortissement de « {{$label}} » d'un montant de {{"%f"|math:$montant|money_currency}} en date du {{$date_debut|date_short}} sur {{$duree}} ans</h2>
|
||||||
{{else}}
|
{{else}}
|
||||||
{{:error message="Immobilisation %s non trouvée"|args:$_GET.immo_id}}
|
{{:error message="Immobilisation %s non trouvée"|args:$_GET.immo_id}}
|
||||||
{{/select}}
|
{{/select}}
|
||||||
@ -95,12 +102,15 @@
|
|||||||
{{* 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}}
|
||||||
|
|
||||||
{{* première annuité *}}
|
{{* première annuité *}}
|
||||||
{{:assign date_amort=$ligne_immo.date_amort|date_short}}
|
{{:assign date_amort=$ligne_immo.date_amort}}
|
||||||
|
{{if $date_amort|strtotime < $date_debut|strtotime}}
|
||||||
|
{{* changer d'exercice *}}
|
||||||
|
{{:include file="_next_year.html" date=$date_amort keep="date_amort"}}
|
||||||
|
{{:assign date_amort=$date_amort|parse_date}}
|
||||||
|
{{/if}}
|
||||||
{{:include file="_calcul_dates.html" date_debut=$date_debut date_fin=$date_amort keep="nbjours"}}
|
{{:include file="_calcul_dates.html" date_debut=$date_debut date_fin=$date_amort keep="nbjours"}}
|
||||||
{{:assign annuite_1="%f/360*%d"|math:$annuite:$nbjours|intval}}
|
{{:assign annuite_1="%f/360*%d"|math:$annuite:$nbjours|intval}}
|
||||||
|
|
||||||
{{:assign annuite_courante=$annuite_1}}
|
{{:assign annuite_courante=$annuite_1}}
|
||||||
{{:assign current_year=$ligne_immo.year_id}}
|
{{:assign current_year=$ligne_immo.year_id}}
|
||||||
{{:assign solde=$ligne_immo.montant}}
|
{{:assign solde=$ligne_immo.montant}}
|
||||||
@ -112,7 +122,7 @@
|
|||||||
Amortissements attachés à « <a class="num"
|
Amortissements attachés à « <a class="num"
|
||||||
href={{"%s/acc/transactions/details.php?id=%s"|args:$admin_url:$ligne_immo.trans_id}}>{{$ligne_immo.trans_id}}</a>
|
href={{"%s/acc/transactions/details.php?id=%s"|args:$admin_url:$ligne_immo.trans_id}}>{{$ligne_immo.trans_id}}</a>
|
||||||
{{$ligne_immo.label}} »
|
{{$ligne_immo.label}} »
|
||||||
({{"%f"|math:$ligne_immo.montant|money_currency}}, {{$date_debut}})
|
({{"%f"|math:$ligne_immo.montant|money_currency}}, {{$date_debut|date_short}})
|
||||||
</h3>
|
</h3>
|
||||||
<table class="list">
|
<table class="list">
|
||||||
<thead>
|
<thead>
|
||||||
@ -139,7 +149,7 @@
|
|||||||
<td class="num"><a href={{$trans_url}}>#{{$line.amort_trans_id}}</a></td>
|
<td class="num"><a href={{$trans_url}}>#{{$line.amort_trans_id}}</a></td>
|
||||||
<td>{{$line.amort_date|date_short}}</td>
|
<td>{{$line.amort_date|date_short}}</td>
|
||||||
<td class="money">{{"%f"|math:$line.amort_amount|money}}</td>
|
<td class="money">{{"%f"|math:$line.amort_amount|money}}</td>
|
||||||
<td class="money">{{"%f"|math:$solde|money}}</td>
|
<td class="money">{{"%f"|math:$solde|money:false}}</td>
|
||||||
<td>
|
<td>
|
||||||
{{if $line.amort_label == null}}
|
{{if $line.amort_label == null}}
|
||||||
{{$line.trans_label}}
|
{{$line.trans_label}}
|
||||||
@ -154,11 +164,7 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{:assign annuite_courante=$annuite}}
|
{{:assign annuite_courante=$annuite}}
|
||||||
{{:assign jour=$date_amort|date:"d"}}
|
{{:include file="_next_year.html" date=$date_amort keep="date_amort"}}
|
||||||
{{:assign mois=$date_amort|date:"m"}}
|
|
||||||
{{:assign annee=$date_amort|date:"Y"}}
|
|
||||||
{{:assign annee="%d+1"|math:$annee}}
|
|
||||||
{{:assign date_amort="%s/%s/%s"|args:$jour:$mois:$annee|parse_date|date_short}}
|
|
||||||
{{:assign nbamort="%d+1"|math:$nbamort}}
|
{{:assign nbamort="%d+1"|math:$nbamort}}
|
||||||
{{/foreach}}
|
{{/foreach}}
|
||||||
</tbody>
|
</tbody>
|
||||||
@ -196,9 +202,9 @@
|
|||||||
{{/select}}
|
{{/select}}
|
||||||
<tr>
|
<tr>
|
||||||
<td class="num">{{"%d+1"|math:$num}}</td>
|
<td class="num">{{"%d+1"|math:$num}}</td>
|
||||||
<td>{{$date_amort}}</td>
|
<td>{{$date_amort|date_short}}</td>
|
||||||
<td class="money">{{"%f"|math:$annuite_courante|money}}</td>
|
<td class="money">{{"%f"|math:$annuite_courante|money}}</td>
|
||||||
<td class="money">{{if $solde == 0}}0,00{{else}}{{"%f"|math:$solde|money}}{{/if}}</td>
|
<td class="money">{{$solde|money:false}}</td>
|
||||||
<td>
|
<td>
|
||||||
{{if $libelle == null}}
|
{{if $libelle == null}}
|
||||||
{{:assign libelle="Amortissement "|cat:$ligne_immo.label}}
|
{{:assign libelle="Amortissement "|cat:$ligne_immo.label}}
|
||||||
@ -216,11 +222,7 @@
|
|||||||
{{/if}}
|
{{/if}}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{:assign jour=$date_amort|date:"d"}}
|
{{:include file="_next_year.html" date=$date_amort keep="date_amort"}}
|
||||||
{{:assign mois=$date_amort|date:"m"}}
|
|
||||||
{{:assign annee=$date_amort|date:"Y"}}
|
|
||||||
{{:assign annee="%d+1"|math:$annee}}
|
|
||||||
{{:assign date_amort="%s/%s/%s"|args:$jour:$mois:$annee|parse_date|date_short}}
|
|
||||||
{{:assign annuite_courante="min(%f,%f)"|math:$annuite:$solde}}
|
{{:assign annuite_courante="min(%f,%f)"|math:$annuite:$solde}}
|
||||||
{{if $solde == 0}}{{:break}}{{/if}}
|
{{if $solde == 0}}{{:break}}{{/if}}
|
||||||
{{/foreach}}
|
{{/foreach}}
|
||||||
@ -229,6 +231,14 @@
|
|||||||
</section>
|
</section>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
|
{{if $_GET.fini == null || $_GET.fini != 1}}
|
||||||
|
|
||||||
|
{{* amortissement à exclure *}}
|
||||||
|
{{:include
|
||||||
|
file="_amort_exclus.html"
|
||||||
|
keep="amort_exclus"
|
||||||
|
}}
|
||||||
|
|
||||||
{{* Autres amortissements non rattachés *}}
|
{{* Autres amortissements non rattachés *}}
|
||||||
{{#select
|
{{#select
|
||||||
li.id as l_id,
|
li.id as l_id,
|
||||||
@ -256,8 +266,11 @@
|
|||||||
where id_transaction = :id_amort or id_related = :id_amort;
|
where id_transaction = :id_amort or id_related = :id_amort;
|
||||||
:id_amort=$t_id
|
:id_amort=$t_id
|
||||||
}}
|
}}
|
||||||
|
{{else}}
|
||||||
|
{{if $autre_amort.t_id|in:$amort_exclus}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{:assign var="autres_amortissements." value=$autre_amort}}
|
{{:assign var="autres_amortissements." value=$autre_amort}}
|
||||||
|
{{/if}}
|
||||||
{{/select}}
|
{{/select}}
|
||||||
{{/select}}
|
{{/select}}
|
||||||
|
|
||||||
@ -301,6 +314,6 @@
|
|||||||
</table>
|
</table>
|
||||||
</section>
|
</section>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
{{/if}}
|
||||||
{{:form_errors}}
|
{{:form_errors}}
|
||||||
{{:admin_footer}}
|
{{:admin_footer}}
|
||||||
|
155
immobilisations.html
Normal file
155
immobilisations.html
Normal file
@ -0,0 +1,155 @@
|
|||||||
|
{{* -*- brindille -*- *}}
|
||||||
|
|
||||||
|
{{* Liste des immobilisations amortissable ou à définir *}}
|
||||||
|
|
||||||
|
<section class="immobilisation">
|
||||||
|
<h2 class="ruler">Immobilisations en cours</h2>
|
||||||
|
|
||||||
|
<table class="list">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>N°</th>
|
||||||
|
<th>Date</th>
|
||||||
|
<th>Libellé</th>
|
||||||
|
<th class="nombre">Montant</th>
|
||||||
|
<th class="nombre">Durée</th>
|
||||||
|
<th>N° compte</th>
|
||||||
|
<th>Compte</th>
|
||||||
|
<th>Projet</th>
|
||||||
|
<th class="actions"></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
|
||||||
|
{{* lister les immobilisations *}}
|
||||||
|
{{:read file="./defaut.json" assign="config_json"}}
|
||||||
|
{{:assign config_defaut=$config_json|json_decode}}
|
||||||
|
{{:assign var="prefix_array" value=$config_defaut.prefixes|keys}}
|
||||||
|
{{:assign quote="'"}}
|
||||||
|
{{:assign condition="("}}
|
||||||
|
{{#foreach from=$prefix_array item="code"}}
|
||||||
|
{{:assign condition=$condition|cat:" account.code LIKE "|cat:$quote|cat:$code|cat:"%"|cat:$quote|cat:" OR "}}
|
||||||
|
{{/foreach}}
|
||||||
|
{{:assign condition=$condition|cat:"0)"}}
|
||||||
|
|
||||||
|
{{#select
|
||||||
|
trans.id as trans_id,
|
||||||
|
trans.label as trans_label,
|
||||||
|
trans.date as trans_date,
|
||||||
|
line.id as immo_id,
|
||||||
|
account.id as account_id,
|
||||||
|
account.code as account_code,
|
||||||
|
account.label as account_label,
|
||||||
|
line.debit AS debit,
|
||||||
|
project.label as project_label,
|
||||||
|
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
|
||||||
|
LEFT JOIN acc_projects AS project ON line.id_project = project.id
|
||||||
|
WHERE !condition
|
||||||
|
ORDER BY trans.date DESC;
|
||||||
|
!condition=$condition
|
||||||
|
}}
|
||||||
|
{{: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 duration=null}}
|
||||||
|
{{#load type="immo" where="$$.line = :line_id" :line_id=$immo_id|intval}}
|
||||||
|
{{:assign duration=$duration}}
|
||||||
|
{{if $noamort}}
|
||||||
|
{{:assign amortissable="non"}}
|
||||||
|
{{else}}
|
||||||
|
{{:assign amortissable="oui"}}
|
||||||
|
{{/if}}
|
||||||
|
{{else}}
|
||||||
|
{{:assign amortissable="nsp"}}
|
||||||
|
{{/load}}
|
||||||
|
{{if $amortissable == "non"}}
|
||||||
|
{{:continue}}
|
||||||
|
{{/if}}
|
||||||
|
{{* voir s'il existe des écritures d'amortissement associées *}}
|
||||||
|
{{#select
|
||||||
|
sum(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
|
||||||
|
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
|
||||||
|
WHERE
|
||||||
|
l_immo.id = :line_id
|
||||||
|
AND
|
||||||
|
l_amort.credit <> 0;
|
||||||
|
:line_id = $immo_id|intval
|
||||||
|
}}
|
||||||
|
{{if $amort_amount == null}}
|
||||||
|
{{:assign exist_amort=false}}
|
||||||
|
{{else}}
|
||||||
|
{{:assign amort_amount=$amort_amount}}
|
||||||
|
{{:assign exist_amort=true}}
|
||||||
|
{{/if}}
|
||||||
|
{{/select}}
|
||||||
|
{{* immo amortie ? *}}
|
||||||
|
{{if $amort_amount >= $debit}}
|
||||||
|
{{:continue}}
|
||||||
|
{{/if}}
|
||||||
|
<tr>
|
||||||
|
<td class="num"><a href={{$trans_url}}>#{{$trans_id}}</a></td>
|
||||||
|
<td>{{$trans_date|date_short}}</td>
|
||||||
|
<td>{{$trans_label}}</td>
|
||||||
|
<td class="money">{{"%f"|math:$debit|money}}</td>
|
||||||
|
<td class="money">{{if $duration != null}}{{$duration}}{{/if}}</td>
|
||||||
|
<td><a href={{$compte_url}}>{{$account_code}}</a></td>
|
||||||
|
<td>{{$account_label}}</td>
|
||||||
|
<td>{{$project_label}}</td>
|
||||||
|
<td class="actions">
|
||||||
|
{{if $duration == null}}
|
||||||
|
{{:linkbutton
|
||||||
|
label="Ajouter infos"
|
||||||
|
href="add_infos.html?immo_id=%s&amort=1"|args:$immo_id
|
||||||
|
shape="help"
|
||||||
|
target="_dialog"
|
||||||
|
}}
|
||||||
|
{{else}}
|
||||||
|
{{if ! $exist_amort}}
|
||||||
|
{{:linkbutton
|
||||||
|
label="Modifier infos"
|
||||||
|
href="modif_infos.html?immo_id=%s&amort=1"|args:$immo_id
|
||||||
|
shape="help"
|
||||||
|
target="_dialog"
|
||||||
|
}}
|
||||||
|
{{/if}}
|
||||||
|
{{:linkbutton
|
||||||
|
label="Amortissements"
|
||||||
|
href="amortization.html?immo_id=%s"|args:$immo_id
|
||||||
|
shape="table"
|
||||||
|
}}
|
||||||
|
{{/if}}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{{/select}}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<form method="post" action="">
|
||||||
|
<fieldset>
|
||||||
|
<legend>Ajouter une immobilisation</legend>
|
||||||
|
<p class="submit">
|
||||||
|
{{:linkbutton
|
||||||
|
label="Ajouter une immobilisation"
|
||||||
|
shape="plus"
|
||||||
|
href="add_asset.html"
|
||||||
|
target="_dialog"
|
||||||
|
}}
|
||||||
|
</p>
|
||||||
|
</fieldset>
|
||||||
|
</form>
|
141
immobilisations_achevees.html
Normal file
141
immobilisations_achevees.html
Normal file
@ -0,0 +1,141 @@
|
|||||||
|
{{* -*- brindille -*- *}}
|
||||||
|
|
||||||
|
{{* Liste des immobilisations totalement amorties *}}
|
||||||
|
|
||||||
|
<section class="immobilisation">
|
||||||
|
<h2 class="ruler">Immobilisations amorties</h2>
|
||||||
|
|
||||||
|
<table class="list">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>N°</th>
|
||||||
|
<th>Date</th>
|
||||||
|
<th>Libellé</th>
|
||||||
|
<th class="nombre">Montant</th>
|
||||||
|
<th class="nombre">Durée</th>
|
||||||
|
<th>N° compte</th>
|
||||||
|
<th>Compte</th>
|
||||||
|
<th>Projet</th>
|
||||||
|
<th class="actions"></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
|
||||||
|
{{* lister les immobilisations *}}
|
||||||
|
{{:read file="./defaut.json" assign="config_json"}}
|
||||||
|
{{:assign config_defaut=$config_json|json_decode}}
|
||||||
|
{{:assign var="prefix_array" value=$config_defaut.prefixes|keys}}
|
||||||
|
{{:assign quote="'"}}
|
||||||
|
{{:assign condition="("}}
|
||||||
|
{{#foreach from=$prefix_array item="code"}}
|
||||||
|
{{:assign condition=$condition|cat:" account.code LIKE "|cat:$quote|cat:$code|cat:"%"|cat:$quote|cat:" OR "}}
|
||||||
|
{{/foreach}}
|
||||||
|
{{:assign condition=$condition|cat:"0)"}}
|
||||||
|
|
||||||
|
{{#select
|
||||||
|
trans.id as trans_id,
|
||||||
|
trans.label as trans_label,
|
||||||
|
trans.date as trans_date,
|
||||||
|
line.id as immo_id,
|
||||||
|
account.id as account_id,
|
||||||
|
account.code as account_code,
|
||||||
|
account.label as account_label,
|
||||||
|
line.debit AS debit,
|
||||||
|
project.label as project_label,
|
||||||
|
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
|
||||||
|
LEFT JOIN acc_projects AS project ON line.id_project = project.id
|
||||||
|
WHERE !condition
|
||||||
|
ORDER BY trans.date DESC;
|
||||||
|
!condition=$condition
|
||||||
|
}}
|
||||||
|
{{: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 duration=null}}
|
||||||
|
{{#load type="immo" where="$$.line = :line_id" :line_id=$immo_id|intval}}
|
||||||
|
{{:assign duration=$duration}}
|
||||||
|
{{if $noamort}}
|
||||||
|
{{:assign amortissable="non"}}
|
||||||
|
{{else}}
|
||||||
|
{{:assign amortissable="oui"}}
|
||||||
|
{{/if}}
|
||||||
|
{{else}}
|
||||||
|
{{:assign amortissable="nsp"}}
|
||||||
|
{{/load}}
|
||||||
|
{{if $amortissable == "non"}}
|
||||||
|
{{:continue}}
|
||||||
|
{{/if}}
|
||||||
|
{{* voir s'il existe des écritures d'amortissement associées *}}
|
||||||
|
{{#select
|
||||||
|
sum(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
|
||||||
|
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
|
||||||
|
WHERE
|
||||||
|
l_immo.id = :line_id
|
||||||
|
AND
|
||||||
|
l_amort.credit <> 0;
|
||||||
|
:line_id = $immo_id|intval
|
||||||
|
}}
|
||||||
|
{{if $amort_amount == null}}
|
||||||
|
{{:assign exist_amort=false}}
|
||||||
|
{{else}}
|
||||||
|
{{:assign amort_amount=$amort_amount}}
|
||||||
|
{{:assign exist_amort=true}}
|
||||||
|
{{/if}}
|
||||||
|
{{/select}}
|
||||||
|
{{* immo amortie ? *}}
|
||||||
|
{{if $amort_amount < $debit}}
|
||||||
|
{{:continue}}
|
||||||
|
{{/if}}
|
||||||
|
<tr>
|
||||||
|
<td class="num"><a href={{$trans_url}}>#{{$trans_id}}</a></td>
|
||||||
|
<td>{{$trans_date|date_short}}</td>
|
||||||
|
<td>{{$trans_label}}</td>
|
||||||
|
<td class="money">{{"%f"|math:$debit|money}}</td>
|
||||||
|
<td class="money">{{if $duration != null}}{{$duration}}{{/if}}</td>
|
||||||
|
<td><a href={{$compte_url}}>{{$account_code}}</a></td>
|
||||||
|
<td>{{$account_label}}</td>
|
||||||
|
<td>{{$project_label}}</td>
|
||||||
|
<td class="actions">
|
||||||
|
{{if $duration == null}}
|
||||||
|
{{:linkbutton
|
||||||
|
label="Ajouter infos"
|
||||||
|
href="add_infos.html?immo_id=%s&amort=1"|args:$immo_id
|
||||||
|
shape="help"
|
||||||
|
target="_dialog"
|
||||||
|
}}
|
||||||
|
{{else}}
|
||||||
|
{{if ! $exist_amort}}
|
||||||
|
{{:linkbutton
|
||||||
|
label="Modifier infos"
|
||||||
|
href="modif_infos.html?immo_id=%s&amort=1"|args:$immo_id
|
||||||
|
shape="help"
|
||||||
|
target="_dialog"
|
||||||
|
}}
|
||||||
|
{{/if}}
|
||||||
|
{{:linkbutton
|
||||||
|
label="Amortissements"
|
||||||
|
href="amortization.html?immo_id=%s&fini=1"|args:$immo_id
|
||||||
|
shape="table"
|
||||||
|
}}
|
||||||
|
{{/if}}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{{/select}}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</section>
|
71
immobilisations_non.html
Normal file
71
immobilisations_non.html
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
{{* -*- brindille -*- *}}
|
||||||
|
|
||||||
|
{{* Liste des immobilisations non amortissable *}}
|
||||||
|
|
||||||
|
<section class="immobilisation">
|
||||||
|
<h2 class="ruler">Immobilisations non amortissables</h2>
|
||||||
|
|
||||||
|
<table class="list">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>N°</th>
|
||||||
|
<th>Date</th>
|
||||||
|
<th>Libellé</th>
|
||||||
|
<th class="nombre">Montant</th>
|
||||||
|
<th>N° compte</th>
|
||||||
|
<th>Compte</th>
|
||||||
|
<th>Projet</th>
|
||||||
|
<th class="actions"></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
|
||||||
|
{{#load type="immo" where="$$.noamort = true"}}
|
||||||
|
{{:assign var="lines." value="'%s'"|args:$line}}
|
||||||
|
{{/load}}
|
||||||
|
{{:assign lines=$lines|implode:","}}
|
||||||
|
{{:assign lines="("|cat:$lines|cat:")"}}
|
||||||
|
{{:assign condition="line.id IN %s"|args:$lines}}
|
||||||
|
{{#select
|
||||||
|
trans.id as trans_id,
|
||||||
|
trans.label as trans_label,
|
||||||
|
trans.date as trans_date,
|
||||||
|
line.id as immo_id,
|
||||||
|
account.id as account_id,
|
||||||
|
account.code as account_code,
|
||||||
|
account.label as account_label,
|
||||||
|
line.debit AS debit,
|
||||||
|
project.label as project_label,
|
||||||
|
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
|
||||||
|
LEFT JOIN acc_projects AS project ON line.id_project = project.id
|
||||||
|
WHERE !condition
|
||||||
|
ORDER BY trans.date DESC;
|
||||||
|
!condition=$condition
|
||||||
|
}}
|
||||||
|
{{: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}}
|
||||||
|
<tr>
|
||||||
|
<td class="num"><a href={{$trans_url}}>#{{$trans_id}}</a></td>
|
||||||
|
<td>{{$trans_date|date_short}}</td>
|
||||||
|
<td>{{$trans_label}}</td>
|
||||||
|
<td class="money">{{"%f"|math:$debit|money}}</td>
|
||||||
|
<td><a href={{$compte_url}}>{{$account_code}}</a></td>
|
||||||
|
<td>{{$account_label}}</td>
|
||||||
|
<td>{{$project_label}}</td>
|
||||||
|
<td class="actions">
|
||||||
|
{{:linkbutton
|
||||||
|
label="Modifier infos"
|
||||||
|
href="modif_infos.html?immo_id=%s&amort=0"|args:$immo_id
|
||||||
|
shape="help"
|
||||||
|
target="_dialog"
|
||||||
|
}}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{{/select}}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</section>
|
122
index.html
122
index.html
@ -1,14 +1,22 @@
|
|||||||
{{* -*- brindille -*- *}}
|
{{* -*- brindille -*- *}}
|
||||||
{{:admin_header title="Gestion des amortissements" custom_css=$custom_css current="module_amortissement"}}
|
{{:admin_header title="Gestion des amortissements" custom_css="./style.css" current="module_amortissement"}}
|
||||||
|
|
||||||
{{* barre de navigation *}}
|
{{* barre de navigation *}}
|
||||||
{{:include file="_nav.html" current="index"}}
|
{{if $_GET.amort == null || $_GET.amort == 1}}
|
||||||
|
{{:assign amort="amort"}}
|
||||||
|
{{elseif $_GET.amort == 2}}
|
||||||
|
{{:assign amort="fini"}}
|
||||||
|
{{else}}
|
||||||
|
{{:assign amort="no_amort"}}
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{:include file="_nav.html" current="index" subcurrent="%s"|args:$amort}}
|
||||||
|
|
||||||
{{if $_GET.ok}}
|
{{if $_GET.ok}}
|
||||||
{{if $_GET.msg|match:"immobilisation"}}
|
{{if $_GET.msg|match:"immobilisation"}}
|
||||||
{{:assign msg="Immobilisation enregistrée"}}
|
{{:assign msg="Immobilisation enregistrée"}}
|
||||||
{{elseif $_GET.msg|match:"durée"}}
|
{{elseif $_GET.msg|match:"infos"}}
|
||||||
{{:assign msg="Durée enregistrée"}}
|
{{:assign msg="Informations enregistrées"}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<p class="block confirm">{{$msg}}</p>
|
<p class="block confirm">{{$msg}}</p>
|
||||||
{{elseif $_GET.err}}
|
{{elseif $_GET.err}}
|
||||||
@ -29,107 +37,11 @@
|
|||||||
{{/select}}
|
{{/select}}
|
||||||
{{/load}}
|
{{/load}}
|
||||||
|
|
||||||
<section class="immobilisation">
|
{{if $amort == "amort"}}
|
||||||
<h2 class="ruler">Liste des immobilisations</h2>
|
{{:include file="./immobilisations.html"}}
|
||||||
|
{{elseif $amort == "fini"}}
|
||||||
<table class="list">
|
{{:include file="./immobilisations_achevees.html"}}
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>N°</th>
|
|
||||||
<th>Date</th>
|
|
||||||
<th>Libellé</th>
|
|
||||||
<th>Montant</th>
|
|
||||||
<th>Durée</th>
|
|
||||||
<th>N° compte</th>
|
|
||||||
<th>Compte</th>
|
|
||||||
<th>Projet</th>
|
|
||||||
<th class="actions"></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
|
|
||||||
{{* lister les immobilisations *}}
|
|
||||||
{{:read file="./defaut.json" assign="config_json"}}
|
|
||||||
{{:assign config_defaut=$config_json|json_decode}}
|
|
||||||
{{:assign var="prefix_array" value=$config_defaut.prefixes|keys}}
|
|
||||||
{{:assign quote="'"}}
|
|
||||||
{{:assign condition="("}}
|
|
||||||
{{#foreach from=$prefix_array item="code"}}
|
|
||||||
{{:assign condition=$condition|cat:" account.code LIKE "|cat:$quote|cat:$code|cat:"%"|cat:$quote|cat:" OR "}}
|
|
||||||
{{/foreach}}
|
|
||||||
{{:assign condition=$condition|cat:"0)"}}
|
|
||||||
|
|
||||||
{{#select
|
|
||||||
trans.id as trans_id,
|
|
||||||
trans.label as trans_label,
|
|
||||||
trans.date as trans_date,
|
|
||||||
line.id as immo_id,
|
|
||||||
account.id as account_id,
|
|
||||||
account.code as account_code,
|
|
||||||
account.label as account_label,
|
|
||||||
line.debit AS debit,
|
|
||||||
project.label as project_label,
|
|
||||||
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
|
|
||||||
LEFT JOIN acc_projects AS project ON line.id_project = project.id
|
|
||||||
WHERE !condition
|
|
||||||
ORDER BY trans.date DESC;
|
|
||||||
!condition=$condition
|
|
||||||
}}
|
|
||||||
{{: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}}
|
|
||||||
{{#load type="immo" where="$$.line = :line_id" :line_id=$immo_id|intval}}
|
|
||||||
{{:assign duration=$duration}}
|
|
||||||
{{else}}
|
{{else}}
|
||||||
{{:assign duration=null}}
|
{{:include file="./immobilisations_non.html"}}
|
||||||
{{/load}}
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td class="num"><a href={{$trans_url}}>#{{$trans_id}}</a></td>
|
|
||||||
<td>{{$trans_date|date_short}}</td>
|
|
||||||
<td>{{$trans_label}}</td>
|
|
||||||
<td class="money">{{"%f"|math:$debit|money}}</td>
|
|
||||||
<td class="num">{{if $duration != null}}{{$duration}}{{/if}}</td>
|
|
||||||
<td><a href={{$compte_url}}>{{$account_code}}</a></td>
|
|
||||||
<td>{{$account_label}}</td>
|
|
||||||
<td>{{$project_label}}</td>
|
|
||||||
<td class="actions">
|
|
||||||
{{if $duration == null}}
|
|
||||||
{{:linkbutton
|
|
||||||
label="Ajouter infos"
|
|
||||||
href="add_duration.html?immo_id=%s"|args:$immo_id
|
|
||||||
shape="help"
|
|
||||||
target="_dialog"
|
|
||||||
}}
|
|
||||||
{{else}}
|
|
||||||
{{:linkbutton
|
|
||||||
label="Amortissements"
|
|
||||||
href="amortization.html?immo_id=%s"|args:$immo_id
|
|
||||||
shape="table"
|
|
||||||
}}
|
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{{/select}}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<form method="post" action="">
|
|
||||||
<fieldset>
|
|
||||||
<legend>Ajouter une immobilisation</legend>
|
|
||||||
<p class="submit">
|
|
||||||
{{:linkbutton
|
|
||||||
label="Ajouter une immobilisation"
|
|
||||||
shape="plus"
|
|
||||||
href="add_asset.html"
|
|
||||||
target="_dialog"
|
|
||||||
}}
|
|
||||||
</p>
|
|
||||||
</fieldset>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
{{:admin_footer}}
|
{{:admin_footer}}
|
||||||
|
113
modif_infos.html
Normal file
113
modif_infos.html
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
{{* -*- brindille -*- *}}
|
||||||
|
|
||||||
|
{{:admin_header title="Modifier informations amortissement" custom_css=$custom_css current="module_amortissement"}}
|
||||||
|
|
||||||
|
{{* barre de navigation *}}
|
||||||
|
{{if ! $dialog}}
|
||||||
|
{{:include file="_nav.html" current="index"}}
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{* infos de l'immobilisation *}}
|
||||||
|
{{:assign var="immo_id" value=$_GET.immo_id|intval}}
|
||||||
|
{{#load type="immo" assign="info_immo" where="$$.line = :line_id" :line_id=$immo_id|intval}}
|
||||||
|
{{/load}}
|
||||||
|
|
||||||
|
{{* Traiter l'envoi du formulaire *}}
|
||||||
|
{{#form on="change"}}
|
||||||
|
|
||||||
|
{{* chercher la date d'acquisition de l'immobilisation *}}
|
||||||
|
{{#select
|
||||||
|
trans.date as date_achat
|
||||||
|
from acc_transactions_lines as line
|
||||||
|
inner join acc_transactions as trans on line.id_transaction = trans.id
|
||||||
|
where line.id = :line_id;
|
||||||
|
:line_id = $immo_id
|
||||||
|
assign=ligne_immo
|
||||||
|
}}
|
||||||
|
{{/select}}
|
||||||
|
|
||||||
|
{{if $_POST.no_amort}}
|
||||||
|
{{* ne pas amortir *}}
|
||||||
|
{{:assign duration=0}}
|
||||||
|
{{:assign date_debut=$ligne_immo.date_achat|parse_date}}
|
||||||
|
{{:assign noamort=true}}
|
||||||
|
{{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}}
|
||||||
|
{{if $date_debut|strtotime < $ligne_immo.date_achat|strtotime}}
|
||||||
|
{{:assign dd=$date_debut|date_short}}
|
||||||
|
{{:assign da=$ligne_immo.date_achat|date_short}}
|
||||||
|
{{:error message="Erreur : la date de mise en service (%s) ne peut être antérieure à la date d'acquisition (%s)"|args:$dd:$da}}
|
||||||
|
{{/if}}
|
||||||
|
{{:assign duration=$_POST.duree|intval}}
|
||||||
|
{{if $duration <= 0}}
|
||||||
|
{{:error message="Erreur : la durée d'amortissement doit être strictement positive"}}
|
||||||
|
{{/if}}
|
||||||
|
{{:assign noamort=false}}
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{* enregistrer les infos modifiées de l'immobilisation *}}
|
||||||
|
{{:save
|
||||||
|
key=$info_immo.key
|
||||||
|
validate_schema="schema.json"
|
||||||
|
type="immo"
|
||||||
|
line=$immo_id
|
||||||
|
duration=$duration
|
||||||
|
date=$date_debut
|
||||||
|
noamort=$noamort
|
||||||
|
}}
|
||||||
|
|
||||||
|
{{if $_POST.no_amort}}
|
||||||
|
{{:assign amort=0}}
|
||||||
|
{{else}}
|
||||||
|
{{:assign amort=1}}
|
||||||
|
{{/if}}
|
||||||
|
{{:redirect force="index.html?ok=1&msg=infos&amort=%s"|args:$amort}}
|
||||||
|
{{else}}
|
||||||
|
{{:form_errors}}
|
||||||
|
{{/form}}
|
||||||
|
|
||||||
|
{{* modifier la date de mise en service et durée d'amortissement *}}
|
||||||
|
|
||||||
|
{{if $_GET.amort == 0}}
|
||||||
|
{{:assign checked=1}}
|
||||||
|
{{:assign disabled=1}}
|
||||||
|
{{else}}
|
||||||
|
{{:assign checked=0}}
|
||||||
|
{{:assign disabled=0}}
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
<form method="post" action="">
|
||||||
|
<fieldset id="infos_immo">
|
||||||
|
<legend></legend>
|
||||||
|
<dl>
|
||||||
|
{{:input id="no_amort" type="checkbox" value=1 name="no_amort" label="Ne pas amortir" default=$checked help="Cocher pour ne pas amortir" onclick="toggleInputs('infos_immo','f_no_amort_1')"}}
|
||||||
|
{{:input type="date" name="date_mes" label="Date de mise en service" default=$info_immo.date disabled=$disabled help="à renseigner uniquement si différente de la date d'acquisition"}}
|
||||||
|
{{:input type="number" name="duree" label="Durée d'amortissement" default=$info_immo.duration required=true min=1 disabled=$disabled}}
|
||||||
|
</dl>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<p class="submit">
|
||||||
|
{{:button type="submit" name="change" label="Modifier" shape="right" class="main"}}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
{{* activer/désactiver les champs de saisie *}}
|
||||||
|
<script type="text/javascript">
|
||||||
|
function toggleInputs(idfs, idcb) {
|
||||||
|
const noamort = document.getElementById(idcb);
|
||||||
|
const fs = document.getElementById(idfs);
|
||||||
|
for (let field of fs.querySelectorAll("input")) {
|
||||||
|
if (field == noamort) { continue }
|
||||||
|
if (noamort.checked) {
|
||||||
|
field.setAttribute("disabled","disabled");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
field.removeAttribute("disabled");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{{:admin_footer}}
|
@ -43,11 +43,13 @@
|
|||||||
{{:assign config_defaut=$config_json|json_decode}}
|
{{:assign config_defaut=$config_json|json_decode}}
|
||||||
{{:assign var="prefix_array" value=$config_defaut.prefixes|keys}}
|
{{:assign var="prefix_array" value=$config_defaut.prefixes|keys}}
|
||||||
{{#foreach from=$prefix_array item="code"}}
|
{{#foreach from=$prefix_array item="code"}}
|
||||||
{{:assign code_s=$code|strval}}
|
{{* déterminer le numéro du compte d'amortissement associé au compte d'immobilisation *}}
|
||||||
{{:assign ch1=$code_s|substr:0:1}}
|
{{:include
|
||||||
{{:assign reste=$code_s|substr:1}}
|
file="./_get_amort_code.html"
|
||||||
{{:assign code=$ch1|cat:"8"|cat:$reste}}
|
code_immo=$code
|
||||||
{{:assign var="amort_array." value=$code|intval}}
|
keep="code_amort"
|
||||||
|
}}
|
||||||
|
{{:assign var="amort_array." value=$code_amort|intval}}
|
||||||
{{/foreach}}
|
{{/foreach}}
|
||||||
|
|
||||||
{{:include
|
{{:include
|
||||||
@ -113,10 +115,12 @@
|
|||||||
d'immobilisation => ajouter un 8 après le 2 de tête
|
d'immobilisation => ajouter un 8 après le 2 de tête
|
||||||
*}}
|
*}}
|
||||||
{{#select code, label from acc_accounts where id = :id; :id=$_GET.account assign=amort_account}}{{/select}}
|
{{#select code, label from acc_accounts where id = :id; :id=$_GET.account assign=amort_account}}{{/select}}
|
||||||
{{:assign c1=$amort_account.code|substr:0:1}}
|
{{:include
|
||||||
{{:assign reste=$amort_account.code|substr:1}}
|
file="./_get_amort_code.html"
|
||||||
{{:assign amort_code=$c1|cat:8|cat:$reste}}
|
code_immo=$amort_account.code
|
||||||
{{:assign var="credit_account.%s"|args:$amort_code value="%s — Amortissements "|args:$amort_code|cat:$amort_account.label}}
|
keep="code_amort"
|
||||||
|
}}
|
||||||
|
{{:assign var="credit_account.%s"|args:$code_amort value="%s — Amortissements "|args:$code_amort|cat:$amort_account.label}}
|
||||||
|
|
||||||
{{#select
|
{{#select
|
||||||
id,
|
id,
|
||||||
|
@ -18,6 +18,9 @@
|
|||||||
"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"
|
||||||
|
},
|
||||||
|
"noamort" : {
|
||||||
|
"type" : ["null", "boolean"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["type", "line", "duration", "date"]
|
"required": ["type", "line", "duration", "date"]
|
||||||
|
Loading…
Reference in New Issue
Block a user