Compare commits
2 Commits
f35ca35538
...
5e8026e09b
Author | SHA1 | Date | |
---|---|---|---|
5e8026e09b | |||
5e081c4f23 |
@ -7,7 +7,6 @@
|
||||
|
||||
{{* Traiter l'envoi du formulaire *}}
|
||||
{{#form on="add"}}
|
||||
{{* :debug POST=$_POST *}}
|
||||
|
||||
{{* enregistrer l'écriture *}}
|
||||
{{:assign var="credit_accounts" value=$_POST.credit_account|keys}}
|
||||
@ -15,9 +14,6 @@
|
||||
{{:assign var="debit_accounts" value=$_POST.debit_account|keys}}
|
||||
{{:assign var="debit_account" value=$debit_accounts.0}}
|
||||
|
||||
{{* :debug credit_account=$credit_account *}}
|
||||
{{* :debug debit_account=$debit_account *}}
|
||||
|
||||
{{:api
|
||||
method="POST"
|
||||
path="accounting/transaction"
|
||||
@ -29,17 +25,11 @@
|
||||
amount=$_POST.montant
|
||||
debit=$debit_account
|
||||
credit=$credit_account
|
||||
id_project=$_POST.id_project
|
||||
}}
|
||||
|
||||
{{* :debug result=$result *}}
|
||||
|
||||
{{* enregistrer les infos de l'immobilisation *}}
|
||||
{{* :debug lines=$result.lines *}}
|
||||
{{* :debug line1=$result.lines.1 *}}
|
||||
|
||||
{{:assign var="line_id" value=$result.lines.1.id}}
|
||||
{{* :debug line_id=$line_id *}}
|
||||
|
||||
{{:assign key=""|uuid}}
|
||||
{{:save
|
||||
key=$key
|
||||
@ -57,7 +47,7 @@
|
||||
{{:assign var="bank_account.512A" value="512A — Compte courant"}}
|
||||
{{#years closed=false}}
|
||||
{{:assign var="open_years.%d"|args:$id value=$label}}
|
||||
{{if $start_date <= $now && $end_date >= $now}}
|
||||
{{if $start_date|strtotime <= $now && $end_date|strtotime >= $now}}
|
||||
{{:assign best_year=$id}}
|
||||
{{/if}}
|
||||
{{/years}}
|
||||
@ -66,9 +56,13 @@
|
||||
|
||||
{{*
|
||||
TODO
|
||||
- ajouter projet et autres rubriques selon besoin
|
||||
- ajouter autres rubriques selon besoin
|
||||
*}}
|
||||
|
||||
{{#select id,label FROM acc_projects WHERE archived = 0;}}
|
||||
{{:assign var="projects.%d"|args:$id value=$label}}
|
||||
{{/select}}
|
||||
|
||||
<form method="post" action="">
|
||||
<fieldset class="ajout_immo">
|
||||
<legend>Ajouter une immobilisation</legend>
|
||||
@ -93,6 +87,9 @@
|
||||
required=true
|
||||
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 —"}}
|
||||
{{/if}}
|
||||
</dl>
|
||||
</fieldset>
|
||||
|
||||
|
@ -13,27 +13,28 @@
|
||||
{{#select
|
||||
line.id as line_id,
|
||||
line.id_account as account_id,
|
||||
line.id_project as project_id,
|
||||
trans.id as trans_id,
|
||||
line.debit as montant,
|
||||
trans.label as label,
|
||||
trans.date as date_achat,
|
||||
y.id as year_id,
|
||||
y.end_date as date_fin
|
||||
y.end_date as date_fin,
|
||||
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;
|
||||
:line_id = $_GET.line|intval
|
||||
assign=ligne_immo
|
||||
}}
|
||||
<h3>Amortissement de « {{$label}} » d'un montant de {{"%f"|math:$montant|money_currency}} en date du {{$date_achat|date_short}}</h3>
|
||||
<h2>Amortissement de « {{$label}} » d'un montant de {{"%f"|math:$montant|money_currency}} en date du {{$date_achat|date_short}} sur {{$info_immo.duration}} ans</h2>
|
||||
{{else}}
|
||||
{{:assign message="Immobilisation %s non trouvée"|args:$_GET.line}}
|
||||
{{:error message=$message}}
|
||||
{{/select}}
|
||||
|
||||
{{*:debug ligne_immo=$ligne_immo*}}
|
||||
|
||||
{{* lister les écritures d'amortissement *}}
|
||||
{{#select
|
||||
line.id as l_immo,
|
||||
@ -45,6 +46,8 @@
|
||||
line2.id_transaction as trans_id,
|
||||
line2.id_project as projet,
|
||||
line2.id_account as account_id,
|
||||
line2.id_project as project_id,
|
||||
project.label as project_label,
|
||||
trans.date as date_immo,
|
||||
acc.code as account_code,
|
||||
acc.label as nom_compte,
|
||||
@ -54,6 +57,7 @@
|
||||
inner JOIN acc_transactions_lines as line2 on links.id_transaction = line2.id_transaction
|
||||
inner join acc_accounts as acc on line2.id_account = acc.id
|
||||
inner join acc_transactions as trans on line2.id_transaction = trans.id
|
||||
left join acc_projects AS project ON line.id_project = project.id
|
||||
where line.id = :line_id and line2.debit <> 0
|
||||
order by trans.date;
|
||||
:line_id = $info_immo.line|intval
|
||||
@ -61,16 +65,11 @@
|
||||
}}
|
||||
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$trans_id}}
|
||||
{{/select}}
|
||||
{{*:debug lines=$lines*}}
|
||||
{{*:debug line=$lines.0*}}
|
||||
{{*:debug line=$lines.1*}}
|
||||
|
||||
{{* calculer les amortissements *}}
|
||||
{{* montant de l'annuité normale *}}
|
||||
{{:assign montant="%f"|math:$ligne_immo.montant}}
|
||||
{{:assign annuite="%f/%f"|math:$montant:$info_immo.duration|intval}}
|
||||
{{*:debug montant=$montant *}}
|
||||
{{*:debug annuite=$annuite *}}
|
||||
|
||||
{{* liste des exercices *}}
|
||||
{{#years}}
|
||||
@ -79,24 +78,18 @@
|
||||
{{:assign var="all_years.%d.closed"|args:$id value=$closed}}
|
||||
{{/years}}
|
||||
|
||||
{{*
|
||||
{{:debug all_years=$all_years}}
|
||||
{{:assign current_year=8}}
|
||||
{{:assign var="date_immo" from="all_years.%s.end_date"|args:$current_year}}
|
||||
{{:debug date_immo=$date_immo}}
|
||||
*}}
|
||||
|
||||
{{* première annuité *}}
|
||||
{{:assign date_achat=$ligne_immo.date_achat|date_short}}
|
||||
{{:assign date_fin=$ligne_immo.date_fin|date_short}}
|
||||
{{:include file="_calcul_dates.html" date_debut=$date_achat date_fin=$date_fin keep="nbjours"}}
|
||||
{{:assign annuite_1="%f/360*%d"|math:$annuite:$nbjours|intval}}
|
||||
{{*:debug annuite1=$annuite_1 *}}
|
||||
|
||||
{{:assign date_immo=$date_fin}}
|
||||
{{:assign annuite_courante=$annuite_1}}
|
||||
{{:assign solde=$montant}}
|
||||
{{:assign current_year=$ligne_immo.year_id}}
|
||||
{{:assign project_id=$ligne_immo.project_id}}
|
||||
{{:assign project_label=$ligne_immo.project_label}}
|
||||
|
||||
<section class="amortissement">
|
||||
<h2 class="ruler">Liste des amortissements</h2>
|
||||
@ -108,16 +101,15 @@
|
||||
<th>Montant</th>
|
||||
<th>Solde</th>
|
||||
<th>Libellé</th>
|
||||
<th>ligne amort</th>
|
||||
<th>N° compte</th>
|
||||
<th>Compte</th>
|
||||
<th>Nom compte</th>
|
||||
<th>Projet</th>
|
||||
<th class="actions"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#foreach count="%d+1"|math:$info_immo.duration|intval key="num"}}
|
||||
{{:assign var="line" from="lines.%s"|args:$num}}
|
||||
{{*:debug line=$line*}}
|
||||
|
||||
{{if $line != null}}
|
||||
{{* données de l'écriture *}}
|
||||
@ -129,13 +121,15 @@
|
||||
<td class="money">{{"%f"|math:$line.montant|money}}</td>
|
||||
<td class="money">{{"%f"|math:$solde|money}}</td>
|
||||
<td>{{$line.libelle}}</td>
|
||||
<td>{{$line.l_amort}}</td>
|
||||
<td>{{$line.account_code}}</td>
|
||||
<td>{{$line.nom_compte}}</td>
|
||||
<td>{{$line.project_label}}</td>
|
||||
<td class="actions"></td>
|
||||
</tr>
|
||||
{{:assign libelle=$line.libelle}}
|
||||
{{:assign ammort_account=$line.ammort_account}}
|
||||
{{:assign project_id=$line.project_id}}
|
||||
{{:assign project_label=$line.project_label}}
|
||||
{{:assign annuite_courante="min(%f,%f)"|math:$annuite:$solde}}
|
||||
{{:assign current_year="%d+1"|math:$current_year}}
|
||||
{{:assign date_immo=$line.date_immo}}
|
||||
@ -167,14 +161,16 @@
|
||||
</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td>{{$project_label}}</td>
|
||||
<td class="actions">
|
||||
{{if $all_years|keys|has:$current_year}}
|
||||
{{:linkbutton
|
||||
label="Enregistrer"
|
||||
href="save_amort.html?amount=%d&account=%s&year=%s&label=%s"|args:$annuite_courante:$ligne_immo.account_id:$current_year:$libelle
|
||||
href="save_amort.html?amount=%d&account=%s&year=%s&trans_id=%d&line_id=%s&project_id=%d&label=%s"|args:$annuite_courante:$ligne_immo.account_id:$current_year:$ligne_immo.trans_id:$_GET.line:$project_id:$libelle
|
||||
shape="right"
|
||||
}}
|
||||
{{else}}
|
||||
{{:linkbutton label="Enregistrer" href="" shape="alert"}}
|
||||
{{/if}}
|
||||
</td>
|
||||
</tr>
|
||||
|
71
index.html
71
index.html
@ -4,12 +4,11 @@
|
||||
{{:include file="_nav.html" current="index"}}
|
||||
|
||||
{{if $_GET.ok}}
|
||||
<p class="block confirm">Modification effectuée</p>
|
||||
<p class="block confirm">Immobilisation enregistrée</p>
|
||||
{{elseif $_GET.err}}
|
||||
<p class="block error">Modification refusée</p>
|
||||
<p class="block error">Enregistrement immobilisation refusée</p>
|
||||
{{/if}}
|
||||
|
||||
|
||||
{{* lister les immobilisations *}}
|
||||
<section class="immobilisation">
|
||||
<h2 class="ruler">Liste des immobilisations</h2>
|
||||
@ -17,21 +16,20 @@
|
||||
<table class="list">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Id</th>
|
||||
<th>Libellé</th>
|
||||
<th>N°</th>
|
||||
<th>Date</th>
|
||||
<th>id_line</th>
|
||||
<th>Libellé</th>
|
||||
<th>Montant</th>
|
||||
<th>Durée</th>
|
||||
<th>N° compte</th>
|
||||
<th>Compte</th>
|
||||
<th>Montant</th>
|
||||
<th>Projet</th>
|
||||
<th class="actions"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{*
|
||||
TODO améliorer cette requête :
|
||||
- ne pas mettre l'id du PC
|
||||
- voir si assez général
|
||||
TODO améliorer cette requête : voir si assez général
|
||||
*}}
|
||||
|
||||
{{#select
|
||||
@ -41,27 +39,28 @@
|
||||
line.id as line_id,
|
||||
account.code as account_code,
|
||||
account.label as account_label,
|
||||
line.debit AS debit
|
||||
line.debit AS debit,
|
||||
project.label as project_label
|
||||
FROM acc_transactions AS trans
|
||||
INNER JOIN acc_transactions_lines AS line ON line.id_transaction = trans.id
|
||||
INNER JOIN acc_accounts AS account ON line.id_account = account.id
|
||||
INNER JOIN acc_years AS years ON trans.id_year = years.id
|
||||
LEFT JOIN acc_projects AS proj ON line.id_project = proj.id
|
||||
LEFT JOIN acc_projects AS project ON line.id_project = project.id
|
||||
WHERE
|
||||
account.id_chart = "3"
|
||||
AND
|
||||
(account.code LIKE '21%' OR account.code LIKE '22%')
|
||||
ORDER BY trans.date DESC
|
||||
}}
|
||||
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$trans_id}}
|
||||
{{#load type="immo" assign="info_immo" where="$$.line = :line_id" :line_id=$line_id|intval}}{{/load}}
|
||||
<tr>
|
||||
<td class="num"><a href={{$trans_url}}>#{{$trans_id}}</a></td>
|
||||
<td>{{$trans_label}}</td>
|
||||
<td>{{$trans_date|date_short}}</td>
|
||||
<td>{{$line_id}}</td>
|
||||
<td>{{$trans_label}}</td>
|
||||
<td class="money">{{"%f"|math:$debit|money}}</td>
|
||||
<td class="num">{{$info_immo.duration}}</td>
|
||||
<td>{{$account_code}}</td>
|
||||
<td>{{$account_label}}</td>
|
||||
<td class="money">{{"%f"|math:$debit|money}}</td>
|
||||
<td>{{$project_label}}</td>
|
||||
<td class="actions">
|
||||
{{:linkbutton
|
||||
label="Amortissements"
|
||||
@ -88,42 +87,4 @@
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
|
||||
{{* sélectionner un compte *}}
|
||||
<h1>TEST</h1>
|
||||
|
||||
{{:assign var="ll.0.d" value="%f/100"|math:$debit}}
|
||||
{{:assign var="ll.1.c" value="%f/100"|math:$debit}}
|
||||
{{* :debug ll=$ll *}}
|
||||
{{:assign
|
||||
var="qs"
|
||||
t=0
|
||||
l="Amortissement de %s"|args:$trans_label
|
||||
dt=$trans_date
|
||||
a00=0
|
||||
ll=$ll
|
||||
}}
|
||||
{{:assign qs=$qs|http_build_query}}
|
||||
{{:linkbutton
|
||||
label="Ajouter"
|
||||
href="!acc/transactions/new.php?%s"|args:$qs
|
||||
shape="plus"
|
||||
target="_dialog"
|
||||
}}
|
||||
|
||||
<form method="post" action="">
|
||||
<fieldset>
|
||||
<legend>Écriture de note de frais</legend>
|
||||
{{:assign var="default_account.625" value="625 Déplacements, missions et réceptions"}}
|
||||
{{:input
|
||||
type="list"
|
||||
name="account"
|
||||
label="Compte de paiement"
|
||||
required=true
|
||||
target="!acc/charts/accounts/selector.php?targets=5&key=code&year=%d"|args:7
|
||||
default=$default_account
|
||||
}}
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
{{:admin_footer}}
|
||||
|
@ -6,6 +6,40 @@
|
||||
{{/if}}
|
||||
|
||||
{{* Traiter l'envoi du formulaire *}}
|
||||
{{#form on="save"}}
|
||||
{{* enregistrer l'écriture *}}
|
||||
{{:assign var="linked_transactions." value=$_GET.trans_id}}
|
||||
|
||||
{{:assign
|
||||
var="lines."
|
||||
debit=$_POST.montant
|
||||
account=$_POST.debit_account|keys|key:0
|
||||
id_project=$_GET.project_id
|
||||
label=$_POST.designation
|
||||
}}
|
||||
{{:assign
|
||||
var="lines."
|
||||
credit=$_POST.montant
|
||||
account=$_POST.credit_account|keys|key:0
|
||||
id_project=$_GET.project_id
|
||||
label=$_POST.designation
|
||||
}}
|
||||
|
||||
{{:api
|
||||
method="POST"
|
||||
path="accounting/transaction"
|
||||
assign="result"
|
||||
assign_code="result_code"
|
||||
id_year=$_POST.id_year|intval
|
||||
type="advanced"
|
||||
date=$_POST.date
|
||||
label=$_POST.designation
|
||||
lines=$lines
|
||||
linked_transactions=$_GET.trans_id|intval
|
||||
}}
|
||||
|
||||
{{:redirect to="amortization.html?line=%s"|args:$_GET.line_id}}
|
||||
{{/form}}
|
||||
|
||||
{{* Préparer les infos pour le formulaire *}}
|
||||
{{:assign var="debit_account.6811" value="6811 — Dot. aux amortissements des immobilisations"}}
|
||||
@ -21,7 +55,6 @@
|
||||
{{:assign var="credit_account.%s"|args:$amort_code value="%s — Amortissements "|args:$amort_code|cat:$amort_account.label}}
|
||||
|
||||
{{#select id, label, end_date from acc_years where id=:id; :id=$_GET.year assign=year}}{{/select}}
|
||||
{{*:debug year.id=$year.id year.end_date=$year.end_date|date_short*}}
|
||||
|
||||
{{#years closed=false}}
|
||||
{{:assign var="open_years.%d"|args:$id value=$label}}
|
||||
@ -45,7 +78,7 @@
|
||||
}}
|
||||
{{:input
|
||||
type="list"
|
||||
name="credi_account"
|
||||
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
|
||||
@ -55,7 +88,7 @@
|
||||
</fieldset>
|
||||
|
||||
<p class="submit">
|
||||
{{:button type="submit" name="add" label="Enregistrer" shape="right" class="main"}}
|
||||
{{:button type="submit" name="save" label="Enregistrer" shape="right" class="main"}}
|
||||
</p>
|
||||
</form>
|
||||
{{:admin_footer}}
|
||||
|
Loading…
Reference in New Issue
Block a user