amortization/asset.html

107 lines
2.8 KiB
HTML
Raw Normal View History

2024-02-15 14:23:03 +01:00
{{:admin_header title="Ajout immobilisation" current="module_amortissement"}}
{{* barre de navigation *}}
{{if ! $dialog}}
{{:include file="_nav.html" current="index"}}
{{/if}}
{{* Traiter l'envoi du formulaire *}}
{{#form on="add"}}
{{* :debug POST=$_POST *}}
{{* enregistrer l'écriture *}}
{{:assign var="credit_accounts" value=$_POST.credit_account|keys}}
{{:assign var="credit_account" value=$credit_accounts.0}}
{{: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"
assign="result"
id_year=$_POST.id_year
type="revenue"
date=$_POST.date
label=$_POST.designation
amount=$_POST.montant
debit=$debit_account
credit=$credit_account
}}
{{* :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
validate_schema="schema.json"
type="immo"
line=$line_id
duration=$_POST.duree|intval
}}
{{:redirect to="index.html?ok=1"}}
{{/form}}
{{* 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 <= $now && $end_date >= $now}}
{{:assign best_year=$id}}
{{/if}}
{{/years}}
{{* formulaire d'ajout d'immobilisation *}}
{{*
TODO
- ajouter projet et autres rubriques selon besoin
*}}
<form method="post" action="">
<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}}
{{:input type="number" name="duree" label="Durée d'amortissement" required=true default=1}}
{{: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&year=%d"|args:$best_year
default=$bank_account
}}
{{:input
type="list"
name="debit_account"
label="Compte d'immobilisation (20xx ou 21xx)"
required=true
target="!acc/charts/accounts/selector.php?key=code&year=%d"|args:$best_year
}}
</dl>
</fieldset>
<p class="submit">
{{:button type="submit" name="add" label="Ajouter" shape="right" class="main"}}
</p>
</form>
{{:admin_footer}}