ci_power 0.0.26 → 0.0.27

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.
@@ -1,94 +1,94 @@
1
- module CiPower
2
- class DossierData < Record
3
- attr_accessor :debt_claim_reason,
4
- :reference_1,
5
- :ikv,
6
- :feature_1,
7
- :feature_2,
8
- :interest_rate,
9
- :currency,
10
- :notes,
11
- :external_dossier_no,
12
- :reference_2,
13
- :reference_3,
14
- :reference_4,
15
- :customer_specific_field_1,
16
- :customer_specific_field_2,
17
- :customer_specific_field_3,
18
- :customer_specific_field_4,
19
- :customer_specific_field_5,
20
- :customer_specific_field_6,
21
- :customer_specific_field_7,
22
- :customer_specific_field_8,
23
- :customer_specific_field_9,
24
- :customer_specific_field_10,
25
- :customer_specific_field_11,
26
- :customer_specific_field_12,
27
- :customer_specific_field_13,
28
- :customer_specific_field_14,
29
- :customer_specific_field_15,
30
- :customer_specific_field_16,
31
- :customer_specific_field_17,
32
- :customer_specific_field_18,
33
- :customer_specific_field_19,
34
- :customer_specific_field_20
35
-
36
- # placeholder attributes
37
- attr_reader :fill_up1, :fill_up2, :fill_up3
38
-
39
- def initialize(attributes = {})
40
- if attributes.is_a? Hash
41
- attributes.merge! :record_type => '10'
42
- attributes.each do |key, value|
43
- self.send("#{key}=".to_sym, value) if self.respond_to?("#{key}=")
44
- end
45
- end
46
- end
47
-
48
- def to_cip(with_line_terminator = true)
49
- fill_up(
50
- {
51
- :record_type => 2,
52
- :group_no => 7,
53
- :address_identification_debtee => 25,
54
- :fill_up1 => 25,
55
- :address_identification_debtor => 25,
56
- :debt_claim_reason => 64,
57
- :reference_1 => 32,
58
- :ikv => 10,
59
- :feature_1 => 10,
60
- :fill_up2 => 22,
61
- :feature_2 => 10,
62
- :fill_up3 => 22,
63
- :interest_rate => 10,
64
- :currency => 10,
65
- :notes => 240,
66
- :external_dossier_no => 32,
67
- :reference_2 => 32,
68
- :reference_3 => 32,
69
- :reference_4 => 32,
70
- :customer_specific_field_1 => 10,
71
- :customer_specific_field_2 => 10,
72
- :customer_specific_field_3 => 10,
73
- :customer_specific_field_4 => 32,
74
- :customer_specific_field_5 => 32,
75
- :customer_specific_field_6 => 32,
76
- :customer_specific_field_7 => 32,
77
- :customer_specific_field_8 => 32,
78
- :customer_specific_field_9 => 32,
79
- :customer_specific_field_10 => 32,
80
- :customer_specific_field_11 => 32,
81
- :customer_specific_field_12 => 32,
82
- :customer_specific_field_13 => 32,
83
- :customer_specific_field_14 => 32,
84
- :customer_specific_field_15 => 32,
85
- :customer_specific_field_16 => 32,
86
- :customer_specific_field_17 => 32,
87
- :customer_specific_field_18 => 32,
88
- :customer_specific_field_19 => 32,
89
- :customer_specific_field_20 => 32
90
- }, with_line_terminator
91
- )
92
- end
93
- end
1
+ module CiPower
2
+ class DossierData < Record
3
+ attr_accessor :debt_claim_reason,
4
+ :reference_1,
5
+ :ikv,
6
+ :feature_1,
7
+ :feature_2,
8
+ :interest_rate,
9
+ :currency,
10
+ :notes,
11
+ :external_dossier_no,
12
+ :reference_2,
13
+ :reference_3,
14
+ :reference_4,
15
+ :customer_specific_field_1,
16
+ :customer_specific_field_2,
17
+ :customer_specific_field_3,
18
+ :customer_specific_field_4,
19
+ :customer_specific_field_5,
20
+ :customer_specific_field_6,
21
+ :customer_specific_field_7,
22
+ :customer_specific_field_8,
23
+ :customer_specific_field_9,
24
+ :customer_specific_field_10,
25
+ :customer_specific_field_11,
26
+ :customer_specific_field_12,
27
+ :customer_specific_field_13,
28
+ :customer_specific_field_14,
29
+ :customer_specific_field_15,
30
+ :customer_specific_field_16,
31
+ :customer_specific_field_17,
32
+ :customer_specific_field_18,
33
+ :customer_specific_field_19,
34
+ :customer_specific_field_20
35
+
36
+ # placeholder attributes
37
+ attr_reader :fill_up1, :fill_up2, :fill_up3
38
+
39
+ def initialize(attributes = {})
40
+ if attributes.is_a? Hash
41
+ attributes.merge! :record_type => '10'
42
+ attributes.each do |key, value|
43
+ self.send("#{key}=".to_sym, value) if self.respond_to?("#{key}=")
44
+ end
45
+ end
46
+ end
47
+
48
+ def to_cip(with_line_terminator = true)
49
+ fill_up(
50
+ {
51
+ :record_type => 2,
52
+ :group_no => 7,
53
+ :address_identification_debtee => 25,
54
+ :fill_up1 => 25,
55
+ :address_identification_debtor => 25,
56
+ :debt_claim_reason => 64,
57
+ :reference_1 => 32,
58
+ :ikv => 10,
59
+ :feature_1 => 10,
60
+ :fill_up2 => 22,
61
+ :feature_2 => 10,
62
+ :fill_up3 => 22,
63
+ :interest_rate => 10,
64
+ :currency => 10,
65
+ :notes => 240,
66
+ :external_dossier_no => 32,
67
+ :reference_2 => 32,
68
+ :reference_3 => 32,
69
+ :reference_4 => 32,
70
+ :customer_specific_field_1 => 10,
71
+ :customer_specific_field_2 => 10,
72
+ :customer_specific_field_3 => 10,
73
+ :customer_specific_field_4 => 32,
74
+ :customer_specific_field_5 => 32,
75
+ :customer_specific_field_6 => 32,
76
+ :customer_specific_field_7 => 32,
77
+ :customer_specific_field_8 => 32,
78
+ :customer_specific_field_9 => 32,
79
+ :customer_specific_field_10 => 32,
80
+ :customer_specific_field_11 => 32,
81
+ :customer_specific_field_12 => 32,
82
+ :customer_specific_field_13 => 32,
83
+ :customer_specific_field_14 => 32,
84
+ :customer_specific_field_15 => 32,
85
+ :customer_specific_field_16 => 32,
86
+ :customer_specific_field_17 => 32,
87
+ :customer_specific_field_18 => 32,
88
+ :customer_specific_field_19 => 32,
89
+ :customer_specific_field_20 => 32
90
+ }, with_line_terminator
91
+ )
92
+ end
93
+ end
94
94
  end
@@ -1,172 +1,172 @@
1
- module CiPower
2
- ##
3
- # The module Export can be used to convert models into CI-Power-Interface format. It can be used as mixin in every
4
- # existing class.
5
- #
6
- # == Example
7
- # <tt>
8
- # class Foo
9
- # include CiPower::Export
10
- #
11
- # def add_to_cip(data)
12
- # export_customer(
13
- # [address_record(data), dossier_data_record(data), debt_claim_record(data)]
14
- # )
15
- # end
16
- #
17
- # def output_cip
18
- # output.each do |record|
19
- # puts record.to_cip
20
- # end
21
- # end
22
- # end
23
- # </tt>
24
- module Export
25
- attr :output
26
- attr :group_no
27
- attr :date_format, true
28
-
29
- ##
30
- # Returns the all added records or an empty array. To add records to the
31
- # output use the method export_customer.
32
- def output
33
- @output ||= []
34
- end
35
-
36
- ##
37
- # Returns the all added records sorted by group number and record type or an empty array.
38
-
39
- def ordered_output
40
- output.sort { |rec1, rec2| "#{rec1.group_no}#{rec1.record_type}".to_i <=> "#{rec2.group_no}#{rec2.record_type}".to_i }
41
- end
42
-
43
- ##
44
- # Returns the group number or default value 0. The method export_customer increments this group number
45
- # by one on every call.
46
- def group_no
47
- @group_no ||= 0
48
- end
49
-
50
- ##
51
- # Returns the date_format. If no date_format is defined the default date_format %Y%m%d is returned.
52
- # This date_format is used to convert a date, time or datetime into a string.
53
- def date_format
54
- @date_format ||= '%Y%m%d'
55
- end
56
-
57
- ##
58
- # Sets the date_format. This date_format is used to convert a date, time or datetime into a string.
59
- def date_format=(date_format)
60
- @date_format = date_format
61
- end
62
-
63
- ##
64
- # Creates a new dossier data record described by the +attributes+ hash
65
- def dossier_data_record(attributes)
66
- record CiPower::DossierData.new, attributes
67
- end
68
-
69
- ##
70
- # Creates a new address record described by the +attributes+ hash
71
- def address_record(attributes)
72
- record CiPower::Address.new, attributes
73
- end
74
-
75
- ##
76
- # Creates a new communication record described by the +attributes+ hash
77
- def communication_record(attributes)
78
- record CiPower::Communication.new, attributes
79
- end
80
-
81
- ##
82
- # Creates a debtor data address record described by the +attributes+ hash
83
- def debtor_data_record(attributes)
84
- record CiPower::DebtorData.new, attributes
85
- end
86
-
87
- ##
88
- # Creates a new debt claim record described by the +attributes+ hash
89
- def debt_claim_record(attributes)
90
- record CiPower::DebtClaim.new, attributes
91
- end
92
-
93
- ##
94
- # Creates a new action record described by the +attributes+ hash
95
- def action_record(attributes)
96
- record CiPower::Action.new, attributes
97
- end
98
-
99
- ##
100
- # Creates a new open appointment record described by the +attributes+ hash
101
- def open_appointment_record(attributes)
102
- record CiPower::OpenAppointment.new, attributes
103
- end
104
-
105
- ##
106
- # Creates a new open appointment record described by the +attributes+ hash
107
- def process_data_record(attributes)
108
- record CiPower::ProcessData.new, attributes
109
- end
110
-
111
- ##
112
- # Creates a new installment plan record described by the +attributes+ hash
113
- def installment_plan_record(attributes)
114
- record CiPower::InstallmentPlan.new, attributes
115
- end
116
-
117
- ##
118
- # Adds a single record or an array of records to the output and increments the group number
119
- def export_customer(records)
120
- if records.is_a?(Array)
121
- records.each do |record|
122
- add_to_output record
123
- end
124
- else
125
- add_to_output records
126
- end
127
- increment_group_no
128
- records
129
- end
130
-
131
- ##
132
- # Adds a single record or an array of records as a new line to the file and increments the group number
133
- def export_to_file(file, records)
134
- if records.is_a?(Array)
135
- records.each do |record|
136
- raise "Export class must be sub class of CiPower::Record" unless record.kind_of? CiPower::Record
137
- file.puts record.to_cip
138
- end
139
- else
140
- raise "Export class must be sub class of CiPower::Record" unless records.kind_of? CiPower::Record
141
- file.puts records.to_cip
142
- end
143
- increment_group_no
144
- end
145
-
146
- ##
147
- # Converts a date or time into a string with the defined date_format
148
- def convert_date(date)
149
- date.strftime(date_format) if date.respond_to?(:strftime)
150
- end
151
-
152
- private
153
- def add_to_output(record)
154
- raise "Export class must be sub class of CiPower::Record" unless record.kind_of? CiPower::Record
155
- output << record
156
- end
157
-
158
- def record(record, attributes)
159
- attributes.merge! :group_no => group_no
160
- attributes.each do |key, value|
161
- method_name = "#{key}=".to_sym
162
- record.send(method_name, value) if record.respond_to? method_name
163
- end
164
- record
165
- end
166
-
167
- def increment_group_no
168
- @group_no = group_no + 1
169
- end
170
-
171
- end
1
+ module CiPower
2
+ ##
3
+ # The module Export can be used to convert models into CI-Power-Interface format. It can be used as mixin in every
4
+ # existing class.
5
+ #
6
+ # == Example
7
+ # <tt>
8
+ # class Foo
9
+ # include CiPower::Export
10
+ #
11
+ # def add_to_cip(data)
12
+ # export_customer(
13
+ # [address_record(data), dossier_data_record(data), debt_claim_record(data)]
14
+ # )
15
+ # end
16
+ #
17
+ # def output_cip
18
+ # output.each do |record|
19
+ # puts record.to_cip
20
+ # end
21
+ # end
22
+ # end
23
+ # </tt>
24
+ module Export
25
+ attr :output
26
+ attr :group_no
27
+ attr :date_format, true
28
+
29
+ ##
30
+ # Returns the all added records or an empty array. To add records to the
31
+ # output use the method export_customer.
32
+ def output
33
+ @output ||= []
34
+ end
35
+
36
+ ##
37
+ # Returns the all added records sorted by group number and record type or an empty array.
38
+
39
+ def ordered_output
40
+ output.sort { |rec1, rec2| "#{rec1.group_no}#{rec1.record_type}".to_i <=> "#{rec2.group_no}#{rec2.record_type}".to_i }
41
+ end
42
+
43
+ ##
44
+ # Returns the group number or default value 0. The method export_customer increments this group number
45
+ # by one on every call.
46
+ def group_no
47
+ @group_no ||= 0
48
+ end
49
+
50
+ ##
51
+ # Returns the date_format. If no date_format is defined the default date_format %Y%m%d is returned.
52
+ # This date_format is used to convert a date, time or datetime into a string.
53
+ def date_format
54
+ @date_format ||= '%Y%m%d'
55
+ end
56
+
57
+ ##
58
+ # Sets the date_format. This date_format is used to convert a date, time or datetime into a string.
59
+ def date_format=(date_format)
60
+ @date_format = date_format
61
+ end
62
+
63
+ ##
64
+ # Creates a new dossier data record described by the +attributes+ hash
65
+ def dossier_data_record(attributes)
66
+ record CiPower::DossierData.new, attributes
67
+ end
68
+
69
+ ##
70
+ # Creates a new address record described by the +attributes+ hash
71
+ def address_record(attributes)
72
+ record CiPower::Address.new, attributes
73
+ end
74
+
75
+ ##
76
+ # Creates a new communication record described by the +attributes+ hash
77
+ def communication_record(attributes)
78
+ record CiPower::Communication.new, attributes
79
+ end
80
+
81
+ ##
82
+ # Creates a debtor data address record described by the +attributes+ hash
83
+ def debtor_data_record(attributes)
84
+ record CiPower::DebtorData.new, attributes
85
+ end
86
+
87
+ ##
88
+ # Creates a new debt claim record described by the +attributes+ hash
89
+ def debt_claim_record(attributes)
90
+ record CiPower::DebtClaim.new, attributes
91
+ end
92
+
93
+ ##
94
+ # Creates a new action record described by the +attributes+ hash
95
+ def action_record(attributes)
96
+ record CiPower::Action.new, attributes
97
+ end
98
+
99
+ ##
100
+ # Creates a new open appointment record described by the +attributes+ hash
101
+ def open_appointment_record(attributes)
102
+ record CiPower::OpenAppointment.new, attributes
103
+ end
104
+
105
+ ##
106
+ # Creates a new open appointment record described by the +attributes+ hash
107
+ def process_data_record(attributes)
108
+ record CiPower::ProcessData.new, attributes
109
+ end
110
+
111
+ ##
112
+ # Creates a new installment plan record described by the +attributes+ hash
113
+ def installment_plan_record(attributes)
114
+ record CiPower::InstallmentPlan.new, attributes
115
+ end
116
+
117
+ ##
118
+ # Adds a single record or an array of records to the output and increments the group number
119
+ def export_customer(records)
120
+ if records.is_a?(Array)
121
+ records.each do |record|
122
+ add_to_output record
123
+ end
124
+ else
125
+ add_to_output records
126
+ end
127
+ increment_group_no
128
+ records
129
+ end
130
+
131
+ ##
132
+ # Adds a single record or an array of records as a new line to the file and increments the group number
133
+ def export_to_file(file, records)
134
+ if records.is_a?(Array)
135
+ records.each do |record|
136
+ raise "Export class must be sub class of CiPower::Record" unless record.kind_of? CiPower::Record
137
+ file.puts record.to_cip
138
+ end
139
+ else
140
+ raise "Export class must be sub class of CiPower::Record" unless records.kind_of? CiPower::Record
141
+ file.puts records.to_cip
142
+ end
143
+ increment_group_no
144
+ end
145
+
146
+ ##
147
+ # Converts a date or time into a string with the defined date_format
148
+ def convert_date(date)
149
+ date.strftime(date_format) if date.respond_to?(:strftime)
150
+ end
151
+
152
+ private
153
+ def add_to_output(record)
154
+ raise "Export class must be sub class of CiPower::Record" unless record.kind_of? CiPower::Record
155
+ output << record
156
+ end
157
+
158
+ def record(record, attributes)
159
+ attributes.merge! :group_no => group_no
160
+ attributes.each do |key, value|
161
+ method_name = "#{key}=".to_sym
162
+ record.send(method_name, value) if record.respond_to? method_name
163
+ end
164
+ record
165
+ end
166
+
167
+ def increment_group_no
168
+ @group_no = group_no + 1
169
+ end
170
+
171
+ end
172
172
  end
@@ -1,40 +1,40 @@
1
- module CiPower
2
- class InstallmentPlan < Record
3
- attr_accessor :no_of_installments,
4
- :installment_amount,
5
- :first_installment_date,
6
- :period,
7
- :interval,
8
- :installment_fee,
9
- :fixed_size_installment_amount,
10
- :last_installment_date
11
-
12
- def initialize(attributes = {})
13
- if attributes.is_a? Hash
14
- attributes.merge! :record_type => '15'
15
- attributes.each do |key, value|
16
- self.send("#{key}=".to_sym, value) if self.respond_to?("#{key}=")
17
- end
18
- end
19
- end
20
-
21
- def to_cip(with_line_terminator = true)
22
- fill_up(
23
- {
24
- :record_type => 2,
25
- :group_no => 7,
26
- :address_identification_debtee => 25,
27
- :address_identification_debtor => 25,
28
- :no_of_installments => 3,
29
- :installment_amount => 15,
30
- :first_installment_date => 10,
31
- :period => 10,
32
- :interval => 3,
33
- :installment_fee => 15,
34
- :fixed_size_installment_amount => 1,
35
- :last_installment_date => 10
36
- }, with_line_terminator
37
- )
38
- end
39
- end
1
+ module CiPower
2
+ class InstallmentPlan < Record
3
+ attr_accessor :no_of_installments,
4
+ :installment_amount,
5
+ :first_installment_date,
6
+ :period,
7
+ :interval,
8
+ :installment_fee,
9
+ :fixed_size_installment_amount,
10
+ :last_installment_date
11
+
12
+ def initialize(attributes = {})
13
+ if attributes.is_a? Hash
14
+ attributes.merge! :record_type => '15'
15
+ attributes.each do |key, value|
16
+ self.send("#{key}=".to_sym, value) if self.respond_to?("#{key}=")
17
+ end
18
+ end
19
+ end
20
+
21
+ def to_cip(with_line_terminator = true)
22
+ fill_up(
23
+ {
24
+ :record_type => 2,
25
+ :group_no => 7,
26
+ :address_identification_debtee => 25,
27
+ :address_identification_debtor => 25,
28
+ :no_of_installments => 3,
29
+ :installment_amount => 15,
30
+ :first_installment_date => 10,
31
+ :period => 10,
32
+ :interval => 3,
33
+ :installment_fee => 15,
34
+ :fixed_size_installment_amount => 1,
35
+ :last_installment_date => 10
36
+ }, with_line_terminator
37
+ )
38
+ end
39
+ end
40
40
  end