tufy 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 673fb6de3058724fa7ade8921263bfbc8501777d
4
- data.tar.gz: 55f6f30f18b8c0e7837e76fa183de304077e8fc4
3
+ metadata.gz: 8ebf4890dfa5545659b7b844ca375317c5b4f904
4
+ data.tar.gz: aea3aad28224881692d6873c2640b707490dfaea
5
5
  SHA512:
6
- metadata.gz: 31e747d42e48a4764ffc7621b3c1b641622ee660d75c32c319a717cf27c72f55668a09050e14614a88aa45725e8332e391f74468020fade47264f75b95378c16
7
- data.tar.gz: 4b9dd23a12cb12bec37f1e5543796f56eb171ab677605a95d3bc0b6e5159fdea6c0dddc05148ae986d1605d4fe523363836a340a230adf1298a2206a5a10a7c4
6
+ metadata.gz: 7f39976fc5d185576be115a4546b809d81a2cb185cdf1d1e10c8b21f7cd60eee289cb023e1a03f72fa13f4cd60e7640f86de09fdd57ed0f7241522e35d97f93d
7
+ data.tar.gz: f5a2c532844cc771dd10fe0d2cb819809bf00ea8bdbde9bbeb47a54aec7616f23de38309906d1d040f6c5460506ecb75858a886787d2158fd0ed502b7fa2698a
@@ -1,3 +1,14 @@
1
+ # v0.0.9
2
+
3
+ - Fix Address segment tag
4
+ - Fix Email Address segment tag
5
+ - Add Contact number type field
6
+ - Do not remove spaces from the address
7
+ - Pad the `account_number` and `restructured_account_number` with leading zeros
8
+ - Zero if outstanding_balance is negative
9
+ - "0000000000" if `contact_number` is `.empty?`
10
+ - Make the reported date field not required
11
+
1
12
  # v0.0.8
2
13
 
3
14
  - PARTIAL PAYMENT is now an optional field
@@ -17,6 +17,7 @@ require "tufy/build_record"
17
17
  require "tufy/transform_raw_data"
18
18
  require "tufy/transform_raw_data_array"
19
19
  require "tufy/build_field.rb"
20
+ require "tufy/fields/account/build_segment_tag_field.rb"
20
21
  require "tufy/fields/account/build_account_number_field.rb"
21
22
  require "tufy/fields/account/build_account_status_field.rb"
22
23
  require "tufy/fields/account/build_account_type_field.rb"
@@ -48,6 +49,7 @@ require "tufy/fields/address/build_address_2_field.rb"
48
49
  require "tufy/fields/address/build_address_type_field.rb"
49
50
  require "tufy/fields/contact_number/build_contact_number_field.rb"
50
51
  require "tufy/fields/contact_number/build_contact_number_format_field.rb"
52
+ require "tufy/fields/contact_number/build_contact_number_type_field.rb"
51
53
  require "tufy/fields/email_address/build_email_address_field.rb"
52
54
  require "tufy/fields/id/build_id_number_field.rb"
53
55
  require "tufy/fields/id/build_id_type_field.rb"
@@ -11,7 +11,6 @@ module Tufy
11
11
  :currency_code,
12
12
  :opened_date,
13
13
  :payment_amount,
14
- :closed_date,
15
14
  :credit_limit_or_loan_amount,
16
15
  :shared_by,
17
16
  :outstanding_balance,
@@ -28,7 +27,7 @@ module Tufy
28
27
 
29
28
  executed do |ctx|
30
29
  validate_presence_of_required_keys(ctx.raw_data, REQUIRED_KEYS)
31
- ctx.transformed_data = ctx.transformed_data + transform(ctx).upcase
30
+ ctx.transformed_data = transform(ctx).upcase
32
31
  end
33
32
 
34
33
  def self.past_due_code(days_past_due)
@@ -45,7 +44,10 @@ module Tufy
45
44
  private
46
45
 
47
46
  def self.transform(ctx)
47
+ ctx[:segment_tag] = Constants::SEGMENT_TAG
48
+
48
49
  result = with(ctx).reduce(
50
+ Fields::BuildSegmentTagField,
49
51
  Fields::Account::BuildAccountNumberField,
50
52
  Fields::Account::BuildRestructuredAccountNumberField,
51
53
  Fields::Account::BuildUserIdField,
@@ -74,7 +76,7 @@ module Tufy
74
76
  Fields::Account::BuildFreshCashAdvanceField,
75
77
  )
76
78
 
77
- Constants::SEGMENT_TAG + result[:transformed_data]
79
+ result[:transformed_data]
78
80
  end
79
81
 
80
82
  module Constants
@@ -11,26 +11,27 @@ module Tufy
11
11
 
12
12
  executed do |ctx|
13
13
  validate_presence_of_required_keys(ctx.raw_data, REQUIRED_KEYS)
14
- ctx.transformed_data = ctx.transformed_data + transform(ctx).upcase
14
+ ctx.transformed_data = transform(ctx).upcase
15
15
  end
16
16
 
17
17
  private
18
18
 
19
19
  def self.transform(ctx)
20
- raw_data = ctx[:raw_data]
20
+ ctx[:segment_tag] = Constants::SEGMENT_TAG
21
21
 
22
22
  result = with(ctx).reduce(
23
+ Fields::BuildSegmentTagField,
23
24
  Fields::Address::BuildAddress1Field,
24
25
  Fields::Address::BuildAddress2Field,
25
26
  Fields::Address::BuildAddressTypeField,
26
27
  )
27
28
 
28
- Constants::SEGMENT_TAG + result[:transformed_data]
29
+ result[:transformed_data]
29
30
  end
30
31
 
31
32
  module Constants
32
33
  # tags
33
- SEGMENT_TAG = "AL03A01"
34
+ SEGMENT_TAG = "PA03A01"
34
35
  ADDRESS_LINE_1_TAG = "01"
35
36
  ADDRESS_LINE_2_TAG = "02"
36
37
  ADDRESS_TYPE_TAG = "07"
@@ -6,24 +6,27 @@ module Tufy
6
6
  REQUIRED_KEYS = [
7
7
  :contact_number,
8
8
  :contact_number_format,
9
+ :contact_number_type,
9
10
  ]
10
11
 
11
12
  executed do |ctx|
12
13
  validate_presence_of_required_keys(ctx.raw_data, REQUIRED_KEYS)
13
- ctx.transformed_data = ctx.transformed_data + transform(ctx).upcase
14
+ ctx.transformed_data = transform(ctx).upcase
14
15
  end
15
16
 
16
17
  private
17
18
 
18
19
  def self.transform(ctx)
19
- raw_data = ctx[:raw_data]
20
+ ctx[:segment_tag] = Constants::SEGMENT_TAG
20
21
 
21
22
  result = with(ctx).reduce(
23
+ Fields::BuildSegmentTagField,
22
24
  Fields::ContactNumber::BuildContactNumberField,
23
25
  Fields::ContactNumber::BuildContactNumberFormatField,
26
+ Fields::ContactNumber::BuildContactNumberTypeField,
24
27
  )
25
28
 
26
- Constants::SEGMENT_TAG + result[:transformed_data]
29
+ result[:transformed_data]
27
30
  end
28
31
 
29
32
  module Constants
@@ -31,10 +34,17 @@ module Tufy
31
34
  SEGMENT_TAG = "PH03P01"
32
35
  CONTACT_NUMBER_TAG = "03"
33
36
  CONTACT_NUMBER_FORMAT_TAG = "05"
37
+ CONTACT_NUMBER_TYPE_TAG = "06"
34
38
 
35
39
  # contact number format constants
36
40
  FREE_FORMAT = "F"
37
41
  STRUCTURED_FORMAT = "S"
42
+
43
+ RESIDENTIAL = "R"
44
+ OFFICE = "O"
45
+ MOBILE = "M"
46
+ CORRESPONDENCE_OR_CONTACT = "C"
47
+ UNKNOWN = "U"
38
48
  end
39
49
  end
40
50
  end
@@ -9,22 +9,25 @@ module Tufy
9
9
 
10
10
  executed do |ctx|
11
11
  validate_presence_of_required_keys(ctx.raw_data, REQUIRED_KEYS)
12
- ctx.transformed_data = ctx.transformed_data + transform(ctx).upcase
12
+ ctx.transformed_data = transform(ctx).upcase
13
13
  end
14
14
 
15
15
  private
16
16
 
17
17
  def self.transform(ctx)
18
- raw_data = ctx[:raw_data]
18
+ ctx[:segment_tag] = Constants::SEGMENT_TAG
19
19
 
20
- result = Fields::EmailAddress::BuildEmailAddressField.execute(ctx)
20
+ result = with(ctx).reduce(
21
+ Fields::BuildSegmentTagField,
22
+ Fields::EmailAddress::BuildEmailAddressField,
23
+ )
21
24
 
22
- Constants::SEGMENT_TAG + result[:transformed_data]
25
+ result[:transformed_data]
23
26
  end
24
27
 
25
28
  module Constants
26
29
  # tags
27
- SEGMENT_TAG = "ID03I01"
30
+ SEGMENT_TAG = "EA03E01"
28
31
  EMAIL_ADDRESS_TAG = "01"
29
32
  end
30
33
  end
@@ -14,5 +14,9 @@ module Tufy
14
14
  def self.remove_special_characters(string)
15
15
  string.gsub(/[^0-9A-Za-z]/, '')
16
16
  end
17
+
18
+ def self.remove_special_characters_except_space(string)
19
+ string.gsub(/[^0-9A-Za-z. ]/, '')
20
+ end
17
21
  end
18
22
  end
@@ -15,21 +15,22 @@ module Tufy
15
15
  # TODO: Testing
16
16
  validate_presence_of_required_keys(ctx.raw_data, REQUIRED_KEYS)
17
17
  if id_type_exists?(ctx.raw_data[:id_type])
18
- ctx.transformed_data = ctx.transformed_data + transform(ctx).upcase
18
+ ctx.transformed_data = transform(ctx).upcase
19
19
  end
20
20
  end
21
21
 
22
22
  private
23
23
 
24
24
  def self.transform(ctx)
25
- raw_data = ctx[:raw_data]
25
+ ctx[:segment_tag] = Constants::SEGMENT_TAG
26
26
 
27
27
  result = with(ctx).reduce(
28
+ Fields::BuildSegmentTagField,
28
29
  Fields::Id::BuildIdNumberField,
29
30
  Fields::Id::BuildIdTypeField,
30
31
  )
31
32
 
32
- Constants::SEGMENT_TAG + result[:transformed_data]
33
+ result[:transformed_data]
33
34
  end
34
35
 
35
36
  def self.id_type_exists?(id_type)
@@ -14,15 +14,16 @@ module Tufy
14
14
 
15
15
  executed do |ctx|
16
16
  validate_presence_of_required_keys(ctx.raw_data, REQUIRED_KEYS)
17
- ctx.transformed_data = ctx.transformed_data + transform(ctx).upcase
17
+ ctx.transformed_data = transform(ctx).upcase
18
18
  end
19
19
 
20
20
  private
21
21
 
22
22
  def self.transform(ctx)
23
- raw_data = ctx[:raw_data]
23
+ ctx[:segment_tag] = Constants::SEGMENT_TAG
24
24
 
25
25
  result = with(ctx).reduce(
26
+ Fields::BuildSegmentTagField,
26
27
  Fields::Name::BuildFirstNameField,
27
28
  Fields::Name::BuildLastNameField,
28
29
  Fields::Name::BuildCivilStatusField,
@@ -31,7 +32,7 @@ module Tufy
31
32
  Fields::Name::BuildAcHolderTypeField,
32
33
  )
33
34
 
34
- Constants::SEGMENT_TAG + result[:transformed_data]
35
+ result[:transformed_data]
35
36
  end
36
37
 
37
38
  module Constants
@@ -17,8 +17,8 @@ module Tufy
17
17
  raw_data = ctx.raw_data
18
18
 
19
19
  BuildAccountSegment::Constants::ACCOUNT_NUMBER_TAG +
20
- FormatStrings::F2TS % raw_data[:account_number].to_s.size +
21
- raw_data[:account_number].to_s
20
+ FormatStrings::F2TS % (FormatStrings::F20TS % raw_data[:account_number]).to_s.size +
21
+ FormatStrings::F20TS % raw_data[:account_number].to_s
22
22
  end
23
23
  end
24
24
  end
@@ -6,9 +6,11 @@ module Tufy
6
6
  promises :transformed_data
7
7
 
8
8
  executed do |ctx|
9
- ctx.transformed_data =
10
- ctx.transformed_data +
11
- transform(ctx).upcase
9
+ if ctx.raw_data[:closed_date]
10
+ ctx.transformed_data =
11
+ ctx.transformed_data +
12
+ transform(ctx).upcase
13
+ end
12
14
  end
13
15
 
14
16
  private
@@ -16,9 +16,12 @@ module Tufy
16
16
  def self.transform(ctx)
17
17
  raw_data = ctx.raw_data
18
18
 
19
+ outstanding_balance = raw_data[:outstanding_balance].to_i
20
+ outstanding_balance = outstanding_balance < 0 ? 0 : outstanding_balance
21
+
19
22
  BuildAccountSegment::Constants::OUTSTANDING_BALANCE_TAG +
20
- FormatStrings::F2TS % raw_data[:outstanding_balance].to_i.to_s.size +
21
- raw_data[:outstanding_balance].to_i.to_s
23
+ FormatStrings::F2TS % outstanding_balance.to_s.size +
24
+ outstanding_balance.to_s
22
25
  end
23
26
  end
24
27
  end
@@ -6,9 +6,11 @@ module Tufy
6
6
  promises :transformed_data
7
7
 
8
8
  executed do |ctx|
9
- ctx.transformed_data =
10
- ctx.transformed_data +
11
- transform(ctx).upcase
9
+ if ctx.raw_data[:reported_date]
10
+ ctx.transformed_data =
11
+ ctx.transformed_data +
12
+ transform(ctx).upcase
13
+ end
12
14
  end
13
15
 
14
16
  private
@@ -18,7 +20,7 @@ module Tufy
18
20
 
19
21
  BuildAccountSegment::Constants::REPORTED_DATE_TAG +
20
22
  FormatStrings::F2TS % transform_date(DateTime.now).size +
21
- transform_date(DateTime.now)
23
+ transform_date(DateTime.now)
22
24
  end
23
25
  end
24
26
  end
@@ -17,8 +17,8 @@ module Tufy
17
17
  raw_data = ctx.raw_data
18
18
 
19
19
  BuildAccountSegment::Constants::RESTRUCTURED_ACCOUNT_NUMBER_TAG +
20
- FormatStrings::F2TS % raw_data[:restructured_account_number].to_s.size +
21
- raw_data[:restructured_account_number].to_s
20
+ FormatStrings::F2TS % (FormatStrings::F20TS % raw_data[:restructured_account_number]).to_s.size +
21
+ FormatStrings::F20TS % raw_data[:restructured_account_number].to_s
22
22
  end
23
23
  end
24
24
  end
@@ -0,0 +1,14 @@
1
+ module Tufy
2
+ module Fields
3
+ class BuildSegmentTagField < BuildField
4
+ expects :segment_tag
5
+ promises :transformed_data
6
+
7
+ executed do |ctx|
8
+ ctx.transformed_data =
9
+ ctx.transformed_data +
10
+ ctx.segment_tag
11
+ end
12
+ end
13
+ end
14
+ end
@@ -17,8 +17,8 @@ module Tufy
17
17
  raw_data = ctx.raw_data
18
18
 
19
19
  BuildAddressSegment::Constants::ADDRESS_LINE_1_TAG +
20
- FormatStrings::F2TS % remove_special_characters(raw_data[:address_line_1]).size +
21
- remove_special_characters(raw_data[:address_line_1])
20
+ FormatStrings::F2TS % remove_special_characters_except_space(raw_data[:address_line_1]).size +
21
+ remove_special_characters_except_space(raw_data[:address_line_1])
22
22
  end
23
23
  end
24
24
  end
@@ -17,8 +17,8 @@ module Tufy
17
17
  raw_data = ctx.raw_data
18
18
 
19
19
  BuildAddressSegment::Constants::ADDRESS_LINE_2_TAG +
20
- FormatStrings::F2TS % remove_special_characters(raw_data[:address_line_2]).size +
21
- remove_special_characters(raw_data[:address_line_2])
20
+ FormatStrings::F2TS % remove_special_characters_except_space(raw_data[:address_line_2]).size +
21
+ remove_special_characters_except_space(raw_data[:address_line_2])
22
22
  end
23
23
  end
24
24
  end
@@ -2,6 +2,10 @@ module Tufy
2
2
  module Fields
3
3
  module ContactNumber
4
4
  class BuildContactNumberField < BuildField
5
+ # When raw_data[:contact_number].blank?
6
+ # we use NULL_CONTACT_NUMBER instead
7
+ NULL_CONTACT_NUMBER = "0000000000"
8
+
5
9
  expects :raw_data
6
10
  promises :transformed_data
7
11
 
@@ -16,9 +20,15 @@ module Tufy
16
20
  def self.transform(ctx)
17
21
  raw_data = ctx.raw_data
18
22
 
23
+ contact_number = if raw_data[:contact_number].empty?
24
+ NULL_CONTACT_NUMBER
25
+ else
26
+ raw_data[:contact_number]
27
+ end
28
+
19
29
  BuildContactNumberSegment::Constants::CONTACT_NUMBER_TAG +
20
- FormatStrings::F2TS % remove_special_characters(raw_data[:contact_number]).size +
21
- remove_special_characters(raw_data[:contact_number])
30
+ FormatStrings::F2TS % remove_special_characters(contact_number).size +
31
+ remove_special_characters(contact_number)
22
32
  end
23
33
  end
24
34
  end
@@ -0,0 +1,26 @@
1
+ module Tufy
2
+ module Fields
3
+ module ContactNumber
4
+ class BuildContactNumberTypeField < BuildField
5
+ expects :raw_data
6
+ promises :transformed_data
7
+
8
+ executed do |ctx|
9
+ ctx.transformed_data =
10
+ ctx.transformed_data +
11
+ transform(ctx).upcase
12
+ end
13
+
14
+ private
15
+
16
+ def self.transform(ctx)
17
+ raw_data = ctx.raw_data
18
+
19
+ BuildContactNumberSegment::Constants::CONTACT_NUMBER_TYPE_TAG +
20
+ FormatStrings::F2TS % raw_data[:contact_number_type].size +
21
+ raw_data[:contact_number_type]
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -6,5 +6,6 @@ module Tufy
6
6
 
7
7
  F2TS = "%02d" # Fixed 2-character String with Leading Zeroes
8
8
  F3TS = "%03d" # Fixed 3-character String with Leading Zeroes
9
+ F20TS = "%020d" # Fixed 3-character String with Leading Zeroes
9
10
  end
10
11
  end
@@ -1,3 +1,3 @@
1
1
  module Tufy
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tufy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Neil Marion dela Cruz
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-07-11 00:00:00.000000000 Z
11
+ date: 2017-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: light-service
@@ -135,6 +135,7 @@ files:
135
135
  - lib/tufy/fields/account/build_payment_frequency_field.rb
136
136
  - lib/tufy/fields/account/build_reported_date_field.rb
137
137
  - lib/tufy/fields/account/build_restructured_account_number_field.rb
138
+ - lib/tufy/fields/account/build_segment_tag_field.rb
138
139
  - lib/tufy/fields/account/build_shared_by_field.rb
139
140
  - lib/tufy/fields/account/build_unbilled_balance_field.rb
140
141
  - lib/tufy/fields/account/build_user_id_field.rb
@@ -143,6 +144,7 @@ files:
143
144
  - lib/tufy/fields/address/build_address_type_field.rb
144
145
  - lib/tufy/fields/contact_number/build_contact_number_field.rb
145
146
  - lib/tufy/fields/contact_number/build_contact_number_format_field.rb
147
+ - lib/tufy/fields/contact_number/build_contact_number_type_field.rb
146
148
  - lib/tufy/fields/email_address/build_email_address_field.rb
147
149
  - lib/tufy/fields/id/build_id_number_field.rb
148
150
  - lib/tufy/fields/id/build_id_type_field.rb