coda_standard 0.1.5 → 0.1.6
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 +4 -4
- data/README.md +6 -3
- data/lib/coda_standard/parser.rb +2 -2
- data/lib/coda_standard/record.rb +5 -5
- data/lib/coda_standard/transaction.rb +4 -1
- data/lib/coda_standard/transaction_list.rb +5 -0
- data/lib/coda_standard/version.rb +1 -1
- data/spec/record_spec.rb +3 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6351da7871b5a7810980fe6e22111fb751a3ff9
|
4
|
+
data.tar.gz: 1bdf0a5f7280aa543ef7e3f0f729dbadacd2e656
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 19dfa00474ea5142b1969e7fd0ba436292bb6ba4d9af51f4e0ed2c497060f0f30c3f3c4c49beedb763d78582df0f5fc05a50a47f9f1c94265f4c4fdcf628ef46
|
7
|
+
data.tar.gz: d2a16c6e73b428f70ad8714d9505c8c5cb18706734279bcb16f7603e71df48bd60b52c40ba6fe80200bf60d9680575dec7e0ef0c4187a78c8c8049179f8c8dc1
|
data/README.md
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
This gem parses the [Coded statement of account](https://www.febelfin.be/sites/default/files/files/Standard-CODA-22-EN.pdf) (CODA) bank standard used by some banks and follows version 2.2 of this standard.
|
4
4
|
|
5
|
-
> This bank standard specifies the lay-out for the electronic files, by banks to customers, of the account transactions and the information concerning the enclosures in connection with the movement.
|
5
|
+
> This bank standard specifies the lay-out for the electronic files, by banks to customers, of the account transactions and the information concerning the enclosures in connection with the movement.
|
6
6
|
|
7
|
-
The coda_standard gem requires Ruby version ~> 2.0.
|
7
|
+
The coda_standard gem requires Ruby version ~> 2.0.
|
8
8
|
|
9
9
|
## Install
|
10
10
|
|
@@ -33,9 +33,12 @@ CodaStandard::Parser.new(filename).parse.current_bic => "GEBABEBB"
|
|
33
33
|
|
34
34
|
# or print a more readable represenation of the file
|
35
35
|
CodaStandard::Parser.new(filename).show
|
36
|
+
|
37
|
+
# you can also find a transaction inside a transaction list object by the structured communication number
|
38
|
+
CodaStandard::Parser.new(filename).parse.find_by_structured_communication('100000001234')
|
36
39
|
```
|
37
40
|
|
38
|
-
The available getters for each transaction are: `name`, `currency`, `bic`, `address`, `postcode`, `city`, `country`, `amount`, `account`, `entry_date`, `reference_number` and `
|
41
|
+
The available getters for each transaction are: `name`, `currency`, `bic`, `address`, `postcode`, `city`, `country`, `amount`, `account`, `entry_date`, `reference_number` and `structured_communication`.
|
39
42
|
|
40
43
|
## Contributing
|
41
44
|
|
data/lib/coda_standard/parser.rb
CHANGED
@@ -22,7 +22,7 @@ module CodaStandard
|
|
22
22
|
@current_transaction.entry_date = record.entry_date
|
23
23
|
@current_transaction.reference_number = record.reference_number
|
24
24
|
@current_transaction.amount = record.amount
|
25
|
-
@current_transaction.
|
25
|
+
@current_transaction.structured_communication = record.structured_communication
|
26
26
|
when record.data_movement2?
|
27
27
|
@current_transaction.bic = record.bic
|
28
28
|
when record.data_movement3?
|
@@ -54,7 +54,7 @@ module CodaStandard
|
|
54
54
|
puts "Account: #{@transactions.current_account} Account type: #{@transactions.current_account_type} BIC: #{@transactions.current_bic}"
|
55
55
|
puts "Old balance: #{@transactions.old_balance} \n\n"
|
56
56
|
@transactions.each_with_index do |transaction, index|
|
57
|
-
puts "-- Transaction n.#{index + 1} - number #{transaction.
|
57
|
+
puts "-- Transaction n.#{index + 1} - number #{transaction.structured_communication} - in date #{transaction.entry_date}-- \n\n"
|
58
58
|
puts " RN: #{transaction.reference_number} Account: #{transaction.account} BIC: #{transaction.bic}"
|
59
59
|
puts " Amount: #{transaction.amount} #{transaction.currency}"
|
60
60
|
puts " Name: #{transaction.name}"
|
data/lib/coda_standard/record.rb
CHANGED
@@ -10,7 +10,7 @@ module CodaStandard
|
|
10
10
|
address: /^32.{8}(.{105})/,
|
11
11
|
account: /^23\d{8}(\w+)\D/,
|
12
12
|
bic: /^22.{96}(.{11})/,
|
13
|
-
amount: /^21
|
13
|
+
amount: /^21.{29}(\d{16})/,
|
14
14
|
old_balance: /^1.{41}(\d)(\d{15})/,
|
15
15
|
sep_address: /(^.+)(\d{4})\s(\S+)(\s\S+)?$/,
|
16
16
|
sep_account: /(^.)(.{3})(.+)/,
|
@@ -18,7 +18,7 @@ module CodaStandard
|
|
18
18
|
bban_foreign_account: /(^.{34})/,
|
19
19
|
iban_be_account: /(^.{31})/,
|
20
20
|
iban_foreign_account: /(^.{34})/,
|
21
|
-
|
21
|
+
structured_communication: /^21.{60}(.{15})/,
|
22
22
|
clean_structured: /.{3}(.{12})/,
|
23
23
|
currencies: /(^.+)(AED|AFN|ALL|AMD|ANG|AOA|ARS|AUD|AWG|AZN|BAM|BBD|BDT|BGN|BHD|BIF|BMD|BND|BOB|BOV|BRL|BSD|BTN|BWP|BYR|BZD|CAD|CDF|CHE|CHF|CHW|CLF|CLP|CNY|COP|COU|CRC|CUC|CUP|CVE|CZK|DJF|DKK|DOP|DZD|EGP|ERN|ETB|EUR|FJD|FKP|GBP|GEL|GHS|GIP|GMD|GNF|GTQ|GYD|HKD|HNL|HRK|HTG|HUF|IDR|ILS|INR|IQD|IRR|ISK|JMD|JOD|JPY|KES|KGS|KHR|KMF|KPW|KRW|KWD|KYD|KZT|LAK|LBP|LKR|LRD|LSL|LTL|LVL|LYD|MAD|MDL|MGA|MKD|MMK|MNT|MOP|MRO|MUR|MVR|MWK|MXN|MXV|MYR|MZN|NAD|NGN|NIO|NOK|NPR|NZD|OMR|PAB|PEN|PGK|PHP|PKR|PLN|PYG|QAR|RON|RSD|RUB|RWF|SAR|SBD|SCR|SDG|SEK|SGD|SHP|SLL|SOS|SRD|SSP|STD|SVC|SYP|SZL|THB|TJS|TMT|TND|TOP|TRY|TTD|TWD|TZS|UAH|UGX|USD|USN|USS|UYI|UYU|UZS|VEF|VND|VUV|WST|XAF|XAG|XAU|XBA|XBB|XBC|XBD|XCD|XDR|XFU|XOF|XPD|XPF|XPT|XSU|XTS|XUA|XXX|YER|ZAR|ZMW|ZWL)/
|
24
24
|
}
|
@@ -97,8 +97,8 @@ module CodaStandard
|
|
97
97
|
extract(:address)
|
98
98
|
end
|
99
99
|
|
100
|
-
def
|
101
|
-
extract(:
|
100
|
+
def structured_communication
|
101
|
+
extract(:structured_communication)
|
102
102
|
end
|
103
103
|
|
104
104
|
private
|
@@ -112,7 +112,7 @@ module CodaStandard
|
|
112
112
|
result = clean_account(result)
|
113
113
|
when :old_balance, :amount
|
114
114
|
result = clean_zeros(result)
|
115
|
-
when :
|
115
|
+
when :structured_communication
|
116
116
|
result = check_structured(result)
|
117
117
|
end
|
118
118
|
result
|
@@ -1,5 +1,8 @@
|
|
1
1
|
module CodaStandard
|
2
2
|
class Transaction
|
3
|
-
attr_accessor :name, :currency, :bic, :address, :postcode, :city, :country, :amount, :account, :entry_date, :reference_number, :
|
3
|
+
attr_accessor :name, :currency, :bic, :address, :postcode, :city, :country, :amount, :account, :entry_date, :reference_number, :structured_communication
|
4
|
+
def match_structured_communication(structured_communication)
|
5
|
+
@structured_communication == structured_communication
|
6
|
+
end
|
4
7
|
end
|
5
8
|
end
|
@@ -15,5 +15,10 @@ module CodaStandard
|
|
15
15
|
def each_with_index(&blk)
|
16
16
|
@transactions.each_with_index(&blk)
|
17
17
|
end
|
18
|
+
|
19
|
+
|
20
|
+
def find_by_structured_communication(structured_communication)
|
21
|
+
@transactions.select{|t| t.match_structured_communication(structured_communication)}
|
22
|
+
end
|
18
23
|
end
|
19
24
|
end
|
data/spec/record_spec.rb
CHANGED
@@ -130,15 +130,15 @@ describe CodaStandard::Record do
|
|
130
130
|
end
|
131
131
|
end
|
132
132
|
|
133
|
-
describe "
|
133
|
+
describe "structured_communication" do
|
134
134
|
context "structured_number" do
|
135
135
|
it "extracts the number" do
|
136
|
-
expect(data_movement1_record.
|
136
|
+
expect(data_movement1_record.structured_communication).to eq("100000834941")
|
137
137
|
end
|
138
138
|
end
|
139
139
|
context "non-structured_number" do
|
140
140
|
it "returns not structured" do
|
141
|
-
expect(data_movement1b_record.
|
141
|
+
expect(data_movement1b_record.structured_communication).to eq("not structured")
|
142
142
|
end
|
143
143
|
end
|
144
144
|
end
|