cetustek 1.0.0__tar.gz

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.
@@ -0,0 +1,44 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ jobs:
8
+ build:
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - uses: actions/checkout@v4
12
+
13
+ - name: Set up Python
14
+ uses: actions/setup-python@v5
15
+ with:
16
+ python-version: "3.12"
17
+
18
+ - name: Install build dependencies
19
+ run: pip install build
20
+
21
+ - name: Build package
22
+ run: python -m build
23
+
24
+ - name: Upload artifacts
25
+ uses: actions/upload-artifact@v4
26
+ with:
27
+ name: dist
28
+ path: dist/
29
+
30
+ publish:
31
+ needs: build
32
+ runs-on: ubuntu-latest
33
+ environment: pypi
34
+ permissions:
35
+ id-token: write
36
+ steps:
37
+ - name: Download artifacts
38
+ uses: actions/download-artifact@v4
39
+ with:
40
+ name: dist
41
+ path: dist/
42
+
43
+ - name: Publish to PyPI
44
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,212 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # poetry
98
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102
+ #poetry.lock
103
+
104
+ # pdm
105
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
106
+ #pdm.lock
107
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
108
+ # in version control.
109
+ # https://pdm.fming.dev/#use-with-ide
110
+ .pdm.toml
111
+
112
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
113
+ __pypackages__/
114
+
115
+ # Celery stuff
116
+ celerybeat-schedule
117
+ celerybeat.pid
118
+
119
+ # SageMath parsed files
120
+ *.sage.py
121
+
122
+ # Environments
123
+ .env
124
+ .venv
125
+ env/
126
+ venv/
127
+ ENV/
128
+ env.bak/
129
+ venv.bak/
130
+
131
+ # Spyder project settings
132
+ .spyderproject
133
+ .spyproject
134
+
135
+ # Rope project settings
136
+ .ropeproject
137
+
138
+ # mkdocs documentation
139
+ /site
140
+
141
+ # mypy
142
+ .mypy_cache/
143
+ .dmypy.json
144
+ dmypy.json
145
+
146
+ # Pyre type checker
147
+ .pyre/
148
+
149
+ # pytype static type analyzer
150
+ .pytype/
151
+
152
+ # Cython debug symbols
153
+ cython_debug/
154
+
155
+ # PyCharm
156
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
157
+ # be added to the global gitignore or merged into this project gitignore. For a PyCharm
158
+ # project, it is recommended to include the following files:
159
+ # .idea/
160
+ # .idea_modules/
161
+ # *.iml
162
+ # *.ipr
163
+ # *.iws
164
+
165
+ # VS Code
166
+ .vscode/
167
+ *.code-workspace
168
+
169
+ # macOS
170
+ .DS_Store
171
+ .AppleDouble
172
+ .LSOverride
173
+
174
+ # Windows
175
+ Thumbs.db
176
+ ehthumbs.db
177
+ Desktop.ini
178
+ $RECYCLE.BIN/
179
+
180
+ # Linux
181
+ *~
182
+
183
+ # IDEs
184
+ .idea/
185
+ *.swp
186
+ *.swo
187
+ *~
188
+
189
+ # Database files
190
+ *.db
191
+ *.sqlite
192
+ *.sqlite3
193
+
194
+ # Log files
195
+ *.log
196
+ logs/
197
+
198
+ # Temporary files
199
+ *.tmp
200
+ *.temp
201
+ tmp/
202
+ temp/
203
+
204
+ # Environment variables
205
+ .env.local
206
+ .env.*.local
207
+ .env.development
208
+ .env.production
209
+
210
+ # Local configuration
211
+ config.local.py
212
+ settings.local.py
cetustek-1.0.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Vince Lee
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,288 @@
1
+ Metadata-Version: 2.4
2
+ Name: cetustek
3
+ Version: 1.0.0
4
+ Summary: Python SDK for Cetustek Taiwan e-invoice API
5
+ Project-URL: Homepage, https://github.com/vincelee888/cetustek
6
+ Project-URL: Repository, https://github.com/vincelee888/cetustek
7
+ Project-URL: Issues, https://github.com/vincelee888/cetustek/issues
8
+ Author: Vince Lee
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: cetustek,e-invoice,einvoice,invoice,taiwan
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Topic :: Office/Business :: Financial
23
+ Classifier: Typing :: Typed
24
+ Requires-Python: >=3.9
25
+ Requires-Dist: requests>=2.25.0
26
+ Provides-Extra: dev
27
+ Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
28
+ Requires-Dist: pytest>=7.0.0; extra == 'dev'
29
+ Description-Content-Type: text/markdown
30
+
31
+ # Cetustek
32
+
33
+ [![PyPI version](https://badge.fury.io/py/cetustek.svg)](https://badge.fury.io/py/cetustek)
34
+ [![Python](https://img.shields.io/pypi/pyversions/cetustek.svg)](https://pypi.org/project/cetustek/)
35
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
36
+
37
+ A Python SDK for the [Cetustek](https://www.cetustek.com.tw/) Taiwan e-invoice API.
38
+
39
+ ## Features
40
+
41
+ - Create, query, and cancel e-invoices
42
+ - Type-safe with dataclass request/response models
43
+ - Comprehensive error handling with custom exceptions
44
+ - Full support for B2B and B2C invoices
45
+
46
+ ## Installation
47
+
48
+ ```bash
49
+ pip install cetustek
50
+ ```
51
+
52
+ **Requirements:** Python 3.9+
53
+
54
+ ## Quick Start
55
+
56
+ ```python
57
+ from cetustek import Cetustek, CreateInvoiceInput, InvoiceItem
58
+
59
+ client = Cetustek(
60
+ endpoint="https://invoice.cetustek.com.tw/InvoiceMultiWeb/InvoiceAPI",
61
+ rent_id="YOUR_RENT_ID",
62
+ site_code="YOUR_SITE_CODE",
63
+ api_password="YOUR_API_PASSWORD",
64
+ )
65
+
66
+ result = client.createInvoice(CreateInvoiceInput(
67
+ order_id="12345678",
68
+ order_date="2026/01/15",
69
+ donate_mark="0",
70
+ invoice_type="07",
71
+ tax_type="1",
72
+ pay_way="1",
73
+ items=[InvoiceItem(
74
+ production_code="PROD001",
75
+ description="Product",
76
+ quantity=1,
77
+ unit_price=1000,
78
+ )],
79
+ ))
80
+
81
+ print(result.invoice_number) # "WP20260002"
82
+ print(result.random_code) # "6827"
83
+ ```
84
+
85
+ ## Usage
86
+
87
+ ### Create Invoice
88
+
89
+ ```python
90
+ from cetustek import CreateInvoiceInput, InvoiceItem, CetustekAPIError
91
+
92
+ try:
93
+ result = client.createInvoice(CreateInvoiceInput(
94
+ order_id="12345678",
95
+ order_date="2026/01/15",
96
+ donate_mark="0", # 0: No donation, 1: Donate, 2: Donate to NPO
97
+ invoice_type="07", # 07: B2B, 08: B2C
98
+ tax_type="1", # 1: Taxable, 2: Zero-rated, 3: Tax-free
99
+ pay_way="1",
100
+ items=[InvoiceItem(
101
+ production_code="PROD001",
102
+ description="Product description",
103
+ quantity=1,
104
+ unit_price=1000,
105
+ unit="件", # Optional
106
+ )],
107
+ # Optional buyer info
108
+ buyer_identifier="12345678", # Tax ID (統一編號)
109
+ buyer_name="Company Name",
110
+ buyer_email="email@example.com",
111
+ tax_rate=0.05, # Default: 5%
112
+ ))
113
+
114
+ print(result.invoice_number) # "WP20260002"
115
+ print(result.random_code) # "6827"
116
+ print(result.invoice_year) # "2026" (derived property)
117
+
118
+ except CetustekAPIError as e:
119
+ print(f"Error: {e.code}")
120
+ ```
121
+
122
+ ### Query Invoice
123
+
124
+ ```python
125
+ from cetustek import QueryInvoiceInput
126
+
127
+ result = client.queryInvoice(QueryInvoiceInput(
128
+ invoice_number="WP20260002",
129
+ invoice_year="2026",
130
+ ))
131
+
132
+ print(result.order_id)
133
+ print(result.buyer_name)
134
+ print(result.total_amount)
135
+ print(result.invoice_status)
136
+ ```
137
+
138
+ ### Cancel Invoice
139
+
140
+ ```python
141
+ from cetustek import CancelInvoiceInput
142
+
143
+ result = client.cancelInvoice(CancelInvoiceInput(
144
+ invoice_number="WP20260002",
145
+ invoice_year="2026",
146
+ remark="Cancellation reason",
147
+ ))
148
+
149
+ if result.success:
150
+ print("Invoice cancelled")
151
+ else:
152
+ print(f"Failed: {result.code}")
153
+ ```
154
+
155
+ ## API Reference
156
+
157
+ ### Client
158
+
159
+ | Parameter | Description |
160
+ |-----------|-------------|
161
+ | `endpoint` | Cetustek API endpoint URL |
162
+ | `rent_id` | Rent ID (統一編號) |
163
+ | `site_code` | Site code |
164
+ | `api_password` | API password |
165
+
166
+ ### Response Models
167
+
168
+ **CreateInvoiceResponse**
169
+
170
+ | Field | Type | Description |
171
+ |-------|------|-------------|
172
+ | `invoice_number` | str | Invoice number (e.g., "WP20260002") |
173
+ | `random_code` | str | 4-digit random code |
174
+ | `invoice_year` | str | Year (derived from invoice_number) |
175
+
176
+ **QueryInvoiceResponse**
177
+
178
+ | Field | Type | Description |
179
+ |-------|------|-------------|
180
+ | `invoice_number` | str | Invoice number |
181
+ | `order_id` | str | Order ID |
182
+ | `random_code` | str | Random code |
183
+ | `buyer_identifier` | str | Buyer tax ID |
184
+ | `buyer_name` | str | Buyer name |
185
+ | `seller_identifier` | str | Seller tax ID |
186
+ | `seller_name` | str | Seller name |
187
+ | `invoice_status` | str | Status |
188
+ | `sales_amount` | float | Sales amount |
189
+ | `tax_amount` | float | Tax amount |
190
+ | `total_amount` | float | Total amount |
191
+ | `raw_xml` | str | Raw XML response |
192
+
193
+ **CancelInvoiceResponse**
194
+
195
+ | Field | Type | Description |
196
+ |-------|------|-------------|
197
+ | `success` | bool | Whether cancellation succeeded |
198
+ | `code` | str | Response code ("C0" = success) |
199
+ | `message` | str | Error message (if failed) |
200
+
201
+ ### Input Models
202
+
203
+ **InvoiceItem**
204
+
205
+ | Field | Type | Required | Description |
206
+ |-------|------|:--------:|-------------|
207
+ | `production_code` | str | Yes | Product code |
208
+ | `description` | str | Yes | Description |
209
+ | `quantity` | float | Yes | Quantity |
210
+ | `unit_price` | float | Yes | Unit price |
211
+ | `unit` | str | No | Unit (e.g., "件") |
212
+
213
+ **CreateInvoiceInput**
214
+
215
+ | Field | Type | Required | Description |
216
+ |-------|------|:--------:|-------------|
217
+ | `order_id` | str | Yes | Order ID |
218
+ | `order_date` | str | Yes | Date (yyyy/MM/dd) |
219
+ | `donate_mark` | str | Yes | 0/1/2 |
220
+ | `invoice_type` | str | Yes | 07 (B2B) / 08 (B2C) |
221
+ | `pay_way` | str | Yes | Payment method |
222
+ | `tax_type` | str | Yes | 1/2/3/4/5/9 |
223
+ | `items` | List | Yes | Invoice items |
224
+ | `buyer_identifier` | str | No | Buyer tax ID |
225
+ | `buyer_name` | str | No | Buyer name |
226
+ | `buyer_email` | str | No | Buyer email |
227
+ | `tax_rate` | float | No | Tax rate (default: 0.05) |
228
+ | `carrier_type` | str | No | Carrier type |
229
+ | `carrier_id1` | str | No | Carrier ID |
230
+ | `npoban` | str | No | NPO code |
231
+
232
+ ## Error Handling
233
+
234
+ ```python
235
+ from cetustek import CetustekError, CetustekAPIError
236
+
237
+ try:
238
+ result = client.createInvoice(invoice_input)
239
+ except CetustekAPIError as e:
240
+ print(f"API Error: {e.code} - {e.message}")
241
+ except CetustekError as e:
242
+ print(f"SDK Error: {e}")
243
+ ```
244
+
245
+ ## Example
246
+
247
+ See [example.py](example.py) for a complete working example.
248
+
249
+ ## Getting Started
250
+
251
+ ```bash
252
+ pip install cetustek
253
+ ```
254
+
255
+ ```python
256
+ from cetustek import Cetustek, CreateInvoiceInput, InvoiceItem
257
+
258
+ # Initialize client
259
+ client = Cetustek(
260
+ endpoint="https://invoice.cetustek.com.tw/InvoiceMultiWeb/InvoiceAPI",
261
+ rent_id="YOUR_RENT_ID",
262
+ site_code="YOUR_SITE_CODE",
263
+ api_password="YOUR_API_PASSWORD",
264
+ )
265
+
266
+ # Create an invoice
267
+ result = client.createInvoice(CreateInvoiceInput(
268
+ order_id="12345678",
269
+ order_date="2026/01/15",
270
+ donate_mark="0",
271
+ invoice_type="07",
272
+ tax_type="1",
273
+ pay_way="1",
274
+ items=[InvoiceItem(
275
+ production_code="PROD001",
276
+ description="Product",
277
+ quantity=1,
278
+ unit_price=1000,
279
+ )],
280
+ ))
281
+
282
+ print(result.invoice_number) # e.g., "WP20260002"
283
+ print(result.random_code) # e.g., "6827"
284
+ ```
285
+
286
+ ## License
287
+
288
+ MIT