Class: TaxJp::WithheldTaxes::Bonus

Inherits:
Object
  • Object
show all
Defined in:
lib/tax_jp/withheld_taxes/bonus.rb

Constant Summary collapse

DB_PATH =
File.join(TaxJp::Utils.data_dir, '源泉徴収税賞与.db')

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(row) ⇒ Bonus

Returns a new instance of Bonus.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/tax_jp/withheld_taxes/bonus.rb', line 19

def initialize(row)
  @valid_from = row[0]
  @valid_until = row[1]
  @tax_ratio = row[2]
  @dependent_0_salary_from = row[3]
  @dependent_0_salary_to = row[4]
  @dependent_1_salary_from = row[5]
  @dependent_1_salary_to = row[6]
  @dependent_2_salary_from = row[7]
  @dependent_2_salary_to = row[8]
  @dependent_3_salary_from = row[9]
  @dependent_3_salary_to = row[10]
  @dependent_4_salary_from = row[11]
  @dependent_4_salary_to = row[12]
  @dependent_5_salary_from = row[13]
  @dependent_5_salary_to = row[14]
  @dependent_6_salary_from = row[15]
  @dependent_6_salary_to = row[16]
  @dependent_7_salary_from = row[17]
  @dependent_7_salary_to = row[18]
  @sub_salary_from = row[19]
  @sub_salary_to = row[20]
end

Instance Attribute Details

#dependent_0_salary_fromObject (readonly)

Returns the value of attribute dependent_0_salary_from.



9
10
11
# File 'lib/tax_jp/withheld_taxes/bonus.rb', line 9

def dependent_0_salary_from
  @dependent_0_salary_from
end

#dependent_0_salary_toObject (readonly)

Returns the value of attribute dependent_0_salary_to.



9
10
11
# File 'lib/tax_jp/withheld_taxes/bonus.rb', line 9

def dependent_0_salary_to
  @dependent_0_salary_to
end

#dependent_1_salary_fromObject (readonly)

Returns the value of attribute dependent_1_salary_from.



10
11
12
# File 'lib/tax_jp/withheld_taxes/bonus.rb', line 10

def dependent_1_salary_from
  @dependent_1_salary_from
end

#dependent_1_salary_toObject (readonly)

Returns the value of attribute dependent_1_salary_to.



10
11
12
# File 'lib/tax_jp/withheld_taxes/bonus.rb', line 10

def dependent_1_salary_to
  @dependent_1_salary_to
end

#dependent_2_salary_fromObject (readonly)

Returns the value of attribute dependent_2_salary_from.



11
12
13
# File 'lib/tax_jp/withheld_taxes/bonus.rb', line 11

def dependent_2_salary_from
  @dependent_2_salary_from
end

#dependent_2_salary_toObject (readonly)

Returns the value of attribute dependent_2_salary_to.



11
12
13
# File 'lib/tax_jp/withheld_taxes/bonus.rb', line 11

def dependent_2_salary_to
  @dependent_2_salary_to
end

#dependent_3_salary_fromObject (readonly)

Returns the value of attribute dependent_3_salary_from.



12
13
14
# File 'lib/tax_jp/withheld_taxes/bonus.rb', line 12

def dependent_3_salary_from
  @dependent_3_salary_from
end

#dependent_3_salary_toObject (readonly)

Returns the value of attribute dependent_3_salary_to.



12
13
14
# File 'lib/tax_jp/withheld_taxes/bonus.rb', line 12

def dependent_3_salary_to
  @dependent_3_salary_to
end

#dependent_4_salary_fromObject (readonly)

Returns the value of attribute dependent_4_salary_from.



13
14
15
# File 'lib/tax_jp/withheld_taxes/bonus.rb', line 13

def dependent_4_salary_from
  @dependent_4_salary_from
end

#dependent_4_salary_toObject (readonly)

Returns the value of attribute dependent_4_salary_to.



13
14
15
# File 'lib/tax_jp/withheld_taxes/bonus.rb', line 13

def dependent_4_salary_to
  @dependent_4_salary_to
end

#dependent_5_salary_fromObject (readonly)

Returns the value of attribute dependent_5_salary_from.



14
15
16
# File 'lib/tax_jp/withheld_taxes/bonus.rb', line 14

def dependent_5_salary_from
  @dependent_5_salary_from
end

#dependent_5_salary_toObject (readonly)

Returns the value of attribute dependent_5_salary_to.



14
15
16
# File 'lib/tax_jp/withheld_taxes/bonus.rb', line 14

def dependent_5_salary_to
  @dependent_5_salary_to
end

#dependent_6_salary_fromObject (readonly)

Returns the value of attribute dependent_6_salary_from.



15
16
17
# File 'lib/tax_jp/withheld_taxes/bonus.rb', line 15

def dependent_6_salary_from
  @dependent_6_salary_from
end

#dependent_6_salary_toObject (readonly)

Returns the value of attribute dependent_6_salary_to.



15
16
17
# File 'lib/tax_jp/withheld_taxes/bonus.rb', line 15

def dependent_6_salary_to
  @dependent_6_salary_to
end

#dependent_7_salary_fromObject (readonly)

Returns the value of attribute dependent_7_salary_from.



16
17
18
# File 'lib/tax_jp/withheld_taxes/bonus.rb', line 16

def dependent_7_salary_from
  @dependent_7_salary_from
end

#dependent_7_salary_toObject (readonly)

Returns the value of attribute dependent_7_salary_to.



16
17
18
# File 'lib/tax_jp/withheld_taxes/bonus.rb', line 16

def dependent_7_salary_to
  @dependent_7_salary_to
end

#sub_salary_fromObject (readonly)

Returns the value of attribute sub_salary_from.



17
18
19
# File 'lib/tax_jp/withheld_taxes/bonus.rb', line 17

def sub_salary_from
  @sub_salary_from
end

#sub_salary_toObject (readonly)

Returns the value of attribute sub_salary_to.



17
18
19
# File 'lib/tax_jp/withheld_taxes/bonus.rb', line 17

def sub_salary_to
  @sub_salary_to
end

#tax_ratioObject (readonly)

Returns the value of attribute tax_ratio.



8
9
10
# File 'lib/tax_jp/withheld_taxes/bonus.rb', line 8

def tax_ratio
  @tax_ratio
end

#valid_fromObject (readonly)

Returns the value of attribute valid_from.



7
8
9
# File 'lib/tax_jp/withheld_taxes/bonus.rb', line 7

def valid_from
  @valid_from
end

#valid_untilObject (readonly)

Returns the value of attribute valid_until.



7
8
9
# File 'lib/tax_jp/withheld_taxes/bonus.rb', line 7

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_taxes/bonus.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(DB_PATH) do |db|
    sql = 'select * from bonus_withheld_taxes where valid_from <= ? and valid_until >= ? order by tax_ratio'
    
    ret = []
    db.execute(sql, [date, date]) do |row|
      ret << TaxJp::WithheldTaxes::Bonus.new(row)
    end
  
    ret
  end
end

.find_by_date_and_salary_and_dependant(date, salary, dependent) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/tax_jp/withheld_taxes/bonus.rb', line 61

def self.find_by_date_and_salary_and_dependant(date, salary, dependent)
  date = date.strftime('%Y-%m-%d') if date.is_a?(Date)
  dependent = dependent.to_i

  TaxJp::Utils.with_database(DB_PATH) do |db|
    sql = "select * from bonus_withheld_taxes "
    sql << "where valid_from <= ? and valid_until >= ? "
    sql << "  and dependent_#{dependent}_salary_from <= ? and dependent_#{dependent}_salary_to > ?"
    
    ret = nil
    db.execute(sql, [date, date, salary, salary]) do |row|
      ret = TaxJp::WithheldTaxes::Bonus.new(row)
    end
  
    ret
  end
end

Instance Method Details

#tax_ratio_percentObject



43
44
45
# File 'lib/tax_jp/withheld_taxes/bonus.rb', line 43

def tax_ratio_percent
  (tax_ratio * 100).round(3)
end