diff --git a/_get_free_amort.html b/_get_free_amort.html index 8a2649b..1e9809e 100644 --- a/_get_free_amort.html +++ b/_get_free_amort.html @@ -41,7 +41,6 @@ {{* pas de ligne d'immo liée à cette ligne d'amort => garder cette ligne d'amortissement *}} {{/load}} {{if $keep_amort && $amort_amount < $amort_line.amount}} - {{:assign var="amort_line.amount" value="%d-%d"|math:$amort_line.amount:$amort_amount}} {{:assign var="free_amort_lines." value=$amort_line}} {{/if}} {{/select}} diff --git a/_immobilisations.html b/_immobilisations.html index ab4d4d6..8e56aef 100644 --- a/_immobilisations.html +++ b/_immobilisations.html @@ -124,7 +124,7 @@ {{$account_code}} {{:linkbutton - label="Détails" + label="Voir" href="amortization.html?immo_doc_id=%s&type_immo=%s"|args:$immo_doc_id:$type_immo shape="eye" }} diff --git a/_immobilisations_autres.html b/_immobilisations_autres.html index 0401feb..bacef59 100644 --- a/_immobilisations_autres.html +++ b/_immobilisations_autres.html @@ -114,6 +114,7 @@ {{:assign var="immo_lines." value=$immo_line}} {{/select}} +{{*:debug lines=$immo_lines nb_lines=$immo_lines|count nb_null=$nb_null nb_managed=$nb_managed nb_ignored=$nb_ignored nb_other=$nb_other unhide=$unhide*}}
@@ -147,7 +148,7 @@ {{else}} {{* vérifier si le libellé aurait pu être filtré *}} {{#foreach from=$module.config.filters item="filter"}} - {{if $trans_label|strpos:$filter !== false}} + {{if $filter|strpos:$trans_label !== false}} {{:assign status="ignored"}} {{/if}} {{/foreach}} diff --git a/_remove_orphan_docs.tpl b/_remove_orphan_docs.tpl index 2514171..4799e33 100644 --- a/_remove_orphan_docs.tpl +++ b/_remove_orphan_docs.tpl @@ -1,45 +1,28 @@ {{* -*- brindille -*- *}} -{{if $module.table}} - {{* supprimer les documents sans écriture associée *}} - {{:assign var="docs." type="amort_link" field="amort_line_id"}} - {{:assign var="docs." type="credit_link" field="credit_line_id"}} - {{:assign var="docs." type="cession_link" field="cession_line_id"}} - {{:assign var="docs." type="exit_link" field="exit_line_id"}} - {{:assign var="docs." type="immo" field="line"}} +{{* supprimer les documents sans écriture associée *}} +{{:assign var="docs." type="amort_link" field="amort_line_id"}} +{{:assign var="docs." type="credit_link" field="credit_line_id"}} +{{:assign var="docs." type="cession_link" field="cession_line_id"}} +{{:assign var="docs." type="exit_link" field="exit_line_id"}} +{{:assign var="docs." type="immo" field="line"}} - {{#foreach from=$docs}} +{{#foreach from=$docs}} - {{:assign join_field="$$."|cat:$field}} - {{:assign type_name=$type|quote_sql}} - {{:assign type_cond="$$.type"|cat:" = "|cat:$type_name}} + {{:assign join_field="$$."|cat:$field}} + {{:assign type_name=$type|quote_sql}} + {{:assign type_cond="$$.type"|cat:" = "|cat:$type_name}} - {{* vérifier existence écriture associée au doc *}} - {{#select - info.id as info_id, - $$.immo_doc_id as immo_doc_id, - line.id as line_id - FROM !table AS info - LEFT JOIN acc_transactions_lines as line ON !join_field = line.id - WHERE !type_cond - ; - !table=$module.table - !type_cond = $type_cond - !join_field = $join_field - assign="line" - }} - {{if $line.line_id == null}} - {{:delete id=$line.info_id}} - {{/if}} - - {{* vérifier existence doc immo *}} - {{if $type != "immo"}} - {{#load id=$immo_doc_id assign="immo_doc"}} - {{else}} - {{:delete id=$line.info_id}} - {{/load}} - {{/if}} - {{/select}} - - {{/foreach}} -{{/if}} + {{#select + info.id + FROM !table AS info + LEFT JOIN acc_transactions_lines as line ON !join_field = line.id + WHERE !type_cond AND line.id IS NULL + ; + !table=$module.table + !type_cond = $type_cond + !join_field = $join_field + }} + {{:delete id=$id}} + {{/select}} +{{/foreach}} diff --git a/amortization.html b/amortization.html index 1bb78db..f7c9d43 100644 --- a/amortization.html +++ b/amortization.html @@ -29,7 +29,13 @@ {{* 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="linked_immos, total_credits"}} {{:assign solde="%d-%d"|math:$ligne_immo.amount:$total_credits}} -{{:assign valeur_residuelle=$solde}} + +{{if $info_immo.status == "amortized"}} + {{:assign amort_amount=$solde}} + {{:assign valeur_residuelle=0}} +{{else}} + {{:assign valeur_residuelle=$solde}} +{{/if}} {{* 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"}} @@ -107,14 +113,15 @@

Immobilisation

- +

+
@@ -138,7 +145,7 @@ {{/if}} {{if $valeur_residuelle > 0}}
Montant des amortissements
-
{{$total_amort|money_currency_html:false|raw}}
+
{{"%d-%d"|math:$solde:$valeur_residuelle|money_currency_html:false|raw}}
Valeur nette résiduelle
{{$valeur_residuelle|money_currency_html:false|raw}}
{{/if}} @@ -149,43 +156,8 @@
-

Avoirs

- - -{{if $linked_immos != null}} - - - - - - - - - - {{#foreach from=$linked_immos item="line"}} - {{:assign url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$line.trans_id}} - - - - - - - - {{/foreach}} - -
DateLibelléMontant
#{{$line.trans_id}}{{$line.date|date_short}}{{$line.label}}{{"%f"|math:$line.amount|money_currency_html:false|raw}} - {{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}} -
-{{/if}} -

Amortissements

- +

{{if $linked_amort != null}}
@@ -259,5 +231,40 @@

Aucun amortissement enregistré pour cette immobilisation ; utilisez le bouton « Enregistrer un amortissement » pour enregistrer un nouvel amortissement

{{/if}} +

Avoirs

+

+ {{if $total_amort == 0}} + {{:linkbutton label="Attacher une écriture d'avoir" href="link_immo.html?immo_doc_id=%s"|args:$_GET.immo_doc_id shape="link" target="_dialog"}} + {{/if}} +

+ +{{if $linked_immos != null}} + + + + + + + + + + {{#foreach from=$linked_immos item="line"}} + {{:assign url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$line.trans_id}} + + + + + + + + {{/foreach}} + +
DateLibelléMontant
#{{$line.trans_id}}{{$line.date|date_short}}{{$line.label}}{{"%f"|math:$line.amount|money_currency_html:false|raw}} + {{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}} +
+{{/if}} + {{:form_errors}} {{:admin_footer}} diff --git a/attach_credit.html b/attach_credit.html index 6e8d22a..721278d 100644 --- a/attach_credit.html +++ b/attach_credit.html @@ -107,7 +107,7 @@ {{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}} + {{:redirect force="amortization.html?immo_doc_id=%s&ok=1&msg=attach_credit"|args:$_GET.immo_doc_id}} {{/if}} {{/form}} diff --git a/modify_infos.html b/modify_infos.html index 5b89e91..f430bbd 100644 --- a/modify_infos.html +++ b/modify_infos.html @@ -188,14 +188,14 @@
Paramètres de l'amortissement
- {{:input type="number" name="duree" label="Durée d'amortissement" min=1 default=$info_immo.duration suffix="année(s)"}} + {{:input type="number" name="duree" label="Durée d'amortissement" min=1 default=$info_immo.duration}} + {{:input type="text" name="libelle" label="Libellé" default=$info_immo.label}} {{if $info_immo.amount != null}} {{:assign max_aff="%f"|math:$max_disponible|money_currency:false}} {{:input type="money" name="montant" label="Montant de l'immobilisation" default=$montant_immo help="Montant maximum : %s"|args:$max_aff}} {{/if}} - {{:input type="date" name="date_achat" label="Date d'acquisition" default=$info_immo.date_achat help="si différente de la date de l'écriture d'immobilisation"}} - {{:input type="date" name="date_mes" label="Date de mise en service" default=$info_immo.date_mes help="si différente de la date d'acquisition"}} - {{:input type="text" name="libelle" label="Libellé" default=$info_immo.label help="si différent du libellé de l'écriture d'immobilisation"}} + {{:input type="date" name="date_achat" label="Date d'acquisition" default=$info_immo.date_achat}} + {{:input type="date" name="date_mes" label="Date de mise en service" default=$info_immo.date_mes}}

diff --git a/other_amortizations.html b/other_amortizations.html index bc5b2c5..febaefa 100644 --- a/other_amortizations.html +++ b/other_amortizations.html @@ -23,7 +23,14 @@ code_immo=$ligne_immo.account_code keep="code_amort" }} - {{:assign filter_condition="account.code = "|cat:$code_amort}} + {{:include file="_get_config.html" keep="module.config"}} + {{:assign account_condition="account.code = "|cat:$code_amort}} + {{:assign filter_condition=$account_condition|cat:" AND NOT ("}} + {{#foreach from=$module.config.filters item="filter"}} + {{:assign filter="%"|cat:$filter|cat:"%"|quote_sql}} + {{:assign filter_condition=$filter_condition|cat:" trans.label LIKE "|cat:$filter|cat:" OR "}} + {{/foreach}} + {{:assign filter_condition=$filter_condition|cat:"0)"}} {{else}} {{:assign account_filter="28%"|quote_sql}} {{:assign filter_condition="account.code LIKE "|cat:$account_filter}} diff --git a/save_amort.html b/save_amort.html index 1705579..c5c8c7b 100644 --- a/save_amort.html +++ b/save_amort.html @@ -22,6 +22,10 @@ {{/if}} {{:assign var="amort_label" value="Amortissement %s"|args:$amort_label}} +{{if $info_immo.status == "amortized" || $info_immo.status == "archived"}} + {{:error message="Cette immobilisation est complètement amortie ; il est impossible d'ajouter une écriture d'amortissement"}} +{{/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 var="ligne_immo.amount" value="%d-%d"|math:$ligne_immo.amount:$total_credits}} @@ -78,9 +82,7 @@ {{:assign var="years_data.%d"|args:$id value=$ts_debut|cat:" "|cat:$ts_fin}} {{:assign msg_years=$msg_years|cat:"\n"|cat:" - "|cat:$label|cat:" : "|cat:$debut|cat:" à "|cat:$fin}} {{else}} - {{:assign date_debut=$date_debut|date_short}} - {{:assign msg="Pas d'exercice ouvert pour enregistrer un amortissement à partir du %s"|args:$date_debut}} - {{:error message=$msg}} + {{:error message="Aucun exercice ouvert pour enregistrer un amortissement"}} {{/years}} {{* Traiter l'envoi du formulaire *}}