Index: src/include/data/1.0.0_migration.sql
==================================================================
--- src/include/data/1.0.0_migration.sql
+++ src/include/data/1.0.0_migration.sql
@@ -8,24 +8,24 @@
.read 1.0.0_schema.sql
-- FIXME: insertion en comptes analytiques des projets et associations dans transactions
-INSERT INTO acc_plans (id, country, code, label) VALUES (1, 'FR', 'PCGA1999', 'Plan comptable associatif 1999');
+INSERT INTO acc_charts (id, country, code, label) VALUES (1, 'FR', 'PCGA1999', 'Plan comptable associatif 1999');
--.read plan_comptable_1999.sql
--.read plan_comptable_2020.sql
-- Migration comptes de code comme identifiant à ID unique
-INSERT INTO acc_accounts (id, id_plan, code, label, position, user)
+INSERT INTO acc_accounts (id, id_chart, code, label, position, user)
SELECT NULL, 1, id, libelle, position, CASE WHEN plan_comptable = 1 THEN 0 ELSE 1 END FROM compta_comptes;
-- Migrations projets vers comptes analytiques
-INSERT INTO acc_accounts (id_plan, code, label, position, user, type)
- VALUES (1, '99', 'Projets', 0, 1, 4);
+INSERT INTO acc_accounts (id_chart, code, label, position, user, type)
+ VALUES (1, '99', 'Projets', 0, 1, 0);
-INSERT INTO acc_accounts (id_plan, code, label, position, user, type)
+INSERT INTO acc_accounts (id_chart, code, label, position, user, type)
SELECT 1, '99' || substr('0000' || id, -4), libelle, 0, 1, 4 FROM compta_projets;
-- Suppression des positions "actif ou passif" et "charge ou produit"
UPDATE acc_accounts SET position = 0 WHERE position = 3 OR position = 12;
@@ -67,11 +67,11 @@
SELECT * FROM membres_operations_old;
-- FIXME: ajout d'entrées dans le le log utilisateur à partir de id_auteur
-- Recopie des exercices, mais la date de fin ne peut être nulle
-INSERT INTO acc_years (id, label, start_date, end_date, closed, id_plan)
+INSERT INTO acc_years (id, label, start_date, end_date, closed, id_chart)
SELECT id, libelle, debut, CASE WHEN fin IS NULL THEN date(debut, '+1 year') ELSE fin END, cloture, 1 FROM compta_exercices;
-- Recopie des catégories, on supprime la colonne id_cotisation_obligatoire
INSERT INTO membres_categories
SELECT id, nom, droit_wiki, droit_membres, droit_compta, droit_inscription, droit_connexion, droit_config, cacher FROM membres_categories_old;
Index: src/include/data/1.0.0_schema.sql
==================================================================
--- src/include/data/1.0.0_schema.sql
+++ src/include/data/1.0.0_schema.sql
@@ -178,24 +178,25 @@
--
-- COMPTA
--
-CREATE TABLE IF NOT EXISTS acc_plans
+CREATE TABLE IF NOT EXISTS acc_charts
-- Plans comptables : il peut y en avoir plusieurs
(
id INTEGER NOT NULL PRIMARY KEY,
country TEXT NOT NULL,
code TEXT NULL, -- NULL = plan comptable créé par l'utilisateur
- label TEXT NOT NULL
+ label TEXT NOT NULL,
+ archived INTEGER NOT NULL DEFAULT 0 -- 1 = archivé, non-modifiable
);
CREATE TABLE IF NOT EXISTS acc_accounts
-- Comptes des plans comptables
(
id INTEGER NOT NULL PRIMARY KEY,
- id_plan INTEGER NOT NULL REFERENCES acc_plans,
+ id_chart INTEGER NOT NULL REFERENCES acc_charts,
code TEXT NOT NULL, -- peut contenir des lettres, eg. 53A, 53B, etc.
label TEXT NOT NULL,
description TEXT NULL,
@@ -203,11 +204,11 @@
position INTEGER NOT NULL, -- position actif/passif/charge/produit
type INTEGER NOT NULL DEFAULT 0, -- Type de compte spécial : banque, caisse, en attente d'encaissement, favori, etc.
user INTEGER NOT NULL DEFAULT 1 -- 1 = fait partie du plan comptable original, 0 = a été ajouté par l'utilisateur
);
-CREATE UNIQUE INDEX IF NOT EXISTS acc_accounts_codes ON acc_accounts (code, id_plan);
+CREATE UNIQUE INDEX IF NOT EXISTS acc_accounts_codes ON acc_accounts (code, id_chart);
CREATE TABLE IF NOT EXISTS acc_years
-- Exercices
(
id INTEGER NOT NULL PRIMARY KEY,
@@ -217,11 +218,11 @@
start_date TEXT NOT NULL CHECK (date(start_date) IS NOT NULL AND date(start_date) = start_date),
end_date TEXT NOT NULL CHECK (date(end_date) IS NOT NULL AND date(end_date) = end_date),
closed INTEGER NOT NULL DEFAULT 0,
- id_plan INTEGER NOT NULL REFERENCES acc_plans (id)
+ id_chart INTEGER NOT NULL REFERENCES acc_charts (id)
);
CREATE TABLE IF NOT EXISTS acc_transactions
-- Opérations comptables
(
Index: src/include/lib/Garradin/Entities/Accounting/Account.php
==================================================================
--- src/include/lib/Garradin/Entities/Accounting/Account.php
+++ src/include/lib/Garradin/Entities/Accounting/Account.php
@@ -54,34 +54,34 @@
'Bénévolat',
'Favori',
];
protected $id;
- protected $id_plan;
+ protected $id_chart;
protected $code;
protected $label;
protected $description;
protected $position;
protected $type;
protected $user;
protected $_types = [
'id' => 'int',
- 'id_plan' => 'int',
+ 'id_chart' => 'int',
'code' => 'string',
'label' => 'string',
'description' => '?string',
'position' => 'int',
'type' => 'int',
'user' => 'int',
];
protected $_validation_rules = [
- 'id_plan' => 'required|integer|in_table:acc_plans,id',
+ 'id_chart' => 'required|integer|in_table:acc_charts,id',
'code' => 'required|string|alpha_num|max:6',
'label' => 'required|string|max:200',
'description' => 'string|max:2000',
'position' => 'required|integer',
'type' => 'required|integer',
'user' => 'integer|min:0|max:1',
];
}
ADDED src/include/lib/Garradin/Entities/Accounting/Chart.php
Index: src/include/lib/Garradin/Entities/Accounting/Chart.php
==================================================================
--- src/include/lib/Garradin/Entities/Accounting/Chart.php
+++ src/include/lib/Garradin/Entities/Accounting/Chart.php
@@ -0,0 +1,37 @@
+ 'integer',
+ 'label' => 'string',
+ 'country' => 'string',
+ 'code' => '?string',
+ 'archived' => 'integer',
+ ];
+
+ protected $_validation_rules = [
+ 'label' => 'required|string|max:200',
+ 'country' => 'required|string|size:2',
+ 'code' => 'string',
+ 'archived' => 'integer|required|max:1|min:0',
+ ];
+
+ public function selfCheck(): void
+ {
+ parent::selfCheck();
+ $this->assert(Utils::getCountryName($this->country), 'Le code pays doit être un code ISO valide');
+ }
+}
DELETED src/include/lib/Garradin/Entities/Accounting/Plan.php
Index: src/include/lib/Garradin/Entities/Accounting/Plan.php
==================================================================
--- src/include/lib/Garradin/Entities/Accounting/Plan.php
+++ src/include/lib/Garradin/Entities/Accounting/Plan.php
@@ -1,37 +0,0 @@
- 'integer',
- 'label' => 'string',
- 'country' => 'string',
- 'code' => '?string',
- ];
-
- protected $_validation_rules = [
- 'label' => 'required|string|max:200',
- 'country' => 'required|string|size:2',
- 'code' => 'string',
- ];
-
- public function selfCheck(): void
- {
- parent::selfCheck();
- $this->assert(Utils::getCountryName($this->country), 'Le code pays doit être un code ISO valide');
- }
-}
Index: src/templates/admin/_head.tpl
==================================================================
--- src/templates/admin/_head.tpl
+++ src/templates/admin/_head.tpl
@@ -81,11 +81,11 @@
Saisie
{/if}
Journaux
Exercices & rapports
{if $session->canAccess('compta', Membres::DROIT_ADMIN)}
- Plans comptables
+ Plans comptables
{/if}
{/if}
{if $session->canAccess('wiki', Membres::DROIT_ACCES)}
ADDED src/templates/admin/acc/accounts/index.tpl
Index: src/templates/admin/acc/accounts/index.tpl
==================================================================
--- src/templates/admin/acc/accounts/index.tpl
+++ src/templates/admin/acc/accounts/index.tpl
@@ -0,0 +1,56 @@
+{include file="admin/_head.tpl" title=$chart.label current="acc/charts"}
+
+
+
+{if count($accounts)}
+
+
+ Code |
+ Libellé |
+ Position |
+ |
+ |
+
+
+ {foreach from=$accounts item="item"}
+
+ {$item.code} |
+ {$item.label} |
+ {$item.position|account_position} |
+
+ {if $item.type == $item::TYPE_BOOKMARK}{icon shape="star"}{/if}
+ {$item.type|account_type}
+ |
+
+ {if $item.user}
+ {icon shape="delete" label="Supprimer" href="acc/charts/accounts/delete.php?id=%d"|args:$item.id}
+ {/if}
+ {icon shape="edit" label="Modifier" href="acc/charts/accounts/edit.php?id=%d"|args:$item.id}
+ |
+
+ {/foreach}
+
+
+{/if}
+
+
+
+{include file="admin/_foot.tpl"}
ADDED src/templates/admin/acc/charts/index.tpl
Index: src/templates/admin/acc/charts/index.tpl
==================================================================
--- src/templates/admin/acc/charts/index.tpl
+++ src/templates/admin/acc/charts/index.tpl
@@ -0,0 +1,51 @@
+{include file="admin/_head.tpl" title="Gestion des plans comptables" current="acc/charts"}
+
+
+
+{if count($list)}
+
+
+ Pays |
+ Libellé |
+ |
+
+
+ {foreach from=$list item="item"}
+
+ {$item.country|get_country_name} |
+ {$item.label} {if $item.code}(officiel){else}(copie){/if} |
+
+ {icon shape="menu" label="Gérer les comptes" href="acc/accounts/?id=%d"|args:$item.id}
+ {icon shape="edit" label="Renommer" href="acc/charts/edit.php?id=%d"|args:$item.id}
+ {icon shape="export" label="Exporter en CSV" href="acc/charts/export.php?id=%d"|args:$item.id}
+ {if empty($item.code)}
+ {icon shape="upload" label="Importer" href="acc/charts/import.php?id=%d"|args:$item.id}
+ {icon shape="delete" label="Supprimer" href="acc/charts/delete.php?id=%d"|args:$item.id}
+ {else}
+ {icon shape="reset" label="Remettre à zéro" href="acc/charts/reset.php?id=%d"|args:$item.id}
+ {/if}
+ |
+
+ {/foreach}
+
+
+{/if}
+
+
+
+{include file="admin/_foot.tpl"}
DELETED src/templates/admin/acc/plans/accounts/index.tpl
Index: src/templates/admin/acc/plans/accounts/index.tpl
==================================================================
--- src/templates/admin/acc/plans/accounts/index.tpl
+++ src/templates/admin/acc/plans/accounts/index.tpl
@@ -1,56 +0,0 @@
-{include file="admin/_head.tpl" title=$plan.label current="acc/plans"}
-
-
-
-{if count($accounts)}
-
-
- Code |
- Libellé |
- Position |
- |
- |
-
-
- {foreach from=$accounts item="item"}
-
- {$item.code} |
- {$item.label} |
- {$item.position|account_position} |
-
- {if $item.type == $item::TYPE_BOOKMARK}{icon shape="star"}{/if}
- {$item.type|account_type}
- |
-
- {if $item.user}
- {icon shape="delete" label="Supprimer" href="acc/plans/accounts/delete.php?id=%d"|args:$item.id}
- {/if}
- {icon shape="edit" label="Modifier" href="acc/plans/accounts/edit.php?id=%d"|args:$item.id}
- |
-
- {/foreach}
-
-
-{/if}
-
-
-
-{include file="admin/_foot.tpl"}
DELETED src/templates/admin/acc/plans/index.tpl
Index: src/templates/admin/acc/plans/index.tpl
==================================================================
--- src/templates/admin/acc/plans/index.tpl
+++ src/templates/admin/acc/plans/index.tpl
@@ -1,51 +0,0 @@
-{include file="admin/_head.tpl" title="Gestion des plans comptables" current="acc/plans"}
-
-
-
-{if count($list)}
-
-
- Pays |
- Libellé |
- |
-
-
- {foreach from=$list item="item"}
-
- {$item.country|get_country_name} |
- {$item.label} {if $item.code}(officiel){else}(copie){/if} |
-
- {icon shape="menu" label="Gérer les comptes" href="acc/plans/accounts/?id=%d"|args:$item.id}
- {icon shape="edit" label="Renommer" href="acc/plans/edit.php?id=%d"|args:$item.id}
- {icon shape="export" label="Exporter en CSV" href="acc/plans/export.php?id=%d"|args:$item.id}
- {if empty($item.code)}
- {icon shape="upload" label="Importer" href="acc/plans/import.php?id=%d"|args:$item.id}
- {icon shape="delete" label="Supprimer" href="acc/plans/delete.php?id=%d"|args:$item.id}
- {else}
- {icon shape="reset" label="Remettre à zéro" href="acc/plans/reset.php?id=%d"|args:$item.id}
- {/if}
- |
-
- {/foreach}
-
-
-{/if}
-
-
-
-{include file="admin/_foot.tpl"}
ADDED src/www/admin/acc/accounts/index.php
Index: src/www/admin/acc/accounts/index.php
==================================================================
--- src/www/admin/acc/accounts/index.php
+++ src/www/admin/acc/accounts/index.php
@@ -0,0 +1,17 @@
+requireAccess('compta', Membres::DROIT_ADMIN);
+
+$chart = (new Charts)->get(qg('id'));
+$accounts = new Accounts;
+
+$tpl->assign('chart', $chart);
+$tpl->assign('accounts', $accounts->listForChart($chart->id()));
+
+$tpl->display('admin/acc/accounts/index.tpl');
ADDED src/www/admin/acc/charts/index.php
Index: src/www/admin/acc/charts/index.php
==================================================================
--- src/www/admin/acc/charts/index.php
+++ src/www/admin/acc/charts/index.php
@@ -0,0 +1,16 @@
+requireAccess('compta', Membres::DROIT_ADMIN);
+
+$charts = new Charts;
+
+$tpl->assign('list', $charts->list());
+$tpl->assign('charts_groupped', $charts->listByCountry());
+$tpl->assign('country_list', Utils::getCountryList());
+
+$tpl->display('admin/acc/charts/index.tpl');
DELETED src/www/admin/acc/plans/accounts/index.php
Index: src/www/admin/acc/plans/accounts/index.php
==================================================================
--- src/www/admin/acc/plans/accounts/index.php
+++ src/www/admin/acc/plans/accounts/index.php
@@ -1,17 +0,0 @@
-requireAccess('compta', Membres::DROIT_ADMIN);
-
-$plan = (new Plans)->get(qg('id'));
-$accounts = new Accounts;
-
-$tpl->assign('plan', $plan);
-$tpl->assign('accounts', $accounts->listForPlan($plan->id()));
-
-$tpl->display('admin/acc/plans/accounts/index.tpl');
DELETED src/www/admin/acc/plans/index.php
Index: src/www/admin/acc/plans/index.php
==================================================================
--- src/www/admin/acc/plans/index.php
+++ src/www/admin/acc/plans/index.php
@@ -1,16 +0,0 @@
-requireAccess('compta', Membres::DROIT_ADMIN);
-
-$plans = new Plans;
-
-$tpl->assign('list', $plans->list());
-$tpl->assign('plans_groupped', $plans->listByCountry());
-$tpl->assign('country_list', Utils::getCountryList());
-
-$tpl->display('admin/acc/plans/index.tpl');