diff --git a/_calcul_dates.html b/_calcul_dates.html index 00ca468..e4dd864 100644 --- a/_calcul_dates.html +++ b/_calcul_dates.html @@ -9,12 +9,4 @@ {{:assign ts_debut=$date_debut|strtotime}} {{:assign ts_fin=$date_fin|strtotime}} - -{{if $ts_debut <= $ts_fin}} - {{:assign nbjours="(%d-%d)/(60*60*24)"|math:$ts_fin:$ts_debut}} -{{else}} - {{:assign nbjours="(%d-%d)/(60*60*24)"|math:$ts_debut:$ts_fin}} -{{/if}} - -{{* pour simplifier : 360 jours par an *}} -{{:assign nbjours="round(%f/365*360)"|math:$nbjours}} +{{:assign nbjours="1+abs(%d-%d)/(60*60*24)"|math:$ts_fin:$ts_debut}} diff --git a/_check_account.html b/_check_account.html index d1234a3..06e1108 100644 --- a/_check_account.html +++ b/_check_account.html @@ -24,11 +24,10 @@ select="code" tables="acc_accounts" where="id_chart = :id_chart %s"|args:$condition - :id_chart = $selected_chart|intval + :id_chart = $chart_id|intval }} {{if $account_code == $code}} {{:assign account_ok=1}} {{:break}} {{/if}} {{/sql}} - diff --git a/_check_date.html b/_check_date.html index 3dc1362..f68ec49 100644 --- a/_check_date.html +++ b/_check_date.html @@ -8,15 +8,11 @@ *}} {{:assign open_years=""}} -{{#years status=false order="start_date"}} - {{:assign open_years=$open_years|cat:"\n"|cat:" - "|cat:$label|cat:" : "}} - {{:assign debut=$start_date|date_short}} - {{:assign fin=$end_date|date_short}} - {{:assign open_years=$open_years|cat:$debut|cat:" à "|cat:$fin}} +{{#years closed=false order="start_date" assign="open_years."}} {{if $start_date|strtotime <= $date|parse_date|strtotime && $end_date|strtotime >= $date|parse_date|strtotime - }} + }} {{:assign selected_year=$id}} {{:assign selected_chart=$id_chart}} {{/if}} diff --git a/_nav.html b/_nav.html index 362f31a..bb819d1 100644 --- a/_nav.html +++ b/_nav.html @@ -12,17 +12,22 @@
La date choisie n'est dans aucun exercice ouvert !
+{{$msg}}
{{/if}} -{{* récupérer les infos de l'immobilisation *}} -{{#select - line.id as immo_id, - line.id_account as account_id, - line.id_project as project_id, - line.debit as montant, - trans.id as trans_id, - trans.label as label, - trans.date, - y.id as year_id, - y.end_date as date_amort, - project.label as project_label - FROM acc_transactions_lines AS line - INNER JOIN acc_transactions AS trans ON line.id_transaction = trans.id - INNER JOIN acc_years AS y ON trans.id_year = y.id - LEFT JOIN acc_projects AS project ON line.id_project = project.id - WHERE line.id = :line_id; - :line_id = $_GET.immo_id|intval - assign=ligne_immo - }} -{{else}} - {{:error message="Immobilisation %s non trouvée"|args:$_GET.immo_id}} -{{/select}} -{{:assign date_debut=$ligne_immo.date}} - -{{#load type="immo" assign="info_immo" where="$$.line = :line_id" :line_id=$_GET.immo_id|intval}} - {{:assign var="duree" from="info_immo.duration"|args:$_GET.immo_id}} - {{:assign date_debut=$info_immo.date}} -{{/load}} - -{{* chercher des écritures d'amortissement liées à l'immobilisation *}} -{{#select - l_amort.credit as amort_amount, - l_amort.label as amort_label, - l_amort.id as amort_line, - CASE links.id_related = t_immo.id - WHEN true THEN links.id_transaction - WHEN false THEN links.id_related - END as amort_trans_id, - trans.date as amort_date, - trans.label as trans_label, - trans.id_year as amort_year, - account.id as account_id, - account.code as account_code, - account.label as account_label - FROM acc_transactions_lines as l_immo - INNER JOIN acc_transactions as t_immo on t_immo.id = l_immo.id_transaction - INNER JOIN acc_transactions_links as links - ON ( - t_immo.id = links.id_transaction - OR - t_immo.id = links.id_related - ) - INNER JOIN acc_transactions_lines as l_amort on amort_trans_id = l_amort.id_transaction - INNER join acc_transactions as trans on l_amort.id_transaction = trans.id - INNER join acc_accounts as account on l_amort.id_account = account.id - WHERE - l_immo.id = :line_id - AND - l_amort.credit <> 0 - AND - account.code LIKE '28%' - ORDER BY trans.date; - :line_id = $_GET.immo_id|intval - assign=linked_lines. -}} - {{:assign var="amort_years." value=$amort_year}} - {{if $date_debut == null}} - {{:assign date_debut=$amort_date}} - {{/if}} -{{/select}} +{{if $valeur_residuelle > 0}} + +{{/if}}N° | -Date | -Montant | -Solde | -Libellé | -- |
---|---|---|---|---|---|
{{"%d+1"|math:$num}} | -{{$date_amort|date_short}} | -{{"%f"|math:$annuite_courante|money}} | -{{$solde|money:false}} | -- {{if $libelle == null}} - {{:assign libelle="Amortissement "|cat:$ligne_immo.label}} - {{/if}} - {{$libelle}} - | -- {{if $enregistrer == 1}} - {{:linkbutton - label="Créer l'écriture" - href="save_amort.html?amount=%d&account=%s&year=%s&trans_id=%d&immo_id=%s&project_id=%d&label=%s&solde=%d"|args:$annuite_courante:$ligne_immo.account_id:$current_year:$ligne_immo.trans_id:$_GET.immo_id:$project_id:$libelle:$solde_prec - shape="right" - target="_dialog" - }} - {{/if}} - | -
N° | +Date | +Libellé | +Montant | +N° compte | +Compte | +Projet | ++ |
---|---|---|---|---|---|---|---|
#{{$trans_id}} | +{{$trans_date|date_short}} | +{{$trans_label}} | +{{"%f"|math:$debit|money:false}} | +{{$account_code}} | +{{$account_label}} | +{{$project_label}} | ++ | +
Aucune immobilisation
+ {{/if}} +Durée | N° compte | Compte | -Projet | @@ -46,13 +46,11 @@ 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 @@ -63,7 +61,7 @@ {{* voir si l'immo est prise en charge *}} {{#load type="immo" where="$$.line = :line_id" :line_id=$immo_id|intval}} {{:assign duration=$duration}} - {{if $noamort}} + {{if $status == "ignored"}} {{:assign amortissable="non"}} {{else}} {{:assign amortissable="oui"}} @@ -74,6 +72,32 @@ {{if $amortissable == "non"}} {{:continue}} {{/if}} + + {{* voir s'il existe une écriture qui solde l'immobilisation *}} + {{:assign ignore=false}} + {{#select + line.id AS line, + line.id_transaction AS trans, + line.debit, + line.label, + line2.id AS line2, + line2.id_transaction AS trans2, + line2.credit, + line2.label + FROM acc_transactions_lines AS line + INNER JOIN acc_accounts AS acc ON acc.id = line.id_account + INNER JOIN acc_transactions_lines AS line2 ON line2.id_account = acc.id + WHERE + line.id = :line_id + AND line2.credit = line.debit; + :line_id = $immo_id|intval + }} + {{:assign ignore=true}} + {{/select}} + {{if $ignore}} + {{:continue}} + {{/if}} + {{* voir s'il existe des écritures d'amortissement associées *}} {{#select sum(l_amort.credit) as amort_amount, @@ -98,7 +122,7 @@ AND account.code LIKE '28%'; :line_id = $immo_id|intval - }} + }} {{if $amort_amount == null}} {{:assign exist_amort=false}} {{:assign amort_amount=0}} @@ -107,12 +131,15 @@ {{:assign exist_amort=true}} {{/if}} {{/select}} - {{* immo amortie ? *}} - {{if $amort == "amort" && $amort_amount >= $debit || - $amort == "fini" && $amort_amount < $debit + + {{* classement par onglet *}} + {{if $amort == "encours" && $amort_amount >= $debit || + $amort == "fini" && $amort_amount < $debit || + $amortissable == "nsp" && ! $exist_amort }} {{:continue}} {{/if}} + {{:assign nb_immo="%d+1"|math:$nb_immo}} | ||
---|---|---|---|---|---|---|
#{{$trans_id}} | {{$trans_date|date_short}} | @@ -121,33 +148,40 @@{{if $duration != null}}{{$duration}}{{/if}} | {{$account_code}} | {{$account_label}} | -{{$project_label}} | - {{if ! $exist_amort && $duration == null}} + {{if ! $exist_amort}} {{:linkbutton - label="Ajouter infos" - href="add_infos.html?immo_id=%s&amort=1"|args:$immo_id - shape="help" - target="_dialog" - }} - {{else}} - {{if ! $exist_amort}} - {{:linkbutton label="Modifier infos" href="modif_infos.html?immo_id=%s&amort=1"|args:$immo_id - shape="help" + shape="settings" target="_dialog" - }} - {{/if}} + }} + {{elseif $amortissable == "nsp"}} {{:linkbutton - label="Amortissements" - href="amortization.html?immo_id=%s&amort=%s"|args:$immo_id:$amort - shape="table" + label="Ajouter infos" + href="add_infos.html?immo_id=%s&amort=1"|args:$immo_id + shape="settings" + target="_dialog" }} {{/if}} + {{if $amort == "encours" || $amort == "fini"}} + {{:linkbutton + label="Sortir du bilan" + href="balance_sheet_exit.html?immo_id=%s"|args:$immo_id + shape="export" + }} + {{/if}} + {{:linkbutton + label="Amortissements" + href="amortization.html?immo_id=%s&amort=%s"|args:$immo_id:$amort + shape="table" + }} |
Aucune immobilisation
+ {{/if}}N° | +Date | +Libellé | +Montant | +N° compte | +Compte | ++ |
---|---|---|---|---|---|---|
#{{$trans_id}} | +{{$trans_date|date_short}} | +{{$trans_label}} | +{{"%f"|math:$debit|money:false}} | +{{$account_code}} | +{{$account_label}} | ++ {{if $status == "nsp"}} + {{:linkbutton + label="Ajouter infos" + href="add_infos.html?immo_id=%s&amort=1"|args:$immo_id + shape="settings" + target="_dialog" + }} + {{else}} + {{:linkbutton + label="Modifier infos" + href="modif_infos.html?immo_id=%s&amort=0"|args:$immo_id + shape="help" + target="_dialog" + }} + {{/if}} + | +