Overview
Comment:Suppression de la colonne "parent", on n'utilise plus que le code pour classer les comptes, il n'y a plus de notion de hiérarchie
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | dev
Files: files | file ages | folders
SHA1: 98f1c451f5aa32978f03be7723f4345f973b43e7
User & Date: bohwaz on 2020-04-24 02:07:48
Other Links: branch diff | manifest | tags
Context
2020-04-24
02:08
Max 6 caractères dans le code check-in: 1372759276 user: bohwaz tags: dev
02:07
Suppression de la colonne "parent", on n'utilise plus que le code pour classer les comptes, il n'y a plus de notion de hiérarchie check-in: 98f1c451f5 user: bohwaz tags: dev
2020-04-23
23:04
Widget de simplification de la gestion des boutons avec icône check-in: b9f5fcdd5f user: bohwaz tags: dev
Changes

Modified src/include/data/1.0.0_migration.sql from [8ebc7fc41e] to [f4a019e169].

12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27

28
29
30
31
32
33
34
35
36
37

INSERT INTO acc_plans (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, parent, label, position, user)
	SELECT NULL, 1, id, NULL, libelle, position, CASE WHEN plan_comptable = 1 THEN 0 ELSE 1 END FROM compta_comptes;

-- Migration de la hiérarchie
UPDATE acc_accounts AS a SET parent = (SELECT id FROM acc_accounts AS b WHERE code = (SELECT parent FROM compta_comptes AS c WHERE id = b.code));

-- Migrations projets vers comptes analytiques
INSERT INTO acc_accounts (id_plan, code, parent, label, position, user, type)
	VALUES (1, '99', (SELECT id FROM acc_accounts WHERE code = '9'), 'Projets', 0, 1, 4);


INSERT INTO acc_accounts (id_plan, code, parent, label, position, user, type)
	SELECT 1, '99' || substr('0000' || id, -4), (SELECT id FROM acc_accounts WHERE code = '99'), libelle, 0, 1, 3 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;

-- Modification des valeurs de la position (qui n'est plus un champ binaire)
UPDATE acc_accounts SET position = 3 WHERE position = 4;
UPDATE acc_accounts SET position = 4 WHERE position = 8;







|
|

<
<
<

|
<
>

|
|







12
13
14
15
16
17
18
19
20
21



22
23

24
25
26
27
28
29
30
31
32
33
34

INSERT INTO acc_plans (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)
	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_plan, code, label, position, user, type)
	SELECT 1, '99' || substr('0000' || id, -4), libelle, 0, 1, 3 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;

-- Modification des valeurs de la position (qui n'est plus un champ binaire)
UPDATE acc_accounts SET position = 3 WHERE position = 4;
UPDATE acc_accounts SET position = 4 WHERE position = 8;

Modified src/include/data/1.0.0_schema.sql from [b1bfe5e1c8] to [28a5a4a85e].

192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
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,

    code TEXT NOT NULL, -- peut contenir des lettres, eg. 53A, 53B, etc.
    parent INTEGER NULL REFERENCES acc_accounts(id),

    label TEXT NOT NULL,
    description TEXT NULL,

    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 INDEX IF NOT EXISTS acc_accounts_parent ON acc_accounts (parent);

CREATE TABLE IF NOT EXISTS acc_years
-- Exercices
(
    id INTEGER NOT NULL PRIMARY KEY,

    label TEXT NOT NULL,







<










<







192
193
194
195
196
197
198

199
200
201
202
203
204
205
206
207
208

209
210
211
212
213
214
215
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,

    code TEXT NOT NULL, -- peut contenir des lettres, eg. 53A, 53B, etc.


    label TEXT NOT NULL,
    description TEXT NULL,

    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 TABLE IF NOT EXISTS acc_years
-- Exercices
(
    id INTEGER NOT NULL PRIMARY KEY,

    label TEXT NOT NULL,

Modified src/include/lib/Garradin/Entities/Accounting/Account.php from [402ab193cd] to [6e87c9507d].

54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
		'Bénévolat',
		'Favori',
	];

	protected $id;
	protected $id_plan;
	protected $code;
	protected $parent;
	protected $label;
	protected $description;
	protected $position;
	protected $type;
	protected $user;

	protected $_types = [
		'id'          => 'int',
		'id_plan'     => 'int',
		'code'        => 'string',
		'parent'      => '?int',
		'label'       => 'string',
		'description' => '?string',
		'position'    => 'int',
		'type'        => 'int',
		'user'        => 'int',
	];

	protected $_validation_rules = [
		'id_plan'     => 'required|integer|in_table:acc_plans,id',
		'code'        => 'required|string|alpha_num|max:8',
		'label'       => 'required|string|max:200',
		'description' => 'string|max:2000',
		'parent'      => 'required|nullable|integer|in_table:acc_accounts,id',
		'position'    => 'required|integer',
		'type'        => 'required|integer',
		'user'        => 'integer|min:0|max:1',
	];
}







<










<












<





54
55
56
57
58
59
60

61
62
63
64
65
66
67
68
69
70

71
72
73
74
75
76
77
78
79
80
81
82

83
84
85
86
87
		'Bénévolat',
		'Favori',
	];

	protected $id;
	protected $id_plan;
	protected $code;

	protected $label;
	protected $description;
	protected $position;
	protected $type;
	protected $user;

	protected $_types = [
		'id'          => 'int',
		'id_plan'     => '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',
		'code'        => 'required|string|alpha_num|max:8',
		'label'       => 'required|string|max:200',
		'description' => 'string|max:2000',

		'position'    => 'required|integer',
		'type'        => 'required|integer',
		'user'        => 'integer|min:0|max:1',
	];
}