cmxl 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +5 -2
- data/CHANGELOG.mdown +28 -18
- data/README.md +45 -26
- data/cmxl.gemspec +15 -16
- data/lib/cmxl.rb +9 -9
- data/lib/cmxl/field.rb +25 -18
- data/lib/cmxl/fields/account_balance.rb +7 -7
- data/lib/cmxl/fields/account_identification.rb +1 -1
- data/lib/cmxl/fields/floor_limit_indicator.rb +20 -0
- data/lib/cmxl/fields/reference.rb +3 -4
- data/lib/cmxl/fields/statement_details.rb +13 -13
- data/lib/cmxl/fields/transaction.rb +10 -1
- data/lib/cmxl/fields/transaction_supplementary.rb +11 -8
- data/lib/cmxl/fields/vmk_summary.rb +33 -0
- data/lib/cmxl/statement.rb +52 -22
- data/lib/cmxl/version.rb +1 -1
- data/spec/field_spec.rb +8 -9
- data/spec/fields/account_balance_spec.rb +18 -18
- data/spec/fields/account_identification_spec.rb +2 -6
- data/spec/fields/available_balance_spec.rb +1 -3
- data/spec/fields/closing_balance_spec.rb +2 -4
- data/spec/fields/entry_date_spec.rb +1 -1
- data/spec/fields/floor_limit_indicator_spec.rb +30 -0
- data/spec/fields/reference_spec.rb +2 -3
- data/spec/fields/statement_details_spec.rb +61 -56
- data/spec/fields/statement_number_spec.rb +0 -2
- data/spec/fields/transaction_spec.rb +4 -4
- data/spec/fields/transaction_supplementary_spec.rb +4 -4
- data/spec/fields/unknown_spec.rb +1 -2
- data/spec/fields/vmk_summary_spec.rb +23 -0
- data/spec/fixtures/lines/floor_limit_indicator_both.txt +1 -0
- data/spec/fixtures/lines/floor_limit_indicator_credit.txt +1 -0
- data/spec/fixtures/lines/floor_limit_indicator_debit.txt +1 -0
- data/spec/fixtures/lines/vmk_summary_credit.txt +1 -0
- data/spec/fixtures/lines/vmk_summary_debit.txt +1 -0
- data/spec/fixtures/mt942.txt +9 -0
- data/spec/fixtures/statement-details-mt942.txt +4 -0
- data/spec/mt940_parsing_spec.rb +13 -14
- data/spec/spec_helper.rb +3 -6
- data/spec/statement_spec.rb +119 -99
- data/spec/support/fixtures.rb +1 -1
- metadata +39 -20
data/spec/field_spec.rb
CHANGED
@@ -5,7 +5,7 @@ describe Cmxl::Field do
|
|
5
5
|
|
6
6
|
it { expect(Cmxl::Field.parser).to eql(/(?<details>.*)/) } # default must be set
|
7
7
|
|
8
|
-
it { expect(subject.to_h).to eql(
|
8
|
+
it { expect(subject.to_h).to eql('tag' => 42, 'details' => 'D140829EUR000000000147,64') }
|
9
9
|
it { expect(subject.to_hash).to eql(subject.to_h) }
|
10
10
|
|
11
11
|
it { expect(subject.to_amount('123.')).to eql(123.00) }
|
@@ -14,14 +14,13 @@ describe Cmxl::Field do
|
|
14
14
|
it { expect(subject.to_amount('123,1')).to eql(123.10) }
|
15
15
|
it { expect(subject.to_amount('123,11')).to eql(123.11) }
|
16
16
|
|
17
|
-
it { expect(subject.to_amount_in_cents('123.')).to eql(
|
18
|
-
it { expect(subject.to_amount_in_cents('123.1')).to eql(
|
19
|
-
it { expect(subject.to_amount_in_cents('123.11')).to eql(
|
20
|
-
it { expect(subject.to_amount_in_cents('123,1')).to eql(
|
21
|
-
it { expect(subject.to_amount_in_cents('123,11')).to eql(
|
17
|
+
it { expect(subject.to_amount_in_cents('123.')).to eql(12_300) }
|
18
|
+
it { expect(subject.to_amount_in_cents('123.1')).to eql(12_310) }
|
19
|
+
it { expect(subject.to_amount_in_cents('123.11')).to eql(12_311) }
|
20
|
+
it { expect(subject.to_amount_in_cents('123,1')).to eql(12_310) }
|
21
|
+
it { expect(subject.to_amount_in_cents('123,11')).to eql(12_311) }
|
22
22
|
|
23
23
|
it { expect(subject.to_date('invalid')).to eql('invalid') }
|
24
|
-
it { expect(subject.to_date('140914')).to eql(Date.new(2014,9,14)) }
|
25
|
-
it { expect(subject.to_date('140914', 2013)).to eql(Date.new(2013,9,14)) }
|
26
|
-
|
24
|
+
it { expect(subject.to_date('140914')).to eql(Date.new(2014, 9, 14)) }
|
25
|
+
it { expect(subject.to_date('140914', 2013)).to eql(Date.new(2013, 9, 14)) }
|
27
26
|
end
|
@@ -1,42 +1,42 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'date'
|
3
3
|
describe Cmxl::Fields::AccountBalance do
|
4
|
-
|
5
4
|
context 'Credit' do
|
6
|
-
subject { Cmxl::Fields::AccountBalance.parse(
|
5
|
+
subject { Cmxl::Fields::AccountBalance.parse(fixture_line(:account_balance_credit)) }
|
7
6
|
|
8
|
-
it { expect(subject.date).to eql(Date.new(2014,8,29)) }
|
7
|
+
it { expect(subject.date).to eql(Date.new(2014, 8, 29)) }
|
9
8
|
it { expect(subject).to be_credit }
|
10
9
|
it { expect(subject).to_not be_debit }
|
11
10
|
it { expect(subject.currency).to eql('EUR') }
|
12
11
|
|
13
12
|
it { expect(subject.amount).to eql(147.64) }
|
14
|
-
it { expect(subject.amount_in_cents).to eql(
|
13
|
+
it { expect(subject.amount_in_cents).to eql(14_764) }
|
15
14
|
it { expect(subject.sign).to eql(1) }
|
16
|
-
it {
|
17
|
-
|
18
|
-
'
|
19
|
-
'
|
20
|
-
'
|
21
|
-
'
|
22
|
-
'
|
23
|
-
'
|
24
|
-
'
|
15
|
+
it {
|
16
|
+
expect(subject.to_h).to eql(
|
17
|
+
'date' => Date.new(2014, 8, 29),
|
18
|
+
'funds_code' => 'C',
|
19
|
+
'credit' => true,
|
20
|
+
'debit' => false,
|
21
|
+
'currency' => 'EUR',
|
22
|
+
'amount' => 147.64,
|
23
|
+
'amount_in_cents' => 14_764,
|
24
|
+
'sign' => 1,
|
25
25
|
'tag' => '60'
|
26
|
-
|
26
|
+
)
|
27
|
+
}
|
27
28
|
end
|
28
29
|
|
29
30
|
context 'Debit' do
|
30
|
-
subject { Cmxl::Fields::AccountBalance.parse(
|
31
|
+
subject { Cmxl::Fields::AccountBalance.parse(fixture_line(:account_balance_debit)) }
|
31
32
|
|
32
|
-
it { expect(subject.date).to eql(Date.new(2014,8,29)) }
|
33
|
+
it { expect(subject.date).to eql(Date.new(2014, 8, 29)) }
|
33
34
|
it { expect(subject).to_not be_credit }
|
34
35
|
it { expect(subject).to be_debit }
|
35
36
|
it { expect(subject.currency).to eql('EUR') }
|
36
37
|
|
37
38
|
it { expect(subject.amount).to eql(147.64) }
|
38
|
-
it { expect(subject.amount_in_cents).to eql(
|
39
|
+
it { expect(subject.amount_in_cents).to eql(14_764) }
|
39
40
|
it { expect(subject.sign).to eql(-1) }
|
40
41
|
end
|
41
|
-
|
42
42
|
end
|
@@ -1,24 +1,20 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Cmxl::Fields::AccountIdentification do
|
4
|
-
|
5
4
|
context 'legacy data' do
|
6
|
-
subject { Cmxl::Fields::AccountBalance.parse(
|
5
|
+
subject { Cmxl::Fields::AccountBalance.parse(fixture_line(:account_identification_legacy)) }
|
7
6
|
|
8
7
|
it { expect(subject.bank_code).to eql('70011110') }
|
9
8
|
it { expect(subject.account_number).to eql('4005287001') }
|
10
9
|
it { expect(subject.currency).to eql('EUR') }
|
11
10
|
it { expect(subject.country).to be_nil }
|
12
|
-
|
13
11
|
end
|
14
12
|
|
15
13
|
context 'iban' do
|
16
|
-
subject { Cmxl::Fields::AccountBalance.parse(
|
14
|
+
subject { Cmxl::Fields::AccountBalance.parse(fixture_line(:account_identification_iban)) }
|
17
15
|
it { expect(subject.country).to eql('PL') }
|
18
16
|
it { expect(subject.ban).to eql('25106000760000888888888888') }
|
19
17
|
it { expect(subject.iban).to eql('PL25106000760000888888888888') }
|
20
18
|
it { expect(subject.bank_code).to be_nil }
|
21
|
-
|
22
19
|
end
|
23
|
-
|
24
20
|
end
|
@@ -1,10 +1,9 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Cmxl::Fields::AvailableBalance do
|
4
|
-
|
5
4
|
subject { Cmxl::Fields::AvailableBalance.parse(fixture_line(:available_balance)) }
|
6
5
|
|
7
|
-
it { expect(subject.date).to eql(Date.new(2014,9,1)) }
|
6
|
+
it { expect(subject.date).to eql(Date.new(2014, 9, 1)) }
|
8
7
|
it { expect(subject).to_not be_credit }
|
9
8
|
it { expect(subject).to be_debit }
|
10
9
|
it { expect(subject.currency).to eql('EUR') }
|
@@ -12,5 +11,4 @@ describe Cmxl::Fields::AvailableBalance do
|
|
12
11
|
it { expect(subject.amount).to eql(3.66) }
|
13
12
|
it { expect(subject.amount_in_cents).to eql(366) }
|
14
13
|
it { expect(subject.sign).to eql(-1) }
|
15
|
-
|
16
14
|
end
|
@@ -1,15 +1,13 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Cmxl::Fields::ClosingBalance do
|
4
|
-
|
5
4
|
subject { Cmxl::Fields::ClosingBalance.parse(fixture_line(:closing_balance)) }
|
6
5
|
|
7
|
-
it { expect(subject.date).to eql(Date.new(2014,9,1)) }
|
6
|
+
it { expect(subject.date).to eql(Date.new(2014, 9, 1)) }
|
8
7
|
it { expect(subject).to be_credit }
|
9
8
|
it { expect(subject).to_not be_debit }
|
10
9
|
|
11
10
|
it { expect(subject.amount).to eql(137.0) }
|
12
|
-
it { expect(subject.amount_in_cents).to eql(
|
11
|
+
it { expect(subject.amount_in_cents).to eql(13_700) }
|
13
12
|
it { expect(subject.sign).to eql(1) }
|
14
|
-
|
15
13
|
end
|
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Cmxl::Fields::EntryDate do
|
4
4
|
context 'iban' do
|
5
|
-
subject { Cmxl::Fields::EntryDate.parse(
|
5
|
+
subject { Cmxl::Fields::EntryDate.parse(fixture_line(:entry_date)) }
|
6
6
|
|
7
7
|
it { expect(subject.date).to eql(Date.parse('2017/12/29')) }
|
8
8
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Cmxl::Fields::FloorLimitIndicator do
|
4
|
+
context 'credit' do
|
5
|
+
subject { Cmxl::Fields::FloorLimitIndicator.parse(fixture_line(:floor_limit_indicator_credit)) }
|
6
|
+
|
7
|
+
it { expect(subject.amount).to eql(47.11) }
|
8
|
+
it { expect(subject.currency).to eql('EUR') }
|
9
|
+
it { expect(subject.credit?).to be_truthy }
|
10
|
+
it { expect(subject.debit?).to be_falsey }
|
11
|
+
end
|
12
|
+
|
13
|
+
context 'debit' do
|
14
|
+
subject { Cmxl::Fields::FloorLimitIndicator.parse(fixture_line(:floor_limit_indicator_debit)) }
|
15
|
+
|
16
|
+
it { expect(subject.amount).to eql(13.37) }
|
17
|
+
it { expect(subject.currency).to eql('EUR') }
|
18
|
+
it { expect(subject.credit?).to be_falsey }
|
19
|
+
it { expect(subject.debit?).to be_truthy }
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'both' do
|
23
|
+
subject { Cmxl::Fields::FloorLimitIndicator.parse(fixture_line(:floor_limit_indicator_both)) }
|
24
|
+
|
25
|
+
it { expect(subject.amount).to eql(13.37) }
|
26
|
+
it { expect(subject.currency).to eql('EUR') }
|
27
|
+
it { expect(subject.credit?).to be_truthy }
|
28
|
+
it { expect(subject.debit?).to be_truthy }
|
29
|
+
end
|
30
|
+
end
|
@@ -1,13 +1,12 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Cmxl::Fields::Reference do
|
4
|
-
|
5
4
|
subject { Cmxl::Fields::Reference.parse(fixture_line(:reference)) }
|
6
5
|
|
7
6
|
it { expect(subject.reference).to eql('D140902049') }
|
8
|
-
it { expect(subject.date).to eql(Date.new(2014,9,2)) }
|
7
|
+
it { expect(subject.date).to eql(Date.new(2014, 9, 2)) }
|
9
8
|
it { expect(subject.statement_identifier).to eql('D') }
|
10
9
|
it { expect(subject.additional_number).to eql('049') }
|
11
|
-
it { expect(subject.to_h).to eql(
|
10
|
+
it { expect(subject.to_h).to eql('tag' => '20', 'statement_identifier' => 'D', 'date' => Date.new(2014, 9, 2), 'additional_number' => '049', 'reference' => 'D140902049') }
|
12
11
|
it { expect(subject.to_hash).to eql(subject.to_h) }
|
13
12
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Cmxl::Fields::StatementDetails do
|
4
|
-
|
5
4
|
context 'sepa' do
|
6
5
|
subject { Cmxl::Fields::StatementDetails.parse(fixture_line(:statement_details)) }
|
7
6
|
|
@@ -9,65 +8,69 @@ describe Cmxl::Fields::StatementDetails do
|
|
9
8
|
it { expect(subject.seperator).to eql('?') }
|
10
9
|
it { expect(subject.description).to eql('SEPA LASTSCHRIFT KUNDE') }
|
11
10
|
it { expect(subject.information).to eql('KREF+EREF+TRX-0A4A47C3-F846-4729-8A1B-5DF620FMREF+CAC97D2144174318AC18D9BF815BD4FBCRED+DE98ZZZ09999999999SVWZ+FOO TRX-0A4A47C3-F846-4729-8A1B-5DF620F') }
|
12
|
-
it { expect(subject.bic).to eql('HYVEDEMMXXX'
|
11
|
+
it { expect(subject.bic).to eql('HYVEDEMMXXX') }
|
13
12
|
it { expect(subject.name).to eql('Peter Pan') }
|
14
13
|
it { expect(subject.iban).to eql('HUkkbbbsssskcccccccccccccccx') }
|
15
|
-
it {
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
14
|
+
it {
|
15
|
+
expect(subject.sub_fields).to eql(
|
16
|
+
'00' => 'SEPA LASTSCHRIFT KUNDE',
|
17
|
+
'10' => '281',
|
18
|
+
'20' => 'KREF+EREF+TRX-0A4A47C3-F846-4729',
|
19
|
+
'21' => '-8A1B-5DF620F',
|
20
|
+
'22' => 'MREF+CAC97D2144174318AC18D9',
|
21
|
+
'23' => 'BF815BD4FB',
|
22
|
+
'24' => 'CRED+DE98ZZZ09999999999',
|
23
|
+
'25' => 'SVWZ+FOO TRX-0A4A47C3-F84',
|
24
|
+
'26' => '6-4729-8A1B-5DF620F',
|
25
|
+
'30' => 'HYVEDEMMXXX',
|
26
|
+
'31' => 'HUkkbbbsssskcccccccccccccccx',
|
27
|
+
'32' => 'Peter Pan',
|
28
|
+
'99' => '',
|
29
|
+
'34' => '171'
|
30
|
+
)
|
31
|
+
}
|
32
|
+
it {
|
33
|
+
expect(subject.sepa).to eql(
|
34
|
+
'KREF' => '',
|
35
|
+
'CRED' => 'DE98ZZZ09999999999',
|
36
|
+
'EREF' => 'TRX-0A4A47C3-F846-4729-8A1B-5DF620F',
|
37
|
+
'MREF' => 'CAC97D2144174318AC18D9BF815BD4FB',
|
38
|
+
'SVWZ' => 'FOO TRX-0A4A47C3-F846-4729-8A1B-5DF620F'
|
39
|
+
)
|
40
|
+
}
|
38
41
|
|
39
42
|
it {
|
40
|
-
expect(subject.to_h).to eql(
|
41
|
-
'bic'=>
|
42
|
-
'iban'=>
|
43
|
-
'name' =>
|
43
|
+
expect(subject.to_h).to eql(
|
44
|
+
'bic' => 'HYVEDEMMXXX',
|
45
|
+
'iban' => 'HUkkbbbsssskcccccccccccccccx',
|
46
|
+
'name' => 'Peter Pan',
|
44
47
|
'sepa' => {
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
48
|
+
'KREF' => '',
|
49
|
+
'EREF' => 'TRX-0A4A47C3-F846-4729-8A1B-5DF620F',
|
50
|
+
'MREF' => 'CAC97D2144174318AC18D9BF815BD4FB',
|
51
|
+
'CRED' => 'DE98ZZZ09999999999',
|
52
|
+
'SVWZ' => 'FOO TRX-0A4A47C3-F846-4729-8A1B-5DF620F'
|
50
53
|
},
|
51
|
-
'information' =>
|
52
|
-
'description' =>
|
54
|
+
'information' => 'KREF+EREF+TRX-0A4A47C3-F846-4729-8A1B-5DF620FMREF+CAC97D2144174318AC18D9BF815BD4FBCRED+DE98ZZZ09999999999SVWZ+FOO TRX-0A4A47C3-F846-4729-8A1B-5DF620F',
|
55
|
+
'description' => 'SEPA LASTSCHRIFT KUNDE',
|
53
56
|
'sub_fields' => {
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
57
|
+
'00' => 'SEPA LASTSCHRIFT KUNDE',
|
58
|
+
'10' => '281',
|
59
|
+
'20' => 'KREF+EREF+TRX-0A4A47C3-F846-4729',
|
60
|
+
'21' => '-8A1B-5DF620F',
|
61
|
+
'22' => 'MREF+CAC97D2144174318AC18D9',
|
62
|
+
'23' => 'BF815BD4FB',
|
63
|
+
'24' => 'CRED+DE98ZZZ09999999999',
|
64
|
+
'25' => 'SVWZ+FOO TRX-0A4A47C3-F84',
|
65
|
+
'26' => '6-4729-8A1B-5DF620F',
|
66
|
+
'30' => 'HYVEDEMMXXX',
|
67
|
+
'31' => 'HUkkbbbsssskcccccccccccccccx',
|
68
|
+
'32' => 'Peter Pan',
|
69
|
+
'34' => '171',
|
70
|
+
'99' => ''
|
68
71
|
},
|
69
|
-
'transaction_code' =>
|
70
|
-
'details' =>
|
72
|
+
'transaction_code' => '171',
|
73
|
+
'details' => '?00SEPA LASTSCHRIFT KUNDE?10281?20KREF+EREF+TRX-0A4A47C3-F846-4729?21-8A1B-5DF620F?22MREF+CAC97D2144174318AC18D9?23BF815BD4FB?24CRED+DE98ZZZ09999999999?25SVWZ+FOO TRX-0A4A47C3-F84?266-4729-8A1B-5DF620F?30HYVEDEMMXXX?31HUkkbbbsssskcccccccccccccccx?32Peter Pan?99?34171'
|
71
74
|
)
|
72
75
|
}
|
73
76
|
it { expect(subject.to_hash).to eql(subject.to_h) }
|
@@ -76,9 +79,11 @@ describe Cmxl::Fields::StatementDetails do
|
|
76
79
|
describe 'information parsing with empty fields on the end' do
|
77
80
|
subject { Cmxl::Fields::StatementDetails.parse(fixture_line(:statement_details_empty_fields)) }
|
78
81
|
|
79
|
-
it {
|
80
|
-
|
81
|
-
|
82
|
-
|
82
|
+
it {
|
83
|
+
expect(subject.sepa).to eql(
|
84
|
+
'EREF' => 'S1001675',
|
85
|
+
'SVWZ' => ''
|
86
|
+
)
|
87
|
+
}
|
83
88
|
end
|
84
89
|
end
|
@@ -1,10 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Cmxl::Fields::StatementNumber do
|
4
|
-
|
5
4
|
subject { Cmxl::Fields::StatementNumber.parse(fixture_line(:statement_number)) }
|
6
5
|
|
7
6
|
it { expect(subject.statement_number).to eql('00035') }
|
8
7
|
it { expect(subject.sequence_number).to eql('001') }
|
9
|
-
|
10
8
|
end
|
@@ -11,8 +11,8 @@ describe Cmxl::Fields::Transaction do
|
|
11
11
|
let(:fixture) { fixture_line(:statement_line).split(/\n/) }
|
12
12
|
|
13
13
|
context 'debit' do
|
14
|
-
it { expect(debit_transaction.date).to eql(Date.new(2014,9,1)) }
|
15
|
-
it { expect(debit_transaction.entry_date).to eql(Date.new(2014,9,2)) }
|
14
|
+
it { expect(debit_transaction.date).to eql(Date.new(2014, 9, 1)) }
|
15
|
+
it { expect(debit_transaction.entry_date).to eql(Date.new(2014, 9, 2)) }
|
16
16
|
it { expect(debit_transaction.funds_code).to eql('D') }
|
17
17
|
it { expect(debit_transaction.currency_letter).to eql('R') }
|
18
18
|
it { expect(debit_transaction.amount).to eql(1.62) }
|
@@ -27,8 +27,8 @@ describe Cmxl::Fields::Transaction do
|
|
27
27
|
end
|
28
28
|
|
29
29
|
context 'storno credit' do
|
30
|
-
it { expect(storno_credit_transaction.date).to eql(Date.new(2014,9,1)) }
|
31
|
-
it { expect(storno_credit_transaction.entry_date).to eql(Date.new(2014,9,2)) }
|
30
|
+
it { expect(storno_credit_transaction.date).to eql(Date.new(2014, 9, 1)) }
|
31
|
+
it { expect(storno_credit_transaction.entry_date).to eql(Date.new(2014, 9, 2)) }
|
32
32
|
it { expect(storno_credit_transaction.funds_code).to eql('RC') }
|
33
33
|
it { expect(storno_credit_transaction.currency_letter).to eql('R') }
|
34
34
|
it { expect(storno_credit_transaction.amount).to eql(1.62) }
|
@@ -7,18 +7,18 @@ describe Cmxl::Fields::TransactionSupplementary do
|
|
7
7
|
it { expect(supplementary.initial_amount_in_cents).to eql(4711) }
|
8
8
|
it { expect(supplementary.initial_currency).to eql('CAD') }
|
9
9
|
|
10
|
-
it { expect(supplementary.charges_in_cents).to eql(
|
10
|
+
it { expect(supplementary.charges_in_cents).to eql(12_345) }
|
11
11
|
it { expect(supplementary.charges_currency).to eql('EUR') }
|
12
12
|
|
13
13
|
describe '.to_h' do
|
14
14
|
it 'returns expected hash' do
|
15
|
-
expect(supplementary.to_h).to eql(
|
15
|
+
expect(supplementary.to_h).to eql(
|
16
16
|
source: 'Card Transaction/OCMT/CAD47,11/CHGS/EUR123,45',
|
17
17
|
initial_amount_in_cents: 4711,
|
18
18
|
initial_currency: 'CAD',
|
19
|
-
charges_in_cents:
|
19
|
+
charges_in_cents: 12_345,
|
20
20
|
charges_currency: 'EUR'
|
21
|
-
|
21
|
+
)
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
data/spec/fields/unknown_spec.rb
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'Unknwn fields' do
|
4
|
-
|
5
4
|
subject { Cmxl::Field.parse(':42F:C140908EUR000000000136,02') }
|
6
5
|
it { expect(subject.tag).to eql('42') }
|
7
6
|
it { expect(subject.source).to eql('C140908EUR000000000136,02') }
|
8
|
-
it { expect(subject.to_h).to eql(
|
7
|
+
it { expect(subject.to_h).to eql(tag: '42', modifier: 'F', source: 'C140908EUR000000000136,02') }
|
9
8
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Cmxl::Fields::VmkSummary do
|
4
|
+
context 'credit' do
|
5
|
+
subject { Cmxl::Fields::VmkSummary.parse(fixture_line(:vmk_summary_credit)) }
|
6
|
+
|
7
|
+
it { expect(subject.amount).to eql(47.11) }
|
8
|
+
it { expect(subject.entries).to eql(2) }
|
9
|
+
it { expect(subject.currency).to eql('EUR') }
|
10
|
+
it { expect(subject.credit?).to be_truthy }
|
11
|
+
it { expect(subject.debit?).to be_falsey }
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'debit' do
|
15
|
+
subject { Cmxl::Fields::VmkSummary.parse(fixture_line(:vmk_summary_debit)) }
|
16
|
+
|
17
|
+
it { expect(subject.amount).to eql(13.37) }
|
18
|
+
it { expect(subject.entries).to eql(3) }
|
19
|
+
it { expect(subject.currency).to eql('EUR') }
|
20
|
+
it { expect(subject.credit?).to be_falsey }
|
21
|
+
it { expect(subject.debit?).to be_truthy }
|
22
|
+
end
|
23
|
+
end
|