Compare commits

..

8 Commits
v0.12 ... main

8 changed files with 53 additions and 98 deletions

View File

@ -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}}

View File

@ -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}}

View File

@ -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,8 +167,8 @@
</form>
{{* activer/désactiver les champs passés en paramètres *}}
<script type="text/javascript">
{{* activer/désactiver les champs passés en paramètres *}}
function toggleInputs(idcb, idfields) {
const noamort = document.getElementById(idcb);
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>
{{:admin_footer}}

View File

@ -237,12 +237,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,
@ -259,7 +253,7 @@
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
where acc.code like "28%" AND credit > 0 AND (NOT trans.status & 16)
order by trans.date, trans.label;
assign=autre_amort
}}
@ -270,11 +264,8 @@
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}}

View File

@ -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,

View File

@ -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"}}

View File

@ -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.14)"
author="Jean-Christophe Engel"
author_url="https://git.roflcopter.fr/lesanges"
home_button=false

View File

@ -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>