keepr 0.3.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +14 -10
- data/Gemfile +2 -0
- data/LICENSE.txt +1 -1
- data/README.md +3 -3
- data/Rakefile +3 -1
- data/ci/Gemfile-rails-4-2 +4 -4
- data/ci/Gemfile-rails-5-0 +4 -4
- data/ci/Gemfile-rails-5-1 +12 -0
- data/ci/Gemfile-rails-5-2 +12 -0
- data/ci/{Gemfile-rails-4-1 → Gemfile-rails-6-0} +4 -4
- data/keepr.gemspec +15 -14
- data/lib/generators/keepr/migration/migration_generator.rb +5 -3
- data/lib/generators/keepr/migration/templates/migration.rb +27 -25
- data/lib/keepr.rb +8 -0
- data/lib/keepr/account.rb +66 -61
- data/lib/keepr/account_export.rb +10 -14
- data/lib/keepr/active_record_extension.rb +10 -8
- data/lib/keepr/contact_export.rb +6 -7
- data/lib/keepr/cost_center.rb +3 -1
- data/lib/keepr/group.rb +25 -16
- data/lib/keepr/groups_creator.rb +11 -11
- data/lib/keepr/journal.rb +19 -16
- data/lib/keepr/journal_export.rb +10 -7
- data/lib/keepr/posting.rb +26 -21
- data/lib/keepr/tax.rb +4 -2
- data/lib/keepr/version.rb +3 -1
- data/spec/factories/account.rb +6 -4
- data/spec/factories/cost_center.rb +5 -3
- data/spec/factories/group.rb +5 -3
- data/spec/factories/tax.rb +7 -5
- data/spec/keepr/account_export_spec.rb +30 -27
- data/spec/keepr/account_spec.rb +92 -87
- data/spec/keepr/active_record_extension_spec.rb +38 -36
- data/spec/keepr/contact_export_spec.rb +20 -17
- data/spec/keepr/cost_center_spec.rb +9 -7
- data/spec/keepr/group_spec.rb +53 -49
- data/spec/keepr/groups_creator_spec.rb +7 -4
- data/spec/keepr/journal_export_spec.rb +76 -75
- data/spec/keepr/journal_spec.rb +48 -46
- data/spec/keepr/posting_spec.rb +25 -23
- data/spec/keepr/tax_spec.rb +21 -14
- data/spec/spec_helper.rb +13 -11
- data/spec/support/contact.rb +2 -0
- data/spec/support/document.rb +2 -0
- data/spec/support/ledger.rb +2 -0
- data/spec/support/spec_migration.rb +3 -1
- metadata +23 -22
data/lib/keepr/version.rb
CHANGED
data/spec/factories/account.rb
CHANGED
data/spec/factories/group.rb
CHANGED
data/spec/factories/tax.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
-
|
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 {
|
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) {
|
5
|
-
let!(:account_1776) {
|
6
|
-
let!(:account_4920) {
|
7
|
-
let!(:account_8400) {
|
8
|
-
let!(:account_9000) {
|
9
|
-
let!(:account_10000) {
|
10
|
-
let!(:account_70000) {
|
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(
|
16
|
-
|
17
|
-
'
|
18
|
-
'
|
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
|
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
|
35
|
+
it 'should return CSV lines' do
|
33
36
|
subject.lines.each { |line| expect(line).to include(';') }
|
34
37
|
end
|
35
38
|
|
36
|
-
it
|
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
|
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
|
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
|
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)
|
data/spec/keepr/account_spec.rb
CHANGED
@@ -1,89 +1,90 @@
|
|
1
|
-
#
|
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
|
7
|
-
account = Keepr::Account.new(:
|
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
|
12
|
-
account = Keepr::Account.new(:
|
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
|
19
|
-
account = Keepr::Account.new(:
|
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) {
|
27
|
-
let!(:account_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! :
|
31
|
-
:
|
32
|
-
:
|
33
|
-
{ :
|
34
|
-
{ :
|
35
|
-
|
36
|
-
|
37
|
-
Keepr::Journal.create! :
|
38
|
-
:
|
39
|
-
{ :
|
40
|
-
{ :
|
41
|
-
|
42
|
-
|
43
|
-
Keepr::Journal.create! :
|
44
|
-
:
|
45
|
-
{ :
|
46
|
-
{ :
|
47
|
-
|
48
|
-
|
49
|
-
Keepr::Journal.create! :
|
50
|
-
:
|
51
|
-
{ :
|
52
|
-
{ :
|
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) {
|
58
|
-
let!(:liability_group) {
|
59
|
-
let!(:asset_group) {
|
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
|
62
|
-
account =
|
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?
|
65
|
+
expect(account.errors.added?(:keepr_group_id, :no_group_allowed_for_result)).to eq(true)
|
65
66
|
end
|
66
67
|
|
67
|
-
it
|
68
|
-
account =
|
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?
|
71
|
+
expect(account.errors.added?(:kind, :group_mismatch)).to eq(true)
|
71
72
|
end
|
72
73
|
|
73
|
-
it
|
74
|
-
account =
|
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?
|
77
|
+
expect(account.errors.added?(:kind, :group_mismatch)).to eq(true)
|
77
78
|
end
|
78
79
|
|
79
|
-
it
|
80
|
-
account =
|
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?
|
83
|
+
expect(account.errors.added?(:kind, :group_conflict)).to eq(true)
|
83
84
|
end
|
84
85
|
|
85
|
-
it
|
86
|
-
account =
|
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(:
|
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(:
|
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(:
|
153
|
-
expect { Keepr::Account.with_sums(:
|
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(:
|
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) {
|
179
|
-
let!(:account_10000) {
|
180
|
-
let!(:account_10001) {
|
181
|
-
let!(:account_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! :
|
185
|
-
:
|
186
|
-
{ :
|
187
|
-
{ :
|
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
|
-
|
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
|
-
|
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)
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
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
|
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) {
|
5
|
-
let(:account_1200) {
|
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! :
|
9
|
-
let!(:account) { ledger.create_keepr_account! :
|
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
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
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! :
|
32
|
-
let(:account1) { contact.keepr_accounts.create! :
|
33
|
-
let(:account2) { contact.keepr_accounts.create! :
|
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
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
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! :
|
57
|
-
Keepr::Journal.create! :
|
58
|
-
:
|
59
|
-
{ :
|
60
|
-
{ :
|
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! :
|
73
|
-
let!(:booked_document)
|
74
|
-
document = Document.create! :
|
75
|
-
Keepr::Journal.create! :
|
76
|
-
:
|
77
|
-
{ :
|
78
|
-
{ :
|
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 }
|