sepa_king 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,48 @@
1
+ # encoding: utf-8
2
+ module SEPA
3
+ class CreditTransaction
4
+ include TextConverter
5
+ attr_reader :name, :iban, :bic, :amount, :reference, :remittance_information
6
+
7
+ def initialize(options)
8
+ options.each_pair do |k,v|
9
+ send("#{k}=", v)
10
+ end
11
+ end
12
+
13
+ def name=(value)
14
+ raise ArgumentError.new('Name is missing') unless value
15
+ @name = convert_text(value)
16
+ end
17
+
18
+ def iban=(value)
19
+ raise ArgumentError.new('IBAN is missing') unless value
20
+ raise ArgumentError.new("IBAN has wrong length: #{value.length}, must be between 15-34") unless value.length.between?(15,34)
21
+ @iban = value
22
+ end
23
+
24
+ def bic=(value)
25
+ raise ArgumentError.new('BIC is missing') unless value
26
+ raise ArgumentError.new("BIC has wrong length: #{value.length} must be between 8-11") unless value.length.between?(8,11)
27
+ @bic = value
28
+ end
29
+
30
+ def amount=(value)
31
+ raise ArgumentError.new('Amount is not a number') unless value.is_a?(Numeric)
32
+ raise ArgumentError.new('Amount cannot be zero') if value.zero?
33
+ raise ArgumentError.new('Amount cannot be negative') if value < 0
34
+ @amount = value
35
+ end
36
+
37
+ def reference=(value)
38
+ raise ArgumentError.new('Reference is missing') unless value
39
+ raise ArgumentError.new("Reference has wrong length: #{value.length}, must be 35 maximum") if value.length > 35
40
+ @reference = convert_text(value)
41
+ end
42
+
43
+ def remittance_information=(value)
44
+ raise ArgumentError.new('Remittance information is missing') unless value
45
+ @remittance_information = convert_text(value)
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,102 @@
1
+ # encoding: utf-8
2
+
3
+ module SEPA
4
+ class CreditTransferInitiation
5
+ attr_reader :debitor, :transactions
6
+
7
+ def initialize(debitor_options)
8
+ @debitor = Account.new(debitor_options)
9
+ @transactions = []
10
+ end
11
+
12
+ def add_transaction(options)
13
+ @transactions << CreditTransaction.new(options)
14
+ end
15
+
16
+ def to_xml
17
+ builder = Builder::XmlMarkup.new :indent => 2
18
+ builder.instruct!
19
+ builder.Document :xmlns => 'urn:iso:std:iso:20022:tech:xsd:pain.001.002.03',
20
+ :'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
21
+ :'xsi:schemaLocation' => 'urn:iso:std:iso:20022:tech:xsd:pain.001.002.03 pain.001.002.03.xsd' do
22
+ builder.CstmrCdtTrfInitn do
23
+ builder.GrpHdr do
24
+ builder.MsgId(message_identification)
25
+ builder.CreDtTm(Time.now.iso8601)
26
+ builder.NbOfTxs(transactions.length)
27
+ builder.InitgPty do
28
+ builder.Nm(debitor.name)
29
+ end
30
+ end
31
+
32
+ builder.PmtInf do
33
+ builder.PmtInfId(payment_information_identification)
34
+ builder.PmtMtd('TRF')
35
+ builder.BtchBookg(true)
36
+ builder.NbOfTxs(transactions.length)
37
+ builder.CtrlSum(amount_total)
38
+ builder.PmtTpInf do
39
+ builder.SvcLvl do
40
+ builder.Cd('SEPA')
41
+ end
42
+ end
43
+ builder.ReqdExctnDt(Date.today.next.iso8601)
44
+ builder.Dbtr do
45
+ builder.Nm(debitor.name)
46
+ end
47
+ builder.DbtrAcct do
48
+ builder.Id do
49
+ builder.IBAN(debitor.iban)
50
+ end
51
+ end
52
+ builder.DbtrAgt do
53
+ builder.FinInstnId do
54
+ builder.BIC(debitor.bic)
55
+ end
56
+ end
57
+ builder.ChrgBr('SLEV')
58
+ transactions.each do |transaction|
59
+ builder.CdtTrfTxInf do
60
+ builder.PmtId do
61
+ builder.EndToEndId(transaction.reference || 'NOTPROVIDED')
62
+ end
63
+ builder.Amt do
64
+ builder.InstdAmt(transaction.amount, :Ccy => 'EUR')
65
+ end
66
+ builder.CdtrAgt do
67
+ builder.FinInstnId do
68
+ builder.BIC(transaction.bic)
69
+ end
70
+ end
71
+ builder.Cdtr do
72
+ builder.Nm(transaction.name)
73
+ end
74
+ builder.CdtrAcct do
75
+ builder.Id do
76
+ builder.IBAN(transaction.iban)
77
+ end
78
+ end
79
+ builder.RmtInf do
80
+ builder.Ustrd(transaction.remittance_information)
81
+ end
82
+ end
83
+ end
84
+ end
85
+ end
86
+ end
87
+ end
88
+
89
+ private
90
+ def amount_total
91
+ transactions.inject(0) { |sum, t| sum + t.amount }
92
+ end
93
+
94
+ def message_identification
95
+ "SEPA-KING/#{Time.now.iso8601}"
96
+ end
97
+
98
+ def payment_information_identification
99
+ message_identification
100
+ end
101
+ end
102
+ end
@@ -0,0 +1,53 @@
1
+ # encoding: utf-8
2
+ module SEPA
3
+ class DebtTransaction
4
+ include TextConverter
5
+ attr_reader :name, :iban, :bic, :amount, :reference, :mandate_id, :mandate_date_of_signature
6
+
7
+ def initialize(options)
8
+ options.each_pair do |k,v|
9
+ send("#{k}=", v)
10
+ end
11
+ end
12
+
13
+ def name=(value)
14
+ raise ArgumentError.new('Name is missing') unless value
15
+ @name = convert_text(value)
16
+ end
17
+
18
+ def iban=(value)
19
+ raise ArgumentError.new('IBAN is missing') unless value
20
+ raise ArgumentError.new("IBAN has wrong length: #{value.length}, must be between 15-34") unless value.length.between?(15,34)
21
+ @iban = value
22
+ end
23
+
24
+ def bic=(value)
25
+ raise ArgumentError.new('BIC is missing') unless value
26
+ raise ArgumentError.new("BIC has wrong length: #{value.length} must be between 8-11") unless value.length.between?(8,11)
27
+ @bic = value
28
+ end
29
+
30
+ def amount=(value)
31
+ raise ArgumentError.new('Amount is not a Number') unless value.is_a?(Numeric)
32
+ raise ArgumentError.new('Amount cannot be zero') if value.zero?
33
+ raise ArgumentError.new('Amount cannot be negative') if value < 0
34
+ @amount = value
35
+ end
36
+
37
+ def reference=(value)
38
+ raise ArgumentError.new('Reference is missing') unless value
39
+ raise ArgumentError.new("Reference has wrong length: #{value.length}, must be 35 maximum") if value.length > 35
40
+ @reference = convert_text(value)
41
+ end
42
+
43
+ def mandate_id=(value)
44
+ raise ArgumentError.new('Mandate ID is missing') unless value
45
+ @mandate_id = convert_text(value)
46
+ end
47
+
48
+ def mandate_date_of_signature=(value)
49
+ raise ArgumentError.new('Mandate Date of Signature is missing') unless value.is_a?(Date)
50
+ @mandate_date_of_signature = value
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,117 @@
1
+ # encoding: utf-8
2
+
3
+ module SEPA
4
+ class DirectDebitInitiation
5
+ attr_reader :creditor, :transactions
6
+
7
+ def initialize(creditor_options)
8
+ @creditor = Account.new(creditor_options)
9
+ @transactions = []
10
+ end
11
+
12
+ def add_transaction(options)
13
+ @transactions << DebtTransaction.new(options)
14
+ end
15
+
16
+ def to_xml
17
+ builder = Builder::XmlMarkup.new :indent => 2
18
+ builder.instruct!
19
+ builder.Document :xmlns => 'urn:iso:std:iso:20022:tech:xsd:pain.008.002.02',
20
+ :'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
21
+ :'xsi:schemaLocation' => 'urn:iso:std:iso:20022:tech:xsd:pain.008.002.02 pain.008.002.02.xsd' do
22
+ builder.CstmrDrctDbtInitn do
23
+ builder.GrpHdr do
24
+ builder.MsgId(message_identification)
25
+ builder.CreDtTm(Time.now.iso8601)
26
+ builder.NbOfTxs(transactions.length)
27
+ builder.CtrlSum(amount_total)
28
+ builder.InitgPty do
29
+ builder.Nm(creditor.name)
30
+ end
31
+ end
32
+
33
+ builder.PmtInf do
34
+ builder.PmtInfId(payment_information_identification)
35
+ builder.PmtMtd('DD')
36
+ builder.PmtTpInf do
37
+ builder.SvcLvl do
38
+ builder.Cd('SEPA')
39
+ end
40
+ builder.LclInstrm do
41
+ builder.Cd('CORE')
42
+ end
43
+ builder.SeqTp('OOFF')
44
+ end
45
+ builder.ReqdColltnDt(Date.today.next.iso8601)
46
+ builder.Cdtr do
47
+ builder.Nm(creditor.name)
48
+ end
49
+ builder.CdtrAcct do
50
+ builder.Id do
51
+ builder.IBAN(creditor.iban)
52
+ end
53
+ end
54
+ builder.CdtrAgt do
55
+ builder.FinInstnId do
56
+ builder.BIC(creditor.bic)
57
+ end
58
+ end
59
+ builder.ChrgBr('SLEV')
60
+ builder.CdtrSchmeId do
61
+ builder.Id do
62
+ builder.PrvtId do
63
+ builder.Othr do
64
+ builder.Id(creditor.identifier)
65
+ builder.SchmeNm do
66
+ builder.Prtry('SEPA')
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
72
+ transactions.each do |transaction|
73
+ builder.DrctDbtTxInf do
74
+ builder.PmtId do
75
+ builder.EndToEndId(transaction.reference || 'NOTPROVIDED')
76
+ end
77
+ builder.InstdAmt(transaction.amount, :Ccy => 'EUR')
78
+ builder.DrctDbtTx do
79
+ builder.MndtRltdInf do
80
+ builder.MndtId(transaction.mandate_id)
81
+ builder.DtOfSgntr(transaction.mandate_date_of_signature.iso8601)
82
+ end
83
+ end
84
+ builder.DbtrAgt do
85
+ builder.FinInstnId do
86
+ builder.BIC(transaction.bic)
87
+ end
88
+ end
89
+ builder.Dbtr do
90
+ builder.Nm(transaction.name)
91
+ end
92
+ builder.DbtrAcct do
93
+ builder.Id do
94
+ builder.IBAN(transaction.iban)
95
+ end
96
+ end
97
+ end
98
+ end
99
+ end
100
+ end
101
+ end
102
+ end
103
+
104
+ private
105
+ def amount_total
106
+ transactions.inject(0) { |sum, t| sum + t.amount }
107
+ end
108
+
109
+ def message_identification
110
+ "SEPA-KING/#{Time.now.iso8601}"
111
+ end
112
+
113
+ def payment_information_identification
114
+ message_identification
115
+ end
116
+ end
117
+ end
@@ -0,0 +1,5 @@
1
+ # encoding: utf-8
2
+ module SEPA
3
+ class Exception < ::Exception
4
+ end
5
+ end
@@ -0,0 +1,25 @@
1
+ # encoding: utf-8
2
+ module SEPA
3
+ module TextConverter
4
+ def convert_text(text)
5
+ text = text.to_s
6
+ return text if text.empty?
7
+
8
+ text = text.
9
+ # Convert german umlauts
10
+ gsub('Ä', 'AE').
11
+ gsub('Ü', 'UE').
12
+ gsub('Ö', 'OE').
13
+ gsub('ä', 'ae').
14
+ gsub('ü', 'ue').
15
+ gsub('ö', 'oe').
16
+ gsub('ß', 'ss')
17
+
18
+ I18n.transliterate(text).
19
+ # Remove all invalid characters
20
+ gsub(/[^a-zA-Z0-9\ \'\:\?\,\-\(\+\.\)\/]/, '').
21
+ # Remove leading and trailing spaces
22
+ strip
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,3 @@
1
+ module SEPA
2
+ VERSION = '0.0.2'
3
+ end
data/lib/sepa_king.rb ADDED
@@ -0,0 +1,11 @@
1
+ require 'i18n'
2
+ require 'bigdecimal'
3
+ require 'builder'
4
+
5
+ require 'sepa_king/text_converter'
6
+ require 'sepa_king/account'
7
+ require 'sepa_king/debt_transaction'
8
+ require 'sepa_king/credit_transaction'
9
+ require 'sepa_king/exception'
10
+ require 'sepa_king/direct_debit_initiation'
11
+ require 'sepa_king/credit_transfer_initiation'
data/sepa_king.gemspec ADDED
@@ -0,0 +1,31 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path('../lib', __FILE__)
3
+ require 'sepa_king/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = %q{sepa_king}
7
+ s.version = SEPA::VERSION
8
+
9
+ s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
10
+ s.authors = ['Georg Leciejewski', 'Georg Ledermann']
11
+ s.date = %q{2013-08-10}
12
+ s.summary = %q{Generate SEPA XML files with Ruby .. the easy way}
13
+ s.description = %q{}
14
+ s.email = %q{gl@salesking.eu}
15
+ s.extra_rdoc_files = ['README.markdown']
16
+ s.executables = nil
17
+ s.files = `git ls-files`.split("\n").reject{|i| i[/^docs\//] }
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+
20
+ s.homepage = %q{http://github.com/salesking/sepa_king}
21
+ s.require_paths = ['lib']
22
+ s.rubygems_version = %q{1.6.2}
23
+
24
+ s.add_runtime_dependency 'i18n'
25
+ s.add_runtime_dependency 'builder'
26
+
27
+ s.add_development_dependency 'rspec'
28
+ s.add_development_dependency 'simplecov'
29
+ s.add_development_dependency 'rake', '>= 0.9.2'
30
+ s.add_development_dependency 'libxml-ruby'
31
+ end
@@ -0,0 +1,89 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!-- Mit XMLSpy v2008 rel. 2 sp2 (http://www.altova.com) von benutzerservice benutzerservice (SIZ GmbH) bearbeitet -->
3
+ <Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.002.03" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:iso:std:iso:20022:tech:xsd:pain.001.002.03 pain.001.002.03.xsd">
4
+ <CstmrCdtTrfInitn>
5
+ <GrpHdr>
6
+ <MsgId>Message-ID-4711</MsgId>
7
+ <CreDtTm>2010-11-11T09:30:47.000Z</CreDtTm>
8
+ <NbOfTxs>2</NbOfTxs>
9
+ <InitgPty>
10
+ <Nm>Initiator Name</Nm>
11
+ </InitgPty>
12
+ </GrpHdr>
13
+ <PmtInf>
14
+ <PmtInfId>Payment-Information-ID-4711</PmtInfId>
15
+ <PmtMtd>TRF</PmtMtd>
16
+ <BtchBookg>true</BtchBookg>
17
+ <NbOfTxs>2</NbOfTxs>
18
+ <CtrlSum>6655.86</CtrlSum>
19
+ <PmtTpInf>
20
+ <SvcLvl>
21
+ <Cd>SEPA</Cd>
22
+ </SvcLvl>
23
+ </PmtTpInf>
24
+ <ReqdExctnDt>2010-11-25</ReqdExctnDt>
25
+ <Dbtr>
26
+ <Nm>Debtor Name</Nm>
27
+ </Dbtr>
28
+ <DbtrAcct>
29
+ <Id>
30
+ <IBAN>DE87200500001234567890</IBAN>
31
+ </Id>
32
+ </DbtrAcct>
33
+ <DbtrAgt>
34
+ <FinInstnId>
35
+ <BIC>BANKDEFFXXX</BIC>
36
+ </FinInstnId>
37
+ </DbtrAgt>
38
+ <ChrgBr>SLEV</ChrgBr>
39
+ <CdtTrfTxInf>
40
+ <PmtId>
41
+ <EndToEndId>OriginatorID1234</EndToEndId>
42
+ </PmtId>
43
+ <Amt>
44
+ <InstdAmt Ccy="EUR">6543.14</InstdAmt>
45
+ </Amt>
46
+ <CdtrAgt>
47
+ <FinInstnId>
48
+ <BIC>SPUEDE2UXXX</BIC>
49
+ </FinInstnId>
50
+ </CdtrAgt>
51
+ <Cdtr>
52
+ <Nm>Creditor Name</Nm>
53
+ </Cdtr>
54
+ <CdtrAcct>
55
+ <Id>
56
+ <IBAN>DE21500500009876543210</IBAN>
57
+ </Id>
58
+ </CdtrAcct>
59
+ <RmtInf>
60
+ <Ustrd>Unstructured Remittance Information</Ustrd>
61
+ </RmtInf>
62
+ </CdtTrfTxInf>
63
+ <CdtTrfTxInf>
64
+ <PmtId>
65
+ <EndToEndId>OriginatorID1235</EndToEndId>
66
+ </PmtId>
67
+ <Amt>
68
+ <InstdAmt Ccy="EUR">112.72</InstdAmt>
69
+ </Amt>
70
+ <CdtrAgt>
71
+ <FinInstnId>
72
+ <BIC>SPUEDE2UXXX</BIC>
73
+ </FinInstnId>
74
+ </CdtrAgt>
75
+ <Cdtr>
76
+ <Nm>Other Creditor Name</Nm>
77
+ </Cdtr>
78
+ <CdtrAcct>
79
+ <Id>
80
+ <IBAN>DE21500500001234567897</IBAN>
81
+ </Id>
82
+ </CdtrAcct>
83
+ <RmtInf>
84
+ <Ustrd>Unstructured Remittance Information</Ustrd>
85
+ </RmtInf>
86
+ </CdtTrfTxInf>
87
+ </PmtInf>
88
+ </CstmrCdtTrfInitn>
89
+ </Document>
@@ -0,0 +1,134 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.008.002.02" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:iso:std:iso:20022:tech:xsd:pain.008.002.02 pain.008.002.02.xsd">
3
+ <CstmrDrctDbtInitn>
4
+ <GrpHdr>
5
+ <MsgId>Message-ID</MsgId>
6
+ <CreDtTm>2010-11-21T09:30:47.000Z</CreDtTm>
7
+ <NbOfTxs>2</NbOfTxs>
8
+ <InitgPty>
9
+ <Nm>Initiator Name</Nm>
10
+ </InitgPty>
11
+ </GrpHdr>
12
+ <PmtInf>
13
+ <PmtInfId>Payment-ID</PmtInfId>
14
+ <PmtMtd>DD</PmtMtd>
15
+ <NbOfTxs>2</NbOfTxs>
16
+ <CtrlSum>6655.86</CtrlSum>
17
+ <PmtTpInf>
18
+ <SvcLvl>
19
+ <Cd>SEPA</Cd>
20
+ </SvcLvl>
21
+ <LclInstrm>
22
+ <Cd>CORE</Cd>
23
+ </LclInstrm>
24
+ <SeqTp>FRST</SeqTp>
25
+ </PmtTpInf>
26
+ <ReqdColltnDt>2010-12-03</ReqdColltnDt>
27
+ <Cdtr>
28
+ <Nm>Creditor Name</Nm>
29
+ </Cdtr>
30
+ <CdtrAcct>
31
+ <Id>
32
+ <IBAN>DE87200500001234567890</IBAN>
33
+ </Id>
34
+ </CdtrAcct>
35
+ <CdtrAgt>
36
+ <FinInstnId>
37
+ <BIC>BANKDEFFXXX</BIC>
38
+ </FinInstnId>
39
+ </CdtrAgt>
40
+ <ChrgBr>SLEV</ChrgBr>
41
+ <CdtrSchmeId>
42
+ <Id>
43
+ <PrvtId>
44
+ <Othr>
45
+ <Id>DE00ZZZ00099999999</Id>
46
+ <SchmeNm>
47
+ <Prtry>SEPA</Prtry>
48
+ </SchmeNm>
49
+ </Othr>
50
+ </PrvtId>
51
+ </Id>
52
+ </CdtrSchmeId>
53
+ <DrctDbtTxInf>
54
+ <PmtId>
55
+ <EndToEndId>OriginatorID1234</EndToEndId>
56
+ </PmtId>
57
+ <InstdAmt Ccy="EUR">6543.14</InstdAmt>
58
+ <DrctDbtTx>
59
+ <MndtRltdInf>
60
+ <MndtId>Mandate-Id</MndtId>
61
+ <DtOfSgntr>2010-11-20</DtOfSgntr>
62
+ <AmdmntInd>true</AmdmntInd>
63
+ <AmdmntInfDtls>
64
+ <OrgnlCdtrSchmeId>
65
+ <Nm>Original Creditor Name</Nm>
66
+ <Id>
67
+ <PrvtId>
68
+ <Othr>
69
+ <Id>AA00ZZZOriginalCreditorID</Id>
70
+ <SchmeNm>
71
+ <Prtry>SEPA</Prtry>
72
+ </SchmeNm>
73
+ </Othr>
74
+ </PrvtId>
75
+ </Id>
76
+ </OrgnlCdtrSchmeId>
77
+ </AmdmntInfDtls>
78
+ </MndtRltdInf>
79
+ </DrctDbtTx>
80
+ <DbtrAgt>
81
+ <FinInstnId>
82
+ <BIC>SPUEDE2UXXX</BIC>
83
+ </FinInstnId>
84
+ </DbtrAgt>
85
+ <Dbtr>
86
+ <Nm>Debtor Name</Nm>
87
+ </Dbtr>
88
+ <DbtrAcct>
89
+ <Id>
90
+ <IBAN>DE21500500009876543210</IBAN>
91
+ </Id>
92
+ </DbtrAcct>
93
+ <UltmtDbtr>
94
+ <Nm>Ultimate Debtor Name</Nm>
95
+ </UltmtDbtr>
96
+ <RmtInf>
97
+ <Ustrd>Unstructured Remittance Information</Ustrd>
98
+ </RmtInf>
99
+ </DrctDbtTxInf>
100
+ <DrctDbtTxInf>
101
+ <PmtId>
102
+ <EndToEndId>OriginatorID1235</EndToEndId>
103
+ </PmtId>
104
+ <InstdAmt Ccy="EUR">112.72</InstdAmt>
105
+ <DrctDbtTx>
106
+ <MndtRltdInf>
107
+ <MndtId>Other-Mandate-Id</MndtId>
108
+ <DtOfSgntr>2010-11-20</DtOfSgntr>
109
+ <AmdmntInd>false</AmdmntInd>
110
+ </MndtRltdInf>
111
+ </DrctDbtTx>
112
+ <DbtrAgt>
113
+ <FinInstnId>
114
+ <BIC>SPUEDE2UXXX</BIC>
115
+ </FinInstnId>
116
+ </DbtrAgt>
117
+ <Dbtr>
118
+ <Nm>Other Debtor Name</Nm>
119
+ </Dbtr>
120
+ <DbtrAcct>
121
+ <Id>
122
+ <IBAN>DE21500500001234567897</IBAN>
123
+ </Id>
124
+ </DbtrAcct>
125
+ <UltmtDbtr>
126
+ <Nm>Ultimate Debtor Name</Nm>
127
+ </UltmtDbtr>
128
+ <RmtInf>
129
+ <Ustrd>Unstructured Remittance Information</Ustrd>
130
+ </RmtInf>
131
+ </DrctDbtTxInf>
132
+ </PmtInf>
133
+ </CstmrDrctDbtInitn>
134
+ </Document>
@@ -0,0 +1,13 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe SEPA::Account do
5
+ it 'should initialize a new account' do
6
+ lambda{
7
+ SEPA::Account.new :name => 'Gläubiger GmbH',
8
+ :bic => 'BANKDEFFXXX',
9
+ :iban => 'DE87200500001234567890',
10
+ :identifier => 'DE98ZZZ09999999999'
11
+ }.should_not raise_error
12
+ end
13
+ end
@@ -0,0 +1,15 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe SEPA::CreditTransaction do
5
+ it 'should initialize a new transaction' do
6
+ lambda{
7
+ SEPA::CreditTransaction.new :name => 'Telekomiker AG',
8
+ :iban => 'DE37112589611964645802',
9
+ :bic => 'PBNKDEFF370',
10
+ :amount => 102.50,
11
+ :reference => 'XYZ-1234/123',
12
+ :remittance_information => 'Rechnung 123 vom 22.08.2013'
13
+ }.should_not raise_error
14
+ end
15
+ end
@@ -0,0 +1,27 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe SEPA::CreditTransferInitiation do
5
+ it 'should create valid XML file' do
6
+ cti = SEPA::CreditTransferInitiation.new :name => 'Schuldner GmbH',
7
+ :bic => 'BANKDEFFXXX',
8
+ :iban => 'DE87200500001234567890',
9
+ :identifier => 'DE98ZZZ09999999999'
10
+
11
+ cti.add_transaction :name => 'Telekomiker AG',
12
+ :iban => 'DE37112589611964645802',
13
+ :bic => 'PBNKDEFF370',
14
+ :amount => 102.50,
15
+ :reference => 'XYZ-1234/123',
16
+ :remittance_information => 'Rechnung vom 22.08.2013'
17
+
18
+ cti.add_transaction :name => 'Amazonas GmbH',
19
+ :iban => 'DE27793589132923472195',
20
+ :bic => 'TUBDDEDDXXX',
21
+ :amount => 59.00,
22
+ :reference => 'XYZ-5678/456',
23
+ :remittance_information => 'Rechnung om 21.08.2013'
24
+
25
+ XML::Document.string(cti.to_xml).should validate_against('pain.001.002.03.xsd')
26
+ end
27
+ end