Compare commits
4 commits
62692ef550
...
3169fe9268
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3169fe9268 | ||
|
|
78407592a1 | ||
|
|
c620ac769e | ||
|
|
d06dd424b3 |
11 changed files with 312 additions and 29 deletions
|
|
@ -82,7 +82,7 @@
|
||||||
et déduire leur montant de celui de l'immo
|
et déduire leur montant de celui de l'immo
|
||||||
*}}
|
*}}
|
||||||
{{#load
|
{{#load
|
||||||
type="immo_link"
|
type="credit_link"
|
||||||
where="$$.immo_doc_id = :immo_doc_id" :immo_doc_id = $immo_doc_id
|
where="$$.immo_doc_id = :immo_doc_id" :immo_doc_id = $immo_doc_id
|
||||||
}}
|
}}
|
||||||
{{if $amount == null}}
|
{{if $amount == null}}
|
||||||
|
|
@ -143,7 +143,7 @@
|
||||||
{{:linkbutton
|
{{:linkbutton
|
||||||
label="Détails"
|
label="Détails"
|
||||||
href="details_immo.html?immo_doc_id=%s"|args:$immo_doc_id
|
href="details_immo.html?immo_doc_id=%s"|args:$immo_doc_id
|
||||||
shape="search"
|
shape="eye"
|
||||||
}}
|
}}
|
||||||
{{* target="_dialog"*}}
|
{{* target="_dialog"*}}
|
||||||
{{*/if*}}
|
{{*/if*}}
|
||||||
|
|
|
||||||
|
|
@ -108,6 +108,11 @@
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{:assign duration=$_POST.duree|intval}}
|
{{:assign duration=$_POST.duree|intval}}
|
||||||
{{:assign status="managed"}}
|
{{:assign status="managed"}}
|
||||||
|
{{if $_POST.date_mes == null || $_POST.date_mes == $_POST.date_achat}}
|
||||||
|
{{:assign date_mes=null}}
|
||||||
|
{{else}}
|
||||||
|
{{:assign date_mes=$_POST.date_mes|date_short}}
|
||||||
|
{{/if}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{* enregistrer l'écriture *}}
|
{{* enregistrer l'écriture *}}
|
||||||
|
|
@ -141,7 +146,7 @@
|
||||||
type="immo"
|
type="immo"
|
||||||
line=$immo_line_id
|
line=$immo_line_id
|
||||||
duration=$duration
|
duration=$duration
|
||||||
date_mes=$date_debut
|
date_mes=$date_mes
|
||||||
status=$status
|
status=$status
|
||||||
}}
|
}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,11 @@
|
||||||
{{:assign status="ignored"}}
|
{{:assign status="ignored"}}
|
||||||
{{else}}
|
{{else}}
|
||||||
|
|
||||||
|
{{if $_POST.date_achat|parse_date > $ligne_immo.date_achat}}
|
||||||
|
{{:assign da=$ligne_immo.date_achat|date_short}}
|
||||||
|
{{:error message="Erreur : la date d'achat (%s) ne peut être postérieure à la date de l'écriture d'immobilisation (%s)"|args:$_POST.date_achat:$da}}
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
{{* vérifier que la date de mise en service est postérieure à la date d'acquisition *}}
|
{{* vérifier que la date de mise en service est postérieure à la date d'acquisition *}}
|
||||||
{{:assign d1=$_POST.date_achat|or:$ligne_immo.date_achat|parse_date}}
|
{{:assign d1=$_POST.date_achat|or:$ligne_immo.date_achat|parse_date}}
|
||||||
{{:assign d2=$_POST.date_mes|or:$d1|parse_date}}
|
{{:assign d2=$_POST.date_mes|or:$d1|parse_date}}
|
||||||
|
|
@ -126,7 +131,6 @@
|
||||||
date_achat=$date_achat
|
date_achat=$date_achat
|
||||||
date_mes=$date_mes
|
date_mes=$date_mes
|
||||||
status=$status
|
status=$status
|
||||||
assign_new_id="new_id"
|
|
||||||
}}
|
}}
|
||||||
|
|
||||||
{{if $_POST.amortir}}
|
{{if $_POST.amortir}}
|
||||||
|
|
@ -136,14 +140,13 @@
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{:redirect force="index.html?ok=1&msg=infos&type_immo=%s"|args:$type_immo}}
|
{{:redirect force="index.html?ok=1&msg=infos&type_immo=%s"|args:$type_immo}}
|
||||||
{{/form}}
|
{{/form}}
|
||||||
{{:form_errors}}
|
|
||||||
|
|
||||||
{{:admin_header title="Classer l'immobilisation" custom_css="./style.css" current="module_amortization"}}
|
{{:admin_header title="Classer l'immobilisation" custom_css="./style.css" current="module_amortization"}}
|
||||||
|
|
||||||
{{* barre de navigation *}}
|
{{* barre de navigation *}}
|
||||||
{{if ! $dialog}}
|
{{if ! $dialog}}
|
||||||
{{:include file="_nav.html" current="index" subcurrent="%s"|args:$_GET.type_immo subsubcurrent="parameter"}}
|
{{:include file="_nav.html" current="index" subcurrent="%s"|args:$_GET.type_immo subsubcurrent="parameter"}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
{{:form_errors}}
|
||||||
|
|
||||||
{{:assign choix_defaut=$_GET.type_immo}}
|
{{:assign choix_defaut=$_GET.type_immo}}
|
||||||
|
|
||||||
|
|
@ -174,7 +177,12 @@
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>Amortissement</legend>
|
<legend>Amortissement</legend>
|
||||||
<dl>
|
<dl>
|
||||||
{{:input id="amortir" type="checkbox" value=1 name="amortir" label="Amortir cette immobilisation sur une ou plusieurs années" checked="checked" help="Dé-cocher pour ne pas amortir"}}
|
{{if $info_immo.status == 'ignored'}}
|
||||||
|
{{:assign checked=null}}
|
||||||
|
{{else}}
|
||||||
|
{{:assign checked="checked"}}
|
||||||
|
{{/if}}
|
||||||
|
{{:input id="amortir" type="checkbox" value=1 name="amortir" label="Amortir cette immobilisation sur une ou plusieurs années" checked="%s"|args:$checked help="Dé-cocher pour ne pas amortir"}}
|
||||||
<div class="masquable">
|
<div class="masquable">
|
||||||
{{:input type="number" name="duree" label="Durée d'amortissement" required=true min=1}}
|
{{:input type="number" name="duree" label="Durée d'amortissement" required=true min=1}}
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -201,13 +209,20 @@
|
||||||
<script type="text/javascript" src="scripts.js"></script>
|
<script type="text/javascript" src="scripts.js"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
function changeVisibility(evt, idcheck = 'f_amortir_1', hiddenclass = 'masquable')
|
function changeVisibility(evt, idcheck = 'f_amortir_1', hiddenclass = 'masquable', id_help = 'help_f_amortir_1')
|
||||||
{
|
{
|
||||||
toggleVisibility(idcheck, document.querySelectorAll('.' + hiddenclass));
|
toggleVisibility(idcheck, document.querySelectorAll('.' + hiddenclass));
|
||||||
|
const help_elem = document.getElementById(id_help);
|
||||||
|
if (document.getElementById(idcheck).checked) {
|
||||||
|
help_elem.innerText = "Dé-cocher pour ne pas amortir";
|
||||||
|
} else {
|
||||||
|
help_elem.innerText = "Cocher pour amortir";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
document.getElementById('f_amortir_1').onclick = changeVisibility;
|
document.getElementById('f_amortir_1').onclick = changeVisibility;
|
||||||
|
changeVisibility(null);
|
||||||
})();
|
})();
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
line.label as line_label,
|
line.label as line_label,
|
||||||
trans.id as immo_trans_id,
|
trans.id as immo_trans_id,
|
||||||
trans.label as label,
|
trans.label as label,
|
||||||
trans.date,
|
trans.date as date_achat,
|
||||||
account.code as account_code,
|
account.code as account_code,
|
||||||
account.label as account_label
|
account.label as account_label
|
||||||
FROM acc_transactions_lines AS line
|
FROM acc_transactions_lines AS line
|
||||||
|
|
@ -34,7 +34,7 @@
|
||||||
{{/select}}
|
{{/select}}
|
||||||
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$ligne_immo.immo_trans_id}}
|
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$ligne_immo.immo_trans_id}}
|
||||||
|
|
||||||
{{:assign date_debut=$info_immo.date_mes|or:$info_immo.date_achat|or:$ligne_immo.date}}
|
{{:assign date_debut=$info_immo.date_mes|or:$info_immo.date_achat|or:$ligne_immo.date_achat}}
|
||||||
{{:assign label_immo=$info_immo.label|or:$ligne_immo.label}}
|
{{:assign label_immo=$info_immo.label|or:$ligne_immo.label}}
|
||||||
{{if $ligne_immo.line_label != null && $ligne_immo.line_label != $label_immo}}
|
{{if $ligne_immo.line_label != null && $ligne_immo.line_label != $label_immo}}
|
||||||
{{:assign label_immo=$label_immo|cat:" — "|cat:$ligne_immo.line_label}}
|
{{:assign label_immo=$label_immo|cat:" — "|cat:$ligne_immo.line_label}}
|
||||||
|
|
@ -52,7 +52,7 @@
|
||||||
et déduire leur montant de celui de l'immo
|
et déduire leur montant de celui de l'immo
|
||||||
*}}
|
*}}
|
||||||
{{:assign total_credits=0}}
|
{{:assign total_credits=0}}
|
||||||
{{#load type="immo_link" where="$$.immo_doc_id=:immo_doc_id" :immo_doc_id=$_GET.immo_doc_id|intval}}
|
{{#load type="credit_link" where="$$.immo_doc_id=:immo_doc_id" :immo_doc_id=$_GET.immo_doc_id|intval}}
|
||||||
{{if $amount == null}}
|
{{if $amount == null}}
|
||||||
{{#select credit FROM acc_transactions_lines WHERE id = :credit_line_id;
|
{{#select credit FROM acc_transactions_lines WHERE id = :credit_line_id;
|
||||||
:credit_line_id=$credit_line_id
|
:credit_line_id=$credit_line_id
|
||||||
|
|
@ -180,9 +180,8 @@
|
||||||
}}
|
}}
|
||||||
</p>
|
</p>
|
||||||
<p class="help">
|
<p class="help">
|
||||||
Il sera possible de choisir la date de sortie, d'indiquer
|
Il sera possible de choisir la date de sortie et d'indiquer
|
||||||
le montant de la cession le cas échéant et de modifier les
|
le montant de la cession le cas échéant.
|
||||||
comptes associés.
|
|
||||||
</p>
|
</p>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@
|
||||||
|
|
||||||
{{* montant de l'écriture de crédit déjà affecté *}}
|
{{* montant de l'écriture de crédit déjà affecté *}}
|
||||||
{{:assign montant_affecte=0}}
|
{{:assign montant_affecte=0}}
|
||||||
{{#load type="immo_link" assign="linked_immo."
|
{{#load type="credit_link" assign="linked_immo."
|
||||||
where="$$.credit_line_id = :credit_line_id"
|
where="$$.credit_line_id = :credit_line_id"
|
||||||
:credit_line_id = $_GET.credit_line_id|intval
|
:credit_line_id = $_GET.credit_line_id|intval
|
||||||
}}
|
}}
|
||||||
|
|
@ -114,7 +114,7 @@
|
||||||
{{* enregistrer la liaison des lignes d'immo *}}
|
{{* enregistrer la liaison des lignes d'immo *}}
|
||||||
{{:save
|
{{:save
|
||||||
key=""|uuid
|
key=""|uuid
|
||||||
type="immo_link"
|
type="credit_link"
|
||||||
immo_doc_id=$_GET.immo_doc_id|intval
|
immo_doc_id=$_GET.immo_doc_id|intval
|
||||||
credit_line_id=$_GET.credit_line_id|intval
|
credit_line_id=$_GET.credit_line_id|intval
|
||||||
amount=$saved_credit
|
amount=$saved_credit
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
"properties": {
|
"properties": {
|
||||||
"type": {
|
"type": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": ["amort_link", "immo_link"]
|
"enum": ["amort_link", "credit_link", "exit_link"]
|
||||||
},
|
},
|
||||||
"immo_doc_id" : {
|
"immo_doc_id" : {
|
||||||
"description": "identifiant du document d'immobilisation associé",
|
"description": "identifiant du document d'immobilisation associé",
|
||||||
|
|
@ -13,12 +13,17 @@
|
||||||
"exclusiveMinimum": 0
|
"exclusiveMinimum": 0
|
||||||
},
|
},
|
||||||
"amort_line_id" : {
|
"amort_line_id" : {
|
||||||
"description": "numéro de ligne d'amortissement associée à l'immobilisation",
|
"description": "ligne d'amortissement associée à l'immobilisation",
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"exclusiveMinimum": 0
|
"exclusiveMinimum": 0
|
||||||
},
|
},
|
||||||
"credit_line_id": {
|
"credit_line_id": {
|
||||||
"description": "numéro de ligne au crédit du compte de l'immobilisation",
|
"description": "ligne au crédit du compte de l'immobilisation",
|
||||||
|
"type": "integer",
|
||||||
|
"exclusiveMinimum": 0
|
||||||
|
},
|
||||||
|
"exit_line_id": {
|
||||||
|
"description": "ligne d'amortissement de sortie du bilan de l'immobilisation",
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"exclusiveMinimum": 0
|
"exclusiveMinimum": 0
|
||||||
},
|
},
|
||||||
|
|
@ -31,6 +36,9 @@
|
||||||
"if": {"properties": {"type": {"const": "amort_link"}}, "required": ["type"]},
|
"if": {"properties": {"type": {"const": "amort_link"}}, "required": ["type"]},
|
||||||
"then": {"required": ["amort_line_id"]},
|
"then": {"required": ["amort_line_id"]},
|
||||||
"else":
|
"else":
|
||||||
"if": {"properties": {"type": {"const": "immo_link"}}, "required": ["type"]},
|
"if": {"properties": {"type": {"const": "credit_link"}}, "required": ["type"]},
|
||||||
"then": {"required": ["credit_line_id"]},
|
"then": {"required": ["credit_line_id"]},
|
||||||
|
"else":
|
||||||
|
"if": {"properties": {"type": {"const": "exit_link"}}, "required": ["type"]},
|
||||||
|
"then": {"required": ["exit_line_id"]},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,6 @@
|
||||||
|
|
||||||
{{*
|
{{*
|
||||||
lister les écritures au crédit du compte de l'immobilisation
|
lister les écritures au crédit du compte de l'immobilisation
|
||||||
variante : utiliser une jointure ; pas forcément plus efficace
|
|
||||||
*}}
|
*}}
|
||||||
{{#select
|
{{#select
|
||||||
line.id as credit_line_id,
|
line.id as credit_line_id,
|
||||||
|
|
@ -57,14 +56,12 @@
|
||||||
INNER JOIN acc_accounts AS account ON account.id = line.id_account
|
INNER JOIN acc_accounts AS account ON account.id = line.id_account
|
||||||
INNER JOIN acc_years AS y ON y.id = trans.id_year
|
INNER JOIN acc_years AS y ON y.id = trans.id_year
|
||||||
WHERE account.code = :account_code AND credit > 0
|
WHERE account.code = :account_code AND credit > 0
|
||||||
AND credit_trans_id NOT IN (
|
AND credit_line_id NOT IN (
|
||||||
SELECT
|
SELECT json_extract(link.document, '$.credit_line_id') AS credit_line_id FROM !table as link
|
||||||
CASE WHEN id_transaction = credit_trans_id THEN id_transaction
|
WHERE json_extract(link.document, '$.type') == "credit_link")
|
||||||
ELSE id_related
|
|
||||||
END AS other_id
|
|
||||||
FROM acc_transactions_links WHERE other_id = credit_trans_id)
|
|
||||||
ORDER BY trans.date, trans.label;
|
ORDER BY trans.date, trans.label;
|
||||||
:account_code = $ligne_immo.account_code
|
:account_code = $ligne_immo.account_code
|
||||||
|
!table =$module.table
|
||||||
assign="other_immos."
|
assign="other_immos."
|
||||||
}}
|
}}
|
||||||
{{/select}}
|
{{/select}}
|
||||||
|
|
|
||||||
255
modify_infos.html
Normal file
255
modify_infos.html
Normal file
|
|
@ -0,0 +1,255 @@
|
||||||
|
{{* -*- brindille -*- *}}
|
||||||
|
{{:admin_header title="Modifier l'immobilisation" custom_css="./style.css" current="module_amortization"}}
|
||||||
|
|
||||||
|
{{*
|
||||||
|
@param immo_line_id
|
||||||
|
@param immo_doc_id
|
||||||
|
¿ @param type_immo : managed, amortized, archived, other ?
|
||||||
|
|
||||||
|
TODO :
|
||||||
|
- ¿ faire une ligne modifiable pour chaque avoir avec un bouton de suppression ?
|
||||||
|
- séparer les cas des immo simples et complexes (BOI)
|
||||||
|
par exemple pour la durée d'amort par défaut {{:input ...}}
|
||||||
|
- prise en charge immo => param = immo_line_id
|
||||||
|
- modif param immo => param = immo_doc_id
|
||||||
|
*}}
|
||||||
|
|
||||||
|
{{* données de l'immobilisation *}}
|
||||||
|
{{#load id=$_GET.immo_doc_id|intval assign="info_immo"}}
|
||||||
|
{{else}}
|
||||||
|
{{:error message="Immobilisation non trouvée"}}
|
||||||
|
{{/load}}
|
||||||
|
{{#select
|
||||||
|
trans.id as immo_trans_id,
|
||||||
|
trans.label as trans_label,
|
||||||
|
trans.date as date_achat,
|
||||||
|
line.debit as montant,
|
||||||
|
line.label as line_label,
|
||||||
|
acc.code,
|
||||||
|
acc.label as account_label
|
||||||
|
FROM acc_transactions_lines AS line
|
||||||
|
INNER join acc_transactions AS trans ON line.id_transaction = trans.id
|
||||||
|
INNER JOIN acc_accounts AS acc ON line.id_account = acc.id
|
||||||
|
WHERE line.id = :line_id;
|
||||||
|
:line_id = $info_immo.line
|
||||||
|
assign="ligne_immo"
|
||||||
|
}}
|
||||||
|
{{else}}
|
||||||
|
{{:error message="Immobilisation non trouvée"}}
|
||||||
|
{{/select}}
|
||||||
|
{{:assign montant_immo=$info_immo.amount|or:$ligne_immo.montant}}
|
||||||
|
|
||||||
|
{{:assign immo_label=$info_immo.label|or:$ligne_immo.trans_label}}
|
||||||
|
{{if $ligne_immo.line_label != null && $ligne_immo.line_label != $immo_label}}
|
||||||
|
{{:assign immo_label=$immo_label|cat:" — "|cat:$ligne_immo.line_label}}
|
||||||
|
{{/if}}
|
||||||
|
{{*
|
||||||
|
chercher des écritures liées à l'immo courante au crédit du même compte
|
||||||
|
et déduire leur montant de celui de l'immo
|
||||||
|
*}}
|
||||||
|
{{:assign linked_immos=null}}
|
||||||
|
{{:assign total_credits=0}}
|
||||||
|
{{#load type="credit_link" where="$$.immo_doc_id=:immo_doc_id" :immo_doc_id=$_GET.immo_doc_id|intval}}
|
||||||
|
{{#select
|
||||||
|
line.credit,
|
||||||
|
trans.id
|
||||||
|
FROM acc_transactions_lines AS line
|
||||||
|
INNER JOIN acc_transactions AS trans ON line.id_transaction = trans.id
|
||||||
|
WHERE line.id = :credit_line_id;
|
||||||
|
:credit_line_id=$credit_line_id
|
||||||
|
}}
|
||||||
|
{{:assign credit=$credit}}
|
||||||
|
{{:assign credit_trans_id=$id}}
|
||||||
|
{{/select}}
|
||||||
|
{{:assign var="linked_immos." value=$credit_trans_id}}
|
||||||
|
{{if $amount == null}}
|
||||||
|
{{:assign total_credits="%d+%d"|math:$total_credits:$credit}}
|
||||||
|
{{else}}
|
||||||
|
{{:assign total_credits="%d+%d"|math:$total_credits:$amount}}
|
||||||
|
{{/if}}
|
||||||
|
{{/load}}
|
||||||
|
{{:assign solde="%d-%d"|math:$montant_immo:$total_credits}}
|
||||||
|
|
||||||
|
{{:assign autres_amount=0}}
|
||||||
|
{{#load
|
||||||
|
type="immo"
|
||||||
|
where="$$.line = :line_id AND id != :doc_id"
|
||||||
|
:line_id = $info_immo.line
|
||||||
|
:doc_id = $info_immo.id
|
||||||
|
}}
|
||||||
|
{{:assign autres_amount="%d+%d"|math:$autres_amount:$amount}}
|
||||||
|
{{/load}}
|
||||||
|
{{:assign max_disponible="%d-%d"|math:$ligne_immo.montant:$autres_amount}}
|
||||||
|
|
||||||
|
{{* traiter la saisie *}}
|
||||||
|
{{#form on="save"}}
|
||||||
|
{{if ! $_POST.amortir}}
|
||||||
|
{{* ne pas amortir *}}
|
||||||
|
{{:assign duration=0}}
|
||||||
|
{{:assign libelle=null}}
|
||||||
|
{{:assign montant=null}}
|
||||||
|
{{:assign date_achat=null}}
|
||||||
|
{{:assign date_mes=null}}
|
||||||
|
{{:assign status="ignored"}}
|
||||||
|
{{else}}
|
||||||
|
{{if $_POST.date_achat == null || $_POST.date_achat|parse_date == $ligne_immo.date_achat}}
|
||||||
|
{{:assign date_achat=null}}
|
||||||
|
{{elseif $_POST.date_achat|parse_date == $info_immo.date_achat}}
|
||||||
|
{{:assign date_achat=$info_immo.date_achat}}
|
||||||
|
{{else}}
|
||||||
|
{{:assign date_achat=$_POST.date_achat|parse_date}}
|
||||||
|
{{/if}}
|
||||||
|
{{if $_POST.date_achat|parse_date > $ligne_immo.date_achat}}
|
||||||
|
{{:assign da=$ligne_immo.date_achat|date_short}}
|
||||||
|
{{:error message="Erreur : la date d'achat (%s) ne peut être postérieure à la date de l'écriture d'immobilisation (%s)"|args:$_POST.date_achat:$da}}
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{if $_POST.date_mes == null || $_POST.date_mes|parse_date == $ligne_immo.date_achat}}
|
||||||
|
{{:assign date_mes=null}}
|
||||||
|
{{elseif $_POST.date_mes|parse_date == $info_immo.date_achat}}
|
||||||
|
{{:assign date_mes=null}}
|
||||||
|
{{else}}
|
||||||
|
{{:assign date_mes=$_POST.date_mes|parse_date}}
|
||||||
|
{{:assign date_achat_comp=$ligne_immo.date_achat}}
|
||||||
|
{{if $date_achat != null}}
|
||||||
|
{{:assign date_achat_comp=$date_achat}}
|
||||||
|
{{/if}}
|
||||||
|
{{if $date_mes < $date_achat_comp}}
|
||||||
|
{{:assign da=$date_achat_comp|date_short}}
|
||||||
|
{{:error message="Erreur : la date de mise en service (%s) ne peut être antérieure à la date d'acquisition (%s)"|args:$_POST.date_mes:$da}}
|
||||||
|
{{/if}}
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{:assign duration=$_POST.duree|intval}}
|
||||||
|
{{if $duration <= 0}}
|
||||||
|
{{:error message="Erreur : la durée d'amortissement doit être strictement positive"}}
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{if $_POST.libelle != $ligne_immo.line_label && $_POST.libelle != $ligne_immo.trans_label}}
|
||||||
|
{{:assign libelle=$_POST.libelle}}
|
||||||
|
{{else}}
|
||||||
|
{{:assign libelle=null}}
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{:assign montant=null}}
|
||||||
|
{{if $_POST.montant == null || $_POST.montant|money_int == 0 || $_POST.montant|money_int == $info_immo.amount}}
|
||||||
|
{{:assign montant=$info_immo.amount}}
|
||||||
|
{{else}}
|
||||||
|
{{:assign montant=$_POST.montant|money_int}}
|
||||||
|
{{if $montant < 0 || $montant > $max_disponible}}
|
||||||
|
{{:assign montant_aff="%f"|math:$montant|money_currency:false}}
|
||||||
|
{{:assign max_aff="%f"|math:$max_disponible|money_currency:false}}
|
||||||
|
{{:error message="Le montant (%s) doit être positif et ne peut être supérieur à %s"|args:$montant_aff:$max_aff}}
|
||||||
|
{{/if}}
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{:assign status="managed"}}
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{* enregistrer les infos de l'immobilisation *}}
|
||||||
|
{{:save
|
||||||
|
key=$info_immo.key
|
||||||
|
validate_schema="schema.json"
|
||||||
|
type="immo"
|
||||||
|
line=$info_immo.line
|
||||||
|
duration=$duration
|
||||||
|
label=$libelle
|
||||||
|
amount=$montant
|
||||||
|
date_achat=$date_achat
|
||||||
|
date_mes=$date_mes
|
||||||
|
status=$status
|
||||||
|
assign_new_id="new_id"
|
||||||
|
}}
|
||||||
|
|
||||||
|
{{if $_POST.amortir}}
|
||||||
|
{{:assign type_immo="managed"}}
|
||||||
|
{{else}}
|
||||||
|
{{:assign type_immo="other"}}
|
||||||
|
{{/if}}
|
||||||
|
{{:redirect force="index.html?ok=1&msg=infos&type_immo=%s"|args:$type_immo}}
|
||||||
|
{{/form}}
|
||||||
|
{{:form_errors}}
|
||||||
|
|
||||||
|
{{* barre de navigation *}}
|
||||||
|
{{if ! $dialog}}
|
||||||
|
{{:include file="_nav.html" current="index" subcurrent="%s"|args:$_GET.type_immo subsubcurrent="parameter"}}
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{:assign choix_defaut=$_GET.type_immo}}
|
||||||
|
|
||||||
|
{{*
|
||||||
|
modifier la date de mise en service, les écritures associées ou la durée d'amortissement
|
||||||
|
*}}
|
||||||
|
|
||||||
|
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$ligne_immo.immo_trans_id}}
|
||||||
|
<h3 class="ruler">Paramètres de l'immobilisation</h3>
|
||||||
|
<div class="informations">
|
||||||
|
<dl class="describe">
|
||||||
|
<dt>Immobilisation</dt>
|
||||||
|
<dd><span class="num"><a href="{{$trans_url}}">#{{$ligne_immo.immo_trans_id}}</a></span> {{$immo_label}}</dd>
|
||||||
|
<dt>Compte d'immobilisation</dt>
|
||||||
|
<dd>{{$ligne_immo.code}} — {{$ligne_immo.account_label}}
|
||||||
|
<dt>Montant</dt>
|
||||||
|
<dd class="money strong">{{"%f"|math:$montant_immo|money_currency_html:false|raw}}</dd>
|
||||||
|
{{if $total_credits > 0}}
|
||||||
|
<dt>Montant des avoirs</dt>
|
||||||
|
<dd class="money">{{"%f"|math:$total_credits|money_currency_html:false|raw}}</dd>
|
||||||
|
<dt>Montant à amortir</dt>
|
||||||
|
<dd class="money strong">{{"%f"|math:$solde|money_currency_html:false|raw}}</dd>
|
||||||
|
{{/if}}
|
||||||
|
<dt>Date de l'écriture d'immobilisation</dt>
|
||||||
|
<dd>{{$ligne_immo.date_achat|date_short}}</dd>
|
||||||
|
</dl>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<form method="post" action="">
|
||||||
|
<fieldset>
|
||||||
|
<legend>Paramètres de l'amortissement</legend>
|
||||||
|
<dl>
|
||||||
|
{{:input id="amortir" type="checkbox" value=1 name="amortir" label="Amortir cette immobilisation sur une ou plusieurs années" checked="checked" help="Dé-cocher pour ne pas amortir"}}
|
||||||
|
<div class="masquable">
|
||||||
|
{{:input type="number" name="duree" label="Durée d'amortissement" min=1 default=$info_immo.duration}}
|
||||||
|
{{:input type="text" name="libelle" label="Libellé" default=$info_immo.label}}
|
||||||
|
{{if $info_immo.amount != null}}
|
||||||
|
{{:assign max_aff="%f"|math:$max_disponible|money_currency:false}}
|
||||||
|
{{:input type="money" name="montant" label="Montant de l'immobilisation" default=$montant_immo help="Montant maximum = %s"|args:$max_aff}}
|
||||||
|
{{/if}}
|
||||||
|
{{:input type="date" name="date_achat" label="Date d'acquisition" default=$info_immo.date_achat}}
|
||||||
|
{{:input type="date" name="date_mes" label="Date de mise en service" default=$info_immo.date_mes}}
|
||||||
|
{{if $linked_immos}}
|
||||||
|
<dt><label>Écritures d'avoir liées à l'immobilisation</label></dt>
|
||||||
|
<dd>
|
||||||
|
<span class="input-list avoirs">
|
||||||
|
<label for="credit_id">Écritures :</label>
|
||||||
|
{{#foreach from=$linked_immos item="id"}}
|
||||||
|
<span class="label">
|
||||||
|
{{:input type="hidden" name="credit_id" value=$id}}{{$id}}
|
||||||
|
<button data-icon="✘" type="button" class=" icn-btn" title="Cliquer pour supprimer la liaison"></button>
|
||||||
|
</span>
|
||||||
|
{{/foreach}}
|
||||||
|
</span>
|
||||||
|
</dd>
|
||||||
|
{{/if}}
|
||||||
|
</div>
|
||||||
|
</dl>
|
||||||
|
</fieldset>
|
||||||
|
<p class="submit">
|
||||||
|
{{:button type="submit" name="save" label="Enregistrer" shape="right" class="main"}}
|
||||||
|
</p>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
{{:admin_footer}}
|
||||||
|
|
||||||
|
<script type="text/javascript" src="scripts.js"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
|
||||||
|
function changeVisibility(evt, idcheck = 'f_amortir_1', hiddenclass = 'masquable')
|
||||||
|
{
|
||||||
|
toggleVisibility(idcheck, document.querySelectorAll('.' + hiddenclass));
|
||||||
|
}
|
||||||
|
|
||||||
|
(function () {
|
||||||
|
document.getElementById('f_amortir_1').onclick = changeVisibility;
|
||||||
|
})();
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
@ -57,7 +57,7 @@
|
||||||
*}}
|
*}}
|
||||||
{{:assign total_credits=0}}
|
{{:assign total_credits=0}}
|
||||||
{{#load
|
{{#load
|
||||||
type="immo_link"
|
type="credit_link"
|
||||||
where="$$.immo_doc_id = :immo_doc_id" :immo_doc_id = $_GET.immo_doc_id|intval
|
where="$$.immo_doc_id = :immo_doc_id" :immo_doc_id = $_GET.immo_doc_id|intval
|
||||||
}}
|
}}
|
||||||
{{if $amount == null}}
|
{{if $amount == null}}
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ function setDateEnd(id_exercices, id_date, id_years) {
|
||||||
|
|
||||||
// renvoyer la valeur numérique d'un montant formaté en €
|
// renvoyer la valeur numérique d'un montant formaté en €
|
||||||
function getNumber(text) {
|
function getNumber(text) {
|
||||||
return Number(text.replace(/[^0-9,]/g, '').replace(/,/, '.'));
|
return Number(text.replace(/[^0-9,]/g, '').replace(/,/, '.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// calculer le montant d'un amortissement
|
// calculer le montant d'un amortissement
|
||||||
|
|
|
||||||
|
|
@ -94,3 +94,7 @@ html.dialog.dark main {
|
||||||
html.dark .block.alert {
|
html.dark .block.alert {
|
||||||
background-color : rgba(87, 206, 235, 0.5);
|
background-color : rgba(87, 206, 235, 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
span.input-list.avoirs label {
|
||||||
|
padding : 0.4rem 0.6rem;
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue