bankserv 0.1.3

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 (75) hide show
  1. data/.gitignore +6 -0
  2. data/.rvmrc +1 -0
  3. data/Gemfile +16 -0
  4. data/Rakefile +8 -0
  5. data/bankserv.gemspec +31 -0
  6. data/config.ru +7 -0
  7. data/lib/bankserv.rb +48 -0
  8. data/lib/bankserv/account_holder_verification.rb +90 -0
  9. data/lib/bankserv/bank_account.rb +19 -0
  10. data/lib/bankserv/configuration.rb +67 -0
  11. data/lib/bankserv/credit.rb +70 -0
  12. data/lib/bankserv/debit.rb +94 -0
  13. data/lib/bankserv/eft.rb +83 -0
  14. data/lib/bankserv/engine.rb +183 -0
  15. data/lib/bankserv/engine/engine_configuration.rb +12 -0
  16. data/lib/bankserv/engine/engine_process.rb +3 -0
  17. data/lib/bankserv/request.rb +27 -0
  18. data/lib/bankserv/transaction.rb +22 -0
  19. data/lib/bankserv/transmission/document.rb +43 -0
  20. data/lib/bankserv/transmission/input_document.rb +84 -0
  21. data/lib/bankserv/transmission/output_document.rb +27 -0
  22. data/lib/bankserv/transmission/record.rb +13 -0
  23. data/lib/bankserv/transmission/reply_document.rb +27 -0
  24. data/lib/bankserv/transmission/set.rb +120 -0
  25. data/lib/bankserv/transmission/set/account_holder_verification.rb +81 -0
  26. data/lib/bankserv/transmission/set/account_holder_verification_output.rb +17 -0
  27. data/lib/bankserv/transmission/set/credit.rb +44 -0
  28. data/lib/bankserv/transmission/set/debit.rb +44 -0
  29. data/lib/bankserv/transmission/set/document.rb +45 -0
  30. data/lib/bankserv/transmission/set/eft.rb +228 -0
  31. data/lib/bankserv/transmission/set/eft_output.rb +12 -0
  32. data/lib/bankserv/transmission/set/eft_redirect.rb +18 -0
  33. data/lib/bankserv/transmission/set/eft_unpaid.rb +18 -0
  34. data/lib/bankserv/transmission/set/reply.rb +47 -0
  35. data/lib/bankserv/transmission/statement.rb +46 -0
  36. data/lib/bankserv/version.rb +3 -0
  37. data/lib/config/ahv.yml +9 -0
  38. data/lib/core_extensions.rb +37 -0
  39. data/lib/generators/active_record/bankserv_generator.rb +30 -0
  40. data/lib/generators/active_record/templates/migration.rb +141 -0
  41. data/spec/examples/ahv_input_file.txt +7 -0
  42. data/spec/examples/ahv_output_file.txt +7 -0
  43. data/spec/examples/credit_eft_input.txt +166 -0
  44. data/spec/examples/debit_eft_input_file.txt +20 -0
  45. data/spec/examples/eft_input_with_2_sets.txt +8 -0
  46. data/spec/examples/eft_output_file.txt +35 -0
  47. data/spec/examples/host2host/tmp.log +1 -0
  48. data/spec/examples/reply/rejected_transmission.txt +7 -0
  49. data/spec/examples/reply/reply_file.txt +5 -0
  50. data/spec/examples/statement4_unpacked.dat +51 -0
  51. data/spec/examples/tmp/OUTPUT0412153500.txt +35 -0
  52. data/spec/examples/tmp/REPLY0412153000.txt +5 -0
  53. data/spec/factories.rb +90 -0
  54. data/spec/internal/config/database.yml.sample +3 -0
  55. data/spec/internal/config/routes.rb +3 -0
  56. data/spec/internal/db/schema.rb +138 -0
  57. data/spec/internal/log/.gitignore +1 -0
  58. data/spec/internal/public/favicon.ico +0 -0
  59. data/spec/lib/bankserv/account_holder_verification_spec.rb +104 -0
  60. data/spec/lib/bankserv/configuration_spec.rb +34 -0
  61. data/spec/lib/bankserv/core_ext_spec.rb +43 -0
  62. data/spec/lib/bankserv/credit_spec.rb +92 -0
  63. data/spec/lib/bankserv/debit_spec.rb +187 -0
  64. data/spec/lib/bankserv/engine/engine_spec.rb +142 -0
  65. data/spec/lib/bankserv/transaction_spec.rb +32 -0
  66. data/spec/lib/bankserv/transmission/input_document_spec.rb +207 -0
  67. data/spec/lib/bankserv/transmission/output_document_spec.rb +210 -0
  68. data/spec/lib/bankserv/transmission/reply_document_spec.rb +117 -0
  69. data/spec/lib/bankserv/transmission/set/account_holder_verification_spec.rb +108 -0
  70. data/spec/lib/bankserv/transmission/set/credit_spec.rb +96 -0
  71. data/spec/lib/bankserv/transmission/set/debit_spec.rb +103 -0
  72. data/spec/lib/bankserv/transmission/statement_spec.rb +109 -0
  73. data/spec/spec_helper.rb +28 -0
  74. data/spec/support/helpers.rb +207 -0
  75. metadata +223 -0
@@ -0,0 +1,117 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bankserv::ReplyDocument do
4
+ include Helpers
5
+
6
+ context "storing a reply transmission" do
7
+
8
+ before(:all) do
9
+ tear_it_down
10
+ create(:configuration)
11
+
12
+ @file_contents = File.open("./spec/examples/reply/reply_file.txt", "rb").read
13
+ @options = Absa::H2h::Transmission::Document.hash_from_s(@file_contents, 'output')
14
+
15
+ @document = Bankserv::OutputDocument.store(@file_contents)
16
+ end
17
+
18
+ it "should mark the document as an output transmission" do
19
+ @document.type.should == "output"
20
+ end
21
+
22
+ it "should store a document, set and records that produce the same data as was provided" do
23
+ @document.to_hash.should == @options
24
+ end
25
+
26
+ it "should produce the exact same file contents when the transmission is rebuilt" do
27
+ absa_document = Absa::H2h::Transmission::Document.build(@document.to_hash[:data])
28
+ absa_document.to_s.should == @file_contents
29
+ end
30
+
31
+ end
32
+
33
+ context "processing a reply transmission" do
34
+
35
+ before(:each) do
36
+ tear_it_down
37
+ create(:configuration)
38
+
39
+ @file_contents = File.open("./spec/examples/eft_input_with_2_sets.txt", "rb").read
40
+ @input_document = Bankserv::InputDocument.store(@file_contents)
41
+
42
+ @file_contents = File.open("./spec/examples/reply/reply_file.txt", "rb").read
43
+ @options = Absa::H2h::Transmission::Document.hash_from_s(@file_contents, 'output')
44
+
45
+ @reply_document = Bankserv::OutputDocument.store(@file_contents)
46
+ end
47
+
48
+ it "should mark the original input document as ACCEPTED if the transmission was accepted" do
49
+ @input_document.reply_status.should be_nil
50
+
51
+ @reply_document.process!
52
+
53
+ @input_document.reload
54
+ @input_document.reply_status.should == "ACCEPTED"
55
+ end
56
+
57
+ it "should mark an EFT user set as ACCEPTED or REJECTED" do
58
+ @reply_document.process!
59
+ @input_document.reload
60
+
61
+ @input_document.set.sets.each do |set|
62
+ set.reply_status.should == "ACCEPTED"
63
+ end
64
+ end
65
+
66
+ end
67
+
68
+ context "processing a reply file reporting that a transmission was rejected" do
69
+
70
+ before(:all) do
71
+ tear_it_down
72
+ create(:configuration)
73
+
74
+ @file_contents = File.open("./spec/examples/eft_input_with_2_sets.txt", "rb").read
75
+ @input_document = Bankserv::InputDocument.store(@file_contents)
76
+
77
+ @file_contents = File.open("./spec/examples/reply/rejected_transmission.txt", "rb").read
78
+ @options = Absa::H2h::Transmission::Document.hash_from_s(@file_contents, 'output')
79
+
80
+ @reply_document = Bankserv::ReplyDocument.store(@file_contents)
81
+
82
+ @reply_document.process!
83
+ @input_document.reload
84
+ end
85
+
86
+ context "processing a transmission status record" do
87
+ it "should mark the document's reply status as REJECTED" do
88
+ @input_document.reply_status.should == "REJECTED"
89
+ end
90
+ end
91
+
92
+ context "processing a transmission rejected reason record" do
93
+ it "should record the transmission rejection error code" do
94
+ @input_document.error[:code].should == "12345"
95
+ end
96
+
97
+ it "should record the transmission rejection error message" do
98
+ @input_document.error[:message].should == "HI THIS IS ERROR"
99
+ end
100
+ end
101
+
102
+ context "processing a rejected message record" do
103
+ it "should update the related record with error information" do
104
+ record = @input_document.set.sets.last.transactions.first
105
+ record.error[:code].should == "12345"
106
+ record.error[:message].should == "HI THIS IS REJECTED MESSAGE"
107
+ end
108
+ end
109
+
110
+ context "processing an accepted report reply record" do
111
+ pending
112
+ end
113
+
114
+ end
115
+
116
+
117
+ end
@@ -0,0 +1,108 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bankserv::Transmission::UserSet::AccountHolderVerification do
4
+ include Helpers
5
+
6
+ before(:all) do
7
+ tear_it_down
8
+ create(:configuration)
9
+
10
+ @ahv_list = [
11
+ Bankserv::AccountHolderVerification.test_request(type: 'ahv', data: attributes_for(:internal_ahv).merge(bank_account: attributes_for(:internal_bank_account))),
12
+ Bankserv::AccountHolderVerification.test_request(type: 'ahv', data: attributes_for(:internal_ahv).merge(bank_account: attributes_for(:internal_bank_account))),
13
+ Bankserv::AccountHolderVerification.test_request(type: 'ahv', data: attributes_for(:ahv).merge(bank_account: attributes_for(:external_bank_account))),
14
+ Bankserv::AccountHolderVerification.test_request(type: 'ahv', data: attributes_for(:ahv).merge(bank_account: attributes_for(:external_bank_account))),
15
+ Bankserv::AccountHolderVerification.test_request(type: 'ahv', data: attributes_for(:ahv).merge(bank_account: attributes_for(:external_bank_account))),
16
+ ]
17
+
18
+ @ahv_list = Bankserv::AccountHolderVerification.all
19
+ end
20
+
21
+ it "should report when there are account holder verification requests that need to be processed" do
22
+ Bankserv::Transmission::UserSet::AccountHolderVerification.has_test_work?.should be_true
23
+ end
24
+
25
+ it "should place internal and external account holder verifications into separate user sets" do
26
+ sets = Bankserv::Transmission::UserSet::AccountHolderVerification.generate(rec_status: "T")
27
+
28
+ sets.count.should == 2
29
+ sets.first.transactions.count.should == 2
30
+ sets.last.transactions.count.should == 3
31
+ end
32
+
33
+ context "Building an account holder verification set" do
34
+
35
+ before(:each) do
36
+ tear_it_down
37
+ create(:configuration)
38
+
39
+ @ahv_list = [
40
+ Bankserv::AccountHolderVerification.test_request(type: 'ahv', data: attributes_for(:internal_ahv).merge(bank_account: attributes_for(:internal_bank_account))),
41
+ Bankserv::AccountHolderVerification.test_request(type: 'ahv', data: attributes_for(:internal_ahv).merge(bank_account: attributes_for(:internal_bank_account))),
42
+ Bankserv::AccountHolderVerification.test_request(type: 'ahv', data: attributes_for(:internal_ahv).merge(bank_account: attributes_for(:internal_bank_account))),
43
+ Bankserv::AccountHolderVerification.test_request(type: 'ahv', data: attributes_for(:internal_ahv).merge(bank_account: attributes_for(:internal_bank_account))),
44
+ ]
45
+
46
+ @ahv_list = Bankserv::AccountHolderVerification.all
47
+ end
48
+
49
+ context "creating a header" do
50
+
51
+ before(:each) do
52
+ @set = Bankserv::Transmission::UserSet::AccountHolderVerification.generate(rec_status: "T").first
53
+ @set.save
54
+ end
55
+
56
+ it "should store the record id 030" do
57
+ @set.header.data[:rec_id].should == "030"
58
+ end
59
+
60
+ it "should store the record status" do
61
+ @set.header.data[:rec_status].should == "T"
62
+ end
63
+
64
+ it "should store the generation number" do
65
+ @set.header.data.has_key?(:gen_no).should be_true
66
+ end
67
+
68
+ it "should store the specified department code" do
69
+ @set.header.data.has_key?(:dept_code).should be_true
70
+ end
71
+ end
72
+
73
+ context "creating a trailer" do
74
+
75
+ before(:each) do
76
+ @set = Bankserv::Transmission::UserSet::AccountHolderVerification.generate(rec_status: "T").first
77
+ @set.save
78
+ end
79
+
80
+ it "should store the record id 039" do
81
+ @set.trailer.data[:rec_id].should == "039"
82
+ end
83
+
84
+ it "should store the record status" do
85
+ @set.trailer.data[:rec_status].should == "T"
86
+ end
87
+
88
+ it "should store the number of records in the set" do
89
+ @set.trailer.data[:no_det_recs].should == "4"
90
+ end
91
+
92
+ it "should store the sum of the transaction account numbers" do
93
+ sum = 0
94
+ @ahv_list.each{|ahv| sum += ahv.bank_account.account_number.to_i}
95
+
96
+ @set.trailer.data[:acc_total].should == sum.to_s
97
+ end
98
+ end
99
+
100
+ it "should create a batch of transactions when the job begins" do
101
+ batch = Bankserv::Transmission::UserSet::AccountHolderVerification.generate(rec_status: "T").first
102
+ batch.save
103
+ batch.transactions.first.record_type.should == "internal_account_detail"
104
+ end
105
+
106
+ end
107
+
108
+ end
@@ -0,0 +1,96 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bankserv::Transmission::UserSet::Credit do
4
+ include Helpers
5
+
6
+ context "Building a credit batch" do
7
+
8
+ before(:all) do
9
+ tear_it_down
10
+
11
+ create(:configuration, client_code: "10", client_name: "LDC USER 10 AFRICA (PTY)", user_code: "9534", user_generation_number: 37, client_abbreviated_name: "ALIMITTST")
12
+
13
+ @data = [{
14
+ debit: {
15
+ account_number: "907654321", branch_code: "632005", account_type: 'savings', id_number: '8207205263083', initials: "RC", account_name: "Rawson Milnerton", amount: 10000.00, user_ref: 234, action_date: Date.today },
16
+ credit: [
17
+ { account_number: "13123123123", branch_code: "123123", account_type: "savings", id_number: "198273981723", initials: "WC", account_name: "Tenant", amount: 5000.00, action_date: Date.today, user_ref: "235"},
18
+ { account_number: "45645645645", branch_code: "123123", account_type: "savings", id_number: "198273922723", initials: "WX", account_name: "Tefant", amount: 2500.00, action_date: Date.today, user_ref: "236"},
19
+ { account_number: "78978978978", branch_code: "789789", account_type: "savings", id_number: "197873933723", initials: "WB", account_name: "Tebant", amount: 2500.00, action_date: Date.today, user_ref: "237"}
20
+ ]
21
+ }, {
22
+ debit: {
23
+ account_number: "907654322", branch_code: "632005", account_type: 'savings', id_number: '8207205263083', initials: "RC", account_name: "Rawson Milnerton", amount: 15000.00, user_ref: 300, action_date: Date.today },
24
+ credit: [
25
+ { account_number: "13123123122", branch_code: "123123", account_type: "savings", id_number: "198273981723", initials: "WC", account_name: "Tenant", amount: 5000.00, action_date: Date.today, user_ref: "301"},
26
+ { account_number: "45645645642", branch_code: "123123", account_type: "savings", id_number: "198273922723", initials: "WX", account_name: "Tefant", amount: 2500.00, action_date: Date.today, user_ref: "302"},
27
+ { account_number: "78978978972", branch_code: "789789", account_type: "savings", id_number: "197873933723", initials: "WB", account_name: "Tebant", amount: 7500.00, action_date: Date.today, user_ref: "303"}
28
+ ]
29
+ }]
30
+
31
+ @hash = {
32
+ type: 'credit',
33
+ data: { type_of_service: "SAMEDAY", batches: @data }
34
+ }
35
+
36
+ Bankserv::Credit.test_request(@hash)
37
+ end
38
+
39
+ it "should return true when a batch needs to be processed" do
40
+ Bankserv::Transmission::UserSet::Credit.has_test_work?.should be_true
41
+ end
42
+
43
+ it "should create a batch with a header when the job begins" do
44
+ batch = Bankserv::Transmission::UserSet::Credit.generate(rec_status: "T")
45
+ batch.save
46
+
47
+ purge = (Date.today + 7.days).strftime("%y%m%d")
48
+
49
+ batch.header.data.should == {
50
+ rec_id: "020",
51
+ rec_status: "T",
52
+ bankserv_record_identifier: "04",
53
+ bankserv_user_code: "9534",
54
+ bankserv_creation_date: Time.now.strftime("%y%m%d"),
55
+ bankserv_purge_date: purge,
56
+ first_action_date: Time.now.strftime("%y%m%d"),
57
+ last_action_date: (Date.today + 3.days).strftime("%y%m%d"),
58
+ first_sequence_number: "1",
59
+ user_generation_number: "37",
60
+ type_of_service: "SAMEDAY",
61
+ accepted_report: "",
62
+ account_type_correct: ""
63
+ }
64
+ end
65
+
66
+ it "should create a 2 batches of debit transactions when the job begins" do
67
+ batch = Bankserv::Transmission::UserSet::Credit.generate(rec_status: "T")
68
+ batch.save
69
+
70
+ batch.contra_records.size.should == 2
71
+ end
72
+
73
+ it "should create a batch with a trailer when the job begins" do
74
+ batch = Bankserv::Transmission::UserSet::Credit.generate(rec_status: "T")
75
+ batch.save
76
+
77
+ batch.trailer.data.should == {
78
+ rec_id: "020",
79
+ rec_status: "T",
80
+ bankserv_record_identifier: "92",
81
+ bankserv_user_code: "9534",
82
+ first_sequence_number: "1",
83
+ last_sequence_number: "8",
84
+ first_action_date: Time.now.strftime("%y%m%d"),
85
+ last_action_date: (Date.today + 3.days).strftime("%y%m%d"),
86
+ no_debit_records: "2",
87
+ no_credit_records: "6",
88
+ no_contra_records: "2",
89
+ total_debit_value: "2500000",
90
+ total_credit_value: "2500000",
91
+ hash_total_of_homing_account_numbers: "277310804125"
92
+ }
93
+ end
94
+ end
95
+
96
+ end
@@ -0,0 +1,103 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bankserv::Transmission::UserSet::Debit do
4
+ include Helpers
5
+
6
+ context "Building a debit batch" do
7
+
8
+ before(:all) do
9
+ tear_it_down
10
+
11
+ create(:configuration, client_code: "10", client_name: "LDC USER 10 AFRICA (PTY)", user_code: "9534", user_generation_number: 37, client_abbreviated_name: "ALIMITTST")
12
+
13
+ @data = [{
14
+ credit: {
15
+ account_number: "907654321", branch_code: "632005", account_type: 'savings', id_number: '8207205263083', initials: "RC", account_name: "Rawson Milnerton", amount: 10000.00, user_ref: 234, action_date: Date.today },
16
+ debit: [
17
+ { account_number: "13123123123", branch_code: "123123", account_type: "savings", id_number: "198273981723", initials: "WC", account_name: "Tenant", amount: 5000.00, action_date: Date.today, user_ref: "235"},
18
+ { account_number: "45645645645", branch_code: "123123", account_type: "savings", id_number: "198273922723", initials: "WX", account_name: "Tefant", amount: 2500.00, action_date: Date.today, user_ref: "236"},
19
+ { account_number: "78978978978", branch_code: "789789", account_type: "savings", id_number: "197873933723", initials: "WB", account_name: "Tebant", amount: 2500.00, action_date: Date.today, user_ref: "237"}
20
+ ]
21
+ }, {
22
+ credit: {
23
+ account_number: "907654322", branch_code: "632005", account_type: 'savings', id_number: '8207205263083', initials: "RC", account_name: "Rawson Milnerton", amount: 15000.00, user_ref: 300, action_date: Date.today },
24
+ debit: [
25
+ { account_number: "13123123122", branch_code: "123123", account_type: "savings", id_number: "198273981723", initials: "WC", account_name: "Tenant", amount: 5000.00, action_date: Date.today, user_ref: "301"},
26
+ { account_number: "45645645642", branch_code: "123123", account_type: "savings", id_number: "198273922723", initials: "WX", account_name: "Tefant", amount: 2500.00, action_date: Date.today, user_ref: "302"},
27
+ { account_number: "78978978972", branch_code: "789789", account_type: "savings", id_number: "197873933723", initials: "WB", account_name: "Tebant", amount: 7500.00, action_date: Date.today, user_ref: "303"}
28
+ ]
29
+ }]
30
+
31
+ @hash = {
32
+ type: 'debit',
33
+ data: { type_of_service: "SAMEDAY", batches: @data }
34
+ }
35
+
36
+ Bankserv::Debit.test_request(@hash)
37
+ end
38
+
39
+ it "should return true when a batch needs to be processed" do
40
+ Bankserv::Transmission::UserSet::Debit.has_test_work?.should be_true
41
+ end
42
+
43
+ it "should create a batch with a header when the job begins" do
44
+ batch = Bankserv::Transmission::UserSet::Debit.generate(rec_status: "T")
45
+ batch.save
46
+
47
+ purge = (Date.today + 7.days).strftime("%y%m%d")
48
+
49
+ batch.header.data.should == {
50
+ rec_id: "001",
51
+ rec_status: "T",
52
+ bankserv_record_identifier: "04",
53
+ bankserv_user_code: "9534",
54
+ bankserv_creation_date: Time.now.strftime("%y%m%d"),
55
+ bankserv_purge_date: purge,
56
+ first_action_date: Time.now.strftime("%y%m%d"),
57
+ last_action_date: (Date.today + 3.days).strftime("%y%m%d"),
58
+ first_sequence_number: "1",
59
+ user_generation_number: "37",
60
+ type_of_service: "SAMEDAY",
61
+ accepted_report: "",
62
+ account_type_correct: ""
63
+ }
64
+ end
65
+
66
+ it "should create a 2 batches of debit transactions when the job begins" do
67
+ batch = Bankserv::Transmission::UserSet::Debit.generate(rec_status: "T")
68
+ batch.save
69
+
70
+ batch.contra_records.size.should == 2
71
+ end
72
+
73
+ it "should contain 6 standard transactions" do
74
+ batch = Bankserv::Transmission::UserSet::Debit.generate(rec_status: "T")
75
+ batch.save
76
+
77
+ batch.standard_records.size.should == 6
78
+ end
79
+
80
+ it "should create a batch with a trailer when the job begins" do
81
+ batch = Bankserv::Transmission::UserSet::Debit.generate(rec_status: "T")
82
+ batch.save
83
+
84
+ batch.trailer.data.should == {
85
+ rec_id: "001",
86
+ rec_status: "T",
87
+ bankserv_record_identifier: "92",
88
+ bankserv_user_code: "9534",
89
+ first_sequence_number: "1",
90
+ last_sequence_number: "8",
91
+ first_action_date: Time.now.strftime("%y%m%d"),
92
+ last_action_date: (Date.today + 3.days).strftime("%y%m%d"),
93
+ no_debit_records: "6",
94
+ no_credit_records: "2",
95
+ no_contra_records: "2",
96
+ total_debit_value: "2500000",
97
+ total_credit_value: "2500000",
98
+ hash_total_of_homing_account_numbers: "277310804125"
99
+ }
100
+ end
101
+ end
102
+
103
+ end
@@ -0,0 +1,109 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bankserv::Statement do
4
+ include Helpers
5
+
6
+ before(:each) do
7
+ tear_it_down
8
+ create(:configuration)
9
+
10
+ @file_contents = File.open("./spec/examples/statement4_unpacked.dat", "rb").read
11
+ @statement = Bankserv::Statement.store(@file_contents)
12
+ end
13
+
14
+ context "storing a statement" do
15
+
16
+ it "should store the client code" do
17
+ @statement.client_code.should == "3174"
18
+ end
19
+
20
+ it "should mark the statement as unprocessed" do
21
+ @statement.processed.should be_false
22
+ end
23
+
24
+ it "should store the hash of information returned from the absa-esd gem as the statement's serialized data" do
25
+ @statement.data.should == Absa::Esd::Transmission::Document.hash_from_s(@file_contents)
26
+ end
27
+
28
+ end
29
+
30
+ context "processing a statement" do
31
+
32
+ before(:each) do
33
+ @statement.process!
34
+ end
35
+
36
+ it "should create a transaction for each recon account detail record" do
37
+ @statement.transactions.count.should == 46
38
+
39
+ Bankserv::Transaction.all.each do |t|
40
+ t.statement.should == @statement
41
+ end
42
+ end
43
+
44
+ it "should set each transaction's client code to the statement's client code" do
45
+ @statement.transactions.all?{|t| t.client_code == "3174"}
46
+ end
47
+
48
+ it "should default the transactions to unprocessed" do
49
+ @statement.transactions.all?{|t| t.processed == false}
50
+ end
51
+
52
+ it "should store the recon account detail record's data as the transaction's data" do
53
+ @statement.transactions.first.data.should == {
54
+ rec_type: "2",
55
+ account_number: "4011111809",
56
+ statement_number: "264",
57
+ page_number: "1",
58
+ transaction_processing_date: "20021118",
59
+ transaction_effective_date: "20021118",
60
+ cheque_number: "0",
61
+ transaction_reference_number: "103899",
62
+ transaction_amount_sign: "+",
63
+ transaction_amount: "2630670",
64
+ account_balance_sign: "+",
65
+ account_balance_after_transaction: "2630670",
66
+ transaction_description: "ACB CREDIT SETTLEMENT",
67
+ dep_id: "BASGHW GP HEALTH000212608",
68
+ transaction_code: "FN71",
69
+ cheques_function_code: "ACC",
70
+ charge_levied_amount_sign: "+",
71
+ charge_levied_amount: "0",
72
+ charge_type: "",
73
+ stamp_duty_amount_sign: "+",
74
+ stamp_duty_levied_amount: "0",
75
+ cash_deposit_fee_sign: "+",
76
+ cash_deposit_fee: "0",
77
+ charges_accrued: "",
78
+ event_number: "12533",
79
+ statement_line_sequence_number: "4",
80
+ vat_amount: "0",
81
+ cash_portion: "0",
82
+ deposit_number: "0",
83
+ transaction_time: "0",
84
+ filler_1: "",
85
+ filler_2: "",
86
+ sitename: "",
87
+ category: "0012",
88
+ transaction_type: "",
89
+ deposit_id_description: "",
90
+ pod_adjustment_amount: "000000000000000",
91
+ pod_adjustment_reason: "",
92
+ pod_returned_cheque_reason_code: "0",
93
+ pod_returned_cheque_drawee: "",
94
+ fedi_payor: "",
95
+ fedi_number: "0",
96
+ redirect_description: "",
97
+ account_number_redirect: "0",
98
+ unpaid_cheque_reason_description: "",
99
+ filler_3: "",
100
+ generation_number: "000000295",
101
+ old_reconfocus_category1: "51",
102
+ old_reconfocus_category2: "51",
103
+ filler_4: ""
104
+ }
105
+ end
106
+
107
+ end
108
+
109
+ end