Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
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}}
|
|
@ -8,7 +8,7 @@
|
|||||||
*}}
|
*}}
|
||||||
|
|
||||||
{{:assign open_years=""}}
|
{{:assign open_years=""}}
|
||||||
{{#years status=false}}
|
{{#years status=false order="start_date"}}
|
||||||
{{:assign open_years=$open_years|cat:"\n"|cat:" - "|cat:$label|cat:" : "}}
|
{{:assign open_years=$open_years|cat:"\n"|cat:" - "|cat:$label|cat:" : "}}
|
||||||
{{:assign debut=$start_date|date_short}}
|
{{:assign debut=$start_date|date_short}}
|
||||||
{{:assign fin=$end_date|date_short}}
|
{{:assign fin=$end_date|date_short}}
|
||||||
|
@ -6,6 +6,10 @@
|
|||||||
{{:include file="_nav.html" current="index"}}
|
{{:include file="_nav.html" current="index"}}
|
||||||
{{/if}}
|
{{/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 *}}
|
{{* Traiter l'envoi du formulaire *}}
|
||||||
{{#form on="add"}}
|
{{#form on="add"}}
|
||||||
|
|
||||||
@ -55,10 +59,6 @@
|
|||||||
- est présent dans le PC de l'exercice correspondant à la date
|
- 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
|
{{:include
|
||||||
file="_check_account.html"
|
file="_check_account.html"
|
||||||
account=$debit_account
|
account=$debit_account
|
||||||
@ -123,22 +123,28 @@
|
|||||||
{{:assign var="projects.%d"|args:$id value=$label}}
|
{{:assign var="projects.%d"|args:$id value=$label}}
|
||||||
{{/select}}
|
{{/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="">
|
<form method="post" action="">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>Ajouter une immobilisation</legend>
|
<legend>Ajouter une immobilisation</legend>
|
||||||
<dl>
|
<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 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="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="text" name="designation" label="Désignation" required=true}}
|
||||||
{{:input type="money" name="montant" label="Montant" 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
|
{{:input
|
||||||
type="list"
|
type="list"
|
||||||
name="credit_account"
|
name="credit_account"
|
||||||
label="Compte de décaissement"
|
label="Compte de décaissement"
|
||||||
required=true
|
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
|
default=$bank_account
|
||||||
}}
|
}}
|
||||||
{{:input
|
{{:input
|
||||||
@ -146,7 +152,7 @@
|
|||||||
name="debit_account"
|
name="debit_account"
|
||||||
label="Compte d'immobilisation (20xx, 21xx, ...)"
|
label="Compte d'immobilisation (20xx, 21xx, ...)"
|
||||||
required=true
|
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
|
default=$immo_account
|
||||||
}}
|
}}
|
||||||
{{if $projects != null}}
|
{{if $projects != null}}
|
||||||
@ -161,8 +167,8 @@
|
|||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
{{* activer/désactiver les champs passés en paramètres *}}
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
{{* activer/désactiver les champs passés en paramètres *}}
|
||||||
function toggleInputs(idcb, idfields) {
|
function toggleInputs(idcb, idfields) {
|
||||||
const noamort = document.getElementById(idcb);
|
const noamort = document.getElementById(idcb);
|
||||||
for (let id of idfields) {
|
for (let id of idfields) {
|
||||||
@ -175,6 +181,21 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
{{* 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>
|
</script>
|
||||||
|
|
||||||
{{:admin_footer}}
|
{{:admin_footer}}
|
||||||
|
@ -237,12 +237,6 @@
|
|||||||
|
|
||||||
{{if $_GET.amort == null || $_GET.amort != "fini"}}
|
{{if $_GET.amort == null || $_GET.amort != "fini"}}
|
||||||
|
|
||||||
{{* amortissement à exclure *}}
|
|
||||||
{{:include
|
|
||||||
file="_amort_exclus.html"
|
|
||||||
keep="amort_exclus"
|
|
||||||
}}
|
|
||||||
|
|
||||||
{{* Autres amortissements non rattachés *}}
|
{{* Autres amortissements non rattachés *}}
|
||||||
{{#select
|
{{#select
|
||||||
li.id as l_id,
|
li.id as l_id,
|
||||||
@ -259,7 +253,7 @@
|
|||||||
inner join acc_accounts as acc on acc.id = li.id_account
|
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_transactions as trans on trans.id = li.id_transaction
|
||||||
inner join acc_years as y on y.id = trans.id_year
|
inner join acc_years as y on y.id = trans.id_year
|
||||||
where acc.code like "28%" AND credit > 0
|
where acc.code like "28%" AND credit > 0 AND (NOT trans.status & 16)
|
||||||
order by trans.date, trans.label;
|
order by trans.date, trans.label;
|
||||||
assign=autre_amort
|
assign=autre_amort
|
||||||
}}
|
}}
|
||||||
@ -270,11 +264,8 @@
|
|||||||
where id_transaction = :id_amort or id_related = :id_amort;
|
where id_transaction = :id_amort or id_related = :id_amort;
|
||||||
:id_amort=$t_id
|
:id_amort=$t_id
|
||||||
}}
|
}}
|
||||||
{{else}}
|
|
||||||
{{if $autre_amort.t_id|in:$amort_exclus}}
|
|
||||||
{{else}}
|
{{else}}
|
||||||
{{:assign var="autres_amortissements." value=$autre_amort}}
|
{{:assign var="autres_amortissements." value=$autre_amort}}
|
||||||
{{/if}}
|
|
||||||
{{/select}}
|
{{/select}}
|
||||||
{{/select}}
|
{{/select}}
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
{{:assign condition=$condition|cat:" account.code LIKE "|cat:$quote|cat:$code|cat:"%"|cat:$quote|cat:" OR "}}
|
{{:assign condition=$condition|cat:" account.code LIKE "|cat:$quote|cat:$code|cat:"%"|cat:$quote|cat:" OR "}}
|
||||||
{{/foreach}}
|
{{/foreach}}
|
||||||
{{:assign condition=$condition|cat:"0)"}}
|
{{: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
|
{{#select
|
||||||
trans.id as trans_id,
|
trans.id as trans_id,
|
||||||
|
14
index.html
14
index.html
@ -21,8 +21,8 @@
|
|||||||
<p class="block error">Échec enregistrement immobilisation</p>
|
<p class="block error">Échec enregistrement immobilisation</p>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{* supprimer les documents sans écriture associée *}}
|
|
||||||
{{#load type="immo"}}
|
{{#load type="immo"}}
|
||||||
|
{{* supprimer les documents sans écriture associée *}}
|
||||||
{{#select
|
{{#select
|
||||||
line.id as line_id
|
line.id as line_id
|
||||||
FROM acc_transactions_lines as line
|
FROM acc_transactions_lines as line
|
||||||
@ -33,6 +33,18 @@
|
|||||||
{{else}}
|
{{else}}
|
||||||
{{:delete key=$key}}
|
{{:delete key=$key}}
|
||||||
{{/select}}
|
{{/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}}
|
{{/load}}
|
||||||
|
|
||||||
{{if $amort == "no_amort"}}
|
{{if $amort == "no_amort"}}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
name="Amortissements"
|
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.14)"
|
||||||
author="Jean-Christophe Engel"
|
author="Jean-Christophe Engel"
|
||||||
author_url="https://git.roflcopter.fr/lesanges"
|
author_url="https://git.roflcopter.fr/lesanges"
|
||||||
home_button=false
|
home_button=false
|
||||||
|
@ -147,7 +147,7 @@
|
|||||||
name="debit_account"
|
name="debit_account"
|
||||||
label="Compte de débit"
|
label="Compte de débit"
|
||||||
required=true
|
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
|
default=$debit_account
|
||||||
}}
|
}}
|
||||||
{{:input
|
{{:input
|
||||||
@ -155,7 +155,7 @@
|
|||||||
name="credit_account"
|
name="credit_account"
|
||||||
label="Compte d'amortissement (280xx ou 281xx)"
|
label="Compte d'amortissement (280xx ou 281xx)"
|
||||||
required=true
|
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
|
default=$credit_account
|
||||||
}}
|
}}
|
||||||
</dl>
|
</dl>
|
||||||
|
Loading…
Reference in New Issue
Block a user