luca-jp 0.1.4 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'json'
4
+ require 'cgi/escape'
5
+ require 'luca_deal'
6
+ require 'luca_support'
7
+ require 'luca_support/config'
8
+ require 'luca/jp'
9
+
10
+ module Luca
11
+ module Jp
12
+ class Urikake < LucaDeal::Invoice
13
+ @dirname = 'invoices'
14
+
15
+ def report(total = nil)
16
+ listed_amount = 0
17
+ str = CSV.generate(String.new, headers: false, col_sep: ',', encoding: 'UTF-8') do |f|
18
+ list.map do |invoice|
19
+ amount = readable(invoice.dig('subtotal', 0, 'items') + invoice.dig('subtotal', 0, 'tax'))
20
+ listed_amount += amount
21
+ f << ['3', '0', '売掛金', invoice.dig('customer', 'name'), invoice.dig('customer', 'address'), amount, nil ]
22
+ end
23
+ if total
24
+ f << ['3', '0', '売掛金', 'その他', nil, total - listed_amount, nil ]
25
+ f << ['3', '1', nil, nil, nil, total, nil ]
26
+ end
27
+ end
28
+ File.open('HOI030_3.0.csv', 'w') { |f| f.write(str) }
29
+ end
30
+
31
+ def list
32
+ invoices = self.class.asof(@date.year, @date.month)
33
+ .map { |dat, _path| dat }
34
+ .sort_by { |invoice| invoice.dig('subtotal', 0, 'items') }
35
+ .reverse
36
+
37
+ reports = invoices.filter { |invoice| 500_000 <= invoice['subtotal'].inject(0) { |sum, i| sum + i['items'] + i['tax'] } }
38
+ return reports if reports.length >= 5
39
+
40
+ additional = invoices
41
+ .filter { |invoice| 500_000 > invoice['subtotal'].inject(0) { |sum, i| sum + i['items'] + i['tax'] } }
42
+ .take(5 - reports.length)
43
+ reports.concat(additional)
44
+ end
45
+ end
46
+ end
47
+ end
data/lib/luca/jp/util.rb CHANGED
@@ -28,6 +28,11 @@ module Luca
28
28
  LucaSupport::Code.readable(amount[code] || 0)
29
29
  end
30
30
 
31
+ def refund_tax(code)
32
+ credit = credit_amount(code, @start_date.year, @start_date.month, @end_date.year, @end_date.month)
33
+ LucaSupport::Code.readable(credit)
34
+ end
35
+
31
36
  def 納付税額(税額, 中間納付額)
32
37
  if 税額 > 中間納付額
33
38
  税額 - 中間納付額
@@ -49,6 +54,8 @@ module Luca
49
54
  end
50
55
 
51
56
  def render_attr(code, val)
57
+ return '' if val.nil? || val.to_s.length == 0
58
+
52
59
  "<#{code}>#{val}</#{code}>"
53
60
  end
54
61
 
@@ -59,6 +66,29 @@ module Luca
59
66
  def config
60
67
  EX_CONF.nil? ? LucaSupport::CONFIG : LucaSupport::CONFIG.merge(EX_CONF)
61
68
  end
69
+
70
+ def it_part_config(key)
71
+ config.dig('jp', 'it_part', key)
72
+ end
73
+
74
+ def beppyo2_config(key)
75
+ config.dig('jp', 'beppyo2', key)
76
+ end
77
+
78
+ def gaikyo_config(key)
79
+ config.dig('jp', 'gaikyo', key)
80
+ end
81
+
82
+ def uchiwake_account_config(key)
83
+ account_list = config.dig('jp', 'accounts')
84
+ return [] if account_list.nil?
85
+
86
+ Array(account_list).filter { |account| /^#{key}/.match(account['code'].to_s) }
87
+ end
88
+
89
+ def eltax_config(key)
90
+ config.dig('jp', 'eltax', key)
91
+ end
62
92
  end
63
93
  end
64
94
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Luca
4
4
  module Jp
5
- VERSION = '0.1.4'
5
+ VERSION = '0.2.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: luca-jp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chuma Takahiro
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-03-21 00:00:00.000000000 Z
11
+ date: 2021-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lucabook
@@ -96,19 +96,26 @@ files:
96
96
  - lib/luca/jp/templates/beppyo51.xml.erb
97
97
  - lib/luca/jp/templates/beppyo52.xml.erb
98
98
  - lib/luca/jp/templates/beppyo7.xml.erb
99
+ - lib/luca/jp/templates/chidai-meisai.xml.erb
99
100
  - lib/luca/jp/templates/consumption.xtx.erb
100
101
  - lib/luca/jp/templates/el-no6-43.xml.erb
101
102
  - lib/luca/jp/templates/el-no6-9.xml.erb
102
103
  - lib/luca/jp/templates/el-no6.xml.erb
104
+ - lib/luca/jp/templates/eltax-userinf.xml.erb
103
105
  - lib/luca/jp/templates/eltax.xml.erb
104
106
  - lib/luca/jp/templates/fuhyo43.xml.erb
105
107
  - lib/luca/jp/templates/fuhyo53.xml.erb
106
108
  - lib/luca/jp/templates/gaikyo.xml.erb
109
+ - lib/luca/jp/templates/kaikake-meisai.xml.erb
110
+ - lib/luca/jp/templates/kariire-meisai.xml.erb
107
111
  - lib/luca/jp/templates/kariuke-meisai.xml.erb
112
+ - lib/luca/jp/templates/shoken-meisai.xml.erb
108
113
  - lib/luca/jp/templates/syouhizei-shinkoku-kanni.xml.erb
109
114
  - lib/luca/jp/templates/tekiyougaku.xml.erb
110
115
  - lib/luca/jp/templates/yakuin-meisai.xml.erb
111
116
  - lib/luca/jp/templates/yokin-meisai.xml.erb
117
+ - lib/luca/jp/uchiwake.rb
118
+ - lib/luca/jp/urikake.rb
112
119
  - lib/luca/jp/util.rb
113
120
  - lib/luca/jp/version.rb
114
121
  homepage: https://github.com/chumaltd/luca-jp/tree/main