bookkeeper 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. data/app/assets/javascripts/bookkeeper.js +1 -1
  2. data/app/controllers/bookkeeper/balance_controller.rb +2 -6
  3. data/app/controllers/bookkeeper/incomings_controller.rb +41 -0
  4. data/app/controllers/bookkeeper/outgoings_controller.rb +41 -0
  5. data/app/models/bookkeeper/account.rb +26 -2
  6. data/app/models/bookkeeper/incoming.rb +5 -0
  7. data/app/models/bookkeeper/movement.rb +18 -3
  8. data/app/models/bookkeeper/outgoing.rb +6 -0
  9. data/app/views/bookkeeper/balance/_balance_chart.html.erb +26 -0
  10. data/app/views/bookkeeper/balance/_movements_chart.html.erb +46 -0
  11. data/app/views/bookkeeper/balance/index.html.erb +52 -27
  12. data/app/views/bookkeeper/incomings/_form.html.erb +3 -0
  13. data/app/views/bookkeeper/{movements → incomings}/edit.html.erb +0 -0
  14. data/app/views/bookkeeper/{movements → incomings}/new.html.erb +0 -0
  15. data/app/views/bookkeeper/outgoings/_form.html.erb +3 -0
  16. data/app/views/bookkeeper/outgoings/edit.html.erb +5 -0
  17. data/app/views/bookkeeper/outgoings/new.html.erb +5 -0
  18. data/app/views/bookkeeper/purchases/_form.html.erb +1 -1
  19. data/app/views/bookkeeper/purchases/index.html.erb +1 -1
  20. data/app/views/bookkeeper/shared/_movement_form.html.erb +16 -0
  21. data/config/locales/en.yml +20 -8
  22. data/config/locales/it.yml +84 -0
  23. data/config/locales/simple_form.it.yml +28 -0
  24. data/config/routes.rb +2 -1
  25. data/db/migrate/20130317163103_add_sti_to_movements.rb +6 -0
  26. data/db/migrate/20130317165439_add_default_to_accounts.rb +6 -0
  27. data/db/migrate/20130317181020_add_date_to_movements.rb +5 -0
  28. data/lib/bookkeeper/version.rb +1 -1
  29. metadata +20 -6
  30. data/app/controllers/bookkeeper/movements_controller.rb +0 -67
  31. data/app/views/bookkeeper/movements/_form.html.erb +0 -15
@@ -3,7 +3,7 @@
3
3
  $(document).ready(function(){
4
4
  $('a[data-toggle=tooltip]').tooltip();
5
5
 
6
- $('input.datepicker').datepicker({ yearRange: "1920:2020", changeMonth: true, changeYear: true });
6
+ $('input.datepicker').datepicker({ weekStart: 1 });
7
7
 
8
8
  $('form .add-on.calendar').click(function(){
9
9
  var el = this.parentNode;
@@ -3,12 +3,8 @@ require_dependency "bookkeeper/application_controller"
3
3
  module Bookkeeper
4
4
  class BalanceController < ApplicationController
5
5
  def index
6
- @movements = Movement.all
7
-
8
- respond_to do |format|
9
- format.html
10
- format.json { render json: @movements }
11
- end
6
+ @account = Account.first
7
+ @movements = @account.movements
12
8
  end
13
9
  end
14
10
  end
@@ -0,0 +1,41 @@
1
+ require_dependency "bookkeeper/application_controller"
2
+
3
+ module Bookkeeper
4
+ class IncomingsController < ApplicationController
5
+ def new
6
+ @incoming = Incoming.new
7
+ end
8
+
9
+ def edit
10
+ @incoming = Incoming.find(params[:id])
11
+ end
12
+
13
+ def create
14
+ @incoming = Incoming.new(params[:incoming])
15
+
16
+ if @incoming.save
17
+ redirect_to balance_index_path, notice: I18n.t('.bookkeeper.controllers.incomings.created')
18
+ else
19
+ render action: "new"
20
+ end
21
+ end
22
+
23
+ def update
24
+ @incoming = Incoming.find(params[:id])
25
+
26
+ if @incoming.update_attributes(params[:incoming])
27
+ redirect_to balance_index_path, notice: I18n.t('.bookkeeper.controllers.incomings.updated')
28
+ else
29
+ render action: "edit"
30
+ end
31
+ end
32
+
33
+ def destroy
34
+ @incoming = Incoming.find(params[:id])
35
+ @incoming.destroy
36
+ flash[:notice] = I18n.t('.bookkeeper.controllers.incomings.destroyed')
37
+
38
+ redirect_to balance_index_path
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,41 @@
1
+ require_dependency "bookkeeper/application_controller"
2
+
3
+ module Bookkeeper
4
+ class OutgoingsController < ApplicationController
5
+ def new
6
+ @outgoing = Outgoing.new
7
+ end
8
+
9
+ def edit
10
+ @outgoing = Outgoing.find(params[:id])
11
+ end
12
+
13
+ def create
14
+ @outgoing = Outgoing.new(params[:outgoing])
15
+
16
+ if @outgoing.save
17
+ redirect_to balance_index_path, notice: I18n.t('.bookkeeper.controllers.outgoings.created')
18
+ else
19
+ render action: "new"
20
+ end
21
+ end
22
+
23
+ def update
24
+ @outgoing = Outgoing.find(params[:id])
25
+
26
+ if @outgoing.update_attributes(params[:outgoing])
27
+ redirect_to balance_index_path, notice: I18n.t('.bookkeeper.controllers.outgoings.updated')
28
+ else
29
+ render action: "edit"
30
+ end
31
+ end
32
+
33
+ def destroy
34
+ @outgoing = Outgoing.find(params[:id])
35
+ @outgoing.destroy
36
+ flash[:notice] = I18n.t('.bookkeeper.controllers.outgoings.destroyed')
37
+
38
+ redirect_to balance_index_path
39
+ end
40
+ end
41
+ end
@@ -1,24 +1,48 @@
1
1
  module Bookkeeper
2
2
  class Account < ActiveRecord::Base
3
- attr_accessible :start_date, :initial_balance
3
+ attr_accessible :title, :start_date, :initial_balance, :default
4
4
 
5
5
  has_many :movements, class_name: "Bookkeeper::Movement"
6
+ has_many :incomings, class_name: "Bookkeeper::Incoming"
7
+ has_many :outgoings, class_name: "Bookkeeper::Outgoing"
6
8
 
7
9
  validates :balance, numericality: { allow_nil: true }
8
10
  validates :title, presence: true, uniqueness: true
11
+ validate :default_must_be_uniq
9
12
 
10
13
  before_save do
11
14
  self.update_start_date if self.start_date.blank? and !self.movements.empty?
12
15
  self.rebuild_balance
13
16
  end
14
17
 
18
+ def update_balance
19
+ self.rebuild_balance
20
+ self.save
21
+ end
22
+
15
23
  def rebuild_balance
16
- self.balance = self.initial_balance + Movement.where('bookkeeper_movements.account_id = ?', self.id).sum(:amount)
24
+ self.balance = self.initial_balance + self.incomings.sum(:amount) - self.outgoings.sum(:amount)
17
25
  end
18
26
 
19
27
  def update_start_date
20
28
  self.update_attribute(:start_date, self.movements.first.created_at)
21
29
  end
30
+
31
+ def self.default
32
+ if account = Account.find_by_default(true)
33
+ account
34
+ else
35
+ Account.create(title: "Default", start_date: Time.now, initial_balance: 0.0, default: true)
36
+ end
37
+ end
38
+
39
+ protected
40
+
41
+ def default_must_be_uniq
42
+ if !self.persisted? && Account.where(default: true).first != self
43
+ errors.add(:base, I18n.t(".default_must_be_uniq"))
44
+ end
45
+ end
22
46
  end
23
47
  end
24
48
 
@@ -0,0 +1,5 @@
1
+ module Bookkeeper
2
+ class Incoming < Movement
3
+ end
4
+ end
5
+
@@ -1,6 +1,6 @@
1
1
  module Bookkeeper
2
2
  class Movement < ActiveRecord::Base
3
- attr_accessible :amount, :description
3
+ attr_accessible :amount, :description, :date
4
4
 
5
5
  belongs_to :account, class_name: "Bookkeeper::Account"
6
6
  has_many :categories, as: :categorizable
@@ -9,14 +9,29 @@ module Bookkeeper
9
9
  validates :description, presence: true
10
10
  validate :amount_cannot_be_zero
11
11
  validates :account, presence: true
12
+ validates :date, presence: true
12
13
 
13
- default_scope order('created_at DESC')
14
+ scope :ordered, order('date ASC, created_at ASC')
15
+ scope :reverse_ordered, order('date DESC, created_at DESC')
14
16
 
17
+ before_validation do
18
+ self.account = Account.default unless self.account
19
+ end
15
20
 
16
21
  after_save do
17
- self.account.rebuild_balance
22
+ self.account.update_balance
23
+ end
24
+
25
+ after_destroy do
26
+ self.account.update_balance
18
27
  end
19
28
 
29
+ def incoming?
30
+ self.class == Bookkeeper::Incoming
31
+ end
32
+
33
+ protected
34
+
20
35
  def amount_cannot_be_zero
21
36
  if !amount.blank? && amount == 0
22
37
  errors.add(:amount, I18n.t(".cannot_be_zero"))
@@ -0,0 +1,6 @@
1
+ module Bookkeeper
2
+ class Outgoing < Movement
3
+ end
4
+ end
5
+
6
+
@@ -0,0 +1,26 @@
1
+ <% content_for :javascripts do %>
2
+ <script type="text/javascript">
3
+ google.setOnLoadCallback(drawBalanceChart);
4
+ function drawBalanceChart() {
5
+ var data = google.visualization.arrayToDataTable([
6
+ ['<%=t ".date" %>', null],
7
+ <% balance = @account.initial_balance %>
8
+ ['<%= @account.start_date.strftime("%d/%m/%Y") %>', <%= balance %> ],
9
+ <% @movements.ordered.each do |movement| %>
10
+ <% movement.incoming? ? (balance += movement.amount) : (balance -= movement.amount) %>
11
+ ['<%= movement.date.strftime("%d/%m/%Y") %>', <%= balance %> ],
12
+ <% end %>
13
+ ]);
14
+
15
+ var options = {
16
+ title: '<%=t ".title" %>',
17
+ colors: ['#F89406']
18
+ };
19
+
20
+ var chart = new google.visualization.LineChart(document.getElementById('balance_chart'));
21
+ chart.draw(data, options);
22
+ }
23
+
24
+ </script>
25
+ <% end %>
26
+
@@ -0,0 +1,46 @@
1
+ <% content_for :javascripts do %>
2
+ <script type="text/javascript">
3
+ google.load("visualization", "1", {packages:["corechart"]});
4
+ google.setOnLoadCallback(drawMovementsChart);
5
+ function drawMovementsChart() {
6
+ var data = new google.visualization.DataTable();
7
+ data.addColumn('string', '<%= t ".date" %>');
8
+ data.addColumn('number', '<%= t ".movement" %>');
9
+ data.addRows([
10
+ <% @movements.ordered.each do |movement| %>
11
+ <% if movement.incoming? %>
12
+ ['<%= movement.date.strftime("%d/%m/%Y") %>', <%= movement.amount %> ],
13
+ <% else %>
14
+ ['<%= movement.date.strftime("%d/%m/%Y") %>', <%= -movement.amount %> ],
15
+ <% end %>
16
+ <% end %>
17
+ ]);
18
+
19
+ var options = {
20
+ isStacked: true,
21
+ title: '<%=t ".title" %>',
22
+ colors: ['#468847', '#F89406'],
23
+ chartArea: { top: 30 },
24
+ hAxis: { format:'#.##€' },
25
+ };
26
+
27
+ var view = new google.visualization.DataView(data);
28
+ view.setColumns([0, {
29
+ type: 'number',
30
+ label: null,
31
+ calc: function (dt, row) {
32
+ return (dt.getValue(row, 1) > 0) ? dt.getValue(row, 1) : null;
33
+ }
34
+ }, {
35
+ type: 'number',
36
+ label: null,
37
+ calc: function (dt, row) {
38
+ return (dt.getValue(row, 1) < 0) ? dt.getValue(row, 1) : null;
39
+ }
40
+ }]);
41
+ var chart = new google.visualization.BarChart(document.getElementById('movements_chart'));
42
+ chart.draw(view, options);
43
+ }
44
+ </script>
45
+ <% end %>
46
+
@@ -1,31 +1,56 @@
1
1
  <h1><%= t '.title' %></h1>
2
2
 
3
- <table class='table table-striped table-condensed table-bordered'>
4
- <thead>
5
- <tr>
6
- <th><%=t 'bookkeeper.models.movement.attributes.amount' %></th>
7
- <th><%=t 'bookkeeper.models.movement.attributes.description' %></th>
8
- <th><%=t 'bookkeeper.models.movement.attributes.created_at' %></th>
9
- <th><%=t 'bookkeeper.models.movement.attributes.updated_at' %></th>
10
- <th></th>
11
- </tr>
12
- </thead>
13
- <tbody>
14
- <% @movements.each do |movement| %>
15
- <tr>
16
- <td><%= number_to_currency movement.amount %></td>
17
- <td><%= movement.description %></td>
18
- <td><%=l movement.created_at, format: :short rescue '' %></td>
19
- <td><%=l movement.updated_at, format: :short rescue '' %></td>
20
- <td>
21
- <%= link_to ('<i class="icon-pencil"></i> ' + t('bookkeeper.actions.edit')).html_safe, edit_movement_path(movement), class: 'btn btn-mini' %>
22
- <%= link_to ('<i class="icon-remove"></i> ' + t('bookkeeper.actions.destroy')).html_safe, movement, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-mini btn-danger' %>
23
- </td>
24
- </tr>
25
- <% end %>
26
- </tbody>
27
- </table>
3
+ <div class="row">
4
+ <div class="span3">
5
+ <h3><%=t '.account_balance' %></h3>
6
+ <p><%= number_to_currency @account.balance %></p>
7
+ </div>
8
+ <div id="balance_chart" class="span9" style="height: 300px;"></div>
9
+ </div>
28
10
 
29
- <br />
11
+ <div class="row">
12
+ <div class="span6">
13
+ <table class='table table-striped table-condensed table-bordered'>
14
+ <thead>
15
+ <tr>
16
+ <th><%=t 'bookkeeper.models.movement.attributes.amount' %></th>
17
+ <th><%=t 'bookkeeper.models.movement.attributes.description' %></th>
18
+ <th><%=t 'bookkeeper.models.movement.attributes.date' %></th>
19
+ <th></th>
20
+ </tr>
21
+ </thead>
22
+ <tbody>
23
+ <% @movements.reverse_ordered.each do |movement| %>
24
+ <tr>
25
+ <td>
26
+ <span class="label label-<%= movement.incoming? ? "success" : "warning" %>"><%= (movement.incoming? ? '<i class="icon-circle-arrow-down"></i>' : '<i class="icon-circle-arrow-up"></i>').html_safe %></span>
27
+ <%= number_to_currency movement.amount %></td>
28
+ <td><%= movement.description %></td>
29
+ <td><%=l movement.date, format: :short rescue '' %></td>
30
+ <td>
31
+ <% if movement.incoming? %>
32
+ <%= link_to ('<i class="icon-pencil"></i> ' + t('bookkeeper.actions.edit')).html_safe, edit_incoming_path(movement), class: 'btn btn-mini' %>
33
+ <% else %>
34
+ <%= link_to ('<i class="icon-pencil"></i> ' + t('bookkeeper.actions.edit')).html_safe, edit_outgoing_path(movement), class: 'btn btn-mini' %>
35
+ <% end %>
36
+ <%= link_to ('<i class="icon-remove"></i> ' + t('bookkeeper.actions.destroy')).html_safe, movement, method: :delete, data: { confirm: t('bookkeeper.actions.destroy_confirm', default: 'Are you sure?') }, class: 'btn btn-mini btn-danger' %>
37
+ </td>
38
+ </tr>
39
+ <% end %>
40
+ </tbody>
41
+ </table>
30
42
 
31
- <%= link_to ('<i class="icon-plus"></i> ' + t('.new')).html_safe, new_movement_path, class: 'btn' %>
43
+ <br />
44
+
45
+ <%= link_to ('<i class="icon-circle-arrow-down"></i> ' + t('.new_incoming')).html_safe, new_incoming_path, class: 'btn btn-success' %>
46
+ <%= link_to ('<i class="icon-circle-arrow-up"></i> ' + t('.new_outgoing')).html_safe, new_outgoing_path, class: 'btn btn-warning' %>
47
+ </div>
48
+ <div id="movements_chart" class="span6" style="height: 500px;"></div>
49
+ </div>
50
+
51
+
52
+ <% content_for :javascripts do %>
53
+ <script type="text/javascript" src="https://www.google.com/jsapi"></script>
54
+ <% end %>
55
+ <%= render partial: "movements_chart" %>
56
+ <%= render partial: "balance_chart" %>
@@ -0,0 +1,3 @@
1
+ <%= simple_form_for @incoming, html: { class: 'form-horizontal' } do |f| %>
2
+ <%= render partial: 'bookkeeper/shared/movement_form', locals: { f: f } %>
3
+ <% end %>
@@ -0,0 +1,3 @@
1
+ <%= simple_form_for @outgoing, html: { class: 'form-horizontal' } do |f| %>
2
+ <%= render partial: 'bookkeeper/shared/movement_form', locals: { f: f } %>
3
+ <% end %>
@@ -0,0 +1,5 @@
1
+ <h1><%= t '.title' %></h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to ('<i class="icon-arrow-left"></i> ' + t('bookkeeper.actions.back')).html_safe, balance_index_path, class: 'btn' %>
@@ -0,0 +1,5 @@
1
+ <h1><%= t '.title' %></h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to ('<i class="icon-arrow-left"></i> ' + t('bookkeeper.actions.back')).html_safe, balance_index_path, class: 'btn' %>
@@ -14,7 +14,7 @@
14
14
  <%= content_tag :span, '<i class="icon-money"></i>'.html_safe, class: "add-on calendar" %>
15
15
  <%= f.input_field :amount, class: "input-mini" %>
16
16
  <% end %>
17
- <%= f.input :warranty_duration, collection: [["6 months", 6], ["1 year", 12], ["2 years", 24], ["3 years", 36]], input_html: { class: 'input-small' } %>
17
+ <%= f.input :warranty_duration, collection: [["6 #{t('simple_form.labels.purchase.months')}", 6], ["1 #{t('simple_form.labels.purchase.year')}", 12], ["2 #{t('simple_form.labels.purchase.years')}", 24], ["3 #{t('simple_form.labels.purchase.years')}", 36]], input_html: { class: 'input-small' } %>
18
18
  <%= f.input :receipt %>
19
19
  </div>
20
20
  <div class="form-actions">
@@ -24,7 +24,7 @@
24
24
  <td><%=l purchase.updated_at, format: :short rescue '' %></td>
25
25
  <td>
26
26
  <%= link_to ('<i class="icon-pencil"></i> ' + t('bookkeeper.actions.edit')).html_safe, edit_purchase_path(purchase), class: 'btn btn-mini' %>
27
- <%= link_to ('<i class="icon-remove"></i> ' + t('bookkeeper.actions.destroy')).html_safe, purchase, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-mini btn-danger' %>
27
+ <%= link_to ('<i class="icon-remove"></i> ' + t('bookkeeper.actions.destroy')).html_safe, purchase, method: :delete, data: { confirm: t('bookkeeper.actions.destroy_confirm', default: 'Are you sure?') }, class: 'btn btn-mini btn-danger' %>
28
28
  </td>
29
29
  </tr>
30
30
  <% end %>
@@ -0,0 +1,16 @@
1
+ <%= f.error_notification %>
2
+
3
+ <div class="form-inputs">
4
+ <%= f.input :amount, :wrapper => :append do %>
5
+ <%= f.input_field :amount, class: "input-mini" %>
6
+ <%= content_tag :span, '&euro;'.html_safe, class: "add-on" %>
7
+ <% end %>
8
+ <%= f.input :description, input_html: { class: 'input-xxlarge' } %>
9
+ <%= f.input :date, :wrapper => :prepend do %>
10
+ <%= content_tag :span, '<i class="icon-calendar"></i>'.html_safe, class: "add-on calendar" %>
11
+ <%= f.input_field :date, as: :datepicker, data: { 'date-format' => 'dd/mm/yyyy' } %>
12
+ <% end %>
13
+ </div>
14
+ <div class="form-actions">
15
+ <%= button_tag ('<i class="icon-ok"></i> ' + t('bookkeeper.actions.save')).html_safe, class: 'btn' %>
16
+ </div>
@@ -27,13 +27,17 @@ en:
27
27
  # controllers
28
28
  controllers:
29
29
  purchases:
30
- created: 'Purchase was successfully created.'
31
- updated: 'Purchase was successfully updated.'
32
- destroyed: 'Purchase was successfully deleted.'
33
- movementss:
34
- created: 'Movement was successfully created.'
35
- updated: 'Movement was successfully updated.'
36
- destroyed: 'Movement was successfully deleted.'
30
+ created: 'The purchase was successfully created.'
31
+ updated: 'The purchase was successfully updated.'
32
+ destroyed: 'The purchase was successfully deleted.'
33
+ incomings:
34
+ created: 'The movement was successfully created.'
35
+ updated: 'The movement was successfully updated.'
36
+ destroyed: 'The movement was successfully deleted.'
37
+ outgoings:
38
+ created: 'The movement was successfully created.'
39
+ updated: 'The movement was successfully updated.'
40
+ destroyed: 'The movement was successfully deleted.'
37
41
  # views
38
42
  search:
39
43
  create:
@@ -51,7 +55,15 @@ en:
51
55
  balance:
52
56
  index:
53
57
  title: 'Last movements'
54
- new: 'Insert new movement'
58
+ new_incoming: 'New incoming'
59
+ new_outgoing: 'New outgoing'
60
+ date: "Date"
61
+ balance_chart:
62
+ title: "Balance"
63
+ movements_chart:
64
+ title: "Movements"
65
+ incomings: "Incomings"
66
+ outgoings: "Outgoings"
55
67
  movements:
56
68
  index:
57
69
  title: 'Listing movements'
@@ -0,0 +1,84 @@
1
+ #encoding: utf-8
2
+ it:
3
+ bookkeeper:
4
+ # actions
5
+ actions:
6
+ save: 'Salva'
7
+ back: 'Indietro'
8
+ new: 'Nuovo'
9
+ edit: 'Modifica'
10
+ destroy: 'Elimina'
11
+ destroy_confirm: 'Sei sicuro?'
12
+ # models
13
+ models:
14
+ purchase:
15
+ attributes:
16
+ title: 'Titolo'
17
+ description: 'Descrizione'
18
+ purchase_date: 'Data di acquisto'
19
+ warranty_duration: 'Durata della garanzia'
20
+ receipt: 'Ricevuta'
21
+ updated_at: 'Ultimo aggiornamento'
22
+ movement:
23
+ attributes:
24
+ amount: 'Importo'
25
+ description: 'Descrizione'
26
+ created_at: 'Data di creazione'
27
+ updated_at: 'Ultimo aggiornamento'
28
+ date: "Data"
29
+ # controllers
30
+ controllers:
31
+ purchases:
32
+ creato: "L'acquisto è stato correttamente creato."
33
+ modificato: "L'acquisto è stato correttamente modificato."
34
+ destroyed: "L'acquisto è stato correttamente eliminato."
35
+ incomings:
36
+ creato: 'Il movimento è stato correttamente creato.'
37
+ modificato: 'Il movimento è stato correttamente modificato.'
38
+ destroyed: 'Il movimento è stato correttamente eliminato.'
39
+ outgoings:
40
+ creato: 'Il movimento è stato correttamente creato.'
41
+ modificato: 'Il movimento è stato correttamente modificato.'
42
+ destroyed: 'Il movimento è stato correttamente eliminato.'
43
+ # views
44
+ search:
45
+ create:
46
+ title: 'Risultati della ricerca di "%{q}"'
47
+ purchases:
48
+ index:
49
+ title: 'Acquisti'
50
+ months: 'mesi'
51
+ new:
52
+ title: 'Nuovo acquisto'
53
+ edit:
54
+ title: "Modifica l'acquisto"
55
+ search:
56
+ search: 'Cerca'
57
+ balance:
58
+ index:
59
+ title: 'Ultimi movimenti'
60
+ new_incoming: 'Nuova entrata'
61
+ new_outgoing: 'Nuova uscita'
62
+ date: "Data"
63
+ account_balance: "Bilancio"
64
+ balance_chart:
65
+ title: "Bilancio"
66
+ movements_chart:
67
+ title: "Movimento"
68
+ incomings: "Entrate"
69
+ outgoings: "Uscite"
70
+ movements:
71
+ index:
72
+ title: 'Ultimi movimenti'
73
+ new:
74
+ title: 'Nuovo movimento'
75
+ edit:
76
+ title: 'Modifica il movimento'
77
+ search:
78
+ search: 'Cerca'
79
+ incomings:
80
+ new:
81
+ title: 'Inserisci una nuova entrata'
82
+ outgoings:
83
+ new:
84
+ title: 'Inserisci una nuova uscita'
@@ -0,0 +1,28 @@
1
+ it:
2
+ simple_form:
3
+ "yes": 'Si'
4
+ "no": 'No'
5
+ required:
6
+ html: '<a href="#" data-toggle="tooltip" title="Obbligatorio"><i class="icon-exclamation-sign"></i></a>'
7
+ error_notification:
8
+ default_message: "I seguenti problemi hanno impedito il salvataggio"
9
+ labels:
10
+ purchase:
11
+ title: 'Titolo'
12
+ description: 'Descrizione'
13
+ purchase_date: 'Data di acquisto'
14
+ warranty_duration: 'Durata della garanzia'
15
+ receipt: 'Ricevuta'
16
+ invoice: 'Fattura'
17
+ amount: 'Importo'
18
+ months: 'mesi'
19
+ year: 'anno'
20
+ years: 'anni'
21
+ incoming:
22
+ amount: 'Importo'
23
+ description: 'Descrizione'
24
+ date: 'Data'
25
+ outgoing:
26
+ amount: 'Importo'
27
+ description: 'Descrizione'
28
+ date: 'Data'
@@ -2,5 +2,6 @@ Bookkeeper::Engine.routes.draw do
2
2
  resources :purchases
3
3
  resources :search, only: [:create]
4
4
  resources :balance, only: [:index]
5
- resources :movements
5
+ resources :incomings, except: [:index, :show]
6
+ resources :outgoings, except: [:index, :show]
6
7
  end
@@ -0,0 +1,6 @@
1
+ class AddStiToMovements < ActiveRecord::Migration
2
+ def change
3
+ add_column :bookkeeper_movements, :type, :string
4
+ add_index :bookkeeper_movements, :type
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ class AddDefaultToAccounts < ActiveRecord::Migration
2
+ def change
3
+ add_column :bookkeeper_accounts, :default, :boolean, default: false
4
+ add_index :bookkeeper_accounts, :default
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ class AddDateToMovements < ActiveRecord::Migration
2
+ def change
3
+ add_column :bookkeeper_movements, :date, :date, nil: false
4
+ end
5
+ end
@@ -1,3 +1,3 @@
1
1
  module Bookkeeper
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bookkeeper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-09 00:00:00.000000000 Z
12
+ date: 2013-03-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -234,37 +234,48 @@ files:
234
234
  - app/assets/stylesheets/bookkeeper.css
235
235
  - app/controllers/bookkeeper/application_controller.rb
236
236
  - app/controllers/bookkeeper/balance_controller.rb
237
- - app/controllers/bookkeeper/movements_controller.rb
237
+ - app/controllers/bookkeeper/incomings_controller.rb
238
+ - app/controllers/bookkeeper/outgoings_controller.rb
238
239
  - app/controllers/bookkeeper/purchases_controller.rb
239
240
  - app/controllers/bookkeeper/search_controller.rb
240
241
  - app/helpers/bookkeeper/application_helper.rb
241
242
  - app/inputs/datepicker_input.rb
242
243
  - app/models/bookkeeper/account.rb
243
244
  - app/models/bookkeeper/categories.rb
245
+ - app/models/bookkeeper/incoming.rb
244
246
  - app/models/bookkeeper/movement.rb
247
+ - app/models/bookkeeper/outgoing.rb
245
248
  - app/models/bookkeeper/purchase.rb
246
249
  - app/uploaders/receipt_uploader.rb
250
+ - app/views/bookkeeper/balance/_balance_chart.html.erb
251
+ - app/views/bookkeeper/balance/_movements_chart.html.erb
247
252
  - app/views/bookkeeper/balance/index.html.erb
248
- - app/views/bookkeeper/movements/_form.html.erb
253
+ - app/views/bookkeeper/incomings/_form.html.erb
254
+ - app/views/bookkeeper/incomings/edit.html.erb
255
+ - app/views/bookkeeper/incomings/new.html.erb
249
256
  - app/views/bookkeeper/movements/_search.html.erb
250
- - app/views/bookkeeper/movements/edit.html.erb
251
257
  - app/views/bookkeeper/movements/index.html.erb
252
- - app/views/bookkeeper/movements/new.html.erb
258
+ - app/views/bookkeeper/outgoings/_form.html.erb
259
+ - app/views/bookkeeper/outgoings/edit.html.erb
260
+ - app/views/bookkeeper/outgoings/new.html.erb
253
261
  - app/views/bookkeeper/purchases/_form.html.erb
254
262
  - app/views/bookkeeper/purchases/_search.html.erb
255
263
  - app/views/bookkeeper/purchases/edit.html.erb
256
264
  - app/views/bookkeeper/purchases/index.html.erb
257
265
  - app/views/bookkeeper/purchases/new.html.erb
258
266
  - app/views/bookkeeper/search/create.html.erb
267
+ - app/views/bookkeeper/shared/_movement_form.html.erb
259
268
  - app/views/layouts/bookkeeper/application.html.erb
260
269
  - config/initializers/carrierwave.rb
261
270
  - config/initializers/simple_form.rb
262
271
  - config/initializers/simple_form_bootstrap.rb
263
272
  - config/initializers/validates_timeliness.rb
264
273
  - config/locales/en.yml
274
+ - config/locales/it.yml
265
275
  - config/locales/rails-i18n.en.yml
266
276
  - config/locales/rails-i18n.it.yml
267
277
  - config/locales/simple_form.en.yml
278
+ - config/locales/simple_form.it.yml
268
279
  - config/locales/validates_timeliness.en.yml
269
280
  - config/routes.rb
270
281
  - db/migrate/20130215165240_create_bookkeeper_purchases.rb
@@ -272,6 +283,9 @@ files:
272
283
  - db/migrate/20130228234703_create_bookkeeper_movements.rb
273
284
  - db/migrate/20130308231159_add_details_to_purchases.rb
274
285
  - db/migrate/20130308231918_create_bookkeeper_categories.rb
286
+ - db/migrate/20130317163103_add_sti_to_movements.rb
287
+ - db/migrate/20130317165439_add_default_to_accounts.rb
288
+ - db/migrate/20130317181020_add_date_to_movements.rb
275
289
  - lib/bookkeeper/engine.rb
276
290
  - lib/bookkeeper/version.rb
277
291
  - lib/bookkeeper.rb
@@ -1,67 +0,0 @@
1
- require_dependency "bookkeeper/application_controller"
2
-
3
- module Bookkeeper
4
- class MovementsController < ApplicationController
5
- def index
6
- @movements = Movement.all
7
-
8
- respond_to do |format|
9
- format.html
10
- format.json { render json: @movements }
11
- end
12
- end
13
-
14
- def new
15
- @movement = Movement.new
16
-
17
- respond_to do |format|
18
- format.html
19
- format.json { render json: @movement }
20
- end
21
- end
22
-
23
- def edit
24
- @movement = Movement.find(params[:id])
25
- end
26
-
27
- def create
28
- @movement = Movement.new(params[:movement])
29
-
30
- respond_to do |format|
31
- if @movement.save
32
- format.html { redirect_to balance_index_path, notice: I18n.t('.bookkeeper.controllers.movements.created') }
33
- format.json { render json: @movement, status: :created, location: @movement }
34
- else
35
- format.html { render action: "new" }
36
- format.json { render json: @movement.errors, status: :unprocessable_entity }
37
- end
38
- end
39
- end
40
-
41
- def update
42
- @movement = Movement.find(params[:id])
43
-
44
- respond_to do |format|
45
- if @movement.update_attributes(params[:movement])
46
- format.html { redirect_to balance_index_path, notice: I18n.t('.bookkeeper.controllers.movements.updated') }
47
- format.json { head :no_content }
48
- else
49
- format.html { render action: "edit" }
50
- format.json { render json: @movement.errors, status: :unprocessable_entity }
51
- end
52
- end
53
- end
54
-
55
- def destroy
56
- @movement = Movement.find(params[:id])
57
- @movement.destroy
58
- flash[:notice] = I18n.t('.bookkeeper.controllers.movements.destroyed')
59
-
60
- respond_to do |format|
61
- format.html { redirect_to balance_index_path }
62
- format.json { head :no_content }
63
- end
64
- end
65
- end
66
- end
67
-
@@ -1,15 +0,0 @@
1
- <%= simple_form_for @movement, html: { class: 'form-horizontal' } do |f| %>
2
-
3
- <%= f.error_notification %>
4
-
5
- <div class="form-inputs">
6
- <%= f.input :amount, :wrapper => :append do %>
7
- <%= f.input_field :amount, class: "input-mini" %>
8
- <%= content_tag :span, '&euro;'.html_safe, class: "add-on" %>
9
- <% end %>
10
- <%= f.input :description, input_html: { class: 'input-xxlarge' } %>
11
- </div>
12
- <div class="form-actions">
13
- <%= button_tag ('<i class="icon-ok"></i> ' + t('bookkeeper.actions.save')).html_safe, class: 'btn' %>
14
- </div>
15
- <% end %>