From 9fe789071898538072051d79bc41e652f3d2d486 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Engel Date: Wed, 21 May 2025 15:06:23 +0200 Subject: [PATCH] =?UTF-8?q?R=C3=A9organisation=20r=C3=A9cup=C3=A9ration=20?= =?UTF-8?q?infos=20comptes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- archives.html | 1 + write_exit.html | 110 ++++++++++++++++++++++++++++-------------------- 2 files changed, 66 insertions(+), 45 deletions(-) diff --git a/archives.html b/archives.html index 9160b73..2607147 100644 --- a/archives.html +++ b/archives.html @@ -24,6 +24,7 @@ {{#load type="immo" where="$$.status = 'archived'"}} {{:assign var="lines." value="'%s'"|args:$line}} {{/load}} +{{:debug lines=$lines}} {{:assign lines=$lines|implode:","}} {{:assign lines="("|cat:$lines|cat:")"}} {{:assign condition="line.id IN %s"|args:$lines}} diff --git a/write_exit.html b/write_exit.html index 95f4045..4703b9f 100644 --- a/write_exit.html +++ b/write_exit.html @@ -19,9 +19,11 @@ line.id_account, trans.date as date_achat, trans.label, + acc.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_id; :immo_id = $_GET.immo_id|intval assign="ligne_immo" @@ -33,18 +35,18 @@ {{* date de début de l'exercice *}} {{#select start_date FROM acc_years WHERE id = :year_id; :year_id = $_GET.year}} - {{*:assign date_debut=$start_date*}} -{{/select}} - -{{*if $date_debut < "2025-01-01"*}} - {{:assign vnc_code=675}} - {{:assign cession_code=775}} {{* -{{else}} - {{:assign vnc_code=657}} - {{:assign cession_code=757}} -{{/if}} + {{if $start_date < "2025-01-01" *}} + {{:assign vnc_code="675"}} + {{:assign cession_code="775"}} +{{* + {{else}} + {{:assign vnc_code="657"}} + {{:assign cession_code="757"}} + {{/if}} +*}} +{{/select}} {{:assign valeur_nette="%f-%f"|math:$ligne_immo.montant:$_GET.amort_amount}} {{:assign amort_comp=0}} {{* amortissement complémentaire jqà date sortie *}} @@ -68,7 +70,6 @@ {{* TODO : faut-il forcer les 3 sélecteurs de compte d'amortissement à avoir toujours la même valeur ? *}} - {{* Traiter l'envoi du formulaire *}} {{#form on="save"}} {{* @@ -87,7 +88,7 @@ account=$account keep="account_code" }} - {{:assign amort_account=$account_code|keys|key:0}} + {{:assign amort_account_code=$account_code|keys|key:0}} {{if $valeur_nette > 0}} {{* immo non totalement amortie *}} @@ -98,20 +99,20 @@ account=$_POST.comp_account keep="account_code" }} - {{:assign comp_account=$account_code|keys|key:0}} + {{:assign comp_account_code=$account_code|keys|key:0}} {{:assign libelle="Amortissement complémentaire "|cat:$ligne_immo.label}} {{:assign var="lines." debit="%f/100"|math:$amort_comp - account=$comp_account + account=$comp_account_code id_project=$ligne_immo.id_project label=$libelle }} {{:assign var="lines." credit="%f/100"|math:$amort_comp - account=$amort_account + account=$amort_account_code id_project=$ligne_immo.id_project label=$libelle }} @@ -124,19 +125,19 @@ account=$_POST.except_account keep="account_code" }} - {{:assign except_account=$account_code|keys|key:0}} + {{:assign except_account_code=$account_code|keys|key:0}} {{:assign libelle="Amortissement exceptionnel "|cat:$ligne_immo.label}} {{:assign var="lines." debit="%f/100"|math:$amort_except - account=$except_account + account=$except_account_code id_project=$ligne_immo.id_project label=$libelle }} {{:assign var="lines." credit="%f/100"|math:$amort_except - account=$amort_account + account=$amort_account_code id_project=$ligne_immo.id_project label=$libelle }} @@ -158,26 +159,38 @@ {{/if}} {{* écriture de sortie du bilan *}} - {{:assign libelle="Sortie du bilan de "|cat:$ligne_immo.label}} {{:assign lines=null}} + {{:include + file="_get_codes.html" + account=$_POST.immo_account + keep="account_code" + }} + {{:assign immo_account_code=$account_code|keys|key:0}} + {{:assign libelle="Sortie du bilan de "|cat:$ligne_immo.label}} {{:assign var="lines." - id_account=$ligne_immo.id_account + account=$immo_account_code credit="%f/100"|math:$ligne_immo.montant id_project=$ligne_immo.id_project label=$libelle }} {{:assign var="lines." - account=$amort_account + account=$amort_account_code debit="(%f-%f)/100"|math:$ligne_immo.montant:$valeur_nette id_project=$ligne_immo.id_project label=$libelle }} {{if $valeur_nette > 0}} + {{:include + file="_get_codes.html" + account=$_POST.vnc_account + keep="account_code" + }} + {{:assign vnc_account_code=$account_code|keys|key:0}} {{:assign var="lines." - account=$vnc_code + account=$vnc_account_code debit="%f/100"|math:$valeur_nette id_project=$ligne_immo.id_project label=$libelle @@ -261,33 +274,40 @@ {{* Préparer les infos pour le formulaire *}} {{* déterminer les comptes pour les différentes écritures *}} -{{:assign var="comp_account.6811" value="6811 — Dot. aux amortissements des immobilisations"}} -{{:assign var="except_account.687" value="687 — Dot. aux amortissements & provisions - Charges exceptionnelles"}} - -{{#select code, label from acc_accounts where id = :id; - :id=$ligne_immo.id_account - assign=immo_account_info -}} -{{/select}} - {{:include file="./_get_amort_code.html" - code_immo=$immo_account_info.code + code_immo=$ligne_immo.code keep="code_amort" }} -{{:assign - var="amort_account.%s"|args:$code_amort - value="%s — Amortissements "|args:$code_amort|cat:$immo_account_info.label}} -{{:assign - var="immo_account.%s"|args:$immo_account_info.code - value="%s — Immobilisation "|args::$immo_account_info.code|cat:$immo_account_info.label}} -{{:assign - var="vnc_account.%s"|args:$vnc_code - value="%s — Valeurs comptables des éléments d'actifs cédés"|args:$vnc_code}} -{{:assign - var="cession_account.%s"|args:$cession_code - value="%s — Produits des cessions d'actif"|args:$cession_code}} -{{:assign var="creance_account.462" value="462 — Créances sur cessions d'immobilisations"}} +{{:assign var="liste_codes.6811" name="comp_account"}} +{{:assign var="liste_codes.687" name="except_account"}} +{{:assign var="liste_codes.462" name="creance_account"}} +{{:assign var="liste_codes.%s"|args:$code_amort name="amort_account"}} +{{:assign var="liste_codes.%s"|args:$ligne_immo.code name="immo_account"}} +{{:assign var="liste_codes.%s"|args:$vnc_code name="vnc_account"}} +{{:assign var="liste_codes.%s"|args:$cession_code name="cession_account"}} +{{:assign condition=$liste_codes|keys|implode:","}} +{{:assign condition="acc.code IN ("|cat:$condition|cat:")"}} + +{{#select + acc.id, + acc.code as acc_code, + acc.label as acc_label, + year.label as year_label + FROM acc_accounts as acc + INNER JOIN acc_charts as chart ON chart.id = acc.id_chart + INNER JOIN acc_years as year ON chart.id = year.id_chart + WHERE year.id = 1 AND !condition; + !condition=$condition +}} + {{:assign var="liste_codes.%s.id"|args:$acc_code value=$id}} + {{:assign var="liste_codes.%s.acc_label"|args:$acc_code value=$acc_label}} + {{:assign var="liste_codes.%s.year_label"|args:$acc_code value=$year_label}} +{{/select}} + +{{#foreach from=$liste_codes key=code}} + {{:assign var="%s.%s"|args:$name:$code value="%s — %s"|args:$code:$acc_label}} +{{/foreach}} {{:read file="./defaut.json" assign="config_json"}} {{:assign config_defaut=$config_json|json_decode}}