5
2
この記事誰得? 私しか得しないニッチな技術で記事投稿!

インボイス対応進んでますか?安心してください。適格請求書発行事業者公表システムWeb-APIのラッパーAPIがありますよ。

Last updated at Posted at 2023-06-13

インボイス制度が2023年10月から始まります。国の方針なため、仕事でもインボイスへの対応を予定している方が多いのではないでしょうか。

行政が作成した資料を読み解きながら、開発に落とし込んでいく。
大変ですよね。

そんなエンジニアに朗報です。

安心してください。適格請求書発行事業者公表システムWeb-APIのラッパーAPIがありますよ。

開発したもの

国税庁が提供している、インボイス制度適格請求書発行事業者公表システムWeb-APIのクライアントAPIをライブラリにし、OSSとして公開しました。名前はkendamaです。
公開したライブラリは、RubyとPython製のものを公開しています。

Rubyであれば、RubyGemsにも登録しているのでbundle install kendamaでインストールができます。

Pythonの方は、pip install kendamaでインストールが可能です。

もし、使ってみて改善点などが見つかったらIssueにぜひ課題を挙げてみてください。プルリクエストも喜んでお待ちしています。

kendamaの使い方

使用方法はREADMEにも書いていますが、こちらにもRubyの場合の使い方を簡単に記します。
デフォルトの状態だと、APIのリクエスト先は検証環境に向いているのでご安心ください。

また、コードを実行する場合はアプリケーションIDが必要となるので忘れずに。

登録番号を指定して情報を取得

require 'kendama'

api_instance = Kendama::V1Api.new
id = 'アプリケーションID'
number = '登録番号'
type = '21'
opts = {
  history: '0'
}

begin
  result = api_instance.get_announcement_by_number(id, number, type, opts)
rescue Kendama::ApiError => e
  puts "Error when calling V1Api->get_announcement_by_number: #{e}"
end

検証環境の場合、T0000000000016T0000000000017などの登録番号がいくつかテストデータとして入っているようです。

取得期間を指定して情報を取得

require 'time'
require 'kendama'

api_instance = Kendama::V1Api.new
id = 'アプリケーションID'
from = Date.parse('Tue Oct 01 09:00:00 JST 2024')
to = Date.parse('Tue Oct 01 09:00:00 JST 2024')
type = '21'
opts = {
  division: '1',
  divide: 'divide_example'
}

begin
  result = api_instance.get_announcement_by_diff(id, from, to, type, opts)
rescue Kendama::ApiError => e
  puts "Error when calling V1Api->get_announcement_by_diff: #{e}"
end

登録番号と日付を指定して情報を取得

require 'time'
require 'kendama'

api_instance = Kendama::V1Api.new
id = 'アプリケーションID'
number = '登録番号'
day = Date.parse('Fri Dec 01 09:00:00 JST 2023')
type = '21'

begin
  result = api_instance.get_announcement_by_valid(id, number, day, type)
rescue Kendama::ApiError => e
  puts "Error when calling V1Api->get_announcement_by_valid: #{e}"
end

その他の仕様

リクエストのクエリパラメーターや、レスポンスボディなどのAPI仕様についてはkendamaのリポジトリにドキュメントを用意しているので、必要な方はご覧ください。

5
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
2