コード例 #1
0
 public function transferNewPeriod()
 {
     $_curPeriod = Yii::app()->settings->get("System", "cCurrentPeriod");
     $_nextPeriod = sParameter::cBeginDateAfter(Yii::app()->settings->get("System", "cCurrentPeriod"));
     $models = tBalanceSheet::model()->findAll('yearmonth_periode = ' . $_curPeriod);
     foreach ($models as $model) {
         if ($model->account->getTypeValue() == 1) {
             $sql = 'INSERT INTO t_balance_sheet (parent_id, yearmonth_periode, type_balance_id, remark, budget, beginning_balance,debit,credit,end_balance) VALUES (' . $model->parent_id . ',' . $_nextPeriod . ', 1, "Automated posted", 0,' . $model->end_balance . ',0,0,' . $model->end_balance . ')';
         } else {
             $sql = 'INSERT INTO t_balance_sheet (parent_id, yearmonth_periode, type_balance_id, remark, budget, beginning_balance,debit,credit,end_balance) VALUES (' . $model->parent_id . ',' . $_nextPeriod . ', 1, "Automated posted", 0,0,0,0,0)';
         }
         $command = Yii::app()->db->createCommand($sql);
         $command->execute();
         tBalanceSheet::model()->updateAll(array('type_balance_id' => 2), 'yearmonth_periode = ' . $_curPeriod);
     }
 }
コード例 #2
0
 public function newAccount($id)
 {
     $model = new tAccount('newaccount');
     // $this->performAjaxValidation($model);
     if (isset($_POST['tAccount'])) {
         $model->attributes = $_POST['tAccount'];
         $model->parent_id = $id;
         if ($model->save()) {
             //haschild
             $modelProperties2Add = new tAccountProperties();
             $modelProperties2Add->parent_id = $model->id;
             $modelProperties2Add->mkey = "haschild_id";
             $modelProperties2Add->mvalue = $_POST['tAccount']['haschild_id'];
             $modelProperties2Add->save();
             //currency
             //$modelProperties3Add = new tAccountProperties();
             //$modelProperties3Add->parent_id=$model->id;
             //$modelProperties3Add->mkey="currency_id";
             //$modelProperties3Add->mvalue=$_POST['tAccount']['currency_id'];
             //$modelProperties3Add->save();
             //state
             //$modelProperties4Add = new tAccountProperties();
             //$modelProperties4Add->parent_id=$model->id;
             //$modelProperties4Add->mkey="state_id";
             //$modelProperties4Add->mvalue=$_POST['tAccount']['state_id'];
             //$modelProperties4Add->save();
             //Balance
             $modelProperties5Add = new tBalanceSheet();
             $modelProperties5Add->parent_id = $model->id;
             $modelProperties5Add->yearmonth_periode = Yii::app()->settings->get("System", "cCurrentPeriod");
             $modelProperties5Add->type_balance_id = 1;
             $modelProperties5Add->debit = 0;
             $modelProperties5Add->credit = 0;
             $modelProperties5Add->beginning_balance = $_POST['tAccount']['beginning_balance'];
             $modelProperties5Add->end_balance = $_POST['tAccount']['beginning_balance'];
             $modelProperties5Add->save();
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     return $model;
 }
コード例 #3
0
 public function actionClosingPeriodExecution()
 {
     uJournal::model()->updateAll(array('state_id' => 3, 'updated_date' => time(), 'updated_by' => Yii::app()->user->id), 'state_id !=4 AND yearmonth_periode = ' . Yii::app()->settings->get("System", "cCurrentPeriod"));
     $_curPeriod = Yii::app()->settings->get("System", "cCurrentPeriod");
     $_nextPeriod = sParameter::cBeginDateAfter(Yii::app()->settings->get("System", "cCurrentPeriod"));
     $models = tBalanceSheet::model()->findAll('yearmonth_periode = ' . $_curPeriod);
     foreach ($models as $model) {
         if ($model->account->getTypeValue() == 1) {
             $sql = 'INSERT INTO t_balance_sheet (parent_id, yearmonth_periode, type_balance_id, remark, budget, beginning_balance,debit,credit,end_balance) VALUES (' . $model->parent_id . ',' . $_nextPeriod . ', 1, \'Automated posted\', 0,' . $model->end_balance . ',0,0,' . $model->end_balance . ')';
         } else {
             $sql = 'INSERT INTO t_balance_sheet (parent_id, yearmonth_periode, type_balance_id, remark, budget, beginning_balance,debit,credit,end_balance) VALUES (' . $model->parent_id . ',' . $_nextPeriod . ', 1, \'Automated posted\', 0,0,0,0,0)';
         }
         $command = Yii::app()->db->createCommand($sql);
         $command->execute();
         tBalanceSheet::model()->updateAll(array('type_balance_id' => 2), 'yearmonth_periode = ' . $_curPeriod);
     }
     $_nextPeriod = sParameter::cBeginDateAfter(Yii::app()->settings->get("System", "cCurrentPeriod"));
     Yii::app()->settings->set("System", "cCurrentPeriod", $_nextPeriod, $toDatabase = true);
     Yii::app()->user->setFlash('success', '<strong>Great!</strong> Closing Period has been successful...');
     $this->redirect(array('index'));
 }
コード例 #4
0
    public function actionUnposting($id)
    {
        $_curPeriod = Yii::app()->settings->get("System", "cCurrentPeriod");
        $_lastPeriod = sParameter::cBeginDateBefore(Yii::app()->settings->get("System", "cCurrentPeriod"));
        $locked = uJournal::model()->updateByPk((int) $id, array('state_id' => 2, 'updated_date' => time(), 'updated_id' => Yii::app()->user->id));
        $models = uJournalDetail::model()->with('journal')->findAll(array('condition' => 'parent_id =' . $id));
        foreach ($models as $model) {
            $modelBalanceCurrent = tBalanceSheet::model()->find(array('condition' => 'parent_id =' . $model->account_no_id . ' AND yearmonth_periode = ' . $_curPeriod));
            $_debit = $model->debit;
            $_credit = $model->credit;
            $_curdebit = $modelBalanceCurrent->debit - $_debit;
            $_curcredit = $modelBalanceCurrent->credit - $_credit;
            $_curbalance = $modelBalanceCurrent->end_balance;
            if ($model->account->getSideValue() == 1 || isset($model->account->reverse)) {
                //Asset, Expense
                $_endbalance = $_curbalance - $_debit + $_credit;
            } else {
                //Pasiva, Income
                $_endbalance = $_curbalance - $_credit + $_debit;
            }
            $command = Yii::app()->db->createCommand('
					UPDATE  t_balance_sheet SET
					debit = ' . $_curdebit . ',
					credit = ' . $_curcredit . ',
					end_balance = ' . $_endbalance . '
					WHERE yearmonth_periode = ' . $_curPeriod . ' AND parent_id = ' . $model->account_no_id);
            $command->execute();
        }
    }
コード例 #5
0
<?php

$this->beginWidget('zii.widgets.jui.CJuiDialog', array('id' => 'mydialog', 'options' => array('title' => 'Posting', 'autoOpen' => false, 'modal' => true)));
echo 'Posting Complete...';
$this->endWidget('zii.widgets.jui.CJuiDialog');
?>

<h2>Balance Sheet</h2>
<?php 
$this->widget('bootstrap.widgets.BootGridView', array('id' => 't-account-balance-sum-grid', 'dataProvider' => tBalanceSheet::model()->search($model->id), 'template' => '{items}{pager}', 'itemsCssClass' => 'table table-striped table-bordered', 'columns' => array(array('name' => 'type_balance_id', 'value' => 'sParameter::item("cBalanceType",$data->type_balance_id)'), 'yearmonth_periode', array('name' => 'beginning_balance', 'value' => 'Yii::app()->indoFormat->number($data->beginning_balance)', 'htmlOptions' => array('style' => 'text-align: right; padding-right: 5px;')), array('name' => 'debit', 'value' => 'Yii::app()->indoFormat->number($data->debit)', 'htmlOptions' => array('style' => 'text-align: right; padding-right: 5px;')), array('name' => 'credit', 'value' => 'Yii::app()->indoFormat->number($data->credit)', 'htmlOptions' => array('style' => 'text-align: right; padding-right: 5px;')), array('name' => 'end_balance', 'value' => 'Yii::app()->indoFormat->number($data->end_balance)', 'htmlOptions' => array('style' => 'text-align: right; padding-right: 5px;')))));
?>

<br>

<h2>
	Current Period Journal List:
	<?php 
echo Yii::app()->settings->get("System", "cCurrentPeriod");
?>
</h2>

<?php 
$this->widget('bootstrap.widgets.BootGridView', array('id' => 't-account-balance-grid', 'dataProvider' => uJournalDetail::model()->searchByAccount($model->id), 'template' => '{items}{pager}{summary}', 'itemsCssClass' => 'table table-striped table-bordered', 'columns' => array(array('class' => 'BootButtonColumn', 'template' => '{post}', 'buttons' => array('post' => array('label' => '<i class="icon-ok-sign"></i> Post', 'url' => '
										Yii::app()->createUrl("/m2/tPosting/posting",
										array("id"=>$data->journal->id))
										', 'visible' => '$data->journal->state_id ==1 || $data->journal->state_id ==2', 'click' => '
										function(){
										$.ajax({
										type : "get",
										url  : $(this).attr("href"),
										data: "",
コード例 #6
0
    public function actionUnposting($id)
    {
        $_curPeriod = Yii::app()->settings->get("System", "cCurrentPeriod");
        $_lastPeriod = sParameter::cBeginDateBefore(Yii::app()->settings->get("System", "cCurrentPeriod"));
        $locked = uJournal::model()->updateByPk((int) $id, array('state_id' => 2, 'updated_date' => time(), 'updated_by' => Yii::app()->user->id));
        $models = uJournalDetail::model()->with('journal')->findAll(array('condition' => 'parent_id = :id', 'params' => array(':id' => $id)));
        foreach ($models as $model) {
            $modelBalanceCurrent = tBalanceSheet::model()->find(array('condition' => 'parent_id = :accid AND yearmonth_periode = :period', 'params' => array(':accid' => $model->account_no_id, ':period' => $_curPeriod)));
            $_debit = $model->debit;
            $_credit = $model->credit;
            $_endbalance = 0;
            $_curdebit = $modelBalanceCurrent->debit - $_debit;
            $_curcredit = $modelBalanceCurrent->credit - $_credit;
            $_curbalance = $modelBalanceCurrent->end_balance;
            if ($model->account->getSideValue() == 1 || isset($model->account->reverse)) {
                //Asset, Expense
                $_endbalance = $_curbalance - $_debit + $_credit;
            } else {
                //Pasiva, Income
                $_endbalance = $_curbalance - $_credit + $_debit;
            }
            $command = Yii::app()->db->createCommand('
					UPDATE  t_balance_sheet SET
					debit = ' . $_curdebit . ',
					credit = ' . $_curcredit . ',
					end_balance = ' . $_endbalance . '
					WHERE yearmonth_periode = ' . $_curPeriod . ' AND parent_id = ' . $model->account_no_id);
            $command->execute();
            //LOG
            $commandLog = Yii::app()->db->createCommand('
					INSERT INTO t_balance_sheet_log (journal_id, yearmonth_periode, type_balance_id, remark, budget, account_no_id, beginning_balance,debit,credit,end_balance) VALUES (' . $model->parent_id . ',' . $_curPeriod . ', 1, \'UNPOSTING LOG\', 0,' . $model->account_no_id . ',' . $_curbalance . ',' . $_debit . ',' . $_credit . ',' . $_endbalance . ')
					');
            $commandLog->execute();
        }
    }