With EASYCARD number and code, you can import electronic invoice from E-invoice platform, Ministry of Finance, Taiwan.
This gem is base on the following spec, 電子發票應用API規格. (Sorry, Chinese only)
Add this line to your application's Gemfile:
gem 'e_invoice'
And then execute:
$ bundle
Or install it yourself as:
$ gem install e_invoice
$ rails generate e_invoice
If you use Figaro gem, you can do like this.
# config/initailizers/e_invoice.rb
require "e_invoice"
module EInvoice
APPID = ENV["EINV_APPID"]
UUID = ENV["EINV_UUID"]
end
# config/applicaton.yml
.
.
.
EINV_APPID: "your_secretappid"
EINV_UUID: "your_secret_uuid"
# create a variable with EASYCARD account number & encrypt.
easy_card = EInvoice::Payload.new("1K0001", card_number, card_encrypt)
# request_header to check whether this EASYCARD is a valid in the database of Ministry of Finance, Taiwan.
headers = easy_card.request_header(Time.now.strftime("%Y-%m-%d"), Time.now.strftime("%Y-%m-%d"))
# If it is valid, the following will be true. This can be used as validation.
EInvoice::Result.new(headers.response_code).success?
invoices = EInvoice::Payload.new("1K0001", easy_card.card_number, easy_card.card_encrypt)
.get_invoices(start_date, end_date)
# start_date can not be prior than 3 months ago.
Bug reports and pull requests are welcome on GitHub at https://github.com/jasonych/e_invoice. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
The gem is available as open source under the terms of the MIT License.