Module: Luca::Jp::Util
Class Method Summary collapse
- .beppyo2_config(key) ⇒ Object
- .config ⇒ Object
- .eltax_config(key) ⇒ Object
- .etax_date(date) ⇒ Object
- .form_rdf(code) ⇒ Object
- .gaikyo_config(key) ⇒ Object
- .gengou(date) ⇒ Object
- .it_part_config(key) ⇒ Object
-
.prepaid_tax(code, customer = nil) ⇒ Object
TODO: customerオプションを適切に扱うには 納付時にx-customerを付加していないケースの考慮が必要.
- .refund_tax(code) ⇒ Object
- .render_attr(code, val) ⇒ Object
- .tokyo23? ⇒ Boolean
- .uchiwake_account_config(key) ⇒ Object
- .wareki(date) ⇒ Object
- .中間還付税額(税額, 中間納付額) ⇒ Object
- .期首期末残高(code) ⇒ Object
- .納付税額(税額, 中間納付額) ⇒ Object
- .純資産期中増減(code) ⇒ Object
Class Method Details
.beppyo2_config(key) ⇒ Object
79 80 81 |
# File 'lib/luca/jp/util.rb', line 79 def beppyo2_config(key) config.dig('jp', 'beppyo2', key) end |
.config ⇒ Object
71 72 73 |
# File 'lib/luca/jp/util.rb', line 71 def config LucaSupport::CONST.config end |
.eltax_config(key) ⇒ Object
94 95 96 |
# File 'lib/luca/jp/util.rb', line 94 def eltax_config(key) config.dig('jp', 'eltax', key) end |
.etax_date(date) ⇒ Object
65 66 67 68 69 |
# File 'lib/luca/jp/util.rb', line 65 def etax_date(date) return nil if date.nil? "<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) ⇒ Object
55 56 57 |
# File 'lib/luca/jp/util.rb', line 55 def form_rdf(code) "<rdf:li><rdf:description about=\"##{code}\"/></rdf:li>" end |
.gaikyo_config(key) ⇒ Object
83 84 85 |
# File 'lib/luca/jp/util.rb', line 83 def gaikyo_config(key) config.dig('jp', 'gaikyo', key) end |
.gengou(date) ⇒ Object
8 9 10 11 12 13 14 |
# 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) ⇒ Object
75 76 77 |
# File 'lib/luca/jp/util.rb', line 75 def it_part_config(key) config.dig('jp', 'it_part', key) end |
.prepaid_tax(code, customer = nil) ⇒ Object
TODO: customerオプションを適切に扱うには納付時にx-customerを付加していないケースの考慮が必要
26 27 28 29 30 31 32 |
# File 'lib/luca/jp/util.rb', line 26 def prepaid_tax(code, customer = nil) search_end = @end_date.prev_day # exclude year end adjustment # header = { customer: customer } unless customer.nil? header = nil amount, _ = self.class.net(@start_date.year, @start_date.month, date_range: @start_date..search_end, code: code, header: header) LucaSupport::Code.readable(amount[code] || 0) end |
.refund_tax(code) ⇒ Object
34 35 36 37 |
# File 'lib/luca/jp/util.rb', line 34 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) ⇒ Object
59 60 61 62 63 |
# File 'lib/luca/jp/util.rb', line 59 def render_attr(code, val) return '' if val.nil? || val.to_s.length == 0 "<#{code}>#{val}</#{code}>" end |
.tokyo23? ⇒ Boolean
98 99 100 |
# File 'lib/luca/jp/util.rb', line 98 def tokyo23? @report_category == '23ku' end |
.uchiwake_account_config(key) ⇒ Object
87 88 89 90 91 92 |
# File 'lib/luca/jp/util.rb', line 87 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) ⇒ Object
16 17 18 19 20 21 22 |
# 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 |
.中間還付税額(税額, 中間納付額) ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/luca/jp/util.rb', line 47 def 中間還付税額(税額, 中間納付額) if 税額 < 中間納付額 中間納付額 - 税額 else 0 end end |
.期首期末残高(code) ⇒ Object
102 103 104 105 106 |
# File 'lib/luca/jp/util.rb', line 102 def 期首期末残高(code) pre = readable(@start_balance.dig(code)) || 0 post = readable(@bs_data.dig(code)) || 0 [readable(pre), readable(post)] end |
.納付税額(税額, 中間納付額) ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/luca/jp/util.rb', line 39 def 納付税額(税額, 中間納付額) if 税額 > 中間納付額 税額 - 中間納付額 else 0 end end |
.純資産期中増減(code) ⇒ Object
108 109 110 111 112 113 |
# File 'lib/luca/jp/util.rb', line 108 def 純資産期中増減(code) inc = credit_amount(code, @start_date.year, @start_date.month, @end_date.year, @end_date.month) dec = debit_amount(code, @start_date.year, @start_date.month, @end_date.year, @end_date.month) [readable(dec), readable(inc)] end |