diff --git a/_archives.html b/_archives.html
index b5d2cc6..a4356d6 100644
--- a/_archives.html
+++ b/_archives.html
@@ -153,7 +153,7 @@
{{$account_code}}
{{$account_label}}
- {{:linkbutton label="Modifier" href="exit_step1.html?immo_doc_id=%s&from=exit"|args:$info_immo.id shape="edit"}}
+ {{:linkbutton label="Modifier" href="exit_step1.html?immo_doc_id=%s"|args:$info_immo.id shape="edit"}}
{{/select}}
diff --git a/_get_free_amort.html b/_get_free_amort.html
index b3b142f..8a2649b 100644
--- a/_get_free_amort.html
+++ b/_get_free_amort.html
@@ -2,7 +2,7 @@
{{*
lister les amortissement non rattachés à une immo
- @param condition
+ @param filter_condition
*}}
{{#select
line.id as line_id,
@@ -18,9 +18,9 @@
FROM acc_transactions_lines AS line
INNER JOIN acc_accounts AS account ON account.id = line.id_account
INNER JOIN acc_transactions AS trans ON trans.id = line.id_transaction
- WHERE credit > 0 AND (NOT trans.status & 16) AND !condition
+ WHERE credit > 0 AND (NOT trans.status & 16) AND !filter_condition
ORDER BY trans.date, trans.label;
- !condition=$condition
+ !filter_condition=$filter_condition
assign="amort_line"
}}
{{* voir s'il existe des lignes d'immo liées à cette ligne d'amortissement *}}
diff --git a/_immobilisations.html b/_immobilisations.html
index 93648ec..ab4d4d6 100644
--- a/_immobilisations.html
+++ b/_immobilisations.html
@@ -76,7 +76,7 @@
{{:assign montant_immo=$doc_amount|or:$debit}}
{{:assign immo_date = $doc_date_achat|or:$trans_date}}
{{:assign label_immo=$doc_label|or:$trans_label}}
- {{if $label_immo|strpos:$line_label === false}}
+ {{if $line_label != null && $line_label != $label_immo}}
{{:assign label_immo=$label_immo|cat:" — "|cat:$line_label}}
{{/if}}
diff --git a/_immobilisations_autres.html b/_immobilisations_autres.html
index 383ba12..7a4b04c 100644
--- a/_immobilisations_autres.html
+++ b/_immobilisations_autres.html
@@ -149,8 +149,6 @@
{{#foreach from=$module.config.filters item="filter"}}
{{if $trans_label|strpos:$filter !== false}}
{{:assign status="ignored"}}
- {{else}}
- {{:assign status=""}}
{{/if}}
{{/foreach}}
{{/if}}
diff --git a/_nav.html b/_nav.html
index a3bf0b8..c81e1f3 100644
--- a/_nav.html
+++ b/_nav.html
@@ -16,7 +16,6 @@
En cours
À classer
Configuration
- Aide
{{if $subcurrent != null}}
diff --git a/_unfinished.html b/_unfinished.html
index f67f188..edbd320 100644
--- a/_unfinished.html
+++ b/_unfinished.html
@@ -129,6 +129,7 @@
{{*
TODO cas où :
- il y a (au moins) une écriture d'avoir
+ - il y a une écriture qui solde l'immo (montant = montant immo - avoir
*}}
{{* voir s'il existe une écriture qui solde l'immobilisation (voir ci-dessus) *}}
diff --git a/add_asset.html b/add_asset.html
index 3738fa3..6c21221 100644
--- a/add_asset.html
+++ b/add_asset.html
@@ -161,7 +161,7 @@
{{:admin_header title="Ajout immobilisation" current="module_amortization"}}
{{* barre de navigation *}}
{{if ! $dialog}}
- {{:linkbutton href="index.html" label="Retour" shape="left"}}
+ {{:include file="_nav.html" current="managed" subcurrent="add_asset"}}
{{/if}}
{{:form_errors}}
@@ -224,7 +224,7 @@
{{:input type="number" name="duree" label="Durée d'amortissement" required=true min=0 default=1 suffix="année(s)"}}
- {{:input type="date" name="date_mes" label="Date de mise en service" default=$now|date_short help="C'est la date de première utilisation ; à modifier si différente de la date d'acquisition"}}
+ {{:input type="date" name="date_mes" label="Date de mise en service" help="C'est la date de première utilisation ; à renseigner uniquement si différente de la date d'acquisition"}}
@@ -245,8 +245,5 @@ function changeYear(evt, f_accounts = ['credit_account', 'debit_account'], f_yea
(function () {
document.getElementById('f_id_year').onchange = changeYear;
- document.getElementById('f_date_achat').addEventListener("change", (e) => {
- document.getElementById('f_date_mes').value = document.getElementById('f_date_achat').value;
- });
})();
diff --git a/add_infos.html b/add_infos.html
index 9a45878..6e5fe46 100644
--- a/add_infos.html
+++ b/add_infos.html
@@ -200,9 +200,9 @@
Classement
Faites un choix (obligatoire)
- {{:input type="radio-btn" name="classify" value="managed" label="Immobilisation à amortir" default=$choix_defaut}}
+ {{:input type="radio-btn" name="classify" value="managed" label="Immobilisation à amortir" help="L'immobilisation sera classée parmi les immobilisations amortissables" default=$choix_defaut}}
{{if $ligne_immo.date_achat > $first_date}}
- {{:input type="radio-btn" name="classify" value="archived" label="Immobilisation sortie du bilan" default=$choix_defaut}}
+ {{:input type="radio-btn" name="classify" value="archived" label="Immobilisation sortie du bilan" help="L'immobilisation sera classée parmi les immobilisations sorties du bilan" default=$choix_defaut}}
{{/if}}
{{:input type="radio-btn" name="classify" value="ignored" label="Immobilisation à ignorer" help="L'écriture n'apparaitra plus dans la liste des immobilisations" default=$choix_defaut}}
@@ -211,11 +211,11 @@
Informations
- {{:input type="date" name="date_achat" label="Date d'acquisition" default=$date_achat_defaut help="à modifier si nécessaire"}}
- {{:input type="text" name="libelle" label="Libellé" default=$immo_label help="à modifier si nécessaire"}}
- {{:input type="money" name="montant" label="Montant de l'immobilisation" required=true default=$reste help="à modifier si différent du montant de l'écriture d'immobilisation"}}
{{:input type="number" name="duree" label="Durée d'amortissement" required=true min=1 suffix="année(s)"}}
+ {{:input type="money" name="montant" label="Montant de l'immobilisation" required=true default=$reste help="à modifier si différent du montant de l'écriture d'immobilisation"}}
+ {{:input type="date" name="date_achat" label="Date d'acquisition" default=$date_achat_defaut help="à modifier si nécessaire"}}
{{:input type="date" name="date_mes" label="Date de mise en service" default=$date_mes_defaut help="à modifier si différente de la date d'acquisition"}}
+ {{:input type="text" name="libelle" label="Libellé" default=$immo_label help="à modifier si nécessaire"}}
@@ -236,6 +236,7 @@ function toggleInputs(event) {
const managed = classement_immo.querySelector('input[type=radio][value=managed]');
if (managed.checked) {
g.toggle('.masquable', true);
+ document.getElementById('f_duree').focus();
} else {
g.toggle('.masquable', false);
}
@@ -247,9 +248,6 @@ toggleInputs();
radios.forEach(radio => {
radio.addEventListener("change", toggleInputs);
});
- document.getElementById('f_date_achat').addEventListener("change", (e) => {
- document.getElementById('f_date_mes').value = document.getElementById('f_date_achat').value;
- });
})();
diff --git a/aide.html b/aide.html
deleted file mode 100644
index 0bf1430..0000000
--- a/aide.html
+++ /dev/null
@@ -1,12 +0,0 @@
-{{* -*- brindille -*- *}}
-
-{{:admin_header title="Aide" custom_css="./style_aide.css" current="module_amortization"}}
-
-{{* barre de navigation *}}
-{{:include file="_nav.html" current="aide"}}
-
-
-
- {{:include file="doc/aide.html"}}
-
-
diff --git a/amortization.html b/amortization.html
index 7d73749..085edd3 100644
--- a/amortization.html
+++ b/amortization.html
@@ -15,7 +15,7 @@
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$ligne_immo.trans_id}}
{{:assign date_debut=$info_immo.date_mes|or:$info_immo.date_achat|or:$ligne_immo.date_achat}}
{{:assign label_immo=$info_immo.label|or:$ligne_immo.trans_label}}
-{{if $label_immo|strpos:$ligne_immo.line_label === false}}
+{{if $ligne_immo.line_label != null && $ligne_immo.line_label != $label_immo}}
{{:assign label_immo=$label_immo|cat:" — "|cat:$ligne_immo.line_label}}
{{/if}}
{{if $info_immo.amount != null}}
@@ -39,11 +39,7 @@
{{* lister les amortissements non attachés à une immo *}}
{{:assign account_filter="28%"|quote_sql}}
{{:assign filter_condition="account.code LIKE "|cat:$account_filter}}
-
- {{:assign date_amort=$date_debut|quote_sql}}
- {{:assign date_condition="trans.date >= "|cat:$date_amort}}
- {{:assign condition=$date_condition|cat:" AND "|cat:$filter_condition}}
- {{:include file="./_get_free_amort.html" condition=$condition keep="free_amort_lines"}}
+ {{:include file="./_get_free_amort.html" filter_condition=$filter_condition keep="free_amort_lines"}}
{{/if}}
{{:admin_header title="Détails de l'immobilisation" custom_css="./style.css" current="module_amortization"}}
@@ -178,8 +174,8 @@
{{$line.date|date_short}}
{{$line.label}}
{{"%f"|math:$line.amount|money_currency_html:false|raw}}
-
- {{if ! $created_amort}}
+
+ {{if $total_amort == 0}}
{{:linkbutton label="Détacher" href="detach_credit.html?immo_doc_id=%s&credit_line_id=%s"|args:$_GET.immo_doc_id:$line.credit_line_id shape="minus"}}
{{/if}}
@@ -243,7 +239,7 @@
{{"%f"|math:$solde|money_html:false|raw}}
{{$line.account_code}}
{{$line.account_label}}
-
+
{{if ! $created_amort}}
{{:linkbutton label="Détacher" href="detach_amort.html?immo_doc_id=%s&amort_line_id=%s"|args:$_GET.immo_doc_id:$line.line_id shape="minus"}}
{{/if}}
diff --git a/attach_amort.html b/attach_amort.html
index c03821b..a6d05bb 100644
--- a/attach_amort.html
+++ b/attach_amort.html
@@ -14,7 +14,7 @@
{{/if}}
{{:assign label_immo=$info_immo.label|or:$ligne_immo.trans_label}}
-{{if $label_immo|strpos:$ligne_immo.line_label === false}}
+{{if $ligne_immo.line_label != null && $ligne_immo.line_label != $label_immo}}
{{:assign label_immo=$label_immo|cat:" — "|cat:$ligne_immo.line_label}}
{{/if}}
{{:assign montant_immo=$info_immo.amount|or:$ligne_immo.amount}}
@@ -130,7 +130,7 @@
{{/if}}
{{if $_GET.from == "exit"}}
- {{:redirect force="exit_step2.html?immo_doc_id=%s&from=exit&ok=1&msg=attach_amort"|args:$_GET.immo_doc_id}}
+ {{:redirect force="exit_step2.html?immo_doc_id=%s&ok=1&msg=attach_amort"|args:$_GET.immo_doc_id}}
{{else}}
{{:redirect force="amortization.html?immo_doc_id=%s&type_immo=%s&ok=1&msg=attach_amort"|args:$_GET.immo_doc_id:$status}}
{{/if}}
diff --git a/attach_cession.html b/attach_cession.html
index bd78460..8ffe851 100644
--- a/attach_cession.html
+++ b/attach_cession.html
@@ -36,4 +36,4 @@
cession_line_id=$_GET.cession_line_id|intval
}}
-{{:redirect force="exit_step3.html?immo_doc_id=%s&from=exit&ok=1&msg=attach_cession"|args:$_GET.immo_doc_id}}
+{{:redirect force="exit_step3.html?immo_doc_id=%s&ok=1&msg=attach_cession"|args:$_GET.immo_doc_id}}
diff --git a/attach_credit.html b/attach_credit.html
index 59cc802..276dc76 100644
--- a/attach_credit.html
+++ b/attach_credit.html
@@ -14,22 +14,13 @@
{{/if}}
{{:assign label_immo=$info_immo.label|or:$ligne_immo.trans_label}}
-{{if $label_immo|strpos:$ligne_immo.line_label === false }}
+{{if $ligne_immo.line_label != null && $ligne_immo.line_label != $label_immo}}
{{:assign label_immo=$label_immo|cat:" — "|cat:$ligne_immo.line_label}}
{{/if}}
-{{if $info_immo.amount != null}}
- {{:assign var="ligne_immo.amount" value=$info_immo.amount}}
-{{/if}}
-
{{* déduire le montant des écritures liées à l'immo courante au crédit du même compte *}}
{{:include file="_get_credit_lines.html" immo_doc_id=$_GET.immo_doc_id keep="total_credits"}}
-{{:assign valeur_residuelle="%d-%d"|math:$ligne_immo.amount:$total_credits}}
-
-{{* lister les amortissements liés à l'immobilisation *}}
-{{:include file="./_get_amort_lines.html" immo_doc_id=$_GET.immo_doc_id keep="linked_amort, total_amort, created_amort"}}
-{{:assign valeur_residuelle="%d-%d"|math:$valeur_residuelle:$total_amort}}
-
+{{:assign solde_immo="%d-%d"|math:$ligne_immo.amount:$total_credits}}
{{* chercher l'écriture au crédit du compte d'immobilisation *}}
{{#select
@@ -71,42 +62,53 @@
{{/if}}
{{else}}
{{:assign montant_credit=$_POST.montant|money_int}}
- {{/if}}
-
- {{* vérifier que le montant saisi est inférieur à la valeur nette de l'écriture d'immobilisation *}}
- {{if $montant_credit > $valeur_residuelle}}
- {{:assign solde_nb="%f"|math:$valeur_residuelle|money_currency:false}}
- {{:error message="Le montant de l'avoir ne peut être supérieur à la valeur nette de l'immobilisation (%s)"|args:$solde_nb}}
- {{/if}}
-
- {{* vérifier que le montant saisi est inférieur au reste de l'écriture de crédit *}}
- {{if $montant_credit > $reste}}
- {{:assign reste_nb="%f"|math:$reste|money_currency:false}}
- {{:error message="Le montant de l'avoir ne peut être supérieur au reste (%s)"|args:$reste_nb}}
- {{/if}}
- {{if $montant_credit == $credit_line.amount}}
- {{:assign saved_credit=null}}
- {{else}}
- {{:assign saved_credit=$montant_credit}}
+ {{* vérifier que le montant saisi est inférieur au solde de l'écriture d'immobilisation *}}
+ {{if $montant_credit > $solde_immo}}
+ {{:assign solde_nb="%f"|math:$solde_immo|money_currency:false}}
+ {{:error message="Le montant de l'avoir ne peut être supérieur au montant de l'immobilisation (%s)"|args:$solde_nb}}
+ {{/if}}
+ {{* vérifier que le montant saisi est inférieur au reste de l'écriture de crédit *}}
+ {{if $montant_credit > $reste}}
+ {{:assign reste_nb="%f"|math:$reste|money_currency:false}}
+ {{:error message="Le montant de l'avoir ne peut être supérieur au reste (%s)"|args:$reste_nb}}
+ {{/if}}
+ {{if $montant_credit == $credit_line.amount}}
+ {{:assign saved_credit=null}}
+ {{else}}
+ {{:assign saved_credit=$montant_credit}}
+ {{/if}}
{{/if}}
{{* Lier l'écriture de crédit à l'écriture d'immobilisation *}}
{{:include file="_common_attach.html" immo_doc_id=$_GET.immo_doc_id trans_id=$credit_line.trans_id}}
- {{* enregistrer la liaison des lignes d'immo *}}
- {{:save
- key=""|uuid
- type="credit_link"
- immo_doc_id=$_GET.immo_doc_id|intval
- credit_line_id=$_GET.credit_line_id|intval
- amount=$saved_credit
- }}
+{{*
+ TODO ? vérifier le succès avant d'enregistrer le doc ?
+*}}
- {{if $_GET.from == "exit"}}
- {{:redirect force="exit_step1.html?immo_doc_id=%s&from=%s&ok=1&msg=attach_avoir"|args:$_GET.immo_doc_id:$_GET.from}}
- {{else}}
- {{:redirect force="amortization.html?immo_doc_id=%s&ok=1&msg=attach_avoir"|args:$_GET.immo_doc_id}}
- {{/if}}
+{{* enregistrer la liaison des lignes d'immo *}}
+{{:save
+ key=""|uuid
+ type="credit_link"
+ immo_doc_id=$_GET.immo_doc_id|intval
+ credit_line_id=$_GET.credit_line_id|intval
+ amount=$saved_credit
+}}
+
+ {{*
+{{if $montant_credit == $solde_immo}}
+ {{:save
+ id=$_GET.immo_doc_id
+ status="archived"
+ }}
+{{/if}}
+*}}
+
+{{if $_GET.from == "exit"}}
+ {{:redirect force="exit_step1.html?immo_doc_id=%s&ok=1&msg=attach_avoir"|args:$_GET.immo_doc_id}}
+{{else}}
+ {{:redirect force="amortization.html?immo_doc_id=%s&ok=1&msg=attach_avoir"|args:$_GET.immo_doc_id}}
+{{/if}}
{{/form}}
{{:admin_header title="Écritures au crédit du compte d'immobilisation" custom_css="./style.css" current="module_amortization"}}
diff --git a/attach_exit.html b/attach_exit.html
index 36cf6bf..2dda568 100644
--- a/attach_exit.html
+++ b/attach_exit.html
@@ -36,4 +36,4 @@
exit_line_id=$_GET.exit_line_id|intval
}}
-{{:redirect to="exit_step4.html?immo_doc_id=%s&from=exit&ok=1&msg=attach_exit"|args:$_GET.immo_doc_id}}
+{{:redirect to="exit_step4.html?immo_doc_id=%s&ok=1&msg=attach_exit"|args:$_GET.immo_doc_id}}
diff --git a/balance_sheet_exit.html b/balance_sheet_exit.html
index da92038..a561c80 100644
--- a/balance_sheet_exit.html
+++ b/balance_sheet_exit.html
@@ -10,9 +10,15 @@
{{if $message != null}}
{{:error message=$message}}
{{/if}}
+{{* TODO VÉRIFIER SI UTILE *}}
+{{*
+{{if $info_immo.duration == null || $info_immo.duration == 0}}
+ {{:error message="Vous devez renseigner la durée d'amortissement au préalable"}}
+{{/if}}
+*}}
{{:assign label_immo=$info_immo.label|or:$ligne_immo.trans_label}}
-{{if $label_immo|strpos:$ligne_immo.line_label === false}}
+{{if $ligne_immo.line_label != null && $ligne_immo.line_label != $label_immo}}
{{:assign label_immo=$label_immo|cat:" — "|cat:$ligne_immo.line_label}}
{{/if}}
diff --git a/compute_exit_data.html b/compute_exit_data.html
index f45a6fe..c824af5 100644
--- a/compute_exit_data.html
+++ b/compute_exit_data.html
@@ -19,7 +19,7 @@
{{/if}}
{{:assign label_immo=$info_immo.label|or:$ligne_immo.trans_label}}
-{{if $label_immo|strpos:$ligne_immo.line_label === false}}
+{{if $ligne_immo.line_label != null && $ligne_immo.line_label != $label_immo}}
{{:assign label_immo=$label_immo|cat:" — "|cat:$ligne_immo.line_label}}
{{/if}}
diff --git a/config.html b/config.html
index a8c91c9..ec47093 100644
--- a/config.html
+++ b/config.html
@@ -129,6 +129,27 @@
{{/if}}