diff --git a/_archives.html b/_archives.html index eea991f..e774b6d 100644 --- a/_archives.html +++ b/_archives.html @@ -37,9 +37,10 @@ {{* Immobilisation avec une écriture de sortie de bilan *}} {{:read file="./defaut.json" assign="config_json"}} {{:assign config_defaut=$config_json|json_decode}} +{{:assign var="prefix_array" value=$config_defaut.prefixes|keys}} {{:assign condition="("}} -{{#foreach from=$config_defaut.prefixes item="code"}} +{{#foreach from=$prefix_array item="code"}} {{:assign code=$code|cat:"%"|quote_sql}} {{:assign condition=$condition|cat:"account.code LIKE "|cat:$code|cat:" OR "}} {{/foreach}} @@ -78,6 +79,8 @@ {{/select}}
+

Immobilisations archivées

+ {{:assign nb_immo=0}} diff --git a/_get_config.html b/_get_config.html deleted file mode 100644 index 25cd4e7..0000000 --- a/_get_config.html +++ /dev/null @@ -1,23 +0,0 @@ -{{* -*- brindille -*- *}} - -{{* - Récupérer la config -*}} - -{{* config par défaut *}} -{{:read file="./defaut.json" assign="config_defaut"}} -{{:assign config_defaut=$config_defaut|json_decode}} - -{{* -{{if $module.config.tva != null}} - {{:assign var="config.tva" value=$module.config.tva}} -{{else}} - {{:assign var="config.tva" value=$config_defaut.tva}} -{{/if}} -*}} - -{{if $module.config.prefixes != null}} - {{:assign var="config.prefixes" value=$module.config.prefixes}} -{{else}} - {{:assign var="config.prefixes" value=$config_defaut.prefixes}} -{{/if}} diff --git a/_immobilisations.html b/_immobilisations.html index 28041ac..e9d6eab 100644 --- a/_immobilisations.html +++ b/_immobilisations.html @@ -3,6 +3,11 @@ {{* Liste des immobilisations en cours ou amorties *}}
+ {{if $type_immo == "managed"}} +

Immobilisations en cours

+ {{elseif $type_immo == "amortized"}} +

Immobilisations amorties

+ {{/if}} {{:assign nb_immo=0}}
@@ -23,8 +28,9 @@ {{* lister les immobilisations *}} {{:read file="./defaut.json" assign="config_json"}} {{:assign config_defaut=$config_json|json_decode}} + {{:assign var="prefix_array" value=$config_defaut.prefixes|keys}} {{:assign condition="("}} - {{#foreach from=$config_defaut.prefixes item="code"}} + {{#foreach from=$prefix_array item="code"}} {{:assign code=$code|cat:"%"|quote_sql}} {{:assign condition=$condition|cat:" account.code LIKE "|cat:$code|cat:" OR "}} {{/foreach}} diff --git a/_immobilisations_autres.html b/_immobilisations_autres.html index c404863..f283686 100644 --- a/_immobilisations_autres.html +++ b/_immobilisations_autres.html @@ -3,12 +3,9 @@ {{* Liste des immobilisations non amortissables ou non (encore) gérées *}}
+

Autres immobilisations

{{:assign nb_immo=0}} -

- Cette page liste les écritures pas (encore) prises en charges par le module ou classées non amortissables -

-
{{:input type="checkbox" value=1 name="unhide" label="Afficher les écritures marquées ignorées" }} @@ -32,8 +29,9 @@ {{* lister les immobilisations *}} {{:read file="./defaut.json" assign="config_json"}} {{:assign config_defaut=$config_json|json_decode}} + {{:assign var="prefix_array" value=$config_defaut.prefixes|keys}} {{:assign condition="("}} - {{#foreach from=$config_defaut.prefixes item="code"}} + {{#foreach from=$prefix_array item="code"}} {{:assign code=$code|cat:"%"|quote_sql}} {{:assign condition=$condition|cat:" account.code LIKE "|cat:$code|cat:" OR "}} {{/foreach}} diff --git a/_nav.html b/_nav.html index 517cc4d..fc5c3c3 100644 --- a/_nav.html +++ b/_nav.html @@ -8,20 +8,21 @@ {{elseif $subsubcurrent == "amortization" && $type_immo == null || $type_immo == "managed" || $type_immo == "other"}} {{/if}} - + {{if $current == "index"}} {{* && $subsubcurrent != "balance_exit" *}} + + {{/if}} {{if $subsubcurrent == "amortization"}}
    diff --git a/add_asset.html b/add_asset.html index 31ec3dc..597126f 100644 --- a/add_asset.html +++ b/add_asset.html @@ -2,6 +2,7 @@ {{:read file="./defaut.json" assign="config_json"}} {{:assign config_defaut=$config_json|json_decode}} +{{:assign var="prefix_array" value=$config_defaut.prefixes|keys}} {{#years closed=false order="start_date" assign=years.}} {{:assign ts_debut=$start_date|strtotime}} @@ -73,7 +74,7 @@ file="_check_account.html" account=$debit_account chart_id=$selected_chart - prefix_array=$config_defaut.prefixes + prefix_array=$prefix_array keep="account_ok" }} @@ -137,7 +138,7 @@ {{:assign var="projects.%d"|args:$id value=$label}} {{/select}} -{{#foreach from=$config_defaut.prefixes item="code"}} +{{#foreach from=$prefix_array item="code"}} {{:assign var="pattern_array." value="%s*"|args:$code}} {{/foreach}} {{:assign var="patterns" value=$pattern_array|implode:"|"}} diff --git a/add_infos.html b/add_infos.html index a147948..b79b867 100644 --- a/add_infos.html +++ b/add_infos.html @@ -76,7 +76,7 @@ {{:form_errors}} {{/form}} -{{:admin_header title="Informations amortissement" custom_css=$custom_css current="module_amortissement"}} +{{:admin_header title="Renseigner informations amortissement" custom_css=$custom_css current="module_amortissement"}} {{* barre de navigation *}} {{if ! $dialog}} @@ -100,19 +100,14 @@ - renseigner ou modifier la date de mise en service et la durée d'amortissement *}} -
    - Classement +
    +
    (obligatoire)
    - {{:input type="radio-btn" name="classify" value="managed" label="Amortir" default=$default onclick="toggleInputs('div_inputs','f_classify_managed', 'f_classify_amortized')"}} - {{:input type="radio-btn" name="classify" value="amortized" label="Amortissement terminé" help="Cette immobilisation sera classée parmi les immobilisations amorties" default=$default onclick="toggleInputs('div_inputs','f_classify_managed', 'f_classify_amortized')"}} - {{:input type="radio-btn" name="classify" value="ignored" label="Ignorer l'écriture" help="Cette écriture n'apparaitra plus dans la liste des immobilisations" default=$default onclick="toggleInputs('div_inputs','f_classify_managed', 'f_classify_amortized')"}} -
    -
    + {{:input type="radio" name="classify" value="managed" label="Amortir" help="Amortir cette immobilisation" default=$default onclick="toggleInputs('div_inputs','f_classify_managed', 'f_classify_amortized')"}} + {{:input type="radio" name="classify" value="amortized" label="Amortissement terminé" help="Cette immobilisation sera classée parmi les immobilisations amorties" default=$default onclick="toggleInputs('div_inputs','f_classify_managed', 'f_classify_amortized')"}} + {{:input type="radio" name="classify" value="ignored" label="Ignorer l'écriture" help="Cette écriture n'apparaitra plus dans la liste des immobilisations" default=$default onclick="toggleInputs('div_inputs','f_classify_managed', 'f_classify_amortized')"}} -
    - Informations -
    {{if $info_immo != null}} {{:assign date_defaut=$info_immo.date}} {{:assign duree_defaut=$info_immo.duration}} diff --git a/config.html b/config.html deleted file mode 100644 index 6506ce9..0000000 --- a/config.html +++ /dev/null @@ -1,191 +0,0 @@ -{{* -*- brindille -*- *}} - -{{:admin_header title="Configuration" custom_css="./style.css" current="module_amortissement"}} -{{* barre de navigation *}} -{{:include file="_nav.html" current="config"}} -{{if $_GET.ok == 1}} -

    Configuration enregistrée.

    -{{/if}} - -{{* lecture config (défaut ou enregistrée) *}} -{{:include file="./_get_config.html" keep="config"}} - -{{#form on="save"}} - {{:assign ok=0}} - {{#foreach from=$_POST.immo_accounts item="line"}} - {{:assign elem=$line|values}} - {{:assign elem=$elem.0}} - {{:assign var="fields" value=$elem|explode:" "}} - {{:assign present=false}} - {{* ne pas garder si préfixe d'un compte déjà présent *}} - {{#foreach from=$account_codes item="code"}} - {{:assign pos=$code|strpos:$fields.0}} - {{if $pos !== false}} - {{:assign present=true}} - {{:break}} - {{/if}} - {{/foreach}} - {{if ! $present}} - {{:assign var="account_codes." value=$fields.0}} - {{/if}} - {{/foreach}} - - {{:save - key="config" - prefixes=$account_codes|sort - }} - {{:assign ok=1}} - - {{:redirect to="./config.html?ok=%d"|args:$ok}} -{{/form}} - -{{* récupérer l'exercice courant *}} -{{:assign var="selected_year" from="logged_user.preferences.accounting_year}} -{{if $selected_year == null}} - {{* sélectionner l'exercice le plus probable *}} - {{#years closed=false order="start_date"}} - {{:assign var="open_years.%d"|args:$id value=$label}} - {{if $start_date|strtotime <= $now && $end_date|strtotime >= $now}} - {{:assign selected_year=$id}} - {{:break}} - {{/if}} - {{/years}} -{{/if}} - -{{* libellés des comptes d'immobilisation *}} -{{:assign condition="("}} -{{#foreach from=$config.prefixes item="code"}} - {{:assign code=$code|quote_sql}} - {{:assign condition=$condition|cat:" account.code = "|cat:$code|cat:" OR "}} -{{/foreach}} -{{:assign condition=$condition|cat:"0)"}} -{{:assign condition=$condition|cat:" AND year.id = %s"|args:$selected_year}} - -{{#select - account.id as account_id, - account.code, - account.id_chart, - account.label, - year.label as year_label, - chart.label as chart_label - FROM acc_accounts AS account - INNER JOIN acc_charts AS chart ON chart.id = account.id_chart - INNER JOIN acc_years AS year ON year.id_chart = chart.id - WHERE !condition - ; - !condition=$condition - }} - {{:assign var="accounts.%s"|args:$code label=$label id=$account_id}} -{{/select}} - -

    Comptes d'immobilisation

    - - -

    - Les immobilisations sont cherchées dans les comptes sélectionnées et leurs sous-comptes. -

    - -
- - - - - - - - {{#foreach from=$accounts key=code item=elem}} - - - - - {{/foreach}} - - - - - - - -
Compte
- {{:assign var="immo_account.%s.%s"|args:$code:$code value="%s — "|args:$code|cat:$elem.label}} - {{:assign var="current_account" from="immo_account.%s"|args:$code}} - {{*:debug immo_account=$immo_account current_account=$current_account*}} - {{:input - type="list" - name="immo_accounts[]" - target="!acc/charts/accounts/selector.php?codes=%s&id_year=%d"|args:$code::$selected_year - default=$current_account - }} - - {{:button - label="Enlever" - title="Enlever une ligne" - shape="minus" - min="1" - name="remove_line" - }} -
{{:button shape="plus" label="Ajouter" title="Ajouter un compte"}}
- -

- {{:button type="submit" name="save" label="Enregistrer" shape="right" class="main"}} -

- - - - - - diff --git a/defaut.json b/defaut.json index 06771a5..5c00d9b 100644 --- a/defaut.json +++ b/defaut.json @@ -1,8 +1,8 @@ { "tva": false, - "prefixes": [ - "20", - "21", - "27" - ] + "prefixes": { + "20": "Immobilisations incorporelles", + "21": "Immobilisations corporelles", + "27": "Immobilisations financières" + } } diff --git a/index.html b/index.html index 27fd870..586ea5b 100644 --- a/index.html +++ b/index.html @@ -1,4 +1,5 @@ {{* -*- brindille -*- *}} +{{:admin_header title="Immobilisations et amortissements" custom_css="./style.css" current="module_amortization"}} {{* barre de navigation *}} {{if $_GET.type_immo == null}} @@ -7,16 +8,6 @@ {{:assign type_immo=$_GET.type_immo}} {{/if}} - {{if $type_immo == "managed"}} - {{:admin_header title="Immobilisations en cours" custom_css="./style.css" current="module_amortization"}} - {{elseif $type_immo == "amortized"}} - {{:admin_header title="Immobilisations amorties" custom_css="./style.css" current="module_amortization"}} - {{elseif $type_immo == "archived"}} - {{:admin_header title="Immobilisations archivées" custom_css="./style.css" current="module_amortization"}} - {{elseif $type_immo == "other"}} - {{:admin_header title="Autres immobilisations" custom_css="./style.css" current="module_amortization"}} - {{/if}} - {{:include file="_nav.html" current="index" subcurrent="%s"|args:$type_immo}} {{if $_GET.ok}} diff --git a/module.ini b/module.ini index 89362b0..a583efe 100644 --- a/module.ini +++ b/module.ini @@ -1,5 +1,5 @@ name="Amortissements" -description="Immobilisations et amortissements" +description="Gestion des amortissements pour le logiciel de comptabilité Paheko" author="Jean-Christophe Engel" author_url="https://gitea.zaclys.com/lesanges" home_button=false diff --git a/save_amort.html b/save_amort.html index 7ad6b50..06f5a26 100644 --- a/save_amort.html +++ b/save_amort.html @@ -149,7 +149,8 @@ *}} {{:read file="./defaut.json" assign="config_json"}} {{:assign config_defaut=$config_json|json_decode}} - {{#foreach from=$config_defaut.prefixes item="code"}} + {{:assign var="prefix_array" value=$config_defaut.prefixes|keys}} + {{#foreach from=$prefix_array item="code"}} {{* déterminer le numéro du compte d'amortissement associé au compte d'immobilisation *}} {{:include file="./_get_amort_code.html" @@ -253,7 +254,7 @@ {{:input type="list" name="credit_account" - label="Compte d'amortissement (28xx)" + label="Compte d'amortissement (280xx ou 281xx)" required=true target="!acc/charts/accounts/selector.php?codes=%s&id_year=%d"|args:"28*":$selected_year default=$credit_account diff --git a/scripts.js b/scripts.js index 3d91074..232df76 100644 --- a/scripts.js +++ b/scripts.js @@ -139,21 +139,3 @@ function setSelectorYear(button_names, f_years_selector) { const selected_year = document.getElementById(f_years_selector).value; setAccountYear(button_names, selected_year); } - -// config : gestion des ajouts/suppression comptes immo - -function initLine(row) { - var removeBtn = row.querySelector('button[name="remove_line"]'); - removeBtn.onclick = () => { - var count = $('.transaction-lines tbody tr').length; - var min = removeBtn.getAttribute('min'); - - if (count <= min) { - alert("Il n'est pas possible d'avoir moins de " + min + " compte(s)."); - return false; - } - - row.parentNode.removeChild(row); - return true; - }; -} diff --git a/write_exit.html b/write_exit.html index 9d0b553..591e803 100644 --- a/write_exit.html +++ b/write_exit.html @@ -260,7 +260,7 @@ }} {{/if}} - {{:redirect to="index.html?type_immo=archived"}} + {{:redirect to="index.html?type_immo=sortie"}} {{/form}} {{:admin_header title="Sortie du bilan" custom_css="./style.css" current="module_amortissement"}} @@ -311,8 +311,9 @@ {{:read file="./defaut.json" assign="config_json"}} {{:assign config_defaut=$config_json|json_decode}} +{{:assign var="prefix_array" value=$config_defaut.prefixes|keys}} -{{#foreach from=$config_defaut.prefixes item="code"}} +{{#foreach from=$prefix_array item="code"}} {{:assign var="pattern_array." value="%s*"|args:$code}} {{/foreach}} {{:assign patterns=$pattern_array|implode:"|"}}