0
|
1 |
drop table if exists chart;
|
|
2 |
|
|
3 |
create table chart (
|
|
4 |
-- Fem que sigui 'char' per fer cerques bé amb wildcards ('30%' per exemple)
|
|
5 |
account_num char(10) not null,
|
|
6 |
-- Nom de la compta (una línia)
|
|
7 |
name tinytext default NULL,
|
|
8 |
-- Explica què s'ha de comptar en aquest compte
|
|
9 |
description text default NULL,
|
|
10 |
-- Marca si forma part del pla general comptable o no
|
|
11 |
general tinyint default 0,
|
|
12 |
-- Bool de si és un compte o no. Podria ser un títol, o una marca en els
|
|
13 |
-- comptes.
|
|
14 |
account tinyint default 0,
|
|
15 |
-- Bool de si la volem veure als diàlegs o no
|
|
16 |
enabled tinyint default 0,
|
|
17 |
-- Actiu, Passiu, Ingressos, Despeses
|
|
18 |
type enum("A","P","I","D") default NULL,
|
|
19 |
-- Aquest set augmentarà més endavant
|
|
20 |
links set("Venda","Compra") default NULL,
|
|
21 |
-- Profunditat (número de caràcters a "number")
|
|
22 |
-- no és necessària, perquè es poden fer cerques amb ?, ??, ...
|
|
23 |
-- level tinyint default 0,
|
|
24 |
|
|
25 |
primary key (account_num)
|
|
26 |
) TYPE=MyISAM;
|
|
27 |
|
|
28 |
|
|
29 |
drop table if exists transactions;
|
|
30 |
|
|
31 |
create table transactions (
|
|
32 |
id int(11) auto_increment not null,
|
|
33 |
t_date date,
|
|
34 |
concept tinytext,
|
|
35 |
-- doc_type set('Factura', ...')
|
|
36 |
-- doc_number char(11)
|
|
37 |
primary key (id)
|
|
38 |
) TYPE=MyISAM;
|
|
39 |
|
|
40 |
|
|
41 |
drop table if exists movements;
|
|
42 |
|
|
43 |
|
|
44 |
create table movements (
|
|
45 |
transaction_id int(11) not null,
|
|
46 |
account_num int(11) not null,
|
|
47 |
amount float(20,2),
|
|
48 |
primary key (transaction_id,account_num)
|
|
49 |
-- foreign key transaction_id (transactions.id),
|
|
50 |
-- foreign key account_num (chart.accout_num)
|
|
51 |
) TYPE=MyISAM;
|