diff --git a/_nav.html b/_nav.html index 5fa79aa..4c1d5a7 100644 --- a/_nav.html +++ b/_nav.html @@ -6,9 +6,13 @@ {{if $current == 'index'}} + {{if $subsubcurrent == 'amortization'}} + + {{/if}} {{/if}} diff --git a/add_duration.html b/add_duration.html index 8963b69..fcaf510 100644 --- a/add_duration.html +++ b/add_duration.html @@ -9,7 +9,8 @@ {{* Traiter l'envoi du formulaire *}} {{#form on="add"}} - {{* chercher la date d'achat de l'immobilisation *}} + + {{* chercher la date d'acquisition de l'immobilisation *}} {{:assign var="immo_id" value=$_GET.immo_id|intval}} {{#select trans.date as date_achat @@ -21,35 +22,55 @@ }} {{/select}} - {{* vérifier que la date d'acquisition est antérieure à la date de mise en service *}} - {{:assign date_debut=$_POST.date_mes|or:$ligne_immo.date_achat|parse_date}} - {{if $date_debut|strtotime < $ligne_immo.date_achat|strtotime}} - {{:assign dd=$date_debut|date_short}} - {{:assign da=$ligne_immo.date_achat|date_short}} - {{:error message="Erreur : la date de mise en service (%s) ne peut être antérieure à la date d'acquisition (%s)"|args:$dd:$da}} + {{if $_POST.no_amort}} + {{* ne pas amortir *}} + {{:assign duration=0}} + {{:assign date_debut=$ligne_immo.date_achat|parse_date}} + {{:assign noamort=true}} + {{else}} + {{* vérifier que la date d'acquisition est antérieure à la date de mise en service *}} + {{:assign date_debut=$_POST.date_mes|or:$ligne_immo.date_achat|parse_date}} + {{if $date_debut|strtotime < $ligne_immo.date_achat|strtotime}} + {{:assign dd=$date_debut|date_short}} + {{:assign da=$ligne_immo.date_achat|date_short}} + {{:error message="Erreur : la date de mise en service (%s) ne peut être antérieure à la date d'acquisition (%s)"|args:$dd:$da}} + {{/if}} + {{:assign duration=$_POST.duree|intval}} + {{:assign noamort=false}} {{/if}} - - {{:assign key=""|uuid}} {{* enregistrer les infos de l'immobilisation *}} + {{:assign key=""|uuid}} + {{:save key=$key validate_schema="schema.json" type="immo" line=$immo_id - duration=$_POST.duree|intval + duration=$duration date=$date_debut + noamort=$noamort }} - {{:redirect force="index.html?ok=1&msg=durée"}} + {{:redirect force="index.html?ok=1&msg=infos"}} +{{else}} + {{:form_errors}} {{/form}} {{* renseigner la date de mise en service et durée d'amortissement *}} +{{if $_GET.amort == 0}} + {{:assign checked=1}} + {{:assign disabled=1}} +{{else}} + {{:assign checked=0}} + {{:assign disabled=0}} +{{/if}}
-
- Renseigner informations amortissement +
+
- {{:input type="date" name="date_mes" label="Date de mise en service" help="à renseigner uniquement si différente de la date d'acquisition"}} - {{:input type="number" name="duree" label="Durée d'amortissement" required=true default=1}} + {{:input id="no_amort" type="checkbox" value=1 name="no_amort" label="Ne pas amortir" default=$checked help="Cocher pour ne pas amortir" onclick="toggleInputs('infos_immo','f_no_amort_1')"}} + {{:input type="date" name="date_mes" label="Date de mise en service" disabled=$disabled help="à renseigner uniquement si différente de la date d'acquisition"}} + {{:input type="number" name="duree" label="Durée d'amortissement" required=true default=1 disabled=$disabled}}
@@ -59,5 +80,22 @@ -{{:form_errors}} +{{* activer/désactiver les champs de saisie *}} + + {{:admin_footer}} diff --git a/amortization.html b/amortization.html index fe315d9..e2af8ff 100644 --- a/amortization.html +++ b/amortization.html @@ -3,7 +3,7 @@ {{:admin_header title="Liste des amortissements" custom_css="./style.css" current="module_amortissement"}} {{* barre de navigation *}} -{{:include file="_nav.html" current="index" subcurrent="amortization"}} +{{:include file="_nav.html" current="index" subcurrent="immobilisation" subsubcurrent="amortization"}} {{if $_GET.ok}} {{if $_GET.msg|match:"attach"}} diff --git a/immobilisations.html b/immobilisations.html new file mode 100644 index 0000000..c222fae --- /dev/null +++ b/immobilisations.html @@ -0,0 +1,114 @@ +{{* -*- brindille -*- *}} + +{{* Liste des immobilisations amortissable ou à définir *}} + +
+

Liste des immobilisations

+ + + + + + + + + + + + + + + + + + {{* 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 quote="'"}} + {{:assign condition="("}} + {{#foreach from=$prefix_array item="code"}} + {{:assign condition=$condition|cat:" account.code LIKE "|cat:$quote|cat:$code|cat:"%"|cat:$quote|cat:" OR "}} + {{/foreach}} + {{:assign condition=$condition|cat:"0)"}} + + {{#select + trans.id as trans_id, + trans.label as trans_label, + trans.date as trans_date, + line.id as immo_id, + account.id as account_id, + account.code as account_code, + account.label as account_label, + line.debit AS debit, + project.label as project_label, + trans.id_year as trans_id_year + FROM acc_transactions AS trans + INNER JOIN acc_transactions_lines AS line ON line.id_transaction = trans.id + INNER JOIN acc_accounts AS account ON line.id_account = account.id + INNER JOIN acc_years AS years ON trans.id_year = years.id + LEFT JOIN acc_projects AS project ON line.id_project = project.id + WHERE !condition + ORDER BY trans.date DESC; + !condition=$condition + }} + {{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$trans_id}} + {{:assign compte_url="%s/acc/accounts/journal.php?id=%s&year=%s"|args:$admin_url:$account_id:$trans_id_year}} + {{:assign duration=null}} + {{#load type="immo" where="$$.line = :line_id" :line_id=$immo_id|intval}} + {{:assign duration=$duration}} + {{if $noamort}} + {{:assign amortissable="non"}} + {{else}} + {{:assign amortissable="oui"}} + {{/if}} + {{else}} + {{:assign amortissable="nsp"}} + {{/load}} + {{if $amortissable == "non"}} + {{:continue}} + {{/if}} + + + + + + + + + + + + {{/select}} + +
DateLibelléMontantDuréeN° compteCompteProjet
#{{$trans_id}}{{$trans_date|date_short}}{{$trans_label}}{{"%f"|math:$debit|money}}{{if $duration != null}}{{$duration}}{{/if}}{{$account_code}}{{$account_label}}{{$project_label}} + {{if $duration == null}} + {{:linkbutton + label="Ajouter infos" + href="add_duration.html?immo_id=%s&amort=1"|args:$immo_id + shape="help" + target="_dialog" + }} + {{else}} + {{:linkbutton + label="Amortissements" + href="amortization.html?immo_id=%s"|args:$immo_id + shape="table" + }} + {{/if}} +
+
+ +
+
+ Ajouter une immobilisation +

+ {{:linkbutton + label="Ajouter une immobilisation" + shape="plus" + href="add_asset.html" + target="_dialog" + }} +

+
+
diff --git a/immobilisations_non.html b/immobilisations_non.html new file mode 100644 index 0000000..de1365d --- /dev/null +++ b/immobilisations_non.html @@ -0,0 +1,71 @@ +{{* -*- brindille -*- *}} + +{{* Liste des immobilisations non amortissable *}} + +
+

Immobilisations non amortissables

+ + + + + + + + + + + + + + + + + {{#load type="immo" where="$$.noamort = true"}} + {{:assign var="lines." value="'%s'"|args:$line}} + {{/load}} + {{:assign lines=$lines|implode:","}} + {{:assign lines="("|cat:$lines|cat:")"}} + {{:assign condition="line.id IN %s"|args:$lines}} + {{#select + trans.id as trans_id, + trans.label as trans_label, + trans.date as trans_date, + line.id as immo_id, + account.id as account_id, + account.code as account_code, + account.label as account_label, + line.debit AS debit, + project.label as project_label, + trans.id_year as trans_id_year + FROM acc_transactions AS trans + INNER JOIN acc_transactions_lines AS line ON line.id_transaction = trans.id + INNER JOIN acc_accounts AS account ON line.id_account = account.id + INNER JOIN acc_years AS years ON trans.id_year = years.id + LEFT JOIN acc_projects AS project ON line.id_project = project.id + WHERE !condition + ORDER BY trans.date DESC; + !condition=$condition + }} + {{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$trans_id}} + {{:assign compte_url="%s/acc/accounts/journal.php?id=%s&year=%s"|args:$admin_url:$account_id:$trans_id_year}} + + + + + + + + + + + {{/select}} + +
DateLibelléMontantN° compteCompteProjet
#{{$trans_id}}{{$trans_date|date_short}}{{$trans_label}}{{"%f"|math:$debit|money}}{{$account_code}}{{$account_label}}{{$project_label}} + {{:linkbutton + label="Ajouter infos" + href="add_duration.html?immo_id=%s&amort=0"|args:$immo_id + shape="help" + target="_dialog" + }} +
+
diff --git a/index.html b/index.html index d34172f..e89cb2b 100644 --- a/index.html +++ b/index.html @@ -2,13 +2,19 @@ {{:admin_header title="Gestion des amortissements" custom_css=$custom_css current="module_amortissement"}} {{* barre de navigation *}} -{{:include file="_nav.html" current="index"}} +{{if $_GET.amort == null || $_GET.amort}} + {{:assign amort="amort"}} +{{else}} + {{:assign amort="no_amort"}} +{{/if}} + +{{:include file="_nav.html" current="index" subcurrent="%s"|args:$amort}} {{if $_GET.ok}} {{if $_GET.msg|match:"immobilisation"}} {{:assign msg="Immobilisation enregistrée"}} - {{elseif $_GET.msg|match:"durée"}} - {{:assign msg="Durée enregistrée"}} + {{elseif $_GET.msg|match:"infos"}} + {{:assign msg="Informations enregistrées"}} {{/if}}

{{$msg}}

{{elseif $_GET.err}} @@ -29,107 +35,9 @@ {{/select}} {{/load}} -
-

Liste des immobilisations

- - - - - - - - - - - - - - - - - - {{* 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 quote="'"}} - {{:assign condition="("}} - {{#foreach from=$prefix_array item="code"}} - {{:assign condition=$condition|cat:" account.code LIKE "|cat:$quote|cat:$code|cat:"%"|cat:$quote|cat:" OR "}} - {{/foreach}} - {{:assign condition=$condition|cat:"0)"}} - - {{#select - trans.id as trans_id, - trans.label as trans_label, - trans.date as trans_date, - line.id as immo_id, - account.id as account_id, - account.code as account_code, - account.label as account_label, - line.debit AS debit, - project.label as project_label, - trans.id_year as trans_id_year - FROM acc_transactions AS trans - INNER JOIN acc_transactions_lines AS line ON line.id_transaction = trans.id - INNER JOIN acc_accounts AS account ON line.id_account = account.id - INNER JOIN acc_years AS years ON trans.id_year = years.id - LEFT JOIN acc_projects AS project ON line.id_project = project.id - WHERE !condition - ORDER BY trans.date DESC; - !condition=$condition - }} - {{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$trans_id}} - {{:assign compte_url="%s/acc/accounts/journal.php?id=%s&year=%s"|args:$admin_url:$account_id:$trans_id_year}} - {{#load type="immo" where="$$.line = :line_id" :line_id=$immo_id|intval}} - {{:assign duration=$duration}} - {{else}} - {{:assign duration=null}} - {{/load}} - - - - - - - - - - - - - {{/select}} - -
DateLibelléMontantDuréeN° compteCompteProjet
#{{$trans_id}}{{$trans_date|date_short}}{{$trans_label}}{{"%f"|math:$debit|money}}{{if $duration != null}}{{$duration}}{{/if}}{{$account_code}}{{$account_label}}{{$project_label}} - {{if $duration == null}} - {{:linkbutton - label="Ajouter infos" - href="add_duration.html?immo_id=%s"|args:$immo_id - shape="help" - target="_dialog" - }} - {{else}} - {{:linkbutton - label="Amortissements" - href="amortization.html?immo_id=%s"|args:$immo_id - shape="table" - }} - {{/if}} -
-
- -
-
- Ajouter une immobilisation -

- {{:linkbutton - label="Ajouter une immobilisation" - shape="plus" - href="add_asset.html" - target="_dialog" - }} -

-
-
- +{{if $amort == "amort"}} + {{:include file="./immobilisations.html"}} +{{else}} + {{:include file="./immobilisations_non.html"}} +{{/if}} {{:admin_footer}} diff --git a/schema.json b/schema.json index cd6a698..b2d16e2 100644 --- a/schema.json +++ b/schema.json @@ -18,6 +18,9 @@ "description" : "date de mise en service de l'immobilisation", "type" : ["string", "null"], "format" : "date" + }, + "noamort" : { + "type" : ["null", "boolean"] } }, "required": ["type", "line", "duration", "date"]