bookkeeper 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/app/assets/javascripts/bookkeeper.js +2 -0
- data/app/controllers/bookkeeper/balance_controller.rb +15 -0
- data/app/controllers/bookkeeper/movements_controller.rb +67 -0
- data/app/models/bookkeeper/account.rb +25 -0
- data/app/models/bookkeeper/categories.rb +9 -0
- data/app/models/bookkeeper/movement.rb +27 -0
- data/app/models/bookkeeper/purchase.rb +4 -1
- data/app/uploaders/receipt_uploader.rb +8 -8
- data/app/views/bookkeeper/balance/index.html.erb +31 -0
- data/app/views/bookkeeper/movements/_form.html.erb +15 -0
- data/app/views/bookkeeper/movements/_search.html.erb +6 -0
- data/app/views/bookkeeper/movements/edit.html.erb +5 -0
- data/app/views/bookkeeper/movements/index.html.erb +36 -0
- data/app/views/bookkeeper/movements/new.html.erb +5 -0
- data/app/views/bookkeeper/purchases/_form.html.erb +7 -1
- data/config/locales/en.yml +23 -0
- data/config/locales/rails-i18n.en.yml +206 -0
- data/config/locales/rails-i18n.it.yml +206 -0
- data/config/locales/simple_form.en.yml +3 -2
- data/config/routes.rb +2 -0
- data/db/migrate/20130228234536_create_bookkeeper_accounts.rb +14 -0
- data/db/migrate/20130228234703_create_bookkeeper_movements.rb +14 -0
- data/db/migrate/20130308231159_add_details_to_purchases.rb +6 -0
- data/db/migrate/20130308231918_create_bookkeeper_categories.rb +9 -0
- data/lib/bookkeeper/engine.rb +0 -1
- data/lib/bookkeeper/version.rb +1 -1
- data/spec/controllers/bookkeeper/balance_controller_spec.rb +26 -0
- data/spec/controllers/bookkeeper/movements_controller_spec.rb +147 -0
- data/spec/controllers/bookkeeper/purchases_controller_spec.rb +144 -158
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/schema.rb +37 -3
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +69 -0
- data/spec/dummy/log/test.log +8485 -0
- data/spec/factories/bookkeeper_accounts.rb +10 -0
- data/spec/factories/bookkeeper_categories.rb +6 -0
- data/spec/factories/bookkeeper_movements.rb +22 -0
- data/spec/factories/bookkeeper_purchases.rb +1 -0
- data/spec/models/bookkeeper/account_spec.rb +21 -0
- data/spec/models/bookkeeper/categories_spec.rb +7 -0
- data/spec/models/bookkeeper/movement_spec.rb +28 -0
- data/spec/uploaders/receipt_uploader_spec.rb +5 -5
- metadata +53 -18
@@ -0,0 +1,206 @@
|
|
1
|
+
#encoding: utf-8
|
2
|
+
it:
|
3
|
+
date:
|
4
|
+
abbr_day_names:
|
5
|
+
- Dom
|
6
|
+
- Lun
|
7
|
+
- Mar
|
8
|
+
- Mer
|
9
|
+
- Gio
|
10
|
+
- Ven
|
11
|
+
- Sab
|
12
|
+
abbr_month_names:
|
13
|
+
-
|
14
|
+
- Gen
|
15
|
+
- Feb
|
16
|
+
- Mar
|
17
|
+
- Apr
|
18
|
+
- Mag
|
19
|
+
- Giu
|
20
|
+
- Lug
|
21
|
+
- Ago
|
22
|
+
- Set
|
23
|
+
- Ott
|
24
|
+
- Nov
|
25
|
+
- Dic
|
26
|
+
day_names:
|
27
|
+
- Domenica
|
28
|
+
- Lunedì
|
29
|
+
- Martedì
|
30
|
+
- Mercoledì
|
31
|
+
- Giovedì
|
32
|
+
- Venerdì
|
33
|
+
- Sabato
|
34
|
+
formats:
|
35
|
+
default: ! '%d-%m-%Y'
|
36
|
+
long: ! '%d %B %Y'
|
37
|
+
short: ! '%d %b'
|
38
|
+
month_names:
|
39
|
+
-
|
40
|
+
- Gennaio
|
41
|
+
- Febbraio
|
42
|
+
- Marzo
|
43
|
+
- Aprile
|
44
|
+
- Maggio
|
45
|
+
- Giugno
|
46
|
+
- Luglio
|
47
|
+
- Agosto
|
48
|
+
- Settembre
|
49
|
+
- Ottobre
|
50
|
+
- Novembre
|
51
|
+
- Dicembre
|
52
|
+
order:
|
53
|
+
- :day
|
54
|
+
- :month
|
55
|
+
- :year
|
56
|
+
datetime:
|
57
|
+
distance_in_words:
|
58
|
+
about_x_hours:
|
59
|
+
one: circa un'ora
|
60
|
+
other: circa %{count} ore
|
61
|
+
about_x_months:
|
62
|
+
one: circa un mese
|
63
|
+
other: circa %{count} mesi
|
64
|
+
about_x_years:
|
65
|
+
one: circa un anno
|
66
|
+
other: circa %{count} anni
|
67
|
+
almost_x_years:
|
68
|
+
one: circa 1 anno
|
69
|
+
other: circa %{count} anni
|
70
|
+
half_a_minute: mezzo minuto
|
71
|
+
less_than_x_minutes:
|
72
|
+
one: meno di un minuto
|
73
|
+
other: meno di %{count} minuti
|
74
|
+
less_than_x_seconds:
|
75
|
+
one: meno di un secondo
|
76
|
+
other: meno di %{count} secondi
|
77
|
+
over_x_years:
|
78
|
+
one: oltre un anno
|
79
|
+
other: oltre %{count} anni
|
80
|
+
x_days:
|
81
|
+
one: 1 giorno
|
82
|
+
other: ! '%{count} giorni'
|
83
|
+
x_minutes:
|
84
|
+
one: 1 minuto
|
85
|
+
other: ! '%{count} minuti'
|
86
|
+
x_months:
|
87
|
+
one: 1 mese
|
88
|
+
other: ! '%{count} mesi'
|
89
|
+
x_seconds:
|
90
|
+
one: 1 secondo
|
91
|
+
other: ! '%{count} secondi'
|
92
|
+
prompts:
|
93
|
+
day: Giorno
|
94
|
+
hour: Ora
|
95
|
+
minute: Minuto
|
96
|
+
month: Mese
|
97
|
+
second: Secondi
|
98
|
+
year: Anno
|
99
|
+
errors: &errors
|
100
|
+
format: ! '%{attribute} %{message}'
|
101
|
+
messages:
|
102
|
+
accepted: deve essere accettata
|
103
|
+
blank: non può essere lasciato in bianco
|
104
|
+
confirmation: non coincide con la conferma
|
105
|
+
empty: non può essere vuoto
|
106
|
+
equal_to: deve essere uguale a %{count}
|
107
|
+
even: deve essere pari
|
108
|
+
exclusion: è riservato
|
109
|
+
greater_than: deve essere superiore a %{count}
|
110
|
+
greater_than_or_equal_to: deve essere superiore o uguale a %{count}
|
111
|
+
inclusion: non è incluso nella lista
|
112
|
+
invalid: non è valido
|
113
|
+
less_than: deve essere meno di %{count}
|
114
|
+
less_than_or_equal_to: deve essere meno o uguale a %{count}
|
115
|
+
not_a_number: non è un numero
|
116
|
+
not_an_integer: non è un intero
|
117
|
+
odd: deve essere dispari
|
118
|
+
record_invalid: ! 'Validazione fallita: %{errors}'
|
119
|
+
taken: è già in uso
|
120
|
+
too_long:
|
121
|
+
one: è troppo lungo (il massimo è 1 carattere)
|
122
|
+
other: è troppo lungo (il massimo è %{count} caratteri)
|
123
|
+
too_short:
|
124
|
+
one: è troppo corto (il minimo è 1 carattere)
|
125
|
+
other: è troppo corto (il minimo è %{count} caratteri)
|
126
|
+
wrong_length:
|
127
|
+
one: è della lunghezza sbagliata (deve essere di 1 carattere)
|
128
|
+
other: è della lunghezza sbagliata (deve essere di %{count} caratteri)
|
129
|
+
template:
|
130
|
+
body: ! 'Per favore ricontrolla i seguenti campi:'
|
131
|
+
header:
|
132
|
+
one: ! 'Non posso salvare questo %{model}: 1 errore'
|
133
|
+
other: ! 'Non posso salvare questo %{model}: %{count} errori.'
|
134
|
+
helpers:
|
135
|
+
select:
|
136
|
+
prompt: Per favore, seleziona
|
137
|
+
submit:
|
138
|
+
create: Crea %{model}
|
139
|
+
submit: Invia %{model}
|
140
|
+
update: Aggiorna %{model}
|
141
|
+
number:
|
142
|
+
currency:
|
143
|
+
format:
|
144
|
+
delimiter: .
|
145
|
+
format: ! '%n %u'
|
146
|
+
precision: 2
|
147
|
+
separator: ! '.'
|
148
|
+
significant: false
|
149
|
+
strip_insignificant_zeros: false
|
150
|
+
unit: €
|
151
|
+
format:
|
152
|
+
delimiter: .
|
153
|
+
precision: 2
|
154
|
+
separator: ! ','
|
155
|
+
significant: false
|
156
|
+
strip_insignificant_zeros: false
|
157
|
+
human:
|
158
|
+
decimal_units:
|
159
|
+
format: ! '%n %u'
|
160
|
+
units:
|
161
|
+
billion: Miliardi
|
162
|
+
million: Milioni
|
163
|
+
quadrillion: Biliardi
|
164
|
+
thousand: Mila
|
165
|
+
trillion: Bilioni
|
166
|
+
unit: ''
|
167
|
+
format:
|
168
|
+
delimiter: ''
|
169
|
+
precision: 1
|
170
|
+
significant: true
|
171
|
+
strip_insignificant_zeros: true
|
172
|
+
storage_units:
|
173
|
+
format: ! '%n %u'
|
174
|
+
units:
|
175
|
+
byte:
|
176
|
+
one: Byte
|
177
|
+
other: Byte
|
178
|
+
gb: GB
|
179
|
+
kb: KB
|
180
|
+
mb: MB
|
181
|
+
tb: TB
|
182
|
+
percentage:
|
183
|
+
format:
|
184
|
+
delimiter: ''
|
185
|
+
precision:
|
186
|
+
format:
|
187
|
+
delimiter: ''
|
188
|
+
support:
|
189
|
+
array:
|
190
|
+
last_word_connector: ! ' e '
|
191
|
+
two_words_connector: ! ' e '
|
192
|
+
words_connector: ! ', '
|
193
|
+
time:
|
194
|
+
am: am
|
195
|
+
formats:
|
196
|
+
default: ! '%a %d %b %Y, %H:%M:%S %z'
|
197
|
+
long: ! '%d %B %Y %H:%M'
|
198
|
+
short: ! '%d %b %H:%M'
|
199
|
+
pm: pm
|
200
|
+
# remove these aliases after 'activemodel' and 'activerecord' namespaces are removed from Rails repository
|
201
|
+
activemodel:
|
202
|
+
errors:
|
203
|
+
<<: *errors
|
204
|
+
activerecord:
|
205
|
+
errors:
|
206
|
+
<<: *errors
|
@@ -3,11 +3,12 @@ en:
|
|
3
3
|
"yes": 'Yes'
|
4
4
|
"no": 'No'
|
5
5
|
required:
|
6
|
-
text: 'required'
|
7
|
-
mark: '*'
|
6
|
+
# text: 'required'
|
7
|
+
# mark: '*'
|
8
8
|
# You can uncomment the line below if you need to overwrite the whole required html.
|
9
9
|
# When using html, text and mark won't be used.
|
10
10
|
# html: '<abbr title="required">*</abbr>'
|
11
|
+
html: '<a href="#" data-toggle="tooltip" title="Required"><i class="icon-exclamation-sign"></i></a>'
|
11
12
|
error_notification:
|
12
13
|
default_message: "Please review the problems below:"
|
13
14
|
# Labels and hints examples
|
data/config/routes.rb
CHANGED
@@ -0,0 +1,14 @@
|
|
1
|
+
class CreateBookkeeperAccounts < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :bookkeeper_accounts do |t|
|
4
|
+
t.string :title, nil: false
|
5
|
+
t.decimal :initial_balance, precision: 8, scale: 2, default: 0
|
6
|
+
t.decimal :balance, precision: 8, scale: 2, nil: false
|
7
|
+
t.datetime :start_date
|
8
|
+
t.datetime :end_date
|
9
|
+
t.timestamps
|
10
|
+
end
|
11
|
+
add_index :bookkeeper_accounts, :title
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class CreateBookkeeperMovements < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :bookkeeper_movements do |t|
|
4
|
+
t.integer :account_id, nil: false
|
5
|
+
t.decimal :amount, precision: 8, scale: 2, nil: false
|
6
|
+
t.string :description, nil: false
|
7
|
+
t.timestamps
|
8
|
+
end
|
9
|
+
add_index :bookkeeper_movements, :account_id
|
10
|
+
add_index :bookkeeper_movements, :amount
|
11
|
+
add_index :bookkeeper_movements, :description
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
data/lib/bookkeeper/engine.rb
CHANGED
data/lib/bookkeeper/version.rb
CHANGED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Bookkeeper
|
4
|
+
describe BalanceController do
|
5
|
+
describe "GET index" do
|
6
|
+
before :each do
|
7
|
+
@account = create(:bookkeeper_account)
|
8
|
+
end
|
9
|
+
|
10
|
+
it "assigns all movements as @movements in reverse creation date" do
|
11
|
+
movement1 = create(:bookkeeper_movement, account: @account)
|
12
|
+
movement2 = create(:bookkeeper_movement, account: @account)
|
13
|
+
movement3 = create(:bookkeeper_movement, account: @account)
|
14
|
+
movement4 = create(:bookkeeper_movement, account: @account)
|
15
|
+
get :index, { use_route: :movements }
|
16
|
+
expect(assigns(:movements)).to eq [movement4, movement3, movement2, movement1]
|
17
|
+
end
|
18
|
+
|
19
|
+
it "renders the :index template" do
|
20
|
+
get :index, { use_route: :movements }
|
21
|
+
expect(response).to render_template :index
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
@@ -0,0 +1,147 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
# module Bookkeeper
|
4
|
+
# describe MovementsController do
|
5
|
+
# describe "GET index" do
|
6
|
+
# it "assigns all movements as @movements" do
|
7
|
+
# movement = create(:bookkeeper_movement)
|
8
|
+
# get :index, { use_route: :movements }
|
9
|
+
# expect(assigns(:movements)).to match_array [movement]
|
10
|
+
# end
|
11
|
+
#
|
12
|
+
# it "renders the :index template" do
|
13
|
+
# movement = create(:bookkeeper_movement)
|
14
|
+
# get :index, { use_route: :movements }
|
15
|
+
# expect(response).to render_template :index
|
16
|
+
# end
|
17
|
+
#
|
18
|
+
# it "shows all movements ordered by creation" do
|
19
|
+
# first_movement = create(:bookkeeper_movement)
|
20
|
+
# last_movement = create(:bookkeeper_movement)
|
21
|
+
# get :index, { use_route: :movements }
|
22
|
+
# expect(assigns(:movements)).to eq([last_movement, first_movement])
|
23
|
+
# end
|
24
|
+
#
|
25
|
+
# end
|
26
|
+
#
|
27
|
+
# describe "GET new" do
|
28
|
+
# it "assigns a new movement as @movement" do
|
29
|
+
# get :new, { use_route: :movements }
|
30
|
+
# expect(assigns(:movement)).to be_a_new(Movement)
|
31
|
+
# end
|
32
|
+
#
|
33
|
+
# it "renders the :new template" do
|
34
|
+
# get :new, { use_route: :movements }
|
35
|
+
# expect(response).to render_template :new
|
36
|
+
# end
|
37
|
+
# end
|
38
|
+
#
|
39
|
+
# describe "GET edit" do
|
40
|
+
# it "assigns the requested movement as @movement" do
|
41
|
+
# movement = create(:bookkeeper_movement)
|
42
|
+
# get :edit, { id: movement.to_param, use_route: :movements }
|
43
|
+
# expect(assigns(:movement)).to eq(movement)
|
44
|
+
# end
|
45
|
+
#
|
46
|
+
# it "renders the :edit template" do
|
47
|
+
# movement = create(:bookkeeper_movement)
|
48
|
+
# get :edit, { id: movement.to_param, use_route: :movements }
|
49
|
+
# expect(response).to render_template :edit
|
50
|
+
# end
|
51
|
+
# end
|
52
|
+
#
|
53
|
+
# describe "POST create" do
|
54
|
+
# describe "with valid params" do
|
55
|
+
# it "creates a new movement" do
|
56
|
+
# expect {
|
57
|
+
# post :create, {movement: attributes_for(:bookkeeper_movement), use_route: :movements}
|
58
|
+
# }.to change(Movement, :count).by(1)
|
59
|
+
# end
|
60
|
+
#
|
61
|
+
# it "assigns a newly created movement as @movement" do
|
62
|
+
# post :create, {movement: attributes_for(:bookkeeper_movement), use_route: :movements}
|
63
|
+
# expect(assigns(:movement)).to be_a(Movement)
|
64
|
+
# expect(assigns(:movement)).to be_persisted
|
65
|
+
# end
|
66
|
+
#
|
67
|
+
# it "redirects to the balance page" do
|
68
|
+
# post :create, {movement: attributes_for(:bookkeeper_movement), use_route: :movements}
|
69
|
+
# expect(response).to redirect_to :balance_index
|
70
|
+
# end
|
71
|
+
# end
|
72
|
+
#
|
73
|
+
# describe "with invalid params" do
|
74
|
+
# it "does not save the new movement" do
|
75
|
+
# expect {
|
76
|
+
# post :create, {movement: attributes_for(:bookkeeper_invalid_movement), use_route: :movements}
|
77
|
+
# }.to_not change(Movement, :count).by(1)
|
78
|
+
# end
|
79
|
+
#
|
80
|
+
# it "assigns a newly created but unsaved movement as @movement" do
|
81
|
+
# post :create, {movement: attributes_for(:bookkeeper_invalid_movement), use_route: :movements}
|
82
|
+
# expect(assigns(:movement)).to be_a_new(Movement)
|
83
|
+
# end
|
84
|
+
#
|
85
|
+
# it "re-renders the 'new' template" do
|
86
|
+
# post :create, {movement: attributes_for(:bookkeeper_invalid_movement), use_route: :movements}
|
87
|
+
# expect(response).to render_template :new
|
88
|
+
# end
|
89
|
+
# end
|
90
|
+
# end
|
91
|
+
#
|
92
|
+
# describe "PUT update" do
|
93
|
+
# before :each do
|
94
|
+
# @movement_amount = 12.0
|
95
|
+
# @movement = create(:bookkeeper_movement, amount: @movement_amount, description: 'Test lorem ipsum')
|
96
|
+
# end
|
97
|
+
#
|
98
|
+
# describe "with valid params" do
|
99
|
+
# it "updates the requested movement" do
|
100
|
+
# put :update, {id: @movement, use_route: :movements, movement: attributes_for(:bookkeeper_movement)}
|
101
|
+
# expect(assigns(:movement)).to eq(@movement)
|
102
|
+
# end
|
103
|
+
#
|
104
|
+
# it "assigns the requested movement as @movement" do
|
105
|
+
# put :update, {id: @movement.to_param, movement: attributes_for(:bookkeeper_movement), use_route: :movements}
|
106
|
+
# expect(assigns(:movement)).to eq(@movement)
|
107
|
+
# end
|
108
|
+
#
|
109
|
+
# it "redirects to the balance page" do
|
110
|
+
# put :update, {id: @movement.to_param, movement: attributes_for(:bookkeeper_movement), use_route: :movements}
|
111
|
+
# expect(response).to redirect_to :balance_index
|
112
|
+
# end
|
113
|
+
# end
|
114
|
+
#
|
115
|
+
# describe "with invalid params" do
|
116
|
+
# it "assigns the movement as @movement" do
|
117
|
+
# put :update, {id: @movement.to_param, movement: attributes_for(:bookkeeper_invalid_movement), use_route: :movements}
|
118
|
+
# @movement.reload
|
119
|
+
# expect(@movement.amount).to eq(@movement_amount)
|
120
|
+
# end
|
121
|
+
#
|
122
|
+
# it "re-renders the 'edit' template" do
|
123
|
+
# put :update, {id: @movement.to_param, movement: attributes_for(:bookkeeper_invalid_movement), use_route: :movements}
|
124
|
+
# expect(response).to render_template :edit
|
125
|
+
# end
|
126
|
+
# end
|
127
|
+
# end
|
128
|
+
#
|
129
|
+
# describe "DELETE destroy" do
|
130
|
+
# before :each do
|
131
|
+
# @movement = create(:bookkeeper_movement)
|
132
|
+
# end
|
133
|
+
# it "destroys the requested movement" do
|
134
|
+
# expect {
|
135
|
+
# delete :destroy, {id: @movement.to_param, use_route: :movements}
|
136
|
+
# }.to change(Movement, :count).by(-1)
|
137
|
+
# end
|
138
|
+
#
|
139
|
+
# it "redirects to the balance page" do
|
140
|
+
# delete :destroy, {id: @movement.to_param, use_route: :movements}
|
141
|
+
# expect(response).to redirect_to :balance_index
|
142
|
+
# end
|
143
|
+
# end
|
144
|
+
#
|
145
|
+
# end
|
146
|
+
# end
|
147
|
+
#
|