Compare commits
No commits in common. "77aac6fd4a079bae33d0ff3d3dc671c7f48d25ba" and "cc7ea1b54c5525ac701fbb05ab527988647ad15f" have entirely different histories.
77aac6fd4a
...
cc7ea1b54c
@ -9,46 +9,6 @@
|
||||
{{* Traiter l'envoi du formulaire *}}
|
||||
{{#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 *}}
|
||||
{{:assign var="credit_accounts" value=$_POST.credit_account|keys}}
|
||||
{{:assign var="credit_account" value=$credit_accounts.0}}
|
||||
@ -59,7 +19,7 @@
|
||||
method="POST"
|
||||
path="accounting/transaction"
|
||||
assign="result"
|
||||
id_year=$selected_year
|
||||
id_year=$_POST.id_year
|
||||
type="revenue"
|
||||
date=$_POST.date
|
||||
label=$_POST.designation
|
||||
@ -83,10 +43,17 @@
|
||||
{{:redirect force="index.html?ok=1&msg=immobilisation"}}
|
||||
{{/form}}
|
||||
|
||||
{{:form_errors}}
|
||||
{{* Préparer les infos pour le formulaire *}}
|
||||
|
||||
{{: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 *}}
|
||||
{{:assign var="bank_account.512A" value="512A — Compte courant"}}
|
||||
|
||||
{{*
|
||||
TODO
|
||||
@ -101,6 +68,7 @@
|
||||
<fieldset class="ajout_immo">
|
||||
<legend>Ajouter une immobilisation</legend>
|
||||
<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="text" name="designation" label="Désignation" required=true}}
|
||||
{{:input type="money" name="montant" label="Montant" required=true}}
|
||||
@ -110,7 +78,7 @@
|
||||
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?targets=1:2:3&key=code&year=%d"|args:$best_year
|
||||
default=$bank_account
|
||||
}}
|
||||
{{:input
|
||||
@ -118,7 +86,7 @@
|
||||
name="debit_account"
|
||||
label="Compte d'immobilisation (20xx ou 21xx)"
|
||||
required=true
|
||||
target="!acc/charts/accounts/selector.php?key=code"
|
||||
target="!acc/charts/accounts/selector.php?key=code&year=%d"|args:$best_year
|
||||
}}
|
||||
{{if $projects != null}}
|
||||
{{:input type="select" name="id_project" label="Projet (analytique)" options=$projects default_empty="— Aucun —"}}
|
||||
|
@ -33,7 +33,7 @@
|
||||
<li>Montant</li>
|
||||
<li>Durée d'amortissement en années</li>
|
||||
<li>Compte de décaissement : à choisir dans la liste</li>
|
||||
<li>Compte d'immobilisation : doit débuter par <b>20</b> ou <b>21</b></li>
|
||||
<li>Compte d'immobilisation : idem</li>
|
||||
<li>Projet analytique (optionnel)</li>
|
||||
</ul>
|
||||
|
||||
|
@ -43,7 +43,7 @@
|
||||
trans.label as label,
|
||||
trans.date as date_achat,
|
||||
y.id as year_id,
|
||||
y.end_date as date_amort,
|
||||
date(y.start_date, "start of year", "+1 year", "-1 day") 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
|
||||
@ -59,6 +59,8 @@
|
||||
{{:error message=$message}}
|
||||
{{/select}}
|
||||
|
||||
{{*:debug ligne_immo=$ligne_immo*}}
|
||||
|
||||
{{* chercher des écritures d'amortissement liées à l'immobilisation *}}
|
||||
{{#select
|
||||
l_amort.credit as amort_amount,
|
||||
@ -98,6 +100,8 @@
|
||||
{{:assign var="amort_years." value=$amort_year}}
|
||||
{{/select}}
|
||||
|
||||
{{*:debug linked_lines=$linked_lines amort_associes=$amort_associes*}}
|
||||
|
||||
{{* chercher parmi les associations *}}
|
||||
{{#foreach from=$info_immo.amort item="id_amort"}}
|
||||
{{#select
|
||||
@ -134,6 +138,7 @@
|
||||
{{/select}}
|
||||
{{/foreach}}
|
||||
|
||||
{{*:debug linked_lines=$linked_lines*}}
|
||||
{{* montant de l'annuité théorique *}}
|
||||
{{:assign montant="%f"|math:$ligne_immo.montant}}
|
||||
{{:assign annuite="%f/%f"|math:$montant:$duree}}
|
||||
@ -144,6 +149,7 @@
|
||||
{{: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 date_amort=$date_fin*}}
|
||||
{{:assign annuite_courante=$annuite_1}}
|
||||
{{:assign current_year=$ligne_immo.year_id}}
|
||||
{{:assign solde=$ligne_immo.montant}}
|
||||
|
@ -59,7 +59,7 @@
|
||||
{{#select
|
||||
id,
|
||||
label,
|
||||
end_date as date_amort
|
||||
date(start_date, "start of year", "+1 year", "-1 day") as date_amort
|
||||
from acc_years where id=:id;
|
||||
:id=$_GET.year assign=year
|
||||
}}
|
||||
|
Loading…
Reference in New Issue
Block a user