Compare commits
2 Commits
cc7ea1b54c
...
77aac6fd4a
Author | SHA1 | Date | |
---|---|---|---|
77aac6fd4a | |||
db26c7b2d6 |
@ -9,6 +9,46 @@
|
|||||||
{{* Traiter l'envoi du formulaire *}}
|
{{* Traiter l'envoi du formulaire *}}
|
||||||
{{#form on="add"}}
|
{{#form on="add"}}
|
||||||
|
|
||||||
|
{{* vérifier que la date est située dans un exercice ouvert *}}
|
||||||
|
{{:assign open_years=""}}
|
||||||
|
{{#years closed=false}}
|
||||||
|
{{: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}}
|
||||||
|
{{if $start_date|strtotime <= $_POST.date|parse_date|strtotime && $end_date|strtotime >= $_POST.date|parse_date|strtotime}}
|
||||||
|
{{:assign selected_year=$id}}
|
||||||
|
{{:assign selected_chart=$id_chart}}
|
||||||
|
{{/if}}
|
||||||
|
{{/years}}
|
||||||
|
{{if $selected_year == null}}
|
||||||
|
{{:assign message="La date choisie n'est dans aucun exercice ouvert !!\nExercices ouverts : %s"|args:$open_years}}
|
||||||
|
{{:error message=$message}}
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{* vérifier :
|
||||||
|
- que le compte d'immo débute par 20 ou 21
|
||||||
|
- est présent dans le PC de l'exercice correspondant à la date
|
||||||
|
*}}
|
||||||
|
{{#select
|
||||||
|
code
|
||||||
|
FROM acc_accounts
|
||||||
|
WHERE id_chart =:id_chart
|
||||||
|
AND
|
||||||
|
(code LIKE "20%" OR code LIKE "21%");
|
||||||
|
:id_chart = $selected_chart|intval
|
||||||
|
}}
|
||||||
|
{{if $_POST.debit_account|has_key:$code}}
|
||||||
|
{{:assign account_ok=1}}
|
||||||
|
{{:break}}
|
||||||
|
{{/if}}
|
||||||
|
{{/select}}
|
||||||
|
|
||||||
|
{{if $account_ok == null}}
|
||||||
|
{{:assign compte=$_POST.debit_account|implode:""}}
|
||||||
|
{{:error message="Le compte « %s » n'est pas un compte d'immobilisation ou n'est pas dans le plan comptable de l'exercice choisi"|args:$compte}}
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
{{* enregistrer l'écriture *}}
|
{{* enregistrer l'écriture *}}
|
||||||
{{:assign var="credit_accounts" value=$_POST.credit_account|keys}}
|
{{:assign var="credit_accounts" value=$_POST.credit_account|keys}}
|
||||||
{{:assign var="credit_account" value=$credit_accounts.0}}
|
{{:assign var="credit_account" value=$credit_accounts.0}}
|
||||||
@ -19,7 +59,7 @@
|
|||||||
method="POST"
|
method="POST"
|
||||||
path="accounting/transaction"
|
path="accounting/transaction"
|
||||||
assign="result"
|
assign="result"
|
||||||
id_year=$_POST.id_year
|
id_year=$selected_year
|
||||||
type="revenue"
|
type="revenue"
|
||||||
date=$_POST.date
|
date=$_POST.date
|
||||||
label=$_POST.designation
|
label=$_POST.designation
|
||||||
@ -43,17 +83,10 @@
|
|||||||
{{:redirect force="index.html?ok=1&msg=immobilisation"}}
|
{{:redirect force="index.html?ok=1&msg=immobilisation"}}
|
||||||
{{/form}}
|
{{/form}}
|
||||||
|
|
||||||
{{* Préparer les infos pour le formulaire *}}
|
{{:form_errors}}
|
||||||
|
|
||||||
{{:assign var="bank_account.512A" value="512A — Compte courant"}}
|
|
||||||
{{#years closed=false}}
|
|
||||||
{{:assign var="open_years.%d"|args:$id value=$label}}
|
|
||||||
{{if $start_date|strtotime <= $now && $end_date|strtotime >= $now}}
|
|
||||||
{{:assign best_year=$id}}
|
|
||||||
{{/if}}
|
|
||||||
{{/years}}
|
|
||||||
|
|
||||||
{{* formulaire d'ajout d'immobilisation *}}
|
{{* formulaire d'ajout d'immobilisation *}}
|
||||||
|
{{:assign var="bank_account.512A" value="512A — Compte courant"}}
|
||||||
|
|
||||||
{{*
|
{{*
|
||||||
TODO
|
TODO
|
||||||
@ -68,7 +101,6 @@
|
|||||||
<fieldset class="ajout_immo">
|
<fieldset class="ajout_immo">
|
||||||
<legend>Ajouter une immobilisation</legend>
|
<legend>Ajouter une immobilisation</legend>
|
||||||
<dl>
|
<dl>
|
||||||
{{:input type="select" default=$best_year name="id_year" label="Exercice" required=true options=$open_years}}
|
|
||||||
{{:input type="date" name="date" label="Date" required=true default=$now|date_short}}
|
{{:input type="date" name="date" label="Date" required=true default=$now|date_short}}
|
||||||
{{: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}}
|
||||||
@ -78,7 +110,7 @@
|
|||||||
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&year=%d"|args:$best_year
|
target="!acc/charts/accounts/selector.php?targets=1:2:3&key=code"
|
||||||
default=$bank_account
|
default=$bank_account
|
||||||
}}
|
}}
|
||||||
{{:input
|
{{:input
|
||||||
@ -86,7 +118,7 @@
|
|||||||
name="debit_account"
|
name="debit_account"
|
||||||
label="Compte d'immobilisation (20xx ou 21xx)"
|
label="Compte d'immobilisation (20xx ou 21xx)"
|
||||||
required=true
|
required=true
|
||||||
target="!acc/charts/accounts/selector.php?key=code&year=%d"|args:$best_year
|
target="!acc/charts/accounts/selector.php?key=code"
|
||||||
}}
|
}}
|
||||||
{{if $projects != null}}
|
{{if $projects != null}}
|
||||||
{{:input type="select" name="id_project" label="Projet (analytique)" options=$projects default_empty="— Aucun —"}}
|
{{:input type="select" name="id_project" label="Projet (analytique)" options=$projects default_empty="— Aucun —"}}
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
<li>Montant</li>
|
<li>Montant</li>
|
||||||
<li>Durée d'amortissement en années</li>
|
<li>Durée d'amortissement en années</li>
|
||||||
<li>Compte de décaissement : à choisir dans la liste</li>
|
<li>Compte de décaissement : à choisir dans la liste</li>
|
||||||
<li>Compte d'immobilisation : idem</li>
|
<li>Compte d'immobilisation : doit débuter par <b>20</b> ou <b>21</b></li>
|
||||||
<li>Projet analytique (optionnel)</li>
|
<li>Projet analytique (optionnel)</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@
|
|||||||
trans.label as label,
|
trans.label as label,
|
||||||
trans.date as date_achat,
|
trans.date as date_achat,
|
||||||
y.id as year_id,
|
y.id as year_id,
|
||||||
date(y.start_date, "start of year", "+1 year", "-1 day") as date_amort,
|
y.end_date as date_amort,
|
||||||
project.label as project_label
|
project.label as project_label
|
||||||
from acc_transactions_lines as line
|
from acc_transactions_lines as line
|
||||||
inner join acc_transactions as trans on line.id_transaction = trans.id
|
inner join acc_transactions as trans on line.id_transaction = trans.id
|
||||||
@ -59,8 +59,6 @@
|
|||||||
{{:error message=$message}}
|
{{:error message=$message}}
|
||||||
{{/select}}
|
{{/select}}
|
||||||
|
|
||||||
{{*:debug ligne_immo=$ligne_immo*}}
|
|
||||||
|
|
||||||
{{* chercher des écritures d'amortissement liées à l'immobilisation *}}
|
{{* chercher des écritures d'amortissement liées à l'immobilisation *}}
|
||||||
{{#select
|
{{#select
|
||||||
l_amort.credit as amort_amount,
|
l_amort.credit as amort_amount,
|
||||||
@ -100,8 +98,6 @@
|
|||||||
{{:assign var="amort_years." value=$amort_year}}
|
{{:assign var="amort_years." value=$amort_year}}
|
||||||
{{/select}}
|
{{/select}}
|
||||||
|
|
||||||
{{*:debug linked_lines=$linked_lines amort_associes=$amort_associes*}}
|
|
||||||
|
|
||||||
{{* chercher parmi les associations *}}
|
{{* chercher parmi les associations *}}
|
||||||
{{#foreach from=$info_immo.amort item="id_amort"}}
|
{{#foreach from=$info_immo.amort item="id_amort"}}
|
||||||
{{#select
|
{{#select
|
||||||
@ -138,7 +134,6 @@
|
|||||||
{{/select}}
|
{{/select}}
|
||||||
{{/foreach}}
|
{{/foreach}}
|
||||||
|
|
||||||
{{*:debug linked_lines=$linked_lines*}}
|
|
||||||
{{* montant de l'annuité théorique *}}
|
{{* montant de l'annuité théorique *}}
|
||||||
{{:assign montant="%f"|math:$ligne_immo.montant}}
|
{{:assign montant="%f"|math:$ligne_immo.montant}}
|
||||||
{{:assign annuite="%f/%f"|math:$montant:$duree}}
|
{{:assign annuite="%f/%f"|math:$montant:$duree}}
|
||||||
@ -149,7 +144,6 @@
|
|||||||
{{:include file="_calcul_dates.html" date_debut=$date_achat date_fin=$date_amort keep="nbjours"}}
|
{{:include file="_calcul_dates.html" date_debut=$date_achat date_fin=$date_amort keep="nbjours"}}
|
||||||
{{:assign annuite_1="%f/360*%d"|math:$annuite:$nbjours|intval}}
|
{{:assign annuite_1="%f/360*%d"|math:$annuite:$nbjours|intval}}
|
||||||
|
|
||||||
{{*:assign date_amort=$date_fin*}}
|
|
||||||
{{:assign annuite_courante=$annuite_1}}
|
{{:assign annuite_courante=$annuite_1}}
|
||||||
{{:assign current_year=$ligne_immo.year_id}}
|
{{:assign current_year=$ligne_immo.year_id}}
|
||||||
{{:assign solde=$ligne_immo.montant}}
|
{{:assign solde=$ligne_immo.montant}}
|
||||||
|
@ -59,7 +59,7 @@
|
|||||||
{{#select
|
{{#select
|
||||||
id,
|
id,
|
||||||
label,
|
label,
|
||||||
date(start_date, "start of year", "+1 year", "-1 day") as date_amort
|
end_date as date_amort
|
||||||
from acc_years where id=:id;
|
from acc_years where id=:id;
|
||||||
:id=$_GET.year assign=year
|
:id=$_GET.year assign=year
|
||||||
}}
|
}}
|
||||||
|
Loading…
Reference in New Issue
Block a user