ci_power 0.0.24 → 0.0.25

Sign up to get free protection for your applications and to get access to all the features.
@@ -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,166 +1,166 @@
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 installment plan record described by the +attributes+ hash
107
- def installment_plan_record(attributes)
108
- record CiPower::InstallmentPlan.new, attributes
109
- end
110
-
111
- ##
112
- # Adds a single record or an array of records to the output and increments the group number
113
- def export_customer(records)
114
- if records.is_a?(Array)
115
- records.each do |record|
116
- add_to_output record
117
- end
118
- else
119
- add_to_output records
120
- end
121
- increment_group_no
122
- records
123
- end
124
-
125
- ##
126
- # Adds a single record or an array of records as a new line to the file and increments the group number
127
- def export_to_file(file, records)
128
- if records.is_a?(Array)
129
- records.each do |record|
130
- raise "Export class must be sub class of CiPower::Record" unless record.kind_of? CiPower::Record
131
- file.puts record.to_cip
132
- end
133
- else
134
- raise "Export class must be sub class of CiPower::Record" unless records.kind_of? CiPower::Record
135
- file.puts records.to_cip
136
- end
137
- increment_group_no
138
- end
139
-
140
- ##
141
- # Converts a date or time into a string with the defined date_format
142
- def convert_date(date)
143
- date.strftime(date_format) if date.respond_to?(:strftime)
144
- end
145
-
146
- private
147
- def add_to_output(record)
148
- raise "Export class must be sub class of CiPower::Record" unless record.kind_of? CiPower::Record
149
- output << record
150
- end
151
-
152
- def record(record, attributes)
153
- attributes.merge! :group_no => group_no
154
- attributes.each do |key, value|
155
- method_name = "#{key}=".to_sym
156
- record.send(method_name, value) if record.respond_to? method_name
157
- end
158
- record
159
- end
160
-
161
- def increment_group_no
162
- @group_no = group_no + 1
163
- end
164
-
165
- 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 installment plan record described by the +attributes+ hash
107
+ def installment_plan_record(attributes)
108
+ record CiPower::InstallmentPlan.new, attributes
109
+ end
110
+
111
+ ##
112
+ # Adds a single record or an array of records to the output and increments the group number
113
+ def export_customer(records)
114
+ if records.is_a?(Array)
115
+ records.each do |record|
116
+ add_to_output record
117
+ end
118
+ else
119
+ add_to_output records
120
+ end
121
+ increment_group_no
122
+ records
123
+ end
124
+
125
+ ##
126
+ # Adds a single record or an array of records as a new line to the file and increments the group number
127
+ def export_to_file(file, records)
128
+ if records.is_a?(Array)
129
+ records.each do |record|
130
+ raise "Export class must be sub class of CiPower::Record" unless record.kind_of? CiPower::Record
131
+ file.puts record.to_cip
132
+ end
133
+ else
134
+ raise "Export class must be sub class of CiPower::Record" unless records.kind_of? CiPower::Record
135
+ file.puts records.to_cip
136
+ end
137
+ increment_group_no
138
+ end
139
+
140
+ ##
141
+ # Converts a date or time into a string with the defined date_format
142
+ def convert_date(date)
143
+ date.strftime(date_format) if date.respond_to?(:strftime)
144
+ end
145
+
146
+ private
147
+ def add_to_output(record)
148
+ raise "Export class must be sub class of CiPower::Record" unless record.kind_of? CiPower::Record
149
+ output << record
150
+ end
151
+
152
+ def record(record, attributes)
153
+ attributes.merge! :group_no => group_no
154
+ attributes.each do |key, value|
155
+ method_name = "#{key}=".to_sym
156
+ record.send(method_name, value) if record.respond_to? method_name
157
+ end
158
+ record
159
+ end
160
+
161
+ def increment_group_no
162
+ @group_no = group_no + 1
163
+ end
164
+
165
+ end
166
166
  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
@@ -1,22 +1,46 @@
1
- module CiPower
2
- class OpenAppointment < Record
3
- attr_accessor :action
4
-
5
- def initialize(attributes = {})
6
- if attributes.is_a? Hash
7
- attributes.merge! :record_type => '18'
8
- attributes.each do |key, value|
9
- self.send("#{key}=".to_sym, value) if self.respond_to?("#{key}=")
10
- end
11
- end
12
- end
13
-
14
- def to_cip(with_line_terminator = true)
15
- cip_default_data << fill_up(
16
- {
17
- :action => 10
18
- }, with_line_terminator
19
- )
20
- end
21
- end
1
+ module CiPower
2
+ class OpenAppointment < Record
3
+ attr_accessor :action,
4
+ :execute_date,
5
+ :execute_mkz_date,
6
+ :planned_date,
7
+ :planned_mkz_date,
8
+ :mutable,
9
+ :comment,
10
+ :customer_specific_field_1,
11
+ :customer_specific_field_2,
12
+ :customer_specific_field_3,
13
+ :customer_specific_field_4,
14
+ :customer_specific_field_5,
15
+ :cip_dossier_no
16
+
17
+ def initialize(attributes = {})
18
+ if attributes.is_a? Hash
19
+ attributes.merge! :record_type => '18'
20
+ attributes.each do |key, value|
21
+ self.send("#{key}=".to_sym, value) if self.respond_to?("#{key}=")
22
+ end
23
+ end
24
+ end
25
+
26
+ def to_cip(with_line_terminator = true)
27
+ cip_default_data << fill_up(
28
+ {
29
+ :action => 10,
30
+ :execute_date => 10,
31
+ :execute_mkz_date => 10,
32
+ :planned_date => 10,
33
+ :planned_mkz_date => 10,
34
+ :mutable => 1,
35
+ :comment => 240,
36
+ :customer_specific_field_1 => 10,
37
+ :customer_specific_field_2 => 10,
38
+ :customer_specific_field_3 => 10,
39
+ :customer_specific_field_4 => 32,
40
+ :customer_specific_field_5 => 32,
41
+ :cip_dossier_no => 9
42
+ }, with_line_terminator
43
+ )
44
+ end
45
+ end
22
46
  end