uob-payroll 1.0.8 → 1.2.0

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
- SHA1:
3
- metadata.gz: bf5115588208dc5a7cf7d82a3cdeac8975754d21
4
- data.tar.gz: eaad5679f122643e360f3e1226c2e5bdd89083d0
2
+ SHA256:
3
+ metadata.gz: a7840f406e4d26612d4196a691b1092954952198312ba047393cd8ec3ee0bb01
4
+ data.tar.gz: df925c8ac447937c3f509f41ee6b58e5cb0f90b7c8936c639f73e41ce5dd5e77
5
5
  SHA512:
6
- metadata.gz: 05f0f214b5ae24db50597495eab7b88eaf61aed0ebd89e082e55ab6e9ec48f8a8c7a191c3b7d142b7cf521c6c29dc19b95ccb3efa53fbd29b1737d5cd5d07e49
7
- data.tar.gz: 9ed79b47f2c32c299f9c830a6919e2654e83f4b9ab22c8e3f6d4eff9c6a0eccdd2915cb4512faea76278cc8461355afa990dc013bfa62f25fa24d0083e9e48d8
6
+ metadata.gz: 106efdd8408e2c622bc353ba5b240b2edfaf41da1662384e9dfcc7044f674665b3fed796e6f30ce53be43507cb20bce8b6a006fa291c3ee23167fb5a5cc92487
7
+ data.tar.gz: 0b4e84c967f8eb9ffb011b4b503a1a893bbe547bc9f27acba5a6068d5685b29ee3918144e9050fe33a7ef99396384d3d6d6dca4ff129d2ff2ba06c237d6f3528
@@ -0,0 +1,39 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: build
9
+
10
+ on: [push, pull_request]
11
+
12
+ jobs:
13
+ test:
14
+ runs-on: ubuntu-20.04
15
+ strategy:
16
+ fail-fast: false
17
+ matrix:
18
+ ruby:
19
+ - 3.1
20
+ - '3.0'
21
+ - 2.7
22
+ - 2.6
23
+ gemfile:
24
+ - Gemfile-6-1
25
+ - Gemfile-7-0
26
+ exclude:
27
+ - gemfile: Gemfile-6-1
28
+ ruby: 3.1
29
+ - gemfile: Gemfile-7-0
30
+ ruby: 2.6
31
+ env:
32
+ BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}
33
+ steps:
34
+ - uses: actions/checkout@v2
35
+ - uses: ruby/setup-ruby@v1
36
+ with:
37
+ ruby-version: ${{ matrix.ruby }}
38
+ bundler-cache: true
39
+ - run: bundle exec rspec
data/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # Change Log
2
2
 
3
+ ## [v1.2.0](https://github.com/payrollhero/aub-payroll/tree/v1.2.0) (2022-12-06)
4
+ [Full Changelog](https://github.com/payrollhero/aub-payroll/compare/v1.1.1...v1.2.0)
5
+
6
+ ## [v1.1.1](https://github.com/payrollhero/aub-payroll/tree/v1.1.1) (2021-08-30)
7
+ [Full Changelog](https://github.com/payrollhero/aub-payroll/compare/v1.1.0...v1.1.1)
8
+
9
+ ## [v1.1.0](https://github.com/payrollhero/aub-payroll/tree/v1.1.0) (2019-08-15)
10
+ [Full Changelog](https://github.com/payrollhero/aub-payroll/compare/v1.0.8...v1.1.0)
11
+
12
+ ## [v1.0.8](https://github.com/payrollhero/aub-payroll/tree/v1.0.8) (2016-04-28)
13
+ [Full Changelog](https://github.com/payrollhero/aub-payroll/compare/v1.0.7...v1.0.8)
14
+
15
+ ## [v1.0.7](https://github.com/payrollhero/aub-payroll/tree/v1.0.7) (2016-04-27)
16
+ [Full Changelog](https://github.com/payrollhero/aub-payroll/compare/v1.0.6...v1.0.7)
17
+
18
+ ## [v1.0.6](https://github.com/payrollhero/aub-payroll/tree/v1.0.6) (2016-04-26)
19
+ [Full Changelog](https://github.com/payrollhero/aub-payroll/compare/v1.0.1...v1.0.6)
20
+
3
21
  ## [v1.0.1](https://github.com/payrollhero/aub-payroll/tree/v1.0.1) (2016-03-22)
4
22
  [Full Changelog](https://github.com/payrollhero/aub-payroll/compare/v1.0.0...v1.0.1)
5
23
 
@@ -14,4 +32,4 @@
14
32
  ## [v0.1.0](https://github.com/payrollhero/aub-payroll/tree/v0.1.0) (2015-10-10)
15
33
 
16
34
 
17
- \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
35
+ \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec path: '..'
4
+
5
+ gem 'rails', '~> 5.0.7'
6
+ gem 'sqlite3', '< 1.4'
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec path: '..'
4
+
5
+ gem 'rails', '~> 5.1.4'
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec path: '..'
4
+
5
+ gem 'rails', '~> 5.2.6'
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec path: '..'
4
+
5
+ gem 'rails', '~> 6.0.4'
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec path: '..'
4
+
5
+ gem 'rails', '~> 6.1.4'
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec path: '..'
4
+
5
+ gem 'rails', '~> 7.0'
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec path: '..'
4
+
5
+ gem 'rails', '~> 7.1'
@@ -0,0 +1,51 @@
1
+ module TxtData
2
+ # A helpful module for formatting fields for fixed length txt data files.
3
+ module FormatHelpers
4
+ # Right justified, "0" padded, 2 decimal places, with no separator.
5
+ # @param [Fixnum] value
6
+ # @param [Fixnum] length
7
+ def money_format(value, length:, just: :right, pad: '0')
8
+ txt = ("%.2f" % value.round(2)).to_s.sub(".", "").truncate(length, omission: "")
9
+ justify(txt, length, just, pad)
10
+ end
11
+
12
+ # Right justified, "0" padded, no decimal places, with no separator.
13
+ # @param [Fixnum] value
14
+ # @param [Fixnum] length
15
+ # @param [Symbol] just
16
+ # @param [String] pad
17
+ def number_format(value, length:, just: :right, pad: '0')
18
+ txt = value.to_i.to_s.truncate(length, omission: "")
19
+ justify(txt, length, just, pad)
20
+ end
21
+
22
+ # Left justified, " " padded, text.
23
+ # @param [String] value
24
+ # @param [Fixnum] length
25
+ # @param [Symbol] just
26
+ # @param [String] pad
27
+ def text_format(value, length:, just: :left, sanitize:, pad: ' ')
28
+ txt = sanitize ? filter_illegal_characters(value.to_s).truncate(length, omission: "") : value
29
+ justify(txt, length, just, pad)
30
+ end
31
+
32
+ # Filters invalid characters specified in CPF eSubmission spec file.
33
+ # @param [String] value
34
+ def filter_illegal_characters(value)
35
+ value.tr("-_+$<>:;?!=[]`^|\\'\"`~", "")
36
+ end
37
+
38
+ private
39
+
40
+ def justify(txt, length, just, pad)
41
+ case just
42
+ when :left
43
+ txt.ljust(length, pad)
44
+ when :right
45
+ txt.rjust(length, pad)
46
+ else
47
+ raise ArgumentError, "Justification #{just} is not supported."
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,43 @@
1
+ require 'txt_data/format_helpers'
2
+
3
+ module TxtData::TxtDataRowDSL
4
+ Field = Struct.new(:symbol, :range, :just, :pad, :value, :format, :sanitize) do
5
+ include TxtData::FormatHelpers
6
+
7
+ def to_s(record)
8
+ data = get_data(record)
9
+ validate_length!(data)
10
+ format_data data
11
+ end
12
+
13
+ private
14
+
15
+ def format_data(data)
16
+ case format
17
+ when :text
18
+ format_text(data, sanitize: sanitize)
19
+ when :number
20
+ number_format(data, length: range.size, just: just, pad: pad)
21
+ when :money
22
+ money_format(data, length: range.size, just: just, pad: pad)
23
+ else
24
+ raise ArgumentError, "Unsupported format #{format}"
25
+ end
26
+ end
27
+
28
+ def validate_length!(data)
29
+ #Do not use .blank? we need to match ' ' for pad.
30
+ if (pad.nil? || pad.empty?) && data.length != range.size
31
+ raise ArgumentError, "Data #{data} is not the correct length for field #{symbol}"
32
+ end
33
+ end
34
+
35
+ def get_data(record)
36
+ value || record.public_send(symbol)
37
+ end
38
+
39
+ def format_text(data, sanitize:)
40
+ text_format(data.to_s, length: range.size, just: just, pad: pad, sanitize: sanitize)
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,79 @@
1
+ module TxtData
2
+ # DSL for defining a class which gives you back a row of a txt data file.
3
+ # @example
4
+ # class MyTxtRow
5
+ # include TxtData::TxtDataRowDSL
6
+ # text :date, 1..6
7
+ # spaces 7..51
8
+ # number :my_number, 52..55
9
+ # text :my_text, 56..58
10
+ # text :my_fixed_text, 58..71, value: '1234'
11
+ #
12
+ # def date
13
+ # '151201'
14
+ # end
15
+ #
16
+ # def my_number
17
+ # 12
18
+ # end
19
+ #
20
+ # def my_text
21
+ # "barf"
22
+ # end
23
+ # end
24
+ # Use #text to define some text, it is by default left padded with spaces
25
+ # Use #number fo define a number, it is by default left padded with zeroes
26
+ # Use #spaces to add spaces in that field.
27
+ module TxtDataRowDSL
28
+ extend ActiveSupport::Concern
29
+ extend ActiveSupport::Autoload
30
+ autoload :Field
31
+
32
+ class_methods do
33
+ def fields
34
+ @fields ||= []
35
+ end
36
+
37
+ # Add a text field, right justified with space padding by default.
38
+ # @param [Symbol] symbol
39
+ # @param [Range] range
40
+ # @param [:right|:left] just
41
+ # @param [String] pad
42
+ # @param [String] value
43
+ def text(symbol, range, just: :right, pad: ' ', value: nil, sanitize: true)
44
+ data(symbol, range, just: just, pad: pad, format: :text, value: value, sanitize: sanitize)
45
+ end
46
+
47
+ def money(symbol, range, just: :right, pad: '0', value: nil)
48
+ data(symbol, range, just: just, pad: pad, format: :money, value: value)
49
+ end
50
+
51
+ # Add a number field, right justified with zero padding by default.
52
+ # @param [Symbol] symbol
53
+ # @param [Range] range
54
+ # @param [:right|:left] just
55
+ # @param [String] pad
56
+ # @param [String] value
57
+ def number(symbol, range, just: :right, pad: '0', value: nil)
58
+ data(symbol, range, just: just, pad: pad, format: :number, value: value)
59
+ end
60
+
61
+ # @param [Range] range
62
+ def spaces(range)
63
+ data(:spaces, range, just: :left, pad: ' ', format: :text, value: ' ' * range.size)
64
+ end
65
+
66
+ private
67
+
68
+ def data(symbol, range, just: :none, pad:, value: nil, format: :text, sanitize: true)
69
+ fields << Field.new(symbol, range, just, pad, value, format, sanitize)
70
+ end
71
+ end
72
+
73
+ def to_s
74
+ self.class.fields.map { |field|
75
+ field.to_s(self)
76
+ }.join("")
77
+ end
78
+ end
79
+ end
@@ -1,12 +1,12 @@
1
1
  require 'active_model'
2
- require 'ph_utility'
3
2
  require_relative '../hash_calculator'
3
+ require 'txt_data/txt_data_row_dsl'
4
4
 
5
5
  module UOB
6
6
  module Payroll
7
7
  class TXTFile::Footer
8
8
  include ActiveModel::Model
9
- include PhUtility::TxtData::TxtDataRowDSL
9
+ include TxtData::TxtDataRowDSL
10
10
 
11
11
  number :record_type, 1..1, value: 9
12
12
  text :formatted_total_amount, 2..19, just: :right, pad: '0'
@@ -1,11 +1,11 @@
1
1
  require 'active_model'
2
- require 'ph_utility'
2
+ require 'txt_data/txt_data_row_dsl'
3
3
 
4
4
  module UOB
5
5
  module Payroll
6
6
  class TXTFile::Header
7
7
  include ActiveModel::Model
8
- include PhUtility::TxtData::TxtDataRowDSL
8
+ include TxtData::TxtDataRowDSL
9
9
 
10
10
  number :record_type, 1..1, value: 1
11
11
  text :filename, 2..11
@@ -1,11 +1,11 @@
1
1
  require 'active_model'
2
- require 'ph_utility'
2
+ require 'txt_data/txt_data_row_dsl'
3
3
 
4
4
  module UOB
5
5
  module Payroll
6
6
  class TXTFile::Row
7
7
  include ActiveModel::Model
8
- include PhUtility::TxtData::TxtDataRowDSL
8
+ include TxtData::TxtDataRowDSL
9
9
 
10
10
  number :record_type, 1..1, value: 2
11
11
  text :receiving_bic_code, 2..12, just: :left
@@ -30,13 +30,13 @@ module UOB
30
30
  @bic_code = bic_code
31
31
  @account_number = account_number
32
32
  @account_name = account_name
33
- @amount = amount
33
+ @amount = amount.is_a?(String) ? BigDecimal(amount) : amount
34
34
 
35
35
  raise Errors::Invalid, errors.full_messages.to_sentence unless valid?
36
36
  end
37
37
 
38
38
  def formatted_amount
39
- (format '%014.2f', amount).gsub('.','')
39
+ (format '%014.2f', amount.round(2)).gsub('.','')
40
40
  end
41
41
 
42
42
  def receiving_bic_code
@@ -19,7 +19,7 @@ module UOB
19
19
  creation_date: date,
20
20
  value_date: payable_date
21
21
  )
22
- @rows = transactions.map { |transaction| Row.new transaction }
22
+ @rows = transactions.map { |transaction| Row.new **transaction }
23
23
  @footer = Footer.new total_amount: total_amount(rows), header: header, rows: rows
24
24
  end
25
25
 
@@ -1,5 +1,5 @@
1
1
  module Uob
2
2
  module Payroll
3
- VERSION = "1.0.8"
3
+ VERSION = "1.2.0"
4
4
  end
5
5
  end
data/uob-payroll.gemspec CHANGED
@@ -18,15 +18,15 @@ Gem::Specification.new do |spec|
18
18
  spec.bindir = "exe"
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
20
  spec.require_paths = ["lib"]
21
+ spec.required_ruby_version = '>= 2.6.0'
21
22
 
22
- spec.add_development_dependency "bundler", "~> 1.11"
23
- spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "bundler", "> 1.16", "< 3"
24
+ spec.add_development_dependency "rake"
24
25
  spec.add_development_dependency "rspec", "~> 3.0"
25
26
  spec.add_development_dependency 'pry'
26
27
  spec.add_development_dependency 'github_changelog_generator'
27
28
 
28
- spec.add_dependency 'activesupport'
29
- spec.add_dependency 'activemodel'
30
- spec.add_dependency 'ph_model'
31
- spec.add_dependency 'ph_utility'
29
+ spec.add_runtime_dependency 'activesupport', '>= 6.1.0'
30
+ spec.add_runtime_dependency 'activemodel', '>= 6.1.0'
31
+ spec.add_runtime_dependency 'ph_model'
32
32
  end
metadata CHANGED
@@ -1,43 +1,49 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uob-payroll
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.8
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vincent Paca
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-04-28 00:00:00.000000000 Z
11
+ date: 2022-12-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ - - "<"
18
21
  - !ruby/object:Gem::Version
19
- version: '1.11'
22
+ version: '3'
20
23
  type: :development
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">"
28
+ - !ruby/object:Gem::Version
29
+ version: '1.16'
30
+ - - "<"
25
31
  - !ruby/object:Gem::Version
26
- version: '1.11'
32
+ version: '3'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: rake
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
- - - "~>"
37
+ - - ">="
32
38
  - !ruby/object:Gem::Version
33
- version: '10.0'
39
+ version: '0'
34
40
  type: :development
35
41
  prerelease: false
36
42
  version_requirements: !ruby/object:Gem::Requirement
37
43
  requirements:
38
- - - "~>"
44
+ - - ">="
39
45
  - !ruby/object:Gem::Version
40
- version: '10.0'
46
+ version: '0'
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: rspec
43
49
  requirement: !ruby/object:Gem::Requirement
@@ -86,28 +92,28 @@ dependencies:
86
92
  requirements:
87
93
  - - ">="
88
94
  - !ruby/object:Gem::Version
89
- version: '0'
95
+ version: 6.1.0
90
96
  type: :runtime
91
97
  prerelease: false
92
98
  version_requirements: !ruby/object:Gem::Requirement
93
99
  requirements:
94
100
  - - ">="
95
101
  - !ruby/object:Gem::Version
96
- version: '0'
102
+ version: 6.1.0
97
103
  - !ruby/object:Gem::Dependency
98
104
  name: activemodel
99
105
  requirement: !ruby/object:Gem::Requirement
100
106
  requirements:
101
107
  - - ">="
102
108
  - !ruby/object:Gem::Version
103
- version: '0'
109
+ version: 6.1.0
104
110
  type: :runtime
105
111
  prerelease: false
106
112
  version_requirements: !ruby/object:Gem::Requirement
107
113
  requirements:
108
114
  - - ">="
109
115
  - !ruby/object:Gem::Version
110
- version: '0'
116
+ version: 6.1.0
111
117
  - !ruby/object:Gem::Dependency
112
118
  name: ph_model
113
119
  requirement: !ruby/object:Gem::Requirement
@@ -122,20 +128,6 @@ dependencies:
122
128
  - - ">="
123
129
  - !ruby/object:Gem::Version
124
130
  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
131
  description: A UOB Payroll File Generator
140
132
  email:
141
133
  - vpaca@payrollhero.com
@@ -143,6 +135,7 @@ executables: []
143
135
  extensions: []
144
136
  extra_rdoc_files: []
145
137
  files:
138
+ - ".github/workflows/build.yml"
146
139
  - ".gitignore"
147
140
  - ".rspec"
148
141
  - ".travis.yml"
@@ -155,6 +148,16 @@ files:
155
148
  - Rakefile
156
149
  - bin/console
157
150
  - bin/setup
151
+ - gemfiles/Gemfile-5-0
152
+ - gemfiles/Gemfile-5-1
153
+ - gemfiles/Gemfile-5-2
154
+ - gemfiles/Gemfile-6-0
155
+ - gemfiles/Gemfile-6-1
156
+ - gemfiles/Gemfile-7-0
157
+ - gemfiles/Gemfile-7-1
158
+ - lib/txt_data/format_helpers.rb
159
+ - lib/txt_data/txt_data_row_dsl.rb
160
+ - lib/txt_data/txt_data_row_dsl/field.rb
158
161
  - lib/uob/payroll.rb
159
162
  - lib/uob/payroll/errors.rb
160
163
  - lib/uob/payroll/hash_calculator.rb
@@ -169,7 +172,7 @@ homepage: https://github.com/payrollhero/uob-payroll
169
172
  licenses:
170
173
  - BSD-3-Clause
171
174
  metadata: {}
172
- post_install_message:
175
+ post_install_message:
173
176
  rdoc_options: []
174
177
  require_paths:
175
178
  - lib
@@ -177,16 +180,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
177
180
  requirements:
178
181
  - - ">="
179
182
  - !ruby/object:Gem::Version
180
- version: '0'
183
+ version: 2.6.0
181
184
  required_rubygems_version: !ruby/object:Gem::Requirement
182
185
  requirements:
183
186
  - - ">="
184
187
  - !ruby/object:Gem::Version
185
188
  version: '0'
186
189
  requirements: []
187
- rubyforge_project:
188
- rubygems_version: 2.5.1
189
- signing_key:
190
+ rubygems_version: 3.2.33
191
+ signing_key:
190
192
  specification_version: 4
191
193
  summary: A UOB Payroll File Generator
192
194
  test_files: []