uob-payroll 1.0.0
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.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/DEPLOYING.md +25 -0
- data/Gemfile +4 -0
- data/LICENSE +27 -0
- data/README.md +36 -0
- data/Rakefile +13 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/uob/payroll/errors.rb +11 -0
- data/lib/uob/payroll/hash_calculator.rb +68 -0
- data/lib/uob/payroll/string_calculator.rb +34 -0
- data/lib/uob/payroll/txt_file/footer.rb +43 -0
- data/lib/uob/payroll/txt_file/header.rb +69 -0
- data/lib/uob/payroll/txt_file/row.rb +60 -0
- data/lib/uob/payroll/txt_file.rb +39 -0
- data/lib/uob/payroll/version.rb +5 -0
- data/lib/uob/payroll.rb +20 -0
- data/uob-payroll.gemspec +32 -0
- metadata +191 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: bfe1a933de005de3abbac4a393aac11b383388b5
|
|
4
|
+
data.tar.gz: a6ef358e8daaed645823e2a466002260dcee7f91
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: e7e36f2455a396baa36517e5e4e74caa4df8ecdb3905121cbcf1a11b201fdd0c21fa4cf274d690d6efc5f3103dfcd69c3f881e9416bf7d00dcac0d4cdf852232
|
|
7
|
+
data.tar.gz: a4917fa954ebfb54224ffce4a2442a00643449858abc98a4280730bcf610f5acbdfe394aa42b1f6d091b67e4bc17ff3259e63226e27edaf832db43291ac5326d
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Contributor Code of Conduct
|
|
2
|
+
|
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
|
7
|
+
|
|
8
|
+
We are committed to making participation in this project a harassment-free
|
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
|
12
|
+
|
|
13
|
+
Examples of unacceptable behavior by participants include:
|
|
14
|
+
|
|
15
|
+
* The use of sexualized language or imagery
|
|
16
|
+
* Personal attacks
|
|
17
|
+
* Trolling or insulting/derogatory comments
|
|
18
|
+
* Public or private harassment
|
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
|
20
|
+
addresses, without explicit permission
|
|
21
|
+
* Other unethical or unprofessional conduct
|
|
22
|
+
|
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
|
27
|
+
threatening, offensive, or harmful.
|
|
28
|
+
|
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
|
32
|
+
Conduct may be permanently removed from the project team.
|
|
33
|
+
|
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
|
35
|
+
when an individual is representing the project or its community.
|
|
36
|
+
|
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
38
|
+
reported by contacting a project maintainer at vincent.paca@gmail.com. All
|
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
|
42
|
+
incident.
|
|
43
|
+
|
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
|
45
|
+
version 1.3.0, available at
|
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
|
47
|
+
|
|
48
|
+
[homepage]: http://contributor-covenant.org
|
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/DEPLOYING.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
## Setup
|
|
2
|
+
|
|
3
|
+
In order to deploy a new version of the gem into the wild ...
|
|
4
|
+
|
|
5
|
+
You will need to configure your github api token for the changelog.
|
|
6
|
+
|
|
7
|
+
Generate a new token for changelogs [here](https://github.com/settings/tokens/new).
|
|
8
|
+
|
|
9
|
+
add:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
export CHANGELOG_GITHUB_TOKEN=YOUR_CHANGELOG_API_TOKEN
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
somewhere in your shell init. (ie .zshrc or simillar)
|
|
16
|
+
|
|
17
|
+
## Deploying
|
|
18
|
+
|
|
19
|
+
1. Update `lib/uob/payroll/version.rb`
|
|
20
|
+
2. Commit the changed files with the version number eg: `1.8.0`
|
|
21
|
+
3. Push this to git
|
|
22
|
+
4. Run `rake release`
|
|
23
|
+
5. Run `rake changelog` (has to be ran after release since its based on github tagging)
|
|
24
|
+
6. Commit the changed changelog named something like `changelog for 1.8.0`
|
|
25
|
+
7. Push this to git
|
data/Gemfile
ADDED
data/LICENSE
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
Copyright (c) 2016, PayrollHero PTE. Ltd
|
|
2
|
+
All rights reserved.
|
|
3
|
+
|
|
4
|
+
Redistribution and use in source and binary forms, with or without
|
|
5
|
+
modification, are permitted provided that the following conditions are met:
|
|
6
|
+
|
|
7
|
+
* Redistributions of source code must retain the above copyright notice, this
|
|
8
|
+
list of conditions and the following disclaimer.
|
|
9
|
+
|
|
10
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
|
11
|
+
this list of conditions and the following disclaimer in the documentation
|
|
12
|
+
and/or other materials provided with the distribution.
|
|
13
|
+
|
|
14
|
+
* Neither the name of zoho-subscriptions nor the names of its
|
|
15
|
+
contributors may be used to endorse or promote products derived from
|
|
16
|
+
this software without specific prior written permission.
|
|
17
|
+
|
|
18
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
19
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
20
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
21
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
22
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
23
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
24
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
25
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
26
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
27
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Uob::Payroll
|
|
2
|
+
|
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/uob/payroll`. To experiment with that code, run `bin/console` for an interactive prompt.
|
|
4
|
+
|
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Add this line to your application's Gemfile:
|
|
10
|
+
|
|
11
|
+
```ruby
|
|
12
|
+
gem 'uob-payroll'
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
And then execute:
|
|
16
|
+
|
|
17
|
+
$ bundle
|
|
18
|
+
|
|
19
|
+
Or install it yourself as:
|
|
20
|
+
|
|
21
|
+
$ gem install uob-payroll
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
TODO: Write usage instructions here
|
|
26
|
+
|
|
27
|
+
## Development
|
|
28
|
+
|
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
30
|
+
|
|
31
|
+
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`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
32
|
+
|
|
33
|
+
## Contributing
|
|
34
|
+
|
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/uob-payroll. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
|
36
|
+
|
data/Rakefile
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
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
|
|
9
|
+
|
|
10
|
+
desc "Updates the changelog"
|
|
11
|
+
task :changelog do
|
|
12
|
+
sh "github_changelog_generator payrollhero/aub-payroll"
|
|
13
|
+
end
|
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "uob/payroll"
|
|
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,68 @@
|
|
|
1
|
+
# See https://payrollhero.atlassian.net/wiki/download/attachments/12288081/FAST-GIRO%20without%20Advice%20File%20Format%20for%20BIBPlus%20%28v3.03%29.pdf?version=1&modificationDate=1460018775794&api=v2
|
|
2
|
+
# Appendix 2 for the Hash Algorithm
|
|
3
|
+
|
|
4
|
+
require_relative 'string_calculator'
|
|
5
|
+
|
|
6
|
+
module UOB
|
|
7
|
+
module Payroll
|
|
8
|
+
class HashCalculator
|
|
9
|
+
|
|
10
|
+
class << self
|
|
11
|
+
def calculate(header:, rows:)
|
|
12
|
+
new(header: header, rows: rows).calculate
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def initialize(header:, rows:)
|
|
17
|
+
@header = header
|
|
18
|
+
@rows = rows
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def calculate
|
|
22
|
+
sum_header +
|
|
23
|
+
sum_rows +
|
|
24
|
+
22 # Payment Type is always 'R' for Payroll and Hash Code will always be 1. See p16.
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
attr_reader :header, :rows
|
|
28
|
+
|
|
29
|
+
def sum_header
|
|
30
|
+
calculate_string(header.originating_bic_code) +
|
|
31
|
+
calculate_padded_string(string: header.originating_account_number, size: 34) +
|
|
32
|
+
calculate_padded_string(string: header.originating_account_name, size: 140)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def sum_rows
|
|
36
|
+
rows.each.with_index(1).map { |row, index|
|
|
37
|
+
calculate_string(row.receiving_bic_code) +
|
|
38
|
+
index * calculate_padded_string(string: row.receiving_account_number, size: 34) +
|
|
39
|
+
index * calculate_padded_string(string: row.receiving_account_name, size: 140) +
|
|
40
|
+
calculate_payment_type(index) +
|
|
41
|
+
calculate_string('SGD') +
|
|
42
|
+
calculate_padded_string(string: row.formatted_amount, size: 18, pad: '0', just: :right) +
|
|
43
|
+
calculate_string('SALA')
|
|
44
|
+
}.reduce(0, :+)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
private
|
|
48
|
+
|
|
49
|
+
# Payment Type is always 'R', so Payment Code = 22
|
|
50
|
+
def calculate_payment_type(index)
|
|
51
|
+
22 * (index)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def calculate_padded_string(string:, size:, pad: ' ', just: :left)
|
|
55
|
+
if just == :left
|
|
56
|
+
calculate_string string[0...size].ljust(size, pad)
|
|
57
|
+
else
|
|
58
|
+
calculate_string string[0...size].rjust(size, pad)
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def calculate_string(string)
|
|
63
|
+
StringCalculator.calculate(string)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
module UOB
|
|
2
|
+
module Payroll
|
|
3
|
+
class StringCalculator
|
|
4
|
+
|
|
5
|
+
attr_reader :string
|
|
6
|
+
|
|
7
|
+
class << self
|
|
8
|
+
def calculate(string)
|
|
9
|
+
new(string).calculate
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def initialize(string)
|
|
14
|
+
@string = string
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# The sum of each byte converted into ASCII multiplied to it's index.
|
|
18
|
+
# For example:
|
|
19
|
+
# BLA #=> 413
|
|
20
|
+
# B ~> 66 * 1
|
|
21
|
+
# L ~> 76 * 2
|
|
22
|
+
# A ~> 65 * 3
|
|
23
|
+
def calculate
|
|
24
|
+
string.
|
|
25
|
+
each_byte.
|
|
26
|
+
to_a.
|
|
27
|
+
each_with_index.
|
|
28
|
+
map { |byte, index| (index + 1) * byte }.
|
|
29
|
+
reduce(0, :+)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
require 'active_model'
|
|
2
|
+
require 'ph_utility'
|
|
3
|
+
require_relative '../hash_calculator'
|
|
4
|
+
|
|
5
|
+
module UOB
|
|
6
|
+
module Payroll
|
|
7
|
+
class TXTFile::Footer
|
|
8
|
+
include ActiveModel::Model
|
|
9
|
+
include PhUtility::TxtData::TxtDataRowDSL
|
|
10
|
+
|
|
11
|
+
number :record_type, 1..1, value: 9
|
|
12
|
+
text :formatted_total_amount, 2..19, just: :right, pad: '0'
|
|
13
|
+
text :formatted_number_of_records, 20..26, just: :right, pad: '0'
|
|
14
|
+
text :hash_total, 27..42, just: :right, pad: '0'
|
|
15
|
+
spaces 43..615
|
|
16
|
+
|
|
17
|
+
attr_reader :total_amount, :number_of_records, :header, :rows
|
|
18
|
+
|
|
19
|
+
# @param [BigDecimal] total_amount The total amount to be transferred
|
|
20
|
+
# @param [TXTFile::Header] header The header details used for the hash computation
|
|
21
|
+
# @param [Array<TXTFile::Row>] rows The row details used for the has computation
|
|
22
|
+
def initialize(total_amount:, header:, rows:)
|
|
23
|
+
@total_amount = total_amount
|
|
24
|
+
@number_of_records = rows.count
|
|
25
|
+
@header = header
|
|
26
|
+
@rows = rows
|
|
27
|
+
raise Errors::Invalid, errors.full_messages.to_sentence unless valid?
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def hash_total
|
|
31
|
+
HashCalculator.calculate(header: header, rows: rows)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def formatted_number_of_records
|
|
35
|
+
format '%06d', number_of_records
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def formatted_total_amount
|
|
39
|
+
(format '%015.2f', total_amount).gsub('.','')
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
require 'active_model'
|
|
2
|
+
require 'ph_utility'
|
|
3
|
+
|
|
4
|
+
module UOB
|
|
5
|
+
module Payroll
|
|
6
|
+
class TXTFile::Header
|
|
7
|
+
include ActiveModel::Model
|
|
8
|
+
include PhUtility::TxtData::TxtDataRowDSL
|
|
9
|
+
|
|
10
|
+
number :record_type, 1..1, value: 1
|
|
11
|
+
text :filename, 2..11
|
|
12
|
+
text :payment_type, 12..12, value: 'R'
|
|
13
|
+
text :service_type, 13..22, value: 'NORMAL', just: :left
|
|
14
|
+
text :processing_mode, 23..23, value: ' '
|
|
15
|
+
spaces 24..35
|
|
16
|
+
text :originating_bic_code, 36..46
|
|
17
|
+
text :originating_account_currency, 47..49, value: 'SGD'
|
|
18
|
+
text :originating_account_number, 50..83, just: :left
|
|
19
|
+
text :originating_account_name, 84..223, just: :left
|
|
20
|
+
text :formatted_creation_date, 224..231
|
|
21
|
+
text :formatted_value_date, 232..239
|
|
22
|
+
text :ultimate_originating_customer, 240..379, just: :left, value: ' '
|
|
23
|
+
text :bulk_customer_reference, 380..395, just: :left, value: ' '
|
|
24
|
+
text :software_label, 396..405, value: 'PH', just: :left
|
|
25
|
+
spaces 406..615
|
|
26
|
+
|
|
27
|
+
attr_reader :company_name, :account_number, :branch_code, :creation_date, :value_date
|
|
28
|
+
|
|
29
|
+
# @param [String] company_name
|
|
30
|
+
# @param [String] account_number The originating 10 digit UOB bank account number
|
|
31
|
+
# @param [String] branch_code The originating UOB branch code
|
|
32
|
+
# @param [Date] creation_date Date when the bank file was created
|
|
33
|
+
# @param [Date] value_date Date when the amounts will be credited to the receiving party
|
|
34
|
+
def initialize(company_name:, account_number:, branch_code:, creation_date:, value_date:)
|
|
35
|
+
@company_name = company_name
|
|
36
|
+
@account_number = account_number
|
|
37
|
+
@branch_code = branch_code
|
|
38
|
+
@creation_date = creation_date
|
|
39
|
+
@value_date = value_date
|
|
40
|
+
|
|
41
|
+
raise Errors::Invalid, errors.full_messages.to_sentence unless valid?
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def filename
|
|
45
|
+
"UGBI#{creation_date.strftime('%m%d')}01"
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def originating_bic_code
|
|
49
|
+
"UOVBSGSG#{branch_code}"
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def originating_account_number
|
|
53
|
+
account_number
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def originating_account_name
|
|
57
|
+
String(company_name).upcase.ljust 140
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def formatted_creation_date
|
|
61
|
+
creation_date.strftime '%Y%m%d'
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def formatted_value_date
|
|
65
|
+
value_date.strftime '%Y%m%d'
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
require 'active_model'
|
|
2
|
+
require 'ph_utility'
|
|
3
|
+
|
|
4
|
+
module UOB
|
|
5
|
+
module Payroll
|
|
6
|
+
class TXTFile::Row
|
|
7
|
+
include ActiveModel::Model
|
|
8
|
+
include PhUtility::TxtData::TxtDataRowDSL
|
|
9
|
+
|
|
10
|
+
number :record_type, 1..1, value: 2
|
|
11
|
+
text :receiving_bic_code, 2..12, just: :left
|
|
12
|
+
text :receiving_account_number, 13..46, just: :left
|
|
13
|
+
text :receiving_account_name, 47..186, just: :left
|
|
14
|
+
text :receiving_account_currency, 187..189, value: 'SGD'
|
|
15
|
+
text :formatted_amount, 190..207, just: :right, pad: '0'
|
|
16
|
+
text :end_to_end_id, 208..242, just: :left
|
|
17
|
+
text :mandate_id, 243..277, value: ' '
|
|
18
|
+
text :purpose_code, 278..281, value: 'SALA'
|
|
19
|
+
spaces 282..615
|
|
20
|
+
|
|
21
|
+
attr_reader :bic_code, :account_number, :account_name, :amount
|
|
22
|
+
|
|
23
|
+
validates :amount, numericality: { greater_than: 0, less_than_or_equal_to: 50_000 }
|
|
24
|
+
|
|
25
|
+
# @param [String] bic_code The Bank Identifier Code or SWIFT code
|
|
26
|
+
# @param [String] account_number The receiving bank account number
|
|
27
|
+
# @param [String] account_name The receiving name of the account
|
|
28
|
+
# @param [BigDecimal] amount The amount to be received
|
|
29
|
+
def initialize(bic_code:, account_number:, account_name:, amount:)
|
|
30
|
+
@bic_code = bic_code
|
|
31
|
+
@account_number = account_number
|
|
32
|
+
@account_name = account_name
|
|
33
|
+
@amount = amount
|
|
34
|
+
|
|
35
|
+
raise Errors::Invalid, errors.full_messages.to_sentence unless valid?
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def formatted_amount
|
|
39
|
+
(format '%014.2f', amount).gsub('.','')
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def receiving_bic_code
|
|
43
|
+
String(bic_code).upcase
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def receiving_account_number
|
|
47
|
+
account_number
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def receiving_account_name
|
|
51
|
+
String(account_name).ljust 140
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def end_to_end_id
|
|
55
|
+
'SALARY'
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
require 'active_model'
|
|
2
|
+
|
|
3
|
+
module UOB
|
|
4
|
+
module Payroll
|
|
5
|
+
class TXTFile
|
|
6
|
+
extend ActiveSupport::Autoload
|
|
7
|
+
|
|
8
|
+
autoload :Header
|
|
9
|
+
autoload :Row
|
|
10
|
+
autoload :Footer
|
|
11
|
+
|
|
12
|
+
include ActiveModel::Model
|
|
13
|
+
|
|
14
|
+
def initialize(company_name:, account_number:, branch_code:, date:, payable_date:, transactions:)
|
|
15
|
+
@header = Header.new(
|
|
16
|
+
company_name: company_name,
|
|
17
|
+
account_number: account_number,
|
|
18
|
+
branch_code: branch_code,
|
|
19
|
+
creation_date: date,
|
|
20
|
+
value_date: payable_date
|
|
21
|
+
)
|
|
22
|
+
@rows = transactions.map { |transaction| Row.new transaction }
|
|
23
|
+
@footer = Footer.new total_amount: rows.sum(&:amount), header: header, rows: rows
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def content
|
|
27
|
+
[
|
|
28
|
+
header,
|
|
29
|
+
rows,
|
|
30
|
+
footer,
|
|
31
|
+
].join("\n")
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
private
|
|
35
|
+
|
|
36
|
+
attr_accessor :header, :rows, :footer
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
data/lib/uob/payroll.rb
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
require 'uob/payroll/version'
|
|
2
|
+
|
|
3
|
+
require 'active_support'
|
|
4
|
+
require 'active_support/dependencies/autoload'
|
|
5
|
+
require 'active_support/core_ext/enumerable'
|
|
6
|
+
|
|
7
|
+
require 'ph_model'
|
|
8
|
+
|
|
9
|
+
module UOB
|
|
10
|
+
module Payroll
|
|
11
|
+
extend ActiveSupport::Autoload
|
|
12
|
+
|
|
13
|
+
autoload :Errors
|
|
14
|
+
autoload :TXTFile
|
|
15
|
+
autoload :StringCalculator
|
|
16
|
+
autoload :HashCalculator
|
|
17
|
+
|
|
18
|
+
GEM_ROOT = File.expand_path(File.dirname(__FILE__) + '/../..')
|
|
19
|
+
end
|
|
20
|
+
end
|
data/uob-payroll.gemspec
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'uob/payroll/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "uob-payroll"
|
|
8
|
+
spec.version = Uob::Payroll::VERSION
|
|
9
|
+
spec.authors = ["Vincent Paca"]
|
|
10
|
+
spec.email = ["vpaca@payrollhero.com"]
|
|
11
|
+
|
|
12
|
+
spec.summary = %q{A UOB Payroll File Generator}
|
|
13
|
+
spec.description = %q{A UOB Payroll File Generator}
|
|
14
|
+
spec.homepage = "https://github.com/payrollhero/uob-payroll"
|
|
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.11"
|
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
24
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
|
25
|
+
spec.add_development_dependency 'pry'
|
|
26
|
+
spec.add_development_dependency 'github_changelog_generator'
|
|
27
|
+
|
|
28
|
+
spec.add_dependency 'activesupport'
|
|
29
|
+
spec.add_dependency 'activemodel'
|
|
30
|
+
spec.add_dependency 'ph_model'
|
|
31
|
+
spec.add_dependency 'ph_utility'
|
|
32
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: uob-payroll
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Vincent Paca
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2016-04-22 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.11'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.11'
|
|
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: '3.0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '3.0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: pry
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
type: :development
|
|
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: github_changelog_generator
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: activesupport
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - ">="
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '0'
|
|
90
|
+
type: :runtime
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - ">="
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '0'
|
|
97
|
+
- !ruby/object:Gem::Dependency
|
|
98
|
+
name: activemodel
|
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
|
100
|
+
requirements:
|
|
101
|
+
- - ">="
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: '0'
|
|
104
|
+
type: :runtime
|
|
105
|
+
prerelease: false
|
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - ">="
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: '0'
|
|
111
|
+
- !ruby/object:Gem::Dependency
|
|
112
|
+
name: ph_model
|
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - ">="
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: '0'
|
|
118
|
+
type: :runtime
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - ">="
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: '0'
|
|
125
|
+
- !ruby/object:Gem::Dependency
|
|
126
|
+
name: ph_utility
|
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
|
128
|
+
requirements:
|
|
129
|
+
- - ">="
|
|
130
|
+
- !ruby/object:Gem::Version
|
|
131
|
+
version: '0'
|
|
132
|
+
type: :runtime
|
|
133
|
+
prerelease: false
|
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
135
|
+
requirements:
|
|
136
|
+
- - ">="
|
|
137
|
+
- !ruby/object:Gem::Version
|
|
138
|
+
version: '0'
|
|
139
|
+
description: A UOB Payroll File Generator
|
|
140
|
+
email:
|
|
141
|
+
- vpaca@payrollhero.com
|
|
142
|
+
executables: []
|
|
143
|
+
extensions: []
|
|
144
|
+
extra_rdoc_files: []
|
|
145
|
+
files:
|
|
146
|
+
- ".gitignore"
|
|
147
|
+
- ".rspec"
|
|
148
|
+
- ".travis.yml"
|
|
149
|
+
- CODE_OF_CONDUCT.md
|
|
150
|
+
- DEPLOYING.md
|
|
151
|
+
- Gemfile
|
|
152
|
+
- LICENSE
|
|
153
|
+
- README.md
|
|
154
|
+
- Rakefile
|
|
155
|
+
- bin/console
|
|
156
|
+
- bin/setup
|
|
157
|
+
- lib/uob/payroll.rb
|
|
158
|
+
- lib/uob/payroll/errors.rb
|
|
159
|
+
- lib/uob/payroll/hash_calculator.rb
|
|
160
|
+
- lib/uob/payroll/string_calculator.rb
|
|
161
|
+
- lib/uob/payroll/txt_file.rb
|
|
162
|
+
- lib/uob/payroll/txt_file/footer.rb
|
|
163
|
+
- lib/uob/payroll/txt_file/header.rb
|
|
164
|
+
- lib/uob/payroll/txt_file/row.rb
|
|
165
|
+
- lib/uob/payroll/version.rb
|
|
166
|
+
- uob-payroll.gemspec
|
|
167
|
+
homepage: https://github.com/payrollhero/uob-payroll
|
|
168
|
+
licenses:
|
|
169
|
+
- BSD-3-Clause
|
|
170
|
+
metadata: {}
|
|
171
|
+
post_install_message:
|
|
172
|
+
rdoc_options: []
|
|
173
|
+
require_paths:
|
|
174
|
+
- lib
|
|
175
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
176
|
+
requirements:
|
|
177
|
+
- - ">="
|
|
178
|
+
- !ruby/object:Gem::Version
|
|
179
|
+
version: '0'
|
|
180
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
181
|
+
requirements:
|
|
182
|
+
- - ">="
|
|
183
|
+
- !ruby/object:Gem::Version
|
|
184
|
+
version: '0'
|
|
185
|
+
requirements: []
|
|
186
|
+
rubyforge_project:
|
|
187
|
+
rubygems_version: 2.5.1
|
|
188
|
+
signing_key:
|
|
189
|
+
specification_version: 4
|
|
190
|
+
summary: A UOB Payroll File Generator
|
|
191
|
+
test_files: []
|