php-finance/double-entry
Composer 安装命令:
composer require php-finance/double-entry
包简介
Double entry accounting
README 文档
README
Double entry is an awesome proven approach to financial and analytical accounting. It allows doing accounting of any complexity.
The library features are:
- Generic double entry accounting implementation.
- Multiple data storage backends available as separate packages.
- Transactional.
- Supports sub-accounts and dimensions.
- Avoids precision problems.
- Documentation and examples.
Glossary
A short glossary is necessary for understanding what's going on.
- Asset is something of value the company owns.
- Liability is something that company owes to another company, bank or person.
- Debit is an accounting entry that results in either increase of assets or decrease in liabilities.
- Credit is an accounting entry that results in either decrease of assets or increase in liabilities.
- Entry is a debit or a credit entry for a certain account.
- Posting is a balanced pair of debit and credit entries that reflects moving of assets or liabilities between accounts.
- Transaction is a financial operation that includes one or several postings.
- Account is group of entries connected to a certain asset or liability.
- Subaccount is used to further specify the purpose of the entries within the account.
- Dimension is used to tag entries regardless of the account.
- Total debit is a sum of all debit of the account.
- Total credit is a sum of all credit of the account.
- Balance is an account remainder.
- Chart of accounts (COA) is a system of accounts, subaccounts, and dimensions, that allows accounting with the ability to calculate metrics needed.
Example
Let's assume we want to do accounting for an ice cream company. It has three trucks, each truck has a driver who's the cashier at the same time. Also they have two storages with one worker in each. Company took out a loan to buy the trucks. Ice-cream is bought from two factories.
The founder wants an accounting to answer the following questions:
- What's the sales revenue? What's the sales revenue for each truck?
- What's the net profit margin?
- What's the equity of the company?
- What are expenses? How much was spent on salaries, buying ice-cream, trucks and gasoline, storages? How much was paid to each worker / storage / truck / factory?
In terms of accounting that means the following answers:
-
Q: How much funds does the company have?
-
A: Balance of subaccounts of "Company funds"
-
Q: How much we spend?
-
A: Total credit of subaccounts of "Company funds"
-
Q: How much is spent on buying ice cream?
-
A: Total debit of account "Purchases"
-
Q: How much is paid to each factory?
-
A: Total debit of account "Purchases" grouped by dimension "Counterparty"
-
Q: How much is spent on salaries?
-
A: Total debit of account "Expenses → Salary"
-
Q: How much is spent on salaries of each employee?
-
A: Total debit of account "Expenses → Salary" grouped by dimension "Employee"
-
Q: How much is spent on truck fuel?
-
A: Total debit of account "Expenses → Fuel"
-
Q: How much is spent on truck fuel for each truck?
-
A: Total debit of account "Expenses → Fuel" grouped by dimension "Truck"
-
A: What are total sales revenue?
-
Q: Total credit of account "Revenue"
-
Q: What are total sales revenue for each truck?
-
A: Total debit of "Company funds → Truck" grouped by dimension "Income type"
And that would be the following chart of accounts:
// TODO: add it as a table
Let's add it:
// TODO: add it
php-finance/double-entry 适用场景与选型建议
php-finance/double-entry 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 13 次下载、GitHub Stars 达 22, 最近一次更新时间为 2023 年 07 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 php-finance/double-entry 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 php-finance/double-entry 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 13
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 22
- 点击次数: 13
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: AGPL-3.0-only
- 更新时间: 2023-07-25