Class: TaxJp::WithheldTax
- Inherits:
-
Object
- Object
- TaxJp::WithheldTax
- Defined in:
- lib/tax_jp/withheld_tax.rb
Constant Summary collapse
Instance Attribute Summary collapse
-
#dependent_0 ⇒ Object
readonly
Returns the value of attribute dependent_0.
-
#dependent_1 ⇒ Object
readonly
Returns the value of attribute dependent_1.
-
#dependent_2 ⇒ Object
readonly
Returns the value of attribute dependent_2.
-
#dependent_3 ⇒ Object
readonly
Returns the value of attribute dependent_3.
-
#dependent_4 ⇒ Object
readonly
Returns the value of attribute dependent_4.
-
#dependent_5 ⇒ Object
readonly
Returns the value of attribute dependent_5.
-
#dependent_6 ⇒ Object
readonly
Returns the value of attribute dependent_6.
-
#dependent_7 ⇒ Object
readonly
Returns the value of attribute dependent_7.
-
#salary_range_from ⇒ Object
readonly
Returns the value of attribute salary_range_from.
-
#salary_range_to ⇒ Object
readonly
Returns the value of attribute salary_range_to.
-
#sub_salary ⇒ Object
readonly
Returns the value of attribute sub_salary.
-
#valid_from ⇒ Object
readonly
Returns the value of attribute valid_from.
-
#valid_until ⇒ Object
readonly
Returns the value of attribute valid_until.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(row) ⇒ WithheldTax
constructor
A new instance of WithheldTax.
Constructor Details
#initialize(row) ⇒ WithheldTax
Returns a new instance of WithheldTax.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/tax_jp/withheld_tax.rb', line 14 def initialize(row) @valid_from = row[0] @valid_until = row[1] @salary_range_from = row[2] @salary_range_to = row[3] @dependent_0 = row[4] @dependent_1 = row[5] @dependent_2 = row[6] @dependent_3 = row[7] @dependent_4 = row[8] @dependent_5 = row[9] @dependent_6 = row[10] @dependent_7 = row[11] @sub_salary = row[12] end |
Instance Attribute Details
#dependent_0 ⇒ Object (readonly)
Returns the value of attribute dependent_0.
11 12 13 |
# File 'lib/tax_jp/withheld_tax.rb', line 11 def dependent_0 @dependent_0 end |
#dependent_1 ⇒ Object (readonly)
Returns the value of attribute dependent_1.
11 12 13 |
# File 'lib/tax_jp/withheld_tax.rb', line 11 def dependent_1 @dependent_1 end |
#dependent_2 ⇒ Object (readonly)
Returns the value of attribute dependent_2.
11 12 13 |
# File 'lib/tax_jp/withheld_tax.rb', line 11 def dependent_2 @dependent_2 end |
#dependent_3 ⇒ Object (readonly)
Returns the value of attribute dependent_3.
11 12 13 |
# File 'lib/tax_jp/withheld_tax.rb', line 11 def dependent_3 @dependent_3 end |
#dependent_4 ⇒ Object (readonly)
Returns the value of attribute dependent_4.
11 12 13 |
# File 'lib/tax_jp/withheld_tax.rb', line 11 def dependent_4 @dependent_4 end |
#dependent_5 ⇒ Object (readonly)
Returns the value of attribute dependent_5.
11 12 13 |
# File 'lib/tax_jp/withheld_tax.rb', line 11 def dependent_5 @dependent_5 end |
#dependent_6 ⇒ Object (readonly)
Returns the value of attribute dependent_6.
11 12 13 |
# File 'lib/tax_jp/withheld_tax.rb', line 11 def dependent_6 @dependent_6 end |
#dependent_7 ⇒ Object (readonly)
Returns the value of attribute dependent_7.
11 12 13 |
# File 'lib/tax_jp/withheld_tax.rb', line 11 def dependent_7 @dependent_7 end |
#salary_range_from ⇒ Object (readonly)
Returns the value of attribute salary_range_from.
10 11 12 |
# File 'lib/tax_jp/withheld_tax.rb', line 10 def salary_range_from @salary_range_from end |
#salary_range_to ⇒ Object (readonly)
Returns the value of attribute salary_range_to.
10 11 12 |
# File 'lib/tax_jp/withheld_tax.rb', line 10 def salary_range_to @salary_range_to end |
#sub_salary ⇒ Object (readonly)
Returns the value of attribute sub_salary.
12 13 14 |
# File 'lib/tax_jp/withheld_tax.rb', line 12 def sub_salary @sub_salary end |
#valid_from ⇒ Object (readonly)
Returns the value of attribute valid_from.
9 10 11 |
# File 'lib/tax_jp/withheld_tax.rb', line 9 def valid_from @valid_from end |
#valid_until ⇒ Object (readonly)
Returns the value of attribute valid_until.
9 10 11 |
# File 'lib/tax_jp/withheld_tax.rb', line 9 def valid_until @valid_until end |
Class Method Details
.find_all_by_date(date) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/tax_jp/withheld_tax.rb', line 47 def self.find_all_by_date(date) date = date.strftime('%Y-%m-%d') if date.is_a?(Date) TaxJp::Utils.with_database(MONTHLY_DB_PATH) do |db| sql = 'select * from withheld_taxes where valid_from <= ? and valid_until >= ?' ret = [] db.execute(sql, [date, date]) do |row| ret << TaxJp::WithheldTax.new(row) end ret.sort{|a, b| a.salary_range_from <=> b.salary_range_from } end end |
.find_by_date_and_salary(date, salary) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/tax_jp/withheld_tax.rb', line 30 def self.find_by_date_and_salary(date, salary) date = date.strftime('%Y-%m-%d') if date.is_a?(Date) TaxJp::Utils.with_database(MONTHLY_DB_PATH) do |db| sql = 'select * from withheld_taxes where valid_from <= ? and valid_until >= ? and salary_range_from <= ? and salary_range_to > ?' ret = nil db.execute(sql, [date, date, salary, salary]) do |row| if ret raise "源泉徴収税が重複して登録されています。date=#{date}, salary=#{salary}" else ret = TaxJp::WithheldTax.new(row) end end ret end end |