Mutualisation infos immo, écritures crédit, amortissements liés et libres
This commit is contained in:
parent
91795c69a8
commit
780eb206ce
21 changed files with 410 additions and 879 deletions
|
|
@ -93,9 +93,7 @@
|
|||
{{/select}}
|
||||
{{/load}}
|
||||
|
||||
{{* 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
|
||||
*}}
|
||||
{{* déduire le montant des écritures liées à l'immo courante au crédit du même compte *}}
|
||||
{{:assign credit_immo=null}}
|
||||
{{:assign total_credits=0}}
|
||||
{{#load
|
||||
|
|
|
|||
39
_get_amort_lines.html
Normal file
39
_get_amort_lines.html
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
{{* -*- brindille -*- *}}
|
||||
|
||||
{{*
|
||||
lister les lignes d'amortissement liées à la ligne d'immobilisation
|
||||
@param immo_doc_id : id du doc associé à l'immobilisation
|
||||
@result linked_amort : lignes d'amortissement liées à la ligne d'immobilisation
|
||||
@result total_amort : montant total des amortissements de l'immobilisation
|
||||
*}}
|
||||
|
||||
{{:assign total_amort=0}}
|
||||
{{#load type="amort_link"
|
||||
where="$$.immo_doc_id = :immo_doc_id"
|
||||
:immo_doc_id = $immo_doc_id|intval
|
||||
assign="amort_info"
|
||||
}}
|
||||
{{#select
|
||||
line.id as line_id,
|
||||
line.credit as amount,
|
||||
line.label as line_label,
|
||||
trans.id as trans_id,
|
||||
trans.label as trans_label,
|
||||
trans.date as date,
|
||||
trans.id_year as year,
|
||||
account.id as account_id,
|
||||
account.code as account_code,
|
||||
account.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 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.amount" value=$amort_info.amount|or:$amort_line.amount}}
|
||||
{{:assign var="linked_amort.%s_%d"|args:$amort_line.date:$amort_info.id value=$amort_line}}
|
||||
{{:assign total_amort="%d+%d"|math:$total_amort:$amort_line.amount}}
|
||||
{{/select}}
|
||||
{{/load}}
|
||||
31
_get_credit_lines.html
Normal file
31
_get_credit_lines.html
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
{{* -*- brindille -*- *}}
|
||||
|
||||
{{*
|
||||
chercher des écritures liées à l'immo paramètre au crédit du même compte
|
||||
@param immo_doc_id : id du doc associé à l'immobilisation
|
||||
@param linked_immos : liste des écritures liées
|
||||
@param total_credits : montant total des écritures
|
||||
*}}
|
||||
{{:assign linked_immos=null}}
|
||||
{{:assign total_credits=0}}
|
||||
{{#load type="credit_link" where="$$.immo_doc_id=:immo_doc_id" :immo_doc_id=$immo_doc_id|intval}}
|
||||
{{#select
|
||||
line.credit,
|
||||
line.id as line_id,
|
||||
trans.id as trans_id,
|
||||
trans.label,
|
||||
trans.date
|
||||
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 var="linked_immos." doc=$id trans_id=$trans_id credit_line_id=$line_id label=$label amount=$credit date=$date}}
|
||||
{{/select}}
|
||||
{{if $amount == null}}
|
||||
{{:assign total_credits="%d+%d"|math:$total_credits:$credit}}
|
||||
{{else}}
|
||||
{{:assign total_credits="%d+%d"|math:$total_credits:$amount}}
|
||||
{{/if}}
|
||||
{{/load}}
|
||||
46
_get_free_amort.html
Normal file
46
_get_free_amort.html
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
{{* -*- brindille -*- *}}
|
||||
|
||||
{{*
|
||||
lister les amortissement non rattachés à une immo
|
||||
@param filter_condition
|
||||
*}}
|
||||
{{#select
|
||||
line.id as line_id,
|
||||
line.id_transaction as trans_id,
|
||||
line.credit as amount,
|
||||
line.label as line_label,
|
||||
trans.date as trans_date,
|
||||
trans.label as trans_label,
|
||||
trans.id_year as year,
|
||||
account.id as account_id,
|
||||
account.code as account_code,
|
||||
account.label as account_label
|
||||
FROM acc_transactions_lines AS line
|
||||
INNER JOIN acc_accounts AS account ON account.id = line.id_account
|
||||
INNER JOIN acc_transactions AS trans ON trans.id = line.id_transaction
|
||||
WHERE account.code LIKE "28%" AND credit > 0 AND (NOT trans.status & 16) AND !filter_condition
|
||||
ORDER BY trans.date, trans.label;
|
||||
!filter_condition=$filter_condition
|
||||
assign="amort_line"
|
||||
}}
|
||||
{{* voir s'il existe des lignes d'immo liées à cette ligne d'amortissement *}}
|
||||
{{:assign amort_amount=0}}
|
||||
{{:assign keep_amort=true}}
|
||||
{{#load type="amort_link"
|
||||
where="$$.amort_line_id = :amort_line_id"
|
||||
:amort_line_id=$amort_line.line_id|intval
|
||||
assign="amort_link"
|
||||
}}
|
||||
{{if $amort_link.amount == null || $amort_link.amount == 0}}
|
||||
{{:assign amort_amount=$amort_line.amount}}
|
||||
{{:assign keep_amort=false}}
|
||||
{{else}}
|
||||
{{:assign amort_amount="%d+%d"|math:$amort_amount:$amort_link.amount}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{* pas de ligne d'immo liée à cette ligne d'amort => garder cette ligne d'amortissement *}}
|
||||
{{/load}}
|
||||
{{if $keep_amort && $amort_amount < $amort_line.amount}}
|
||||
{{:assign var="free_amort_lines." value=$amort_line}}
|
||||
{{/if}}
|
||||
{{/select}}
|
||||
39
_get_immo_data.html
Normal file
39
_get_immo_data.html
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
{{* -*- brindille -*- *}}
|
||||
|
||||
{{*
|
||||
Récupérer les infos d'une immobilisation
|
||||
@param immo_doc_id : id du document associé à l'immobilisation
|
||||
@result info_immo : infos du document associé
|
||||
@result ligne_immo : données de la base
|
||||
@result message non null si une erreur s'est produite
|
||||
*}}
|
||||
|
||||
{{#load id=$immo_doc_id|intval assign="info_immo"}}
|
||||
{{else}}
|
||||
{{:assign error=true}}
|
||||
{{:assign message="Immobilisation non trouvée"}}
|
||||
{{/load}}
|
||||
|
||||
{{if ! $error}}
|
||||
{{#select
|
||||
line.id as line_id,
|
||||
line.debit as amount,
|
||||
line.label as line_label,
|
||||
line.id_project as id_project,
|
||||
trans.id as trans_id,
|
||||
trans.label as trans_label,
|
||||
trans.date as date_achat,
|
||||
account.id as account_id,
|
||||
account.code as account_code,
|
||||
account.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 account ON line.id_account = account.id
|
||||
WHERE line.id = :line_id;
|
||||
:line_id = $info_immo.line
|
||||
assign="ligne_immo"
|
||||
}}
|
||||
{{else}}
|
||||
{{:assign message="Immobilisation non trouvée"}}
|
||||
{{/select}}
|
||||
{{/if}}
|
||||
|
|
@ -77,10 +77,7 @@
|
|||
{{:assign label_immo=$label_immo|cat:" — "|cat:$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
|
||||
*}}
|
||||
{{* déduire le montant des écritures liées à l'immo courante au crédit du même compte *}}
|
||||
{{#load
|
||||
type="credit_link"
|
||||
where="$$.immo_doc_id = :immo_doc_id" :immo_doc_id = $immo_doc_id
|
||||
|
|
@ -102,24 +99,9 @@
|
|||
{{:continue}}
|
||||
{{/if}}
|
||||
|
||||
{{* chercher des lignes des écritures d'amortissement liées à la ligne d'immobilisation *}}
|
||||
{{:assign amort_lines=null}}
|
||||
{{:assign amort_amount=0}}
|
||||
{{#load type="amort_link"
|
||||
where="$$.immo_doc_id = :immo_doc_id"
|
||||
:immo_doc_id = $immo_doc_id
|
||||
assign="amort_link"
|
||||
}}
|
||||
{{if $amount == null}}
|
||||
{{#select credit FROM acc_transactions_lines WHERE id = :amort_line_id;
|
||||
:amort_line_id = $amort_line_id
|
||||
}}
|
||||
{{:assign amort_amount="%d+%d"|math:$amort_amount:$credit}}
|
||||
{{/select}}
|
||||
{{else}}
|
||||
{{:assign amort_amount="%d+%d"|math:$amort_amount:$amount}}
|
||||
{{/if}}
|
||||
{{/load}}
|
||||
{{* montant des amortissements liés à l'immobilisation *}}
|
||||
{{:include file="./_get_amort_lines.html" immo_doc_id=$immo_doc_id keep="total_amort"}}
|
||||
{{:assign amort_amount=$total_amort}}
|
||||
|
||||
{{* classement par onglet *}}
|
||||
{{if $type_immo == "managed" && $amort_amount >= $montant_immo}}{{:continue}}{{/if}}
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@
|
|||
{{*
|
||||
TODO cas où :
|
||||
- il y a (au moins) une écriture d'avoir
|
||||
- il y a une écriture dui solde l'immo (montant = montant immo - avoir
|
||||
- il y a une écriture qui solde l'immo (montant = montant immo - avoir
|
||||
*}}
|
||||
|
||||
{{* voir s'il existe une écriture qui solde l'immobilisation (voir ci-dessus) *}}
|
||||
|
|
|
|||
|
|
@ -7,62 +7,28 @@
|
|||
*}}
|
||||
|
||||
{{* données de l'immobilisation *}}
|
||||
{{#load type="immo" id=$_GET.immo_doc_id|intval assign="info_immo"}}
|
||||
{{else}}
|
||||
{{:error message="Immobilisation non trouvée"}}
|
||||
{{/load}}
|
||||
|
||||
{{#select
|
||||
line.id as immo_line_id,
|
||||
line.debit as montant,
|
||||
line.label as line_label,
|
||||
trans.id as immo_trans_id,
|
||||
trans.label as label,
|
||||
trans.date as date_achat,
|
||||
account.code as account_code,
|
||||
account.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 account ON line.id_account = account.id
|
||||
WHERE line.id = :line_id;
|
||||
:line_id = $info_immo.line
|
||||
assign="ligne_immo"
|
||||
}}
|
||||
{{else}}
|
||||
{{:error message="Immobilisation non trouvée"}}
|
||||
{{/select}}
|
||||
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$ligne_immo.immo_trans_id}}
|
||||
{{:include file="_get_immo_data.html" immo_doc_id=$_GET.immo_doc_id keep="info_immo, ligne_immo, message"}}
|
||||
{{if $message != null}}
|
||||
{{:error message=$message}}
|
||||
{{/if}}
|
||||
|
||||
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$ligne_immo.trans_id}}
|
||||
{{: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.trans_label}}
|
||||
{{if $ligne_immo.line_label != null && $ligne_immo.line_label != $label_immo}}
|
||||
{{:assign label_immo=$label_immo|cat:" — "|cat:$ligne_immo.line_label}}
|
||||
{{/if}}
|
||||
{{if $info_immo.amount != null}}
|
||||
{{:assign var="ligne_immo.montant" value=$info_immo.amount}}
|
||||
{{:assign var="ligne_immo.amount" value=$info_immo.amount}}
|
||||
{{/if}}
|
||||
|
||||
{{if $info_immo.status == 'ignored'}}
|
||||
{{:error message="Cette immobilisation ne doit pas être amortie"}}
|
||||
{{/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 total_credits=0}}
|
||||
{{#load type="credit_link" where="$$.immo_doc_id=:immo_doc_id" :immo_doc_id=$_GET.immo_doc_id|intval}}
|
||||
{{if $amount == null}}
|
||||
{{#select credit FROM acc_transactions_lines WHERE id = :credit_line_id;
|
||||
:credit_line_id=$credit_line_id
|
||||
}}
|
||||
{{:assign total_credits="%d+%d"|math:$total_credits:$credit}}
|
||||
{{/select}}
|
||||
{{else}}
|
||||
{{:assign total_credits="%d+%d"|math:$total_credits:$amount}}
|
||||
{{/if}}
|
||||
{{/load}}
|
||||
{{:assign solde="%d-%d"|math:$ligne_immo.montant:$total_credits}}
|
||||
{{* déduire le montant des écritures liées à l'immo courante au crédit du même compte *}}
|
||||
{{:include file="_get_credit_lines.html" immo_doc_id=$_GET.immo_doc_id keep="total_credits"}}
|
||||
{{:assign solde="%d-%d"|math:$ligne_immo.amount:$total_credits}}
|
||||
|
||||
{{if $info_immo.status == "amortized"}}
|
||||
{{:assign amort_amount=$solde}}
|
||||
|
|
@ -71,71 +37,13 @@
|
|||
{{:assign valeur_residuelle=$solde}}
|
||||
{{/if}}
|
||||
|
||||
{{* lister les lignes des écritures d'amortissement liées à l'immobilisation *}}
|
||||
{{#load type="amort_link"
|
||||
where="$$.immo_doc_id = :immo_doc_id"
|
||||
: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
|
||||
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 var="linked_amort.%s_%d"|args:$amort_date:$id value=$amort_line}}
|
||||
{{:assign valeur_residuelle="%d-%d"|math:$valeur_residuelle:$amort_line.amort_amount}}
|
||||
{{/select}}
|
||||
{{/load}}
|
||||
{{* lister les amortissements liés à l'immobilisation *}}
|
||||
{{:include file="./_get_amort_lines.html" immo_doc_id=$_GET.immo_doc_id keep="linked_amort, total_amort"}}
|
||||
{{:assign valeur_residuelle="%d-%d"|math:$valeur_residuelle:$total_amort}}
|
||||
|
||||
{{if $valeur_residuelle > 0}}
|
||||
{{* Chercher des amortissements non rattachés à une immo *}}
|
||||
{{#select
|
||||
line.id as amort_line_id,
|
||||
line.id_transaction AS amort_trans_id,
|
||||
line.credit as amort_amount
|
||||
FROM acc_transactions_lines AS line
|
||||
INNER JOIN acc_accounts AS account ON account.id = line.id_account
|
||||
INNER JOIN acc_transactions AS trans ON trans.id = line.id_transaction
|
||||
INNER JOIN acc_years AS y ON y.id = trans.id_year
|
||||
WHERE account.code LIKE "28%" AND credit > 0 AND (NOT trans.status & 16)
|
||||
ORDER BY trans.date, trans.label;
|
||||
assign="amort"
|
||||
}}
|
||||
{{* voir s'il existe des lignes d'immo liées à cette ligne d'amortissement *}}
|
||||
{{:assign amort_amount=0}}
|
||||
{{:assign keep_amort=true}}
|
||||
{{#load type="amort_link"
|
||||
where="$$.amort_line_id = :amort_line_id"
|
||||
:amort_line_id = $amort_line_id
|
||||
assign="amort_link"
|
||||
}}
|
||||
{{if $amort_link.amount == null || $amort_link.amount == 0}}
|
||||
{{:assign amort_amount=$amort.amort_amount}}
|
||||
{{:assign keep_amort=false}}
|
||||
{{else}}
|
||||
{{:assign amort_amount="%d+%d"|math:$amort_amount:$amort_link.amount}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{* pas de ligne d'immo liée à cette ligne d'amort => garder cette ligne d'amortissement *}}
|
||||
{{/load}}
|
||||
{{if $keep_amort && $amort_amount < $amort.amort_amount}}
|
||||
{{:assign var="free_amort_lines." value=$amort}}
|
||||
{{/if}}
|
||||
{{/select}}
|
||||
{{* lister les amortissements non rattachés à une immo *}}
|
||||
{{:include file="./_get_free_amort.html" filter_condition="1" keep="free_amort_lines"}}
|
||||
{{/if}}
|
||||
|
||||
{{:admin_header title="Liste des amortissements" custom_css="./style.css" current="module_amortization"}}
|
||||
|
|
@ -199,7 +107,7 @@
|
|||
<div class="informations">
|
||||
<dl class="describe">
|
||||
<dt>Immobilisation</dt>
|
||||
<dd><span class="num"><a href="{{$trans_url}}">#{{$ligne_immo.immo_trans_id}}</a></span> {{$label_immo}}</dd>
|
||||
<dd><span class="num"><a href="{{$trans_url}}">#{{$ligne_immo.trans_id}}</a></span> {{$label_immo}}</dd>
|
||||
<dt>Compte d'immobilisation</dt>
|
||||
<dd>{{$ligne_immo.account_code}} — {{$ligne_immo.account_label}}</dd>
|
||||
<dt>Début d'amortissement</dt>
|
||||
|
|
@ -209,7 +117,7 @@
|
|||
<dd>{{$info_immo.duration}} ans</dd>
|
||||
{{/if}}
|
||||
<dt>Montant de l'immobilisation</dt>
|
||||
<dd class="money strong">{{"%f"|math:$ligne_immo.montant|money_currency_html:false|raw}}</dd>
|
||||
<dd class="money strong">{{"%f"|math:$ligne_immo.amount|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>
|
||||
|
|
@ -237,9 +145,9 @@
|
|||
<tr>
|
||||
<th class="num">N°</th>
|
||||
<th>Date</th>
|
||||
<th>Libellé</th>
|
||||
<th class="nombre">Montant</th>
|
||||
<th class="nombre">Valeur nette</th>
|
||||
<th>Libellé</th>
|
||||
<th>N° compte</th>
|
||||
<th>Compte</th>
|
||||
<th class="actions"></th>
|
||||
|
|
@ -248,24 +156,24 @@
|
|||
<tbody>
|
||||
{{#foreach from=$linked_amort|ksort item="line"}}
|
||||
{{* données de l'écriture *}}
|
||||
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$line.amort_trans_id}}
|
||||
{{:assign compte_url="%s/acc/accounts/journal.php?id=%s&year=%s"|args:$admin_url:$line.account_id:$line.amort_year}}
|
||||
{{:assign solde="%f-%d"|math:$solde:$line.amort_amount}}
|
||||
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$line.trans_id}}
|
||||
{{:assign compte_url="%s/acc/accounts/journal.php?id=%s&year=%s"|args:$admin_url:$line.account_id:$line.year}}
|
||||
{{:assign solde="%f-%d"|math:$solde:$line.amount}}
|
||||
<tr>
|
||||
<td class="num"><a href="{{$trans_url}}">#{{$line.amort_trans_id}}</a></td>
|
||||
<td>{{$line.amort_date|date_short}}</td>
|
||||
<td class="money">{{"%f"|math:$line.amort_amount|money_html:false|raw}}</td>
|
||||
<td class="money">{{"%f"|math:$solde|money_html:false|raw}}</td>
|
||||
<td class="num"><a href="{{$trans_url}}">#{{$line.trans_id}}</a></td>
|
||||
<td>{{$line.date|date_short}}</td>
|
||||
<td>
|
||||
{{$line.amort_trans_label}}
|
||||
{{if $line.amort_line_label != null && $line.amort_line_label != $line.amort_trans_label}}
|
||||
— {{$line.amort_line_label}}
|
||||
{{$line.trans_label}}
|
||||
{{if $line.line_label != null && $line.line_label != $line.trans_label}}
|
||||
— {{$line.line_label}}
|
||||
{{/if}}
|
||||
</td>
|
||||
<td class="money">{{"%f"|math:$line.amount|money_html:false|raw}}</td>
|
||||
<td class="money">{{"%f"|math:$solde|money_html:false|raw}}</td>
|
||||
<td><a href="{{$compte_url}}">{{$line.account_code}}</a></td>
|
||||
<td>{{$line.account_label}}</td>
|
||||
<td>
|
||||
{{:linkbutton label="Détacher" href="detach_amort.html?immo_doc_id=%s&amort_line_id=%s"|args:$_GET.immo_doc_id:$line.amort_line_id shape="minus"}}
|
||||
{{:linkbutton label="Détacher" href="detach_amort.html?immo_doc_id=%s&amort_line_id=%s"|args:$_GET.immo_doc_id:$line.line_id shape="minus"}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/foreach}}
|
||||
|
|
|
|||
|
|
@ -8,31 +8,16 @@
|
|||
*}}
|
||||
|
||||
{{* données de l'immobilisation *}}
|
||||
{{#load id=$_GET.immo_doc_id|intval assign="info_immo"}}
|
||||
{{else}}
|
||||
{{:error message="Immobilisation non trouvée"}}
|
||||
{{/load}}
|
||||
|
||||
{{#select
|
||||
line.id_transaction as immo_trans_id,
|
||||
line.debit as montant,
|
||||
trans.label as trans_label,
|
||||
line.label as line_label
|
||||
FROM acc_transactions_lines as line
|
||||
INNER JOIN acc_transactions AS trans ON line.id_transaction = trans.id
|
||||
WHERE line.id = :line_id;
|
||||
:line_id = $info_immo.line
|
||||
assign="ligne_immo"
|
||||
}}
|
||||
{{else}}
|
||||
{{:error message="Immobilisation non trouvée"}}
|
||||
{{/select}}
|
||||
{{:include file="_get_immo_data.html" immo_doc_id=$_GET.immo_doc_id|intval keep="info_immo, ligne_immo, message"}}
|
||||
{{if $message != null}}
|
||||
{{:error message=$message}}
|
||||
{{/if}}
|
||||
|
||||
{{:assign label_immo=$info_immo.label|or:$ligne_immo.trans_label}}
|
||||
{{if $ligne_immo.line_label != null && $ligne_immo.line_label != $label_immo}}
|
||||
{{:assign label_immo=$label_immo|cat:" — "|cat:$ligne_immo.line_label}}
|
||||
{{/if}}
|
||||
{{:assign montant_immo=$info_immo.amount|or:$ligne_immo.montant}}
|
||||
{{:assign montant_immo=$info_immo.amount|or:$ligne_immo.amount}}
|
||||
|
||||
{{* chercher l'écriture d'amortissement *}}
|
||||
{{#select
|
||||
|
|
@ -61,7 +46,7 @@
|
|||
|
||||
{{* montant de l'écriture d'amortissement déjà affecté *}}
|
||||
{{:assign montant_affecte=0}}
|
||||
{{#load type="amort_link" assign="linked_amort."
|
||||
{{#load type="amort_link"
|
||||
where="$$.amort_line_id = :amort_line_id"
|
||||
:amort_line_id = $_GET.amort_line_id|intval
|
||||
}}
|
||||
|
|
@ -92,49 +77,14 @@
|
|||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
{{* vérifier que le montant total des amortissements ne dépasse pas la valeur de l'immo *}}
|
||||
{{* montant de l'immo *}}
|
||||
{{:assign total_credits=0}}
|
||||
{{#load
|
||||
type="credit_link"
|
||||
where="$$.immo_doc_id = :immo_doc_id" :immo_doc_id = $_GET.immo_doc_id|intval
|
||||
}}
|
||||
{{if $amount == null}}
|
||||
{{#select credit FROM acc_transactions_lines WHERE id = :credit_line_id;
|
||||
:credit_line_id=$credit_line_id
|
||||
}}
|
||||
{{:assign total_credits="%d+%d"|math:$total_credits:$credit}}
|
||||
{{/select}}
|
||||
{{else}}
|
||||
{{:assign total_credits="%d+%d"|math:$total_credits:$amount}}
|
||||
{{/if}}
|
||||
{{/load}}
|
||||
{{* déduire le montant des écritures liées à l'immo courante au crédit du même compte *}}
|
||||
{{:include file="_get_credit_lines.html" immo_doc_id=$_GET.immo_doc_id keep="total_credits"}}
|
||||
{{:assign montant_immo="%d-%d"|math:$montant_immo:$total_credits}}
|
||||
|
||||
{{* montant des amortissements *}}
|
||||
{{:assign total_amort=0}}
|
||||
{{#load
|
||||
type="amort_link"
|
||||
where="$$.immo_doc_id = :immo_doc_id"
|
||||
:immo_doc_id=$_GET.immo_doc_id|intval
|
||||
}}
|
||||
{{if $amount == null || $amount == 0}}
|
||||
{{#select
|
||||
line.credit
|
||||
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 total_amort="%d+%d"|math:$total_amort:$credit}}
|
||||
{{/select}}
|
||||
{{else}}
|
||||
{{:assign total_amort="%d+%d"|math:$total_amort:$amount}}
|
||||
{{/if}}
|
||||
{{/load}}
|
||||
{{:include file="./_get_amort_lines.html" immo_doc_id=$_GET.immo_doc_id keep="total_amort"}}
|
||||
|
||||
{{* vérifier que le montant total des amortissements ne dépasse pas la valeur de l'immo *}}
|
||||
{{:assign vnc="%d-%d"|math:$montant_immo:$total_amort}}
|
||||
{{:assign total_amort="%d+%d"|math:$total_amort:$montant_amort}}
|
||||
{{if $total_amort > $montant_immo}}
|
||||
|
|
@ -151,7 +101,7 @@
|
|||
END as linked_id
|
||||
FROM acc_transactions_links as links
|
||||
WHERE id_transaction = :immo_trans_id or id_related = :immo_trans_id;
|
||||
:immo_trans_id = $ligne_immo.immo_trans_id
|
||||
:immo_trans_id = $ligne_immo.trans_id
|
||||
}}
|
||||
{{:assign var="linked_transactions." value=$linked_id}}
|
||||
{{/select}}
|
||||
|
|
@ -160,7 +110,7 @@
|
|||
{{:assign var="linked_transactions." value=$amort_line.trans_id}}
|
||||
{{:api
|
||||
method="POST"
|
||||
path="accounting/transaction/%s/transactions"|args:$ligne_immo.immo_trans_id
|
||||
path="accounting/transaction/%s/transactions"|args:$ligne_immo.trans_id
|
||||
assign="result"
|
||||
assign_code="result_code"
|
||||
transactions=$linked_transactions
|
||||
|
|
|
|||
|
|
@ -4,29 +4,15 @@
|
|||
{{*
|
||||
Enregistrer la liaison entre une ligne d'immobilisation et
|
||||
une ligne d'écriture au crédit du compte de l'immobilisation
|
||||
@param credit_line_id : ligne d'écriture au crédit du compte de l'immobilisation
|
||||
@param immo_doc_id : numéro du doc d'immo
|
||||
@param credit_line_id : ligne d'écriture au crédit du compte de l'immobilisation
|
||||
*}}
|
||||
|
||||
{{* chercher l'écriture d'immobilisation *}}
|
||||
{{#load id=$_GET.immo_doc_id|intval assign="doc_immo"}}
|
||||
{{else}}
|
||||
{{:error message="Immobilisation non gérée ; vous devez d'abord renseigner ses informations"}}
|
||||
{{/load}}
|
||||
{{#select
|
||||
line.id as immo_line_id,
|
||||
line.id_transaction as immo_trans_id,
|
||||
line.label as line_label,
|
||||
trans.label as trans_label
|
||||
FROM acc_transactions_lines as line
|
||||
INNER JOIN acc_transactions AS trans ON line.id_transaction = trans.id
|
||||
WHERE line.id = :line_id;
|
||||
:line_id = $doc_immo.line
|
||||
assign="ligne_immo"
|
||||
}}
|
||||
{{else}}
|
||||
{{:error message="Immobilisation non trouvée"}}
|
||||
{{/select}}
|
||||
{{* données de l'immobilisation *}}
|
||||
{{:include file="_get_immo_data.html" immo_doc_id=$_GET.immo_doc_id|intval keep="info_immo, ligne_immo, message"}}
|
||||
{{if $message != null}}
|
||||
{{:error message=$message}}
|
||||
{{/if}}
|
||||
|
||||
{{:assign label_immo=$doc_immo.label|or:$ligne_immo.trans_label}}
|
||||
{{if $ligne_immo.line_label != null && $ligne_immo.line_label != $label_immo}}
|
||||
|
|
@ -35,7 +21,7 @@
|
|||
|
||||
{{* chercher l'écriture au crédit du compte d'immobilisation *}}
|
||||
{{#select
|
||||
line.id_transaction as credit_trans_id,
|
||||
line.id_transaction as trans_id,
|
||||
line.credit as amount,
|
||||
trans.label as trans_label,
|
||||
line.label as line_label
|
||||
|
|
@ -48,7 +34,7 @@
|
|||
{{else}}
|
||||
{{:error message="Impossible de trouver l'écriture au crédit du compte de l'immobilisation de la ligne « %s »"|args:$ligne_immo.trans_label}}
|
||||
{{/select}}
|
||||
{{:assign credit_trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$credit_line.credit_trans_id}}
|
||||
{{:assign credit_trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$credit_line.trans_id}}
|
||||
|
||||
{{* montant de l'écriture de crédit déjà affecté *}}
|
||||
{{:assign montant_affecte=0}}
|
||||
|
|
@ -90,18 +76,18 @@
|
|||
END as linked_id
|
||||
FROM acc_transactions_links as links
|
||||
WHERE id_transaction = :immo_trans_id or id_related = :immo_trans_id;
|
||||
:immo_trans_id = $ligne_immo.immo_trans_id
|
||||
:immo_trans_id = $ligne_immo.trans_id
|
||||
}}
|
||||
{{:assign var="linked_transactions." value=$linked_id}}
|
||||
{{/select}}
|
||||
|
||||
{{* ajouter la nouvelle liaison *}}
|
||||
{{:assign var="linked_transactions." value=$credit_line.credit_trans_id}}
|
||||
{{:assign var="linked_transactions." value=$credit_line.trans_id}}
|
||||
|
||||
{{* Enregistrer les liaisons *}}
|
||||
{{:api
|
||||
method="POST"
|
||||
path="accounting/transaction/%s/transactions"|args:$ligne_immo.immo_trans_id
|
||||
path="accounting/transaction/%s/transactions"|args:$ligne_immo.trans_id
|
||||
assign="result"
|
||||
assign_code="result_code"
|
||||
transactions=$linked_transactions
|
||||
|
|
@ -139,7 +125,7 @@
|
|||
<dt>Immobilisation</dt>
|
||||
<dd>{{$label_immo}}</dd>
|
||||
<dt>Écriture au crédit du compte d'immobilisation</dt>
|
||||
<dd><span class="num"><a href="{{$credit_trans_url}}">#{{$credit_line.credit_trans_id}}</a></span> {{$credit_line.trans_label}}{{if $credit_line.line_label != null && $credit_line.line_label != $credit_line.trans_label}} — {{$credit_line.line_label}}{{/if}}</dd>
|
||||
<dd><span class="num"><a href="{{$credit_trans_url}}">#{{$credit_line.trans_id}}</a></span> {{$credit_line.trans_label}}{{if $credit_line.line_label != null && $credit_line.line_label != $credit_line.trans_label}} — {{$credit_line.line_label}}{{/if}}</dd>
|
||||
<dt>Montant de l'écriture</dt>
|
||||
<dd>{{$credit_line.amount|money_currency_html:false|raw}}</dd>
|
||||
<dt>Montant déjà affecté</dt>
|
||||
|
|
|
|||
|
|
@ -5,114 +5,49 @@
|
|||
@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,
|
||||
trans.date as date_achat,
|
||||
trans.label,
|
||||
account.code as account_code
|
||||
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 = :line_id;
|
||||
:line_id = $info_immo.line
|
||||
assign="ligne_immo"
|
||||
}}
|
||||
{{else}}
|
||||
{{:error message="Immobilisation non trouvée"}}
|
||||
{{/select}}
|
||||
|
||||
{{: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}}
|
||||
{{* données de l'immobilisation *}}
|
||||
{{:include file="_get_immo_data.html" immo_doc_id=$_GET.immo_doc_id|intval keep="info_immo, ligne_immo, message"}}
|
||||
{{if $message != null}}
|
||||
{{:error message=$message}}
|
||||
{{/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 total_credits=0}}
|
||||
{{#load
|
||||
type="credit_link"
|
||||
where="$$.immo_doc_id = :immo_doc_id"
|
||||
:immo_doc_id = $info_immo.id
|
||||
assign="credit_link"
|
||||
}}
|
||||
{{if $amount == null}}
|
||||
{{#select credit FROM acc_transactions_lines WHERE id = :credit_line_id;
|
||||
:credit_line_id=$credit_line_id
|
||||
}}
|
||||
{{:assign total_credits="%d+%d"|math:$total_credits:$credit}}
|
||||
{{/select}}
|
||||
{{else}}
|
||||
{{:assign total_credits="%d+%d"|math:$total_credits:$amount}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{*
|
||||
TODO : à garder ?
|
||||
pas de doc => voir liaison écritures
|
||||
*}}
|
||||
{{#select
|
||||
CASE links.id_related = :immo_trans_id
|
||||
WHEN true THEN links.id_transaction
|
||||
WHEN false THEN links.id_related
|
||||
END as other_id,
|
||||
line.credit
|
||||
FROM acc_transactions AS trans
|
||||
INNER JOIN acc_transactions_links as links
|
||||
ON (trans.id = links.id_transaction OR trans.id = links.id_related)
|
||||
INNER JOIN acc_transactions_lines AS line on line.id_transaction = other_id
|
||||
INNER JOIN acc_accounts AS acc ON line.id_account = acc.id
|
||||
WHERE trans.id = :immo_trans_id AND line.credit > 0 AND acc.code = :account;
|
||||
:immo_trans_id=$ligne_immo.trans_id
|
||||
:account=$ligne_immo.account_code
|
||||
}}
|
||||
{{:assign total_credits="%d+%d"|math:$total_credits:$credit}}
|
||||
{{/select}}
|
||||
{{/load}}
|
||||
{{:assign var="ligne_immo.montant" value="%d-%d"|math:$ligne_immo.montant:$total_credits}}
|
||||
{{:assign label_immo=$info_immo.label|or:$ligne_immo.trans_label}}
|
||||
{{if $ligne_immo.line_label != null && $ligne_immo.line_label != $label_immo}}
|
||||
{{:assign label_immo=$label_immo|cat:" — "|cat:$ligne_immo.line_label}}
|
||||
{{/if}}
|
||||
|
||||
{{:assign total_amort=0}}
|
||||
{{#load type="amort_link"
|
||||
where="$$.immo_doc_id = :immo_doc_id"
|
||||
:immo_doc_id = $_GET.immo_doc_id|intval
|
||||
}}
|
||||
{{#select
|
||||
line.credit,
|
||||
trans.date as amort_date
|
||||
FROM acc_transactions_lines AS line
|
||||
INNER JOIN acc_transactions AS trans ON line.id_transaction = trans.id
|
||||
WHERE line.id = :amort_line_id
|
||||
;
|
||||
:amort_line_id = $amort_line_id
|
||||
assign="amort_line"
|
||||
}}
|
||||
{{: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}}
|
||||
{{:assign date_achat=$info_immo.date_achat|or:$ligne_immo.date_achat}}
|
||||
{{if $info_immo.date_mes != null && $info_immo.date_mes != $date_achat}}
|
||||
{{:assign date_mes=$info_immo.date_mes}}
|
||||
{{/if}}
|
||||
{{: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.amount" value=$info_immo.amount}}
|
||||
{{/if}}
|
||||
|
||||
{{* déduire le montant des écritures liées à l'immo courante au crédit du même compte *}}
|
||||
{{:include file="_get_credit_lines.html" immo_doc_id=$_GET.immo_doc_id keep="total_credits"}}
|
||||
{{:assign var="ligne_immo.amount" value="%d-%d"|math:$ligne_immo.amount:$total_credits}}
|
||||
|
||||
{{* lister les amortissements liés à l'immobilisation *}}
|
||||
{{:include file="./_get_amort_lines.html" immo_doc_id=$_GET.immo_doc_id keep="linked_amort, total_amort"}}
|
||||
{{:assign amort_number=$linked_amort|count}}
|
||||
|
||||
{{#foreach from=$linked_amort|ksort item="line"}}
|
||||
{{if $first_amort_date == null}}
|
||||
{{:assign first_amort_date=$line.amort_date}}
|
||||
{{:assign first_amort_date=$line.date}}
|
||||
{{/if}}
|
||||
{{if $last_amort_date == null}}
|
||||
{{:assign last_amort_date=$line.amort_date}}
|
||||
{{elseif $line.amort_date > $last_amort_date}}
|
||||
{{:assign last_amort_date=$line.amort_date}}
|
||||
{{:assign last_amort_date=$line.date}}
|
||||
{{elseif $line.date > $last_amort_date}}
|
||||
{{:assign last_amort_date=$line.date}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
|
||||
{{if $total_amort == 0}}
|
||||
{{if $info_immo.status == "amortized"}}
|
||||
{{:assign total_amort=$ligne_immo.montant}}
|
||||
{{:assign total_amort=$ligne_immo.amount}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{:assign date_debut=$last_amort_date}}
|
||||
|
|
@ -120,7 +55,7 @@
|
|||
{{:assign ts_debut=$date_debut|strtotime}}
|
||||
{{:assign ts_debut="%d+(60*60*24)"|math:$ts_debut}}
|
||||
{{:assign date_debut=$ts_debut|date:"Y-m-d"}}
|
||||
{{:assign valeur_nette="%f-%f"|math:$ligne_immo.montant:$total_amort}}
|
||||
{{:assign valeur_nette="%f-%f"|math:$ligne_immo.amount:$total_amort}}
|
||||
|
||||
{{*
|
||||
lister les exercices ouverts dont la date de fin est postérieure à la date du dernier amortissment
|
||||
|
|
@ -205,19 +140,19 @@
|
|||
{{:form_errors}}
|
||||
|
||||
{{* formulaire de sortie du bilan *}}
|
||||
<h3>Sortir l'immobilisation « {{$ligne_immo.label}} » du bilan</h3>
|
||||
<h3>Sortir l'immobilisation « {{$label_immo}} » du bilan</h3>
|
||||
<form method="post" action="">
|
||||
|
||||
<div class="informations">
|
||||
<legend>Données de l'imobilisation</legend>
|
||||
<dl class="describe">
|
||||
<dt>Montant</dt>
|
||||
<dd id="montant_immo" class="money">{{$ligne_immo.montant|money_currency_html:false|raw}}</dd>
|
||||
<dd id="montant_immo" class="money">{{$ligne_immo.amount|money_currency_html:false|raw}}</dd>
|
||||
<dt>Date d'acquisition</dt>
|
||||
<dd>{{$info_immo.date_achat|or:$ligne_immo.date_achat|date_short}}</dd>
|
||||
{{if $info_immo.date_mes != null && $info_immo.date_mes != $ligne_immo.date_achat}}
|
||||
<dd>{{$date_achat|date_short}}
|
||||
{{if $date_mes != null}}
|
||||
<dt>Date de mise en service</dt>
|
||||
<dd>{{$info_immo.date_mes|date_short}}</dd>
|
||||
<dd>{{$date_mes|date_short}}</dd>
|
||||
{{/if}}
|
||||
{{if $info_immo.duration != null}}
|
||||
<dt>Durée de l'amortissement</dt>
|
||||
|
|
|
|||
|
|
@ -10,78 +10,35 @@
|
|||
@param exit_date : date de sortie de l'immobilisation
|
||||
*}}
|
||||
{{* TODO *}}
|
||||
{{* Infos de l'immobilisation *}}
|
||||
{{#load id=$_GET.immo_doc_id|intval assign="info_immo"}}
|
||||
{{else}}
|
||||
{{:error message="Immobilisation non trouvée"}}
|
||||
{{/load}}
|
||||
{{* données de l'immobilisation *}}
|
||||
{{:include file="_get_immo_data.html" immo_doc_id=$_GET.immo_doc_id|intval keep="info_immo, ligne_immo, message"}}
|
||||
{{if $message != null}}
|
||||
{{:error message=$message}}
|
||||
{{/if}}
|
||||
|
||||
{{#select
|
||||
line.debit as montant,
|
||||
trans.id AS trans_id,
|
||||
trans.date as date_achat,
|
||||
trans.label,
|
||||
account.code as account_code
|
||||
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 = :line_id;
|
||||
:line_id = $info_immo.line
|
||||
assign="ligne_immo"
|
||||
}}
|
||||
{{else}}
|
||||
{{:error message="Immobilisation non trouvée"}}
|
||||
{{/select}}
|
||||
{{:assign label_immo=$info_immo.label|or:$ligne_immo.trans_label}}
|
||||
{{if $ligne_immo.line_label != null && $ligne_immo.line_label != $label_immo}}
|
||||
{{:assign label_immo=$label_immo|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 total_credits=0}}
|
||||
{{#load
|
||||
type="credit_link"
|
||||
where="$$.immo_doc_id = :immo_doc_id"
|
||||
:immo_doc_id = $info_immo.id
|
||||
assign="credit_link"
|
||||
}}
|
||||
{{if $amount == null}}
|
||||
{{#select credit FROM acc_transactions_lines WHERE id = :credit_line_id;
|
||||
:credit_line_id=$credit_line_id
|
||||
}}
|
||||
{{:assign total_credits="%d+%d"|math:$total_credits:$credit}}
|
||||
{{/select}}
|
||||
{{else}}
|
||||
{{:assign total_credits="%d+%d"|math:$total_credits:$amount}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{*
|
||||
TODO : à garder ?
|
||||
pas de doc => voir liaison écritures
|
||||
*}}
|
||||
{{#select
|
||||
CASE links.id_related = :immo_trans_id
|
||||
WHEN true THEN links.id_transaction
|
||||
WHEN false THEN links.id_related
|
||||
END as other_id,
|
||||
line.credit
|
||||
FROM acc_transactions AS trans
|
||||
INNER JOIN acc_transactions_links as links
|
||||
ON (trans.id = links.id_transaction OR trans.id = links.id_related)
|
||||
INNER JOIN acc_transactions_lines AS line on line.id_transaction = other_id
|
||||
INNER JOIN acc_accounts AS acc ON line.id_account = acc.id
|
||||
WHERE trans.id = :immo_trans_id AND line.credit > 0 AND acc.code = :account;
|
||||
:immo_trans_id=$ligne_immo.trans_id
|
||||
:account=$ligne_immo.account_code
|
||||
}}
|
||||
{{:assign total_credits="%d+%d"|math:$total_credits:$credit}}
|
||||
{{/select}}
|
||||
{{/load}}
|
||||
{{:assign var="ligne_immo.montant" value="%d-%d"|math:$ligne_immo.montant:$total_credits}}
|
||||
{{:assign valeur_nette="%f-%f"|math:$ligne_immo.montant:$_GET.amort_amount}}
|
||||
{{:assign date_achat=$info_immo.date_achat|or:$ligne_immo.date_achat}}
|
||||
{{if $info_immo.date_mes != null && $info_immo.date_mes != $date_achat}}
|
||||
{{:assign date_mes=$info_immo.date_mes}}
|
||||
{{/if}}
|
||||
|
||||
{{if $info_immo.amount != null}}
|
||||
{{:assign var="ligne_immo.amount" value=$info_immo.amount}}
|
||||
{{/if}}
|
||||
|
||||
{{* déduire le montant des écritures liées à l'immo courante au crédit du même compte *}}
|
||||
{{:include file="_get_credit_lines.html" immo_doc_id=$_GET.immo_doc_id keep="total_credits"}}
|
||||
{{:assign var="ligne_immo.amount" value="%d-%d"|math:$ligne_immo.amount:$total_credits}}
|
||||
{{:assign valeur_nette="%f-%f"|math:$ligne_immo.amount:$_GET.amort_amount}}
|
||||
|
||||
{{:assign amort_comp=0}} {{* amortissement complémentaire jqà date sortie *}}
|
||||
{{if $valeur_nette > 0}}
|
||||
{{:assign nbjours="1+(%d-%d)/(60*60*24)"|math:$_GET.exit_date:$_GET.date_debut}}
|
||||
{{:assign annuite="%f/%f"|math:$ligne_immo.montant:$info_immo.duration}}
|
||||
{{:assign annuite="%f/%f"|math:$ligne_immo.amount:$info_immo.duration}}
|
||||
{{:assign amort_comp="round(%f/365*%f, 0)"|math:$annuite:$nbjours}}
|
||||
{{:assign amort_comp="min(%f, %f)"|math:$valeur_nette:$amort_comp}}
|
||||
{{/if}}
|
||||
|
|
@ -106,19 +63,19 @@
|
|||
|
||||
{{:form_errors}}
|
||||
|
||||
<h3>Sortir l'immobilisation « {{$ligne_immo.label}} » du bilan</h3>
|
||||
<h3>Sortir l'immobilisation « {{$label_immo}} » du bilan</h3>
|
||||
<form method="post" action="">
|
||||
|
||||
<div class="informations">
|
||||
<legend>Données de l'imobilisation</legend>
|
||||
<dl class="describe">
|
||||
<dt>Montant</dt>
|
||||
<dd id="montant_immo" class="money">{{$ligne_immo.montant|money_currency_html:false|raw}}</dd>
|
||||
<dd id="montant_immo" class="money">{{$ligne_immo.amount|money_currency_html:false|raw}}</dd>
|
||||
<dt>Date d'acquisition</dt>
|
||||
<dd >{{$ligne_immo.date_achat|date_short}}</dd>
|
||||
{{if $info_immo.date_mes != null && $info_immo.date_mes != $ligne_immo.date_achat}}
|
||||
<dd >{{$date_achat|date_short}}</dd>
|
||||
{{if $date_mes != null}}
|
||||
<dt>Date de mise en service</dt>
|
||||
<dd>{{$info_immo.date_mes|date_short}}</dd>
|
||||
<dd>{{$date_mes|date_short}}</dd>
|
||||
{{/if}}
|
||||
<dt>Durée de l'amortissement</dt>
|
||||
<dd id="duree_amort" class="num">{{$info_immo.duration}} ans</dd>
|
||||
|
|
|
|||
|
|
@ -5,30 +5,12 @@
|
|||
@param immo_doc_id
|
||||
*}}
|
||||
|
||||
{{#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}}
|
||||
{{:include file="_get_immo_data.html" immo_doc_id=$_GET.immo_doc_id|intval keep="info_immo, ligne_immo, message"}}
|
||||
{{if $message != null}}
|
||||
{{:error message=$message}}
|
||||
{{/if}}
|
||||
|
||||
{{: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.trans_id}}
|
||||
{{: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}}
|
||||
|
|
@ -49,7 +31,6 @@
|
|||
{{:assign var="linked_trans." value=$id}}
|
||||
{{/select}}
|
||||
|
||||
{{:debug linked_trans=$linked_trans}}
|
||||
{{if $linked_trans != null}}
|
||||
{{* chercher et supprimer les écritures liées *}}
|
||||
{{#select
|
||||
|
|
@ -62,7 +43,7 @@
|
|||
ON (links.id_transaction = trans.id OR links.id_related = trans.id)
|
||||
WHERE trans.id = :immo_trans_id
|
||||
;
|
||||
:immo_trans_id=$ligne_immo.immo_trans_id
|
||||
:immo_trans_id=$ligne_immo.trans_id
|
||||
}}
|
||||
{{if ! $linked_trans|has:$linked_id}}
|
||||
{{:assign var="linked_transactions." value=$linked_id}}
|
||||
|
|
@ -72,7 +53,7 @@
|
|||
{{* enregistrer les liaisons restantes *}}
|
||||
{{:api
|
||||
method="POST"
|
||||
path="accounting/transaction/%s/transactions"|args:$ligne_immo.immo_trans_id
|
||||
path="accounting/transaction/%s/transactions"|args:$ligne_immo.trans_id
|
||||
assign="result"
|
||||
assign_code="result_code"
|
||||
transactions=$linked_transactions
|
||||
|
|
@ -92,8 +73,8 @@
|
|||
{{:admin_header title="Supprimer" current="module_amortization"}}
|
||||
{{:form_errors}}
|
||||
{{:delete_form
|
||||
legend="Immobilisation « #%s %s »"|args:$ligne_immo.immo_trans_id:$immo_label
|
||||
warning="Supprimer les paramètres de l'immobilisation « #%s %s » ?"|args:$ligne_immo.immo_trans_id:$immo_label
|
||||
legend="Immobilisation « #%s %s »"|args:$ligne_immo.trans_id:$immo_label
|
||||
warning="Supprimer les paramètres de l'immobilisation « #%s %s » ?"|args:$ligne_immo.trans_id:$immo_label
|
||||
info="L'écriture d'immobilisation ne sera pas supprimée ; les nouveaux paramètres pourront être saisis depuis l'onglet « À classer »"
|
||||
}}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,22 +8,10 @@
|
|||
*}}
|
||||
|
||||
{{* données de l'immobilisation *}}
|
||||
{{#load id=$_GET.immo_doc_id|intval assign="info_immo"}}
|
||||
{{else}}
|
||||
{{:error message="Immobilisation non trouvée"}}
|
||||
{{/load}}
|
||||
|
||||
{{* écriture d'immobilisation *}}
|
||||
{{#select
|
||||
id_transaction
|
||||
FROM acc_transactions_lines
|
||||
WHERE id = :line_id;
|
||||
:line_id = $info_immo.line
|
||||
}}
|
||||
{{:assign immo_trans_id=$id_transaction}}
|
||||
{{else}}
|
||||
{{:error message="Immobilisation non trouvée"}}
|
||||
{{/select}}
|
||||
{{:include file="_get_immo_data.html" immo_doc_id=$_GET.immo_doc_id|intval keep="info_immo, ligne_immo, message"}}
|
||||
{{if $message != null}}
|
||||
{{:error message=$message}}
|
||||
{{/if}}
|
||||
|
||||
{{* écriture d'amortissement *}}
|
||||
{{#select
|
||||
|
|
@ -48,7 +36,7 @@
|
|||
END as linked_id
|
||||
FROM acc_transactions_links as links
|
||||
WHERE id_transaction = :immo_trans_id or id_related = :immo_trans_id;
|
||||
:immo_trans_id = $immo_trans_id
|
||||
:immo_trans_id = $ligne_immo.trans_id
|
||||
}}
|
||||
{{if $linked_id != $amort_id}}
|
||||
{{:assign var="linked_transactions." value=$linked_id}}
|
||||
|
|
@ -58,7 +46,7 @@
|
|||
{{* Enregistrer les liaisons *}}
|
||||
{{:api
|
||||
method="POST"
|
||||
path="accounting/transaction/%s/transactions"|args:$immo_trans_id
|
||||
path="accounting/transaction/%s/transactions"|args:$ligne_immo.trans_id
|
||||
assign="result"
|
||||
assign_code="result_code"
|
||||
transactions=$linked_transactions
|
||||
|
|
|
|||
|
|
@ -8,21 +8,10 @@
|
|||
*}}
|
||||
|
||||
{{* données de l'immobilisation *}}
|
||||
{{#load type="immo" id=$_GET.immo_doc_id|intval assign="info_immo"}}
|
||||
{{else}}
|
||||
{{:error message="Immobilisation non trouvée"}}
|
||||
{{/load}}
|
||||
|
||||
{{#select
|
||||
id_transaction
|
||||
FROM acc_transactions_lines
|
||||
WHERE id = :line_id;
|
||||
:line_id = $info_immo.line
|
||||
}}
|
||||
{{:assign immo_trans_id=$id_transaction}}
|
||||
{{else}}
|
||||
{{:error message="Immobilisation non trouvée"}}
|
||||
{{/select}}
|
||||
{{:include file="_get_immo_data.html" immo_doc_id=$_GET.immo_doc_id|intval keep="info_immo, ligne_immo, message"}}
|
||||
{{if $message != null}}
|
||||
{{:error message=$message}}
|
||||
{{/if}}
|
||||
|
||||
{{* chercher l'écriture au crédit *}}
|
||||
{{#select
|
||||
|
|
@ -47,7 +36,7 @@
|
|||
END as linked_id
|
||||
FROM acc_transactions_links as links
|
||||
WHERE id_transaction = :immo_trans_id or id_related = :immo_trans_id;
|
||||
:immo_trans_id = $immo_trans_id
|
||||
:immo_trans_id = $ligne_immo.trans_id
|
||||
}}
|
||||
{{if $linked_id != $credit_id}}
|
||||
{{:assign var="linked_transactions." value=$linked_id}}
|
||||
|
|
@ -57,7 +46,7 @@
|
|||
{{* Enregistrer les liaisons *}}
|
||||
{{:api
|
||||
method="POST"
|
||||
path="accounting/transaction/%s/transactions"|args:$immo_trans_id
|
||||
path="accounting/transaction/%s/transactions"|args:$ligne_immo.trans_id
|
||||
assign="result"
|
||||
assign_code="result_code"
|
||||
transactions=$linked_transactions
|
||||
|
|
|
|||
|
|
@ -9,84 +9,25 @@
|
|||
*}}
|
||||
|
||||
{{* données de l'immobilisation *}}
|
||||
{{#load type="immo" id=$_GET.immo_doc_id|intval assign="info_immo"}}
|
||||
{{else}}
|
||||
{{:error message="Immobilisation non trouvée"}}
|
||||
{{/load}}
|
||||
{{:include file="_get_immo_data.html" immo_doc_id=$_GET.immo_doc_id|intval keep="info_immo, ligne_immo, message"}}
|
||||
{{if $message != null}}
|
||||
{{:error message=$message}}
|
||||
{{/if}}
|
||||
|
||||
{{#select
|
||||
trans.id as immo_trans_id,
|
||||
trans.label as label,
|
||||
trans.date as date_achat,
|
||||
line.id as immo_line_id,
|
||||
line.debit as montant,
|
||||
line.label as line_label,
|
||||
account.code as account_code,
|
||||
account.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 account ON line.id_account = account.id
|
||||
WHERE line.id = :line_id;
|
||||
:line_id = $info_immo.line
|
||||
assign="ligne_immo"
|
||||
}}
|
||||
{{else}}
|
||||
{{:error message="Immobilisation non trouvée"}}
|
||||
{{/select}}
|
||||
|
||||
{{:assign var="info_immo.amount" value=$info_immo.amount|or:$ligne_immo.montant}}
|
||||
{{:assign var="info_immo.amount" value=$info_immo.amount|or:$ligne_immo.amount}}
|
||||
{{:assign var="info_immo.date_achat" value=$info_immo.date_achat|or:$ligne_immo.date_achat}}
|
||||
{{:assign var="info_immo.date_mes" value=$info_immo.date_mes|or:$info_immo.date_achat|or:$ligne_immo.date_achat}}
|
||||
{{:assign var="info_immo.label" value=$info_immo.label|or:$ligne_immo.label}}
|
||||
{{:assign var="info_immo.label" value=$info_immo.label|or:$ligne_immo.trans_label}}
|
||||
{{if $ligne_immo.line_label != null && $ligne_immo.line_label != $info_immo.label}}
|
||||
{{:assign var="info_immo.label" value=$info_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,
|
||||
line.id as line_id,
|
||||
trans.id as trans_id,
|
||||
trans.label,
|
||||
trans.date
|
||||
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 var="linked_immos." trans_id=$trans_id credit_line_id=$line_id label=$label amount=$credit date=$date}}
|
||||
{{/select}}
|
||||
{{if $amount == null}}
|
||||
{{:assign total_credits="%d+%d"|math:$total_credits:$credit}}
|
||||
{{else}}
|
||||
{{:assign total_credits="%d+%d"|math:$total_credits:$amount}}
|
||||
{{/if}}
|
||||
{{/load}}
|
||||
{{* déduire le montant des écritures liées à l'immo courante au crédit du même compte *}}
|
||||
{{:include file="_get_credit_lines.html" immo_doc_id=$_GET.immo_doc_id keep="linked_immos, total_credits"}}
|
||||
{{:assign solde="%d-%d"|math:$info_immo.amount:$total_credits}}
|
||||
|
||||
{{:assign total_amort=0}}
|
||||
{{* lister les docs d'amortissement liées à la ligne d'immobilisation *}}
|
||||
{{#load type="amort_link"
|
||||
where="$$.immo_doc_id = :immo_doc_id"
|
||||
:immo_doc_id=$_GET.immo_doc_id|intval
|
||||
}}
|
||||
{{if $amount != null}}
|
||||
{{:assign total_amort="%d+%d"|math:$total_amort:$amount}}
|
||||
{{else}}
|
||||
{{#select credit FROM acc_transactions_lines WHERE id = :amort_line_id;
|
||||
:amort_line_id=$amort_line_id
|
||||
}}
|
||||
{{:assign total_amort="%d+%d"|math:$total_amort:$credit}}
|
||||
{{/select}}
|
||||
{{/if}}
|
||||
{{/load}}
|
||||
{{* lister les amortissements liés à l'immobilisation *}}
|
||||
{{:include file="./_get_amort_lines.html" immo_doc_id=$_GET.immo_doc_id keep="total_amort"}}
|
||||
|
||||
{{:admin_header title="Détails de l'immobilisation" custom_css="./style.css" current="module_amortization"}}
|
||||
|
||||
|
|
@ -102,7 +43,7 @@
|
|||
{{:include file="_nav.html" current="index" subcurrent="details" subsubcurrent=$subsubcurrent}}
|
||||
{{/if}}
|
||||
*}}
|
||||
{{: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.trans_id}}
|
||||
|
||||
<nav class="tabs">
|
||||
<aside>
|
||||
|
|
@ -122,7 +63,7 @@
|
|||
{{if $_GET.ok}}
|
||||
{{if $_GET.msg|match:"attach_amort"}}
|
||||
{{:assign msg="Écriture d'amortissement attachée"}}
|
||||
{{elseif $_GET.msg|match:"attach_immo"}}
|
||||
{{elseif $_GET.msg|match:"attach_credit"}}
|
||||
{{:assign msg="Écriture au crédit attachée"}}
|
||||
{{elseif $_GET.msg|match:"info"}}
|
||||
{{:assign msg="Données de l'immobilisation enregistrées"}}
|
||||
|
|
@ -139,7 +80,7 @@
|
|||
|
||||
<h3 class="ruler">
|
||||
Immobilisation
|
||||
<span class="num"><a href="{{$trans_url}}">#{{$ligne_immo.immo_trans_id}}</a></span>
|
||||
<span class="num"><a href="{{$trans_url}}">#{{$ligne_immo.trans_id}}</a></span>
|
||||
{{$info_immo.label}}
|
||||
</h3>
|
||||
{{if $linked_immos != null}}
|
||||
|
|
@ -155,7 +96,7 @@
|
|||
<td>{{$line.date|date_short}}</td>
|
||||
<td class="money">{{"%f"|math:$line.amount|money_currency_html:false|raw}}</td>
|
||||
<td>
|
||||
{{:linkbutton label="Détacher" href="detach_immo.html?immo_doc_id=%s&credit_line_id=%s"|args:$_GET.immo_doc_id:$line.credit_line_id shape="minus"}}
|
||||
{{:linkbutton label="Détacher" href="detach_credit.html?immo_doc_id=%s&credit_line_id=%s"|args:$_GET.immo_doc_id:$line.credit_line_id shape="minus"}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/foreach}}
|
||||
|
|
@ -163,11 +104,12 @@
|
|||
</table>
|
||||
</aside>
|
||||
{{/if}}
|
||||
|
||||
<div class="informations">
|
||||
<dl class="describe">
|
||||
{{*
|
||||
<dt>Immobilisation</dt>
|
||||
<dd><span class="num"><a href="{{$trans_url}}">#{{$ligne_immo.immo_trans_id}}</a></span><span class="label"> {{$info_immo.label}}</span></dd>
|
||||
<dd><span class="num"><a href="{{$trans_url}}">#{{$ligne_immo.trans_id}}</a></span><span class="label"> {{$info_immo.label}}</span></dd>
|
||||
*}}
|
||||
<dt>Compte d'immobilisation</dt>
|
||||
<dd>{{$ligne_immo.account_code}} — {{$ligne_immo.account_label}}</dd>
|
||||
|
|
|
|||
|
|
@ -6,34 +6,9 @@
|
|||
@param immo_doc_id : document associé à l'immo
|
||||
*}}
|
||||
|
||||
{{#load id=$_GET.immo_doc_id|intval assign="info_immo"}}
|
||||
{{else}}
|
||||
{{:error message="Informations de l'immobilisation non trouvées"}}
|
||||
{{/load}}
|
||||
|
||||
{{* récupérer les infos de l'immobilisation *}}
|
||||
{{#select
|
||||
trans.id as immo_trans_id,
|
||||
trans.label as label,
|
||||
trans.date as date_achat,
|
||||
line.id as immo_line_id,
|
||||
line.label as line_label,
|
||||
line.debit as montant,
|
||||
account.code as account_code
|
||||
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 = :line_id;
|
||||
:line_id = $info_immo.line
|
||||
assign="ligne_immo"
|
||||
}}
|
||||
{{else}}
|
||||
{{:error message="Immobilisation « %s » non trouvée"|args:$info_immo.line}}
|
||||
{{/select}}
|
||||
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$ligne_immo.immo_trans_id}}
|
||||
{{:assign label_immo=$ligne_immo.label}}
|
||||
{{if $ligne_immo.line_label != null && $ligne_immo.line_label != $label_immo}}
|
||||
{{:assign label_immo=$label_immo|cat:" — "|cat:$ligne_immo.line_label}}
|
||||
{{:include file="_get_immo_data.html" immo_doc_id=$_GET.immo_doc_id|intval keep="info_immo, ligne_immo, message"}}
|
||||
{{if $message != null}}
|
||||
{{:error message=$message}}
|
||||
{{/if}}
|
||||
|
||||
{{*
|
||||
|
|
@ -88,9 +63,9 @@
|
|||
<div class="informations">
|
||||
<dl class="describe">
|
||||
<dt>Immobilisation</dt>
|
||||
<dd><span class="num"><a href="{{$trans_url}}">#{{$ligne_immo.immo_trans_id}}</a></span> {{$label_immo}}</dd>
|
||||
<dd><span class="num"><a href="{{$trans_url}}">#{{$ligne_immo.trans_id}}</a></span> {{$label_immo}}</dd>
|
||||
<dt>Montant</dt>
|
||||
<dd class="money strong">{{"%f"|math:$ligne_immo.montant|money_currency_html:false|raw}}</dd>
|
||||
<dd class="money strong">{{"%f"|math:$ligne_immo.amount|money_currency_html:false|raw}}</dd>
|
||||
<dt>Date de l'écriture d'immobilisation</dt>
|
||||
<dd>{{$ligne_immo.date_achat|date_short}}</dd>
|
||||
</dl>
|
||||
|
|
|
|||
|
|
@ -11,60 +11,19 @@
|
|||
- DONE possibilité supprimer liaison écriture avoir
|
||||
*}}
|
||||
|
||||
{{* 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}}
|
||||
{{:include file="_get_immo_data.html" immo_doc_id=$_GET.immo_doc_id|intval keep="info_immo, ligne_immo, message"}}
|
||||
{{if $message != null}}
|
||||
{{:error message=$message}}
|
||||
{{/if}}
|
||||
|
||||
{{:assign montant_immo=$info_immo.amount|or:$ligne_immo.amount}}
|
||||
{{: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." doc=$id trans=$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}}
|
||||
|
||||
{{* déduire le montant des écritures liées à l'immo courante au crédit du même compte *}}
|
||||
{{:include file="_get_credit_lines.html" immo_doc_id=$_GET.immo_doc_id keep="linked_immos, total_credits"}}
|
||||
{{:assign solde="%d-%d"|math:$montant_immo:$total_credits}}
|
||||
|
||||
{{:assign autres_amount=0}}
|
||||
|
|
@ -76,7 +35,7 @@
|
|||
}}
|
||||
{{:assign autres_amount="%d+%d"|math:$autres_amount:$amount}}
|
||||
{{/load}}
|
||||
{{:assign max_disponible="%d-%d"|math:$ligne_immo.montant:$autres_amount}}
|
||||
{{:assign max_disponible="%d-%d"|math:$ligne_immo.amount:$autres_amount}}
|
||||
|
||||
{{* traiter la saisie *}}
|
||||
{{#form on="save"}}
|
||||
|
|
@ -152,10 +111,10 @@
|
|||
{{/if}}
|
||||
|
||||
{{* écritures de crédit *}}
|
||||
{{#foreach from=$linked_immos item="elem"}}
|
||||
{{if ! $_POST.credit_id|has:$elem.trans}}
|
||||
{{:assign var="docs_to_remove." value=$elem.doc}}
|
||||
{{:assign var="links_to_remove." value=$elem.trans}}
|
||||
{{#foreach from=$linked_immos item="line"}}
|
||||
{{if ! $_POST.credit_id|has:$line.trans_id}}
|
||||
{{:assign var="docs_to_remove." value=$line.doc}}
|
||||
{{:assign var="links_to_remove." value=$line.trans_id}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
|
||||
|
|
@ -172,7 +131,7 @@
|
|||
END as linked_id
|
||||
FROM acc_transactions_links as links
|
||||
WHERE id_transaction = :immo_trans_id or id_related = :immo_trans_id;
|
||||
:immo_trans_id = $ligne_immo.immo_trans_id
|
||||
:immo_trans_id = $ligne_immo.trans_id
|
||||
}}
|
||||
{{if ! $linked_id|in:$links_to_remove}}
|
||||
{{:assign var="linked_transactions." value=$linked_id}}
|
||||
|
|
@ -182,7 +141,7 @@
|
|||
{{* Enregistrer les liaisons *}}
|
||||
{{:api
|
||||
method="POST"
|
||||
path="accounting/transaction/%s/transactions"|args:$ligne_immo.immo_trans_id
|
||||
path="accounting/transaction/%s/transactions"|args:$ligne_immo.trans_id
|
||||
assign="result"
|
||||
assign_code="result_code"
|
||||
transactions=$linked_transactions
|
||||
|
|
@ -225,14 +184,14 @@
|
|||
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}}
|
||||
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$ligne_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>
|
||||
<dd><span class="num"><a href="{{$trans_url}}">#{{$ligne_immo.trans_id}}</a></span> {{$immo_label}}</dd>
|
||||
<dt>Compte d'immobilisation</dt>
|
||||
<dd>{{$ligne_immo.code}} — {{$ligne_immo.account_label}}
|
||||
<dd>{{$ligne_immo.account_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}}
|
||||
|
|
@ -265,9 +224,9 @@
|
|||
<dd>
|
||||
<span class="input-list avoirs">
|
||||
<label for="credit_id">Écritures :</label>
|
||||
{{#foreach from=$linked_immos item="elem"}}
|
||||
{{#foreach from=$linked_immos item="line"}}
|
||||
<span class="label">
|
||||
<input type="hidden" name="credit_id[]" value="{{$elem.trans}}">{{$elem.trans}}
|
||||
<input type="hidden" name="credit_id[]" value="{{$line.trans_id}}">{{$line.trans_id}}
|
||||
<button data-icon="✘" type="button" class=" icn-btn" title="Cliquer pour supprimer la liaison"></button>
|
||||
</span>
|
||||
{{/foreach}}
|
||||
|
|
|
|||
|
|
@ -7,25 +7,12 @@
|
|||
*}}
|
||||
|
||||
{{* données de l'immobilisation *}}
|
||||
{{#load id=$_GET.immo_doc_id|intval assign="info_immo"}}
|
||||
{{else}}
|
||||
{{:error message="Immobilisation non trouvée"}}
|
||||
{{/load}}
|
||||
{{:include file="_get_immo_data.html" immo_doc_id=$_GET.immo_doc_id|intval keep="info_immo, ligne_immo, message"}}
|
||||
{{if $message != null}}
|
||||
{{:error message=$message}}
|
||||
{{/if}}
|
||||
|
||||
{{#select
|
||||
trans.label as label,
|
||||
line.label as line_label
|
||||
FROM acc_transactions_lines AS line
|
||||
INNER JOIN acc_transactions AS trans ON line.id_transaction = trans.id
|
||||
WHERE line.id = :line_id;
|
||||
:line_id = $info_immo.line
|
||||
assign="ligne_immo"
|
||||
}}
|
||||
{{else}}
|
||||
{{:error message="Immobilisation non trouvée"}}
|
||||
{{/select}}
|
||||
|
||||
{{:assign label_immo=$info_immo.label|or:$ligne_immo.label}}
|
||||
{{:assign label_immo=$info_immo.label|or:$ligne_immo.trans_label}}
|
||||
{{if $ligne_immo.line_label != null && $ligne_immo.line_label != $label_immo}}
|
||||
{{:assign label_immo=$label_immo|cat:" — "|cat:$ligne_immo.line_label}}
|
||||
{{/if}}
|
||||
|
|
@ -42,48 +29,8 @@
|
|||
{{:assign filter_condition="1"}}
|
||||
{{/if}}
|
||||
|
||||
{{* lister les écritures d'amortissement *}}
|
||||
{{#select
|
||||
line.id as amort_line_id,
|
||||
line.id_transaction as amort_trans_id,
|
||||
line.credit as amort_amount,
|
||||
line.label as line_label,
|
||||
trans.date as trans_date,
|
||||
trans.label as trans_label,
|
||||
trans.id_year as amort_year,
|
||||
account.id as account_id,
|
||||
account.code as account_code,
|
||||
account.label as account_label
|
||||
FROM acc_transactions_lines AS line
|
||||
INNER JOIN acc_accounts AS account ON account.id = line.id_account
|
||||
INNER JOIN acc_transactions AS trans ON trans.id = line.id_transaction
|
||||
INNER JOIN acc_years AS y ON y.id = trans.id_year
|
||||
WHERE account.code LIKE "28%" AND credit > 0 AND (NOT trans.status & 16) AND !filter_condition
|
||||
ORDER BY trans.date, trans.label;
|
||||
!filter_condition=$filter_condition
|
||||
assign="amort"
|
||||
}}
|
||||
{{* voir s'il existe des lignes d'immo liées à cette ligne d'amortissement *}}
|
||||
{{:assign amort_amount=0}}
|
||||
{{:assign keep_amort=true}}
|
||||
{{#load type="amort_link"
|
||||
where="$$.amort_line_id = :amort_line_id"
|
||||
:amort_line_id=$amort.amort_line_id|intval
|
||||
assign="amort_link"
|
||||
}}
|
||||
{{if $amort_link.amount == null || $amort_link.amount == 0}}
|
||||
{{:assign amort_amount=$amort.amort_amount}}
|
||||
{{:assign keep_amort=false}}
|
||||
{{else}}
|
||||
{{:assign amort_amount="%d+%d"|math:$amort_amount:$amort_link.amount}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{* pas de ligne d'immo liée à cette ligne d'amort => garder cette ligne d'amortissement *}}
|
||||
{{/load}}
|
||||
{{if $keep_amort && $amort_amount < $amort.amort_amount}}
|
||||
{{:assign var="free_amort_lines." value=$amort}}
|
||||
{{/if}}
|
||||
{{/select}}
|
||||
{{* lister les amortissements non rattachés à une immo *}}
|
||||
{{:include file="./_get_free_amort.html" filter_condition=$filter_condition keep="free_amort_lines"}}
|
||||
|
||||
{{:admin_header title="Amortissements non rattachés" custom_css="./style.css" current="module_amortization"}}
|
||||
|
||||
|
|
@ -117,8 +64,8 @@
|
|||
<tr>
|
||||
<th>N°</th>
|
||||
<th>Date</th>
|
||||
<th class="nombre">Montant</th>
|
||||
<th>Libellé</th>
|
||||
<th class="nombre">Montant</th>
|
||||
<th>N° compte</th>
|
||||
<th>Compte</th>
|
||||
<th class="actions"></th>
|
||||
|
|
@ -126,19 +73,19 @@
|
|||
</thead>
|
||||
<tbody>
|
||||
{{#foreach from=$free_amort_lines item="line"}}
|
||||
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$line.amort_trans_id}}
|
||||
{{:assign compte_url="%s/acc/accounts/journal.php?id=%s&year=%s"|args:$admin_url:$line.account_id:$line.amort_year}}
|
||||
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$line.trans_id}}
|
||||
{{:assign compte_url="%s/acc/accounts/journal.php?id=%s&year=%s"|args:$admin_url:$line.account_id:$line.year}}
|
||||
<tr>
|
||||
<td class="num"><a href="{{$trans_url}}">#{{$line.amort_trans_id}}</a></td>
|
||||
<td class="num"><a href="{{$trans_url}}">#{{$line.trans_id}}</a></td>
|
||||
<td>{{$line.trans_date|date_short}}</td>
|
||||
<td class="money">{{"%f"|math:$line.amort_amount|money_html:false|raw}}</td>
|
||||
<td>{{$line.trans_label}}
|
||||
{{if $line.line_label != null && $line.line_label != $line.trans_label}} - {{$line.line_label}}{{/if}}
|
||||
</td>
|
||||
<td class="money">{{"%f"|math:$line.amount|money_html:false|raw}}</td>
|
||||
<td><a href="{{$compte_url}}">{{$line.account_code}}</a></td>
|
||||
<td>{{$line.account_label}}</td>
|
||||
<td>
|
||||
{{:linkbutton label="Attacher" href="attach_amort.html?immo_doc_id=%s&amort_line_id=%s"|args:$_GET.immo_doc_id:$line.amort_line_id shape="plus"}}
|
||||
{{:linkbutton label="Attacher" href="attach_amort.html?immo_doc_id=%s&amort_line_id=%s"|args:$_GET.immo_doc_id:$line.line_id shape="plus"}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/foreach}}
|
||||
|
|
|
|||
129
save_amort.html
129
save_amort.html
|
|
@ -5,37 +5,17 @@
|
|||
@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.id_account as account_id,
|
||||
line.debit as montant,
|
||||
line.id_project as project_id,
|
||||
line.label as line_label,
|
||||
trans.id as immo_trans_id,
|
||||
trans.label,
|
||||
trans.date,
|
||||
account.code as account_code
|
||||
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
|
||||
LEFT JOIN acc_projects AS project ON line.id_project = project.id
|
||||
WHERE line.id = :line_id;
|
||||
:line_id = $info_immo.line
|
||||
assign="ligne_immo"
|
||||
}}
|
||||
{{else}}
|
||||
{{:error message="Immobilisation non trouvée"}}
|
||||
{{/select}}
|
||||
{{if $info_immo.amount != null}}
|
||||
{{:assign var="ligne_immo.montant" value=$info_immo.amount}}
|
||||
{{* données de l'immobilisation *}}
|
||||
{{:include file="_get_immo_data.html" immo_doc_id=$_GET.immo_doc_id|intval keep="info_immo, ligne_immo, message"}}
|
||||
{{if $message != null}}
|
||||
{{:error message=$message}}
|
||||
{{/if}}
|
||||
{{:assign date_debut=$info_immo.date_mes|or:$info_immo.date_achat|or:$ligne_immo.date}}
|
||||
{{:assign amort_label=$info_immo.label|or:$ligne_immo.label}}
|
||||
|
||||
{{if $info_immo.amount != null}}
|
||||
{{:assign var="ligne_immo.amount" value=$info_immo.amount}}
|
||||
{{/if}}
|
||||
{{:assign date_debut=$info_immo.date_mes|or:$info_immo.date_achat|or:$ligne_immo.date_achat}}
|
||||
{{:assign amort_label=$info_immo.label|or:$ligne_immo.trans_label}}
|
||||
|
||||
{{if $ligne_immo.line_label != null && $ligne_immo.line_label != $amort_label}}
|
||||
{{:assign amort_label=$amort_label|cat:" — "|cat:$ligne_immo.line_label}}
|
||||
|
|
@ -46,69 +26,25 @@
|
|||
{{:error message="Cette immobilisation est complètement amortie ; il est impossible d'ajouter une écriture d'amortissement"}}
|
||||
{{/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 total_credits=0}}
|
||||
{{#load
|
||||
type="credit_link"
|
||||
where="$$.immo_doc_id = :immo_doc_id" :immo_doc_id = $_GET.immo_doc_id|intval
|
||||
}}
|
||||
{{if $amount == null}}
|
||||
{{#select credit FROM acc_transactions_lines WHERE id = :credit_line_id;
|
||||
:credit_line_id=$credit_line_id
|
||||
}}
|
||||
{{:assign total_credits="%d+%d"|math:$total_credits:$credit}}
|
||||
{{/select}}
|
||||
{{else}}
|
||||
{{:assign total_credits="%d+%d"|math:$total_credits:$amount}}
|
||||
{{/if}}
|
||||
{{/load}}
|
||||
{{:assign var="ligne_immo.montant" value="%d-%d"|math:$ligne_immo.montant:$total_credits}}
|
||||
{{:assign solde=$ligne_immo.montant}}
|
||||
{{* déduire le montant des écritures liées à l'immo courante au crédit du même compte *}}
|
||||
{{:include file="_get_credit_lines.html" immo_doc_id=$_GET.immo_doc_id keep="total_credits"}}
|
||||
{{:assign var="ligne_immo.amount" value="%d-%d"|math:$ligne_immo.amount:$total_credits}}
|
||||
|
||||
{{* chercher des écritures d'amortissement liées à la ligne d'immobilisation *}}
|
||||
{{#load
|
||||
type="amort_link"
|
||||
where="$$.immo_doc_id = :immo_doc_id"
|
||||
order="$$.date"
|
||||
:immo_doc_id=$_GET.immo_doc_id|intval
|
||||
}}
|
||||
{{#select
|
||||
line.credit,
|
||||
trans.date as amort_date,
|
||||
COALESCE(trans.label, line.label) as amort_label,
|
||||
account.code as account_code,
|
||||
account.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 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 var="linked_amort.%s_%d"|args:$amort_date:$id value=$amort_line}}
|
||||
{{/select}}
|
||||
{{/load}}
|
||||
|
||||
{{:assign total_amort=0}}
|
||||
{{:assign valeur_residuelle=$ligne_immo.montant}}
|
||||
{{#foreach from=$linked_amort|ksort item="line"}}
|
||||
{{:assign valeur_residuelle="%d-%d"|math:$valeur_residuelle:$line.amort_amount}}
|
||||
{{:assign total_amort="%d+%d"|math:$total_amort:$line.amort_amount}}
|
||||
{{:assign date_debut=$line.amort_date}}
|
||||
{{:assign code_amort=$line.account_code}}
|
||||
{{:assign amort_account_label=$line.account_label}}
|
||||
{{:assign amort_label=$amort_label}}
|
||||
{{/foreach}}
|
||||
{{* lister les amortissements liés à l'immobilisation *}}
|
||||
{{:include file="./_get_amort_lines.html" immo_doc_id=$_GET.immo_doc_id keep="linked_amort, total_amort"}}
|
||||
|
||||
{{:assign valeur_residuelle="%d-%d"|math:$ligne_immo.amount:$total_amort}}
|
||||
{{if $valeur_residuelle == 0}}
|
||||
{{:error message="Cette immobilisation est complètement amortie ; il est impossible d'ajouter une écriture d'amortissement"}}
|
||||
{{/if}}
|
||||
|
||||
{{#foreach from=$linked_amort|ksort item="line"}}
|
||||
{{:assign date_debut=$line.date}}
|
||||
{{:assign code_amort=$line.account_code}}
|
||||
{{:assign amort_account_label=$line.account_label}}
|
||||
{{:assign amort_label=$line_label|or:$trans_label}}
|
||||
{{/foreach}}
|
||||
|
||||
{{if $total_amort == 0}}
|
||||
{{* 1er amortissement *}}
|
||||
{{* déterminer le compte d'amortissement en fonction du compte d'immobilisation *}}
|
||||
|
|
@ -120,7 +56,7 @@
|
|||
keep="code_amort"
|
||||
}}
|
||||
{{:assign var="amort_account_label" value="Amortissement %s"|args:$amort_account.label}}
|
||||
{{:assign var=libelle value="Amortissement %s"|args:$ligne_immo.label}}
|
||||
{{:assign var=libelle value="Amortissement %s"|args:$ligne_immo.trans_label}}
|
||||
{{else}}
|
||||
{{* amortissements suivants *}}
|
||||
{{:assign date_debut=$date_debut|strtotime}}
|
||||
|
|
@ -207,10 +143,11 @@
|
|||
{{/if}}
|
||||
|
||||
{{* vérifier que le montant ne dépasse pas le solde restant *}}
|
||||
{{:assign solde="%d-%d"|math:$ligne_immo.montant:$total_amort}}
|
||||
{{:assign solde="%d-%d"|math:$ligne_immo.amount:$total_amort}}
|
||||
{{if $_POST.montant|trim|money_int > $solde|intval}}
|
||||
{{:assign montant=$_POST.montant|trim|money_int|money_raw}}
|
||||
{{:assign solde=$solde|money_raw}}
|
||||
{{:error message="Le montant indiqué « %s » dépasse le solde à amortir « %s »"|args:$_POST.montant:$solde}}
|
||||
{{:error message="Le montant indiqué « %s » dépasse le solde à amortir « %s »"|args:$montant:$solde}}
|
||||
{{/if}}
|
||||
|
||||
{{* enregistrer l'écriture *}}
|
||||
|
|
@ -218,13 +155,13 @@
|
|||
var="lines."
|
||||
debit=$_POST.montant
|
||||
account=$debit_account|keys|value:0
|
||||
id_project=$ligne_immo.project_id
|
||||
id_project=$ligne_immo.id_project
|
||||
}}
|
||||
{{:assign
|
||||
var="lines."
|
||||
credit=$_POST.montant
|
||||
account=$credit_account|keys|value:0
|
||||
id_project=$ligne_immo.project_id
|
||||
id_project=$ligne_immo.id_project
|
||||
}}
|
||||
|
||||
{{:api
|
||||
|
|
@ -237,7 +174,7 @@
|
|||
date=$_POST.date_amort
|
||||
label=$_POST.designation
|
||||
lines=$lines
|
||||
linked_transactions=$ligne_immo.immo_trans_id|intval
|
||||
linked_transactions=$ligne_immo.trans_id|intval
|
||||
}}
|
||||
|
||||
{{* enregistrer la liaison des lignes *}}
|
||||
|
|
@ -279,8 +216,8 @@
|
|||
{{:include file="_calcul_dates.html" date_debut=$date_debut date_fin=$date_amort keep="nbjours"}}
|
||||
|
||||
{{* montant de l'amortissement *}}
|
||||
{{:assign montant_amort="%f/%f/365*%d"|math:$ligne_immo.montant:$info_immo.duration:$nbjours|intval}}
|
||||
{{:assign montant_amort="min(%f, %d-%d)"|math:$montant_amort:$ligne_immo.montant:$total_amort}}
|
||||
{{:assign montant_amort="%f/%f/365*%d"|math:$ligne_immo.amount:$info_immo.duration:$nbjours|intval}}
|
||||
{{:assign montant_amort="min(%f, %d-%d)"|math:$montant_amort:$ligne_immo.amount:$total_amort}}
|
||||
{{:assign var="debit_account.6811" value="6811 — Dot. aux amortissements des immobilisations"}}
|
||||
{{:assign var="credit_account.%s"|args:$code_amort value="%s — "|args:$code_amort|cat:$amort_account_label}}
|
||||
|
||||
|
|
@ -315,7 +252,7 @@
|
|||
default=$credit_account
|
||||
}}
|
||||
<div id="donnees" class="hidden">
|
||||
{{:input type="text" name="montant_immo" default=$ligne_immo.montant}}
|
||||
{{:input type="text" name="montant_immo" default=$ligne_immo.amount}}
|
||||
{{:input type="text" name="duree_amort" default=$info_immo.duration}}
|
||||
{{:input type="text" name="somme_amort" default=$total_amort}}
|
||||
{{:input type="select" name="years_data" options=$years_data}}
|
||||
|
|
|
|||
108
write_exit.html
108
write_exit.html
|
|
@ -11,85 +11,27 @@
|
|||
- cession : montant de la cession (optionnel)
|
||||
*}}
|
||||
|
||||
{{#load id=$_GET.immo_doc_id|intval assign="info_immo"}}
|
||||
{{else}}
|
||||
{{:error message="Immobilisation non trouvée"}}
|
||||
{{/load}}
|
||||
{{* données de l'immobilisation *}}
|
||||
{{:include file="_get_immo_data.html" immo_doc_id=$_GET.immo_doc_id|intval keep="info_immo, ligne_immo, message"}}
|
||||
{{if $message != null}}
|
||||
{{:error message=$message}}
|
||||
{{/if}}
|
||||
|
||||
{{#select
|
||||
line.debit as montant,
|
||||
line.id_transaction,
|
||||
trans.id AS trans_id,
|
||||
trans.date as date_achat,
|
||||
trans.label,
|
||||
acc.code as account_code,
|
||||
id_project
|
||||
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 = :immo_line_id;
|
||||
:immo_line_id = $info_immo.line
|
||||
assign="ligne_immo"
|
||||
}}
|
||||
{{else}}
|
||||
{{:error message="Immobilisation non trouvée"}}
|
||||
{{/select}}
|
||||
|
||||
{{* 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 total_credits=0}}
|
||||
{{#load
|
||||
type="credit_link"
|
||||
where="$$.immo_doc_id = :immo_doc_id"
|
||||
:immo_doc_id = $info_immo.id
|
||||
assign="credit_link"
|
||||
}}
|
||||
{{if $amount == null}}
|
||||
{{#select credit FROM acc_transactions_lines WHERE id = :credit_line_id;
|
||||
:credit_line_id=$credit_line_id
|
||||
}}
|
||||
{{:assign total_credits="%d+%d"|math:$total_credits:$credit}}
|
||||
{{/select}}
|
||||
{{else}}
|
||||
{{:assign total_credits="%d+%d"|math:$total_credits:$amount}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{*
|
||||
TODO : à garder ?
|
||||
pas de doc => voir liaison écritures
|
||||
*}}
|
||||
{{#select
|
||||
CASE links.id_related = :immo_trans_id
|
||||
WHEN true THEN links.id_transaction
|
||||
WHEN false THEN links.id_related
|
||||
END as other_id,
|
||||
line.credit
|
||||
FROM acc_transactions AS trans
|
||||
INNER JOIN acc_transactions_links as links
|
||||
ON (trans.id = links.id_transaction OR trans.id = links.id_related)
|
||||
INNER JOIN acc_transactions_lines AS line on line.id_transaction = other_id
|
||||
INNER JOIN acc_accounts AS acc ON line.id_account = acc.id
|
||||
WHERE trans.id = :immo_trans_id AND line.credit > 0 AND acc.code = :account;
|
||||
:immo_trans_id=$ligne_immo.trans_id
|
||||
:account=$ligne_immo.account_code
|
||||
}}
|
||||
{{:assign total_credits="%d+%d"|math:$total_credits:$credit}}
|
||||
{{/select}}
|
||||
{{/load}}
|
||||
{{:assign var="ligne_immo.montant" value="%d-%d"|math:$ligne_immo.montant:$total_credits}}
|
||||
{{:assign valeur_nette="%f-%f"|math:$ligne_immo.montant:$_GET.amort_amount}}
|
||||
{{* déduire le montant des écritures liées à l'immo courante au crédit du même compte *}}
|
||||
{{:include file="_get_credit_lines.html" immo_doc_id=$_GET.immo_doc_id keep="total_credits"}}
|
||||
{{:assign var="ligne_immo.amount" value="%d-%d"|math:$ligne_immo.amount:$total_credits}}
|
||||
{{:assign valeur_nette="%f-%f"|math:$ligne_immo.amount:$_GET.amort_amount}}
|
||||
|
||||
{{:assign amort_comp=0}} {{* amortissement complémentaire jqà date sortie *}}
|
||||
{{:assign amort_except=0}} {{* amortissement exceptionnel jqà date fin amortissement *}}
|
||||
{{if $valeur_nette > 0}}
|
||||
{{:assign nbjours="1+(%d-%d)/(60*60*24)"|math:$_GET.exit_date:$_GET.date_debut}}
|
||||
{{:assign annuite="%f/%f"|math:$ligne_immo.montant:$info_immo.duration}}
|
||||
{{:assign annuite="%f/%f"|math:$ligne_immo.amount:$info_immo.duration}}
|
||||
{{:assign amort_comp="round(%f/365*%f, 0)"|math:$annuite:$nbjours}}
|
||||
{{:assign amort_comp="min(%f, %f)"|math:$valeur_nette:$amort_comp}}
|
||||
|
||||
{{if $_GET.cession == null}}
|
||||
{{:assign amort_except="%f-%f-%f"|math:$ligne_immo.montant:$_GET.amort_amount:$amort_comp}}
|
||||
{{:assign amort_except="%f-%f-%f"|math:$ligne_immo.amount:$_GET.amort_amount:$amort_comp}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
|
|
@ -132,7 +74,7 @@
|
|||
}}
|
||||
{{:assign comp_account_code=$account_code|keys|value:0}}
|
||||
|
||||
{{:assign libelle="Amortissement complémentaire "|cat:$ligne_immo.label}}
|
||||
{{:assign libelle="Amortissement complémentaire "|cat:$ligne_immo.trans_label}}
|
||||
{{:assign
|
||||
var="lines."
|
||||
debit="%f/100"|math:$amort_comp
|
||||
|
|
@ -157,7 +99,7 @@
|
|||
keep="account_code"
|
||||
}}
|
||||
{{:assign except_account_code=$account_code|keys|value:0}}
|
||||
{{:assign libelle="Amortissement exceptionnel "|cat:$ligne_immo.label}}
|
||||
{{:assign libelle="Amortissement exceptionnel "|cat:$ligne_immo.trans_label}}
|
||||
{{:assign
|
||||
var="lines."
|
||||
debit="%f/100"|math:$amort_except
|
||||
|
|
@ -183,9 +125,9 @@
|
|||
id_year=$_GET.year
|
||||
type="advanced"
|
||||
date=$_GET.exit_date
|
||||
label="Amortissement final "|cat:$ligne_immo.label
|
||||
label="Amortissement final "|cat:$ligne_immo.trans_label
|
||||
lines=$lines
|
||||
linked_transactions=$ligne_immo.id_transaction
|
||||
linked_transactions=$ligne_immo.trans_id
|
||||
}}
|
||||
|
||||
{{* liaisons lignes d'amortissement *}}
|
||||
|
|
@ -209,18 +151,18 @@
|
|||
keep="account_code"
|
||||
}}
|
||||
{{:assign immo_account_code=$account_code|keys|value:0}}
|
||||
{{:assign libelle="Sortie du bilan de "|cat:$ligne_immo.label}}
|
||||
{{:assign libelle="Sortie du bilan de "|cat:$ligne_immo.trans_label}}
|
||||
{{:assign
|
||||
var="lines."
|
||||
account=$immo_account_code
|
||||
credit="%f/100"|math:$ligne_immo.montant
|
||||
credit="%f/100"|math:$ligne_immo.amount
|
||||
id_project=$ligne_immo.id_project
|
||||
label=$libelle
|
||||
}}
|
||||
{{:assign
|
||||
var="lines."
|
||||
account=$amort_account_code
|
||||
debit="(%f-%f)/100"|math:$ligne_immo.montant:$valeur_nette
|
||||
debit="(%f-%f)/100"|math:$ligne_immo.amount:$valeur_nette
|
||||
id_project=$ligne_immo.id_project
|
||||
label=$libelle
|
||||
}}
|
||||
|
|
@ -250,7 +192,7 @@
|
|||
date=$_GET.exit_date
|
||||
label=$libelle
|
||||
lines=$lines
|
||||
linked_transactions=$ligne_immo.id_transaction
|
||||
linked_transactions=$ligne_immo.trans_id
|
||||
}}
|
||||
|
||||
{{* liaison écriture de sortie *}}
|
||||
|
|
@ -268,7 +210,7 @@
|
|||
|
||||
{{if $montant_cession > 0}}
|
||||
{{* Cession de l'immobilisation *}}
|
||||
{{:assign libelle="Produit cession "|cat:$ligne_immo.label}}
|
||||
{{:assign libelle="Produit cession "|cat:$ligne_immo.trans_label}}
|
||||
{{:include
|
||||
file="_get_codes.html"
|
||||
account=$_POST.creance_account
|
||||
|
|
@ -294,7 +236,7 @@
|
|||
debit=$creance_account
|
||||
credit=$cession_account
|
||||
id_project=$ligne_immo.id_project
|
||||
linked_transactions=$ligne_immo.id_transaction
|
||||
linked_transactions=$ligne_immo.trans_id
|
||||
}}
|
||||
{{/if}}
|
||||
|
||||
|
|
@ -371,14 +313,14 @@
|
|||
{{/foreach}}
|
||||
{{:assign patterns=$pattern_array|implode:"|"}}
|
||||
|
||||
<h3>Sortir l'immobilisation « {{$ligne_immo.label}} » du bilan</h3>
|
||||
<h3>Sortir l'immobilisation « {{$ligne_immo.trans_label}} » du bilan</h3>
|
||||
<form method="post" action="">
|
||||
|
||||
<div class="informations">
|
||||
<legend>Données de l'imobilisation</legend>
|
||||
<dl class="describe">
|
||||
<dt>Montant</dt>
|
||||
<dd class="money">{{$ligne_immo.montant|money_currency_html:false|raw}}</dd>
|
||||
<dd class="money">{{$ligne_immo.amount|money_currency_html:false|raw}}</dd>
|
||||
<dt>Date d'acquisition</dt>
|
||||
<dd >{{$ligne_immo.date_achat|date_short}}</dd>
|
||||
{{if $info_immo.date_mes != null && $info_immo.date_mes != $ligne_immo.date_achat}}
|
||||
|
|
@ -524,7 +466,7 @@
|
|||
}}
|
||||
</td>
|
||||
{{if $montant_cession == 0}}
|
||||
{{:assign montant=$ligne_immo.montant}}
|
||||
{{:assign montant=$ligne_immo.amount}}
|
||||
{{else}}
|
||||
{{:assign montant="%f+%f"|math:$_GET.amort_amount:$amort_comp}}
|
||||
{{/if}}
|
||||
|
|
@ -555,7 +497,7 @@
|
|||
}}
|
||||
</td>
|
||||
<td></td>
|
||||
<td>{{$ligne_immo.montant|money_currency_html:false|raw}}</td>
|
||||
<td>{{$ligne_immo.amount|money_currency_html:false|raw}}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue