Adaptation sortie bilan aux nouveaux documents
This commit is contained in:
parent
c427e8900f
commit
bb8d27b616
3 changed files with 138 additions and 160 deletions
|
|
@ -2,11 +2,15 @@
|
|||
|
||||
{{*
|
||||
Sortir une immobilisation du bilan
|
||||
@param immo_line_id : id de la ligne d'immobilisation
|
||||
@param immo_doc_id : id du doc associé à l'immo
|
||||
*}}
|
||||
|
||||
{{* Infos de l'immobilisation *}}
|
||||
{{#load id=$_GET.immo_doc_id|intval assign="info_immo"}}
|
||||
{{else}}
|
||||
{{:error message="Immobilisation non trouvée"}}
|
||||
{{/load}}
|
||||
|
||||
{{#select
|
||||
line.debit as montant,
|
||||
trans.id AS trans_id,
|
||||
|
|
@ -17,30 +21,17 @@
|
|||
INNER JOIN acc_transactions AS trans ON line.id_transaction = trans.id
|
||||
INNER JOIN acc_accounts AS account ON line.id_account = account.id
|
||||
WHERE line.id = :line_id;
|
||||
:line_id = $_GET.immo_line_id|intval
|
||||
:line_id = $info_immo.line
|
||||
assign="ligne_immo"
|
||||
}}
|
||||
{{else}}
|
||||
{{:error message="Immobilisation non trouvée"}}
|
||||
{{/select}}
|
||||
|
||||
{{:assign date_debut=$ligne_immo.date_achat}}
|
||||
{{:assign ts_mes=$ligne_immo.date_achat|strtotime}}
|
||||
|
||||
{{* TODO : traiter le cas des immos sans doc *}}
|
||||
{{#load id=$_GET.immo_doc_id|intval assign="info_immo"}}
|
||||
{{:assign ts_mes=$date_mes|strtotime}}
|
||||
{{if $date_mes != null}}
|
||||
{{:assign date_debut=$date_mes}}
|
||||
{{/if}}
|
||||
{{:assign duree_amort=$duration}}
|
||||
{{if $amount != null}}
|
||||
{{:assign var="ligne_immo.montant" value=$amount}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{* TODO *}}
|
||||
{{:error message="Immobilisation non trouvée"}}
|
||||
{{/load}}
|
||||
{{:assign date_debut=$info_immo.date_mes|or:$info_immo.date_achat|or:$ligne_immo.date_achat}}
|
||||
{{if $info_immo.amount != null}}
|
||||
{{:assign var="ligne_immo.montant" value=$info_immo.amount}}
|
||||
{{/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
|
||||
|
|
@ -62,7 +53,10 @@
|
|||
{{:assign total_credits="%d+%d"|math:$total_credits:$amount}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{* pas de doc => voir liaison écritures *}}
|
||||
{{*
|
||||
TODO : à garder ?
|
||||
pas de doc => voir liaison écritures
|
||||
*}}
|
||||
{{#select
|
||||
CASE links.id_related = :immo_trans_id
|
||||
WHEN true THEN links.id_transaction
|
||||
|
|
@ -89,26 +83,17 @@
|
|||
:immo_doc_id = $_GET.immo_doc_id|intval
|
||||
}}
|
||||
{{#select
|
||||
line.id as amort_line_id,
|
||||
line.credit,
|
||||
line.label as amort_line_label,
|
||||
trans.id as amort_trans_id,
|
||||
trans.label as amort_trans_label,
|
||||
trans.date as amort_date,
|
||||
trans.id_year as amort_year,
|
||||
account.id as account_id,
|
||||
account.code as account_code,
|
||||
account.label as account_label
|
||||
trans.date as amort_date
|
||||
FROM acc_transactions_lines AS line
|
||||
INNER JOIN acc_transactions AS trans ON line.id_transaction = trans.id
|
||||
INNER join acc_accounts AS account on line.id_account = account.id
|
||||
WHERE line.id = :amort_line_id
|
||||
;
|
||||
:amort_line_id = $amort_line_id
|
||||
assign="amort_line"
|
||||
}}
|
||||
{{:assign var="amort_line.amort_amount" value=$amount|or:$credit}}
|
||||
{{:assign total_amort="%d+%d"|math:$total_amort:$amort_line.amort_amount}}
|
||||
{{:assign amort_amount=$amount|or:$credit}}
|
||||
{{:assign total_amort="%d+%d"|math:$total_amort:$amort_amount}}
|
||||
{{:assign var="linked_amort.%s_%d"|args:$amort_date:$id value=$amort_line}}
|
||||
{{/select}}
|
||||
{{/load}}
|
||||
|
|
@ -166,39 +151,12 @@
|
|||
{{:error message="Vous devez renseigner la date de sortie"}}
|
||||
{{/if}}
|
||||
|
||||
{{* vérifier la validité de la date de mise en service *}}
|
||||
{{if $_POST.date_mes != null}}
|
||||
{{:assign ts_mes=$_POST.date_mes|parse_date|strtotime}}
|
||||
{{if $ts_mes < $ligne_immo.date_achat|strtotime || $ts_mes > $first_amort_date|strtotime}}
|
||||
{{:assign immo_date=$ligne_immo.date_achat|date_short}}
|
||||
{{:assign amort_date=$first_amort_date|date_short}}
|
||||
{{:error message="La date de mise en service doit être postérieure à la date d'acquisition de l'immobilisation (%s) et antérieure à la date du premier amortissement (%s)"|args:$immo_date:$amort_date}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
{{* vérifier la validité de la durée d'immobilisation *}}
|
||||
{{if $valeur_nette > 0}}
|
||||
{{if $info_immo.duration == null}}
|
||||
{{if $_POST.duree == null}}
|
||||
{{:error message="Vous devez renseigner la durée de l'immobilisation"}}
|
||||
{{elseif $_POST.duree < $amort_number}}
|
||||
{{:error message="La durée de l'amortissement ne peut être inférieure au nombre d'écritures d'amortissement (%d)"|args:$amort_number}}
|
||||
{{else}}
|
||||
{{:assign duree_amort=$_POST.duree}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
{{* vérifier la validité de la date de sortie *}}
|
||||
{{if $info_immo.date_mes != null}}
|
||||
{{if $_POST.date_sortie|parse_date < $info_immo.date_mes}}
|
||||
{{:assign immo_date=$info_immo.date_mes|date_short}}
|
||||
{{:error message="La date de sortie doit être postérieure à la date de mise en service de l'immobilisation (%s)"|args:$immo_date}}
|
||||
{{/if}}
|
||||
{{elseif $_POST.date_mes != null}}
|
||||
{{if $_POST.date_sortie|parse_date < $_POST.date_mes|parse_date}}
|
||||
{{:error message="La date de sortie doit être postérieure à la date de mise en service de l'immobilisation (%s)"|args:$_POST.date_mes}}
|
||||
{{/if}}
|
||||
{{elseif $_POST.date_sortie|parse_date < $ligne_immo.date_achat}}
|
||||
{{:assign immo_date=$ligne_immo.date_achat|date_short}}
|
||||
{{:error message="La date de sortie doit être postérieure à la date d'acquisition de l'immobilisation (%s)"|args:$immo_date}}
|
||||
|
|
@ -232,17 +190,15 @@
|
|||
{{else}}
|
||||
{{:assign amort_ok=false}}
|
||||
{{/if}}
|
||||
|
||||
{{if ! $amort_ok}}
|
||||
{{:error message="Vous devez d'abord enregistrer les amortissements des exercices précédents"}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
{{:redirect to="compute_exit_data.html?immo_line_id=%s&amort_amount=%s&year=%s&date_mes=%s&date_debut=%s&exit_date=%s&duree_amort=%s"|args:$_GET.immo_line_id:$total_amort:$selected_year:$ts_mes:$ts_debut:$ts_exit:$duree_amort}}
|
||||
{{:redirect to="compute_exit_data.html?immo_doc_id=%s&amort_amount=%s&year=%s&date_debut=%s&exit_date=%s"|args:$_GET.immo_doc_id:$total_amort:$selected_year:$ts_debut:$ts_exit}}
|
||||
{{/form}}
|
||||
|
||||
{{:admin_header title="Sortie de bilan" custom_css="./style.css" current="module_amortization"}}
|
||||
{{* barre de navigation *}}
|
||||
{{if ! $dialog}}
|
||||
{{:include file="_nav.html" current="index" subcurrent="%s"|args:$_GET.type_immo subsubcurrent="balance_exit"}}
|
||||
{{/if}}
|
||||
|
|
@ -278,16 +234,6 @@
|
|||
</dl>
|
||||
</div>
|
||||
|
||||
{{if $info_immo == null && $total_amort == 0 }}
|
||||
<fieldset>
|
||||
<legend>Autres informations</legend>
|
||||
<dl>
|
||||
{{:input type="date" name="date_mes" label="Date de mise en service" help="C'est la date de première utilisation ; à renseigner uniquement si différente de la date d'acquisition"}}
|
||||
{{:input type="number" name="duree" label="Durée d'amortissement" required=true min=1 help="La durée est nécessaire pour calculer l'amortissement complémentaire"}}
|
||||
</dl>
|
||||
</fieldset>
|
||||
{{/if}}
|
||||
|
||||
<fieldset>
|
||||
<legend>Informations de sortie</legend>
|
||||
<dl>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue