d3yii2 / yii2-d3acc
Yii2会计模块,账户和期间
0.4.0
2017-02-07 19:11 UTC
Requires
- php: >=5.4.0
- yiisoft/yii2: *
This package is auto-updated.
Last update: 2024-09-08 19:39:38 UTC
README
会计
此Yii2模块提供基于借记和贷记原则的余额会计(簿记)系统支持。提供额外的功能
- 期间(结算期间和期间余额)
- 动态创建与一个或多个表关联的账户
安装
安装此扩展的首选方法是通过 composer。
运行以下命令之一:
php composer.phar require --prefer-dist d3yii2/yii2-d3acc "*"
或
"d3yii2/yii2-d3acc": "*"
将以下内容添加到您的 composer.json
文件的 require 部分。
推送迁移
数据库结构
账户定义
创建对象 acc
use \d3acc\models\AcRecAcc; use Yii; /** * Description of acc * * @author Dealer */ class acc { const MONTH_PERIOD = 1; const PLAYER_ACC = 4; const EXPENSES = 10; const FOND_PLAYGROUND = 7; acc::CODE_CRD_PLAYGROUND = 'CreditPlaygound'; /** * get player account * @param int $personId * @return AcRecAcc */ public static function player($personId) { return AcRecAcc::getAcc(self::PLAYER_ACC, ['person' => $personId]); } /** * get expenses account * @return AcRecAcc */ public static function expenses() { return AcRecAcc::getAcc(self::EXPENSES); } /** * get for player playground account * @param int $personId * @param int $playgroundId * @return AcRecAcc */ public static function fondPlayground($personId, $playgroundId) { return AcRecAcc::getAcc(self::FOND_PLAYGROUND, ['person' => $personId, 'playground' => $playgroundId]); } }
事务登记
/** * player accounts */ $recAccPPG = acc::playerPlayground($person_id, $playground_id); $recAccPlayer = acc::player($person_id); $day = date('Y-m-d'); $tran = AcTran::registre($recAccPlayer, $recAccPPG, $personAmt, $day, acc::MONTH_PERIOD, acc::CODE_CRD_PLAYGROUND);
期间
use d3acc\models\AcPeriod; $acPeriod = AcPeriod::getActivePeriod(acc::MONTH_PERIOD)) //close period \d3acc\components\PeriodMonth::close(acc::MONTH_PERIOD);
事务
$recAccPlayer = acc::player($person_id); $data = AcTran::accPeriodTran($recAccPlayer, $acPeriod);
余额
$filter = ['playground' => $playgroundId] $playgroundAllPersonBalance = AcTran::accBalanceFilter(acc::FOND_PLAYGROUND, $acPeriod,$filter); $filter = ['person' => $personId] $personAllPlaygroundsBalance = AcTran::accBalanceFilter(acc::FOND_PLAYGROUND, $acPeriod,$filter); $allPlaygroundsAllPersonBalance = AcTran::accBalanceFilter(acc::FOND_PLAYGROUND, $acPeriod,[]);
通过创建 acc 类来定义账户计划
在表中添加定义记录
使用 AccConstructor 进行迁移
$constructor = new AccConstructor();
加载现有或创建新账户(ac_account 表)以进行会话
$constructor->load($accId); $constructor->create($code, $name);
为加载/创建的账户添加新账户维度(ac_def 表)
$definition = $constructor->addDimension($table, $pkField);
为加载/创建的账户添加新扩展账户(ac_rec_acc 表)
$extAccount = $constructor->addExtendedAccount();
添加新维度值(ac_rec_ref 表)并重新计算给定扩展账户(ac_rec_acc 表)的标签
$constructor->addDimensionRecAcc($extAccount->id, $definition->id, $pk_value);