union_bank-e_crediting 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4aea3632f33f1c9d1149a76b770dc3d26e17d4e9
4
+ data.tar.gz: 64c0c5527442b56b34bde72e7c208476294c7536
5
+ SHA512:
6
+ metadata.gz: 5a7144edc2682a8f55fb33c2789bd527af2ff80e2c8d6d299dfe2d45c35fa0817724e01d2f26a3b59ce929a3f60cacf246b86134a280d83f57cf1489756f273e
7
+ data.tar.gz: 92372ffc2051cb34c7d813f1eaf8d6eb3908fa2cfc4c3c0808be75b0dc9862426d60565525a9eab6d89f12f1f808152392b4bdcd3a2bb04ae5f157d9b26c99e6
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.6
4
+ - 2.2.3
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in union_bank-e_crediting.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014, PayrollHero PTE. Ltd. All rights reserved.
2
+
3
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that
4
+ the following conditions are met:
5
+
6
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the
7
+ following disclaimer.
8
+
9
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
10
+ following disclaimer in the documentation and/or other materials provided with the distribution.
11
+
12
+ 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or
13
+ promote products derived from this software without specific prior written permission.
14
+
15
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
16
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
17
+ PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
18
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
20
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
21
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
22
+ DAMAGE.
data/README.md ADDED
@@ -0,0 +1,66 @@
1
+ # UnionBank::ECrediting
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/union_bank-e_crediting.svg)](http://badge.fury.io/rb/union_bank-e_crediting)
4
+ [![Code Climate](https://codeclimate.com/github/payrollhero/union_bank-e_crediting/badges/gpa.svg)](https://codeclimate.com/github/payrollhero/union_bank-e_crediting)
5
+ [![Build Status](https://travis-ci.org/payrollhero/union_bank-e_crediting.svg)](https://travis-ci.org/payrollhero/union_bank-e_crediting)
6
+
7
+ Generates file contents for UnionBank's eCrediting enrollment and transaction files.
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem 'union_bank-e_crediting'
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install union_bank-e_crediting
24
+
25
+ ## Usage
26
+
27
+ ```ruby
28
+ enrollment_file = UnionBank::ECrediting::EnrollmentFile.new org_short_code: "COMPANY-ABC",
29
+ date: "2010-01-01".to_date,
30
+ details: [
31
+ {
32
+ payee_id: "000000000001",
33
+ account_number: "000000000001",
34
+ account_name: "Person A",
35
+ mobile_number: "888-8888",
36
+ email: "person.a@company.com"
37
+ }
38
+ ]
39
+
40
+ enrollment_file.content #=> "H|COMPANY-ABC|01012010|0\r\nD|000000000001|000000000001|Person A|888-8888|person.a@company.com\r\n"
41
+
42
+ transaction_file = UnionBank::ECrediting::TransactionFile.new org_short_code: "COMPANY-ABC",
43
+ date: "2010-01-01".to_date,
44
+ details: [
45
+ {
46
+ payee_id: "000000000001",
47
+ amount: 123.45
48
+ }
49
+ ]
50
+
51
+ transaction_file.content #=> "H|COMPANY-ABC|01012010|0\r\nD|000000000001|1|000000012345\r\n"
52
+ ```
53
+
54
+ ## Development
55
+
56
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
57
+
58
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
59
+
60
+ ## Contributing
61
+
62
+ 1. Fork it ( https://github.com/[my-github-username]/union_bank-e_crediting/fork )
63
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
64
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
65
+ 4. Push to the branch (`git push origin my-new-feature`)
66
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ begin
4
+ require "rspec/core/rake_task"
5
+ RSpec::Core::RakeTask.new(:spec)
6
+ task default: :spec
7
+ rescue LoadError
8
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "union_bank/e_crediting"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,14 @@
1
+ require "union_bank/e_crediting/version"
2
+ require "bigdecimal"
3
+ require "active_support"
4
+
5
+ module UnionBank
6
+ module ECrediting
7
+ extend ActiveSupport::Autoload
8
+
9
+ autoload :Common
10
+ autoload :EnrollmentFile
11
+ autoload :TransactionFile
12
+ autoload :PipeDelimitedFile
13
+ end
14
+ end
@@ -0,0 +1,9 @@
1
+ module UnionBank
2
+ module ECrediting
3
+ module Common
4
+ extend ActiveSupport::Autoload
5
+
6
+ autoload :HeaderLine
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,41 @@
1
+ require "active_model"
2
+
3
+ module UnionBank
4
+ module ECrediting
5
+ module Common
6
+ # Describes UnionBank eCrediting generic file header line
7
+ class HeaderLine
8
+ include ActiveModel::Model
9
+
10
+ attr_accessor :org_short_code,
11
+ :date,
12
+ :total_no_of_refs
13
+
14
+ validates :org_short_code, length: { maximum: 15 }
15
+ validates :total_no_of_refs, length: { minimum: 1, maximum: 2 }, numericality: { only_integer: true }
16
+ validates :org_short_code, :date, :total_no_of_refs, presence: true
17
+
18
+ # @param [String] org_short_code
19
+ # @param [Date] date
20
+ # @param [Integer] total_no_of_refs
21
+ def initialize(org_short_code:, date:, total_no_of_refs: 0)
22
+ @org_short_code = org_short_code
23
+ @date = date
24
+ @total_no_of_refs = total_no_of_refs
25
+
26
+ raise ArgumentError, errors.full_messages.to_sentence unless valid?
27
+ end
28
+
29
+ # @return [Array]
30
+ def ordered_field_values
31
+ [
32
+ "H", # identifier
33
+ org_short_code.strip,
34
+ date.strftime("%m%d%Y"),
35
+ total_no_of_refs
36
+ ]
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,13 @@
1
+ module UnionBank
2
+ module ECrediting
3
+ # Describes UnionBank's eCrediting Enrollment File
4
+ class EnrollmentFile
5
+ include PipeDelimitedFile
6
+
7
+ # @return [Array<UnionBank::ECrediting::EnrollmentFile::DetailLine>]
8
+ def detail_lines
9
+ @detail_lines ||= details.map { |detail| DetailLine.new detail }
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,56 @@
1
+ require "active_model"
2
+
3
+ module UnionBank
4
+ module ECrediting
5
+ # Describes UnionBank's eCrediting Enrollment File's detail line
6
+ class EnrollmentFile::DetailLine
7
+ include ActiveModel::Model
8
+
9
+ attr_accessor :payee_id,
10
+ :account_number,
11
+ :account_name,
12
+ :mobile_number,
13
+ :email
14
+
15
+ validates :payee_id, length: { maximum: 50 }
16
+ validates :account_number, length: { maximum: 16 }
17
+ validates :account_name, length: { maximum: 120 }
18
+ validates :mobile_number, length: { maximum: 13 }
19
+ validates :email, length: { maximum: 40 }
20
+
21
+ validates :payee_id,
22
+ :account_number,
23
+ :account_name,
24
+ :mobile_number,
25
+ :email,
26
+ presence: true
27
+
28
+ # @param [String] payee_id
29
+ # @param [String] account_number
30
+ # @param [String] account_name
31
+ # @param [String] mobile_number
32
+ # @param [String] email
33
+ def initialize(payee_id:, account_number:, account_name:, mobile_number:, email:)
34
+ @payee_id = payee_id
35
+ @account_number = account_number
36
+ @account_name = account_name
37
+ @mobile_number = mobile_number
38
+ @email = email
39
+
40
+ raise ArgumentError, errors.full_messages.to_sentence unless valid?
41
+ end
42
+
43
+ # @return [Array]
44
+ def ordered_field_values
45
+ [
46
+ "D", # identifier
47
+ payee_id,
48
+ account_number,
49
+ account_name,
50
+ mobile_number,
51
+ email
52
+ ]
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,52 @@
1
+ require "csv"
2
+
3
+ module UnionBank
4
+ module ECrediting
5
+ # Defines common methods of a pipe delimited file (CSV file with "|" as the column separator).
6
+ module PipeDelimitedFile
7
+ extend ActiveSupport::Concern
8
+
9
+ included do
10
+ extend ActiveSupport::Autoload
11
+ autoload :DetailLine
12
+ end
13
+
14
+ # @param [String] org_short_code
15
+ # @param [Date] date
16
+ # @param [Integer] total_no_of_refs
17
+ # @param [Array] details
18
+ def initialize(org_short_code:, date:, total_no_of_refs: 0, details: [])
19
+ @org_short_code = org_short_code
20
+ @date = date
21
+ @total_no_of_refs = total_no_of_refs
22
+ @details = details
23
+ end
24
+
25
+ # @return [String]
26
+ def content
27
+ CSV.generate(col_sep: "|", row_sep: "\r\n") do |csv|
28
+ csv << header_line.ordered_field_values
29
+
30
+ detail_lines.each do |line|
31
+ csv << line.ordered_field_values
32
+ end
33
+ end
34
+ end
35
+
36
+ # @return [UnionBank::ECrediting::Common::HeaderLine]
37
+ def header_line
38
+ @header_line ||= Common::HeaderLine.new org_short_code: org_short_code,
39
+ date: date,
40
+ total_no_of_refs: total_no_of_refs
41
+ end
42
+
43
+ def detail_lines
44
+ raise NotImplementedError, "#{self.class} must implement #detail_lines"
45
+ end
46
+
47
+ private
48
+
49
+ attr_reader :org_short_code, :date, :total_no_of_refs, :details
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,17 @@
1
+ require "csv"
2
+
3
+ module UnionBank
4
+ module ECrediting
5
+ # Describes UnionBank's eCrediting Transaction File
6
+ class TransactionFile
7
+ include PipeDelimitedFile
8
+
9
+ # @return [Array<UnionBank::ECrediting::TransactionFile::DetailLine>]
10
+ def detail_lines
11
+ @detail_lines ||= details.each_with_index.map do |detail, index|
12
+ DetailLine.new detail.merge(ref_number: (index + 1))
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,55 @@
1
+ require "active_model"
2
+
3
+ module UnionBank
4
+ module ECrediting
5
+ # Describes UnionBank's eCrediting Transaction File's detail line
6
+ class TransactionFile::DetailLine
7
+ include ActiveModel::Model
8
+
9
+ AMOUNT_RANGE = BigDecimal("0")..BigDecimal("9999999999.99")
10
+
11
+ attr_accessor :payee_id,
12
+ :ref_number,
13
+ :amount,
14
+ :ref_values
15
+
16
+ validates :payee_id, length: { maximum: 50 }
17
+ validates :ref_number, length: { maximum: 20 }
18
+ validates :amount, inclusion: { in: AMOUNT_RANGE, message: "must be between 0.00 to 9,999,999,999.99" }
19
+
20
+ validates :payee_id,
21
+ :ref_number,
22
+ :amount,
23
+ presence: true
24
+
25
+ # @param [String] payee_id
26
+ # @param [Integer] ref_number
27
+ # @param [BigDecimal] amount
28
+ # @param [Array] ref_values
29
+ def initialize(payee_id:, ref_number:, amount:, ref_values: [])
30
+ @payee_id = payee_id
31
+ @ref_number = ref_number
32
+ @amount = BigDecimal(amount.to_s)
33
+ @ref_values = ref_values
34
+
35
+ raise ArgumentError, errors.full_messages.to_sentence unless valid?
36
+ end
37
+
38
+ # @return [Array]
39
+ def ordered_field_values
40
+ [
41
+ "D", # identifier
42
+ payee_id,
43
+ ref_number,
44
+ formatted_amount,
45
+ ] + ref_values
46
+ end
47
+
48
+ private
49
+
50
+ def formatted_amount
51
+ "%012d" % (amount * BigDecimal("100"))
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,5 @@
1
+ module UnionBank
2
+ module ECrediting
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'union_bank/e_crediting/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "union_bank-e_crediting"
8
+ spec.version = UnionBank::ECrediting::VERSION
9
+ spec.authors = ["Ronald Maravilla"]
10
+ spec.email = ["rmaravilla@payrollhero.com"]
11
+
12
+ spec.summary = %q{Generates file contents for UnionBank's eCrediting enrollment and transaction files.}
13
+ spec.description = %q{Generates file contents for UnionBank's eCrediting enrollment and transaction files.}
14
+ spec.homepage = "https://github.com/payrollhero/union_bank-e_crediting"
15
+ spec.license = "BSD-3-Clause"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.9"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "rspec"
25
+
26
+ spec.add_dependency "activesupport"
27
+ spec.add_dependency "activemodel"
28
+ end
metadata ADDED
@@ -0,0 +1,137 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: union_bank-e_crediting
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Ronald Maravilla
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-09-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.9'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.9'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: activesupport
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: activemodel
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Generates file contents for UnionBank's eCrediting enrollment and transaction
84
+ files.
85
+ email:
86
+ - rmaravilla@payrollhero.com
87
+ executables: []
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - ".rspec"
93
+ - ".travis.yml"
94
+ - CODE_OF_CONDUCT.md
95
+ - Gemfile
96
+ - LICENSE
97
+ - README.md
98
+ - Rakefile
99
+ - bin/console
100
+ - bin/setup
101
+ - lib/union_bank/e_crediting.rb
102
+ - lib/union_bank/e_crediting/common.rb
103
+ - lib/union_bank/e_crediting/common/header_line.rb
104
+ - lib/union_bank/e_crediting/enrollment_file.rb
105
+ - lib/union_bank/e_crediting/enrollment_file/detail_line.rb
106
+ - lib/union_bank/e_crediting/pipe_delimited_file.rb
107
+ - lib/union_bank/e_crediting/transaction_file.rb
108
+ - lib/union_bank/e_crediting/transaction_file/detail_line.rb
109
+ - lib/union_bank/e_crediting/version.rb
110
+ - union_bank-e_crediting.gemspec
111
+ homepage: https://github.com/payrollhero/union_bank-e_crediting
112
+ licenses:
113
+ - BSD-3-Clause
114
+ metadata: {}
115
+ post_install_message:
116
+ rdoc_options: []
117
+ require_paths:
118
+ - lib
119
+ required_ruby_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ required_rubygems_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ requirements: []
130
+ rubyforge_project:
131
+ rubygems_version: 2.2.3
132
+ signing_key:
133
+ specification_version: 4
134
+ summary: Generates file contents for UnionBank's eCrediting enrollment and transaction
135
+ files.
136
+ test_files: []
137
+ has_rdoc: