Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add `raw` method to Deposits

  • Loading branch information...
commit c9586c27378b5977d096f35755bb91ed48ed97c7 1 parent 0340fa7
@dvrensk dvrensk authored
View
1  README.md
@@ -59,6 +59,7 @@ payment_1.currency # => "SEK"
payment_2.currency # => nil
```
+The `raw` method is also available on deposit objects.
See the specs for more details.
Files are expected to be ISO-8859-1 (as Bankgirot prefers), but data strings
View
12 lib/bankgiro_inbetalningar/parser.rb
@@ -35,11 +35,18 @@ def line_parser_class
end
def record_line
+ if result.deposit && deposit_line?
+ result.deposit.raw << @line
+ end
if result.deposit && result.payment && payment_line?
result.payment.raw << @line
end
end
+ def deposit_line?
+ payment_line? || %w(05 15).include?(@line[0..1])
+ end
+
def payment_line?
@line[0] == '2'
end
@@ -215,9 +222,10 @@ def payments
end
class Deposit
- attr_accessor :bgno, :currency, :payments, :date
+ attr_accessor :bgno, :currency, :payments, :date, :raw
def initialize
@payments = []
+ @raw = ""
end
end
@@ -225,7 +233,7 @@ class Payment
attr_accessor :cents, :references, :currency, :raw, :payer, :sender_bgno, :text, :date, :number
def initialize
@references = []
- @raw = "".force_encoding('iso-8859-1')
+ @raw = ""
end
def payer!
View
5 spec/bankgiro_inbetalningar/parser_spec.rb
@@ -33,7 +33,6 @@ module BankgiroInbetalningar
payment.references.should == ['535765']
payment.currency.should == 'SEK'
payment.cents.should == 500_00
- payment.raw.should == "200000000000 535765000000000000050000230000000000230 \r\n"
end
it "has a date" do
payment.date.should == Date.civil(2004,5,25)
@@ -41,6 +40,10 @@ module BankgiroInbetalningar
it "has a number" do
payment.number.should == "000000000023"
end
+ it "stores the raw data" do
+ payment.raw.should == "200000000000 535765000000000000050000230000000000230 \r\n"
+ result.deposits[3].raw.split(/\r\n/).should == data.encode('utf-8').split(/\r\n/)[50..65]
+ end
end
context "simple OCR payment with address" do
Please sign in to comment.
Something went wrong with that request. Please try again.