Skip to main content

taiwan-payroll (Python)

台灣勞健保勞退法定費用計算引擎的 Python 實作。讀同一份 data/,跑通同一套 testdata/ 黃金向量,與 TypeScript 版計算結果完全一致。零執行期依賴(純 stdlib)。

安裝

pip install taiwan-payroll

用法

from taiwan_payroll import create_payroll_engine, CalculateInput, SupplementaryInput, ProratedInput

engine = create_payroll_engine(year=2026)
engine.calculate(CalculateInput(monthly_salary=42000, dependents=1, pension_self_contribution=0.06))
engine.calculate_supplementary(SupplementaryInput(type="bonus", amount=200000, monthly_insured_salary=42000))
engine.calculate_prorated(ProratedInput(monthly_salary=29500, start_date="2026-03-08"))

申報媒體檔(健保補充保費)

產生健保署「補充保險費明細申報檔」(CSV/Big5),6 類所得各一(獎金62/兼職63/執行業務65/股利66/利息67/租金68),皆以官方範例逐位元驗證、與 TypeScript 版一致。

from taiwan_payroll import generate_supplementary_bonus_filing, to_big5_bytes, SupplementaryBonusFilingInput, SupplementaryBonusFilingUnit, SupplementaryBonusRecord

r = generate_supplementary_bonus_filing(SupplementaryBonusFilingInput(
    year=2026, filing_date="20260901",
    unit=SupplementaryBonusFilingUnit(tax_id="11111111", name="甲公司", phone="0227065866", email="a@b.tw", contact_name="王小明"),
    records=[SupplementaryBonusRecord(action="I", pay_date="20260615", payee_id="A123456789", payee_name="李四",
        bonus_amount=50000, insured_salary=31800, ytd_bonus_cumulative=150000, unit_code="123456789")],
))
open(r.filename, "wb").write(to_big5_bytes(r.content))  # 檔案為 Big5

股利(generate_supplementary_dividend_filing)逐列保費由呼叫端提供(另附 calc_dividend_premium)。

勞保老年給付試算

calc_old_age_pension(年金月領,擇優兩式、可提前/延後)、calc_old_age_lump_sum(老年一次金)、calc_old_age_single_payment(一次請領,舊制基數),皆對勞保局官方數值/公式驗證、與 TypeScript 版一致。

from taiwan_payroll import calc_old_age_pension, get_year_data, OldAgePensionInput
calc_old_age_pension(get_year_data(2026), OldAgePensionInput(avg_insured_salary=32000, years=35, months=6))

開發

cd packages/python && python3 -m venv .venv && .venv/bin/python -m pip install -e ".[test]"
.venv/bin/python -m pytest

跨語言一致性:tests/test_vectors.py 載入 repo 根 testdata/ 的同一套黃金向量,與 TypeScript 引擎逐位元比對。

免責聲明

計算結果僅供參考,實際應繳金額以勞保局、健保署核發之繳款單為準。

Metadata

Release files for taiwan-payroll 1.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for taiwan-payroll 1.3.1
File Size Uploaded Provenance
taiwan_payroll-1.3.1.tar.gz 22.7 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for taiwan-payroll 1.3.1
File Interpreter ABI Platform
taiwan_payroll-1.3.1-py3-none-any.whl Python 3 none any Details

Total release size: 65.0 kB

Release files / taiwan_payroll-1.3.1.tar.gz

Download URL taiwan_payroll-1.3.1.tar.gz
Size 22.7 kB
Tags Source
SHA-256 checksum
How to use checksums
acc7df0fc3aaee18aa77916076c6a20ee33db7371aeac0d3845a0e3cbc2d6bc6
BLAKE2b-256 checksum
How to use checksums
8a871e64aa9bb5b8a01df5756019ae66a22d9390a0718c033bb9144b976d9a13
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 8, 2026.

Transparency log

Release files / taiwan_payroll-1.3.1-py3-none-any.whl

Download URL taiwan_payroll-1.3.1-py3-none-any.whl
Size 42.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a327111aa8b98d57472f4fd80ff026faaab5d300919370e04bc443793a186b01
BLAKE2b-256 checksum
How to use checksums
417239aaf382a673ce5ce2a8781d16a57a2f61bab69c2101a8315bf93754e1b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 8, 2026.

Transparency log

Security for taiwan-payroll 1.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for taiwan_payroll-1.3.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 8, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page