module Luca::Jp::Util

Public Instance Methods

beppyo2_config(key) click to toggle source
# File lib/luca/jp/util.rb, line 74
def beppyo2_config(key)
  config.dig('jp', 'beppyo2', key)
end
config() click to toggle source
# File lib/luca/jp/util.rb, line 66
def config
  EX_CONF.nil? ? LucaSupport::CONFIG : LucaSupport::CONFIG.merge(EX_CONF)
end
eltax_config(key) click to toggle source
# File lib/luca/jp/util.rb, line 89
def eltax_config(key)
  config.dig('jp', 'eltax', key)
end
etax_date(date) click to toggle source
# File lib/luca/jp/util.rb, line 62
def etax_date(date)
  "<gen:era>#{gengou(date)}</gen:era><gen:yy>#{wareki(date)}</gen:yy><gen:mm>#{date.month}</gen:mm><gen:dd>#{date.day}</gen:dd>"
end
form_rdf(code) click to toggle source
# File lib/luca/jp/util.rb, line 52
def form_rdf(code)
  "<rdf:li><rdf:description about=\"##{code}\"/></rdf:li>"
end
gaikyo_config(key) click to toggle source
# File lib/luca/jp/util.rb, line 78
def gaikyo_config(key)
  config.dig('jp', 'gaikyo', key)
end
gengou(date) click to toggle source
# File lib/luca/jp/util.rb, line 8
def gengou(date)
  if date >= Date.new(2019, 5, 1)
    5
  else
    4
  end
end
it_part_config(key) click to toggle source
# File lib/luca/jp/util.rb, line 70
def it_part_config(key)
  config.dig('jp', 'it_part', key)
end
prepaid_tax(code) click to toggle source
# File lib/luca/jp/util.rb, line 24
def prepaid_tax(code)
  #LucaSupport::Code.readable(@bs_data.dig(code) || 0)
  search_end = @end_date.prev_month # exclude year end adjustment
  amount, _ = self.class.net(@start_date.year, @start_date.month, search_end.year, search_end.month, code: code)
  LucaSupport::Code.readable(amount[code] || 0)
end
refund_tax(code) click to toggle source
# File lib/luca/jp/util.rb, line 31
def refund_tax(code)
  credit = credit_amount(code, @start_date.year, @start_date.month, @end_date.year, @end_date.month)
  LucaSupport::Code.readable(credit)
end
render_attr(code, val) click to toggle source
# File lib/luca/jp/util.rb, line 56
def render_attr(code, val)
  return '' if val.nil? || val.to_s.length == 0

  "<#{code}>#{val}</#{code}>"
end
uchiwake_account_config(key) click to toggle source
# File lib/luca/jp/util.rb, line 82
def uchiwake_account_config(key)
  account_list = config.dig('jp', 'accounts')
  return [] if account_list.nil?

  Array(account_list).filter { |account| /^#{key}/.match(account['code'].to_s) }
end
wareki(date) click to toggle source
# File lib/luca/jp/util.rb, line 16
def wareki(date)
  if date >= Date.new(2019, 5, 1)
    date.year - 2018
  else
    date.year - 1988
  end
end
中間還付税額(税額, 中間納付額) click to toggle source
# File lib/luca/jp/util.rb, line 44
def 中間還付税額(税額, 中間納付額)
  if 税額 < 中間納付額
    中間納付額 - 税額
  else
    0
  end
end
納付税額(税額, 中間納付額) click to toggle source
# File lib/luca/jp/util.rb, line 36
def 納付税額(税額, 中間納付額)
  if 税額 > 中間納付額
    税額 - 中間納付額
  else
    0
  end
end