keepr 0.3.0 → 0.6.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.
Files changed (48) hide show
  1. checksums.yaml +5 -5
  2. data/.travis.yml +14 -10
  3. data/Gemfile +2 -0
  4. data/LICENSE.txt +1 -1
  5. data/README.md +3 -3
  6. data/Rakefile +3 -1
  7. data/ci/Gemfile-rails-4-2 +4 -4
  8. data/ci/Gemfile-rails-5-0 +4 -4
  9. data/ci/Gemfile-rails-5-1 +12 -0
  10. data/ci/Gemfile-rails-5-2 +12 -0
  11. data/ci/{Gemfile-rails-4-1 → Gemfile-rails-6-0} +4 -4
  12. data/keepr.gemspec +15 -14
  13. data/lib/generators/keepr/migration/migration_generator.rb +5 -3
  14. data/lib/generators/keepr/migration/templates/migration.rb +27 -25
  15. data/lib/keepr.rb +8 -0
  16. data/lib/keepr/account.rb +66 -61
  17. data/lib/keepr/account_export.rb +10 -14
  18. data/lib/keepr/active_record_extension.rb +10 -8
  19. data/lib/keepr/contact_export.rb +6 -7
  20. data/lib/keepr/cost_center.rb +3 -1
  21. data/lib/keepr/group.rb +25 -16
  22. data/lib/keepr/groups_creator.rb +11 -11
  23. data/lib/keepr/journal.rb +19 -16
  24. data/lib/keepr/journal_export.rb +10 -7
  25. data/lib/keepr/posting.rb +26 -21
  26. data/lib/keepr/tax.rb +4 -2
  27. data/lib/keepr/version.rb +3 -1
  28. data/spec/factories/account.rb +6 -4
  29. data/spec/factories/cost_center.rb +5 -3
  30. data/spec/factories/group.rb +5 -3
  31. data/spec/factories/tax.rb +7 -5
  32. data/spec/keepr/account_export_spec.rb +30 -27
  33. data/spec/keepr/account_spec.rb +92 -87
  34. data/spec/keepr/active_record_extension_spec.rb +38 -36
  35. data/spec/keepr/contact_export_spec.rb +20 -17
  36. data/spec/keepr/cost_center_spec.rb +9 -7
  37. data/spec/keepr/group_spec.rb +53 -49
  38. data/spec/keepr/groups_creator_spec.rb +7 -4
  39. data/spec/keepr/journal_export_spec.rb +76 -75
  40. data/spec/keepr/journal_spec.rb +48 -46
  41. data/spec/keepr/posting_spec.rb +25 -23
  42. data/spec/keepr/tax_spec.rb +21 -14
  43. data/spec/spec_helper.rb +13 -11
  44. data/spec/support/contact.rb +2 -0
  45. data/spec/support/document.rb +2 -0
  46. data/spec/support/ledger.rb +2 -0
  47. data/spec/support/spec_migration.rb +3 -1
  48. metadata +23 -22
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Keepr
2
- VERSION = '0.3.0'
4
+ VERSION = '0.6.0'
3
5
  end
@@ -1,7 +1,9 @@
1
- FactoryGirl.define do
1
+ # frozen_string_literal: true
2
+
3
+ FactoryBot.define do
2
4
  factory :account, class: Keepr::Account do
3
- number 12345
4
- kind :asset
5
- name 'Foo'
5
+ number { 12_345 }
6
+ kind { :asset }
7
+ name { 'Foo' }
6
8
  end
7
9
  end
@@ -1,6 +1,8 @@
1
- FactoryGirl.define do
1
+ # frozen_string_literal: true
2
+
3
+ FactoryBot.define do
2
4
  factory :cost_center, class: Keepr::CostCenter do
3
- number 'FZ1'
4
- name 'Kleintransporter'
5
+ number { 'FZ1' }
6
+ name { 'Kleintransporter' }
5
7
  end
6
8
  end
@@ -1,6 +1,8 @@
1
- FactoryGirl.define do
1
+ # frozen_string_literal: true
2
+
3
+ FactoryBot.define do
2
4
  factory :group, class: Keepr::Group do
3
- target :asset
4
- name 'Foo'
5
+ target { :asset }
6
+ name { 'Foo' }
5
7
  end
6
8
  end
@@ -1,8 +1,10 @@
1
- FactoryGirl.define do
1
+ # frozen_string_literal: true
2
+
3
+ FactoryBot.define do
2
4
  factory :tax, class: Keepr::Tax do
3
- name 'USt19'
4
- description 'Umsatzsteuer 19%'
5
- value 19.0
6
- keepr_account { FactoryGirl.create :account, :number => 1776 }
5
+ name { 'USt19' }
6
+ description { 'Umsatzsteuer 19%' }
7
+ value { 19.0 }
8
+ keepr_account { FactoryBot.create :account, number: 1776 }
7
9
  end
8
10
  end
@@ -1,26 +1,29 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Keepr::AccountExport do
4
- let!(:account_1000) { FactoryGirl.create :account, :kind => :asset, :number => 1000, :name => 'Kasse' }
5
- let!(:account_1776) { FactoryGirl.create :account, :kind => :liability, :number => 1776, :name => 'Umsatzsteuer 19 %' }
6
- let!(:account_4920) { FactoryGirl.create :account, :kind => :expense, :number => 4920, :name => 'Telefon' }
7
- let!(:account_8400) { FactoryGirl.create :account, :kind => :revenue, :number => 8400, :name => 'Erlöse 19 %' }
8
- let!(:account_9000) { FactoryGirl.create :account, :kind => :neutral, :number => 9000, :name => 'Saldenvorträge Sachkonten' }
9
- let!(:account_10000) { FactoryGirl.create :account, :kind => :creditor, :number => 10000, :name => 'Diverse Kreditoren' }
10
- let!(:account_70000) { FactoryGirl.create :account, :kind => :debtor, :number => 70000, :name => 'Diverse Debitoren' }
6
+ let!(:account_1000) { FactoryBot.create :account, kind: :asset, number: 1000, name: 'Kasse' }
7
+ let!(:account_1776) { FactoryBot.create :account, kind: :liability, number: 1776, name: 'Umsatzsteuer 19 %' }
8
+ let!(:account_4920) { FactoryBot.create :account, kind: :expense, number: 4920, name: 'Telefon' }
9
+ let!(:account_8400) { FactoryBot.create :account, kind: :revenue, number: 8400, name: 'Erlöse 19 %' }
10
+ let!(:account_9000) { FactoryBot.create :account, kind: :forward, number: 9000, name: 'Saldenvorträge Sachkonten' }
11
+ let!(:account_10000) { FactoryBot.create :account, kind: :creditor, number: 10_000, name: 'Diverse Kreditoren' }
12
+ let!(:account_70000) { FactoryBot.create :account, kind: :debtor, number: 70_000, name: 'Diverse Debitoren' }
11
13
 
12
14
  let(:scope) { Keepr::Account.all }
13
15
 
14
- let(:export) {
15
- Keepr::AccountExport.new(scope,
16
- 'Berater' => 1234567,
17
- 'Mandant' => 78901,
18
- 'WJ-Beginn' => Date.new(2016,1,1),
16
+ let(:export) do
17
+ Keepr::AccountExport.new(
18
+ scope,
19
+ 'Berater' => 1_234_567,
20
+ 'Mandant' => 78_901,
21
+ 'WJ-Beginn' => Date.new(2016, 1, 1),
19
22
  'Bezeichnung' => 'Keepr-Konten'
20
- ) do |account|
23
+ ) do
21
24
  { 'Sprach-ID' => 'de-DE' }
22
25
  end
23
- }
26
+ end
24
27
 
25
28
  describe :to_s do
26
29
  subject { export.to_s }
@@ -29,43 +32,43 @@ describe Keepr::AccountExport do
29
32
  subject.lines[2..-1].map { |line| line.encode(Encoding::UTF_8) }
30
33
  end
31
34
 
32
- it "should return CSV lines" do
35
+ it 'should return CSV lines' do
33
36
  subject.lines.each { |line| expect(line).to include(';') }
34
37
  end
35
38
 
36
- it "should include header data" do
39
+ it 'should include header data' do
37
40
  expect(subject.lines[0]).to include('1234567;')
38
41
  expect(subject.lines[0]).to include('78901;')
39
- expect(subject.lines[0]).to include('Keepr-Konten;')
42
+ expect(subject.lines[0]).to include('"Keepr-Konten";')
40
43
  end
41
44
 
42
- it "should include all accounts except debtor/creditor" do
45
+ it 'should include all accounts except debtor/creditor' do
43
46
  expect(account_lines.count).to eq(5)
44
47
 
45
48
  expect(account_lines[0]).to include('1000;')
46
- expect(account_lines[0]).to include('Kasse;')
49
+ expect(account_lines[0]).to include('"Kasse";')
47
50
 
48
51
  expect(account_lines[1]).to include('1776;')
49
- expect(account_lines[1]).to include('Umsatzsteuer 19 %;')
52
+ expect(account_lines[1]).to include('"Umsatzsteuer 19 %";')
50
53
 
51
54
  expect(account_lines[2]).to include('4920;')
52
- expect(account_lines[2]).to include('Telefon;')
55
+ expect(account_lines[2]).to include('"Telefon";')
53
56
 
54
57
  expect(account_lines[3]).to include('8400;')
55
- expect(account_lines[3]).to include('Erlöse 19 %;')
58
+ expect(account_lines[3]).to include('"Erlöse 19 %";')
56
59
 
57
60
  expect(account_lines[4]).to include('9000;')
58
- expect(account_lines[4]).to include('Saldenvorträge Sachkonten;')
61
+ expect(account_lines[4]).to include('"Saldenvorträge Sachkonten";')
59
62
  end
60
63
 
61
- it "should include data from block" do
62
- expect(account_lines[0]).to include(';de-DE')
63
- expect(account_lines[1]).to include(';de-DE')
64
+ it 'should include data from block' do
65
+ expect(account_lines[0]).to include(';"de-DE"')
66
+ expect(account_lines[1]).to include(';"de-DE"')
64
67
  end
65
68
  end
66
69
 
67
70
  describe :to_file do
68
- it "should create CSV file" do
71
+ it 'should create CSV file' do
69
72
  Dir.mktmpdir do |dir|
70
73
  filename = "#{dir}/EXTF_Kontenbeschriftungen.csv"
71
74
  export.to_file(filename)
@@ -1,89 +1,90 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
+
2
3
  require 'spec_helper'
3
4
 
4
5
  describe Keepr::Account do
5
6
  describe :number_as_string do
6
- it "should return number with leading zeros for low values" do
7
- account = Keepr::Account.new(:number => 999)
7
+ it 'should return number with leading zeros for low values' do
8
+ account = Keepr::Account.new(number: 999)
8
9
  expect(account.number_as_string).to eq('0999')
9
10
  end
10
11
 
11
- it "should return number unchanged for high values" do
12
- account = Keepr::Account.new(:number => 70000)
12
+ it 'should return number unchanged for high values' do
13
+ account = Keepr::Account.new(number: 70_000)
13
14
  expect(account.number_as_string).to eq('70000')
14
15
  end
15
16
  end
16
17
 
17
18
  describe :to_s do
18
- it "should format" do
19
- account = Keepr::Account.new(:number => 27, :name => 'Software')
19
+ it 'should format' do
20
+ account = Keepr::Account.new(number: 27, name: 'Software')
20
21
  expect(account.to_s).to eq('0027 (Software)')
21
22
  end
22
23
  end
23
24
  end
24
25
 
25
26
  describe Keepr::Account do
26
- let!(:account_1000) { FactoryGirl.create(:account, :number => 1000) }
27
- let!(:account_1200) { FactoryGirl.create(:account, :number => 1200) }
27
+ let!(:account_1000) { FactoryBot.create(:account, number: 1000) }
28
+ let!(:account_1200) { FactoryBot.create(:account, number: 1200) }
28
29
 
29
30
  before :each do
30
- Keepr::Journal.create! :date => Date.yesterday,
31
- :permanent => true,
32
- :keepr_postings_attributes => [
33
- { :keepr_account => account_1000, :amount => 20, :side => 'debit' },
34
- { :keepr_account => account_1200, :amount => 20, :side => 'credit' }
35
- ]
36
-
37
- Keepr::Journal.create! :date => Date.yesterday,
38
- :keepr_postings_attributes => [
39
- { :keepr_account => account_1000, :amount => 10, :side => 'credit' },
40
- { :keepr_account => account_1200, :amount => 10, :side => 'debit' },
41
- ]
42
-
43
- Keepr::Journal.create! :date => Date.today,
44
- :keepr_postings_attributes => [
45
- { :keepr_account => account_1000, :amount => 200, :side => 'debit' },
46
- { :keepr_account => account_1200, :amount => 200, :side => 'credit' }
47
- ]
48
-
49
- Keepr::Journal.create! :date => Date.today,
50
- :keepr_postings_attributes => [
51
- { :keepr_account => account_1000, :amount => 100, :side => 'credit' },
52
- { :keepr_account => account_1200, :amount => 100, :side => 'debit' },
53
- ]
31
+ Keepr::Journal.create! date: Date.yesterday,
32
+ permanent: true,
33
+ keepr_postings_attributes: [
34
+ { keepr_account: account_1000, amount: 20, side: 'debit' },
35
+ { keepr_account: account_1200, amount: 20, side: 'credit' }
36
+ ]
37
+
38
+ Keepr::Journal.create! date: Date.yesterday,
39
+ keepr_postings_attributes: [
40
+ { keepr_account: account_1000, amount: 10, side: 'credit' },
41
+ { keepr_account: account_1200, amount: 10, side: 'debit' }
42
+ ]
43
+
44
+ Keepr::Journal.create! date: Date.current,
45
+ keepr_postings_attributes: [
46
+ { keepr_account: account_1000, amount: 200, side: 'debit' },
47
+ { keepr_account: account_1200, amount: 200, side: 'credit' }
48
+ ]
49
+
50
+ Keepr::Journal.create! date: Date.current,
51
+ keepr_postings_attributes: [
52
+ { keepr_account: account_1000, amount: 100, side: 'credit' },
53
+ { keepr_account: account_1200, amount: 100, side: 'debit' }
54
+ ]
54
55
  end
55
56
 
56
57
  describe 'validations' do
57
- let!(:result_group) { FactoryGirl.create(:group, :target => :liability, :is_result => true) }
58
- let!(:liability_group) { FactoryGirl.create(:group, :target => :liability) }
59
- let!(:asset_group) { FactoryGirl.create(:group, :target => :asset) }
58
+ let!(:result_group) { FactoryBot.create(:group, target: :liability, is_result: true) }
59
+ let!(:liability_group) { FactoryBot.create(:group, target: :liability) }
60
+ let!(:asset_group) { FactoryBot.create(:group, target: :asset) }
60
61
 
61
- it "should not allow assigning to result group" do
62
- account = FactoryGirl.build(:account, :keepr_group => result_group)
62
+ it 'should not allow assigning to result group' do
63
+ account = FactoryBot.build(:account, keepr_group: result_group)
63
64
  expect(account).to_not be_valid
64
- expect(account.errors.added? :keepr_group_id, :no_group_allowed_for_result).to eq(true)
65
+ expect(account.errors.added?(:keepr_group_id, :no_group_allowed_for_result)).to eq(true)
65
66
  end
66
67
 
67
- it "should not allow assigning asset account to liability group" do
68
- account = FactoryGirl.build(:account, :kind => :asset, :keepr_group => liability_group)
68
+ it 'should not allow assigning asset account to liability group' do
69
+ account = FactoryBot.build(:account, kind: :asset, keepr_group: liability_group)
69
70
  expect(account).to_not be_valid
70
- expect(account.errors.added? :kind, :group_mismatch).to eq(true)
71
+ expect(account.errors.added?(:kind, :group_mismatch)).to eq(true)
71
72
  end
72
73
 
73
- it "should not allow assigning liability account to asset group" do
74
- account = FactoryGirl.build(:account, :kind => :liability, :keepr_group => asset_group)
74
+ it 'should not allow assigning liability account to asset group' do
75
+ account = FactoryBot.build(:account, kind: :liability, keepr_group: asset_group)
75
76
  expect(account).to_not be_valid
76
- expect(account.errors.added? :kind, :group_mismatch).to eq(true)
77
+ expect(account.errors.added?(:kind, :group_mismatch)).to eq(true)
77
78
  end
78
79
 
79
- it "should not allow assigning neutral account to asset group" do
80
- account = FactoryGirl.build(:account, :kind => :neutral, :keepr_group => asset_group)
80
+ it 'should not allow assigning forward account to asset group' do
81
+ account = FactoryBot.build(:account, kind: :forward, keepr_group: asset_group)
81
82
  expect(account).to_not be_valid
82
- expect(account.errors.added? :kind, :group_conflict).to eq(true)
83
+ expect(account.errors.added?(:kind, :group_conflict)).to eq(true)
83
84
  end
84
85
 
85
- it "should allow target match" do
86
- account = FactoryGirl.build(:account, :kind => :asset, :keepr_group => asset_group)
86
+ it 'should allow target match' do
87
+ account = FactoryBot.build(:account, kind: :asset, keepr_group: asset_group)
87
88
  expect(account).to be_valid
88
89
  end
89
90
  end
@@ -131,7 +132,7 @@ describe Keepr::Account do
131
132
 
132
133
  context 'with date option' do
133
134
  it 'should work with Date' do
134
- account1, account2 = Keepr::Account.with_sums(:date => Date.yesterday)
135
+ account1, account2 = Keepr::Account.with_sums(date: Date.yesterday)
135
136
 
136
137
  expect(account1.number).to eq(1000)
137
138
  expect(account1.sum_amount).to eq(10)
@@ -140,7 +141,7 @@ describe Keepr::Account do
140
141
  end
141
142
 
142
143
  it 'should work with Range' do
143
- account1, account2 = Keepr::Account.with_sums(:date => Date.today..Date.tomorrow)
144
+ account1, account2 = Keepr::Account.with_sums(date: Date.today..Date.tomorrow)
144
145
 
145
146
  expect(account1.number).to eq(1000)
146
147
  expect(account1.sum_amount).to eq(100)
@@ -149,14 +150,14 @@ describe Keepr::Account do
149
150
  end
150
151
 
151
152
  it 'should raise for other class' do
152
- expect { Keepr::Account.with_sums(:date => Time.current) }.to raise_error(ArgumentError)
153
- expect { Keepr::Account.with_sums(:date => :foo) }.to raise_error(ArgumentError)
153
+ expect { Keepr::Account.with_sums(date: Time.current) }.to raise_error(ArgumentError)
154
+ expect { Keepr::Account.with_sums(date: :foo) }.to raise_error(ArgumentError)
154
155
  end
155
156
  end
156
157
 
157
158
  context 'with permanent_only option' do
158
159
  it 'should filter the permanent journals' do
159
- account1, account2 = Keepr::Account.with_sums(:permanent_only => true)
160
+ account1, account2 = Keepr::Account.with_sums(permanent_only: true)
160
161
 
161
162
  expect(account1.number).to eq(1000)
162
163
  expect(account1.sum_amount).to eq(20)
@@ -175,17 +176,17 @@ describe Keepr::Account do
175
176
  end
176
177
 
177
178
  describe Keepr::Account, 'with subaccounts' do
178
- let!(:account_1400) { FactoryGirl.create(:account, :number => 1400) }
179
- let!(:account_10000) { FactoryGirl.create(:account, :number => 10000, :parent => account_1400) }
180
- let!(:account_10001) { FactoryGirl.create(:account, :number => 10001, :parent => account_1400) }
181
- let!(:account_8400) { FactoryGirl.create(:account, :number => 8400) }
179
+ let!(:account_1400) { FactoryBot.create(:account, number: 1400) }
180
+ let!(:account_10000) { FactoryBot.create(:account, number: 10_000, parent: account_1400) }
181
+ let!(:account_10001) { FactoryBot.create(:account, number: 10_001, parent: account_1400) }
182
+ let!(:account_8400) { FactoryBot.create(:account, number: 8400) }
182
183
 
183
184
  before :each do
184
- Keepr::Journal.create! :date => Date.yesterday,
185
- :keepr_postings_attributes => [
186
- { :keepr_account => account_10000, :amount => 20, :side => 'debit' },
187
- { :keepr_account => account_8400, :amount => 20, :side => 'credit' }
188
- ]
185
+ Keepr::Journal.create! date: Date.yesterday,
186
+ keepr_postings_attributes: [
187
+ { keepr_account: account_10000, amount: 20, side: 'debit' },
188
+ { keepr_account: account_8400, amount: 20, side: 'credit' }
189
+ ]
189
190
  end
190
191
 
191
192
  describe :keepr_postings do
@@ -209,42 +210,46 @@ describe Keepr::Account, 'with subaccounts' do
209
210
 
210
211
  describe :with_sums do
211
212
  it 'should calc balance' do
212
- expect(Keepr::Account.with_sums.
213
- select(&:sum_amount).
214
- map { |a| [a.number, a.sum_amount] }).
215
- to eq([[8400, -20], [10000, 20]])
213
+ expect(Keepr::Account.with_sums
214
+ .select(&:sum_amount)
215
+ .map { |a| [a.number, a.sum_amount] })
216
+ .to eq([[8400, -20], [10_000, 20]])
216
217
  end
217
218
  end
218
219
 
219
220
  describe :merged_with_sums do
220
221
  it 'should calc merged balance' do
221
- expect(Keepr::Account.merged_with_sums.
222
- select(&:sum_amount).
223
- map { |a| [a.number, a.sum_amount] }).
224
- to eq([[1400, 20], [8400, -20]])
222
+ expect(Keepr::Account.merged_with_sums
223
+ .select(&:sum_amount)
224
+ .map { |a| [a.number, a.sum_amount] })
225
+ .to eq([[1400, 20], [8400, -20]])
225
226
  end
226
227
  end
227
228
  end
228
229
 
229
230
  describe Keepr::Account, 'with tax' do
230
- let!(:tax_account) { Keepr::Account.create! :number => 1776,
231
- :name => 'Umsatzsteuer 19%',
232
- :kind => :asset }
233
-
234
- let!(:tax) { Keepr::Tax.create! :name => 'USt19',
235
- :description => 'Umsatzsteuer 19%',
236
- :value => 19.0,
237
- :keepr_account => tax_account }
238
-
239
- it "should link to tax" do
240
- account = Keepr::Account.new :number => 8400,
241
- :name => 'Erlöse 19% USt',
242
- :kind => :revenue,
243
- :keepr_tax => tax
231
+ let!(:tax_account) do
232
+ Keepr::Account.create! number: 1776,
233
+ name: 'Umsatzsteuer 19%',
234
+ kind: :asset
235
+ end
236
+
237
+ let!(:tax) do
238
+ Keepr::Tax.create! name: 'USt19',
239
+ description: 'Umsatzsteuer 19%',
240
+ value: 19.0,
241
+ keepr_account: tax_account
242
+ end
243
+
244
+ it 'should link to tax' do
245
+ account = Keepr::Account.new number: 8400,
246
+ name: 'Erlöse 19% USt',
247
+ kind: :revenue,
248
+ keepr_tax: tax
244
249
  expect(account).to be_valid
245
250
  end
246
251
 
247
- it "should avoid circular reference" do
252
+ it 'should avoid circular reference' do
248
253
  tax_account.keepr_tax_id = tax.id
249
254
  expect(tax_account).to be_invalid
250
255
  end
@@ -1,26 +1,28 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Keepr::ActiveRecordExtension do
4
- let(:account_1000) { FactoryGirl.create(:account, :number => 1000, :kind => :asset) }
5
- let(:account_1200) { FactoryGirl.create(:account, :number => 1200, :kind => :asset) }
6
+ let(:account_1000) { FactoryBot.create(:account, number: 1000, kind: :asset) }
7
+ let(:account_1200) { FactoryBot.create(:account, number: 1200, kind: :asset) }
6
8
 
7
9
  describe 'ledger with associated account' do
8
- let(:ledger) { Ledger.create! :bank_name => 'Sparkasse' }
9
- let!(:account) { ledger.create_keepr_account! :number => '1250', :kind => :asset, :name => 'Girokonto' }
10
+ let(:ledger) { Ledger.create! bank_name: 'Sparkasse' }
11
+ let!(:account) { ledger.create_keepr_account! number: '1250', kind: :asset, name: 'Girokonto' }
10
12
 
11
13
  it 'has keepr_account' do
12
14
  expect(ledger.keepr_account).to eq(account)
13
15
  end
14
16
 
15
17
  it 'has keepr_postings' do
16
- journal = Keepr::Journal.create! :keepr_postings_attributes => [
17
- { :keepr_account => account, :amount => 30, :side => 'debit' },
18
- { :keepr_account => account_1200, :amount => 30, :side => 'credit' }
19
- ]
20
- other_journal = Keepr::Journal.create! :keepr_postings_attributes => [
21
- { :keepr_account => account_1000, :amount => 20, :side => 'debit' },
22
- { :keepr_account => account_1200, :amount => 20, :side => 'credit' }
23
- ]
18
+ Keepr::Journal.create! keepr_postings_attributes: [
19
+ { keepr_account: account, amount: 30, side: 'debit' },
20
+ { keepr_account: account_1200, amount: 30, side: 'credit' }
21
+ ]
22
+ Keepr::Journal.create! keepr_postings_attributes: [
23
+ { keepr_account: account_1000, amount: 20, side: 'debit' },
24
+ { keepr_account: account_1200, amount: 20, side: 'credit' }
25
+ ]
24
26
 
25
27
  expect(ledger.keepr_postings.count).to eq(1)
26
28
  expect(ledger.keepr_postings.first.amount).to eq(30)
@@ -28,23 +30,23 @@ describe Keepr::ActiveRecordExtension do
28
30
  end
29
31
 
30
32
  describe 'contact with multiple associated accounts' do
31
- let(:contact) { Contact.create! :name => 'John Doe' }
32
- let(:account1) { contact.keepr_accounts.create! :number => '70001', :kind => :debtor, :name => "Doe's main account" }
33
- let(:account2) { contact.keepr_accounts.create! :number => '70002', :kind => :debtor, :name => "Doe's second account" }
33
+ let(:contact) { Contact.create! name: 'John Doe' }
34
+ let(:account1) { contact.keepr_accounts.create! number: '70001', kind: :debtor, name: "Doe's main account" }
35
+ let(:account2) { contact.keepr_accounts.create! number: '70002', kind: :debtor, name: "Doe's second account" }
34
36
 
35
37
  it 'has multiple keepr_accounts' do
36
38
  expect(contact.keepr_accounts).to eq([account1, account2])
37
39
  end
38
40
 
39
41
  it 'has keepr_postings' do
40
- journal = Keepr::Journal.create! :keepr_postings_attributes => [
41
- { :keepr_account => account1, :amount => 30, :side => 'debit' },
42
- { :keepr_account => account_1200, :amount => 30, :side => 'credit' }
43
- ]
44
- other_journal = Keepr::Journal.create! :keepr_postings_attributes => [
45
- { :keepr_account => account_1000, :amount => 20, :side => 'debit' },
46
- { :keepr_account => account_1200, :amount => 20, :side => 'credit' }
47
- ]
42
+ Keepr::Journal.create! keepr_postings_attributes: [
43
+ { keepr_account: account1, amount: 30, side: 'debit' },
44
+ { keepr_account: account_1200, amount: 30, side: 'credit' }
45
+ ]
46
+ Keepr::Journal.create! keepr_postings_attributes: [
47
+ { keepr_account: account_1000, amount: 20, side: 'debit' },
48
+ { keepr_account: account_1200, amount: 20, side: 'credit' }
49
+ ]
48
50
 
49
51
  expect(contact.keepr_postings.count).to eq(1)
50
52
  expect(contact.keepr_postings.first.amount).to eq(30)
@@ -53,11 +55,11 @@ describe Keepr::ActiveRecordExtension do
53
55
 
54
56
  describe 'Document with associated journal' do
55
57
  subject do
56
- document = Document.create! :number => 'RE-2013-10-12345'
57
- Keepr::Journal.create! :accountable => document,
58
- :keepr_postings_attributes => [
59
- { :keepr_account => account_1000, :amount => 100.99, :side => 'debit' },
60
- { :keepr_account => account_1200, :amount => 100.99, :side => 'credit' }
58
+ document = Document.create! number: 'RE-2013-10-12345'
59
+ Keepr::Journal.create! accountable: document,
60
+ keepr_postings_attributes: [
61
+ { keepr_account: account_1000, amount: 100.99, side: 'debit' },
62
+ { keepr_account: account_1200, amount: 100.99, side: 'credit' }
61
63
  ]
62
64
  document
63
65
  end
@@ -69,16 +71,16 @@ describe Keepr::ActiveRecordExtension do
69
71
  end
70
72
 
71
73
  describe 'scopes' do
72
- let!(:unbooked_document) { Document.create! :number => 'Unbooked' }
73
- let!(:booked_document) {
74
- document = Document.create! :number => 'Booked'
75
- Keepr::Journal.create! :accountable => document,
76
- :keepr_postings_attributes => [
77
- { :keepr_account => account_1000, :amount => 100.99, :side => 'debit' },
78
- { :keepr_account => account_1200, :amount => 100.99, :side => 'credit' }
74
+ let!(:unbooked_document) { Document.create! number: 'Unbooked' }
75
+ let!(:booked_document) do
76
+ document = Document.create! number: 'Booked'
77
+ Keepr::Journal.create! accountable: document,
78
+ keepr_postings_attributes: [
79
+ { keepr_account: account_1000, amount: 100.99, side: 'debit' },
80
+ { keepr_account: account_1200, amount: 100.99, side: 'credit' }
79
81
  ]
80
82
  document
81
- }
83
+ end
82
84
 
83
85
  describe :keepr_booked do
84
86
  subject { Document.keepr_booked }