Incorporation écritures comptes 23xx créées hors Paheko
This commit is contained in:
parent
f1738f2197
commit
54273c6707
6 changed files with 186 additions and 91 deletions
130
_unfinished.html
130
_unfinished.html
|
|
@ -9,6 +9,15 @@
|
|||
la construction d'un bâtiment destiné à être amorti)
|
||||
</p>
|
||||
|
||||
{{#form on="transfer"}}
|
||||
{{if $_POST.selected == null}}
|
||||
<p class="block error">Vous n'avez sélectionné aucune écriture !</p>
|
||||
{{else}}
|
||||
{{:assign doc_list=$_POST.selected|implode:","}}
|
||||
{{:redirect to="transfer.html?doc=%s"|args:$doc_list}}
|
||||
{{/if}}
|
||||
{{/form}}
|
||||
|
||||
{{:include file="_get_config.html" keep="module.config"}}
|
||||
{{:assign saved_hides=$module.config.hides}}
|
||||
{{:assign var="user_hides" from="saved_hides.%s"|args:$logged_user.id}}
|
||||
|
|
@ -21,7 +30,7 @@
|
|||
{{else}}
|
||||
{{:assign unhide=1}}
|
||||
{{/if}}
|
||||
{{:assign var="user_hides.unhide_unfinished" value=$unhide"}}
|
||||
{{:assign var="user_hides.unhide_unfinished" value=$unhide}}
|
||||
{{:assign var="saved_hides.%s"|args:$logged_user.id value=$user_hides}}
|
||||
{{:save key="config" hides=$saved_hides}}
|
||||
{{/if}}
|
||||
|
|
@ -64,57 +73,83 @@
|
|||
account.id as account_id,
|
||||
account.code as account_code,
|
||||
account.label as account_label,
|
||||
sum(line.debit) AS debit,
|
||||
line.debit AS debit,
|
||||
trans.id_year as trans_id_year
|
||||
FROM acc_transactions AS trans
|
||||
INNER JOIN acc_transactions_lines AS line ON line.id_transaction = trans.id
|
||||
INNER JOIN acc_accounts AS account ON line.id_account = account.id
|
||||
INNER JOIN acc_years AS years ON trans.id_year = years.id
|
||||
WHERE !condition
|
||||
GROUP BY trans.id
|
||||
ORDER BY trans.date DESC;
|
||||
!condition=$condition
|
||||
assign="immo_line"
|
||||
}}
|
||||
{{* voir si l'écriture a été marquée ignorée *}}
|
||||
{{:assign var="immo_line.ignore" value=false}}
|
||||
{{#load type="immo" assign="info_immo" where="$$.line = :line_id AND $$.status = 'ignored'" :line_id=$immo_line_id|intval}}
|
||||
{{:assign var="immo_line.ignore" value=true}}
|
||||
{{* document associé *}}
|
||||
{{#load type="immo" where="$$.line = :line_id" :line_id=$immo_line_id assign="info_immo"}}
|
||||
{{:assign var="immo_line.doc_id" value=$info_immo.id}}
|
||||
{{* *}}
|
||||
{{if $status == "unfinished"}}
|
||||
{{* voir si l'immo a été ventilée *}}
|
||||
{{:assign var="immo_line.allocated_amount" value=0}}
|
||||
{{#load type="immo" where="$$.line = :immo_line_id AND ($$.status = 'inprogress' OR $$.status = "transferred")" :immo_line_id=$immo_line_id}}
|
||||
{{:assign var="immo_line.allocated_amount" value="%d+%d"|math:$immo_line.allocated_amount:$amount}}
|
||||
{{/load}}
|
||||
{{elseif $status == 'ignored'}}
|
||||
{{:assign nb_ignored="%d + 1"|math:$nb_ignored}}
|
||||
{{if $unhide == null}}
|
||||
{{:continue}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{* cas d'une immo sans doc associé => créer le doc *}}
|
||||
{{:save
|
||||
key=""|uuid
|
||||
validate_schema="asset.schema.json"
|
||||
type="immo"
|
||||
line=$immo_line_id|intval
|
||||
duration=0
|
||||
status="unfinished"
|
||||
assign_new_id="immo_doc_id"
|
||||
}}
|
||||
{{:assign var="immo_line.doc_id" value=$immo_doc_id|intval}}
|
||||
{{/load}}
|
||||
{{if $immo_line.ignore}}
|
||||
{{:assign nb_ignored="%d + 1"|math:$nb_ignored}}
|
||||
{{/if}}
|
||||
{{if $immo_line.ignore && $unhide == null}}
|
||||
|
||||
{{if $info_immo.status == 'transferred'}}
|
||||
{{:continue}}
|
||||
{{/if}}
|
||||
|
||||
{{*
|
||||
TODO cas où :
|
||||
- il y a (au moins) une écriture d'avoir
|
||||
*}}
|
||||
|
||||
{{* voir s'il existe une écriture qui solde l'immobilisation (voir ci-dessus) *}}
|
||||
{{#select
|
||||
count(*) AS count
|
||||
FROM acc_transactions AS trans
|
||||
INNER JOIN acc_transactions_lines AS line ON line.id_transaction = trans.id
|
||||
INNER JOIN acc_accounts AS account ON line.id_account = account.id
|
||||
WHERE line.credit = :amount AND code = :account_code
|
||||
;
|
||||
:amount = $debit
|
||||
:account_code = $account_code
|
||||
}}
|
||||
{{:assign count=$count}}
|
||||
{{/select}}
|
||||
|
||||
{{* S'il y a plus d'une écriture de même montant on ne peut pas décider *}}
|
||||
{{if $count == 1}}
|
||||
{{if $immo_line.allocated_amount == $debit}}
|
||||
{{:continue}}
|
||||
{{/if}}
|
||||
|
||||
{{:assign var="immo_lines." value=$immo_line}}
|
||||
{{/select}}
|
||||
|
||||
{{* lister les immos incorporées de la balance d'ouverture *}}
|
||||
{{#load type="immo" where="$$.status='inprogress'" assign="unfinished_immo"}}
|
||||
{{* chercher l'écriture dont est tirée l'immo *}}
|
||||
{{#select
|
||||
trans.id as trans_id,
|
||||
line.id as immo_line_id,
|
||||
account.id as account_id,
|
||||
account.code as account_code,
|
||||
account.label as account_label,
|
||||
trans.id_year as trans_id_year
|
||||
FROM acc_transactions AS trans
|
||||
INNER JOIN acc_transactions_lines AS line ON line.id_transaction = trans.id
|
||||
INNER JOIN acc_accounts AS account ON line.id_account = account.id
|
||||
INNER JOIN acc_years AS years ON trans.id_year = years.id
|
||||
WHERE line.id = :unfinished_immo_line;
|
||||
:unfinished_immo_line = $unfinished_immo.line
|
||||
assign="immo_line"
|
||||
}}
|
||||
{{:assign var="immo_line.trans_label" value=$unfinished_immo.label}}
|
||||
{{:assign var="immo_line.trans_date" value=$unfinished_immo.date_achat}}
|
||||
{{:assign var="immo_line.debit" value=$unfinished_immo.amount}}
|
||||
{{:assign var="immo_line.doc_id" value=$id}}
|
||||
{{:assign var="immo_lines." value=$immo_line}}
|
||||
{{/select}}
|
||||
{{/load}}
|
||||
|
||||
<form method="post" action="">
|
||||
{{if $immo_lines|count > 0}}
|
||||
<fieldset class="shortFormLeft">
|
||||
|
|
@ -133,9 +168,10 @@
|
|||
</div>
|
||||
<div>
|
||||
<p class="submit">
|
||||
{{:linkbutton
|
||||
{{:button
|
||||
type="submit"
|
||||
name="transfer"
|
||||
label="Transférer"
|
||||
href="transfer.html?trans="
|
||||
shape="right"
|
||||
id="transfer"
|
||||
}}
|
||||
|
|
@ -148,7 +184,6 @@
|
|||
{{:input type="checkbox" value=1 name="unhide" checked="%s"|args:$checked label="Afficher les écritures ignorées" }}
|
||||
</fieldset>
|
||||
{{/if}}
|
||||
</form>
|
||||
|
||||
{{if $immo_lines|count > 0}}
|
||||
<section class="immobilisation">
|
||||
|
|
@ -160,6 +195,8 @@
|
|||
<th>Date</th>
|
||||
<th>Libellé</th>
|
||||
<th class="nombre">Montant</th>
|
||||
<th class="nombre">Affecté</th>
|
||||
<th class="nombre">Reste</th>
|
||||
<th>N° compte</th>
|
||||
<th>Compte</th>
|
||||
<th class="actions"></th>
|
||||
|
|
@ -174,21 +211,24 @@
|
|||
{{:assign total_immo="%d+%d"|math:$total_immo:$debit}}
|
||||
{{:assign var="montant" from="sommes_immo.%s"|args:$account_code}}
|
||||
{{:assign var="sommes_immo.%s"|args:$account_code value="%d+%d"|math:$montant:$debit}}
|
||||
{{:assign var="row_value" value=$trans_id|cat:"_"|cat:$doc_id}}
|
||||
|
||||
<tr {{if $ignore}}class="checked"{{/if}}>
|
||||
<td class="check">{{:input type="checkbox" name="selected[]" value=$trans_id}}</td>
|
||||
<tr {{if $ignore}}class="checked"{{/if}}{{if $allocated_amount > 0}}class="strong"{{/if}}>
|
||||
<td class="check">{{:input type="checkbox" name="selected[]" value=$doc_id}}</td>
|
||||
<td class="num"><a href="{{$trans_url}}">#{{$trans_id}}</a></td>
|
||||
<td>{{$trans_date|date_short}}</td>
|
||||
<td>{{$trans_label}}</td>
|
||||
<td class="money">{{"%f"|math:$debit|money_html:false|raw}}</td>
|
||||
<td class="money">{{"%f"|math:$allocated_amount|money_html:false|raw}}</td>
|
||||
<td class="money remainder">{{"%f-%f"|math:$debit:$allocated_amount|money_html:false|raw}}</td>
|
||||
<td class="account_code"><a href="{{$compte_url}}">{{$account_code}}</a></td>
|
||||
<td>{{$account_label}}</td>
|
||||
<td class="actions">
|
||||
{{:linkbutton
|
||||
label="Modifier"
|
||||
href="ignore.html?immo_line_id=%s"|args:$immo_line_id
|
||||
shape="edit"
|
||||
target="_dialog"
|
||||
label="Paramètres"
|
||||
href="add_infos.html?immo_line_id=%s"|args:$immo_line_id
|
||||
shape="settings"
|
||||
target="_dialog"
|
||||
}}
|
||||
</td>
|
||||
</tr>
|
||||
|
|
@ -226,6 +266,7 @@
|
|||
{{else}}
|
||||
<p class="block alert">Aucune écriture d'immobilisation trouvée dans la comptabilité (compte {{$first_code}} et sous-comptes)</p>
|
||||
{{/if}}
|
||||
</form>
|
||||
|
||||
<script type="text/javascript" src="scripts.js"></script>
|
||||
<script type="text/javascript" async="async">
|
||||
|
|
@ -244,7 +285,10 @@ function changeVisibility(evt, idcheck = 'f_unhide_1') {
|
|||
}
|
||||
|
||||
(function () {
|
||||
document.getElementById('f_unhide_1').onclick = changeVisibility;
|
||||
let unhide_button = document.getElementById('f_unhide_1');
|
||||
if (unhide_button != null) {
|
||||
unhide_button.onclick = changeVisibility;
|
||||
}
|
||||
})();
|
||||
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue