einvoice 1.2.22 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -102,7 +102,7 @@ module Einvoice
102
102
 
103
103
  # Type I R G A
104
104
  validates :receiverName, allow_blank: true, length: { maximum: 30 }, if: proc { %w(I R G A).include?(self.type) }
105
- validates :receiverAddrZip, allow_blank: true, length: { maximum: 5 }, if: proc { %w(I R G A).include?(self.type) }
105
+ validates :receiverAddrZip, allow_blank: true, length: { maximum: 6 }, if: proc { %w(I R G A).include?(self.type) }
106
106
  validates :receiverAddrRoad, allow_blank: true, length: { maximum: 100 }, if: proc { %w(I R G A).include?(self.type) }
107
107
  validates :receiverEmail, allow_blank: true, length: { maximum: 80 }, if: proc { %w(I R G A).include?(self.type) }
108
108
  validates :receiverMobile, allow_blank: true, length: { maximum: 15 }, if: proc { %w(I R G A).include?(self.type) }
@@ -25,7 +25,7 @@ module Einvoice
25
25
  validates :serialNumber, presence: true, length: { is: 4 }, numericality: true
26
26
  validates :invoiceNumber, allow_blank: true, length: { is: 10 }
27
27
  validates :invoiceDate, allow_blank: true, length: { is: 8 }, numericality: true
28
- validates :invoiceTime, allow_blank: true, length: { is: 8 }, format: { with: /\Ad{2}\:\d{2}\:\d{2}\Z/ }
28
+ validates :invoiceTime, allow_blank: true, length: { is: 8 }, format: { with: /\A\d{2}\:\d{2}\:\d{2}\Z/ }
29
29
  validates :productCode, allow_blank: true, length: { maximum: 30 }
30
30
  validates :productName, presence: true, length: { maximum: 300 }
31
31
  validates :qty, presence: true, length: { maximum: 20 }
@@ -18,11 +18,7 @@ module Einvoice
18
18
  issue_data.from_json(payload.to_json)
19
19
 
20
20
  if issue_data.valid?
21
- response = connection(
22
- ssl: {
23
- verify: false
24
- }
25
- ).post do |request|
21
+ response = connection.post do |request|
26
22
  request.url endpoint_url || endpoint + "/DEFAULTAPI/post/issue"
27
23
  request.params[:v] = encrypted_params(issueData: issue_data.payload)
28
24
  end.body
@@ -38,11 +34,7 @@ module Einvoice
38
34
  void_data.from_json(payload.to_json)
39
35
 
40
36
  if void_data.valid?
41
- response = connection(
42
- ssl: {
43
- verify: false
44
- }
45
- ).post do |request|
37
+ response = connection.post do |request|
46
38
  request.url endpoint_url || endpoint + "/DEFAULTAPI/post/cancel"
47
39
  request.params[:v] = encrypted_params(voidData: void_data.payload)
48
40
  end.body
@@ -54,11 +46,7 @@ module Einvoice
54
46
  end
55
47
 
56
48
  def search_invoice_by_member_id(payload, options = {})
57
- response = connection(
58
- ssl: {
59
- verify: false
60
- }
61
- ).get do |request|
49
+ response = connection.get do |request|
62
50
  request.url endpoint_url || endpoint + "/DEFAULTAPI/get/searchInvoiceByMemberId"
63
51
  request.params[:v] = encrypted_params(payload)
64
52
  end.body
@@ -67,11 +55,7 @@ module Einvoice
67
55
  end
68
56
 
69
57
  def search_invoice_detail(invoice_number)
70
- response = connection(
71
- ssl: {
72
- verify: false
73
- }
74
- ).get do |request|
58
+ response = connection.get do |request|
75
59
  request.url endpoint_url || endpoint + "/DEFAULTAPI/get/searchInvoiceDetail"
76
60
  request.params[:v] = encrypted_params(invoiceNumber: invoice_number)
77
61
  end.body
@@ -80,11 +64,7 @@ module Einvoice
80
64
  end
81
65
 
82
66
  def search_invoice_by_transaction_number(payload, options = {})
83
- response = connection(
84
- ssl: {
85
- verify: false
86
- }
87
- ).get do |request|
67
+ response = connection.get do |request|
88
68
  request.url endpoint_url || endpoint + "/DEFAULTAPI/get/searchInvoiceInfoByTransactionnumber"
89
69
  request.params[:v] = encrypted_params(payload.slice(:companyUn, :orgId, :transactionNumber))
90
70
  end.body
@@ -93,11 +73,7 @@ module Einvoice
93
73
  end
94
74
 
95
75
  def send_card_info_to_cust(payload, options = {})
96
- response = connection(
97
- ssl: {
98
- verify: false
99
- }
100
- ).get do |request|
76
+ response = connection.get do |request|
101
77
  request.url endpoint_url || endpoint + "/DEFAULTAPI/get/sendCardInfotoCust"
102
78
  request.params[:v] = encrypted_params(payload)
103
79
  end.body
@@ -106,11 +82,7 @@ module Einvoice
106
82
  end
107
83
 
108
84
  def get_invoice_mark_info(payload, options = {})
109
- response = connection(
110
- ssl: {
111
- verify: false
112
- }
113
- ).get do |request|
85
+ response = connection.get do |request|
114
86
  request.url endpoint_url || endpoint + "/DEFAULTAPI/get/getInvoiceMarkInfo"
115
87
  request.params[:v] = encrypted_params(payload)
116
88
  end.body
@@ -119,11 +91,7 @@ module Einvoice
119
91
  end
120
92
 
121
93
  def get_donate_unit_list(companyUn, options = {})
122
- response = connection(
123
- ssl: {
124
- verify: false
125
- }
126
- ).get do |request|
94
+ response = connection.get do |request|
127
95
  request.url endpoint_url || endpoint + "/DEFAULTAPI/get/getDonateUnitList"
128
96
  request.params[:v] = encrypted_params(companyUn: companyUn)
129
97
  end.body
@@ -132,11 +100,7 @@ module Einvoice
132
100
  end
133
101
 
134
102
  def get_invoice_content(payload, options = {})
135
- response = connection(
136
- ssl: {
137
- verify: false
138
- }
139
- ).get do |request|
103
+ response = connection.get do |request|
140
104
  request.url endpoint_url || endpoint + "/DEFAULTAPI/get/getInvoiceContent"
141
105
  request.params[:v] = encrypted_params(payload)
142
106
  end.body
@@ -19,7 +19,7 @@ module Einvoice
19
19
 
20
20
  class TotalValidator < ActiveModel::EachValidator
21
21
  def validate_each(record, attribute, value)
22
- unless value != record.itemList.map(&:itemTotal).map(&:to_i).inject(&:+)
22
+ if value.to_i != record.itemList.map(&:itemTotal).map(&:to_i).sum
23
23
  record.errors.add attribute, options[:message] || :invalid
24
24
  end
25
25
  end
@@ -27,7 +27,7 @@ module Einvoice
27
27
 
28
28
  class AllowanceNumberValidator < ActiveModel::EachValidator
29
29
  def validate_each(record, attribute, value)
30
- unless record.allowanceNumber =~ Regexp.new("\A#{record.orgId}")
30
+ unless record.allowanceNumber =~ Regexp.new("\\A#{record.orgId}")
31
31
  record.errors.add attribute, options[:message] || :invalid
32
32
  end
33
33
  end
@@ -55,20 +55,20 @@ module Einvoice
55
55
  class ItemListValidator < ActiveModel::EachValidator
56
56
  def validate_each(record, attribtue, value)
57
57
  if record.itemList.map(&:itemTotal).map(&:blank?).reduce(&:|)
58
- record.errors[:itemList] << options[:message] || :invalid
58
+ record.errors.add :itemList, options[:message] || :invalid
59
59
  elsif record.itemList.map(&:taxType).map(&:blank?).reduce(&:|)
60
- record.errors[:itemList] << options[:message] || :invalid
60
+ record.errors.add :itemList, options[:message] || :invalid
61
61
  else
62
62
  # none
63
63
  end
64
64
 
65
65
  if %w(A H).include?(record.type)
66
66
  if record.itemList.map(&:invoiceNumber).map(&:blank?).reduce(&:|)
67
- record.errors[:itemList] << options[:message] || :invalid
67
+ record.errors.add :itemList, options[:message] || :invalid
68
68
  elsif record.itemList.map(&:invoiceDate).map(&:blank?).reduce(&:|)
69
- record.errors[:itemList] << options[:message] || :invalid
69
+ record.errors.add :itemList, options[:message] || :invalid
70
70
  elsif record.itemList.map(&:itemExclude).map(&:blank?).reduce(&:|)
71
- record.errors[:itemList] << options[:message] || :invalid
71
+ record.errors.add :itemList, options[:message] || :invalid
72
72
  else
73
73
  # none
74
74
  end
@@ -1,3 +1,3 @@
1
1
  module Einvoice
2
- VERSION = "1.2.22"
2
+ VERSION = "1.4.0"
3
3
  end
@@ -30,7 +30,7 @@ module Faraday
30
30
  cipher.padding = 0
31
31
 
32
32
  decrypted = cipher.update(Base64.decode64(content)) + cipher.final
33
- JSON.load(decrypted.strip)
33
+ JSON.parse(decrypted.strip)
34
34
  end
35
35
  end
36
36
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: einvoice
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.22
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Yun
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2023-04-29 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: faraday
@@ -154,16 +153,16 @@ dependencies:
154
153
  name: factory_bot
155
154
  requirement: !ruby/object:Gem::Requirement
156
155
  requirements:
157
- - - "~>"
156
+ - - ">="
158
157
  - !ruby/object:Gem::Version
159
- version: '4.0'
158
+ version: '0'
160
159
  type: :development
161
160
  prerelease: false
162
161
  version_requirements: !ruby/object:Gem::Requirement
163
162
  requirements:
164
- - - "~>"
163
+ - - ">="
165
164
  - !ruby/object:Gem::Version
166
- version: '4.0'
165
+ version: '0'
167
166
  - !ruby/object:Gem::Dependency
168
167
  name: shoulda-matchers
169
168
  requirement: !ruby/object:Gem::Requirement
@@ -206,17 +205,17 @@ dependencies:
206
205
  - - ">="
207
206
  - !ruby/object:Gem::Version
208
207
  version: '0'
209
- description:
210
208
  email:
211
209
  - abookyun@gmail.com
212
210
  executables: []
213
211
  extensions: []
214
212
  extra_rdoc_files: []
215
213
  files:
214
+ - ".github/workflows/build.yml"
216
215
  - ".github/workflows/cron.yml"
217
216
  - ".gitignore"
218
217
  - ".rspec"
219
- - ".travis.yml"
218
+ - CHANGELOG.md
220
219
  - Gemfile
221
220
  - LICENSE.txt
222
221
  - README.md
@@ -247,7 +246,6 @@ homepage: https://github.com/abookyun/einvoice
247
246
  licenses:
248
247
  - MIT
249
248
  metadata: {}
250
- post_install_message:
251
249
  rdoc_options: []
252
250
  require_paths:
253
251
  - lib
@@ -262,8 +260,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
262
260
  - !ruby/object:Gem::Version
263
261
  version: '0'
264
262
  requirements: []
265
- rubygems_version: 3.4.1
266
- signing_key:
263
+ rubygems_version: 4.0.17
267
264
  specification_version: 4
268
265
  summary: A API wrapper for Taiwan e-invoice services.
269
266
  test_files: []
data/.travis.yml DELETED
@@ -1,18 +0,0 @@
1
- env:
2
- global:
3
- - CC_TEST_REPORTER_ID=134e1f1cc8b60db4f2a491152c9227a6dbbfbeba5c1d05ee8b44cd78a1069f28
4
- language: ruby
5
- rvm:
6
- - 2.5.5
7
- - 2.6.3
8
- - 2.7.0
9
- - 3.0.0
10
- before_script:
11
- - gem install bundler
12
- - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
13
- - chmod +x ./cc-test-reporter
14
- - ./cc-test-reporter before-build
15
- script:
16
- - bundle exec rspec
17
- after_script:
18
- - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT