aub-payroll 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE +28 -0
- data/README.md +56 -0
- data/Rakefile +8 -0
- data/aub-payroll.gemspec +28 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/aub/payroll.rb +13 -0
- data/lib/aub/payroll/errors.rb +11 -0
- data/lib/aub/payroll/file.rb +33 -0
- data/lib/aub/payroll/file/footer.rb +41 -0
- data/lib/aub/payroll/file/header.rb +40 -0
- data/lib/aub/payroll/file/row.rb +37 -0
- data/lib/aub/payroll/version.rb +5 -0
- metadata +133 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3b61ae020a0974c8833e3b7a7cd4956aeda629da
|
4
|
+
data.tar.gz: d18a160389743a79e08f2fd2b8b6e8ef923486b3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3c286327ba7620e0a4b828bbfb1a4a35dd22a97da124f4f274f370bb714c244f29adf1b10531d41493603c597039450b4e3294e0932f3b74a4c73149db366d7d
|
7
|
+
data.tar.gz: 7edb9ccd4d8cdb992c06181394e4f76001af1ce52850f632d8f64729877c75be2e6b4cd573802e1f0453f7a1020964d2348d83dacb2536e60c786fb5fb206a9a
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -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
data/LICENSE
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
Copyright (c) 2015, 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.
|
28
|
+
|
data/README.md
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
# AUB::Payroll
|
2
|
+
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/aub-payroll.svg)](http://badge.fury.io/rb/aub-payroll)
|
4
|
+
[![Code Climate](https://codeclimate.com/github/payrollhero/aub-payroll/badges/gpa.svg)](https://codeclimate.com/github/payrollhero/aub-payroll)
|
5
|
+
[![Build Status](https://travis-ci.org/payrollhero/aub-payroll.svg)](https://travis-ci.org/payrollhero/aub-payroll)
|
6
|
+
|
7
|
+
An AUB Payroll File Generator.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'aub-payroll'
|
15
|
+
```
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install aub-payroll
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
file = AUB::Payroll::File.new company_name: "StyroPrints",
|
29
|
+
date: Date.new(2000, 6, 2),
|
30
|
+
transactions: [
|
31
|
+
{ account_number: "001120001146", amount: 540.00 },
|
32
|
+
{ account_number: "001120001146", amount: 921.00 },
|
33
|
+
{ account_number: "001120001146", amount: 816.25 },
|
34
|
+
{ account_number: "001120001146", amount: 500.00 },
|
35
|
+
{ account_number: "001120001146", amount: 882.50 },
|
36
|
+
{ account_number: "001120001146", amount: 857.50 },
|
37
|
+
{ account_number: "001120001146", amount: 1_044.00 },
|
38
|
+
{ account_number: "001120001146", amount: 1_612.50 }
|
39
|
+
]
|
40
|
+
|
41
|
+
File.write "payroll.epf", file.content
|
42
|
+
```
|
43
|
+
|
44
|
+
## Development
|
45
|
+
|
46
|
+
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.
|
47
|
+
|
48
|
+
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).
|
49
|
+
|
50
|
+
## Contributing
|
51
|
+
|
52
|
+
1. Fork it ( https://github.com/payrollhero/aub-payroll/fork )
|
53
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
54
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
55
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
56
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/aub-payroll.gemspec
ADDED
@@ -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 'aub/payroll/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "aub-payroll"
|
8
|
+
spec.version = AUB::Payroll::VERSION
|
9
|
+
spec.authors = ["Ronald Maravilla"]
|
10
|
+
spec.email = ["rmaravilla@payrollhero.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{An AUB Payroll File Generator.}
|
13
|
+
spec.description = %q{An AUB Payroll File Generator.}
|
14
|
+
spec.homepage = "https://github.com/payrollhero/aub-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.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
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "aub/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
data/lib/aub/payroll.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require "aub/payroll/version"
|
2
|
+
require "active_support"
|
3
|
+
require "active_support/dependencies/autoload"
|
4
|
+
require "active_support/core_ext/enumerable"
|
5
|
+
|
6
|
+
module AUB
|
7
|
+
module Payroll
|
8
|
+
extend ActiveSupport::Autoload
|
9
|
+
|
10
|
+
autoload :Errors
|
11
|
+
autoload :File
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require "active_model"
|
2
|
+
|
3
|
+
module AUB
|
4
|
+
module Payroll
|
5
|
+
class File
|
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:, date:, transactions:)
|
15
|
+
@header = Header.new company_name: company_name, date: date
|
16
|
+
@rows = transactions.map { |transaction| Row.new transaction }
|
17
|
+
@footer = Footer.new number_of_records: rows.count, total_amount: rows.sum(&:amount)
|
18
|
+
end
|
19
|
+
|
20
|
+
def content
|
21
|
+
[
|
22
|
+
header,
|
23
|
+
rows,
|
24
|
+
footer,
|
25
|
+
].join("\r\n")
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
attr_accessor :header, :rows, :footer
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require "active_model"
|
2
|
+
|
3
|
+
module AUB
|
4
|
+
module Payroll
|
5
|
+
class File::Footer
|
6
|
+
include ActiveModel::Model
|
7
|
+
|
8
|
+
attr_accessor :number_of_records, :total_amount
|
9
|
+
|
10
|
+
validates :number_of_records, numericality: { greater_than: 0, less_than_or_equal_to: 999_999 }
|
11
|
+
validates :total_amount, numericality: { greater_than: 0, less_than_or_equal_to: 999_999_999_999.99 }
|
12
|
+
|
13
|
+
# @param [Integer] number_of_records:
|
14
|
+
# @param [BigDecimal] total_amount:
|
15
|
+
def initialize(*)
|
16
|
+
super
|
17
|
+
raise Errors::Invalid, errors.full_messages.to_sentence unless valid?
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
def to_s
|
22
|
+
[
|
23
|
+
"EF", # marks the end of file
|
24
|
+
formatted_number_of_records,
|
25
|
+
formatted_total_amount,
|
26
|
+
"0" * 27,
|
27
|
+
].join
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def formatted_number_of_records
|
33
|
+
"%06d" % number_of_records
|
34
|
+
end
|
35
|
+
|
36
|
+
def formatted_total_amount
|
37
|
+
"%015.2f" % total_amount
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require "active_model"
|
2
|
+
|
3
|
+
module AUB
|
4
|
+
module Payroll
|
5
|
+
class File::Header
|
6
|
+
include ActiveModel::Model
|
7
|
+
|
8
|
+
attr_accessor :company_name, :date
|
9
|
+
|
10
|
+
validates :company_name, presence: true, length: { maximum: 40 }
|
11
|
+
validates :date, presence: true
|
12
|
+
|
13
|
+
# @param [String] company_name:
|
14
|
+
# @param [Date] date:
|
15
|
+
def initialize(*)
|
16
|
+
super
|
17
|
+
raise Errors::Invalid, errors.full_messages.to_sentence unless valid?
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
def to_s
|
22
|
+
[
|
23
|
+
"BF", # marks the beginning of file
|
24
|
+
formatted_company_name,
|
25
|
+
formatted_date,
|
26
|
+
].join
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def formatted_company_name
|
32
|
+
String(company_name).upcase.ljust 40
|
33
|
+
end
|
34
|
+
|
35
|
+
def formatted_date
|
36
|
+
date.strftime "%Y%m%d"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require "active_model"
|
2
|
+
|
3
|
+
module AUB
|
4
|
+
module Payroll
|
5
|
+
class File::Row
|
6
|
+
include ActiveModel::Model
|
7
|
+
|
8
|
+
attr_accessor :account_number, :amount
|
9
|
+
|
10
|
+
validates :account_number, presence: true, length: { is: 12 }
|
11
|
+
validates :amount, numericality: { greater_than: 0, less_than_or_equal_to: 99_999_999_999.99 }
|
12
|
+
|
13
|
+
# @param [String] account_number:
|
14
|
+
# @param [BigDecimal] amount:
|
15
|
+
def initialize(*)
|
16
|
+
super
|
17
|
+
raise Errors::Invalid, errors.full_messages.to_sentence unless valid?
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
def to_s
|
22
|
+
[
|
23
|
+
"01",
|
24
|
+
account_number,
|
25
|
+
formatted_amount,
|
26
|
+
"0" * 22
|
27
|
+
].join
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def formatted_amount
|
33
|
+
"%014.2f" % amount
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
metadata
ADDED
@@ -0,0 +1,133 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: aub-payroll
|
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-10-10 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: An AUB Payroll File Generator.
|
84
|
+
email:
|
85
|
+
- rmaravilla@payrollhero.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".rspec"
|
92
|
+
- ".travis.yml"
|
93
|
+
- CODE_OF_CONDUCT.md
|
94
|
+
- Gemfile
|
95
|
+
- LICENSE
|
96
|
+
- README.md
|
97
|
+
- Rakefile
|
98
|
+
- aub-payroll.gemspec
|
99
|
+
- bin/console
|
100
|
+
- bin/setup
|
101
|
+
- lib/aub/payroll.rb
|
102
|
+
- lib/aub/payroll/errors.rb
|
103
|
+
- lib/aub/payroll/file.rb
|
104
|
+
- lib/aub/payroll/file/footer.rb
|
105
|
+
- lib/aub/payroll/file/header.rb
|
106
|
+
- lib/aub/payroll/file/row.rb
|
107
|
+
- lib/aub/payroll/version.rb
|
108
|
+
homepage: https://github.com/payrollhero/aub-payroll
|
109
|
+
licenses:
|
110
|
+
- BSD-3-Clause
|
111
|
+
metadata: {}
|
112
|
+
post_install_message:
|
113
|
+
rdoc_options: []
|
114
|
+
require_paths:
|
115
|
+
- lib
|
116
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
requirements: []
|
127
|
+
rubyforge_project:
|
128
|
+
rubygems_version: 2.2.3
|
129
|
+
signing_key:
|
130
|
+
specification_version: 4
|
131
|
+
summary: An AUB Payroll File Generator.
|
132
|
+
test_files: []
|
133
|
+
has_rdoc:
|