camt 0.0.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,141 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Document xmlns="urn:iso:std:iso:20022:tech:xsd:camt.053.001.02" xmlns:xs="http://www.w3.org/2001/XMLSchema"
3
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
4
+ <BkToCstmrStmt>
5
+ <GrpHdr>
6
+ <MsgId>KOBE111130009991</MsgId>
7
+ <CreDtTm>2011-11-30T14:09:00.00Z</CreDtTm>
8
+ <MsgPgntn>
9
+ <PgNb>1</PgNb>
10
+ <LastPgInd>true</LastPgInd>
11
+ </MsgPgntn>
12
+ </GrpHdr>
13
+ <Stmt>
14
+ <Id>KOBE111130009991</Id>
15
+ <ElctrncSeqNb>1</ElctrncSeqNb>
16
+ <CreDtTm>2011-11-30T14:09:00.00Z</CreDtTm>
17
+ <Acct>
18
+ <Id>
19
+ <IBAN>CH8809000000505005006</IBAN>
20
+ </Id>
21
+ </Acct>
22
+ <Bal>
23
+ <Tp>
24
+ <CdOrPrtry>
25
+ <Cd>OPBD</Cd>
26
+ </CdOrPrtry>
27
+ </Tp>
28
+ <Amt Ccy="CHF">191.99</Amt>
29
+ <CdtDbtInd>CRDT</CdtDbtInd>
30
+ <Dt>
31
+ <Dt>2011-11-29</Dt>
32
+ </Dt>
33
+ </Bal>
34
+ <Bal>
35
+ <Tp>
36
+ <CdOrPrtry>
37
+ <Cd>CLBD</Cd>
38
+ </CdOrPrtry>
39
+ </Tp>
40
+ <Amt Ccy="CHF">190.99</Amt>
41
+ <CdtDbtInd>CRDT</CdtDbtInd>
42
+ <Dt>
43
+ <Dt>2011-11-30</Dt>
44
+ </Dt>
45
+ </Bal>
46
+ <Ntry>
47
+ <Amt Ccy="CHF">3.50</Amt>
48
+ <CdtDbtInd>CRDT</CdtDbtInd>
49
+ <Sts>BOOK</Sts>
50
+ <BookgDt>
51
+ <Dt>2011-11-30</Dt>
52
+ </BookgDt>
53
+ <ValDt>
54
+ <Dt>2011-11-30</Dt>
55
+ </ValDt>
56
+ <AcctSvcrRef>20111129001032001038264000000111</AcctSvcrRef>
57
+ <BkTxCd>
58
+ <Domn>
59
+ <Cd>PMNT</Cd>
60
+ <Fmly>
61
+ <Cd>RCDT</Cd>
62
+ <SubFmlyCd>VCOM</SubFmlyCd>
63
+ </Fmly>
64
+ </Domn>
65
+ </BkTxCd>
66
+ <NtryDtls>
67
+ <TxDtls>
68
+ <Refs>
69
+ <AcctSvcrRef>20111129001032001038264000000111</AcctSvcrRef>
70
+ </Refs>
71
+ <AmtDtls>
72
+ <InstdAmt>
73
+ <Amt Ccy="CHF">3.50</Amt>
74
+ </InstdAmt>
75
+ </AmtDtls>
76
+ <BkTxCd>
77
+ <Domn>
78
+ <Cd>PMNT</Cd>
79
+ <Fmly>
80
+ <Cd>RCDT</Cd>
81
+ <SubFmlyCd>VCOM</SubFmlyCd>
82
+ </Fmly>
83
+ </Domn>
84
+ </BkTxCd>
85
+ </TxDtls>
86
+ </NtryDtls>
87
+ <AddtlNtryInf>ORANGE EINZAHLUNGSSCHEINE VERARBEITUNG 29.11.2011 KUNDENNUMMER 01-38264-3</AddtlNtryInf>
88
+ </Ntry>
89
+ <Ntry>
90
+ <Amt Ccy="CHF">4.50</Amt>
91
+ <CdtDbtInd>DBIT</CdtDbtInd>
92
+ <Sts>BOOK</Sts>
93
+ <BookgDt>
94
+ <Dt>2011-11-30</Dt>
95
+ </BookgDt>
96
+ <ValDt>
97
+ <Dt>2011-11-30</Dt>
98
+ </ValDt>
99
+ <AcctSvcrRef>20111130001020001762625000000103</AcctSvcrRef>
100
+ <BkTxCd>
101
+ <Domn>
102
+ <Cd>PMNT</Cd>
103
+ <Fmly>
104
+ <Cd>ICDT</Cd>
105
+ <SubFmlyCd>AUTT</SubFmlyCd>
106
+ </Fmly>
107
+ </Domn>
108
+ </BkTxCd>
109
+ <NtryDtls>
110
+ <TxDtls>
111
+ <Refs>
112
+ <AcctSvcrRef>20111130001020001762625000000103</AcctSvcrRef>
113
+ </Refs>
114
+ <AmtDtls>
115
+ <InstdAmt>
116
+ <Amt Ccy="CHF">4.50</Amt>
117
+ </InstdAmt>
118
+ </AmtDtls>
119
+ <BkTxCd>
120
+ <Domn>
121
+ <Cd>PMNT</Cd>
122
+ <Fmly>
123
+ <Cd>ICDT</Cd>
124
+ <SubFmlyCd>AUTT</SubFmlyCd>
125
+ </Fmly>
126
+ </Domn>
127
+ </BkTxCd>
128
+ <RmtInf>
129
+ <Strd>
130
+ <CdtrRefInf>
131
+ <Ref>123457</Ref>
132
+ </CdtrRefInf>
133
+ </Strd>
134
+ </RmtInf>
135
+ </TxDtls>
136
+ </NtryDtls>
137
+ <AddtlNtryInf>E-FINANCE 01-38264-3 TESTLABOR ONLINE/OFFLINE PRODUCT-MANAGEMENT II</AddtlNtryInf>
138
+ </Ntry>
139
+ </Stmt>
140
+ </BkToCstmrStmt>
141
+ </Document>
@@ -0,0 +1,144 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Document xsi:schemaLocation="urn:iso:std:iso:20022:tech:xsd:camt.053.001.02 camt.053.001.02.xsd" xmlns="urn:iso:std:iso:20022:tech:xsd:camt.053.001.02" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
3
+ <BkToCstmrStmt>
4
+ <GrpHdr>
5
+ <MsgId>MSGID-C053.01.00.10-110725163809-01</MsgId>
6
+ <CreDtTm>2011-07-25T09:30:47Z</CreDtTm>
7
+ <MsgPgntn>
8
+ <PgNb>1</PgNb>
9
+ <LastPgInd>true</LastPgInd>
10
+ </MsgPgntn>
11
+ </GrpHdr>
12
+ <Stmt>
13
+ <Id>STMID-C053.01.00.10-110725163809-01</Id>
14
+ <ElctrncSeqNb>147</ElctrncSeqNb>
15
+ <CreDtTm>2011-07-25T09:30:47Z</CreDtTm>
16
+ <Acct>
17
+ <Id>
18
+ <IBAN>CH9581320000001998736</IBAN>
19
+ </Id>
20
+ </Acct>
21
+ <Bal>
22
+ <Tp>
23
+ <CdOrPrtry>
24
+ <Cd>OPBD</Cd>
25
+ </CdOrPrtry>
26
+ </Tp>
27
+ <Amt Ccy="CHF">2501.50</Amt>
28
+ <CdtDbtInd>CRDT</CdtDbtInd>
29
+ <Dt>
30
+ <Dt>2011-07-22</Dt>
31
+ </Dt>
32
+ </Bal>
33
+ <Bal>
34
+ <Tp>
35
+ <CdOrPrtry>
36
+ <Cd>CLAV</Cd>
37
+ </CdOrPrtry>
38
+ </Tp>
39
+ <Amt Ccy="CHF">2397.2</Amt>
40
+ <CdtDbtInd>CRDT</CdtDbtInd>
41
+ <Dt>
42
+ <Dt>2011-07-25</Dt>
43
+ </Dt>
44
+ </Bal>
45
+ <Ntry>
46
+ <Amt Ccy="CHF">145.70</Amt>
47
+ <CdtDbtInd>CRDT</CdtDbtInd>
48
+ <Sts>BOOK</Sts>
49
+ <BookgDt>
50
+ <Dt>2011-07-25</Dt>
51
+ </BookgDt>
52
+ <ValDt>
53
+ <Dt>2011-07-25 </Dt>
54
+ </ValDt>
55
+ <BkTxCd>
56
+ <Domn>
57
+ <Cd>PMNT</Cd>
58
+ <Fmly>
59
+ <Cd>RCDT</Cd>
60
+ <SubFmlyCd>VCOM</SubFmlyCd>
61
+ </Fmly>
62
+ </Domn>
63
+ </BkTxCd>
64
+ <NtryDtls>
65
+ <TxDtls>
66
+ <Refs>
67
+ <EndToEndId>E2EID-P001.01.00.01-110718163809-01</EndToEndId>
68
+ </Refs>
69
+ <AmtDtls>
70
+ <InstdAmt>
71
+ <Amt Ccy="CHF">100.00</Amt>
72
+ </InstdAmt>
73
+ </AmtDtls>
74
+ <RmtInf>
75
+ <Strd>
76
+ <CdtrRefInf>
77
+ <Ref>123456789012345678901234567</Ref>
78
+ </CdtrRefInf>
79
+ </Strd>
80
+ </RmtInf>
81
+ </TxDtls>
82
+ <TxDtls>
83
+ <Refs>
84
+ <EndToEndId>E2EID-P001.01.00.01-110718163809-02</EndToEndId>
85
+ </Refs>
86
+ <AmtDtls>
87
+ <InstdAmt>
88
+ <Amt Ccy="CHF">45.70</Amt>
89
+ </InstdAmt>
90
+ </AmtDtls>
91
+ <RmtInf>
92
+ <Strd>
93
+ <CdtrRefInf>
94
+ <Ref>210000000003139471430009017</Ref>
95
+ </CdtrRefInf>
96
+ </Strd>
97
+ </RmtInf>
98
+ </TxDtls>
99
+ </NtryDtls>
100
+ </Ntry>
101
+ <Ntry>
102
+ <Amt Ccy="CHF">250.00</Amt>
103
+ <CdtDbtInd>DBIT</CdtDbtInd>
104
+ <Sts>BOOK</Sts>
105
+ <BookgDt>
106
+ <Dt>2011-07-25</Dt>
107
+ </BookgDt>
108
+ <ValDt>
109
+ <Dt>2011-07-24</Dt>
110
+ </ValDt>
111
+ <BkTxCd>
112
+ <Domn>
113
+ <Cd>PMNT</Cd>
114
+ <Fmly>
115
+ <Cd>CCRD</Cd>
116
+ <SubFmlyCd>CWDL</SubFmlyCd>
117
+ </Fmly>
118
+ </Domn>
119
+ </BkTxCd>
120
+ <NtryDtls>
121
+ <TxDtls>
122
+ <Refs>
123
+ <EndToEndId>E2EID-P001.01.00.02-110718163809-01</EndToEndId>
124
+ </Refs>
125
+ <AmtDtls>
126
+ <InstdAmt>
127
+ <Amt Ccy="CHF">250.00</Amt>
128
+ </InstdAmt>
129
+ </AmtDtls>
130
+ <BkTxCd>
131
+ <Domn>
132
+ <Cd>PMNT</Cd>
133
+ <Fmly>
134
+ <Cd>CCRD</Cd>
135
+ <SubFmlyCd>CWDL</SubFmlyCd>
136
+ </Fmly>
137
+ </Domn>
138
+ </BkTxCd>
139
+ </TxDtls>
140
+ </NtryDtls>
141
+ </Ntry>
142
+ </Stmt>
143
+ </BkToCstmrStmt>
144
+ </Document>
@@ -0,0 +1,73 @@
1
+ require "camt"
2
+
3
+ RSpec.configure do |config|
4
+
5
+ config.expect_with :rspec do |expectations|
6
+ # This option will default to `true` in RSpec 4. It makes the `description`
7
+ # and `failure_message` of custom matchers include text for helper methods
8
+ # defined using `chain`, e.g.:
9
+ # be_bigger_than(2).and_smaller_than(4).description
10
+ # # => "be bigger than 2 and smaller than 4"
11
+ # ...rather than:
12
+ # # => "be bigger than 2"
13
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
14
+ end
15
+
16
+ # rspec-mocks config goes here. You can use an alternate test double
17
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
18
+ config.mock_with :rspec do |mocks|
19
+ # Prevents you from mocking or stubbing a method that does not exist on
20
+ # a real object. This is generally recommended, and will default to
21
+ # `true` in RSpec 4.
22
+ mocks.verify_partial_doubles = true
23
+ end
24
+
25
+ # These two settings work together to allow you to limit a spec run
26
+ # to individual examples or groups you care about by tagging them with
27
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
28
+ # get run.
29
+ config.filter_run :focus
30
+ config.run_all_when_everything_filtered = true
31
+
32
+ # Limits the available syntax to the non-monkey patched syntax that is recommended.
33
+ # For more details, see:
34
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
35
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
36
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
37
+ config.disable_monkey_patching!
38
+
39
+ # This setting enables warnings. It's recommended, but in some cases may
40
+ # be too noisy due to issues in dependencies.
41
+ config.warnings = true
42
+
43
+ # Many RSpec users commonly either run the entire suite or an individual
44
+ # file, and it's useful to allow more verbose output when running an
45
+ # individual spec file.
46
+ if config.files_to_run.one?
47
+ # Use the documentation formatter for detailed output,
48
+ # unless a formatter has already been configured
49
+ # (e.g. via a command-line flag).
50
+ config.default_formatter = 'doc'
51
+ end
52
+
53
+ # Print the 10 slowest examples and example groups at the
54
+ # end of the spec run, to help surface which specs are running
55
+ # particularly slow.
56
+ config.profile_examples = 10
57
+
58
+ # Run specs in random order to surface order dependencies. If you find an
59
+ # order dependency and want to debug it, you can fix the order by providing
60
+ # the seed, which is printed after each run.
61
+ # --seed 1234
62
+ config.order = :random
63
+
64
+ # Seed global randomization in this process using the `--seed` CLI option.
65
+ # Setting this allows you to use `--seed` to deterministically reproduce
66
+ # test failures related to randomization by passing the same `--seed` value
67
+ # as the one that triggered the failure.
68
+ Kernel.srand config.seed
69
+ end
70
+
71
+ Camt.configure do |config|
72
+ config.default_country_code = "XY"
73
+ end
@@ -0,0 +1,82 @@
1
+ RSpec.describe Camt::Statement do
2
+
3
+ let(:filename) { "camt.xml" }
4
+ let(:file) { Camt::File.parse(::File.expand_path("../sample_files/" << filename, __FILE__)) }
5
+ let(:doc) { file.doc.tap { |doc| doc.remove_namespaces! } }
6
+ let(:node) { doc.xpath('//BkToCstmrStmt/Stmt').first }
7
+ let(:country_code) { "NL" }
8
+
9
+ subject { described_class.new(node, country_code) }
10
+
11
+ describe "#id" do
12
+ let(:expected) { "0574908765.2013-04-02" }
13
+
14
+ it "has the value from the parsed file" do
15
+ expect(subject.id).to eq expected
16
+ end
17
+ end
18
+
19
+ describe "#electronic_sequence_number" do
20
+ let(:expected) { "0070" }
21
+
22
+ it "has the value from the parsed file" do
23
+ expect(subject.electronic_sequence_number).to eq expected
24
+ end
25
+ end
26
+
27
+ describe "#created_at" do
28
+ let(:expected) { Time.parse("2013-04-12T10:55:08.66+02:00") }
29
+
30
+ it "has the value from the parsed file" do
31
+ expect(subject.created_at).to eq expected
32
+ end
33
+ end
34
+
35
+ describe "#local_account" do
36
+ let(:expected) { "NL77ABNA0574908765" }
37
+
38
+ it "has the value from the parsed file" do
39
+ expect(subject.local_account).to eq expected
40
+ end
41
+ end
42
+
43
+ describe "#local_currency" do
44
+ let(:expected) { "EUR" }
45
+
46
+ it "has the value from the parsed file" do
47
+ expect(subject.local_currency).to eq expected
48
+ end
49
+ end
50
+
51
+ describe "#date" do
52
+ let(:expected) { Date.parse("2013-04-02") }
53
+
54
+ it "has the value from the parsed file" do
55
+ expect(subject.date).to eq expected
56
+ end
57
+ end
58
+
59
+ describe "#start_balance" do
60
+ let(:expected) { 1000.01 }
61
+
62
+ it "has the value from the parsed file" do
63
+ expect(subject.start_balance).to eq expected
64
+ end
65
+ end
66
+
67
+ describe "#end_balance" do
68
+ let(:expected) { 100.01 }
69
+
70
+ it "has the value from the parsed file" do
71
+ expect(subject.end_balance).to eq expected
72
+ end
73
+ end
74
+
75
+ describe "#transactions" do
76
+ let(:expected_count) { 13 }
77
+
78
+ it "has the value from the parsed file" do
79
+ expect(subject.transactions.count).to eq expected_count
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,57 @@
1
+ RSpec.shared_examples_for "any CAMT.053 file" do
2
+
3
+ let :filename do |example|
4
+ example.metadata[:example_group][:parent_example_group][:description]
5
+ end
6
+
7
+ let(:file) { Camt::File.parse(::File.expand_path("../../sample_files/" << filename, __FILE__)) }
8
+ let(:statement) { file.statements.first }
9
+
10
+ it "has the correct Id" do
11
+ expect(statement.id).to eq expected_id
12
+ end
13
+
14
+ it "has the correct electronic sequence number" do
15
+ expect(statement.electronic_sequence_number).to eq expected_electronic_sequence_number
16
+ end
17
+
18
+ it "has the correct creation time" do
19
+ expect(statement.created_at).to eq Time.parse(expected_creation_time)
20
+ end
21
+
22
+ it "has the correct IBAN" do
23
+ expect(statement.iban).to eq expected_iban
24
+ end
25
+
26
+ it "has the correct currency" do
27
+ expect(statement.local_currency).to eq expected_currency
28
+ end
29
+
30
+ it "has the correct date" do
31
+ expect(statement.date).to eq Date.parse(expected_date)
32
+ end
33
+
34
+ it "has the correct start balance" do
35
+ expect(statement.start_balance).to eq expected_start_balance
36
+ end
37
+
38
+ it "has the correct end balance" do
39
+ expect(statement.end_balance).to eq expected_end_balance
40
+ end
41
+
42
+ it "has the correct number of transactions" do
43
+ expect(statement.transactions.size).to eq expected_transactions.size
44
+ end
45
+
46
+ it "has the correct transaction data" do
47
+ expected_transactions.each_with_index do |expected, index|
48
+ transaction = statement.transactions[index]
49
+ expect(transaction.execution_date).to eq Date.parse(expected[:ex_date])
50
+ expect(transaction.effective_date).to eq Date.parse(expected[:eff_date])
51
+ expect(transaction.type).to eq expected[:type]
52
+ expect(transaction.amount).to eq expected[:amount]
53
+ expect(transaction.details).to eq expected[:details]
54
+ expect(transaction.purpose).to eq expected[:purpose]
55
+ end
56
+ end
57
+ end