clevic 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,12 +4,11 @@ require 'clevic.rb'
4
4
  Clevic::DbOptions.connect( $options ) do
5
5
  database :accounts_test
6
6
  adapter :postgresql
7
- username 'panic'
7
+ username 'accounts'
8
8
  end
9
9
 
10
10
  # This is a read-only view, which is currently not implemented
11
- class Values < ActiveRecord::Base
12
- include ActiveRecord::Dirty
11
+ class Values < Clevic::Record
13
12
  set_table_name 'values'
14
13
  has_many :debits, :class_name => 'Entry', :foreign_key => 'debit_id'
15
14
  has_many :credits, :class_name => 'Entry', :foreign_key => 'credit_id'
data/script/console CHANGED
@@ -2,7 +2,7 @@
2
2
  # File: script/console
3
3
  irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
4
 
5
- libs = " -r irb/completion"
5
+ libs = "-I #{File.dirname(__FILE__) + '/../lib'} -r irb/completion"
6
6
  # Perhaps use a console_lib to store any extra methods I may want available in the cosole
7
7
  # libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
8
8
  libs << " -r #{File.dirname(__FILE__) + '/../lib/clevic.rb'}"
data/sql/accounts.sql CHANGED
@@ -21,7 +21,7 @@ SET default_tablespace = '';
21
21
  SET default_with_oids = true;
22
22
 
23
23
  --
24
- -- Name: accounts; Type: TABLE; Schema: public; Owner: panic; Tablespace:
24
+ -- Name: accounts; Type: TABLE; Schema: public; Owner: accounts; Tablespace:
25
25
  --
26
26
 
27
27
  CREATE TABLE accounts (
@@ -35,10 +35,10 @@ CREATE TABLE accounts (
35
35
  );
36
36
 
37
37
 
38
- ALTER TABLE public.accounts OWNER TO panic;
38
+ ALTER TABLE public.accounts OWNER TO accounts;
39
39
 
40
40
  --
41
- -- Name: accounts_id_seq; Type: SEQUENCE; Schema: public; Owner: panic
41
+ -- Name: accounts_id_seq; Type: SEQUENCE; Schema: public; Owner: accounts
42
42
  --
43
43
 
44
44
  CREATE SEQUENCE accounts_id_seq
@@ -48,10 +48,10 @@ CREATE SEQUENCE accounts_id_seq
48
48
  CACHE 1;
49
49
 
50
50
 
51
- ALTER TABLE public.accounts_id_seq OWNER TO panic;
51
+ ALTER TABLE public.accounts_id_seq OWNER TO accounts;
52
52
 
53
53
  --
54
- -- Name: entries; Type: TABLE; Schema: public; Owner: panic; Tablespace:
54
+ -- Name: entries; Type: TABLE; Schema: public; Owner: accounts; Tablespace:
55
55
  --
56
56
 
57
57
  CREATE TABLE entries (
@@ -67,110 +67,110 @@ CREATE TABLE entries (
67
67
  );
68
68
 
69
69
 
70
- ALTER TABLE public.entries OWNER TO panic;
70
+ ALTER TABLE public.entries OWNER TO accounts;
71
71
 
72
72
  --
73
- -- Name: transactions; Type: VIEW; Schema: public; Owner: panic
73
+ -- Name: transactions; Type: VIEW; Schema: public; Owner: accounts
74
74
  --
75
75
 
76
76
  CREATE VIEW transactions AS
77
77
  SELECT entries.id, entries.date, entries.description, (SELECT accounts.name FROM accounts WHERE (accounts.id = entries.debit_id)) AS debit, (SELECT accounts.name FROM accounts WHERE (accounts.id = entries.credit_id)) AS credit, entries.amount, entries.cheque_number, entries.active, entries.vat FROM entries;
78
78
 
79
79
 
80
- ALTER TABLE public.transactions OWNER TO panic;
80
+ ALTER TABLE public.transactions OWNER TO accounts;
81
81
 
82
82
  --
83
- -- Name: values; Type: VIEW; Schema: public; Owner: panic
83
+ -- Name: values; Type: VIEW; Schema: public; Owner: accounts
84
84
  --
85
85
 
86
86
  CREATE VIEW "values" AS
87
87
  SELECT transactions.amount AS pre_vat_amount, transactions.id, transactions.date, transactions.description, transactions.debit, transactions.credit, transactions.cheque_number, transactions.vat, CASE WHEN (date_part('month'::text, transactions.date) > (2)::double precision) THEN (date_part('year'::text, transactions.date) + (1)::double precision) ELSE date_part('year'::text, transactions.date) END AS financial_year, date_part('month'::text, transactions.date) AS "month" FROM transactions WHERE (transactions.active = true);
88
88
 
89
89
 
90
- ALTER TABLE public."values" OWNER TO panic;
90
+ ALTER TABLE public."values" OWNER TO accounts;
91
91
 
92
92
  --
93
- -- Name: pre_amounts; Type: VIEW; Schema: public; Owner: panic
93
+ -- Name: pre_amounts; Type: VIEW; Schema: public; Owner: accounts
94
94
  --
95
95
 
96
96
  CREATE VIEW pre_amounts AS
97
97
  ((SELECT "values".financial_year, to_char(("values".date)::timestamp with time zone, 'mon'::text) AS "month", "values".date, "values".description, "values".debit AS account, accounts.account_type, accounts.fringe, accounts.vat, (- "values".pre_vat_amount) AS pre_vat_amount, CASE WHEN (((accounts.vat)::text = 'yes'::text) AND ("values".vat = true)) THEN (((- float8("values".pre_vat_amount)) * (100.0)::double precision) / (114.0)::double precision) WHEN (((accounts.vat)::text = 'no'::text) OR ("values".vat = false)) THEN ((- "values".pre_vat_amount))::double precision WHEN ((accounts.vat)::text = 'all'::text) THEN (0)::double precision ELSE NULL::double precision END AS amount FROM "values", accounts WHERE (("values".debit)::text = (accounts.name)::text) UNION SELECT "values".financial_year, to_char(("values".date)::timestamp with time zone, 'mon'::text) AS "month", "values".date, "values".description, 'VAT' AS account, 'Tax' AS account_type, accounts.fringe, accounts.vat, (- "values".pre_vat_amount) AS pre_vat_amount, CASE WHEN (((accounts.vat)::text = 'yes'::text) AND ("values".vat = true)) THEN (((- float8("values".pre_vat_amount)) * (14.0)::double precision) / (114.0)::double precision) WHEN (((accounts.vat)::text = 'no'::text) OR ("values".vat = false)) THEN (0)::double precision WHEN ((accounts.vat)::text = 'all'::text) THEN ((- "values".pre_vat_amount))::double precision ELSE NULL::double precision END AS amount FROM "values", accounts WHERE (("values".debit)::text = (accounts.name)::text)) UNION SELECT "values".financial_year, to_char(("values".date)::timestamp with time zone, 'mon'::text) AS "month", "values".date, "values".description, "values".credit AS account, accounts.account_type, accounts.fringe, accounts.vat, "values".pre_vat_amount, CASE WHEN (((accounts.vat)::text = 'yes'::text) AND ("values".vat = true)) THEN ((float8("values".pre_vat_amount) * (100.0)::double precision) / (114.0)::double precision) WHEN (((accounts.vat)::text = 'no'::text) OR ("values".vat = false)) THEN ("values".pre_vat_amount)::double precision WHEN ((accounts.vat)::text = 'all'::text) THEN (0)::double precision ELSE NULL::double precision END AS amount FROM "values", accounts WHERE (("values".credit)::text = (accounts.name)::text)) UNION SELECT "values".financial_year, to_char(("values".date)::timestamp with time zone, 'mon'::text) AS "month", "values".date, "values".description, 'VAT' AS account, 'Tax' AS account_type, accounts.fringe, accounts.vat, "values".pre_vat_amount, CASE WHEN (((accounts.vat)::text = 'yes'::text) AND ("values".vat = true)) THEN ((float8("values".pre_vat_amount) * (14.0)::double precision) / (114.0)::double precision) WHEN (((accounts.vat)::text = 'no'::text) OR ("values".vat = false)) THEN (0)::double precision WHEN ((accounts.vat)::text = 'all'::text) THEN ("values".pre_vat_amount)::double precision ELSE NULL::double precision END AS amount FROM "values", accounts WHERE (("values".credit)::text = (accounts.name)::text);
98
98
 
99
99
 
100
- ALTER TABLE public.pre_amounts OWNER TO panic;
100
+ ALTER TABLE public.pre_amounts OWNER TO accounts;
101
101
 
102
102
  --
103
- -- Name: amounts; Type: VIEW; Schema: public; Owner: panic
103
+ -- Name: amounts; Type: VIEW; Schema: public; Owner: accounts
104
104
  --
105
105
 
106
106
  CREATE VIEW amounts AS
107
107
  SELECT pre_amounts.financial_year, pre_amounts."month", pre_amounts.date, pre_amounts.description, pre_amounts.account, pre_amounts.account_type, pre_amounts.fringe, pre_amounts.vat, pre_amounts.pre_vat_amount, pre_amounts.amount, (pre_amounts.fringe * pre_amounts.amount) AS fringeamount FROM pre_amounts WHERE (NOT (pre_amounts.amount = (0)::double precision));
108
108
 
109
109
 
110
- ALTER TABLE public.amounts OWNER TO panic;
110
+ ALTER TABLE public.amounts OWNER TO accounts;
111
111
 
112
112
  --
113
- -- Name: bank_statement; Type: VIEW; Schema: public; Owner: panic
113
+ -- Name: bank_statement; Type: VIEW; Schema: public; Owner: accounts
114
114
  --
115
115
 
116
116
  CREATE VIEW bank_statement AS
117
117
  SELECT transactions.id, transactions.date, transactions.description, transactions.debit, transactions.credit, transactions.amount, transactions.cheque_number, transactions.active, transactions.vat, CASE WHEN ((transactions.debit)::text = 'Bank'::text) THEN (- transactions.amount) WHEN ((transactions.credit)::text = 'Bank'::text) THEN transactions.amount ELSE (0)::numeric END AS movement FROM transactions WHERE (((transactions.debit)::text = 'Bank'::text) OR ((transactions.credit)::text = 'Bank'::text)) ORDER BY transactions.date;
118
118
 
119
119
 
120
- ALTER TABLE public.bank_statement OWNER TO panic;
120
+ ALTER TABLE public.bank_statement OWNER TO accounts;
121
121
 
122
122
  --
123
- -- Name: running_total; Type: VIEW; Schema: public; Owner: panic
123
+ -- Name: running_total; Type: VIEW; Schema: public; Owner: accounts
124
124
  --
125
125
 
126
126
  CREATE VIEW running_total AS
127
127
  SELECT transactions.date, sum(CASE WHEN ((transactions.debit)::text = 'Bank'::text) THEN (- transactions.amount) WHEN ((transactions.credit)::text = 'Bank'::text) THEN transactions.amount ELSE (0)::numeric END) AS balance, CASE WHEN (date_part('month'::text, transactions.date) <= (2)::double precision) THEN (date_part('year'::text, transactions.date) - (1)::double precision) ELSE date_part('year'::text, transactions.date) END AS financial_year FROM transactions WHERE ((((transactions.debit)::text = 'Bank'::text) OR ((transactions.credit)::text = 'Bank'::text)) AND (transactions.active = true)) GROUP BY transactions.date;
128
128
 
129
129
 
130
- ALTER TABLE public.running_total OWNER TO panic;
130
+ ALTER TABLE public.running_total OWNER TO accounts;
131
131
 
132
132
  --
133
- -- Name: daily_2006; Type: VIEW; Schema: public; Owner: panic
133
+ -- Name: daily_2006; Type: VIEW; Schema: public; Owner: accounts
134
134
  --
135
135
 
136
136
  CREATE VIEW daily_2006 AS
137
137
  SELECT running_total.date, (SELECT sum(running.balance) AS sum FROM running_total running WHERE ((running.date >= '2006-03-01'::date) AND (running.date <= running_total.date))) AS balance FROM running_total WHERE ((running_total.date >= '2006-03-01'::date) AND (running_total.date < '2007-03-01'::date)) ORDER BY running_total.date;
138
138
 
139
139
 
140
- ALTER TABLE public.daily_2006 OWNER TO panic;
140
+ ALTER TABLE public.daily_2006 OWNER TO accounts;
141
141
 
142
142
  --
143
- -- Name: daily_2007; Type: VIEW; Schema: public; Owner: panic
143
+ -- Name: daily_2007; Type: VIEW; Schema: public; Owner: accounts
144
144
  --
145
145
 
146
146
  CREATE VIEW daily_2007 AS
147
147
  SELECT running_total.date, (SELECT sum(running.balance) AS sum FROM running_total running WHERE ((running.date >= '2007-03-01'::date) AND (running.date <= running_total.date))) AS balance FROM running_total WHERE ((running_total.date >= '2007-03-01'::date) AND (running_total.date < '2008-03-01'::date)) ORDER BY running_total.date;
148
148
 
149
149
 
150
- ALTER TABLE public.daily_2007 OWNER TO panic;
150
+ ALTER TABLE public.daily_2007 OWNER TO accounts;
151
151
 
152
152
  --
153
- -- Name: daily_2008; Type: VIEW; Schema: public; Owner: panic
153
+ -- Name: daily_2008; Type: VIEW; Schema: public; Owner: accounts
154
154
  --
155
155
 
156
156
  CREATE VIEW daily_2008 AS
157
157
  SELECT running_total.date, (SELECT sum(running.balance) AS sum FROM running_total running WHERE ((running.date >= '2008-03-01'::date) AND (running.date <= running_total.date))) AS balance FROM running_total WHERE ((running_total.date >= '2008-03-01'::date) AND (running_total.date < '2009-03-01'::date)) ORDER BY running_total.date;
158
158
 
159
159
 
160
- ALTER TABLE public.daily_2008 OWNER TO panic;
160
+ ALTER TABLE public.daily_2008 OWNER TO accounts;
161
161
 
162
162
  --
163
- -- Name: daily_bank_balances; Type: VIEW; Schema: public; Owner: panic
163
+ -- Name: daily_bank_balances; Type: VIEW; Schema: public; Owner: accounts
164
164
  --
165
165
 
166
166
  CREATE VIEW daily_bank_balances AS
167
167
  SELECT running_total.date, (SELECT sum(running.balance) AS sum FROM running_total running WHERE (running.date <= running_total.date)) AS balance FROM running_total ORDER BY running_total.date;
168
168
 
169
169
 
170
- ALTER TABLE public.daily_bank_balances OWNER TO panic;
170
+ ALTER TABLE public.daily_bank_balances OWNER TO accounts;
171
171
 
172
172
  --
173
- -- Name: entries_id; Type: SEQUENCE; Schema: public; Owner: panic
173
+ -- Name: entries_id; Type: SEQUENCE; Schema: public; Owner: accounts
174
174
  --
175
175
 
176
176
  CREATE SEQUENCE entries_id
@@ -180,30 +180,30 @@ CREATE SEQUENCE entries_id
180
180
  CACHE 1;
181
181
 
182
182
 
183
- ALTER TABLE public.entries_id OWNER TO panic;
183
+ ALTER TABLE public.entries_id OWNER TO accounts;
184
184
 
185
185
  --
186
- -- Name: pastel_export; Type: VIEW; Schema: public; Owner: panic
186
+ -- Name: pastel_export; Type: VIEW; Schema: public; Owner: accounts
187
187
  --
188
188
 
189
189
  CREATE VIEW pastel_export AS
190
190
  ((SELECT CASE WHEN (date_part('month'::text, transactions.date) > (2)::double precision) THEN (date_part('year'::text, transactions.date) + (1)::double precision) ELSE date_part('year'::text, transactions.date) END AS financial_year, CASE WHEN (date_part('month'::text, transactions.date) > (2)::double precision) THEN (date_part('month'::text, transactions.date) - (2)::double precision) ELSE (date_part('month'::text, transactions.date) + (10)::double precision) END AS period, transactions.date, 'G' AS gdc, accounts.pastel_number AS "Account Number", transactions.id AS reference, transactions.description, CASE WHEN ((accounts.vat)::text = 'yes'::text) THEN (((- float8(transactions.amount)) * (100.0)::double precision) / (114.0)::double precision) WHEN ((accounts.vat)::text = 'no'::text) THEN ((- transactions.amount))::double precision WHEN ((accounts.vat)::text = 'all'::text) THEN (0)::double precision ELSE NULL::double precision END AS amount, 0 AS "Tax Type", 0 AS "Tax Amount", NULL::"unknown" AS "Open Item Type", NULL::"unknown" AS "Cost Code", NULL::"unknown" AS "Contra Account", 0.0 AS "Exchange Rate", 0.0 AS "Bank Exchange Rate", NULL::"unknown" AS "Batch ID", NULL::"unknown" AS "Discount Tax Type", NULL::"unknown" AS "Discount Amount", NULL::"unknown" AS "Home Amount", 'Debit Amount' AS debug FROM transactions, accounts WHERE ((((((accounts.name)::text = (transactions.debit)::text) AND ((accounts.account_type)::text <> 'Personal'::text)) AND (((SELECT accounts.account_type FROM accounts WHERE ((accounts.name)::text = (transactions.credit)::text)))::text <> 'Personal'::text)) AND (transactions.active = true)) AND (accounts.active = true)) UNION SELECT CASE WHEN (date_part('month'::text, transactions.date) > (2)::double precision) THEN (date_part('year'::text, transactions.date) + (1)::double precision) ELSE date_part('year'::text, transactions.date) END AS financial_year, CASE WHEN (date_part('month'::text, transactions.date) > (2)::double precision) THEN (date_part('month'::text, transactions.date) - (2)::double precision) ELSE (date_part('month'::text, transactions.date) + (10)::double precision) END AS period, transactions.date, 'G' AS gdc, '9500000' AS "Account Number", transactions.id AS reference, transactions.description, CASE WHEN ((accounts.vat)::text = 'yes'::text) THEN (((- float8(transactions.amount)) * (14.0)::double precision) / (114.0)::double precision) WHEN ((accounts.vat)::text = 'no'::text) THEN (0)::double precision WHEN ((accounts.vat)::text = 'all'::text) THEN ((- transactions.amount))::double precision ELSE NULL::double precision END AS amount, 0 AS "Tax Type", 0 AS "Tax Amount", NULL::"unknown" AS "Open Item Type", NULL::"unknown" AS "Cost Code", NULL::"unknown" AS "Contra Account", 0.0 AS "Exchange Rate", 0.0 AS "Bank Exchange Rate", NULL::"unknown" AS "Batch ID", NULL::"unknown" AS "Discount Tax Type", NULL::"unknown" AS "Discount Amount", NULL::"unknown" AS "Home Amount", 'Debit VAT' AS debug FROM transactions, accounts WHERE ((((((accounts.name)::text = (transactions.debit)::text) AND ((accounts.account_type)::text <> 'Personal'::text)) AND (((SELECT accounts.account_type FROM accounts WHERE ((accounts.name)::text = (transactions.credit)::text)))::text <> 'Personal'::text)) AND (transactions.active = true)) AND (accounts.active = true))) UNION SELECT CASE WHEN (date_part('month'::text, transactions.date) > (2)::double precision) THEN (date_part('year'::text, transactions.date) + (1)::double precision) ELSE date_part('year'::text, transactions.date) END AS financial_year, CASE WHEN (date_part('month'::text, transactions.date) > (2)::double precision) THEN (date_part('month'::text, transactions.date) - (2)::double precision) ELSE (date_part('month'::text, transactions.date) + (10)::double precision) END AS period, transactions.date, 'G' AS gdc, accounts.pastel_number AS "Account Number", transactions.id AS reference, transactions.description, CASE WHEN ((accounts.vat)::text = 'yes'::text) THEN ((float8(transactions.amount) * (100.0)::double precision) / (114.0)::double precision) WHEN ((accounts.vat)::text = 'no'::text) THEN (transactions.amount)::double precision WHEN ((accounts.vat)::text = 'all'::text) THEN (0)::double precision ELSE NULL::double precision END AS amount, 0 AS "Tax Type", 0 AS "Tax Amount", NULL::"unknown" AS "Open Item Type", NULL::"unknown" AS "Cost Code", NULL::"unknown" AS "Contra Account", 0.0 AS "Exchange Rate", 0.0 AS "Bank Exchange Rate", NULL::"unknown" AS "Batch ID", NULL::"unknown" AS "Discount Tax Type", NULL::"unknown" AS "Discount Amount", NULL::"unknown" AS "Home Amount", 'Credit Amount' AS debug FROM transactions, accounts WHERE ((((((accounts.name)::text = (transactions.credit)::text) AND ((accounts.account_type)::text <> 'Personal'::text)) AND (((SELECT accounts.account_type FROM accounts WHERE ((accounts.name)::text = (transactions.debit)::text)))::text <> 'Personal'::text)) AND (transactions.active = true)) AND (accounts.active = true))) UNION SELECT CASE WHEN (date_part('month'::text, transactions.date) > (2)::double precision) THEN (date_part('year'::text, transactions.date) + (1)::double precision) ELSE date_part('year'::text, transactions.date) END AS financial_year, CASE WHEN (date_part('month'::text, transactions.date) > (2)::double precision) THEN (date_part('month'::text, transactions.date) - (2)::double precision) ELSE (date_part('month'::text, transactions.date) + (10)::double precision) END AS period, transactions.date, 'G' AS gdc, '9500000' AS "Account Number", transactions.id AS reference, transactions.description, CASE WHEN ((accounts.vat)::text = 'yes'::text) THEN ((float8(transactions.amount) * (14.0)::double precision) / (114.0)::double precision) WHEN ((accounts.vat)::text = 'no'::text) THEN (0)::double precision WHEN ((accounts.vat)::text = 'all'::text) THEN (transactions.amount)::double precision ELSE NULL::double precision END AS amount, 0 AS "Tax Type", 0 AS "Tax Amount", NULL::"unknown" AS "Open Item Type", NULL::"unknown" AS "Cost Code", NULL::"unknown" AS "Contra Account", 0.0 AS "Exchange Rate", 0.0 AS "Bank Exchange Rate", NULL::"unknown" AS "Batch ID", NULL::"unknown" AS "Discount Tax Type", NULL::"unknown" AS "Discount Amount", NULL::"unknown" AS "Home Amount", 'Credit VAT' AS debug FROM transactions, accounts WHERE ((((((accounts.name)::text = (transactions.credit)::text) AND ((accounts.account_type)::text <> 'Personal'::text)) AND (((SELECT accounts.account_type FROM accounts WHERE ((accounts.name)::text = (transactions.debit)::text)))::text <> 'Personal'::text)) AND (transactions.active = true)) AND (accounts.active = true));
191
191
 
192
192
 
193
- ALTER TABLE public.pastel_export OWNER TO panic;
193
+ ALTER TABLE public.pastel_export OWNER TO accounts;
194
194
 
195
195
  --
196
- -- Name: pastel_2008; Type: VIEW; Schema: public; Owner: panic
196
+ -- Name: pastel_2008; Type: VIEW; Schema: public; Owner: accounts
197
197
  --
198
198
 
199
199
  CREATE VIEW pastel_2008 AS
200
200
  SELECT pastel_export.period, pastel_export.date, pastel_export.gdc, pastel_export."Account Number", pastel_export.reference, pastel_export.description, pastel_export.amount, pastel_export."Tax Type", pastel_export."Tax Amount", pastel_export."Open Item Type", pastel_export."Cost Code", pastel_export."Contra Account", pastel_export."Exchange Rate", pastel_export."Bank Exchange Rate", pastel_export."Batch ID", pastel_export."Discount Tax Type", pastel_export."Discount Amount", pastel_export."Home Amount" FROM pastel_export WHERE ((pastel_export.financial_year = (2008)::double precision) AND (NOT (pastel_export.amount = float8(0.0))));
201
201
 
202
202
 
203
- ALTER TABLE public.pastel_2008 OWNER TO panic;
203
+ ALTER TABLE public.pastel_2008 OWNER TO accounts;
204
204
 
205
205
  --
206
- -- Name: pastel_accounts; Type: TABLE; Schema: public; Owner: panic; Tablespace:
206
+ -- Name: pastel_accounts; Type: TABLE; Schema: public; Owner: accounts; Tablespace:
207
207
  --
208
208
 
209
209
  CREATE TABLE pastel_accounts (
@@ -216,75 +216,75 @@ CREATE TABLE pastel_accounts (
216
216
  );
217
217
 
218
218
 
219
- ALTER TABLE public.pastel_accounts OWNER TO panic;
219
+ ALTER TABLE public.pastel_accounts OWNER TO accounts;
220
220
 
221
221
  --
222
- -- Name: transaction_description; Type: VIEW; Schema: public; Owner: panic
222
+ -- Name: transaction_description; Type: VIEW; Schema: public; Owner: accounts
223
223
  --
224
224
 
225
225
  CREATE VIEW transaction_description AS
226
226
  SELECT DISTINCT entries.description FROM entries ORDER BY entries.description;
227
227
 
228
228
 
229
- ALTER TABLE public.transaction_description OWNER TO panic;
229
+ ALTER TABLE public.transaction_description OWNER TO accounts;
230
230
 
231
231
  --
232
- -- Name: vat_summary; Type: VIEW; Schema: public; Owner: panic
232
+ -- Name: vat_summary; Type: VIEW; Schema: public; Owner: accounts
233
233
  --
234
234
 
235
235
  CREATE VIEW vat_summary AS
236
236
  SELECT pre_amounts.financial_year, pre_amounts."month", pre_amounts.date, pre_amounts.description, pre_amounts.account, pre_amounts.account_type, pre_amounts.fringe, pre_amounts.vat, pre_amounts.pre_vat_amount, pre_amounts.amount, date_part('year'::text, pre_amounts.date) AS "year", CASE WHEN ((pre_amounts.vat)::text = 'yes'::text) THEN (float8(pre_amounts.pre_vat_amount) - pre_amounts.amount) WHEN ((pre_amounts.vat)::text = 'all'::text) THEN (pre_amounts.pre_vat_amount)::double precision ELSE (0)::double precision END AS vat_amount, CASE WHEN ((date_part('month'::text, pre_amounts.date) = (1)::double precision) OR (date_part('month'::text, pre_amounts.date) = (2)::double precision)) THEN '8 Jan - Feb'::text WHEN ((date_part('month'::text, pre_amounts.date) = (3)::double precision) OR (date_part('month'::text, pre_amounts.date) = (4)::double precision)) THEN '1 Mar - Apr'::text WHEN ((date_part('month'::text, pre_amounts.date) = (5)::double precision) OR (date_part('month'::text, pre_amounts.date) = (6)::double precision)) THEN '3 May - Jun'::text WHEN ((date_part('month'::text, pre_amounts.date) = (7)::double precision) OR (date_part('month'::text, pre_amounts.date) = (8)::double precision)) THEN '4 Jul - Aug'::text WHEN ((date_part('month'::text, pre_amounts.date) = (9)::double precision) OR (date_part('month'::text, pre_amounts.date) = (10)::double precision)) THEN '5 Sep - Oct'::text WHEN ((date_part('month'::text, pre_amounts.date) = (11)::double precision) OR (date_part('month'::text, pre_amounts.date) = (12)::double precision)) THEN '6 Nov - Dec'::text ELSE NULL::text END AS vat_period FROM pre_amounts WHERE (NOT ((pre_amounts.vat)::text = 'no'::text));
237
237
 
238
238
 
239
- ALTER TABLE public.vat_summary OWNER TO panic;
239
+ ALTER TABLE public.vat_summary OWNER TO accounts;
240
240
 
241
241
  --
242
- -- Name: vat_totals; Type: VIEW; Schema: public; Owner: panic
242
+ -- Name: vat_totals; Type: VIEW; Schema: public; Owner: accounts
243
243
  --
244
244
 
245
245
  CREATE VIEW vat_totals AS
246
246
  SELECT vat_summary.financial_year, vat_summary.vat_period, vat_summary.account_type, sum(vat_summary.pre_vat_amount) AS pre_vat_amount, sum(vat_summary.vat_amount) AS vat_amount FROM vat_summary WHERE (((((vat_summary.account_type)::text = 'Assets'::text) OR ((vat_summary.account_type)::text = 'Expenses'::text)) OR ((vat_summary.account_type)::text = 'Income'::text)) OR ((vat_summary.account_type)::text = 'VAT'::text)) GROUP BY vat_summary.financial_year, vat_summary.vat_period, vat_summary.account_type ORDER BY vat_summary.financial_year, vat_summary.vat_period, vat_summary.account_type;
247
247
 
248
248
 
249
- ALTER TABLE public.vat_totals OWNER TO panic;
249
+ ALTER TABLE public.vat_totals OWNER TO accounts;
250
250
 
251
251
  --
252
- -- Name: accounts_pkey; Type: CONSTRAINT; Schema: public; Owner: panic; Tablespace:
252
+ -- Name: accounts_pkey; Type: CONSTRAINT; Schema: public; Owner: accounts; Tablespace:
253
253
  --
254
254
 
255
255
  ALTER TABLE ONLY accounts
256
256
  ADD CONSTRAINT accounts_pkey PRIMARY KEY (name);
257
257
 
258
258
 
259
- ALTER INDEX public.accounts_pkey OWNER TO panic;
259
+ ALTER INDEX public.accounts_pkey OWNER TO accounts;
260
260
 
261
261
  --
262
- -- Name: entries_pkey; Type: CONSTRAINT; Schema: public; Owner: panic; Tablespace:
262
+ -- Name: entries_pkey; Type: CONSTRAINT; Schema: public; Owner: accounts; Tablespace:
263
263
  --
264
264
 
265
265
  ALTER TABLE ONLY entries
266
266
  ADD CONSTRAINT entries_pkey PRIMARY KEY (id);
267
267
 
268
268
 
269
- ALTER INDEX public.entries_pkey OWNER TO panic;
269
+ ALTER INDEX public.entries_pkey OWNER TO accounts;
270
270
 
271
271
  --
272
- -- Name: entries_date; Type: INDEX; Schema: public; Owner: panic; Tablespace:
272
+ -- Name: entries_date; Type: INDEX; Schema: public; Owner: accounts; Tablespace:
273
273
  --
274
274
 
275
275
  CREATE INDEX entries_date ON entries USING btree (date);
276
276
 
277
277
 
278
- ALTER INDEX public.entries_date OWNER TO panic;
278
+ ALTER INDEX public.entries_date OWNER TO accounts;
279
279
 
280
280
  --
281
- -- Name: entries_description; Type: INDEX; Schema: public; Owner: panic; Tablespace:
281
+ -- Name: entries_description; Type: INDEX; Schema: public; Owner: accounts; Tablespace:
282
282
  --
283
283
 
284
284
  CREATE INDEX entries_description ON entries USING btree (description);
285
285
 
286
286
 
287
- ALTER INDEX public.entries_description OWNER TO panic;
287
+ ALTER INDEX public.entries_description OWNER TO accounts;
288
288
 
289
289
  --
290
290
  -- Name: public; Type: ACL; Schema: -; Owner: postgres
data/sql/times.sql CHANGED
@@ -20,7 +20,7 @@ SET default_tablespace = '';
20
20
  SET default_with_oids = true;
21
21
 
22
22
  --
23
- -- Name: activities; Type: TABLE; Schema: public; Owner: panic; Tablespace:
23
+ -- Name: activities; Type: TABLE; Schema: public; Owner: times; Tablespace:
24
24
  --
25
25
 
26
26
  CREATE TABLE activities (
@@ -30,10 +30,10 @@ CREATE TABLE activities (
30
30
  );
31
31
 
32
32
 
33
- ALTER TABLE public.activities OWNER TO panic;
33
+ ALTER TABLE public.activities OWNER TO times;
34
34
 
35
35
  --
36
- -- Name: entries; Type: TABLE; Schema: public; Owner: panic; Tablespace:
36
+ -- Name: entries; Type: TABLE; Schema: public; Owner: times; Tablespace:
37
37
  --
38
38
 
39
39
  CREATE TABLE entries (
@@ -45,7 +45,7 @@ CREATE TABLE entries (
45
45
  "start" time without time zone,
46
46
  "end" time without time zone,
47
47
  description text,
48
- person character varying(30) DEFAULT 'John'::character varying,
48
+ person character varying(30),
49
49
  order_number character varying(40),
50
50
  out_of_spec integer,
51
51
  module character varying(100),
@@ -54,10 +54,10 @@ CREATE TABLE entries (
54
54
  );
55
55
 
56
56
 
57
- ALTER TABLE public.entries OWNER TO panic;
57
+ ALTER TABLE public.entries OWNER TO times;
58
58
 
59
59
  --
60
- -- Name: entries_id_seq; Type: SEQUENCE; Schema: public; Owner: panic
60
+ -- Name: entries_id_seq; Type: SEQUENCE; Schema: public; Owner: times
61
61
  --
62
62
 
63
63
  CREATE SEQUENCE entries_id_seq
@@ -67,10 +67,10 @@ CREATE SEQUENCE entries_id_seq
67
67
  CACHE 1;
68
68
 
69
69
 
70
- ALTER TABLE public.entries_id_seq OWNER TO panic;
70
+ ALTER TABLE public.entries_id_seq OWNER TO times;
71
71
 
72
72
  --
73
- -- Name: invoices; Type: TABLE; Schema: public; Owner: panic; Tablespace:
73
+ -- Name: invoices; Type: TABLE; Schema: public; Owner: times; Tablespace:
74
74
  --
75
75
 
76
76
  CREATE TABLE invoices (
@@ -86,10 +86,10 @@ CREATE TABLE invoices (
86
86
  );
87
87
 
88
88
 
89
- ALTER TABLE public.invoices OWNER TO panic;
89
+ ALTER TABLE public.invoices OWNER TO times;
90
90
 
91
91
  --
92
- -- Name: invoices_id_seq; Type: SEQUENCE; Schema: public; Owner: panic
92
+ -- Name: invoices_id_seq; Type: SEQUENCE; Schema: public; Owner: times
93
93
  --
94
94
 
95
95
  CREATE SEQUENCE invoices_id_seq
@@ -99,10 +99,10 @@ CREATE SEQUENCE invoices_id_seq
99
99
  CACHE 1;
100
100
 
101
101
 
102
- ALTER TABLE public.invoices_id_seq OWNER TO panic;
102
+ ALTER TABLE public.invoices_id_seq OWNER TO times;
103
103
 
104
104
  --
105
- -- Name: projects; Type: TABLE; Schema: public; Owner: panic; Tablespace:
105
+ -- Name: projects; Type: TABLE; Schema: public; Owner: times; Tablespace:
106
106
  --
107
107
 
108
108
  CREATE TABLE projects (
@@ -116,20 +116,20 @@ CREATE TABLE projects (
116
116
  );
117
117
 
118
118
 
119
- ALTER TABLE public.projects OWNER TO panic;
119
+ ALTER TABLE public.projects OWNER TO times;
120
120
 
121
121
  --
122
- -- Name: nice_entries; Type: VIEW; Schema: public; Owner: panic
122
+ -- Name: nice_entries; Type: VIEW; Schema: public; Owner: times
123
123
  --
124
124
 
125
125
  CREATE VIEW nice_entries AS
126
126
  SELECT entries.id, invoices.invoice_number, invoices.status, projects.project, activities.activity, ((entries."end" - entries."start"))::time without time zone AS elapsed, entries.date, entries."start", entries."end", entries.description, entries.person, entries.order_number, entries.out_of_spec, entries.module, entries.rate, entries.charge FROM (((entries JOIN activities ON ((entries.activity_id = activities.id))) JOIN projects ON ((entries.project_id = projects.id))) JOIN invoices ON ((entries.invoice_id = invoices.id)));
127
127
 
128
128
 
129
- ALTER TABLE public.nice_entries OWNER TO panic;
129
+ ALTER TABLE public.nice_entries OWNER TO times;
130
130
 
131
131
  --
132
- -- Name: projects_id_seq; Type: SEQUENCE; Schema: public; Owner: panic
132
+ -- Name: projects_id_seq; Type: SEQUENCE; Schema: public; Owner: times
133
133
  --
134
134
 
135
135
  CREATE SEQUENCE projects_id_seq
@@ -139,47 +139,47 @@ CREATE SEQUENCE projects_id_seq
139
139
  CACHE 1;
140
140
 
141
141
 
142
- ALTER TABLE public.projects_id_seq OWNER TO panic;
142
+ ALTER TABLE public.projects_id_seq OWNER TO times;
143
143
 
144
144
  --
145
- -- Name: activities_pkey; Type: CONSTRAINT; Schema: public; Owner: panic; Tablespace:
145
+ -- Name: activities_pkey; Type: CONSTRAINT; Schema: public; Owner: times; Tablespace:
146
146
  --
147
147
 
148
148
  ALTER TABLE ONLY activities
149
149
  ADD CONSTRAINT activities_pkey PRIMARY KEY (id);
150
150
 
151
151
 
152
- ALTER INDEX public.activities_pkey OWNER TO panic;
152
+ ALTER INDEX public.activities_pkey OWNER TO times;
153
153
 
154
154
  --
155
- -- Name: entries_pkey; Type: CONSTRAINT; Schema: public; Owner: panic; Tablespace:
155
+ -- Name: entries_pkey; Type: CONSTRAINT; Schema: public; Owner: times; Tablespace:
156
156
  --
157
157
 
158
158
  ALTER TABLE ONLY entries
159
159
  ADD CONSTRAINT entries_pkey PRIMARY KEY (id);
160
160
 
161
161
 
162
- ALTER INDEX public.entries_pkey OWNER TO panic;
162
+ ALTER INDEX public.entries_pkey OWNER TO times;
163
163
 
164
164
  --
165
- -- Name: invoices_pkey; Type: CONSTRAINT; Schema: public; Owner: panic; Tablespace:
165
+ -- Name: invoices_pkey; Type: CONSTRAINT; Schema: public; Owner: times; Tablespace:
166
166
  --
167
167
 
168
168
  ALTER TABLE ONLY invoices
169
169
  ADD CONSTRAINT invoices_pkey PRIMARY KEY (id);
170
170
 
171
171
 
172
- ALTER INDEX public.invoices_pkey OWNER TO panic;
172
+ ALTER INDEX public.invoices_pkey OWNER TO times;
173
173
 
174
174
  --
175
- -- Name: projects_pkey; Type: CONSTRAINT; Schema: public; Owner: panic; Tablespace:
175
+ -- Name: projects_pkey; Type: CONSTRAINT; Schema: public; Owner: times; Tablespace:
176
176
  --
177
177
 
178
178
  ALTER TABLE ONLY projects
179
179
  ADD CONSTRAINT projects_pkey PRIMARY KEY (id);
180
180
 
181
181
 
182
- ALTER INDEX public.projects_pkey OWNER TO panic;
182
+ ALTER INDEX public.projects_pkey OWNER TO times;
183
183
 
184
184
  --
185
185
  -- Name: public; Type: ACL; Schema: -; Owner: postgres