einvoice 1.4.0 → 2.0.0.alpha2

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.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/.coderabbit.yaml +12 -0
  3. data/.github/workflows/build.yml +7 -4
  4. data/CHANGELOG.md +55 -35
  5. data/Gemfile +3 -2
  6. data/README.md +230 -265
  7. data/README.zh-TW.md +322 -0
  8. data/Rakefile +2 -13
  9. data/bin/console +3 -6
  10. data/einvoice.gemspec +24 -21
  11. data/lib/einvoice/amego/client.rb +116 -0
  12. data/lib/einvoice/amego/errors.rb +84 -0
  13. data/lib/einvoice/amego/payload.rb +276 -0
  14. data/lib/einvoice/amego/provider.rb +267 -0
  15. data/lib/einvoice/amego.rb +27 -0
  16. data/lib/einvoice/capability.rb +79 -0
  17. data/lib/einvoice/ecpay/client.rb +183 -0
  18. data/lib/einvoice/ecpay/crypto.rb +85 -0
  19. data/lib/einvoice/ecpay/errors.rb +115 -0
  20. data/lib/einvoice/ecpay/payload.rb +241 -0
  21. data/lib/einvoice/ecpay/provider.rb +362 -0
  22. data/lib/einvoice/ecpay.rb +31 -0
  23. data/lib/einvoice/error.rb +220 -0
  24. data/lib/einvoice/ezpay/client.rb +130 -0
  25. data/lib/einvoice/ezpay/crypto.rb +85 -0
  26. data/lib/einvoice/ezpay/errors.rb +72 -0
  27. data/lib/einvoice/ezpay/payload.rb +269 -0
  28. data/lib/einvoice/ezpay/provider.rb +235 -0
  29. data/lib/einvoice/ezpay.rb +19 -0
  30. data/lib/einvoice/input.rb +494 -0
  31. data/lib/einvoice/mock_provider.rb +191 -0
  32. data/lib/einvoice/mof/donation_codes.rb +157 -0
  33. data/lib/einvoice/mof.rb +16 -0
  34. data/lib/einvoice/number.rb +51 -0
  35. data/lib/einvoice/provider.rb +57 -14
  36. data/lib/einvoice/redaction.rb +54 -0
  37. data/lib/einvoice/taipei.rb +89 -0
  38. data/lib/einvoice/tax_split.rb +124 -0
  39. data/lib/einvoice/tradevan/default_api/client.rb +175 -0
  40. data/lib/einvoice/tradevan/default_api/crypto.rb +90 -0
  41. data/lib/einvoice/tradevan/default_api/errors.rb +54 -0
  42. data/lib/einvoice/tradevan/default_api/payload.rb +259 -0
  43. data/lib/einvoice/tradevan/default_api/provider.rb +366 -0
  44. data/lib/einvoice/tradevan/default_api/rules.rb +314 -0
  45. data/lib/einvoice/tradevan.rb +25 -0
  46. data/lib/einvoice/types.rb +323 -0
  47. data/lib/einvoice/version.rb +3 -1
  48. data/lib/einvoice.rb +21 -10
  49. metadata +60 -176
  50. data/.github/workflows/cron.yml +0 -31
  51. data/docs/Tradevan E-Invoice APIs.md +0 -201
  52. data/docs/neweb.md +0 -347
  53. data/lib/einvoice/client.rb +0 -21
  54. data/lib/einvoice/configuration.rb +0 -49
  55. data/lib/einvoice/connection.rb +0 -31
  56. data/lib/einvoice/donation_unit_list.json +0 -2022
  57. data/lib/einvoice/result.rb +0 -21
  58. data/lib/einvoice/tradevan/model/base.rb +0 -34
  59. data/lib/einvoice/tradevan/model/issue_data.rb +0 -129
  60. data/lib/einvoice/tradevan/model/issue_item.rb +0 -41
  61. data/lib/einvoice/tradevan/model/void_data.rb +0 -35
  62. data/lib/einvoice/tradevan/provider.rb +0 -140
  63. data/lib/einvoice/tradevan/result.rb +0 -25
  64. data/lib/einvoice/tradevan/validator/issue_data_validator.rb +0 -80
  65. data/lib/einvoice/utils.rb +0 -13
  66. data/lib/faraday/response/decode_tradevan.rb +0 -38
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: einvoice
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 2.0.0.alpha2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Yun
@@ -9,243 +9,127 @@ bindir: exe
9
9
  cert_chain: []
10
10
  date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
- - !ruby/object:Gem::Dependency
13
- name: faraday
14
- requirement: !ruby/object:Gem::Requirement
15
- requirements:
16
- - - ">="
17
- - !ruby/object:Gem::Version
18
- version: '0'
19
- type: :runtime
20
- prerelease: false
21
- version_requirements: !ruby/object:Gem::Requirement
22
- requirements:
23
- - - ">="
24
- - !ruby/object:Gem::Version
25
- version: '0'
26
- - !ruby/object:Gem::Dependency
27
- name: faraday_middleware
28
- requirement: !ruby/object:Gem::Requirement
29
- requirements:
30
- - - ">="
31
- - !ruby/object:Gem::Version
32
- version: '0'
33
- type: :runtime
34
- prerelease: false
35
- version_requirements: !ruby/object:Gem::Requirement
36
- requirements:
37
- - - ">="
38
- - !ruby/object:Gem::Version
39
- version: '0'
40
- - !ruby/object:Gem::Dependency
41
- name: multi_xml
42
- requirement: !ruby/object:Gem::Requirement
43
- requirements:
44
- - - ">="
45
- - !ruby/object:Gem::Version
46
- version: '0'
47
- type: :runtime
48
- prerelease: false
49
- version_requirements: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - ">="
52
- - !ruby/object:Gem::Version
53
- version: '0'
54
- - !ruby/object:Gem::Dependency
55
- name: activemodel
56
- requirement: !ruby/object:Gem::Requirement
57
- requirements:
58
- - - ">="
59
- - !ruby/object:Gem::Version
60
- version: '0'
61
- type: :runtime
62
- prerelease: false
63
- version_requirements: !ruby/object:Gem::Requirement
64
- requirements:
65
- - - ">="
66
- - !ruby/object:Gem::Version
67
- version: '0'
68
- - !ruby/object:Gem::Dependency
69
- name: activesupport
70
- requirement: !ruby/object:Gem::Requirement
71
- requirements:
72
- - - ">="
73
- - !ruby/object:Gem::Version
74
- version: '0'
75
- type: :runtime
76
- prerelease: false
77
- version_requirements: !ruby/object:Gem::Requirement
78
- requirements:
79
- - - ">="
80
- - !ruby/object:Gem::Version
81
- version: '0'
82
- - !ruby/object:Gem::Dependency
83
- name: gyoku
84
- requirement: !ruby/object:Gem::Requirement
85
- requirements:
86
- - - ">="
87
- - !ruby/object:Gem::Version
88
- version: '0'
89
- type: :runtime
90
- prerelease: false
91
- version_requirements: !ruby/object:Gem::Requirement
92
- requirements:
93
- - - ">="
94
- - !ruby/object:Gem::Version
95
- version: '0'
96
- - !ruby/object:Gem::Dependency
97
- name: bundler
98
- requirement: !ruby/object:Gem::Requirement
99
- requirements:
100
- - - ">"
101
- - !ruby/object:Gem::Version
102
- version: '1.17'
103
- type: :development
104
- prerelease: false
105
- version_requirements: !ruby/object:Gem::Requirement
106
- requirements:
107
- - - ">"
108
- - !ruby/object:Gem::Version
109
- version: '1.17'
110
12
  - !ruby/object:Gem::Dependency
111
13
  name: rake
112
14
  requirement: !ruby/object:Gem::Requirement
113
15
  requirements:
114
16
  - - "~>"
115
17
  - !ruby/object:Gem::Version
116
- version: '12.3'
18
+ version: '13.0'
117
19
  type: :development
118
20
  prerelease: false
119
21
  version_requirements: !ruby/object:Gem::Requirement
120
22
  requirements:
121
23
  - - "~>"
122
24
  - !ruby/object:Gem::Version
123
- version: '12.3'
124
- - !ruby/object:Gem::Dependency
125
- name: pry
126
- requirement: !ruby/object:Gem::Requirement
127
- requirements:
128
- - - ">="
129
- - !ruby/object:Gem::Version
130
- version: '0'
131
- type: :development
132
- prerelease: false
133
- version_requirements: !ruby/object:Gem::Requirement
134
- requirements:
135
- - - ">="
136
- - !ruby/object:Gem::Version
137
- version: '0'
25
+ version: '13.0'
138
26
  - !ruby/object:Gem::Dependency
139
27
  name: rspec
140
28
  requirement: !ruby/object:Gem::Requirement
141
29
  requirements:
142
- - - ">="
143
- - !ruby/object:Gem::Version
144
- version: '0'
145
- type: :development
146
- prerelease: false
147
- version_requirements: !ruby/object:Gem::Requirement
148
- requirements:
149
- - - ">="
150
- - !ruby/object:Gem::Version
151
- version: '0'
152
- - !ruby/object:Gem::Dependency
153
- name: factory_bot
154
- requirement: !ruby/object:Gem::Requirement
155
- requirements:
156
- - - ">="
157
- - !ruby/object:Gem::Version
158
- version: '0'
159
- type: :development
160
- prerelease: false
161
- version_requirements: !ruby/object:Gem::Requirement
162
- requirements:
163
- - - ">="
164
- - !ruby/object:Gem::Version
165
- version: '0'
166
- - !ruby/object:Gem::Dependency
167
- name: shoulda-matchers
168
- requirement: !ruby/object:Gem::Requirement
169
- requirements:
170
- - - ">="
30
+ - - "~>"
171
31
  - !ruby/object:Gem::Version
172
- version: '0'
32
+ version: '3.13'
173
33
  type: :development
174
34
  prerelease: false
175
35
  version_requirements: !ruby/object:Gem::Requirement
176
36
  requirements:
177
- - - ">="
37
+ - - "~>"
178
38
  - !ruby/object:Gem::Version
179
- version: '0'
39
+ version: '3.13'
180
40
  - !ruby/object:Gem::Dependency
181
41
  name: vcr
182
42
  requirement: !ruby/object:Gem::Requirement
183
43
  requirements:
184
- - - ">="
44
+ - - "~>"
185
45
  - !ruby/object:Gem::Version
186
- version: '0'
46
+ version: '6.3'
187
47
  type: :development
188
48
  prerelease: false
189
49
  version_requirements: !ruby/object:Gem::Requirement
190
50
  requirements:
191
- - - ">="
51
+ - - "~>"
192
52
  - !ruby/object:Gem::Version
193
- version: '0'
53
+ version: '6.3'
194
54
  - !ruby/object:Gem::Dependency
195
55
  name: webmock
196
56
  requirement: !ruby/object:Gem::Requirement
197
57
  requirements:
198
- - - ">="
58
+ - - "~>"
199
59
  - !ruby/object:Gem::Version
200
- version: '0'
60
+ version: '3.23'
201
61
  type: :development
202
62
  prerelease: false
203
63
  version_requirements: !ruby/object:Gem::Requirement
204
64
  requirements:
205
- - - ">="
65
+ - - "~>"
206
66
  - !ruby/object:Gem::Version
207
- version: '0'
67
+ version: '3.23'
208
68
  email:
209
69
  - abookyun@gmail.com
210
70
  executables: []
211
71
  extensions: []
212
72
  extra_rdoc_files: []
213
73
  files:
74
+ - ".coderabbit.yaml"
214
75
  - ".github/workflows/build.yml"
215
- - ".github/workflows/cron.yml"
216
76
  - ".gitignore"
217
77
  - ".rspec"
218
78
  - CHANGELOG.md
219
79
  - Gemfile
220
80
  - LICENSE.txt
221
81
  - README.md
82
+ - README.zh-TW.md
222
83
  - Rakefile
223
84
  - bin/console
224
85
  - bin/setup
225
- - docs/Tradevan E-Invoice APIs.md
226
- - docs/neweb.md
227
86
  - einvoice.gemspec
228
87
  - lib/einvoice.rb
229
- - lib/einvoice/client.rb
230
- - lib/einvoice/configuration.rb
231
- - lib/einvoice/connection.rb
232
- - lib/einvoice/donation_unit_list.json
88
+ - lib/einvoice/amego.rb
89
+ - lib/einvoice/amego/client.rb
90
+ - lib/einvoice/amego/errors.rb
91
+ - lib/einvoice/amego/payload.rb
92
+ - lib/einvoice/amego/provider.rb
93
+ - lib/einvoice/capability.rb
94
+ - lib/einvoice/ecpay.rb
95
+ - lib/einvoice/ecpay/client.rb
96
+ - lib/einvoice/ecpay/crypto.rb
97
+ - lib/einvoice/ecpay/errors.rb
98
+ - lib/einvoice/ecpay/payload.rb
99
+ - lib/einvoice/ecpay/provider.rb
100
+ - lib/einvoice/error.rb
101
+ - lib/einvoice/ezpay.rb
102
+ - lib/einvoice/ezpay/client.rb
103
+ - lib/einvoice/ezpay/crypto.rb
104
+ - lib/einvoice/ezpay/errors.rb
105
+ - lib/einvoice/ezpay/payload.rb
106
+ - lib/einvoice/ezpay/provider.rb
107
+ - lib/einvoice/input.rb
108
+ - lib/einvoice/mock_provider.rb
109
+ - lib/einvoice/mof.rb
110
+ - lib/einvoice/mof/donation_codes.rb
111
+ - lib/einvoice/number.rb
233
112
  - lib/einvoice/provider.rb
234
- - lib/einvoice/result.rb
235
- - lib/einvoice/tradevan/model/base.rb
236
- - lib/einvoice/tradevan/model/issue_data.rb
237
- - lib/einvoice/tradevan/model/issue_item.rb
238
- - lib/einvoice/tradevan/model/void_data.rb
239
- - lib/einvoice/tradevan/provider.rb
240
- - lib/einvoice/tradevan/result.rb
241
- - lib/einvoice/tradevan/validator/issue_data_validator.rb
242
- - lib/einvoice/utils.rb
113
+ - lib/einvoice/redaction.rb
114
+ - lib/einvoice/taipei.rb
115
+ - lib/einvoice/tax_split.rb
116
+ - lib/einvoice/tradevan.rb
117
+ - lib/einvoice/tradevan/default_api/client.rb
118
+ - lib/einvoice/tradevan/default_api/crypto.rb
119
+ - lib/einvoice/tradevan/default_api/errors.rb
120
+ - lib/einvoice/tradevan/default_api/payload.rb
121
+ - lib/einvoice/tradevan/default_api/provider.rb
122
+ - lib/einvoice/tradevan/default_api/rules.rb
123
+ - lib/einvoice/types.rb
243
124
  - lib/einvoice/version.rb
244
- - lib/faraday/response/decode_tradevan.rb
245
125
  homepage: https://github.com/abookyun/einvoice
246
126
  licenses:
247
127
  - MIT
248
- metadata: {}
128
+ metadata:
129
+ source_code_uri: https://github.com/abookyun/einvoice
130
+ changelog_uri: https://github.com/abookyun/einvoice/blob/v2.0.0.alpha2/CHANGELOG.md
131
+ bug_tracker_uri: https://github.com/abookyun/einvoice/issues
132
+ rubygems_mfa_required: 'true'
249
133
  rdoc_options: []
250
134
  require_paths:
251
135
  - lib
@@ -253,14 +137,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
253
137
  requirements:
254
138
  - - ">="
255
139
  - !ruby/object:Gem::Version
256
- version: 2.0.0
140
+ version: '3.2'
257
141
  required_rubygems_version: !ruby/object:Gem::Requirement
258
142
  requirements:
259
143
  - - ">="
260
144
  - !ruby/object:Gem::Version
261
145
  version: '0'
262
146
  requirements: []
263
- rubygems_version: 4.0.17
147
+ rubygems_version: 4.0.20
264
148
  specification_version: 4
265
- summary: A API wrapper for Taiwan e-invoice services.
149
+ summary: Provider-agnostic Taiwan e-invoice SDK (unified model + per-provider adapters).
266
150
  test_files: []
@@ -1,31 +0,0 @@
1
- name: Daily update
2
- on:
3
- schedule:
4
- - cron: 0 0 * * *
5
- workflow_dispatch:
6
-
7
- permissions:
8
- contents: write
9
-
10
- jobs:
11
- build:
12
- runs-on: ubuntu-latest
13
- steps:
14
- - uses: actions/checkout@v4
15
- - uses: ruby/setup-ruby@v1
16
- with:
17
- ruby-version: '3.3'
18
- bundler-cache: true
19
- - name: Update donation unit list
20
- run: bundle exec rake update_donation_unit
21
- - name: Commit and push changes
22
- run: |
23
- if git diff --quiet; then
24
- echo "Donation unit list is up to date"
25
- exit 0
26
- fi
27
- git config user.name "github-actions[bot]"
28
- git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
29
- git add lib/einvoice/donation_unit_list.json
30
- git commit -m "Automated donation unit list update"
31
- git push
@@ -1,201 +0,0 @@
1
- # Tradevan E-Invoice APIs
2
-
3
- ## Overview
4
-
5
- * Preparation
6
- * Encode Request
7
- * Decode Response
8
- * APIs
9
-
10
- ## Preparation
11
-
12
- After contacting with Tradevan, you'll get
13
-
14
- * acnt: your account name
15
- * acntp: your account password
16
- * key1: 1st AES encryption key
17
- * key2: 2nd AES encryption key
18
-
19
- ## Encode Request
20
-
21
- * Method: POST/GET
22
- * URL: "#{endpoint}/#{path}"
23
- * Parameters: "#{v}"
24
- * v: `Base64_strict.encode(AES.encrypt(key2, { acnt: "#{acnt}", acntp: "#{acntp}", api_key1: "#{encryption_of_api_value1}", api_key2: "#{encryption_of_api_value2}", ... }))`
25
- * `AES.encrypt(key, content)`:
26
- * mode: CBC-128
27
- * key: use `key2` for outter encryption, use `key1` for inner value encryption
28
- * iv: same as key
29
- * padding: no, but you should manually pad with `"\u0000"`(character space in bytes format) to fit correct CBC block size
30
- * encryption_of_api_value1: `Base64_strict.encode(AES.encrypt(key1, api_value1))`
31
-
32
- ## Decode Response
33
-
34
- * Format: JSON, i.e. `{ "Success": "Y", "Message": "#{encryption_of_message}" }`
35
- * Success: "Y" for OK, "N" for Failure, "E" for Error
36
- * Message:
37
- * Plain Text when `"Success": "E"`
38
- * Encryption Text when `"Success": "Y"` or `"Success": "N"`
39
- * Decryption: `AES.decrypt(key2, Base64_strict.decode(response["Message"]))`
40
- * `AES.decrypt(key, content)`:
41
- * mode: CBC-128
42
- * key: use `key2` for decrypt `response["Message"]` content
43
- * iv: key
44
- * padding: no
45
-
46
- ## APIs
47
-
48
- ### POST /DEFAULTAPI/post/issue
49
-
50
- You could use this API to do
51
-
52
- 1. issue an new invoice
53
- 2. issue an existed invoice
54
- 3. issue an allowance
55
- 4. issue an existed allowance
56
-
57
- #### Parameters
58
-
59
- * issueData
60
- * type: json
61
-
62
- ### POST /DEFAULTAPI/post/cancel
63
-
64
- You could use this API to do
65
-
66
- 1. cancel an existed invoice
67
- 2. cancel an allowance
68
-
69
- #### Parameters
70
-
71
- * voidData
72
- * type: json
73
-
74
- ### GET /DEFAULTAPI/get/searchInvoiceByMemberId
75
-
76
- #### Parameters
77
-
78
- * invoiceStartDate
79
- * description: begining of invoice issued date interval
80
- * type: string
81
- * require: false
82
- * format: yyyyMMdd
83
- * invoiceEndDate
84
- * description: end of invoice issued date interval
85
- * type: string
86
- * require: false
87
- * format: yyyyMMdd
88
- * companyUn
89
- * description: company universal business number(ubn) of Taiwan
90
- * type: string
91
- * require: true
92
- * memberId
93
- * description: customer's member id of your service
94
- * type: string
95
- * require: true if `sellTargetCode` and `carrierId` are empty
96
- * carrierId
97
- * description: customer's carrier id of invoices
98
- * type: string
99
- * require: true if `memberId` and `sellTargetCode` are empty
100
- * sellTargetCode
101
- * description: ?
102
- * type: string
103
- * require: true if `memberId` and `carrierId` are empty
104
-
105
- ### GET /DEFAULTAPI/get/searchInvoiceDetail
106
-
107
- #### Parameters
108
-
109
- * invoiceNumber
110
- * description: invoice number
111
- * type: string
112
- * require: true
113
-
114
- ### GET /DEFAULTAPI/get/sendCardInfotoCust
115
-
116
- #### Parameters
117
-
118
- * companyUn
119
- * description: company universal business number(ubn) of Taiwan
120
- * type: string
121
- * require: true
122
- * sellTargetCode
123
- * description: ?
124
- * type: string
125
- * require: true
126
- * invoiceStartYM
127
- * description: begining of invoice issued year and month interval
128
- * type: string
129
- * require: false
130
- * format: yyyyMM
131
- * invoiceEndYM
132
- * description: end of invoice issued year and month interval
133
- * type: string
134
- * require: false
135
- * format: yyyyMM
136
- * receiverEmail
137
- * description: receiver's email
138
- * type: string
139
- * require: true if `receiverMobile` is empty
140
- * receiverMobile
141
- * description: receiver's mobile
142
- * type: string
143
- * require: true if `receiverEmail` is empty
144
-
145
- ### GET /DEFAULTAPI/get/getInvoiceMarkInfo
146
-
147
- #### Parameters
148
-
149
- * companyUn
150
- * description: your company universal business number(ubn) of Taiwan
151
- * type: string
152
- * require: true
153
- * orgId
154
- * description: your orgId
155
- * type: string
156
- * require: true
157
- * uniFiedNumber
158
- * description: your company or branch ubn used to issue invoices
159
- * type: string
160
- * require: true
161
- * bookType
162
- * description: your book type
163
- * type: string
164
- * require: true
165
- * period
166
- * description: query year with or without months
167
- * type: string
168
- * require: true
169
- * format: yyyymm
170
-
171
- ### GET /DEFAULTAPI/get/getDonateUnitList
172
-
173
- #### Parameters
174
-
175
- * companyUn
176
- * description: company universal business number(ubn) of Taiwan
177
- * type: string
178
- * require: true
179
-
180
- ### GET /DEFAULTAPI/get/getInvoiceContent
181
-
182
- #### Parameters
183
-
184
- * invoiceNumber
185
- * description: invoice number
186
- * type: string
187
- * require: true if `sellTargetCode` is empty
188
- * sellTargetCode
189
- * description: ?
190
- * type: string
191
- * require: true if `invoiceNumber` is empty
192
- * invoiceStartDate
193
- * description: begining of invoice issued date interval
194
- * type: string
195
- * require: false
196
- * format: yyyyMMdd
197
- * invoiceEndDate
198
- * description: end of invoice issued date interval
199
- * type: string
200
- * require: false
201
- * format: yyyyMMdd