diff --git a/add_asset.html b/add_asset.html index dad1351..5586043 100644 --- a/add_asset.html +++ b/add_asset.html @@ -7,7 +7,6 @@ {{* Traiter l'envoi du formulaire *}} {{#form on="add"}} - {{* :debug POST=$_POST *}} {{* enregistrer l'écriture *}} {{:assign var="credit_accounts" value=$_POST.credit_account|keys}} @@ -15,9 +14,6 @@ {{:assign var="debit_accounts" value=$_POST.debit_account|keys}} {{:assign var="debit_account" value=$debit_accounts.0}} - {{* :debug credit_account=$credit_account *}} - {{* :debug debit_account=$debit_account *}} - {{:api method="POST" path="accounting/transaction" @@ -29,17 +25,11 @@ amount=$_POST.montant debit=$debit_account credit=$credit_account + id_project=$_POST.id_project }} - {{* :debug result=$result *}} - {{* enregistrer les infos de l'immobilisation *}} - {{* :debug lines=$result.lines *}} - {{* :debug line1=$result.lines.1 *}} - {{:assign var="line_id" value=$result.lines.1.id}} - {{* :debug line_id=$line_id *}} - {{:assign key=""|uuid}} {{:save key=$key @@ -57,7 +47,7 @@ {{:assign var="bank_account.512A" value="512A — Compte courant"}} {{#years closed=false}} {{:assign var="open_years.%d"|args:$id value=$label}} - {{if $start_date <= $now && $end_date >= $now}} + {{if $start_date|strtotime <= $now && $end_date|strtotime >= $now}} {{:assign best_year=$id}} {{/if}} {{/years}} @@ -66,9 +56,13 @@ {{* TODO - - ajouter projet et autres rubriques selon besoin + - ajouter autres rubriques selon besoin *}} +{{#select id,label FROM acc_projects WHERE archived = 0;}} + {{:assign var="projects.%d"|args:$id value=$label}} +{{/select}} +
Ajouter une immobilisation @@ -93,6 +87,9 @@ required=true target="!acc/charts/accounts/selector.php?key=code&year=%d"|args:$best_year }} + {{if $projects != null}} + {{:input type="select" name="id_project" label="Projet (analytique)" options=$projects default_empty="— Aucun —"}} + {{/if}}
diff --git a/amortization.html b/amortization.html index 3e30292..6a63ffc 100644 --- a/amortization.html +++ b/amortization.html @@ -13,27 +13,28 @@ {{#select line.id as line_id, line.id_account as account_id, + line.id_project as project_id, trans.id as trans_id, line.debit as montant, trans.label as label, trans.date as date_achat, y.id as year_id, - y.end_date as date_fin + y.end_date as date_fin, + project.label as project_label from acc_transactions_lines as line inner join acc_transactions as trans on line.id_transaction = trans.id inner join acc_years as y on trans.id_year = y.id + left join acc_projects AS project ON line.id_project = project.id where line.id = :line_id; :line_id = $_GET.line|intval assign=ligne_immo }} -

Amortissement de « {{$label}} » d'un montant de {{"%f"|math:$montant|money_currency}} en date du {{$date_achat|date_short}}

+

Amortissement de « {{$label}} » d'un montant de {{"%f"|math:$montant|money_currency}} en date du {{$date_achat|date_short}} sur {{$info_immo.duration}} ans

{{else}} {{:assign message="Immobilisation %s non trouvée"|args:$_GET.line}} {{:error message=$message}} {{/select}} -{{*:debug ligne_immo=$ligne_immo*}} - {{* lister les écritures d'amortissement *}} {{#select line.id as l_immo, @@ -45,6 +46,8 @@ line2.id_transaction as trans_id, line2.id_project as projet, line2.id_account as account_id, + line2.id_project as project_id, + project.label as project_label, trans.date as date_immo, acc.code as account_code, acc.label as nom_compte, @@ -54,6 +57,7 @@ inner JOIN acc_transactions_lines as line2 on links.id_transaction = line2.id_transaction inner join acc_accounts as acc on line2.id_account = acc.id inner join acc_transactions as trans on line2.id_transaction = trans.id + left join acc_projects AS project ON line.id_project = project.id where line.id = :line_id and line2.debit <> 0 order by trans.date; :line_id = $info_immo.line|intval @@ -61,16 +65,11 @@ }} {{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$trans_id}} {{/select}} -{{*:debug lines=$lines*}} -{{*:debug line=$lines.0*}} -{{*:debug line=$lines.1*}} {{* calculer les amortissements *}} {{* montant de l'annuité normale *}} {{:assign montant="%f"|math:$ligne_immo.montant}} {{:assign annuite="%f/%f"|math:$montant:$info_immo.duration|intval}} -{{*:debug montant=$montant *}} -{{*:debug annuite=$annuite *}} {{* liste des exercices *}} {{#years}} @@ -79,24 +78,18 @@ {{:assign var="all_years.%d.closed"|args:$id value=$closed}} {{/years}} -{{* -{{:debug all_years=$all_years}} -{{:assign current_year=8}} -{{:assign var="date_immo" from="all_years.%s.end_date"|args:$current_year}} -{{:debug date_immo=$date_immo}} -*}} - {{* première annuité *}} {{:assign date_achat=$ligne_immo.date_achat|date_short}} {{:assign date_fin=$ligne_immo.date_fin|date_short}} {{:include file="_calcul_dates.html" date_debut=$date_achat date_fin=$date_fin keep="nbjours"}} {{:assign annuite_1="%f/360*%d"|math:$annuite:$nbjours|intval}} -{{*:debug annuite1=$annuite_1 *}} {{:assign date_immo=$date_fin}} {{:assign annuite_courante=$annuite_1}} {{:assign solde=$montant}} {{:assign current_year=$ligne_immo.year_id}} +{{:assign project_id=$ligne_immo.project_id}} +{{:assign project_label=$ligne_immo.project_label}}

Liste des amortissements

@@ -108,16 +101,15 @@ Montant Solde Libellé - ligne amort + N° compte Compte - Nom compte + Projet {{#foreach count="%d+1"|math:$info_immo.duration|intval key="num"}} {{:assign var="line" from="lines.%s"|args:$num}} - {{*:debug line=$line*}} {{if $line != null}} {{* données de l'écriture *}} @@ -129,13 +121,15 @@ {{"%f"|math:$line.montant|money}} {{"%f"|math:$solde|money}} {{$line.libelle}} - {{$line.l_amort}} {{$line.account_code}} {{$line.nom_compte}} + {{$line.project_label}} {{:assign libelle=$line.libelle}} {{:assign ammort_account=$line.ammort_account}} + {{:assign project_id=$line.project_id}} + {{:assign project_label=$line.project_label}} {{:assign annuite_courante="min(%f,%f)"|math:$annuite:$solde}} {{:assign current_year="%d+1"|math:$current_year}} {{:assign date_immo=$line.date_immo}} @@ -167,14 +161,16 @@ - + {{$project_label}} {{if $all_years|keys|has:$current_year}} {{:linkbutton label="Enregistrer" - href="save_amort.html?amount=%d&account=%s&year=%s&label=%s"|args:$annuite_courante:$ligne_immo.account_id:$current_year:$libelle + href="save_amort.html?amount=%d&account=%s&year=%s&trans_id=%d&line_id=%s&project_id=%d&label=%s"|args:$annuite_courante:$ligne_immo.account_id:$current_year:$ligne_immo.trans_id:$_GET.line:$project_id:$libelle shape="right" }} + {{else}} + {{:linkbutton label="Enregistrer" href="" shape="alert"}} {{/if}} diff --git a/index.html b/index.html index dd6d783..e9d12e5 100644 --- a/index.html +++ b/index.html @@ -4,12 +4,11 @@ {{:include file="_nav.html" current="index"}} {{if $_GET.ok}} -

Modification effectuée

+

Immobilisation enregistrée

{{elseif $_GET.err}} -

Modification refusée

+

Enregistrement immobilisation refusée

{{/if}} - {{* lister les immobilisations *}}

Liste des immobilisations

@@ -17,21 +16,20 @@ - - + - + + + - + {{* - TODO améliorer cette requête : - - ne pas mettre l'id du PC - - voir si assez général + TODO améliorer cette requête : voir si assez général *}} {{#select @@ -41,27 +39,28 @@ line.id as line_id, account.code as account_code, account.label as account_label, - line.debit AS debit + line.debit AS debit, + project.label as project_label 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 - LEFT JOIN acc_projects AS proj ON line.id_project = proj.id + LEFT JOIN acc_projects AS project ON line.id_project = project.id WHERE - account.id_chart = "3" - AND (account.code LIKE '21%' OR account.code LIKE '22%') ORDER BY trans.date DESC }} {{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$trans_id}} + {{#load type="immo" assign="info_immo" where="$$.line = :line_id" :line_id=$line_id|intval}}{{/load}} - - + + + - +
IdLibellé Dateid_lineLibelléMontantDurée N° compte CompteMontantProjet
#{{$trans_id}}{{$trans_label}} {{$trans_date|date_short}}{{$line_id}}{{$trans_label}}{{"%f"|math:$debit|money}}{{$info_immo.duration}} {{$account_code}} {{$account_label}}{{"%f"|math:$debit|money}}{{$project_label}} {{:linkbutton label="Amortissements" @@ -88,42 +87,4 @@ - -{{* sélectionner un compte *}} -

TEST

- -{{:assign var="ll.0.d" value="%f/100"|math:$debit}} -{{:assign var="ll.1.c" value="%f/100"|math:$debit}} -{{* :debug ll=$ll *}} -{{:assign - var="qs" - t=0 - l="Amortissement de %s"|args:$trans_label - dt=$trans_date - a00=0 - ll=$ll -}} -{{:assign qs=$qs|http_build_query}} -{{:linkbutton - label="Ajouter" - href="!acc/transactions/new.php?%s"|args:$qs - shape="plus" - target="_dialog" -}} - -
-
- Écriture de note de frais - {{:assign var="default_account.625" value="625 Déplacements, missions et réceptions"}} - {{:input - type="list" - name="account" - label="Compte de paiement" - required=true - target="!acc/charts/accounts/selector.php?targets=5&key=code&year=%d"|args:7 - default=$default_account - }} -
-
- {{:admin_footer}}