{"id":13751883,"url":"https://github.com/g0v/labor-standards-tw","last_synced_at":"2025-04-12T06:36:50.444Z","repository":{"id":136535954,"uuid":"87950066","full_name":"g0v/labor-standards-tw","owner":"g0v","description":"台灣勞動基準法函式庫, Taiwan Labor Standards Act Library","archived":false,"fork":false,"pushed_at":"2018-01-15T01:59:40.000Z","size":510,"stargazers_count":54,"open_issues_count":8,"forks_count":14,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-03-26T02:01:43.927Z","etag":null,"topics":["civil-tech","cucumberjs","labor","labor-rights","labor-standards-act","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/g0v.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-04-11T15:25:21.000Z","updated_at":"2024-09-13T04:56:40.000Z","dependencies_parsed_at":null,"dependency_job_id":"27c9fb72-5cb7-4813-82a6-8a77b5cf4c1e","html_url":"https://github.com/g0v/labor-standards-tw","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/g0v%2Flabor-standards-tw","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/g0v%2Flabor-standards-tw/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/g0v%2Flabor-standards-tw/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/g0v%2Flabor-standards-tw/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/g0v","download_url":"https://codeload.github.com/g0v/labor-standards-tw/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248530549,"owners_count":21119590,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["civil-tech","cucumberjs","labor","labor-rights","labor-standards-act","typescript"],"created_at":"2024-08-03T09:00:56.556Z","updated_at":"2025-04-12T06:36:50.390Z","avatar_url":"https://github.com/g0v.png","language":"TypeScript","funding_links":[],"categories":["工具 Utilities"],"sub_categories":[],"readme":"# labor-standards-tw\n\n台灣勞動基準法的函式庫，可用於計算違法罰款、加班費、特休假、確認班表是否違法等。\n\nTaiwan `Labor Standards Act` Library for calculating penalty, overtime wages, annual paid leaves \u0026 checking shift work schedule is legal or not.\n\n## 目錄\n* [如何使用](#如何使用)\n* [協助開發](#協助開發)\n\n## 如何使用\n\n首先可以使用 `npm` 安裝本函式庫：\n\n```shell\nnpm install g0v/labor-standards-tw --save\n```\n\n安裝後，在 node.js 環境底下可以用 `require()` 引入函示庫，如在瀏覽器環境，可以用 webpack 後使用 `import` 語法引入：\n\n```javascript\n// for Node.js\nconst {Labor, WorkTime} = require('labor-standards-tw')\n\n// for Webpack\nimport {Labor, WorkTime} from 'labor-standards-tw'\n```\n\n### Labor class\n\nLabor 類別是本函式庫的基礎，所有功能都圍繞著這個類別。它可以用來設定一個勞工的就職日、月薪、年齡等條件。\n\n```javascript\nimport { Labor, Gender } from 'labor-standards-tw'\n\n// 一個 20 歲的女性勞工於 2017/3/20 就職，月薪為 24000 元\nconst labor = new Labor()\nlabor.setGender(Gender.FEMALE)\n     .setAge(20)\n     .onBoard(new Date(2017, 4, 20))\n     .setMonthlySalary(24000)\n```\n\nLabor 類別有兩種類型的 methods，第一種是如上述的一些 setter / getter 可以設定基本資訊，另外一種是依據這些基本資訊計算出更進一步的資訊，第二種類型的 methods 都會回傳 [Result 類別](https://github.com/g0v/labor-standards-tw/blob/master/src/Result.ts)。\n\n```javascript\nimport { Labor, ChildLaborType } from 'labor-standards-tw'\n\nconst labor = new Labor().setAge(15)\n\n// 驗證勞工是否為童工身分\nlet result = labor.validateChildLabor()\n\n// 根據勞動基準法 44 條，此勞工為合法的童工身分\nexpect(result.value.legal).eq(true)\nexpect(result.value.type).eq(ChildLaborType.CHILD_LABOR)\nlet article = result.according[0]\nexpect(article.lawTitle).eq('勞動基準法')\nexpect(article.id).eq('44')\n\n// 如果勞工年齡為 14 歲\nresult = labor.setAge(14).validateChildLabor()\n\n// 非法\nexpect(result.value.legal).eq(false)\n\n// 身分為非法勞工\nexpect(result.value.type).eq(ChildLaborType.ILLEGAL)\n\n// 違反勞基法 44 條\narticle = result.violations[0]\nexpect(article.lawTitle).eq('勞動基準法')\nexpect(article.id).eq('44')\n\n// 有三種可能性的罰則\n// 1. 罰款 300,000 以下\n// 2. 拘役 6 個月以下\n// 3. 前面兩者加起來\nconst penalty = article.penalize()\nexpect(penalty.article.id).eq('77')\nexpect(penalty.possibilities.length).eq(3)\n```\n\n更詳細的用法，請參考程式內的 jsdoc 註解，或是 cucumber 的 [測試案例](https://github.com/g0v/labor-standards-tw/tree/master/features/step_definitions)\n\n## 協助開發\n\n本專案使用 node.js v6 LTS，如果你有許多專案使用不同版本的 node.js，推薦你使用 [nvm](https://github.com/creationix/nvm)\n\n### 如何開發\n\n你可以先使用 `npm install` 安裝所有相依性套件。接著用 `npm test` 可以執行所有測試。\n\n如果需要除錯，可以使用 Visual Studio Code，在你需要下斷點的地方鍵入 `debugger;` 跳到除錯的頁籤，並且執行 `Debug` task。\n\n比如說你想要在 `Labor.ts` 底下的 `retire()` 下斷點，就把 `debugger` 加在第一行如下面程式片段：\n\n```typescript\nretire (date: Date): Result {\n  debugger; // 加入在這裡\n  const result = new Result()\n\n  const years = moment(date).diff(this._onboard, 'years')\n  const retirement = (years \u003e= 15 \u0026\u0026 this.getAge() \u003e= 55) ||\n                      (years \u003e= 25) ||\n                      (years \u003e= 10 \u0026\u0026 this.getAge() \u003e= 60)\n\n  result.value.retirement = retirement\n  result.according.push(new Article('勞動基準法', '53'))\n\n  return result\n}\n```\n\n執行 `Debug` task 後，就會停在中斷點，並且可以逐步執行。\n\n![Screenshot for debugging](http://i.imgur.com/wdjJw6a.png)\n\n### 如何貢獻\n\n如果你發現程式碼有錯誤，或任何需要改進的地方，請到 [issues](https://github.com/g0v/labor-standards-tw/issues) 頁面開一個新的 issue。\n\n如果想協助本專案，請到 [Github issue](https://github.com/g0v/labor-standards-tw/issues) 逛逛，看看有沒有還沒解掉的 issues 可以協助。\n\n若要提交你的修改，請送 pull request 到本專案，travis-ci 上面會有基本的語法與 coding style 檢查後，接著經由團隊成員審核後就會將您的變更合併入專案當中。\n\n關於 cucumber 的測試方式，請參考 [test.md](https://github.com/g0v/labor-standards-tw/tree/master/docs/test.md)。\n\n## 相關資訊\n\n* [活動共筆：從砍七天假爭議談勞基法工時規定](https://g0v.hackpad.com/3hMbxYbFCxv)\n* [2016工時制度及工作彈性化措施手冊彈性化措施手冊(勞動部)](http://www.mol.gov.tw/topic/3067/14530/14533/)\n* [2016勞動法令\u0026實務彙編(台北市勞工局)](http://bola.gov.taipei/lp.asp?ctNode=62983\u0026CtUnit=34049\u0026BaseDSD=7\u0026mp=116003)\n* [106年度勞基法新制上路中小企業因應須知](https://law.moeasmea.gov.tw/upload/106%E5%B9%B4%E5%BA%A6%E5%8B%9E%E5%9F%BA%E6%B3%95%E6%96%B0%E5%88%B6%E4%B8%8A%E8%B7%AF%E4%B8%AD%E5%B0%8F%E4%BC%81%E6%A5%AD%E5%9B%A0%E6%87%89%E9%A0%88%E7%9F%A5.pdf)\n\n## 授權\n\n本專案依照 [MIT 授權](https://github.com/g0v/labor-standards-tw/blob/master/LICENSE) 釋出，若需使用請確保您的使用方式符合 MIT 授權。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fg0v%2Flabor-standards-tw","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fg0v%2Flabor-standards-tw","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fg0v%2Flabor-standards-tw/lists"}