Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
9ac427415a | |||
17d132ffa2 | |||
f17ccd1bc8 | |||
4b63ad4560 | |||
2aa64cc525 | |||
022e324bea | |||
5ab7d628a8 | |||
ad4b76695d | |||
f1bea6bda2 | |||
1e2ba133f5 | |||
993ded84d3 | |||
a604a86a3f |
@ -1,69 +0,0 @@
|
||||
{{* -*- 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}}
|
@ -16,6 +16,4 @@
|
||||
{{:assign nbjours="-1*%d"|math:$nbjours}}
|
||||
{{/if}}
|
||||
{{* pour simplifier : 360 jours par an *}}
|
||||
{{if $nbjours > 360}}
|
||||
{{:assign nbjours=360}}
|
||||
{{/if}}
|
||||
{{:assign nbjours="round(%f/365*360)"|math:$nbjours}}
|
||||
|
@ -8,7 +8,7 @@
|
||||
*}}
|
||||
|
||||
{{:assign open_years=""}}
|
||||
{{#years status=false}}
|
||||
{{#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}}
|
||||
|
@ -1,3 +1,5 @@
|
||||
{{* -*- brindille -*- *}}
|
||||
|
||||
<nav class="tabs">
|
||||
{{if $current == 'index'}}
|
||||
<aside>
|
||||
@ -16,9 +18,10 @@
|
||||
<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="current"><a>Amortissements</a></li>
|
||||
<li class="title"><strong>Amortissements</strong></li>
|
||||
</ul>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
@ -6,6 +6,10 @@
|
||||
{{:include file="_nav.html" current="index"}}
|
||||
{{/if}}
|
||||
|
||||
{{:read file="./defaut.json" assign="config_json"}}
|
||||
{{:assign config_defaut=$config_json|json_decode}}
|
||||
{{:assign var="prefix_array" value=$config_defaut.prefixes|keys}}
|
||||
|
||||
{{* Traiter l'envoi du formulaire *}}
|
||||
{{#form on="add"}}
|
||||
|
||||
@ -55,10 +59,6 @@
|
||||
- est présent dans le PC de l'exercice correspondant à la date
|
||||
*}}
|
||||
|
||||
{{:read file="./defaut.json" assign="config_json"}}
|
||||
{{:assign config_defaut=$config_json|json_decode}}
|
||||
{{:assign var="prefix_array" value=$config_defaut.prefixes|keys}}
|
||||
|
||||
{{:include
|
||||
file="_check_account.html"
|
||||
account=$debit_account
|
||||
@ -123,22 +123,28 @@
|
||||
{{:assign var="projects.%d"|args:$id value=$label}}
|
||||
{{/select}}
|
||||
|
||||
{{#foreach from=$prefix_array item="code"}}
|
||||
{{:assign var="pattern_array." value="%s*"|args:$code}}
|
||||
{{/foreach}}
|
||||
{{:assign patterns=$pattern_array|implode:"|"}}
|
||||
{{:assign date=$now|date:'Y-m-d'}}
|
||||
|
||||
<form method="post" action="">
|
||||
<fieldset>
|
||||
<legend>Ajouter une immobilisation</legend>
|
||||
<dl>
|
||||
{{:input id="no_amort" type="checkbox" value=1 name="no_amort" label="Ne pas amortir" help="Cocher pour ne pas amortir" onclick="toggleInputs('f_no_amort_1', ['f_date_mes','f_duree'])"}}
|
||||
{{:input type="date" name="date_achat" label="Date d'acquisition" required=true default=$now|date_short}}
|
||||
{{:input type="date" name="date_achat" label="Date d'acquisition" required=true default=$now|date_short onchange="setDate('date_achat', ['credit_account', 'debit_account'])"}}
|
||||
{{: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="text" name="designation" label="Désignation" required=true}}
|
||||
{{:input type="money" name="montant" label="Montant" required=true}}
|
||||
{{:input type="number" name="duree" label="Durée d'amortissement" required=true min=0 default=1}}
|
||||
{{:input type="number" name="duree" label="Durée d'amortissement" required=true min=0 default=1 suffix="année(s)"}}
|
||||
{{:input
|
||||
type="list"
|
||||
name="credit_account"
|
||||
label="Compte de décaissement"
|
||||
required=true
|
||||
target="!acc/charts/accounts/selector.php?targets=1:2:3&key=code"
|
||||
target="!acc/charts/accounts/selector.php?types=%s&date=%s"|args:"1|2|3":$date
|
||||
default=$bank_account
|
||||
}}
|
||||
{{:input
|
||||
@ -146,7 +152,7 @@
|
||||
name="debit_account"
|
||||
label="Compte d'immobilisation (20xx, 21xx, ...)"
|
||||
required=true
|
||||
target="!acc/charts/accounts/selector.php?key=code"
|
||||
target="!acc/charts/accounts/selector.php?date=%s&codes=%s"|args:$date:$patterns
|
||||
default=$immo_account
|
||||
}}
|
||||
{{if $projects != null}}
|
||||
@ -161,9 +167,9 @@
|
||||
|
||||
</form>
|
||||
|
||||
{{* activer/désactiver les champs passés en paramètres *}}
|
||||
<script type="text/javascript">
|
||||
function toggleInputs(idcb, idfields) {
|
||||
{{* activer/désactiver les champs passés en paramètres *}}
|
||||
function toggleInputs(idcb, idfields) {
|
||||
const noamort = document.getElementById(idcb);
|
||||
for (let id of idfields) {
|
||||
const field = document.getElementById(id);
|
||||
@ -174,7 +180,22 @@
|
||||
field.removeAttribute("disabled");
|
||||
}
|
||||
}
|
||||
}
|
||||
{{* fixer la date des sélecteurs *}}
|
||||
function setDate(b_date, button_names) {
|
||||
const elem_date = document.querySelector("input[name=" + b_date + "]");
|
||||
const date_fr = elem_date.value;
|
||||
const new_date = date_fr.replace(/([0-9]+)\/([0-9]+)\/([0-9]+)/, "$3-$2-$1");
|
||||
for (const name of button_names) {
|
||||
const button = document.querySelector("button[data-name=" + name + "]");
|
||||
const b_value = button.value;
|
||||
const new_value = b_value.replace(/date=[0-9]+-[0-9]+-[0-9]+/, 'date=' + new_date);
|
||||
console.log(" date = " + new_date + " old_val = " + b_value + " new_val = " + new_value);
|
||||
button.setAttribute('value', new_value);
|
||||
console.log("button_value = " + button.value);
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
{{:admin_footer}}
|
||||
|
@ -41,11 +41,11 @@
|
||||
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
|
||||
}}
|
||||
@ -70,9 +70,9 @@
|
||||
trans.date as amort_date,
|
||||
trans.label as trans_label,
|
||||
trans.id_year as amort_year,
|
||||
acc.id as account_id,
|
||||
acc.code as account_code,
|
||||
acc.label as account_name
|
||||
account.id as account_id,
|
||||
account.code as account_code,
|
||||
account.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
|
||||
@ -84,11 +84,13 @@
|
||||
)
|
||||
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 acc on l_amort.id_account = acc.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.
|
||||
@ -99,7 +101,13 @@
|
||||
{{/if}}
|
||||
{{/select}}
|
||||
|
||||
<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>
|
||||
<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>
|
||||
|
||||
{{if $duree != null}}
|
||||
{{* montant de l'annuité théorique *}}
|
||||
@ -122,12 +130,7 @@
|
||||
{{:assign solde=$ligne_immo.montant}}
|
||||
{{if $linked_lines != null}}
|
||||
<section class="amortissement">
|
||||
<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>
|
||||
<h3 class="center-block ruler">Amortissements rattachés</h3>
|
||||
<table class="list">
|
||||
<thead>
|
||||
<tr>
|
||||
@ -182,7 +185,7 @@
|
||||
{{:assign nbamort="%d-%d"|math:$duree:$nbamort}}
|
||||
{{:assign annuite_courante="min(%f,%f)"|math:$annuite_courante:$solde}}
|
||||
<section class="amortissement">
|
||||
<h3 class="ruler">Amortissements à enregistrer</h3>
|
||||
<h3 class="center-block ruler">Amortissements à enregistrer</h3>
|
||||
<table class="list">
|
||||
<thead>
|
||||
<tr>
|
||||
@ -198,7 +201,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}}
|
||||
@ -237,12 +240,6 @@
|
||||
|
||||
{{if $_GET.amort == null || $_GET.amort != "fini"}}
|
||||
|
||||
{{* amortissement à exclure *}}
|
||||
{{:include
|
||||
file="_amort_exclus.html"
|
||||
keep="amort_exclus"
|
||||
}}
|
||||
|
||||
{{* Autres amortissements non rattachés *}}
|
||||
{{#select
|
||||
li.id as l_id,
|
||||
@ -252,35 +249,32 @@
|
||||
li.label as l_label,
|
||||
trans.date as t_date,
|
||||
trans.label as t_label,
|
||||
acc.code as a_code,
|
||||
acc.label as a_label,
|
||||
account.code as a_code,
|
||||
account.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
|
||||
order by trans.date, trans.label;
|
||||
FROM acc_transactions_lines AS li
|
||||
INNER JOIN acc_accounts AS account ON account.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 account.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}}
|
||||
{{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="ruler">Autres amortissements non rattachés</h3>
|
||||
<h3 class="center-block ruler">Autres amortissements non rattachés</h3>
|
||||
<table class="list">
|
||||
<thead>
|
||||
<tr>
|
||||
|
@ -35,7 +35,7 @@
|
||||
{{: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"}}
|
||||
{{:assign condition=$condition|cat:" AND debit > 0 AND NOT (trans.status & 16)"}}
|
||||
|
||||
{{#select
|
||||
trans.id as trans_id,
|
||||
@ -90,10 +90,13 @@
|
||||
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;
|
||||
l_amort.credit <> 0
|
||||
AND
|
||||
account.code LIKE '28%';
|
||||
:line_id = $immo_id|intval
|
||||
}}
|
||||
{{if $amort_amount == null}}
|
||||
|
@ -1,6 +1,6 @@
|
||||
{{* -*- brindille -*- *}}
|
||||
|
||||
{{* Liste des immobilisations non amortissable *}}
|
||||
{{* Liste des immobilisations non amortissables *}}
|
||||
|
||||
<section class="immobilisation">
|
||||
<h2 class="ruler">Immobilisations non amortissables</h2>
|
||||
|
14
index.html
14
index.html
@ -21,8 +21,8 @@
|
||||
<p class="block error">Échec enregistrement immobilisation</p>
|
||||
{{/if}}
|
||||
|
||||
{{* supprimer les documents sans écriture associée *}}
|
||||
{{#load type="immo"}}
|
||||
{{* supprimer les documents sans écriture associée *}}
|
||||
{{#select
|
||||
line.id as line_id
|
||||
FROM acc_transactions_lines as line
|
||||
@ -33,6 +33,18 @@
|
||||
{{else}}
|
||||
{{:delete key=$key}}
|
||||
{{/select}}
|
||||
|
||||
{{* supprimer les documents correspondant à une écriture de la balance d'ouverture *}}
|
||||
{{#select
|
||||
line.id as line_id,
|
||||
trans.status
|
||||
FROM acc_transactions_lines as line
|
||||
INNER JOIN acc_transactions AS trans on line.id_transaction = trans.id
|
||||
WHERE line.id = :line_id AND (trans.status & 16);
|
||||
:line_id = $line
|
||||
}}
|
||||
{{:delete key=$key}}
|
||||
{{/select}}
|
||||
{{/load}}
|
||||
|
||||
{{if $amort == "no_amort"}}
|
||||
|
@ -1,5 +1,5 @@
|
||||
name="Amortissements"
|
||||
description="Gestion des amortissements pour le logiciel de comptabilité Paheko (v0.12)"
|
||||
description="Gestion des amortissements pour le logiciel de comptabilité Paheko (v0.16)"
|
||||
author="Jean-Christophe Engel"
|
||||
author_url="https://git.roflcopter.fr/lesanges"
|
||||
home_button=false
|
||||
|
@ -147,7 +147,7 @@
|
||||
name="debit_account"
|
||||
label="Compte de débit"
|
||||
required=true
|
||||
target="!acc/charts/accounts/selector.php?&key=code&year=%d"|args:$year.id
|
||||
target="!acc/charts/accounts/selector.php?codes=%s&year=%d"|args:"68*":$year.id
|
||||
default=$debit_account
|
||||
}}
|
||||
{{:input
|
||||
@ -155,7 +155,7 @@
|
||||
name="credit_account"
|
||||
label="Compte d'amortissement (280xx ou 281xx)"
|
||||
required=true
|
||||
target="!acc/charts/accounts/selector.php?key=code&year=%d"|args:$year.id
|
||||
target="!acc/charts/accounts/selector.php?codes=%s&year=%d"|args:"28*":$year.id
|
||||
default=$credit_account
|
||||
}}
|
||||
</dl>
|
||||
|
Loading…
Reference in New Issue
Block a user