diff --git a/README.md b/README.md index 578af08..e771e69 100644 --- a/README.md +++ b/README.md @@ -4,14 +4,15 @@ Ce module permet de gérer les écritures d'amortissements pour les immobilisati - lister les immobilisations - ajouter une nouvelle immobilisation -- lister les amortissements d'une immobilisation +- lister les amortissements d'une immobilisation : + - amortissements déjà enregistrés + - amortissements à venir +- associer une écriture d'amortissement à une immobilisation - enregistrer un nouvel amortissement -- incorporer d'anciennes immobilisations et leurs amortisements ## Installation - télécharger [l'archive zip](https://link.infini.fr/amortissement) - cliquer « Configuration » puis « Extensions » - en bas de la page, cliquer « Importer un module » - sélectionner l'archive téléchargée ci-dessus -- activer le module - +- activer le module qui est maintenant présent dans la liste des extensions inactives diff --git a/_archives.html b/_archives.html index a4356d6..ce92aff 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"|args:$info_immo.id shape="edit"}} + {{:linkbutton label="Modifier" href="exit_step4.html?immo_doc_id=%s"|args:$info_immo.id shape="edit"}} {{/select}} diff --git a/_common_detach.html b/_common_detach.html index 8c84736..b4e80d0 100644 --- a/_common_detach.html +++ b/_common_detach.html @@ -1,13 +1,12 @@ {{* -*- brindille -*- *}} {{* - Supprimer l'association entre une ligne d'immo et une autre ligne (amort, credit, cession, sortie) + Supprimer l'association entre deux lignes @param immo_doc_id : id du doc associé à la ligne d'immobilisation @param line_id : id de la ligne à détacher *}} - {{* données de l'immobilisation *}} -{{:include file="_get_immo_data.html" immo_doc_id=$immo_doc_id|intval keep="info_immo, ligne_immo, message"}} +{{:include file="_get_immo_data.html" immo_doc_id=$immo_doc_id|intval keep="ligne_immo, message"}} {{if $message != null}} {{:error message=$message}} {{/if}} diff --git a/_immobilisations_autres.html b/_immobilisations_autres.html index 7a4b04c..0401feb 100644 --- a/_immobilisations_autres.html +++ b/_immobilisations_autres.html @@ -86,7 +86,7 @@ !table_join WHERE !condition GROUP BY immo_line_id - ORDER BY trans.date; + ORDER BY trans.date DESC; !columns=$columns !table_join=$table_join !table=$module.table diff --git a/_nav.html b/_nav.html index c81e1f3..fac14e4 100644 --- a/_nav.html +++ b/_nav.html @@ -1,31 +1,55 @@ {{* -*- brindille -*- *}} -{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$ligne_immo.trans_id}} -
-
-
-
Immobilisation
-
#{{$ligne_immo.trans_id}} {{$label_immo}}
-
Montant
-
{{"%f"|math:$montant_immo|money_currency_html:false|raw}}
-
Début d'amortissement
-
{{$date_mes|date_short}}
-
-
- - {{if $free_amort_lines != null}} +{{if $free_amort_lines != null}} +
+

Immobilisation « {{$label_immo}} »

@@ -94,6 +78,11 @@ {{#foreach from=$free_amort_lines item="line"}} +{{* + {{if $_GET.filter && $line.account_code != $code_amort}} + {{:continue}} + {{/if}} +*}} {{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$line.trans_id}} {{:assign compte_url="%s/acc/accounts/journal.php?id=%s&year=%s"|args:$admin_url:$line.account_id:$line.year}} @@ -118,12 +107,11 @@ {{/foreach}} -

Sélectionner une écriture d'amortissement pour l'associer à l'immobilisation

- {{else}} -

Aucun amortissement pour le compte {{$code_amort}}

- {{/if}} -
+
+{{else}} +

Aucun amortissement pour le compte {{$code_amort}}

+{{/if}} {{:form_errors}} diff --git a/save_amort.html b/save_amort.html index 2504ff8..1705579 100644 --- a/save_amort.html +++ b/save_amort.html @@ -65,7 +65,7 @@ *}} {{:assign msg_years=""}} {{#years closed=false order="start_date" where="start_date <= :debut AND :debut <= end_date" - :debut=$date_debut assign="years."}} + :debut=$date_debut assign=years.}} {{if $total_amort == 0}} {{:assign ts_debut=$date_debut|strtotime}} {{else}} @@ -148,12 +148,6 @@ {{:error message="Le montant indiqué « %s » dépasse le solde à amortir « %s »"|args:$montant:$solde}} {{/if}} - {{* - supprimer les documents qui pointent sur une ligne d'amortissement absente - cas de la suppression manuelle d'un amortissement - *}} - {{:include file="_remove_orphan_docs.tpl"}} - {{* enregistrer l'écriture *}} {{:assign var="lines." @@ -167,6 +161,7 @@ account=$credit_account|keys|value:0 id_project=$ligne_immo.id_project }} + {{:api method="POST" path="accounting/transaction" @@ -196,30 +191,26 @@ {{* immo soldée ? *}} {{if $_POST.montant|trim|money_int == $solde}} - {{:assign status="amortized"}} + {{:assign var="info_immo.status" value="amortized"}} {{:save key=$info_immo.key - status=$status + status=$info_immo.status }} {{/if}} - {{:redirect force="amortization.html?immo_doc_id=%s&type_immo=%s&ok=1&msg=amortissement"|args:$_GET.immo_doc_id:$status}} + {{:redirect force="amortization.html?immo_doc_id=%s&type_immo=%s&ok=1&msg=amortissement"|args:$_GET.immo_doc_id:$info_immo.status}} {{/form}} -{{:assign label_immo=$info_immo.label|or:$ligne_immo.trans_label}} - -{{:admin_header title="Amortissement pour « %s »"|args:$label_immo custom_css="./style.css" current="module_amortization"}} +{{:admin_header title="Ajout amortissement" custom_css="./style.css" current="module_amortization"}} {{* barre de navigation *}} {{if ! $dialog}} - {{:include file="_nav.html" current="managed" subcurrent="amortization"}} + {{:include file="_nav.html" current="index" subcurrent="managed" subsubcurrent="amortization"}} {{/if}} {{:form_errors}} -{{if $years|count == 1}} - {{:assign var=selected_year value=$years.0.id}} -{{/if}} +{{:assign var=selected_year value=$years.0.id}} {{:assign var=date_amort value=$years.0.end_date}} {{:include file="_calcul_dates.html" date_debut=$date_debut date_fin=$date_amort keep="nbjours"}} diff --git a/scripts.js b/scripts.js index 3def0ba..c59df55 100644 --- a/scripts.js +++ b/scripts.js @@ -12,10 +12,9 @@ function toggleInputs(idcb, idfields) { } } -function toggleVisibility(id_check, fields) { - const elem = document.getElementById(id_check); - fields.forEach(function (id_field) { - const field = document.getElementById(id_field); +function toggleVisibility(idcheck, fields) { + const elem = document.getElementById(idcheck); + fields.forEach(function (field) { if (elem.checked) { field.classList.remove('hidden'); } else { @@ -145,21 +144,19 @@ function setSelectorYear(button_names, f_years_selector) // Associer au bouton « Enlever » de chaque ligne l'action de suppression de la ligne function initLine(row) { - let removeBtn = row.querySelector('button[name="remove_line"]'); - if (removeBtn != null) { - removeBtn.onclick = () => { - let count = removeBtn.closest("table").querySelectorAll('tbody tr').length; - var min = removeBtn.getAttribute('min'); + var removeBtn = row.querySelector('button[name="remove_line"]'); + removeBtn.onclick = () => { + let count = removeBtn.closest("table").querySelectorAll('tbody tr').length; + var min = removeBtn.getAttribute('min'); - if (count <= min) { - alert("Il n'est pas possible d'avoir moins de " + min + " ligne(s)."); - return false; - } + if (count <= min) { + alert("Il n'est pas possible d'avoir moins de " + min + " ligne(s)."); + return false; + } - row.parentNode.removeChild(row); - return true; - }; - } + row.parentNode.removeChild(row); + return true; + }; } // Associer au bouton « Ajouter » de chaque table l'action d'ajouter une ligne @@ -187,28 +184,6 @@ function addLine(button, codes) { let lib = newNode.querySelector('.input-list span.label'); lib.innerText = ''; - // si besoin, ajouter le bouton de suppression - let action_cell = newNode.querySelector('td.actions'); - let removeBtn = newNode.querySelector('button[name="remove_line"]'); - if (removeBtn == null) { - const attributs = { - "title" : "Enlever une ligne", - "min": "1", - "name": "remove_line", - "data-icon": "➖", - "type": "button", - "class": "icn-btn", - "value": "1", - "aria-label": "Enlever une ligne" - }; - let new_button = document.createElement("button"); - new_button.appendChild(document.createTextNode("Enlever")); - for (let attr in attributs) { - new_button.setAttribute(attr, attributs[attr]); - } - action_cell.appendChild(new_button); - } - // ajouter la nouvelle ligne line.parentNode.appendChild(newNode); initLine(newNode); diff --git a/transfer.html b/transfer.html index 6a491b1..a9c9f50 100644 --- a/transfer.html +++ b/transfer.html @@ -181,7 +181,6 @@ duration=$duration date_mes=null status=$status - created=true }} {{if $_POST.amortir}} {{:assign type_immo="managed"}} @@ -193,7 +192,7 @@ {{:admin_header title="Transfert d'immobilisation en cours" custom_css="./style.css" current="module_amortization"}} {{if ! $dialog}} - {{:include file="_nav.html" current="unfinished" subcurrent="transfer"}} + {{:include file="_nav.html" current="index" subcurrent="unfinished" subsubcurrent="transfer"}} {{/if}} {{:form_errors}} diff --git a/write_exit.html b/write_exit.html index cfd4a3a..0a17d3b 100644 --- a/write_exit.html +++ b/write_exit.html @@ -142,7 +142,6 @@ type="amort_link" immo_doc_id=$info_immo.id amort_line_id=$line.id - created=true }} {{/if}} {{/foreach}} @@ -208,7 +207,6 @@ type="exit_link" immo_doc_id=$info_immo.id exit_line_id=$line.id - created=true }} {{:break}} {{/if}} @@ -254,7 +252,6 @@ type="cession_link" immo_doc_id=$info_immo.id cession_line_id=$line.id - created=true }} {{:break}} {{/if}} @@ -270,12 +267,7 @@ {{:admin_header title="Sortie du bilan" custom_css="./style.css" current="module_amortization"}} {{if ! $dialog}} - {{if $valeur_nette > 0}} - {{:assign type_immo="managed"}} - {{else}} - {{:assign type_immo="amortized"}} - {{/if}} - {{:include file="_nav.html" current="%s"|args:$type_immo subcurrent="balance_exit"}} + {{:include file="_nav.html" current="index" subcurrent="balance_exit"}} {{/if}} {{*