has_accounts 0.19.1 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,3 @@
1
1
  class BankAccountsController < AccountsController
2
+ defaults :resource_class => BankAccount
2
3
  end
@@ -0,0 +1,3 @@
1
+ class BanksController < PeopleController
2
+ defaults :resource_class => Bank
3
+ end
@@ -1,16 +1,16 @@
1
1
  class Account < ActiveRecord::Base
2
2
  # Access restrictions
3
- attr_accessible :title, :code, :account_type_id
3
+ attr_accessible :title, :code
4
4
 
5
5
  # Scopes
6
6
  default_scope :order => 'code'
7
-
7
+
8
8
  # Dummy scope to make scoped_by happy
9
9
  scope :by_value_period, scoped
10
-
10
+
11
11
  # Validation
12
12
  validates_presence_of :code, :title
13
-
13
+
14
14
  # String
15
15
  def to_s(format = :default)
16
16
  "%s (%s)" % [title, code]
@@ -19,12 +19,13 @@ class Account < ActiveRecord::Base
19
19
  # Account Type
20
20
  # ============
21
21
  belongs_to :account_type
22
+ attr_accessible :title, :code, :account_type_id, :account_type
22
23
  validates_presence_of :account_type
23
24
 
24
25
  def is_asset_account?
25
26
  Account.by_type(['current_assets', 'capital_assets', 'costs']).exists?(self)
26
27
  end
27
-
28
+
28
29
  def is_liability_account?
29
30
  !is_asset_account?
30
31
  end
@@ -44,12 +45,12 @@ class Account < ActiveRecord::Base
44
45
  # Holder
45
46
  # ======
46
47
  belongs_to :holder, :polymorphic => true
47
-
48
+
48
49
  # Bookings
49
50
  # ========
50
51
  has_many :credit_bookings, :class_name => "Booking", :foreign_key => "credit_account_id"
51
52
  has_many :debit_bookings, :class_name => "Booking", :foreign_key => "debit_account_id"
52
-
53
+
53
54
  def bookings
54
55
  Booking.by_account(id)
55
56
  end
@@ -64,7 +65,7 @@ class Account < ActiveRecord::Base
64
65
  def self.overview(value_range = Date.today, format = :default)
65
66
  Account.all.map{|a| a.to_s(value_range, format)}
66
67
  end
67
-
68
+
68
69
  # Calculations
69
70
  def turnover(selector = Date.today, inclusive = true)
70
71
  equality = "=" if inclusive
@@ -108,15 +109,15 @@ class Account < ActiveRecord::Base
108
109
 
109
110
  credit_amount = credit_bookings.where(condition).sum(:amount)
110
111
  debit_amount = debit_bookings.where(condition).sum(:amount)
111
-
112
+
112
113
  [credit_amount || 0.0, debit_amount || 0.0]
113
114
  end
114
-
115
+
115
116
  def saldo(selector = Date.today, inclusive = true)
116
117
  credit_amount, debit_amount = turnover(selector, inclusive)
117
118
 
118
119
  amount = credit_amount - debit_amount
119
-
120
+
120
121
  return is_asset_account? ? amount : -amount
121
122
  end
122
123
  end
data/app/models/bank.rb CHANGED
@@ -1,11 +1,12 @@
1
1
  class Bank < Person
2
- has_many :bank_accounts
2
+ # Access restrictions
3
+ attr_accessible :swift, :clearing
3
4
 
4
- has_vcards
5
+ has_many :bank_accounts
5
6
 
6
7
  def to_s
7
8
  return "" unless vcard
8
9
 
9
- [vcard.full_name, vcard.locality].compact.join(', ')
10
+ [vcard.full_name, vcard.locality].compact.join(', ')
10
11
  end
11
12
  end
@@ -0,0 +1,3 @@
1
+ %tr[bank]
2
+ %td= link_to bank.vcard.try(:full_name), bank, {'data-href-container' => 'tr'}
3
+ %td= [ bank.vcard.address_lines.join(", "), bank.vcard.contacts.map{|contact| contact.to_s(': ', :label)}.join(', ') ].compact.join("<br/>").html_safe
@@ -0,0 +1,12 @@
1
+ = simple_form_for resource do |f|
2
+ = render 'address_form', :f => f
3
+
4
+ %h3= t('form.bank.money_transfer')
5
+ .row-fluid
6
+ .span6
7
+ = f.input :swift
8
+ .span6
9
+ = f.input :clearing
10
+
11
+ .form-actions
12
+ = f.button :submit
@@ -44,10 +44,23 @@ de:
44
44
  valuta: Valuta
45
45
  value: Betrag
46
46
 
47
+ form:
48
+ bank:
49
+ money_transfer: Bankverbindung
50
+
47
51
  # Title customizations
48
52
  accounts:
49
53
  index:
50
54
  title: Kontenplan
55
+ edit_bookings:
56
+ title: Buchungen
57
+ info:
58
+ title: Kontodaten
59
+ journal:
60
+ title: Auszug
61
+ attachments:
62
+ list:
63
+ title: Dokumente
51
64
  bank_accounts:
52
65
  index:
53
66
  title: Bankkonti
@@ -66,3 +79,5 @@ de:
66
79
  crud:
67
80
  action:
68
81
  copy: Kopieren
82
+ only_credit_bookings: "Nur Soll"
83
+ only_debit_bookings: "Nur Haben"
data/config/routes.rb CHANGED
@@ -24,7 +24,16 @@ Rails.application.routes.draw do
24
24
  resources :attachments
25
25
  end
26
26
 
27
- resources :banks
27
+ resources :banks do
28
+ resources :phone_numbers
29
+ member do
30
+ get :new_phone_number
31
+ end
32
+ collection do
33
+ get :new_phone_number
34
+ end
35
+ end
36
+
28
37
  resources :bank_accounts do
29
38
  member do
30
39
  get :csv_bookings
@@ -1,3 +1,3 @@
1
1
  module HasAccounts
2
- VERSION = "0.19.1"
2
+ VERSION = "0.20.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: has_accounts
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.19.1
4
+ version: 0.20.0
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-02-04 00:00:00.000000000 Z
12
+ date: 2013-02-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -87,6 +87,7 @@ extra_rdoc_files:
87
87
  files:
88
88
  - app/controllers/accounts_controller.rb
89
89
  - app/controllers/bank_accounts_controller.rb
90
+ - app/controllers/banks_controller.rb
90
91
  - app/controllers/bookings_controller.rb
91
92
  - app/helpers/account_helper.rb
92
93
  - app/models/account.rb
@@ -116,6 +117,8 @@ files:
116
117
  - app/views/accounts/show.html.haml
117
118
  - app/views/bank_accounts/_bank_account.html.haml
118
119
  - app/views/bank_accounts/_form.html.haml
120
+ - app/views/banks/_bank.html.haml
121
+ - app/views/banks/_form.html.haml
119
122
  - app/views/bookings/_booking.html.haml
120
123
  - app/views/bookings/_form.html.haml
121
124
  - app/views/bookings/_list.html.haml