{"id":17942733,"url":"https://github.com/b1f6c1c4/professionalaccounting","last_synced_at":"2025-03-24T14:32:48.809Z","repository":{"id":23876043,"uuid":"27254971","full_name":"b1f6c1c4/ProfessionalAccounting","owner":"b1f6c1c4","description":"Accounting software with debit and credit. 使用借贷记帐法的记账软件","archived":false,"fork":false,"pushed_at":"2024-04-13T08:46:55.000Z","size":24916,"stargazers_count":30,"open_issues_count":2,"forks_count":9,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-04-13T22:05:01.901Z","etag":null,"topics":["accounting","bookkeeping","csharp","double-entry-accounting","double-entry-bookkeeping","personal-accounting"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/b1f6c1c4.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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-11-28T06:43:24.000Z","updated_at":"2024-04-28T04:42:50.608Z","dependencies_parsed_at":"2024-04-13T09:38:46.119Z","dependency_job_id":"ba5dd5cc-dbcd-4772-9fb6-b2a8387aacfe","html_url":"https://github.com/b1f6c1c4/ProfessionalAccounting","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/b1f6c1c4%2FProfessionalAccounting","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b1f6c1c4%2FProfessionalAccounting/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b1f6c1c4%2FProfessionalAccounting/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b1f6c1c4%2FProfessionalAccounting/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/b1f6c1c4","download_url":"https://codeload.github.com/b1f6c1c4/ProfessionalAccounting/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245289799,"owners_count":20591134,"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":["accounting","bookkeeping","csharp","double-entry-accounting","double-entry-bookkeeping","personal-accounting"],"created_at":"2024-10-29T03:07:03.724Z","updated_at":"2025-03-24T14:32:48.393Z","avatar_url":"https://github.com/b1f6c1c4.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ProfessionalAccounting\n\n\u003e 使用借贷记帐法的记账软件 Accounting software with debit and credit\n\n[![Appveyor Build](https://img.shields.io/appveyor/build/b1f6c1c4/ProfessionalAccounting?style=flat-square)](https://ci.appveyor.com/project/b1f6c1c4/professionalaccounting)\n[![Appveyor Tests](https://img.shields.io/appveyor/tests/b1f6c1c4/ProfessionalAccounting?style=flat-square)](https://ci.appveyor.com/project/b1f6c1c4/professionalaccounting/build/tests)\n[![Coveralls](https://img.shields.io/coveralls/github/b1f6c1c4/ProfessionalAccounting?style=flat-square)](https://coveralls.io/github/b1f6c1c4/ProfessionalAccounting)\n\n## 简介 Introduction\n\n- [Double-entry bookkeeping](https://en.wikipedia.org/wiki/Double-entry_bookkeeping)\n- Client/Server architecture\n- DSL (Domain Specfic Langauge) for CRUD\n- Backend\n    - Monolithic architecture, business logic `C# 10.0`编写\n    - Uses MongoDB as the database\n    - Compiled on the `.NET 8.0` platform\n    - Uses nginx as a reverse proxy, supports TLSv1.3、HTTP/3\n    - Deployed using Docker\n- Frontend\n    - Uses Redux for state management\n    - Uses p5.js for UI rendering\n    - Uses webpack for bundling\n\n### 功能 Functionalities\n\n- Fast entry of common vouchers [常见记账凭证的快速录入](AccountingServer.Shell/Serializer/AbbrSerializer.cs)\n- Fast entry of split bill expenses [AA制消费的快速录入](AccountingServer.Shell/Serializer/DiscountSerializer.cs)\n- Multi-currency accounting, even within a single voucher [多币种记账](AccountingServer.Entities/Voucher.cs#L153-L157)（支持一张记账凭证多个币种共存）\n- Exchange rate inquiry / conversion [汇率查询与自动转换](AccountingServer.BLL/Util/Exchange.cs)（在分类汇总时可按本位币显示外币）\n- Multi-users, transferring money to each other [多用户互相转账](AccountingServer.Entities/Voucher.cs#L147-L151)（支持一张记账凭证多个用户共存）\n- Mutable accounting base currency [记账本位币变动](AccountingServer.Shell/Carry/BaseCurrencyShell.cs)（所有者权益币种变动）\n- Fixed asset management [固定资产管理](AccountingServer.Shell/AssetShell.cs)（购置登记、折旧、贬值与处置）\n- Automatic amortization [自动摊销](AccountingServer.Shell/AmortizationShell.cs)\n- Monthly / annually revenue carrying [期末结转](AccountingServer.Shell/Carry/CarryShell.cs)\n- JSON/CSV import / export [导入/导出](AccountingServer.Shell/Serializer)\n- Joint property and cash flow for spouses / partners [（妻妻）共同财产现金流分析](AccountingServer.Shell/Plugins/Coupling)\n- Cheque management [支票管理](AccountingServer.Shell/Plugins/Cheque)\n- Interest calulation of debt [利息收入与费用计算](AccountingServer.Shell/Plugins/Interest)\n- Investment return calculation [投资收益率计算](AccountingServer.Shell/Plugins/YieldRate)\n- Interest calculation of deposit [活期存款利息计算](AccountingServer.Shell/Plugins/BankBalance)\n- Cash flow forecasting [现金流预估](AccountingServer.Shell/Plugins/CashFlow)\n- Entry of foreign currency transactions on credit cards [信用卡外币交易入账](AccountingServer.Shell/Plugins/CreditCardConvert)\n- Credit card statement reconciliation [信用卡对账](AccountingServer.Shell/Plugins/Statement)\n- Spreadsheet reconciliation \u0026 statistics [表格对账统计](AccountingServer.Shell/Plugins/SpreadSheet)\n\n## 安装与配置\n\n本项目提供两种部署方式：\n1. 本地/内网调试（无TLS，无客户端认证，无可靠数据存储）\n1. 网络部署（TLS，客户端证书，MongoDB Atlas数据库后端）\n\n### 准备\n\n首先准备一台Linux服务器，安装以下软件：\n- docker，推荐采用[get.docker.com](https://get.docker.com/)\n- （仅限网络部署）openssl（请自行检索安装方法）\n\n### 配置记账系统功能\n\n为了方便地从GitHub下载单独文件（而不用下载整个repo的整个历史），\n此处推荐大家使用[git-get](https://github.com/b1f6c1c4/git-get)来下载。\n\n1. ssh登录*服务器*\n1. 下载`docker-compose.yml`文件（网络部署）或者`docker-compose.local.yml`（本地部署）：\n    ```bash\n    git get b1f6c1c4/ProfessionalAccounting -- docker-compose.yml\n    git get b1f6c1c4/ProfessionalAccounting -- docker-compose.local.yml\n    ```\n1. 下载示例配置文件夹，放在`/data/accounting/config.d/`（网络部署）：\n    ```bash\n    mkdir -p /data/accounting\n    git get -o /data/accounting/config.d b1f6c1c4/ProfessionalAccounting -- example/config.d/\n    ```\n1. 修改必须修改的配置文件：\n    - `BaseCurrency.xml` - 记账本位币\n    - `Symbol.xml` - 货币符号表\n    - `Titles.xml` - 记账科目列表\n    - `Carry.xml` - 期末结转规则\n    - `Exchange.xml` - 汇率查询API（[fixer.io](https://fixer.io)、[CoinMarketCap](https://coinmartketcap.com)）的配置\n1. 修改可选的配置文件：\n    - `Abbr.xml` - 登记新记账凭证时使用的缩写列表\n    - `Cash.xml` - 现金流插件相关配置\n    - `Composite.xml` - 常用检索式列表\n    - `Util.xml` - 快速登记记账凭证插件的配置\n    - `SpreadSheet.xml` - 表格形式对账插件的配置\n\n### 配置服务器和客户端x509证书（仅限网络部署）\n\n1. 将服务器证书和私钥（`server.crt`，`server.key`）放在服务器的`/data/accounting/certs`目录下\n    1. 如果你没有服务器证书，推荐使用 [acme.sh](https://github.com/acmesh-official/acme.sh/wiki/%E8%AF%B4%E6%98%8E) 来免费获得一个\n1. 在服务器上创建dhparams：\n    ```bash\n    openssl dhparam -out /data/accounting/certs/dhparam.pem 2048\n    ```\n1. 创建自签名的客户端证书和私钥：\n   （注意：如果客户端机器未安装`openssl`，则在服务器上创建客户端的证书和私钥，并把加密后的私钥`client.p12`传回客户端）\n    1. **在客户端机器上**创建证书和私钥：\n    ```bash\n    openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.crt -days 1825 -nodes\n    chmod 0400 key.pem\n    ```\n    1. 将证书上传服务器：\n    ```bash\n    scp ./cert.crt \u003cserver\u003e:/data/accounting/certs/client.crt\n    ```\n    1. 将证书和私钥封装成`.p12`格式，删除原来的`.pem`文件：\n    （这一步的目的是方便在客户端上安装证书）\n    ```bash\n    openssl pkcs12 -export -inkey key.pem -in cert.crt -out client.p12 \u0026\u0026 rm -f key.pem\n    ```\n1. 在客户端上安装证书：\n    1. 恕不赘述，请自行Google `install p12 certificate on XXX`（`XXX`=Linux/FreeBSD/Windows/MacOS/iOS/iPadOS/...）\n\n### 启动、停止\n\n直接使用docker-compose启动，将在18080端口侦听请求：\n\n- 本地部署：\n    ```bash\n    docker compose -f docker-compose.local.yml up -d   # start\n    docker compose down     # stop\n    ```\n- 网络部署：\n    ```bash\n    docker compose up -d    # start\n    docker compose down     # stop\n    ```\n\n## 基本使用方法\n\n### 记账（记账凭证的增加、修改与删除）\n\n![记账过程](example/create.gif)\n\n1. 在客户端上使用浏览器访问服务器的18080端口：`http://\u003cserver\u003e:18080/`（本地）或`https://\u003cserver\u003e:18080/`（网络）\n1. 可以看到用户界面分为两部分：上面的一行命令框和下面的编辑器\n1. 在命令框中，输入命令：`login \u003cusername\u003e`并按回车\n    - `\u003cusername\u003e`是你在记账系统中的用户名\n    - 无需注册，没有密码，用户名只是个代号而已\n    - 用户名会在前端存储在localstorage中，无需每次`login`\n1. 按tab可以在命令框和编辑器之间切换\n1. 执行空白命令会在编辑器中添加一个空的记账凭证模板（`@new Voucher { }@`）\n1. 在模板中需要填写记账凭证的内容，也就是**谁**、**用什么货币**、**关于什么**、交易了**多少钱**\n    - 例子：`T1001 -5`\n        - 字面意思是：我（刚刚`login`的用户名）、用本位币（参考`BaseCurrency.xml`）、关于库存现金（参考`Titles.xml`）、交易了-5元\n        - 翻译过来就是：现金少了5元人民币（假设你没有修改`BaseCurrency.xml`）\n    - 例子：`sp 5`\n        - 字面意思是：我、用本位币、关于食品（参考`Abbr.xml`）、交易了5元\n        - 翻译过来就是：食品开销增加了5元人民币\n    - 两个例子合在一起，就表明了“今天我用5元人民币现金购买了5元的食品”\n1. 按Alt+Enter保存记账凭证，可以看到增加了不少信息：\n    - `^5edc...^` 这是mongoDB的`_id`，用于唯一标识记账凭证\n    - `20200606` 这是交易发生的日期，在保存记账凭证的时刻被记录下来了\n    - `// 库存现金` 这是注释，以免使用者忘记记账科目\n    - `T1001 -5` 与保存之前的写法和语义完全相同\n    - `T660206 '食品' 5` 这是从`sp 5`翻译过来的完整写法\n        - 在`Abbr.xml`里面已经规定了`sp`就是`T660206 '食品'`的简称，所以在保存记账凭证时变回原样也不足为奇\n1. 按Alt+Delete可以删除已经保存的记账凭证\n    - 如果记账凭证尚且没有保存，那么它也就无所谓删除，一旦刷新页面就会丢掉\n1. 对于已经保存了的记账凭证，再次按Alt+Enter可以修改它的内容\n\n*注意：记账凭证不能嵌套，如果不小心在一个记账凭证模板里面又嵌套了一个模板，请立即按Ctrl+Z撤销。*\n\n### 检索\n\n![检索过程](example/query.gif)\n\n在命令框中执行检索命令可以列出相应的记账凭证：\n\n*注意：执行命令会覆盖下方编辑器中的全部内容；如果你希望在编辑器中添加而非覆盖，请在命令框中按Shift+Enter。*\n\n- `.` - **我**、**今天**都发生了什么交易\n- `..` - **我**、**昨天**都发生了什么交易\n- `T1001 .` - **我**、**今天**都发生了什么**现金**交易\n- `T660206 食品 0` - **我**、**这个月**都发生了什么**食品**交易\n    - 注意这里不能使用`sp`缩写\n- `unsafe 2020` - **我**、**在2020年**都发生了什么交易\n    - 由于可能返回非常多的结果，这里需要加上关键词`unsafe`\n- 关于记账凭证检索式（DSL）的具体语法，可以在命令框中输入`?`命令调出帮助文档\n\n### 汇总\n\n![汇总过程](example/subtotal.gif)\n\n在命令框中执行分类汇总命令可以对帐务数据进行统计：\n\n- `` ` `` - 我的基本财务报表\n- `` 0 ` `` - 我这个月的资金变动情况\n- `` ~-1 ` `` - 我上个月的基本财务报表\n- 关于分类汇总检索式（DSL）的具体语法，可以在命令框中输入`?`命令调出帮助文档\n\n## 开发\n\n### 项目文件结构\n\n- `nginx` - 前端\n- `AccountingServer` - HTTP Server\n- `AccountingServer.Shell` - 记账凭证的序列化/反序列化，分类汇总的显示\n- `AccountingServer.BLL` - 汇率转换，分类汇总，固定资产处理，摊销处理\n- `AccountingServer.DAL` - mongoDB数据库访问\n- `AccountingServer.Entities` - 基本对象结构定义\n- `AccountingServer.QueryGeneration` - 基于Antlr4的DSL Parser\n- `AccountingServer.Test` - 单元测试和集成测试\n\n### 本地后端开发环境\n\n#### 在Linux上构建开发环境\n\n1. 请先安装以下工具：\n    - [.NET 8.0](https://dotnet.microsoft.com/download/dotnet/8.0)\n    - [JetBrains Rider](https://www.jetbrains.com/rider/)\n    - [Docker](https://www.docker.com/)\n1. 启动测试数据库：\n\n    ```bash\n    docker run -d --rm --name mongo -p 27017:27017 mongo\n    ```\n\n1. 启动Rider即可。\n\n#### 在Windows上构建开发环境\n\n1. 请先安装以下工具：\n    - [.NET 8.0](https://dotnet.microsoft.com/download/dotnet/8.0)\n    - [Visual Studio](https://visualstudio.microsoft.com/)\n    - [Mongo DB](https://www.mongodb.com/)\n1. 启动测试数据库：在`services.msc`中启动`MongoDB`服务。\n1. 启动Visual Studio即可。\n\n### 本地前端开发环境\n\n1. 请先安装以下工具：\n    - [nodejs](https://nodejs.org/)\n1. 下载所需npm包：\n\n    ```bash\n    cd nginx \u0026\u0026 npm install\n    ```\n\n1. 启动webpack开发环境：\n\n    ```bash\n    npm run serve\n    ```\n\n## 许可\n\n本项目以GNU AGPL v3.0协议开源。\nThis project is licensed under **GNU AGPL v3.0** only. (AGPL-3.0-only).\n\n注解：（请参阅协议原文，以下解释没有法律效力）\n\n- 若个人开发者采用客户端证书的方式将端口保护起来，阻止自己以外的其他任何人访问，\n  这种行为不算“making available to the public”，也不构成协议中的\n  “propagate/convey/remote network interaction”，\n  因此将**不受GNU AGPL v3.0协议的限制**。\n- 但是若个人开发者不采用任何方式保护端口，其他人将有可能通过网络与该软件交互\n  （“remote network interaction”），这种行为就算作“convey”了。\n  这种情况下该行为**受到GNU AGPL v3.0协议的限制**，必须提供与后端程序的**版本一致**、**完整的**源代码。\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fb1f6c1c4%2Fprofessionalaccounting","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fb1f6c1c4%2Fprofessionalaccounting","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fb1f6c1c4%2Fprofessionalaccounting/lists"}