144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
|
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, etc.
user INTEGER NOT NULL DEFAULT 1, -- 0 = fait partie du plan comptable original, 1 = a été ajouté par l'utilisateur
favorite INTEGER NOT NULL DEFAULT 0 -- 1 = is marked as favorite
);
CREATE UNIQUE INDEX IF NOT EXISTS acc_accounts_codes ON acc_accounts (code, id_chart);
CREATE INDEX IF NOT EXISTS acc_accounts_type ON acc_accounts (type);
CREATE INDEX IF NOT EXISTS acc_accounts_position ON acc_accounts (position);
CREATE INDEX IF NOT EXISTS acc_accounts_favorite ON acc_accounts (id_chart, favorite, code);
-- Balance des comptes par exercice
CREATE VIEW IF NOT EXISTS acc_accounts_balances
AS
SELECT id_year, id, label, code, type, debit, credit,
CASE -- 3 = dynamic asset or liability depending on balance
WHEN position = 3 AND (debit - credit) > 0 THEN 1 -- 1 = Asset (actif) comptes fournisseurs, tiers créditeurs
|
|
|
|
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
|
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, etc.
user INTEGER NOT NULL DEFAULT 1, -- 0 = fait partie du plan comptable original, 1 = a été ajouté par l'utilisateur
bookmark INTEGER NOT NULL DEFAULT 0 -- 1 = is marked as favorite
);
CREATE UNIQUE INDEX IF NOT EXISTS acc_accounts_codes ON acc_accounts (code, id_chart);
CREATE INDEX IF NOT EXISTS acc_accounts_type ON acc_accounts (type);
CREATE INDEX IF NOT EXISTS acc_accounts_position ON acc_accounts (position);
CREATE INDEX IF NOT EXISTS acc_accounts_bookmarks ON acc_accounts (id_chart, bookmark, code);
-- Balance des comptes par exercice
CREATE VIEW IF NOT EXISTS acc_accounts_balances
AS
SELECT id_year, id, label, code, type, debit, credit,
CASE -- 3 = dynamic asset or liability depending on balance
WHEN position = 3 AND (debit - credit) > 0 THEN 1 -- 1 = Asset (actif) comptes fournisseurs, tiers créditeurs
|