train-tax-calculator 1.0.1 → 1.1.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 +4 -4
- data/Gemfile.lock +2 -2
- data/README.md +32 -4
- data/lib/train/tax/calculator.rb +58 -13
- data/lib/train/tax/calculator/version.rb +1 -1
- metadata +3 -3
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: a99645469acca17aa9b47092ded7c4c1b8f671b7
         | 
| 4 | 
            +
              data.tar.gz: e76caff248fc86acd6f1838453f498b54c4ec8d8
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: c9b2f62717b2e700b7954cad69fd1561d6b3808d6d2294e6621e23be2bf89dab4e3b653761e96072668d026a3b804846dd16d22706b62562ec1140b1b594d7d3
         | 
| 7 | 
            +
              data.tar.gz: 7a745f9940a81427f6fdd053bd2de9817b39f0d6a6315197d63a17b534516d01212715077e5e4680ad99b8c71796efe90f29612238205fc723075f2e9093cb98
         | 
    
        data/Gemfile.lock
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | @@ -16,21 +16,49 @@ Or install it yourself as: | |
| 16 16 |  | 
| 17 17 | 
             
                $ gem install train-tax-calculator
         | 
| 18 18 |  | 
| 19 | 
            +
            ## References
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            SSS [https://philpad.com/new-sss-contribution-table/](https://philpad.com/new-sss-contribution-table/)  
         | 
| 22 | 
            +
            Philhealth [https://www.philhealth.gov.ph/circulars/2017/circ2017-0024.pdf](https://www.philhealth.gov.ph/circulars/2017/circ2017-0024.pdf)  
         | 
| 23 | 
            +
            Pagibig [https://philpad.com/pagibig-contribution-table/](https://philpad.com/pagibig-contribution-table/)  
         | 
| 24 | 
            +
             | 
| 19 25 | 
             
            ## Usage
         | 
| 20 26 |  | 
| 27 | 
            +
            If using IRB, require the library first.
         | 
| 28 | 
            +
             | 
| 29 | 
            +
            ```ruby
         | 
| 30 | 
            +
            require 'train/tax/calculator'
         | 
| 31 | 
            +
            ```
         | 
| 32 | 
            +
             | 
| 33 | 
            +
            Get Withholding Tax
         | 
| 34 | 
            +
            ```ruby
         | 
| 35 | 
            +
            Train::Tax::Calculator.withholding_tax(15_000)
         | 
| 36 | 
            +
            ```
         | 
| 37 | 
            +
             | 
| 38 | 
            +
            Get Net Income
         | 
| 39 | 
            +
            ```ruby
         | 
| 40 | 
            +
            Train::Tax::Calculator.net_income(15_000)
         | 
| 41 | 
            +
            ```
         | 
| 42 | 
            +
             | 
| 21 43 | 
             
            Get SSS contribution
         | 
| 22 44 | 
             
            ```ruby
         | 
| 23 | 
            -
            Train::Tax::Calculator.for_sss(15_000) #  | 
| 45 | 
            +
            sss = Train::Tax::Calculator.for_sss(15_000) # where 15_000 is the basic salary
         | 
| 46 | 
            +
             | 
| 47 | 
            +
            # employee share
         | 
| 48 | 
            +
            sss[:es]
         | 
| 49 | 
            +
             | 
| 50 | 
            +
            # employer share
         | 
| 51 | 
            +
            sss[:er]
         | 
| 24 52 | 
             
            ```
         | 
| 25 53 |  | 
| 26 54 | 
             
            Get Pagibig contribution
         | 
| 27 55 | 
             
            ```ruby
         | 
| 28 | 
            -
            Train::Tax::Calculator.for_pagibig(15_000) #  | 
| 56 | 
            +
            Train::Tax::Calculator.for_pagibig(15_000) # where 15_000 is the basic salary
         | 
| 29 57 | 
             
            ```
         | 
| 30 58 |  | 
| 31 59 | 
             
            Get Philhealth contribution
         | 
| 32 60 | 
             
            ```ruby
         | 
| 33 | 
            -
            Train::Tax::Calculator.for_philhealth(15_000) #  | 
| 61 | 
            +
            Train::Tax::Calculator.for_philhealth(15_000) # where 15_000 is the basic salary
         | 
| 34 62 | 
             
            ```
         | 
| 35 63 |  | 
| 36 64 | 
             
            ## Development
         | 
| @@ -41,7 +69,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To | |
| 41 69 |  | 
| 42 70 | 
             
            ## Contributing
         | 
| 43 71 |  | 
| 44 | 
            -
            Bug reports and pull requests are welcome on GitHub at https://github.com/ | 
| 72 | 
            +
            Bug reports and pull requests are welcome on GitHub at https://github.com/mrkjlchvz/train-tax-calculator. 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.
         | 
| 45 73 |  | 
| 46 74 | 
             
            ## Code of Conduct
         | 
| 47 75 |  | 
    
        data/lib/train/tax/calculator.rb
    CHANGED
    
    | @@ -7,24 +7,69 @@ module Train | |
| 7 7 | 
             
              module Tax
         | 
| 8 8 | 
             
                module Calculator
         | 
| 9 9 |  | 
| 10 | 
            -
                   | 
| 11 | 
            -
                    Philhealth.compute(salary_base)
         | 
| 12 | 
            -
                  end
         | 
| 10 | 
            +
                  class << self
         | 
| 13 11 |  | 
| 14 | 
            -
             | 
| 15 | 
            -
             | 
| 16 | 
            -
             | 
| 12 | 
            +
                    def withholding_tax(basic_salary)
         | 
| 13 | 
            +
                      deductions = for_philhealth(basic_salary) + for_pagibig(basic_salary) + for_sss_es(basic_salary)
         | 
| 14 | 
            +
                      taxable_income = basic_salary - deductions
         | 
| 17 15 |  | 
| 18 | 
            -
             | 
| 19 | 
            -
                     | 
| 20 | 
            -
             | 
| 16 | 
            +
                      compute_withholding_for(taxable_income).round(2)
         | 
| 17 | 
            +
                    end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                    def net_income(basic_salary)
         | 
| 20 | 
            +
                      basic_salary - withholding_tax(basic_salary)
         | 
| 21 | 
            +
                    end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                    def for_philhealth(basic_salary)
         | 
| 24 | 
            +
                      Philhealth.compute(basic_salary)
         | 
| 25 | 
            +
                    end
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                    def for_pagibig(basic_salary)
         | 
| 28 | 
            +
                      Pagibig.compute(basic_salary)
         | 
| 29 | 
            +
                    end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                    def for_sss(basic_salary)
         | 
| 32 | 
            +
                      Sss.compute(basic_salary)
         | 
| 33 | 
            +
                    end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                    def for_sss_es(basic_salary)
         | 
| 36 | 
            +
                      Sss.compute_employee_share(basic_salary)
         | 
| 37 | 
            +
                    end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                    def for_sss_er(basic_salary)
         | 
| 40 | 
            +
                      Sss.compute_employer_share(basic_salary)
         | 
| 41 | 
            +
                    end
         | 
| 21 42 |  | 
| 22 | 
            -
                  def self.for_sss_es(salary_base)
         | 
| 23 | 
            -
                    Sss.compute_employee_share(salary_base)
         | 
| 24 43 | 
             
                  end
         | 
| 25 44 |  | 
| 26 | 
            -
                   | 
| 27 | 
            -
             | 
| 45 | 
            +
                  private
         | 
| 46 | 
            +
             | 
| 47 | 
            +
                  def self.compute_withholding_for(income)
         | 
| 48 | 
            +
                    if income >= 666_667.00
         | 
| 49 | 
            +
             | 
| 50 | 
            +
                      200_833.33 + ((income - 666_667.00) * 0.35)
         | 
| 51 | 
            +
             | 
| 52 | 
            +
                    elsif income >= 166_667.00
         | 
| 53 | 
            +
             | 
| 54 | 
            +
                      40_833.33 + ((income - 166_667.00) * 0.32)
         | 
| 55 | 
            +
             | 
| 56 | 
            +
                    elsif income >= 66_667.00
         | 
| 57 | 
            +
             | 
| 58 | 
            +
                      10_833.33 + ((income - 66_667.00) * 0.30)
         | 
| 59 | 
            +
             | 
| 60 | 
            +
                    elsif income >= 33_333.00
         | 
| 61 | 
            +
             | 
| 62 | 
            +
                      2_500.00 + ((income - 33_333.00) * 0.25)
         | 
| 63 | 
            +
             | 
| 64 | 
            +
                    elsif income >= 20_833.00
         | 
| 65 | 
            +
             | 
| 66 | 
            +
                      0.00 + ((income - 20_833.00) * 0.20)
         | 
| 67 | 
            +
             | 
| 68 | 
            +
                    else
         | 
| 69 | 
            +
             | 
| 70 | 
            +
                      0.00
         | 
| 71 | 
            +
             | 
| 72 | 
            +
                    end
         | 
| 28 73 | 
             
                  end
         | 
| 29 74 |  | 
| 30 75 | 
             
                end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: train-tax-calculator
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1.0 | 
| 4 | 
            +
              version: 1.1.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Mark Chavez
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: exe
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2018-02- | 
| 11 | 
            +
            date: 2018-02-06 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: bundler
         | 
| @@ -96,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 96 96 | 
             
                  version: '0'
         | 
| 97 97 | 
             
            requirements: []
         | 
| 98 98 | 
             
            rubyforge_project: 
         | 
| 99 | 
            -
            rubygems_version: 2.6. | 
| 99 | 
            +
            rubygems_version: 2.6.12
         | 
| 100 100 | 
             
            signing_key: 
         | 
| 101 101 | 
             
            specification_version: 4
         | 
| 102 102 | 
             
            summary: TRAIN Tax Calculator for PH 2018
         |