├── .env ├── .gitignore ├── nodemon.json ├── src ├── expense │ ├── expense_budgets.trigger.js │ ├── expense_subjects.object.yml │ ├── expense_budgets.manager.js │ ├── expense_lists.trigger.js │ ├── expense_forms.object.yml │ ├── expense_budgets.object.yml │ └── expense_lists.object.yml ├── oa.app.yml └── expense.app.yml ├── server.js ├── steedos-config.yml ├── package.json ├── README.md └── LICENSE.txt /.env: -------------------------------------------------------------------------------- 1 | MONGO_URL=mongodb://127.0.0.1:27017/steedos 2 | PORT=5000 3 | ROOT_URL=http://127.0.0.1:5000 -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | **/.DS_Store 2 | **/.idea 3 | 4 | **/node_modules 5 | **/package-lock.json 6 | 7 | **/npm-error.log 8 | **/yarn-error.log 9 | **/lerna-debug.log 10 | 11 | **/lib 12 | 13 | **/.vscode/launch.* 14 | 15 | .DS_Store 16 | 17 | isolate-*.log 18 | .env.local 19 | 20 | storage/** -------------------------------------------------------------------------------- /nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "restartable": "rs", 3 | "ignore": [ 4 | ".git", 5 | "node_modules/**/node_modules" 6 | ], 7 | "verbose": false, 8 | "env": { 9 | "NODE_ENV": "development" 10 | }, 11 | "ext": "js,json,yml", 12 | "delay": "3000" 13 | } -------------------------------------------------------------------------------- /src/expense/expense_budgets.trigger.js: -------------------------------------------------------------------------------- 1 | const ebManager = require('./expense_budgets.manager'); 2 | 3 | module.exports = { 4 | listenTo: 'expense_budgets', 5 | 6 | afterInsert: async function () { 7 | await ebManager.caculateAmount(this.doc._id) 8 | }, 9 | 10 | afterUpdate: async function () { 11 | await ebManager.caculateAmount(this.id); 12 | }, 13 | 14 | } -------------------------------------------------------------------------------- /src/oa.app.yml: -------------------------------------------------------------------------------- 1 | _id: oa 2 | name: 华炎办公 3 | description: '云办公平台,实现实时在线审批。' 4 | icon_slds: groups 5 | is_creator: true 6 | sort: 100 7 | objects: 8 | - instances 9 | - cms_posts 10 | - announcements 11 | - space_users 12 | - tasks 13 | - events 14 | mobile_objects: 15 | - instances 16 | - cms_posts 17 | - announcements 18 | - space_users 19 | - tasks 20 | - events -------------------------------------------------------------------------------- /server.js: -------------------------------------------------------------------------------- 1 | require('dotenv-flow').config(); 2 | 3 | var server = require('@steedos/meteor-bundle-runner'); 4 | var steedos = require('@steedos/core') 5 | 6 | server.Fiber(function () { 7 | try { 8 | server.Profile.run("Server startup", function () { 9 | server.loadServerBundles(); 10 | steedos.init(); 11 | server.callStartupHooks(); 12 | server.runMain(); 13 | }) 14 | } catch (error) { 15 | console.error(error.stack) 16 | } 17 | }).run() 18 | -------------------------------------------------------------------------------- /src/expense.app.yml: -------------------------------------------------------------------------------- 1 | _id: expense 2 | name: 费用管控 3 | description: 费用预算编制、费用发生、费用管控。 4 | icon_slds: coaching 5 | is_creator: true 6 | objects: 7 | - expense_budgets 8 | - expense_forms 9 | - expense_lists 10 | - instances 11 | - reports 12 | mobile_objects: 13 | - expense_budgets 14 | - expense_forms 15 | - expense_lists 16 | - instances 17 | admin_menus: 18 | - _id: expense 19 | name: 费用管控 20 | permission_sets: 21 | - admin 22 | expanded: false 23 | - _id: expense_subjects 24 | name: 费用科目 25 | object_name: expense_subjects 26 | parent: expense 27 | -------------------------------------------------------------------------------- /steedos-config.yml: -------------------------------------------------------------------------------- 1 | datasources: 2 | default: 3 | connection: 4 | url: ${MONGO_URL} 5 | objectFiles: 6 | - "./src/**" 7 | public: 8 | cfs: 9 | store: "local" 10 | local: 11 | folder: "./storage" 12 | email: 13 | host: 14 | port: 465 15 | username: 16 | password: 17 | secure: true 18 | from: 19 | tenant: 20 | _id: 21 | name: 华炎魔方 22 | logo_url: 23 | background_url: 24 | enable_register: true 25 | enable_forget_password: false 26 | enable_create_tenant: true 27 | enable_password_login: true 28 | enable_bind_email: false 29 | enable_bind_mobile: false 30 | plugins: 31 | - "@steedos/accounts" 32 | cron: 33 | instancerecordqueue_interval: 10000 -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "test2", 3 | "version": "0.0.1", 4 | "description": "", 5 | "main": "server.js", 6 | "scripts": { 7 | "debug": "nodemon server.js", 8 | "start": "node server.js", 9 | "test": "echo \"Error: no test specified\" && exit 1" 10 | }, 11 | "author": "", 12 | "license": "ISC", 13 | "dependencies": { 14 | "@steedos/accounts": "1.19.8", 15 | "@steedos/steedos-plugin-workflow": "^2.0.8", 16 | "dotenv-flow": "^3.1.0", 17 | "mssql": "^6.2.0", 18 | "mysql": "^2.18.1", 19 | "steedos-server": "1.21.6" 20 | }, 21 | "devDependencies": { 22 | "nodemon": "^1.19.1" 23 | }, 24 | "homepage": "https://developer.steedos.com", 25 | "resolutions": { 26 | "**/lodash": "^4.17.15", 27 | "**/handlebars": "^4.3.0", 28 | "**/debug": "^3.1.0", 29 | "**/hoek": "^5.0.3", 30 | "**/cryptiles": "^4.1.2", 31 | "**/bcrypt": "3.0.6", 32 | "**/samlp": "3.4.1", 33 | "**/xmldom": "0.2.1", 34 | "**/tslib": "1.11.2", 35 | "**/fibers": "^4.0.3" 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/expense/expense_subjects.object.yml: -------------------------------------------------------------------------------- 1 | name: expense_subjects 2 | label: 费用科目 3 | icon: product_item 4 | enable_api: true 5 | fields: 6 | name: 7 | type: text 8 | label: 科目名称 9 | required: true 10 | searchable: true 11 | index: true 12 | # 此字段需要自动计算 13 | full_name: 14 | type: text 15 | label: 完整名称 16 | omit: true 17 | readonly: true 18 | parent_id: 19 | label: 上级科目 20 | type: lookup 21 | reference_to: expense_subjects 22 | sortable: true 23 | filterable: true 24 | searchable: true 25 | # 此字段需要自动计算 26 | sub_subjects_count: 27 | type: number 28 | label: 子科目数量 29 | inlineHelpText: The number of products under this category (Does not consider the children categories) 30 | omit: true 31 | readonly: true 32 | 33 | list_views: 34 | all: 35 | label: 所有科目 36 | columns: 37 | - name 38 | - parent_id 39 | - created 40 | 41 | permission_set: 42 | user: 43 | allowCreate: false 44 | allowDelete: false 45 | allowEdit: false 46 | allowRead: false 47 | viewCompanyRecords: false 48 | modifyCompanyRecords: false 49 | viewAllRecords: true 50 | modifyAllRecords: false 51 | admin: 52 | allowCreate: true 53 | allowDelete: true 54 | allowEdit: true 55 | allowRead: true 56 | viewCompanyRecords: true 57 | modifyCompanyRecords: true 58 | viewAllRecords: true 59 | modifyAllRecords: true 60 | -------------------------------------------------------------------------------- /src/expense/expense_budgets.manager.js: -------------------------------------------------------------------------------- 1 | const objectql = require('@steedos/objectql'); 2 | /** 3 | * 4 | * @param {string} budgetId 5 | */ 6 | 7 | async function caculateAmount(budgetId) { 8 | if (!budgetId) { 9 | return; 10 | } 11 | const steedosSchema = objectql.getSteedosSchema(); 12 | let budgetObj = steedosSchema.getObject('expense_budgets'); 13 | 14 | let budget = await budgetObj.findOne(budgetId); 15 | if (!budget) { 16 | console.error(`未找到费用预算:${budgetId}`); 17 | return; 18 | } 19 | 20 | let this_budget_value = budget.budget_value; 21 | let this_spended_value = 0; 22 | let this_approving_value = 0; 23 | let this_surplus_value = 0; 24 | (await steedosSchema.getObject('expense_lists').find({ filters: [['expense_budget', '=', budgetId]] })).forEach(function (thisline) { 25 | if (thisline.approve_state == 'approved') { 26 | this_spended_value += (thisline.spend_value || 0); 27 | } else if (thisline.approve_state == 'completed') { 28 | this_spended_value += (thisline.spend_value || 0); 29 | } else if (thisline.approve_state == 'pending') { 30 | this_approving_value += (thisline.spend_value || 0); 31 | } 32 | }); 33 | this_surplus_value = this_budget_value - this_spended_value 34 | await budgetObj.directUpdate(budgetId, { spended_value: this_spended_value , approving_value: this_approving_value , surplus_value: this_surplus_value }); 35 | } 36 | 37 | module.exports = { 38 | caculateAmount 39 | }; -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### 系统功能 2 | 3 | #### 费用预算 4 | 5 | - 管理员新建和维护基于部门和费用科目的费用预算。 6 | - 用户查看费用预算,以及相关的费用执行情况(即费用明细)。 7 | - 通过定义对象权限,实现不同权限组查看不同范围的费用预算记录。例如,限制部门经理只能查看本部门的费用预算。 8 | 9 | ![预算列表](https://www-steedos-com.oss-cn-beijing.aliyuncs.com/images/steedos-app-expense/expense_budget_list.png) 10 | ![预算显示](https://www-steedos-com.oss-cn-beijing.aliyuncs.com/images/steedos-app-expense/expense_budget_display.png) 11 | 12 | #### 费用单据 13 | 14 | - 通过定义对象流程映射,自动将费用审批单即时同步为费用单据记录、将费用审批单上的费用明细即时同步为费用明细记录。 15 | - 用户查看费用单据,以相关的费用明细。 16 | - 通过定义对象权限,实现不同权限组查看不同范围的费用单据记录。例如,限制部门员工只能查看本人的费用单据。 17 | 18 | ![单据](https://www-steedos-com.oss-cn-beijing.aliyuncs.com/images/steedos-app-expense/expense_form_display.png) 19 | 20 | 21 | #### 费用明细 22 | 23 | - 用户查看费用明细,也可查看相关的费用预算、费用单据。 24 | - 通过定义对象权限,实现不同权限组查看不同范围的费用明细记录。例如,开放财务部员工能查看全部的费用明细。 25 | 26 | ![明细](https://www-steedos-com.oss-cn-beijing.aliyuncs.com/images/steedos-app-expense/expense_list_display.png) 27 | 28 | #### 费用审批 29 | 30 | - 自定义各类费用审批流程,例如日常费用审批、出差费用审批等。 31 | - 发起、处理各类费用审批流程。 32 | - 通过定义对象流程映射,自动将费用审批单即时同步为费用单据记录、将费用审批单上的费用明细即时同步为费用明细记录。 33 | 34 | ![明细](https://www-steedos-com.oss-cn-beijing.aliyuncs.com/images/steedos-app-expense/expense_approve.png) 35 | 36 | #### 费用统计 37 | 38 | - 自定义各类费用统计报表 39 | - 发布各类费用统计报表 40 | 41 | #### 基础数据管理 42 | 43 | - 费用科目 44 | 45 | ![设置](https://www-steedos-com.oss-cn-beijing.aliyuncs.com/images/steedos-app-expense/expense_subject_list.png) 46 | 47 | ### 系统安装 48 | 49 | #### 安装 yarn 50 | ``` 51 | npm i yarn -g 52 | ``` 53 | 54 | #### 国内建议使用npm淘宝镜像 55 | ``` 56 | npm config set registry http://registry.npm.taobao.org/ 57 | ``` 58 | 59 | #### 使用yarn安装依赖包 60 | ``` 61 | yarn 62 | ``` 63 | 64 | #### 启动服务器 65 | ``` 66 | yarn start 67 | ``` 68 | 69 | #### 了解更多 70 | - [开发文档](https://steedos.github.io) 71 | -------------------------------------------------------------------------------- /src/expense/expense_lists.trigger.js: -------------------------------------------------------------------------------- 1 | /* 2 | 所有脚本函数均为无参函数,所属数据可从this中获取,this结构如下 3 | id: 记录的唯一标识[string], 4 | userId: 当前用户唯一标识[string], 5 | spaceId: 当前工作区[string], 6 | doc: 需要新增/修改的记录内容[json], 7 | previousDoc: 修改/删除前的记录[json], //仅afterUpdate, afterDelete时存在此属性 8 | object_name: 当前对象名称[string], 9 | datasource_name: 数据源名称[string], 10 | getObject: function(object_name: string)Id 11 | query: 查询数据相关参数[json], //仅beforeFind时存在此属性 12 | */ 13 | 14 | const ebManager = require('./expense_budgets.manager'); 15 | 16 | module.exports = { 17 | listenTo: 'expense_lists', 18 | 19 | afterInsert: async function () { 20 | await caculateBudget(this.doc._id); 21 | }, 22 | 23 | afterUpdate: async function () { 24 | await caculateBudget(this.id); 25 | }, 26 | 27 | } 28 | const objectql = require('@steedos/objectql'); 29 | 30 | async function caculateBudget(listId) { 31 | if (!listId) { 32 | return; 33 | } 34 | const steedosSchema = objectql.getSteedosSchema(); 35 | let listObj = steedosSchema.getObject('expense_lists'); 36 | 37 | let this_list = await listObj.findOne(listId); 38 | if (!this_list) { 39 | console.error(`未找到费用明细:${listId}`); 40 | return; 41 | } 42 | 43 | let this_department = this_list.spend_department; 44 | let this_subject = this_list.expense_subject; 45 | 46 | (await steedosSchema.getObject('expense_subjects').find({ filters: [['name', '=', this_subject]] })).forEach(function (thisline) { 47 | this_subject = thisline._id; 48 | }); 49 | 50 | let this_expense_budget = ""; 51 | (await steedosSchema.getObject('expense_budgets').find({ filters: [['department', '=', this_department], ['expense_subject', '=', this_subject]] })).forEach(function (thisbudget) { 52 | this_expense_budget = thisbudget._id; 53 | }); 54 | if (!this_expense_budget) { 55 | } else { 56 | await listObj.directUpdate(listId, { expense_budget: this_expense_budget }); 57 | await ebManager.caculateAmount(this_expense_budget); 58 | } 59 | } -------------------------------------------------------------------------------- /src/expense/expense_forms.object.yml: -------------------------------------------------------------------------------- 1 | name: expense_forms 2 | label: 费用单据 3 | icon: quip_sheet 4 | enable_api: true 5 | enable_files: true 6 | enable_workflow: true 7 | fields: 8 | name: 9 | type: text 10 | label: 名称 11 | required: true 12 | searchable: true 13 | index: true 14 | type: 15 | label: 类型 16 | type: select 17 | sortable: true 18 | options: 19 | - label: 费用报销单 20 | value: expense_claims 21 | - label: 出差报销单 22 | value: trip_claims 23 | filterable: true 24 | required: true 25 | searchable: true 26 | department: 27 | label: 发生部门 28 | type: lookup 29 | reference_to: organizations 30 | sortable: true 31 | filterable: true 32 | searchable: true 33 | submiter: 34 | label: 发生人员 35 | type: lookup 36 | reference_to: space_users 37 | sortable: true 38 | filterable: true 39 | searchable: true 40 | submit_date: 41 | type: date 42 | label: 提交日期 43 | total_value: 44 | type: number 45 | label: 总金额 46 | scale: 2 47 | complete_date: 48 | type: date 49 | label: 完成日期 50 | description: 51 | type: textarea 52 | label: 备注 53 | is_wide: true 54 | company_id: 55 | label: 所属单位 56 | required: true 57 | omit: false 58 | hidden: false 59 | sortable: true 60 | list_views: 61 | all: 62 | label: 所有单据 63 | columns: 64 | - name 65 | - type 66 | - department 67 | - submiter 68 | - submit_date 69 | - total_value 70 | - complete_date 71 | relatedList: 72 | - cms_files 73 | - expense_lists 74 | 75 | permission_set: 76 | user: 77 | allowCreate: false 78 | allowDelete: false 79 | allowEdit: false 80 | allowRead: true 81 | viewCompanyRecords: false 82 | modifyCompanyRecords: false 83 | viewAllRecords: false 84 | modifyAllRecords: false 85 | admin: 86 | allowCreate: true 87 | allowDelete: true 88 | allowEdit: true 89 | allowRead: true 90 | viewCompanyRecords: true 91 | modifyCompanyRecords: true 92 | viewAllRecords: true 93 | modifyAllRecords: true 94 | -------------------------------------------------------------------------------- /src/expense/expense_budgets.object.yml: -------------------------------------------------------------------------------- 1 | name: expense_budgets 2 | label: 费用预算 3 | icon: goals 4 | enable_api: true 5 | enable_files: true 6 | fields: 7 | name: 8 | type: text 9 | label: 名称 10 | required: true 11 | searchable: true 12 | index: true 13 | year: 14 | label: 年度 15 | type: select 16 | sortable: true 17 | options: 18 | - label: "2020全年" 19 | value: "2020" 20 | filterable: true 21 | required: true 22 | defaultValue: 2020 23 | searchable: true 24 | start_date: 25 | type: date 26 | label: 开始日期 27 | inlineHelpText: The start date of expense budget. 28 | omit: true 29 | readonly: true 30 | end_date: 31 | type: date 32 | label: 结束日期 33 | inlineHelpText: The end date of expense budget. 34 | omit: true 35 | readonly: true 36 | expense_subject: 37 | label: 费用科目 38 | type: master_detail 39 | reference_to: expense_subjects 40 | sortable: true 41 | filterable: true 42 | searchable: true 43 | department: 44 | label: 部门 45 | type: lookup 46 | reference_to: organizations 47 | sortable: true 48 | filterable: true 49 | searchable: true 50 | budget_value: 51 | type: number 52 | label: 预算数 53 | scale: 2 54 | spended_value: 55 | type: number 56 | label: 已发生数 57 | scale: 2 58 | omit: true 59 | readonly: true 60 | surplus_value: 61 | type: number 62 | label: 可用预算数 63 | scale: 2 64 | omit: true 65 | readonly: true 66 | approving_value: 67 | type: number 68 | label: 审批中 69 | scale: 2 70 | omit: true 71 | readonly: true 72 | description: 73 | type: textarea 74 | label: 备注 75 | is_wide: true 76 | company_id: 77 | label: 所属单位 78 | required: true 79 | omit: false 80 | hidden: false 81 | sortable: true 82 | list_views: 83 | all: 84 | label: 所有预算 85 | columns: 86 | - field: name 87 | width: 200 88 | - year 89 | - department 90 | - expense_subject 91 | - budget_value 92 | - spended_value 93 | - surplus_value 94 | - approving_value 95 | relatedList: 96 | - cms_files 97 | - expense_lists 98 | 99 | permission_set: 100 | user: 101 | allowCreate: false 102 | allowDelete: false 103 | allowEdit: false 104 | allowRead: true 105 | viewCompanyRecords: true 106 | modifyCompanyRecords: false 107 | viewAllRecords: false 108 | modifyAllRecords: false 109 | admin: 110 | allowCreate: true 111 | allowDelete: true 112 | allowEdit: true 113 | allowRead: true 114 | viewCompanyRecords: true 115 | modifyCompanyRecords: true 116 | viewAllRecords: true 117 | modifyAllRecords: true 118 | -------------------------------------------------------------------------------- /src/expense/expense_lists.object.yml: -------------------------------------------------------------------------------- 1 | name: expense_lists 2 | label: 费用明细 3 | icon: poll 4 | enable_api: true 5 | enable_files: true 6 | enable_workflow: true 7 | fields: 8 | name: 9 | type: text 10 | label: 名称 11 | required: true 12 | searchable: true 13 | index: true 14 | expense_subject: 15 | label: 费用科目 16 | type: lookup 17 | reference_to: expense_subjects 18 | sortable: true 19 | filterable: true 20 | searchable: true 21 | spend_date: 22 | type: date 23 | label: 发生日期 24 | spend_department: 25 | label: 发生部门 26 | type: lookup 27 | reference_to: organizations 28 | sortable: true 29 | filterable: true 30 | searchable: true 31 | spend_user: 32 | label: 发生人员 33 | type: lookup 34 | reference_to: space_users 35 | sortable: true 36 | filterable: true 37 | searchable: true 38 | spend_value: 39 | type: number 40 | label: 发生数额 41 | scale: 2 42 | expense_budget: 43 | label: 费用预算 44 | type: lookup 45 | reference_to: expense_budgets 46 | sortable: true 47 | filterable: true 48 | searchable: true 49 | expense_form: 50 | label: 费用单据 51 | type: master_detail 52 | reference_to: expense_forms 53 | sortable: true 54 | filterable: true 55 | searchable: true 56 | approve_state: 57 | label: 审批状态 58 | scale: 2 59 | omit: true 60 | readonly: true 61 | type: select 62 | options: 63 | - label: 草稿 64 | value: draft 65 | - label: 进行中 66 | value: pending 67 | - label: 已完成 68 | value: completed 69 | - label: 已核准 70 | value: approved 71 | - label: 已驳回 72 | value: rejected 73 | - label: 已取消 74 | value: terminated 75 | company_id: 76 | label: 所属单位 77 | required: true 78 | omit: false 79 | hidden: false 80 | sortable: true 81 | description: 82 | type: textarea 83 | label: 备注 84 | is_wide: true 85 | list_views: 86 | all: 87 | label: 所有记录 88 | columns: 89 | - name 90 | - approve_state 91 | - spend_date 92 | - spend_department 93 | - spend_user 94 | - spend_value 95 | - field: expense_subject 96 | width: 140 97 | - field: expense_budget 98 | width: 200 99 | - field: expense_form 100 | width: 150 101 | 102 | permission_set: 103 | user: 104 | allowCreate: false 105 | allowDelete: false 106 | allowEdit: false 107 | allowRead: true 108 | viewCompanyRecords: false 109 | modifyCompanyRecords: false 110 | viewAllRecords: false 111 | modifyAllRecords: false 112 | admin: 113 | allowCreate: true 114 | allowDelete: true 115 | allowEdit: true 116 | allowRead: true 117 | viewCompanyRecords: true 118 | modifyCompanyRecords: true 119 | viewAllRecords: true 120 | modifyAllRecords: true 121 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright 2001-present Steedos, Inc. 2 | 3 | Apache License 4 | Version 2.0, January 2004 5 | http://www.apache.org/licenses/ 6 | 7 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 8 | 9 | 1. Definitions. 10 | 11 | "License" shall mean the terms and conditions for use, reproduction, 12 | and distribution as defined by Sections 1 through 9 of this document. 13 | 14 | "Licensor" shall mean the copyright owner or entity authorized by 15 | the copyright owner that is granting the License. 16 | 17 | "Legal Entity" shall mean the union of the acting entity and all 18 | other entities that control, are controlled by, or are under common 19 | control with that entity. For the purposes of this definition, 20 | "control" means (i) the power, direct or indirect, to cause the 21 | direction or management of such entity, whether by contract or 22 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 23 | outstanding shares, or (iii) beneficial ownership of such entity. 24 | 25 | "You" (or "Your") shall mean an individual or Legal Entity 26 | exercising permissions granted by this License. 27 | 28 | "Source" form shall mean the preferred form for making modifications, 29 | including but not limited to software source code, documentation 30 | source, and configuration files. 31 | 32 | "Object" form shall mean any form resulting from mechanical 33 | transformation or translation of a Source form, including but 34 | not limited to compiled object code, generated documentation, 35 | and conversions to other media types. 36 | 37 | "Work" shall mean the work of authorship, whether in Source or 38 | Object form, made available under the License, as indicated by a 39 | copyright notice that is included in or attached to the work 40 | (an example is provided in the Appendix below). 41 | 42 | "Derivative Works" shall mean any work, whether in Source or Object 43 | form, that is based on (or derived from) the Work and for which the 44 | editorial revisions, annotations, elaborations, or other modifications 45 | represent, as a whole, an original work of authorship. For the purposes 46 | of this License, Derivative Works shall not include works that remain 47 | separable from, or merely link (or bind by name) to the interfaces of, 48 | the Work and Derivative Works thereof. 49 | 50 | "Contribution" shall mean any work of authorship, including 51 | the original version of the Work and any modifications or additions 52 | to that Work or Derivative Works thereof, that is intentionally 53 | submitted to Licensor for inclusion in the Work by the copyright owner 54 | or by an individual or Legal Entity authorized to submit on behalf of 55 | the copyright owner. For the purposes of this definition, "submitted" 56 | means any form of electronic, verbal, or written communication sent 57 | to the Licensor or its representatives, including but not limited to 58 | communication on electronic mailing lists, source code control systems, 59 | and issue tracking systems that are managed by, or on behalf of, the 60 | Licensor for the purpose of discussing and improving the Work, but 61 | excluding communication that is conspicuously marked or otherwise 62 | designated in writing by the copyright owner as "Not a Contribution." 63 | 64 | "Contributor" shall mean Licensor and any individual or Legal Entity 65 | on behalf of whom a Contribution has been received by Licensor and 66 | subsequently incorporated within the Work. 67 | 68 | 2. Grant of Copyright License. Subject to the terms and conditions of 69 | this License, each Contributor hereby grants to You a perpetual, 70 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 71 | copyright license to reproduce, prepare Derivative Works of, 72 | publicly display, publicly perform, sublicense, and distribute the 73 | Work and such Derivative Works in Source or Object form. 74 | 75 | 3. Grant of Patent License. Subject to the terms and conditions of 76 | this License, each Contributor hereby grants to You a perpetual, 77 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 78 | (except as stated in this section) patent license to make, have made, 79 | use, offer to sell, sell, import, and otherwise transfer the Work, 80 | where such license applies only to those patent claims licensable 81 | by such Contributor that are necessarily infringed by their 82 | Contribution(s) alone or by combination of their Contribution(s) 83 | with the Work to which such Contribution(s) was submitted. If You 84 | institute patent litigation against any entity (including a 85 | cross-claim or counterclaim in a lawsuit) alleging that the Work 86 | or a Contribution incorporated within the Work constitutes direct 87 | or contributory patent infringement, then any patent licenses 88 | granted to You under this License for that Work shall terminate 89 | as of the date such litigation is filed. 90 | 91 | 4. Redistribution. You may reproduce and distribute copies of the 92 | Work or Derivative Works thereof in any medium, with or without 93 | modifications, and in Source or Object form, provided that You 94 | meet the following conditions: 95 | 96 | (a) You must give any other recipients of the Work or 97 | Derivative Works a copy of this License; and 98 | 99 | (b) You must cause any modified files to carry prominent notices 100 | stating that You changed the files; and 101 | 102 | (c) You must retain, in the Source form of any Derivative Works 103 | that You distribute, all copyright, patent, trademark, and 104 | attribution notices from the Source form of the Work, 105 | excluding those notices that do not pertain to any part of 106 | the Derivative Works; and 107 | 108 | (d) If the Work includes a "NOTICE" text file as part of its 109 | distribution, then any Derivative Works that You distribute must 110 | include a readable copy of the attribution notices contained 111 | within such NOTICE file, excluding those notices that do not 112 | pertain to any part of the Derivative Works, in at least one 113 | of the following places: within a NOTICE text file distributed 114 | as part of the Derivative Works; within the Source form or 115 | documentation, if provided along with the Derivative Works; or, 116 | within a display generated by the Derivative Works, if and 117 | wherever such third-party notices normally appear. The contents 118 | of the NOTICE file are for informational purposes only and 119 | do not modify the License. You may add Your own attribution 120 | notices within Derivative Works that You distribute, alongside 121 | or as an addendum to the NOTICE text from the Work, provided 122 | that such additional attribution notices cannot be construed 123 | as modifying the License. 124 | 125 | You may add Your own copyright statement to Your modifications and 126 | may provide additional or different license terms and conditions 127 | for use, reproduction, or distribution of Your modifications, or 128 | for any such Derivative Works as a whole, provided Your use, 129 | reproduction, and distribution of the Work otherwise complies with 130 | the conditions stated in this License. 131 | 132 | 5. Submission of Contributions. Unless You explicitly state otherwise, 133 | any Contribution intentionally submitted for inclusion in the Work 134 | by You to the Licensor shall be under the terms and conditions of 135 | this License, without any additional terms or conditions. 136 | Notwithstanding the above, nothing herein shall supersede or modify 137 | the terms of any separate license agreement you may have executed 138 | with Licensor regarding such Contributions. 139 | 140 | 6. Trademarks. This License does not grant permission to use the trade 141 | names, trademarks, service marks, or product names of the Licensor, 142 | except as required for reasonable and customary use in describing the 143 | origin of the Work and reproducing the content of the NOTICE file. 144 | 145 | 7. Disclaimer of Warranty. Unless required by applicable law or 146 | agreed to in writing, Licensor provides the Work (and each 147 | Contributor provides its Contributions) on an "AS IS" BASIS, 148 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 149 | implied, including, without limitation, any warranties or conditions 150 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 151 | PARTICULAR PURPOSE. You are solely responsible for determining the 152 | appropriateness of using or redistributing the Work and assume any 153 | risks associated with Your exercise of permissions under this License. 154 | 155 | 8. Limitation of Liability. In no event and under no legal theory, 156 | whether in tort (including negligence), contract, or otherwise, 157 | unless required by applicable law (such as deliberate and grossly 158 | negligent acts) or agreed to in writing, shall any Contributor be 159 | liable to You for damages, including any direct, indirect, special, 160 | incidental, or consequential damages of any character arising as a 161 | result of this License or out of the use or inability to use the 162 | Work (including but not limited to damages for loss of goodwill, 163 | work stoppage, computer failure or malfunction, or any and all 164 | other commercial damages or losses), even if such Contributor 165 | has been advised of the possibility of such damages. 166 | 167 | 9. Accepting Warranty or Additional Liability. While redistributing 168 | the Work or Derivative Works thereof, You may choose to offer, 169 | and charge a fee for, acceptance of support, warranty, indemnity, 170 | or other liability obligations and/or rights consistent with this 171 | License. However, in accepting such obligations, You may act only 172 | on Your own behalf and on Your sole responsibility, not on behalf 173 | of any other Contributor, and only if You agree to indemnify, 174 | defend, and hold each Contributor harmless for any liability 175 | incurred by, or claims asserted against, such Contributor by reason 176 | of your accepting any such warranty or additional liability. 177 | 178 | END OF TERMS AND CONDITIONS 179 | 180 | APPENDIX: How to apply the Apache License to your work. 181 | 182 | To apply the Apache License to your work, attach the following 183 | boilerplate notice, with the fields enclosed by brackets "{}" 184 | replaced with your own identifying information. (Don't include 185 | the brackets!) The text should be enclosed in the appropriate 186 | comment syntax for the file format. We also recommend that a 187 | file or class name and description of purpose be included on the 188 | same "printed page" as the copyright notice for easier 189 | identification within third-party archives. 190 | 191 | Copyright {yyyy} {name of copyright owner} 192 | 193 | Licensed under the Apache License, Version 2.0 (the "License"); 194 | you may not use this file except in compliance with the License. 195 | You may obtain a copy of the License at 196 | 197 | http://www.apache.org/licenses/LICENSE-2.0 198 | 199 | Unless required by applicable law or agreed to in writing, software 200 | distributed under the License is distributed on an "AS IS" BASIS, 201 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 202 | See the License for the specific language governing permissions and 203 | limitations under the License. --------------------------------------------------------------------------------