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.
- 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
@@ -1,22 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Keepr::ContactExport do
|
4
|
-
let!(:account_1000) {
|
5
|
-
let!(:account_10000) {
|
6
|
-
let!(:account_70000) {
|
6
|
+
let!(:account_1000) { FactoryBot.create :account, kind: :asset, number: 1000, name: 'Kasse' }
|
7
|
+
let!(:account_10000) { FactoryBot.create :account, kind: :creditor, number: 10_000, name: 'Meyer GmbH' }
|
8
|
+
let!(:account_70000) { FactoryBot.create :account, kind: :debtor, number: 70_000, name: 'Schulze AG' }
|
7
9
|
|
8
10
|
let(:scope) { Keepr::Account.all }
|
9
11
|
|
10
|
-
let(:export)
|
11
|
-
Keepr::ContactExport.new(
|
12
|
-
|
13
|
-
'
|
14
|
-
'
|
12
|
+
let(:export) do
|
13
|
+
Keepr::ContactExport.new(
|
14
|
+
scope,
|
15
|
+
'Berater' => 1_234_567,
|
16
|
+
'Mandant' => 78_901,
|
17
|
+
'WJ-Beginn' => Date.new(2016, 1, 1),
|
15
18
|
'Bezeichnung' => 'Keepr-Kontakte'
|
16
19
|
) do |account|
|
17
20
|
{ 'Kurzbezeichnung' => account.name }
|
18
21
|
end
|
19
|
-
|
22
|
+
end
|
20
23
|
|
21
24
|
describe :to_s do
|
22
25
|
subject { export.to_s }
|
@@ -25,31 +28,31 @@ describe Keepr::ContactExport do
|
|
25
28
|
subject.lines[2..-1]
|
26
29
|
end
|
27
30
|
|
28
|
-
it
|
31
|
+
it 'should return CSV lines' do
|
29
32
|
subject.lines.each { |line| expect(line).to include(';') }
|
30
33
|
end
|
31
34
|
|
32
|
-
it
|
35
|
+
it 'should include header data' do
|
33
36
|
expect(subject.lines[0]).to include('1234567;')
|
34
37
|
expect(subject.lines[0]).to include('78901;')
|
35
|
-
expect(subject.lines[0]).to include('Keepr-Kontakte;')
|
38
|
+
expect(subject.lines[0]).to include('"Keepr-Kontakte";')
|
36
39
|
end
|
37
40
|
|
38
|
-
it
|
41
|
+
it 'should include debtor/creditor accounts only' do
|
39
42
|
expect(account_lines.count).to eq(2)
|
40
43
|
|
41
44
|
expect(account_lines[0]).to include('10000;')
|
42
45
|
expect(account_lines[1]).to include('70000;')
|
43
46
|
end
|
44
47
|
|
45
|
-
it
|
46
|
-
expect(account_lines[0]).to include('Meyer GmbH;')
|
47
|
-
expect(account_lines[1]).to include('Schulze AG;')
|
48
|
+
it 'should include data from block' do
|
49
|
+
expect(account_lines[0]).to include('"Meyer GmbH";')
|
50
|
+
expect(account_lines[1]).to include('"Schulze AG";')
|
48
51
|
end
|
49
52
|
end
|
50
53
|
|
51
54
|
describe :to_file do
|
52
|
-
it
|
55
|
+
it 'should create CSV file' do
|
53
56
|
Dir.mktmpdir do |dir|
|
54
57
|
filename = "#{dir}/EXTF_Stammdaten.csv"
|
55
58
|
export.to_file(filename)
|
@@ -1,15 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Keepr::CostCenter do
|
4
|
-
let(:cost_center) {
|
5
|
-
let(:account) {
|
6
|
+
let(:cost_center) { FactoryBot.create(:cost_center) }
|
7
|
+
let(:account) { FactoryBot.create(:account, number: 8400, kind: :revenue) }
|
6
8
|
|
7
9
|
it 'should have postings' do
|
8
|
-
posting = Keepr::Posting.create! :
|
9
|
-
:
|
10
|
-
:
|
11
|
-
:
|
12
|
-
:
|
10
|
+
posting = Keepr::Posting.create! amount: 10,
|
11
|
+
side: 'debit',
|
12
|
+
keepr_account: account,
|
13
|
+
keepr_cost_center: cost_center,
|
14
|
+
keepr_journal_id: 42
|
13
15
|
|
14
16
|
expect(cost_center.keepr_postings).to eq([posting])
|
15
17
|
end
|
data/spec/keepr/group_spec.rb
CHANGED
@@ -1,25 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Keepr::Group do
|
4
6
|
describe 'validations' do
|
5
|
-
it
|
6
|
-
group = Keepr::Group.new(:
|
7
|
+
it 'should allow is_result for liability' do
|
8
|
+
group = Keepr::Group.new(is_result: true, target: :liability, name: 'foo')
|
7
9
|
expect(group).to be_valid
|
8
10
|
end
|
9
11
|
|
10
|
-
[
|
12
|
+
%i[asset profit_and_loss].each do |target|
|
11
13
|
it "should not allow is_result for #{target}" do
|
12
|
-
group = Keepr::Group.new(:
|
14
|
+
group = Keepr::Group.new(is_result: true, target: target, name: 'foo')
|
13
15
|
expect(group).not_to be_valid
|
14
|
-
expect(group.errors.added?
|
16
|
+
expect(group.errors.added?(:base, :liability_needed_for_result)).to eq(true)
|
15
17
|
end
|
16
18
|
end
|
17
19
|
end
|
18
20
|
|
19
21
|
describe :get_from_parent do
|
20
22
|
it 'should preset parent' do
|
21
|
-
root =
|
22
|
-
child = root.children.create! :
|
23
|
+
root = FactoryBot.create :group, target: :asset
|
24
|
+
child = root.children.create! name: 'Bar'
|
23
25
|
|
24
26
|
expect(child.target).to eq('asset')
|
25
27
|
end
|
@@ -27,16 +29,16 @@ describe Keepr::Group do
|
|
27
29
|
|
28
30
|
describe :keepr_accounts do
|
29
31
|
it 'should not destroy if there are accounts' do
|
30
|
-
group =
|
31
|
-
|
32
|
+
group = FactoryBot.create :group
|
33
|
+
FactoryBot.create :account, number: 1000, keepr_group: group
|
32
34
|
|
33
|
-
expect { group.destroy }.to_not change
|
35
|
+
expect { group.destroy }.to_not change(Keepr::Group, :count)
|
34
36
|
expect(group.destroy).to eq(false)
|
35
37
|
expect(group.reload).to eq(group)
|
36
38
|
end
|
37
39
|
|
38
40
|
it 'should destroy if there are no accounts' do
|
39
|
-
group =
|
41
|
+
group = FactoryBot.create :group
|
40
42
|
|
41
43
|
expect { group.destroy }.to change { Keepr::Group.count }.by(-1)
|
42
44
|
end
|
@@ -44,58 +46,60 @@ describe Keepr::Group do
|
|
44
46
|
|
45
47
|
describe :keepr_postings do
|
46
48
|
# Simple asset group hierarchy
|
47
|
-
let(:group_1) {
|
48
|
-
let(:group_1_1) {
|
49
|
-
let(:group_1_1_1) {
|
49
|
+
let(:group_1) { FactoryBot.create :group, target: :asset }
|
50
|
+
let(:group_1_1) { FactoryBot.create :group, target: :asset, parent: group_1 }
|
51
|
+
let(:group_1_1_1) { FactoryBot.create :group, target: :asset, parent: group_1_1 }
|
50
52
|
|
51
53
|
# Group for P&L accounts
|
52
|
-
let(:group_2) {
|
54
|
+
let(:group_2) { FactoryBot.create :group, target: :profit_and_loss }
|
53
55
|
|
54
56
|
# Group for balance result
|
55
|
-
let(:group_result){
|
57
|
+
let(:group_result) { FactoryBot.create :group, target: :liability, is_result: true }
|
56
58
|
|
57
59
|
# Accounts
|
58
|
-
let(:account_1a) {
|
59
|
-
let(:account_1b) {
|
60
|
-
let(:account_1c) {
|
60
|
+
let(:account_1a) { FactoryBot.create :account, number: '0001', keepr_group: group_1_1_1 }
|
61
|
+
let(:account_1b) { FactoryBot.create :account, number: '0011', keepr_group: group_1_1_1 }
|
62
|
+
let(:account_1c) { FactoryBot.create :account, number: '0111', keepr_group: group_1_1_1 }
|
61
63
|
|
62
|
-
let(:account_2) {
|
64
|
+
let(:account_2) { FactoryBot.create :account, number: '8400', keepr_group: group_2, kind: :revenue }
|
63
65
|
|
64
66
|
# Journals
|
65
|
-
let!(:journal1)
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
67
|
+
let!(:journal1) do
|
68
|
+
Keepr::Journal.create! keepr_postings_attributes: [
|
69
|
+
{ keepr_account: account_1a, amount: 100.99, side: 'debit' },
|
70
|
+
{ keepr_account: account_2, amount: 100.99, side: 'credit' }
|
71
|
+
]
|
72
|
+
end
|
73
|
+
let!(:journal2) do
|
74
|
+
Keepr::Journal.create! keepr_postings_attributes: [
|
75
|
+
{ keepr_account: account_1b, amount: 100.99, side: 'debit' },
|
76
|
+
{ keepr_account: account_2, amount: 100.99, side: 'credit' }
|
77
|
+
]
|
78
|
+
end
|
79
|
+
let!(:journal3) do
|
80
|
+
Keepr::Journal.create! keepr_postings_attributes: [
|
81
|
+
{ keepr_account: account_1c, amount: 100.99, side: 'debit' },
|
82
|
+
{ keepr_account: account_2, amount: 100.99, side: 'credit' }
|
83
|
+
]
|
84
|
+
end
|
80
85
|
|
81
86
|
context 'for normal groups' do
|
82
|
-
it
|
83
|
-
|
84
|
-
expect(group_1.keepr_postings).to eq(
|
85
|
-
expect(group_1_1.keepr_postings).to eq(
|
86
|
-
expect(group_1_1_1.keepr_postings).to eq(
|
87
|
-
|
88
|
-
|
89
|
-
expect(group_2.keepr_postings).to eq(
|
87
|
+
it 'should return postings of all accounts within the group' do
|
88
|
+
postings1 = [journal1.debit_postings.first, journal2.debit_postings.first, journal3.debit_postings.first]
|
89
|
+
expect(group_1.keepr_postings).to eq(postings1)
|
90
|
+
expect(group_1_1.keepr_postings).to eq(postings1)
|
91
|
+
expect(group_1_1_1.keepr_postings).to eq(postings1)
|
92
|
+
|
93
|
+
postings2 = [journal1.credit_postings.first, journal2.credit_postings.first, journal3.credit_postings.first]
|
94
|
+
expect(group_2.keepr_postings).to eq(postings2)
|
90
95
|
end
|
91
96
|
end
|
92
97
|
|
93
|
-
context
|
94
|
-
it
|
95
|
-
result_postings = [
|
96
|
-
|
97
|
-
|
98
|
-
]
|
98
|
+
context 'for result group' do
|
99
|
+
it 'should return postings for P&L accounts' do
|
100
|
+
result_postings = [journal1.credit_postings.first,
|
101
|
+
journal2.credit_postings.first,
|
102
|
+
journal3.credit_postings.first]
|
99
103
|
|
100
104
|
expect(group_result.keepr_postings).to eq(result_postings)
|
101
105
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Keepr::GroupsCreator do
|
@@ -6,7 +8,7 @@ describe Keepr::GroupsCreator do
|
|
6
8
|
Keepr::GroupsCreator.new(:balance).run
|
7
9
|
end
|
8
10
|
|
9
|
-
it
|
11
|
+
it 'should create groups' do
|
10
12
|
expect(Keepr::Group.count).to eq(64)
|
11
13
|
expect(Keepr::Group.asset.count).to eq(36)
|
12
14
|
expect(Keepr::Group.liability.count).to eq(28)
|
@@ -15,7 +17,7 @@ describe Keepr::GroupsCreator do
|
|
15
17
|
compare_with_source(Keepr::Group.liability, 'liability.txt')
|
16
18
|
end
|
17
19
|
|
18
|
-
it
|
20
|
+
it 'should create result group' do
|
19
21
|
expect(Keepr::Group.result).to be_a(Keepr::Group)
|
20
22
|
end
|
21
23
|
end
|
@@ -25,7 +27,7 @@ describe Keepr::GroupsCreator do
|
|
25
27
|
Keepr::GroupsCreator.new(:profit_and_loss).run
|
26
28
|
end
|
27
29
|
|
28
|
-
it
|
30
|
+
it 'should create profit & loss groups' do
|
29
31
|
expect(Keepr::Group.count).to eq(31)
|
30
32
|
expect(Keepr::Group.profit_and_loss.count).to eq(31)
|
31
33
|
|
@@ -33,7 +35,8 @@ describe Keepr::GroupsCreator do
|
|
33
35
|
end
|
34
36
|
end
|
35
37
|
|
36
|
-
private
|
38
|
+
private
|
39
|
+
|
37
40
|
def compare_with_source(scope, filename)
|
38
41
|
full_filename = File.join(File.dirname(__FILE__), "../../lib/keepr/groups_creator/#{filename}")
|
39
42
|
source = File.read(full_filename)
|
@@ -1,34 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Keepr::JournalExport do
|
4
|
-
let(:ust) { Keepr::Tax.create! :
|
5
|
-
let(:vst) { Keepr::Tax.create! :
|
6
|
+
let(:ust) { Keepr::Tax.create! name: 'USt19', value: 19.0, keepr_account: account_1776 }
|
7
|
+
let(:vst) { Keepr::Tax.create! name: 'VSt19', value: 19.0, keepr_account: account_1576 }
|
6
8
|
|
7
|
-
let(:account_1000) {
|
8
|
-
let(:account_1200) {
|
9
|
-
let(:account_1576) {
|
10
|
-
let(:account_1776) {
|
11
|
-
let(:account_1600) {
|
12
|
-
let(:account_1718) {
|
13
|
-
let(:account_4920) {
|
14
|
-
let(:account_8400) {
|
9
|
+
let(:account_1000) { FactoryBot.create :account, number: 1000, kind: :asset }
|
10
|
+
let(:account_1200) { FactoryBot.create :account, number: 1200, kind: :asset }
|
11
|
+
let(:account_1576) { FactoryBot.create :account, number: 1576, kind: :asset }
|
12
|
+
let(:account_1776) { FactoryBot.create :account, number: 1776, kind: :liability }
|
13
|
+
let(:account_1600) { FactoryBot.create :account, number: 1600, kind: :liability }
|
14
|
+
let(:account_1718) { FactoryBot.create :account, number: 1718, kind: :liability, keepr_tax: ust }
|
15
|
+
let(:account_4920) { FactoryBot.create :account, number: 4920, kind: :expense, keepr_tax: vst }
|
16
|
+
let(:account_8400) { FactoryBot.create :account, number: 8400, kind: :revenue, keepr_tax: ust }
|
15
17
|
|
16
|
-
let(:account_10000) {
|
18
|
+
let(:account_10000) { FactoryBot.create :account, number: 10_000, kind: :debtor }
|
17
19
|
|
18
20
|
let(:scope) { Keepr::Journal.reorder(:number) }
|
19
21
|
|
20
|
-
let(:export)
|
22
|
+
let(:export) do
|
21
23
|
Keepr::JournalExport.new(scope,
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
) do |posting|
|
24
|
+
'Berater' => 1_234_567,
|
25
|
+
'Mandant' => 78_901,
|
26
|
+
'Datum vom' => Date.new(2016, 6, 1),
|
27
|
+
'Datum bis' => Date.new(2016, 6, 30),
|
28
|
+
'WJ-Beginn' => Date.new(2016, 1, 1),
|
29
|
+
'Bezeichnung' => 'Keepr-Buchungen') do |posting|
|
29
30
|
{ 'Identifikationsnummer' => "ID:#{posting.id}" }
|
30
31
|
end
|
31
|
-
|
32
|
+
end
|
32
33
|
|
33
34
|
describe :to_s do
|
34
35
|
subject { export.to_s }
|
@@ -37,127 +38,127 @@ describe Keepr::JournalExport do
|
|
37
38
|
subject.lines[2..-1]
|
38
39
|
end
|
39
40
|
|
40
|
-
it
|
41
|
+
it 'should return CSV lines' do
|
41
42
|
expect(subject.lines.count).to eq(2)
|
42
43
|
subject.lines.each { |line| expect(line).to include(';') }
|
43
44
|
end
|
44
45
|
|
45
|
-
it
|
46
|
+
it 'should include header data' do
|
46
47
|
expect(subject.lines[0]).to include('1234567;')
|
47
48
|
expect(subject.lines[0]).to include('78901;')
|
48
49
|
expect(subject.lines[0]).to include('20160601;20160630;')
|
49
|
-
expect(subject.lines[0]).to include('Keepr-Buchungen;')
|
50
|
+
expect(subject.lines[0]).to include('"Keepr-Buchungen";')
|
50
51
|
end
|
51
52
|
|
52
|
-
context
|
53
|
+
context 'Journal without tax' do
|
53
54
|
let!(:journal_without_tax) do
|
54
|
-
Keepr::Journal.create! :
|
55
|
-
:
|
56
|
-
:
|
57
|
-
:
|
58
|
-
{ :
|
59
|
-
{ :
|
55
|
+
Keepr::Journal.create! number: 'BELEG-1',
|
56
|
+
subject: 'Geldautomat',
|
57
|
+
date: Date.new(2016, 0o6, 23),
|
58
|
+
keepr_postings_attributes: [
|
59
|
+
{ keepr_account: account_1000, amount: 105, side: 'debit' },
|
60
|
+
{ keepr_account: account_1200, amount: 105, side: 'credit' }
|
60
61
|
]
|
61
62
|
end
|
62
63
|
|
63
|
-
it
|
64
|
+
it 'should include data' do
|
64
65
|
expect(booking_lines.count).to eq(1)
|
65
66
|
|
66
|
-
expect(booking_lines[0]).to include('Geldautomat;')
|
67
|
+
expect(booking_lines[0]).to include('"Geldautomat";')
|
67
68
|
expect(booking_lines[0]).to include('1000;1200;')
|
68
69
|
expect(booking_lines[0]).to include('105,00;')
|
69
|
-
expect(booking_lines[0]).to include(';S;')
|
70
|
+
expect(booking_lines[0]).to include(';"S";')
|
70
71
|
expect(booking_lines[0]).to include('2306;')
|
71
|
-
expect(booking_lines[0]).to include('BELEG-1;')
|
72
|
+
expect(booking_lines[0]).to include('"BELEG-1";')
|
72
73
|
expect(booking_lines[0]).to include(';0;')
|
73
74
|
end
|
74
75
|
end
|
75
76
|
|
76
|
-
context
|
77
|
+
context 'Journal with tax' do
|
77
78
|
let!(:journal_with_tax) do
|
78
|
-
Keepr::Journal.create! :
|
79
|
-
:
|
80
|
-
:
|
81
|
-
:
|
82
|
-
{ :
|
83
|
-
{ :
|
84
|
-
{ :
|
79
|
+
Keepr::Journal.create! number: 'BELEG-2',
|
80
|
+
subject: 'Telefonrechnung',
|
81
|
+
date: Date.new(2016, 0o6, 24),
|
82
|
+
keepr_postings_attributes: [
|
83
|
+
{ keepr_account: account_4920, amount: 8.40, side: 'debit' },
|
84
|
+
{ keepr_account: account_1576, amount: 1.60, side: 'debit' },
|
85
|
+
{ keepr_account: account_1600, amount: 10.00, side: 'credit' }
|
85
86
|
]
|
86
87
|
end
|
87
88
|
|
88
|
-
it
|
89
|
+
it 'should include data' do
|
89
90
|
expect(booking_lines.count).to eq(2)
|
90
91
|
|
91
|
-
expect(booking_lines[0]).to include('Telefonrechnung;')
|
92
|
+
expect(booking_lines[0]).to include('"Telefonrechnung";')
|
92
93
|
expect(booking_lines[0]).to include('4920;1600;')
|
93
94
|
expect(booking_lines[0]).to include('8,40;')
|
94
|
-
expect(booking_lines[0]).to include(';S;')
|
95
|
+
expect(booking_lines[0]).to include(';"S";')
|
95
96
|
expect(booking_lines[0]).to include('2406;')
|
96
|
-
expect(booking_lines[0]).to include('BELEG-2;')
|
97
|
+
expect(booking_lines[0]).to include('"BELEG-2";')
|
97
98
|
expect(booking_lines[0]).to include(';0;')
|
98
99
|
|
99
|
-
expect(booking_lines[1]).to include('Telefonrechnung;')
|
100
|
+
expect(booking_lines[1]).to include('"Telefonrechnung";')
|
100
101
|
expect(booking_lines[1]).to include('1576;1600;')
|
101
102
|
expect(booking_lines[1]).to include('1,60;')
|
102
|
-
expect(booking_lines[1]).to include(';S;')
|
103
|
+
expect(booking_lines[1]).to include(';"S";')
|
103
104
|
expect(booking_lines[1]).to include('2406;')
|
104
|
-
expect(booking_lines[1]).to include('BELEG-2;')
|
105
|
+
expect(booking_lines[1]).to include('"BELEG-2";')
|
105
106
|
expect(booking_lines[1]).to include(';0;')
|
106
107
|
end
|
107
108
|
end
|
108
109
|
|
109
|
-
context
|
110
|
+
context 'Journal with debtor' do
|
110
111
|
let!(:journal_with_debtor) do
|
111
|
-
Keepr::Journal.create! :
|
112
|
-
:
|
113
|
-
:
|
114
|
-
:
|
115
|
-
{ :
|
116
|
-
{ :
|
117
|
-
{ :
|
118
|
-
|
119
|
-
{ :
|
120
|
-
{ :
|
112
|
+
Keepr::Journal.create! number: 'BELEG-3',
|
113
|
+
subject: 'Warenverkauf mit Anzahlung',
|
114
|
+
date: Date.new(2016, 0o6, 25),
|
115
|
+
keepr_postings_attributes: [
|
116
|
+
{ keepr_account: account_10000, amount: 4760.00, side: 'debit' },
|
117
|
+
{ keepr_account: account_1718, amount: 1000.00, side: 'debit' },
|
118
|
+
{ keepr_account: account_1776, amount: 190.00, side: 'debit' },
|
119
|
+
|
120
|
+
{ keepr_account: account_8400, amount: 5000.00, side: 'credit' },
|
121
|
+
{ keepr_account: account_1776, amount: 950.00, side: 'credit' }
|
121
122
|
]
|
122
123
|
end
|
123
124
|
|
124
|
-
it
|
125
|
+
it 'should include data' do
|
125
126
|
expect(booking_lines.count).to eq(4)
|
126
127
|
|
127
|
-
expect(booking_lines[0]).to include('Warenverkauf mit Anzahlung;')
|
128
|
+
expect(booking_lines[0]).to include('"Warenverkauf mit Anzahlung";')
|
128
129
|
expect(booking_lines[0]).to include('10000;8400;')
|
129
130
|
expect(booking_lines[0]).to include('5000,00;')
|
130
|
-
expect(booking_lines[0]).to include(';S;')
|
131
|
+
expect(booking_lines[0]).to include(';"S";')
|
131
132
|
expect(booking_lines[0]).to include('2506;')
|
132
|
-
expect(booking_lines[0]).to include('BELEG-3;')
|
133
|
+
expect(booking_lines[0]).to include('"BELEG-3";')
|
133
134
|
expect(booking_lines[0]).to include(';0;')
|
134
135
|
|
135
|
-
expect(booking_lines[1]).to include('Warenverkauf mit Anzahlung;')
|
136
|
+
expect(booking_lines[1]).to include('"Warenverkauf mit Anzahlung";')
|
136
137
|
expect(booking_lines[1]).to include('10000;1776;')
|
137
138
|
expect(booking_lines[1]).to include('950,00;')
|
138
|
-
expect(booking_lines[1]).to include(';S;')
|
139
|
+
expect(booking_lines[1]).to include(';"S";')
|
139
140
|
expect(booking_lines[1]).to include('2506;')
|
140
|
-
expect(booking_lines[1]).to include('BELEG-3;')
|
141
|
+
expect(booking_lines[1]).to include('"BELEG-3";')
|
141
142
|
expect(booking_lines[1]).to include(';0;')
|
142
143
|
|
143
|
-
expect(booking_lines[2]).to include('Warenverkauf mit Anzahlung;')
|
144
|
+
expect(booking_lines[2]).to include('"Warenverkauf mit Anzahlung";')
|
144
145
|
expect(booking_lines[2]).to include('1718;10000;')
|
145
146
|
expect(booking_lines[2]).to include('1000,00;')
|
146
|
-
expect(booking_lines[2]).to include(';S;')
|
147
|
+
expect(booking_lines[2]).to include(';"S";')
|
147
148
|
expect(booking_lines[2]).to include('2506;')
|
148
|
-
expect(booking_lines[2]).to include('BELEG-3;')
|
149
|
+
expect(booking_lines[2]).to include('"BELEG-3";')
|
149
150
|
expect(booking_lines[2]).to include(';0;')
|
150
151
|
|
151
|
-
expect(booking_lines[3]).to include('Warenverkauf mit Anzahlung;')
|
152
|
+
expect(booking_lines[3]).to include('"Warenverkauf mit Anzahlung";')
|
152
153
|
expect(booking_lines[3]).to include('1776;10000;')
|
153
154
|
expect(booking_lines[3]).to include('190,00;')
|
154
|
-
expect(booking_lines[3]).to include(';S;')
|
155
|
+
expect(booking_lines[3]).to include(';"S";')
|
155
156
|
expect(booking_lines[3]).to include('2506;')
|
156
|
-
expect(booking_lines[3]).to include('BELEG-3;')
|
157
|
+
expect(booking_lines[3]).to include('"BELEG-3";')
|
157
158
|
expect(booking_lines[3]).to include(';0;')
|
158
159
|
end
|
159
160
|
|
160
|
-
it
|
161
|
+
it 'should include data from block' do
|
161
162
|
expect(booking_lines[0]).to include('ID:')
|
162
163
|
expect(booking_lines[1]).to include('ID:')
|
163
164
|
end
|
@@ -165,7 +166,7 @@ describe Keepr::JournalExport do
|
|
165
166
|
end
|
166
167
|
|
167
168
|
describe :to_file do
|
168
|
-
it
|
169
|
+
it 'should create CSV file' do
|
169
170
|
Dir.mktmpdir do |dir|
|
170
171
|
filename = "#{dir}/EXTF_Buchungsstapel.csv"
|
171
172
|
export.to_file(filename)
|