Compare commits
No commits in common. "main" and "v0.14" have entirely different histories.
69
_amort_exclus.html
Normal file
69
_amort_exclus.html
Normal file
@ -0,0 +1,69 @@
|
||||
{{* -*- brindille -*- *}}
|
||||
|
||||
{{*
|
||||
Trouver les lignes d'amortissement et d'immobilisation qui sont dans la même écriture
|
||||
- param : aucun
|
||||
- résultat : amort_exclus = tableau des amortissements à exclure
|
||||
*}}
|
||||
|
||||
{{* lignes des immo non amorties *}}
|
||||
{{#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}}
|
||||
{{*:debug condition=$condition*}}
|
||||
|
||||
{{* écritures et comptes associés *}}
|
||||
{{#select
|
||||
line.id as line_id,
|
||||
line.id_transaction as trans_id,
|
||||
account.id as account_id,
|
||||
account.code as account_code,
|
||||
account.id_chart as id_chart
|
||||
FROM acc_transactions_lines AS line
|
||||
INNER JOIN acc_transactions AS trans on trans.id = line.id_transaction
|
||||
INNER JOIN acc_accounts AS account ON line.id_account = account.id
|
||||
INNER JOIN acc_years AS years ON trans.id_year = years.id
|
||||
WHERE !condition;
|
||||
!condition=$condition
|
||||
assign="ecriture"
|
||||
}}
|
||||
{{:assign var="ecritures." value="'%s'"|args:$trans_id}}
|
||||
{{* déterminer le numéro du compte d'amortissement associé au compte d'immobilisation *}}
|
||||
{{:include
|
||||
file="./_get_amort_code.html"
|
||||
code_immo=$account_code
|
||||
keep="code_amort"
|
||||
}}
|
||||
{{:assign var="accounts." value="'%s'"|args:$code_amort}}
|
||||
{{/select}}
|
||||
{{*:debug ecritures=$ecritures accounts=$accounts*}}
|
||||
|
||||
{{* écritures d'amortissement avec :
|
||||
- numéro d'écritures obtenus ci-dessus
|
||||
- numéros de comptes d'amortissement déduits des comptes d'immo ci-dessus
|
||||
*}}
|
||||
|
||||
{{:assign ecritures=$ecritures|implode:","}}
|
||||
{{:assign ecritures="("|cat:$ecritures|cat:")"}}
|
||||
{{:assign accounts=$accounts|implode:","}}
|
||||
{{:assign accounts="("|cat:$accounts|cat:")"}}
|
||||
{{:assign condition="line.id_transaction IN %s AND account.code IN %s"|args:$ecritures:$accounts}}
|
||||
|
||||
{{#select
|
||||
line.id as line_id,
|
||||
line.id_transaction as trans_id,
|
||||
account.id as account_id,
|
||||
account.code as account_code
|
||||
FROM acc_transactions_lines AS line
|
||||
INNER JOIN acc_transactions AS trans on trans.id = line.id_transaction
|
||||
INNER JOIN acc_accounts AS account ON line.id_account = account.id
|
||||
INNER JOIN acc_years AS years ON trans.id_year = years.id
|
||||
WHERE !condition;
|
||||
!condition=$condition
|
||||
assign="amort"
|
||||
}}
|
||||
{{:assign var="amort_exclus." value=$trans_id}}
|
||||
{{/select}}
|
@ -9,12 +9,13 @@
|
||||
|
||||
{{:assign ts_debut=$date_debut|strtotime}}
|
||||
{{:assign ts_fin=$date_fin|strtotime}}
|
||||
{{:assign nbjours="1+(%d-%d)/(60*60*24)"|math:$ts_fin:$ts_debut}}
|
||||
|
||||
{{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}}
|
||||
{{* au cas où les deux dates seraient inversées ... *}}
|
||||
{{if $nbjours < 0}}
|
||||
{{:assign nbjours="-1*%d"|math:$nbjours}}
|
||||
{{/if}}
|
||||
|
||||
{{* pour simplifier : 360 jours par an *}}
|
||||
{{:assign nbjours="round(%f/365*360)"|math:$nbjours}}
|
||||
{{if $nbjours > 360}}
|
||||
{{:assign nbjours=360}}
|
||||
{{/if}}
|
||||
|
@ -12,10 +12,10 @@
|
||||
- account_ok
|
||||
*}}
|
||||
|
||||
{{:assign quote="'"}}
|
||||
{{:assign condition=" AND ("}}
|
||||
{{#foreach from=$prefix_array item="code"}}
|
||||
{{:assign code=$code|cat:"%"|quote_sql}}
|
||||
{{:assign condition=$condition|cat:" code LIKE "|cat:$code|cat:" OR "}}
|
||||
{{:assign condition=$condition|cat:" code LIKE "|cat:$quote|cat:$code|cat:"%"|cat:$quote|cat:" OR "}}
|
||||
{{/foreach}}
|
||||
{{:assign condition=$condition|cat:"0)"}}
|
||||
|
||||
|
@ -1,5 +1,3 @@
|
||||
{{* -*- brindille -*- *}}
|
||||
|
||||
<nav class="tabs">
|
||||
{{if $current == 'index'}}
|
||||
<aside>
|
||||
@ -18,10 +16,9 @@
|
||||
<li {{if $subcurrent == 'fini'}}class="current"{{/if}}><a href="index.html?amort=fini">Terminées</a></li>
|
||||
<li {{if $subcurrent == 'no_amort'}}class="current"{{/if}}><a href="index.html?amort=no_amort">Non amortissables</a></li>
|
||||
</ul>
|
||||
|
||||
{{if $subsubcurrent == 'amortization'}}
|
||||
<ul class="sub">
|
||||
<li class="title"><strong>Amortissements</strong></li>
|
||||
<li class="current"><a>Amortissements</a></li>
|
||||
</ul>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
@ -14,9 +14,9 @@
|
||||
|
||||
{{if $_GET.ok}}
|
||||
{{if $_GET.msg|match:"attach"}}
|
||||
{{:assign msg="Attachement écriture %s effectué"|args:$_GET.trans_id}}
|
||||
{{:assign msg="Attachement effectué (écriture %s)"|args:$_GET.trans_id}}
|
||||
{{elseif $_GET.msg|match:"detach"}}
|
||||
{{:assign msg="Détachement écriture %s affectué"|args:$_GET.trans_id}}
|
||||
{{:assign msg="Attachement supprimé (écriture %s)"|args:$_GET.trans_id}}
|
||||
{{elseif $_GET.msg|match:"amortissement"}}
|
||||
{{:assign msg="Amortissement enregistré"}}
|
||||
{{/if}}
|
||||
@ -38,22 +38,20 @@
|
||||
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;
|
||||
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}}
|
||||
@ -72,10 +70,11 @@
|
||||
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
|
||||
acc.id as account_id,
|
||||
acc.code as account_code,
|
||||
acc.label as account_name
|
||||
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 (
|
||||
@ -85,13 +84,11 @@
|
||||
)
|
||||
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
|
||||
INNER join acc_accounts as acc on l_amort.id_account = acc.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.
|
||||
@ -102,13 +99,7 @@
|
||||
{{/if}}
|
||||
{{/select}}
|
||||
|
||||
<h3>Amortissement de «
|
||||
<a class="num"
|
||||
href={{"%s/acc/transactions/details.php?id=%s"|args:$admin_url:$ligne_immo.trans_id}}>#{{$ligne_immo.trans_id}}</a>
|
||||
{{$ligne_immo.label}} » d'un montant de
|
||||
{{"%f"|math:$ligne_immo.montant|money_currency}}
|
||||
en date du {{$date_debut|date_short}}{{if $duree != null}} sur {{$duree}} ans{{/if}}
|
||||
</h3>
|
||||
<h2>Amortissement de « {{$ligne_immo.label}} » d'un montant de {{"%f"|math:$ligne_immo.montant|money_currency}} en date du {{$date_debut|date_short}}{{if $duree != null}} sur {{$duree}} ans{{/if}}</h2>
|
||||
|
||||
{{if $duree != null}}
|
||||
{{* montant de l'annuité théorique *}}
|
||||
@ -131,7 +122,12 @@
|
||||
{{:assign solde=$ligne_immo.montant}}
|
||||
{{if $linked_lines != null}}
|
||||
<section class="amortissement">
|
||||
<h3 class="center-block ruler">Amortissements rattachés</h3>
|
||||
<h3 class="ruler">
|
||||
Amortissements attachés à « <a class="num"
|
||||
href={{"%s/acc/transactions/details.php?id=%s"|args:$admin_url:$ligne_immo.trans_id}}>{{$ligne_immo.trans_id}}</a>
|
||||
{{$ligne_immo.label}} »
|
||||
({{"%f"|math:$ligne_immo.montant|money_currency}}, {{$date_debut|date_short}})
|
||||
</h3>
|
||||
<table class="list">
|
||||
<thead>
|
||||
<tr>
|
||||
@ -166,7 +162,7 @@
|
||||
{{/if}}
|
||||
</td>
|
||||
<td><a href={{$compte_url}}>{{$line.account_code}}</a></td>
|
||||
<td>{{$line.account_label}}</td>
|
||||
<td>{{$line.account_name}}</td>
|
||||
<td>
|
||||
{{:linkbutton label="Détacher" href="detach_amort.html?amort_id=%d&immo_id=%d"|args:$line.amort_line:$ligne_immo.immo_id shape="plus"}}
|
||||
</td>
|
||||
@ -186,7 +182,7 @@
|
||||
{{:assign nbamort="%d-%d"|math:$duree:$nbamort}}
|
||||
{{:assign annuite_courante="min(%f,%f)"|math:$annuite_courante:$solde}}
|
||||
<section class="amortissement">
|
||||
<h3 class="center-block ruler">Amortissements à enregistrer</h3>
|
||||
<h3 class="ruler">Amortissements à enregistrer</h3>
|
||||
<table class="list">
|
||||
<thead>
|
||||
<tr>
|
||||
@ -202,7 +198,7 @@
|
||||
{{#foreach count="%d+1"|math:$nbamort key="num"}}
|
||||
{{:assign solde_prec=$solde}}
|
||||
{{:assign solde="%f-%d"|math:$solde:$annuite_courante}}
|
||||
{{#select id FROM acc_years WHERE :amort_date >= start_date AND :amort_date <= end_date AND status == 0; :amort_date=$date_amort|parse_date}}
|
||||
{{#select id from acc_years where :amort_date >= start_date and :amort_date <= end_date and status == 0; :amort_date=$date_amort|parse_date}}
|
||||
{{:assign enregistrer=1}}
|
||||
{{:assign current_year=$id}}
|
||||
{{else}}
|
||||
@ -241,41 +237,50 @@
|
||||
|
||||
{{if $_GET.amort == null || $_GET.amort != "fini"}}
|
||||
|
||||
{{* amortissement à exclure *}}
|
||||
{{:include
|
||||
file="_amort_exclus.html"
|
||||
keep="amort_exclus"
|
||||
}}
|
||||
|
||||
{{* Autres amortissements non rattachés *}}
|
||||
{{#select
|
||||
line.id as l_id,
|
||||
line.id_transaction as t_id,
|
||||
line.credit as amort_amount,
|
||||
line.label as l_label,
|
||||
li.id as l_id,
|
||||
li.id_transaction as t_id,
|
||||
li.credit as montant,
|
||||
li.reference,
|
||||
li.label as l_label,
|
||||
trans.date as t_date,
|
||||
trans.label as t_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 line
|
||||
INNER JOIN acc_accounts AS account ON account.id = line.id_account
|
||||
INNER JOIN acc_transactions AS trans ON trans.id = line.id_transaction
|
||||
INNER JOIN acc_years AS y ON y.id = trans.id_year
|
||||
WHERE account.code LIKE "28%" AND credit > 0 AND (NOT trans.status & 16)
|
||||
ORDER BY trans.date, trans.label;
|
||||
acc.code as a_code,
|
||||
acc.label as a_label,
|
||||
y.label as y_label
|
||||
from acc_transactions_lines as li
|
||||
inner join acc_accounts as acc on acc.id = li.id_account
|
||||
inner join acc_transactions as trans on trans.id = li.id_transaction
|
||||
inner join acc_years as y on y.id = trans.id_year
|
||||
where acc.code like "28%" AND credit > 0 AND (NOT trans.status & 16)
|
||||
order by trans.date, trans.label;
|
||||
assign=autre_amort
|
||||
}}
|
||||
{{#select
|
||||
id_transaction,
|
||||
id_related
|
||||
FROM acc_transactions_links
|
||||
WHERE id_transaction = :id_amort OR id_related = :id_amort;
|
||||
from acc_transactions_links
|
||||
where id_transaction = :id_amort or id_related = :id_amort;
|
||||
:id_amort=$t_id
|
||||
}}
|
||||
{{else}}
|
||||
{{:assign var="autres_amortissements." value=$autre_amort}}
|
||||
{{if $autre_amort.t_id|in:$amort_exclus}}
|
||||
{{else}}
|
||||
{{:assign var="autres_amortissements." value=$autre_amort}}
|
||||
{{/if}}
|
||||
{{/select}}
|
||||
{{/select}}
|
||||
|
||||
{{if $autres_amortissements != null}}
|
||||
<section class="amortissement">
|
||||
<h3 class="center-block ruler">Autres amortissements non rattachés</h3>
|
||||
<h3 class="ruler">Autres amortissements non rattachés</h3>
|
||||
<table class="list">
|
||||
<thead>
|
||||
<tr>
|
||||
@ -289,21 +294,21 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
{{#foreach from=$autres_amortissements item="line"}}
|
||||
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$line.t_id}}
|
||||
{{:assign compte_url="%s/acc/accounts/journal.php?id=%s&year=%s"|args:$admin_url:$line.account_id:$line.amort_year}}
|
||||
<tr>
|
||||
<td class="num"><a href={{$trans_url}}>#{{$line.t_id}}</a></td>
|
||||
<td>{{$line.t_date|date_short}}</td>
|
||||
<td class="money">{{"%f"|math:$line.amort_amount|money}}</td>
|
||||
<td class="money">{{"%f"|math:$line.montant|money}}</td>
|
||||
<td>{{if $line.l_label == null}}
|
||||
{{$line.t_label}}
|
||||
{{else}}
|
||||
{{$line.l_label}}
|
||||
{{/if}}
|
||||
</td>
|
||||
<td><a href={{$compte_url}}>{{$line.account_code}}</a></td>
|
||||
<td>{{$line.account_label}}</td>
|
||||
<td>{{$line.a_code}}</td>
|
||||
<td>{{$line.a_label}}</td>
|
||||
<td>
|
||||
{{:linkbutton label="Attacher" href="attach_amort.html?amort_id=%d&immo_id=%d"|args:$line.l_id:$ligne_immo.immo_id shape="plus"}}
|
||||
</td>
|
||||
|
@ -29,10 +29,10 @@
|
||||
{{: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 code=$code|cat:"%"|quote_sql}}
|
||||
{{:assign condition=$condition|cat:" account.code LIKE "|cat:$code|cat:" OR "}}
|
||||
{{:assign condition=$condition|cat:" account.code LIKE "|cat:$quote|cat:$code|cat:"%"|cat:$quote|cat:" OR "}}
|
||||
{{/foreach}}
|
||||
{{:assign condition=$condition|cat:"0)"}}
|
||||
{{:assign condition=$condition|cat:" AND debit > 0 AND NOT (trans.status & 16)"}}
|
||||
@ -90,13 +90,10 @@
|
||||
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_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%';
|
||||
l_amort.credit <> 0;
|
||||
:line_id = $immo_id|intval
|
||||
}}
|
||||
{{if $amort_amount == null}}
|
||||
|
@ -1,6 +1,6 @@
|
||||
{{* -*- brindille -*- *}}
|
||||
|
||||
{{* Liste des immobilisations non amortissables *}}
|
||||
{{* Liste des immobilisations non amortissable *}}
|
||||
|
||||
<section class="immobilisation">
|
||||
<h2 class="ruler">Immobilisations non amortissables</h2>
|
||||
|
@ -1,5 +1,5 @@
|
||||
name="Amortissements"
|
||||
description="Gestion des amortissements pour le logiciel de comptabilité Paheko (v0.16)"
|
||||
description="Gestion des amortissements pour le logiciel de comptabilité Paheko (v0.12)"
|
||||
author="Jean-Christophe Engel"
|
||||
author_url="https://git.roflcopter.fr/lesanges"
|
||||
home_button=false
|
||||
|
Loading…
Reference in New Issue
Block a user