diff --git a/_archives.html b/_archives.html index b5d2cc6..a4356d6 100644 --- a/_archives.html +++ b/_archives.html @@ -153,7 +153,7 @@
| {{$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 +237,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..eec7baf 100644 --- a/config.html +++ b/config.html @@ -129,7 +129,6 @@ {{/if}} |