diff --git a/_check_date.html b/_check_date.html
new file mode 100644
index 0000000..f68ec49
--- /dev/null
+++ b/_check_date.html
@@ -0,0 +1,19 @@
+{{* -*- 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 order="start_date" assign="open_years."}}
+ {{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}}
diff --git a/_next_year.html b/_next_year.html
new file mode 100644
index 0000000..0de8dea
--- /dev/null
+++ b/_next_year.html
@@ -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}}
diff --git a/amortization.html b/amortization.html
index 0e97af0..ad2c891 100644
--- a/amortization.html
+++ b/amortization.html
@@ -137,9 +137,9 @@
{{/if}}
-
Amortissements enregistrés
{{if $linked_lines != null}}
+ Amortissements enregistrés
-{{else}}
- Aucun amortissement enregistré pour cette immobilisation
{{/if}}
{{if $_GET.type_immo == null || $_GET.type_immo != "fini"}}
@@ -221,7 +219,7 @@
{{if $autres_amortissements != null}}
- Amortissements non rattachés
+ Autres amortissements non rattachés
diff --git a/_archives.html b/archives.html
similarity index 100%
rename from _archives.html
rename to archives.html
diff --git a/_immobilisations.html b/immobilisations.html
similarity index 100%
rename from _immobilisations.html
rename to immobilisations.html
diff --git a/_immobilisations_autres.html b/immobilisations_autres.html
similarity index 96%
rename from _immobilisations_autres.html
rename to immobilisations_autres.html
index 2d81e86..c987088 100644
--- a/_immobilisations_autres.html
+++ b/immobilisations_autres.html
@@ -120,11 +120,6 @@
target="_dialog"
}}
{{/if}}
- {{:linkbutton
- label="Amortissements"
- href="amortization.html?immo_id=%s&type_immo=autres"|args:$immo_id
- shape="table"
- }}
{{/select}}
diff --git a/immobilisations_non.html b/immobilisations_non.html
new file mode 100644
index 0000000..39fbd96
--- /dev/null
+++ b/immobilisations_non.html
@@ -0,0 +1,72 @@
+{{* -*- brindille -*- *}}
+
+{{* Liste des immobilisations non amortissables *}}
+
+
+ Immobilisations non amortissables
+
+
+
+
+ | N° |
+ Date |
+ Libellé |
+ Montant |
+ N° compte |
+ Compte |
+ Projet |
+ |
+
+
+
+
+ {{#load type="immo" where="$$.status = 'ignored'"}}
+ {{: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}}
+ {{#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}}
+
+ | #{{$trans_id}} |
+ {{$trans_date|date_short}} |
+ {{$trans_label}} |
+ {{"%f"|math:$debit|money:false}} |
+ {{$account_code}} |
+ {{$account_label}} |
+ {{$project_label}} |
+
+ {{:linkbutton
+ label="Modifier infos"
+ href="modif_infos.html?immo_id=%s&amort=0"|args:$immo_id
+ shape="help"
+ target="_dialog"
+ }}
+ |
+
+ {{/select}}
+
+
+
diff --git a/index.html b/index.html
index 9af0454..3d7bfe2 100644
--- a/index.html
+++ b/index.html
@@ -1,5 +1,5 @@
{{* -*- brindille -*- *}}
-{{:admin_header title="Immobilisations et amortissements" custom_css="./style.css" current="module_amortization"}}
+{{:admin_header title="Immobilisations et amortissements" custom_css="./style.css" current="module_amortissement"}}
{{* barre de navigation *}}
{{if $_GET.type_immo == null}}
@@ -32,14 +32,27 @@
{{else}}
{{:delete key=$key}}
{{/select}}
+
+ {{* supprimer les documents correspondant à une écriture de la balance d'ouverture
+ {{#select
+ line.id as line_id,
+ trans.status
+ FROM acc_transactions_lines as line
+ INNER JOIN acc_transactions AS trans on line.id_transaction = trans.id
+ WHERE line.id = :line_id AND (trans.status & 16);
+ :line_id = $line
+ }}
+ {{:delete key=$key}}
+ {{/select}}
+ *}}
{{/load}}
{{if $type_immo == "autres"}}
- {{:include file="_immobilisations_autres.html"}}
+ {{:include file="./immobilisations_autres.html"}}
{{elseif $type_immo == "archive"}}
- {{:include file="_archives.html"}}
+ {{:include file="archives.html"}}
{{elseif $type_immo == "encours" || $type_immo == "fini"}}
- {{:include file="_immobilisations.html"}}
+ {{:include file="./immobilisations.html"}}
{{/if}}
{{:admin_footer}}
diff --git a/modif_infos.html b/modif_infos.html
new file mode 100644
index 0000000..7181226
--- /dev/null
+++ b/modif_infos.html
@@ -0,0 +1,118 @@
+{{* -*- 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 status="ignored"}}
+ {{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 status="managed"}}
+ {{/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
+ status=$status
+ }}
+
+ {{if $_POST.no_amort}}
+ {{:assign amort="autres"}}
+ {{else}}
+ {{:assign amort="encours"}}
+ {{/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}}
+
+
+
+{{* activer/désactiver les champs de saisie *}}
+
+
+{{:admin_footer}}