tax_jp 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5a7f6739291fb205178a42c73be65ba4e5c8df82
4
+ data.tar.gz: 4c098b73873a315dd44754db359456128767fc0c
5
+ SHA512:
6
+ metadata.gz: f09ec055e716f235faa1ba9c4d83b63e5360f472bbfe19e5bad39324b174f204c8090c8f3ac70b2253a4bdd04e76db9630fa6e814ec9b797c33c4ba3ae88f157
7
+ data.tar.gz: f4ce7804eba4d9e5af84b2bd08d30014dff9cca120374bb50e63816e3074a90218cc3dc9f56d20b926300f452d4f0f2f75299ef83dc3ec7bb467bb63afd0c360
data/.gitignore ADDED
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+ /.project
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 hybitz
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
data/README.md ADDED
@@ -0,0 +1,34 @@
1
+ # TaxJp
2
+
3
+ 消費税計算ライブラリ
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'tax_jp'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install tax_jp
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/[my-github-username]/tax_jp/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
32
+ =======
33
+ tax_jp
34
+ ======
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,42 @@
1
+ if (typeof tax === "undefined") {
2
+ var tax = {};
3
+ }
4
+
5
+ tax.NONTAXABLE = 1; // 非課税
6
+ tax.INCLUSIVE = 2; // 内税
7
+ tax.EXCLUSIVE = 3; // 外税
8
+
9
+ tax.RATE_3 = Date.parse('1989-04-01');
10
+ tax.RATE_5 = Date.parse('1997-04-01');
11
+ tax.RATE_8 = Date.parse('2014-04-01');
12
+
13
+ tax.getRateOn = function(date) {
14
+ if (typeof date === 'string') {
15
+ date = Date.parse(date);
16
+ }
17
+
18
+ if (date >= tax.RATE_3 && date < tax.RATE_5) {
19
+ return 0.03;
20
+ } else if (date >= tax.RATE_5 && date < tax.RATE_8) {
21
+ return 0.05;
22
+ } else if (date >= tax.RATE_8) {
23
+ return 0.08;
24
+ }
25
+
26
+ return 0;
27
+ };
28
+
29
+ tax.calcTaxAmount = function(taxType, rate, amount) {
30
+ if ( isNaN( amount ) ) {
31
+ return '';
32
+ }
33
+
34
+ if ( taxType == tax.INCLUSIVE ) {
35
+ return parseInt(amount * rate / (1 + rate));
36
+ }
37
+ else if ( taxType == tax.EXCLUSIVE ) {
38
+ return parseInt(amount * rate);
39
+ }
40
+
41
+ return '';
42
+ };
@@ -0,0 +1 @@
1
+ //= require_tree .
@@ -0,0 +1,27 @@
1
+ module TaxJp
2
+ module Calculation
3
+
4
+ def self.get_rate_on(date, options = {})
5
+ if (date.is_a?(String))
6
+ date = Date.parse(date)
7
+ end
8
+
9
+ if (date >= RATE_3 && date < RATE_5)
10
+ ret = 0.03;
11
+ elsif (date >= RATE_5 && date < RATE_8)
12
+ ret = 0.05;
13
+ elsif (date >= RATE_8)
14
+ ret = 0.08;
15
+ else
16
+ ret = 0
17
+ end
18
+
19
+ if options[:percent]
20
+ ret *= 100
21
+ end
22
+
23
+ ret
24
+ end
25
+
26
+ end
27
+ end
@@ -0,0 +1,12 @@
1
+ module TaxJp
2
+ # 消費税区分
3
+ TAX_TYPES = {
4
+ TAX_TYPE_NONTAXABLE = 1 => '非課税',
5
+ TAX_TYPE_INCLUSIVE = 2 => '内税',
6
+ TAX_TYPE_EXCLUSIVE = 3 => '外税',
7
+ }
8
+
9
+ RATE_3 = Date.parse('1989-04-01');
10
+ RATE_5 = Date.parse('1997-04-01');
11
+ RATE_8 = Date.parse('2014-04-01');
12
+ end
@@ -0,0 +1,4 @@
1
+ module TaxJp
2
+ class Engine < ::Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1,6 @@
1
+ require_relative 'calculation'
2
+
3
+ module TaxJp
4
+ class Railtie < ::Rails::Railtie
5
+ end
6
+ end
@@ -0,0 +1,3 @@
1
+ module TaxJp
2
+ VERSION = "0.0.1"
3
+ end
data/lib/tax_jp.rb ADDED
@@ -0,0 +1,8 @@
1
+ require 'tax_jp/version'
2
+ require 'tax_jp/const'
3
+ require 'tax_jp/engine'
4
+ require 'tax_jp/railtie'
5
+
6
+ module TaxJp
7
+ extend TaxJp::Calculation
8
+ end
data/tax_jp.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'tax_jp/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "tax_jp"
7
+ spec.version = TaxJp::VERSION
8
+ spec.authors = ["ichy"]
9
+ spec.email = ["ichylinux@gmail.com"]
10
+ spec.summary = %q{消費税計算ライブラリ}
11
+ spec.description = %q{消費税計算ライブラリ}
12
+ spec.homepage = ""
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.required_ruby_version = '~> 2.0'
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.7"
23
+ spec.add_dependency "activesupport", '>= 3.2.0', '< 5.0.0'
24
+ spec.add_dependency "actionpack", '>= 3.2.0', '< 5.0.0'
25
+ spec.add_dependency "railties", '>= 3.2.0', '< 5.0.0'
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ end
metadata ADDED
@@ -0,0 +1,146 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tax_jp
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - ichy
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-17 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.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: activesupport
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 3.2.0
34
+ - - "<"
35
+ - !ruby/object:Gem::Version
36
+ version: 5.0.0
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 3.2.0
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: 5.0.0
47
+ - !ruby/object:Gem::Dependency
48
+ name: actionpack
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: 3.2.0
54
+ - - "<"
55
+ - !ruby/object:Gem::Version
56
+ version: 5.0.0
57
+ type: :runtime
58
+ prerelease: false
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: 3.2.0
64
+ - - "<"
65
+ - !ruby/object:Gem::Version
66
+ version: 5.0.0
67
+ - !ruby/object:Gem::Dependency
68
+ name: railties
69
+ requirement: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: 3.2.0
74
+ - - "<"
75
+ - !ruby/object:Gem::Version
76
+ version: 5.0.0
77
+ type: :runtime
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: 3.2.0
84
+ - - "<"
85
+ - !ruby/object:Gem::Version
86
+ version: 5.0.0
87
+ - !ruby/object:Gem::Dependency
88
+ name: rake
89
+ requirement: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - "~>"
92
+ - !ruby/object:Gem::Version
93
+ version: '10.0'
94
+ type: :development
95
+ prerelease: false
96
+ version_requirements: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - "~>"
99
+ - !ruby/object:Gem::Version
100
+ version: '10.0'
101
+ description: "消費税計算ライブラリ"
102
+ email:
103
+ - ichylinux@gmail.com
104
+ executables: []
105
+ extensions: []
106
+ extra_rdoc_files: []
107
+ files:
108
+ - ".gitignore"
109
+ - Gemfile
110
+ - LICENSE
111
+ - README.md
112
+ - Rakefile
113
+ - app/assets/javascripts/tax.js
114
+ - app/assets/javascripts/tax_jp.js
115
+ - lib/tax_jp.rb
116
+ - lib/tax_jp/calculation.rb
117
+ - lib/tax_jp/const.rb
118
+ - lib/tax_jp/engine.rb
119
+ - lib/tax_jp/railtie.rb
120
+ - lib/tax_jp/version.rb
121
+ - tax_jp.gemspec
122
+ homepage: ''
123
+ licenses:
124
+ - MIT
125
+ metadata: {}
126
+ post_install_message:
127
+ rdoc_options: []
128
+ require_paths:
129
+ - lib
130
+ required_ruby_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - "~>"
133
+ - !ruby/object:Gem::Version
134
+ version: '2.0'
135
+ required_rubygems_version: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
140
+ requirements: []
141
+ rubyforge_project:
142
+ rubygems_version: 2.4.1
143
+ signing_key:
144
+ specification_version: 4
145
+ summary: "消費税計算ライブラリ"
146
+ test_files: []