Compare commits
6 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
79c704a76a | ||
|
|
d344334179 | ||
|
|
515d24a004 | ||
|
|
8f09359180 | ||
|
|
c460f39c8c | ||
|
|
56e7703859 |
6 changed files with 269 additions and 1 deletions
34
_compare_version.tpl
Normal file
34
_compare_version.tpl
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
{{* -*- brindille -*- *}}
|
||||||
|
|
||||||
|
{{*
|
||||||
|
Comparer deux numéros de version n1.n2[.n3]
|
||||||
|
@param nv1
|
||||||
|
@param nv2
|
||||||
|
@result comp : -1 si nv1 < nv2, 0 si nv1 = nv2, 1 si nv1 > nv2
|
||||||
|
*}}
|
||||||
|
|
||||||
|
{{:assign nv1=$nv1|cat:"."}}
|
||||||
|
{{:assign nv2=$nv2|cat:"."}}
|
||||||
|
{{:assign var="tv1" value=$nv1|explode:"."}}
|
||||||
|
{{:assign var="tv2" value=$nv2|explode:"."}}
|
||||||
|
|
||||||
|
{{:assign comp=0}}
|
||||||
|
{{:assign i=0}}
|
||||||
|
{{#foreach from=$tv1 item="e1"}}
|
||||||
|
{{:assign var="e2" from="tv2.%d"|args:$i}}
|
||||||
|
{{if $e1 < $e2}}
|
||||||
|
{{:assign comp=-1}}
|
||||||
|
{{:break}}
|
||||||
|
{{elseif $e1 > $e2}}
|
||||||
|
{{:assign comp=1}}
|
||||||
|
{{:break}}
|
||||||
|
{{/if}}
|
||||||
|
{{:assign i="%d+1"|math:$i}}
|
||||||
|
{{/foreach}}
|
||||||
|
{{*
|
||||||
|
cas où le premier tableau a moins d'éléments que le 2ème
|
||||||
|
et où les éléments présents dans les deux tableaux sont identiques
|
||||||
|
*}}
|
||||||
|
{{if $comp == 0 && $tv1|count < $tv2|count}}
|
||||||
|
{{:assign comp = -1}}
|
||||||
|
{{/if}}
|
||||||
99
_upgrade_to031.tpl
Normal file
99
_upgrade_to031.tpl
Normal file
|
|
@ -0,0 +1,99 @@
|
||||||
|
{{* -*- brindille -*- *}}
|
||||||
|
|
||||||
|
{{*
|
||||||
|
Mettre à niveau vers v0.31
|
||||||
|
- créer un doc de liaison pour chaque amortissement lié à une immobilisation
|
||||||
|
mais uniquement pour les immo déjà gérées, sinon l'upgrade
|
||||||
|
vers 0.33 ne fonctionnera pas car on pourrait se retrouver avec
|
||||||
|
des liaisons immo <-> amort sans doc associé à l'immo donc la
|
||||||
|
transformation de link vers amort_link ne pourra se faire
|
||||||
|
|
||||||
|
- id ligne d'immobilisation
|
||||||
|
- id ligne d'amortissement
|
||||||
|
- id écriture d'amortissement
|
||||||
|
*}}
|
||||||
|
|
||||||
|
{{* lister les immobilisations *}}
|
||||||
|
{{:include file="_get_config.html" keep="module.config"}}
|
||||||
|
|
||||||
|
{{:assign account_condition="("}}
|
||||||
|
{{#foreach from=$module.config.prefixes item="code"}}
|
||||||
|
{{:assign code=$code|cat:"%"|quote_sql}}
|
||||||
|
{{:assign account_condition=$account_condition|cat:" account.code LIKE "|cat:$code|cat:" OR "}}
|
||||||
|
{{/foreach}}
|
||||||
|
{{:assign account_condition=$account_condition|cat:"0)"}}
|
||||||
|
|
||||||
|
{{:assign filter_condition=" AND NOT ("}}
|
||||||
|
{{#foreach from=$module.config.filters item="filter"}}
|
||||||
|
{{:assign filter="%"|cat:$filter|cat:"%"|quote_sql}}
|
||||||
|
{{:assign filter_condition=$filter_condition|cat:" trans.label LIKE "|cat:$filter|cat:" OR "}}
|
||||||
|
{{/foreach}}
|
||||||
|
{{:assign filter_condition=$filter_condition|cat:"0)"}}
|
||||||
|
|
||||||
|
{{:assign condition=$account_condition|cat:" AND debit > 0 AND NOT (trans.status & 16)"|cat:$filter_condition}}
|
||||||
|
|
||||||
|
{{#select
|
||||||
|
line.id as immo_line_id
|
||||||
|
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
|
||||||
|
ORDER BY trans.date DESC;
|
||||||
|
!condition=$condition
|
||||||
|
}}
|
||||||
|
{{* voir si l'immo est prise en charge *}}
|
||||||
|
{{#load type="immo" where="$$.line = :line_id" :line_id=$immo_line_id|intval}}
|
||||||
|
{{:assign status=$status}}
|
||||||
|
{{else}}
|
||||||
|
{{:assign status="unknown"}}
|
||||||
|
{{/load}}
|
||||||
|
|
||||||
|
{{* ne pas faire la liaison si pas de doc *}}
|
||||||
|
{{if $status == "ignored" || $status == "unknown"}}
|
||||||
|
{{:continue}}
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{* lister les écritures d'amortissement liées *}}
|
||||||
|
{{:assign amort_lines=null}}
|
||||||
|
{{#select
|
||||||
|
CASE links.id_related = t_immo.id
|
||||||
|
WHEN true THEN links.id_transaction
|
||||||
|
WHEN false THEN links.id_related
|
||||||
|
END as amort_trans_id,
|
||||||
|
l_amort.id AS amort_line_id
|
||||||
|
FROM acc_transactions_lines as l_immo
|
||||||
|
INNER JOIN acc_transactions as t_immo on t_immo.id = l_immo.id_transaction
|
||||||
|
INNER JOIN acc_transactions_links as links
|
||||||
|
ON (t_immo.id = links.id_transaction OR t_immo.id = links.id_related)
|
||||||
|
INNER JOIN acc_transactions_lines as l_amort on amort_trans_id = l_amort.id_transaction
|
||||||
|
INNER JOIN acc_accounts AS account ON l_amort.id_account = account.id
|
||||||
|
WHERE l_immo.id = :line_id AND l_amort.credit <> 0 AND account.code LIKE '28%';
|
||||||
|
:line_id = $immo_line_id|intval
|
||||||
|
assign="amort_lines."
|
||||||
|
}}
|
||||||
|
{{/select}}
|
||||||
|
|
||||||
|
{{#foreach from=$amort_lines item="line"}}
|
||||||
|
{{* chercher un doc associé *}}
|
||||||
|
{{#load type="link"
|
||||||
|
where="$$.immo_line_id = :immo_line_id
|
||||||
|
AND $$.amort_line_id = :amort_line_id
|
||||||
|
AND $$.amort_trans_id = :amort_trans_id"
|
||||||
|
:immo_line_id = $immo_line_id
|
||||||
|
:amort_line_id = $line.amort_line_id
|
||||||
|
:amort_trans_id = $line.amort_trans_id
|
||||||
|
assign="link"
|
||||||
|
}}
|
||||||
|
{{else}}
|
||||||
|
{{* pas de doc => le créer *}}
|
||||||
|
{{:save
|
||||||
|
key=""|uuid
|
||||||
|
type="link"
|
||||||
|
immo_line_id=$immo_line_id
|
||||||
|
amort_line_id=$line.amort_line_id
|
||||||
|
amort_trans_id=$line.amort_trans_id
|
||||||
|
}}
|
||||||
|
{{/load}}
|
||||||
|
{{/foreach}}
|
||||||
|
{{/select}}
|
||||||
64
_upgrade_to033.tpl
Normal file
64
_upgrade_to033.tpl
Normal file
|
|
@ -0,0 +1,64 @@
|
||||||
|
{{* -*- brindille -*- *}}
|
||||||
|
|
||||||
|
{{*
|
||||||
|
Mettre à niveau vers v0.33, pour gérer les écritures du bilan d'ouverture
|
||||||
|
où le montant d'une ligne d'immo ou d'une ligne d'amort peut être
|
||||||
|
réparti entre plusieurs immo et plusieurs amort
|
||||||
|
|
||||||
|
- modifier le doc d'immo
|
||||||
|
- date => date_mes (date mise en service)
|
||||||
|
|
||||||
|
- modifier le doc de liaison d'amortissement
|
||||||
|
- id ligne d'immobilisation => id doc immobilisation
|
||||||
|
- id ligne d'amortissement
|
||||||
|
- id écriture d'amortissement
|
||||||
|
- ajouter montant amortissement
|
||||||
|
*}}
|
||||||
|
|
||||||
|
{{* doc immo *}}
|
||||||
|
{{#load type="immo" assign="elem"}}
|
||||||
|
{{if $elem.date != null}}
|
||||||
|
{{:assign var="elem.date_mes" value=$elem.date}}
|
||||||
|
{{:assign var="docs." value=$elem}}
|
||||||
|
{{:delete id=$elem.id}}
|
||||||
|
{{/if}}
|
||||||
|
{{/load}}
|
||||||
|
|
||||||
|
{{* créer les nouveaux documents *}}
|
||||||
|
{{#foreach from=$docs item="doc"}}
|
||||||
|
{{:save
|
||||||
|
key=""|uuid
|
||||||
|
type=$doc.type
|
||||||
|
line=$doc.line
|
||||||
|
duration=$doc.duration
|
||||||
|
label=$doc.label
|
||||||
|
amount=$doc.amount
|
||||||
|
date_achat=$doc.date_achat
|
||||||
|
date_mes=$doc.date_mes
|
||||||
|
status=$doc.status
|
||||||
|
}}
|
||||||
|
{{/foreach}}
|
||||||
|
|
||||||
|
{{* lister les liaisons actuelles ligne amort => ligne immo *}}
|
||||||
|
{{#load type="link" assign="link"}}
|
||||||
|
{{#load type="immo" where="$$.line = :immo_line_id" :immo_line_id=$link.immo_line_id assign="immo"}}
|
||||||
|
{{:assign link_doc=null}}
|
||||||
|
{{:assign var="link_doc.immo_doc_id" value=$immo.id}}
|
||||||
|
{{:assign var="link_doc.amort_line_id" value=$link.amort_line_id}}
|
||||||
|
{{:assign var="link_docs." value=$link_doc}}
|
||||||
|
{{else}}
|
||||||
|
{{* liaison orpheline : ignorer *}}
|
||||||
|
{{/load}}
|
||||||
|
{{:delete id=$link.id}}
|
||||||
|
{{/load}}
|
||||||
|
|
||||||
|
{{* créer les nouvelles liaisons *}}
|
||||||
|
{{#foreach from=$link_docs item="link"}}
|
||||||
|
{{:save
|
||||||
|
key=""|uuid
|
||||||
|
type="amort_link"
|
||||||
|
immo_doc_id=$link.immo_doc_id
|
||||||
|
amort_line_id=$link.amort_line_id
|
||||||
|
amount=null
|
||||||
|
}}
|
||||||
|
{{/foreach}}
|
||||||
22
config.html
22
config.html
|
|
@ -129,6 +129,28 @@
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
<form method="post" action="">
|
<form method="post" action="">
|
||||||
|
{{* Nouvelle version ? *}}
|
||||||
|
{{:include file="_get_module_version.tpl" keep="module_version"}}
|
||||||
|
{{:include file="_compare_version.tpl" nv1=$module_version nv2=$module.config.version keep="comp"}}
|
||||||
|
|
||||||
|
{{if $comp > 0}}
|
||||||
|
<fieldset>
|
||||||
|
<legend>Mettre à niveau le module</legend>
|
||||||
|
<p class="block alert">
|
||||||
|
Une nouvelle version du module {{$module.label}}
|
||||||
|
est disponible ; veuillez cliquer sur le buton
|
||||||
|
« Mettre à niveau le module » pour effectuer la
|
||||||
|
mise à niveau
|
||||||
|
</p>
|
||||||
|
{{:linkbutton
|
||||||
|
label="Mettre à niveau le module"
|
||||||
|
href="upgrade.html"
|
||||||
|
shape="reset"
|
||||||
|
class="main"
|
||||||
|
}}
|
||||||
|
</fieldset>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
<h3>Comptes d'immobilisation amortissables</h3>
|
<h3>Comptes d'immobilisation amortissables</h3>
|
||||||
<p class="help">
|
<p class="help">
|
||||||
Les immobilisations amortissables sont cherchées dans les comptes sélectionnés et leurs sous-comptes.
|
Les immobilisations amortissables sont cherchées dans les comptes sélectionnés et leurs sous-comptes.
|
||||||
|
|
|
||||||
|
|
@ -46,5 +46,4 @@
|
||||||
{{elseif $type_immo == "managed" || $type_immo == "amortized"}}
|
{{elseif $type_immo == "managed" || $type_immo == "amortized"}}
|
||||||
{{:include file="_immobilisations.html"}}
|
{{:include file="_immobilisations.html"}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{:admin_footer}}
|
{{:admin_footer}}
|
||||||
|
|
|
||||||
50
upgrade.html
Normal file
50
upgrade.html
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
{{* -*- brindille -*- *}}
|
||||||
|
|
||||||
|
{{*
|
||||||
|
mise à niveau des documents selon version
|
||||||
|
*}}
|
||||||
|
|
||||||
|
{{:admin_header title="Mise à niveau" custom_css="./style.css" current="module_amortization"}}
|
||||||
|
|
||||||
|
{{* numéro de version du module *}}
|
||||||
|
{{:include file="_get_module_version.tpl" keep="module_version"}}
|
||||||
|
|
||||||
|
{{* version 0.31 *}}
|
||||||
|
{{:assign tag="0.31"}}
|
||||||
|
|
||||||
|
{{:include file="_compare_version.tpl" nv1=$module_version nv2=$tag keep="comp"}}
|
||||||
|
{{:assign module_comp=$comp}}
|
||||||
|
{{:include file="_compare_version.tpl" nv1=$module.config.version nv2=$tag keep="comp"}}
|
||||||
|
{{:assign config_comp=$comp}}
|
||||||
|
|
||||||
|
{{if $module_comp >= 0 && $config_comp < 0}}
|
||||||
|
{{* $module_version >= '0.31' && $module.config.version < '0.31' *}}
|
||||||
|
|
||||||
|
{{:include file="_upgrade_to031.tpl"}}
|
||||||
|
<p class="block info">Mise à jour vers version {{$tag}} terminée</p>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{* version 0.33 *}}
|
||||||
|
{{:assign tag="0.33"}}
|
||||||
|
|
||||||
|
{{:include file="_compare_version.tpl" nv1=$module_version nv2=$tag keep="comp"}}
|
||||||
|
{{:assign module_comp=$comp}}
|
||||||
|
{{:include file="_compare_version.tpl" nv1=$module.config.version nv2=$tag keep="comp"}}
|
||||||
|
{{:assign config_comp=$comp}}
|
||||||
|
|
||||||
|
{{if $module_comp >= 0 && $config_comp < 0}}
|
||||||
|
{{* $module_version >= '0.33' && $module.config.version < '0.33' *}}
|
||||||
|
|
||||||
|
{{:include file="_upgrade_to033.tpl"}}
|
||||||
|
<p class="block info">Mise à jour vers version {{$tag}} terminée</p>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{* enregistrer le nouveau numéro de version dans la config du module *}}
|
||||||
|
{{:include file="_compare_version.tpl" nv1=$module_version nv2=$module.config.version keep="comp"}}
|
||||||
|
{{if $comp > 0}}
|
||||||
|
{{:save key="config" version=$module_version}}
|
||||||
|
<p class="block alert">Nouvelle version enregistrée : {{$module_version}}</p>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{:linkbutton label="Revenir à la page d'accueil du module" href="index.html" shape="right"}}
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue