Exemplo n.º 1
0
 public function actionIndex()
 {
     $searchModel = new FinTimeDepositTran();
     $phpFmShortDate = DateTimeUtils::getPhpDateFormat();
     $arrTimedepositTrantype = MasterValueUtils::getArrData('fin_timedeposit_trantype');
     $arrSavingAccount = ModelUtils::getArrData(FinAccount::find()->select(['account_id', 'account_name'])->where(['delete_flag' => 0, 'account_type' => 4])->orderBy('account_type, order_num'), 'account_id', 'account_name');
     $arrCurrentAssets = ModelUtils::getArrData(FinAccount::find()->select(['account_id', 'account_name'])->where(['delete_flag' => 0, 'account_type' => [1, 2]])->orderBy('account_type, order_num'), 'account_id', 'account_name');
     // submit data
     $postData = Yii::$app->request->post();
     // populate model attributes with user inputs
     $searchModel->load($postData);
     // init value
     if (Yii::$app->request->getIsGet()) {
         $today = new \DateTime();
         $tdInfo = getdate($today->getTimestamp());
         $searchModel->opening_date_to = $today->format($phpFmShortDate);
         $searchModel->opening_date_from = DateTimeUtils::parse($tdInfo[DateTimeUtils::FN_KEY_GETDATE_YEAR] - 1 . '0101', DateTimeUtils::FM_DEV_DATE, $phpFmShortDate);
     }
     FinTimeDepositTran::$_PHP_FM_SHORTDATE = $phpFmShortDate;
     $searchModel->scenario = MasterValueUtils::SCENARIO_LIST;
     // sum Interest & Principal Amount (Adding funds OR Partial withdrawal)
     $sumTimeDepositValue = false;
     // query for dataprovider
     $dataQuery = null;
     if ($searchModel->validate()) {
         $dataQuery = FinTimeDepositTran::find()->where(['=', 'delete_flag', MasterValueUtils::MV_FIN_FLG_DELETE_FALSE]);
         $sumTimeDepositQuery = (new Query())->select(['SUM(interest_add) AS interest_add, SUM(IF(add_flag = 1, entry_value, 0)) AS adding_value, SUM(IF(add_flag = 2, entry_value, 0)) AS withdrawal_value']);
         $sumTimeDepositQuery->from('fin_time_deposit_tran')->where(['=', 'delete_flag', MasterValueUtils::MV_FIN_FLG_DELETE_FALSE]);
         if (!empty($searchModel->opening_date_from)) {
             $dataQuery->andWhere(['>=', 'opening_date', $searchModel->opening_date_from]);
             $sumTimeDepositQuery->andWhere(['>=', 'opening_date', $searchModel->opening_date_from]);
         }
         if (!empty($searchModel->opening_date_to)) {
             $dataQuery->andWhere(['<=', 'opening_date', $searchModel->opening_date_to]);
             $sumTimeDepositQuery->andWhere(['<=', 'opening_date', $searchModel->opening_date_to]);
         }
         if ($searchModel->saving_account > 0) {
             $dataQuery->andWhere(['=', 'saving_account', $searchModel->saving_account]);
             $sumTimeDepositQuery->andWhere(['=', 'saving_account', $searchModel->saving_account]);
         }
         if ($searchModel->current_assets > 0) {
             $dataQuery->andWhere(['=', 'current_assets', $searchModel->current_assets]);
             $sumTimeDepositQuery->andWhere(['=', 'current_assets', $searchModel->current_assets]);
         }
         $dataQuery->orderBy('opening_date DESC, create_date DESC');
         $sumTimeDepositValue = $sumTimeDepositQuery->createCommand()->queryOne();
     } else {
         $dataQuery = FinTimeDepositTran::find()->where(['transactions_id' => -1]);
     }
     // render GUI
     $renderData = ['searchModel' => $searchModel, 'dataQuery' => $dataQuery, 'phpFmShortDate' => $phpFmShortDate, 'sumTimeDepositValue' => $sumTimeDepositValue, 'arrCurrentAssets' => $arrCurrentAssets, 'arrSavingAccount' => $arrSavingAccount, 'arrTimedepositTrantype' => $arrTimedepositTrantype];
     return $this->render('index', $renderData);
 }
Exemplo n.º 2
0
 /**
  * update a Purchase
  * @param $purchase OefPurchase
  * @param $fmShortDatePhp
  * @throws Exception
  * @return string|true
  */
 private function updatePurchase($purchase, $fmShortDatePhp)
 {
     // modify data for DB
     $purchase->purchase_date = DateTimeUtils::parse($purchase->purchase_date, $fmShortDatePhp, DateTimeUtils::FM_DB_DATE);
     if (!empty($purchase->sip_date)) {
         $purchase->sip_date = DateTimeUtils::parse($purchase->sip_date, $fmShortDatePhp, DateTimeUtils::FM_DB_DATE);
     }
     $transaction = Yii::$app->db->beginTransaction();
     $save = true;
     $message = null;
     // begin transaction
     try {
         // save OefPurchase
         $save = $purchase->save();
         // FinAccountEntry
         $finPayment = FinAccountEntry::findOne($purchase->fin_entry_id);
         if ($save !== false && !is_null($finPayment)) {
             $finPayment->entry_date = $purchase->purchase_date;
             $finPayment->entry_value = $purchase->investment;
             $save = $finPayment->save();
             // save FinAccount (Debit)
             if ($save !== false) {
                 $debitFinAccount = FinAccount::findOne($finPayment->account_source);
                 $debitFinAccount->opening_balance = $debitFinAccount->opening_balance - $purchase->investment + $purchase->investment_old;
                 $save = $debitFinAccount->save();
             }
             // save FinAccount (Credit)
             if ($save !== false) {
                 $creditFinAccount = FinAccount::findOne($finPayment->account_target);
                 $creditFinAccount->opening_balance = $creditFinAccount->opening_balance + $purchase->investment - $purchase->investment_old;
                 $creditFinAccount->capital = $creditFinAccount->capital + $purchase->investment - $purchase->investment_old;
                 $save = $creditFinAccount->save();
             }
         }
         // save JarPayment
         $jarPayment = JarPayment::findOne($purchase->jar_payment_id);
         if ($save !== false && !is_null($jarPayment)) {
             $jarPayment->entry_date = $purchase->purchase_date;
             $jarPayment->entry_value = $purchase->investment;
             $save = $jarPayment->save();
             // save JarAccount (Debit)
             if ($save !== false) {
                 $debitJarAccount = JarAccount::findOne($jarPayment->account_source);
                 $debitJarAccount->useable_balance = $debitJarAccount->useable_balance - $purchase->investment + $purchase->investment_old;
                 $save = $debitJarAccount->save();
             }
             // save JarAccount (Credit)
             if ($save !== false) {
                 $creditJarAccount = JarAccount::findOne($jarPayment->account_target);
                 $creditJarAccount->useable_balance = $creditJarAccount->useable_balance + $purchase->investment - $purchase->investment_old;
                 $save = $creditJarAccount->save();
             }
         }
     } catch (Exception $e) {
         $save = false;
         $message = Yii::t('common', 'Unable to save {record}.', ['record' => Yii::t('oef.models', 'Purchase')]);
     }
     // end transaction
     try {
         if ($save === false) {
             $transaction->rollback();
             return $message;
         } else {
             $transaction->commit();
         }
     } catch (Exception $e) {
         throw Exception(Yii::t('common', 'Unable to excute Transaction.'));
     }
     return true;
 }
Exemplo n.º 3
0
            <th style="text-align: center" colspan="2"><?php 
echo Yii::t('fin.grid', 'Cost');
?>
</th>
        </tr>
        <?php 
foreach ($arrModel as $model) {
    ?>
            <?php 
    $rowClass = MasterValueUtils::getColorRow($rowindex);
    $rowindex++;
    $startDateStr = '';
    $diffDays = '';
    $diffFull = '';
    if (!is_null($model->start_date)) {
        $startDate = DateTimeUtils::parse($model->start_date, DateTimeUtils::FM_DB_DATETIME);
        $startDateStr = DateTimeUtils::htmlDateTimeFormatFromDB($model->start_date, DateTimeUtils::FM_VIEW_DATE, true);
        $interval = $currentDate->diff($startDate);
        $diffDays = $interval->days;
        $diffFull = $interval->format('%Y-%M-%D %H:%I:%S');
    }
    $costAll = '';
    $costDay = '';
    if (!is_null($model->costs)) {
        $costAll = NumberUtils::format($model->costs);
        if ($diffDays > 0) {
            $costDay = NumberUtils::format($model->costs / $diffDays, 2);
        }
    }
    ?>
            <tr class="<?php 
Exemplo n.º 4
0
 /**
  * update Payment
  * @param $payment JarPayment
  * @param $fmShortDatePhp
  * @throws Exception
  * @return string|true
  */
 private function updatePayment($payment, $fmShortDatePhp)
 {
     // modify data for DB
     $payment->entry_date = DateTimeUtils::parse($payment->entry_date, $fmShortDatePhp, DateTimeUtils::FM_DB_DATE);
     $transaction = Yii::$app->db->beginTransaction();
     $save = true;
     $message = null;
     // begin transaction
     try {
         $accountSource = JarAccount::findOne($payment->account_source);
         $accountTarget = JarAccount::findOne($payment->account_target);
         if ($payment->account_source == 0 || $payment->account_target == 0) {
             // save source
             if (!is_null($accountSource) && $save !== false) {
                 $accountSource->real_balance = $accountSource->real_balance - $payment->entry_adjust;
                 $accountSource->useable_balance = $accountSource->useable_balance - $payment->entry_adjust;
                 $save = $accountSource->save();
             }
             // save target
             if (!is_null($accountTarget) && $save !== false) {
                 $accountTarget->real_balance = $accountTarget->real_balance + $payment->entry_adjust;
                 $accountTarget->useable_balance = $accountTarget->useable_balance + $payment->entry_adjust;
                 $save = $accountTarget->save();
             }
         } else {
             // save source
             if ($save !== false) {
                 $accountSource->useable_balance = $accountSource->useable_balance - $payment->entry_adjust;
                 $save = $accountSource->save();
             }
             // save target
             if ($save !== false) {
                 $accountTarget->useable_balance = $accountTarget->useable_balance + $payment->entry_adjust;
                 $save = $accountTarget->save();
             }
         }
         // save payment
         if ($save !== false) {
             $payment->entry_value = $payment->entry_value + $payment->entry_adjust;
             $save = $payment->save();
         }
     } catch (Exception $e) {
         $save = false;
         $message = Yii::t('common', 'Unable to save {record}.', ['record' => Yii::t('jar.models', 'Payment')]);
     }
     // end transaction
     try {
         if ($save === false) {
             $transaction->rollback();
             return $message;
         } else {
             $transaction->commit();
         }
     } catch (Exception $e) {
         throw Exception(Yii::t('common', 'Unable to excute Transaction.'));
     }
     return true;
 }
Exemplo n.º 5
0
 /**
  * update a Bill
  * @param $model
  * @param $arrBillDetail
  * @param $fmShortDatePhp
  * @throws Exception
  * @return string|true
  */
 private function updateBill($model, $arrBillDetail, $fmShortDatePhp)
 {
     // modify data for DB
     $model->bill_date = DateTimeUtils::parse($model->bill_date, $fmShortDatePhp, DateTimeUtils::FM_DB_DATE);
     $model->member_num = count($model->arr_member_list);
     $model->member_list = serialize($model->arr_member_list);
     $pricePerMember = NumberUtils::rounds($model->total / $model->member_num, NumberUtils::NUM_CEIL);
     $pricePerMemberOld = NumberUtils::rounds($model->total_old / $model->member_num_old, NumberUtils::NUM_CEIL);
     foreach ($arrBillDetail as $billDetail) {
         if (!$billDetail->delete_flag) {
             $billDetail->pay_date = DateTimeUtils::parse($billDetail->pay_date, $fmShortDatePhp, DateTimeUtils::FM_DB_DATE);
         }
     }
     $transaction = Yii::$app->db->beginTransaction();
     $save = true;
     $message = null;
     // begin transaction
     try {
         // save Bill
         $save = $model->save(false);
         // save Bill Detail
         if ($save !== false) {
             // delete all Bill Detail
             NetBillDetail::deleteAll(['bill_id' => $model->id]);
             $itemNo = 1;
             foreach ($arrBillDetail as $billDetail) {
                 if (!$billDetail->delete_flag) {
                     $billDetail->setIsNewRecord(true);
                     $billDetail->bill_id = $model->id;
                     $billDetail->item_no = $itemNo;
                     $itemNo++;
                     $save = $billDetail->save(false);
                     if ($save === false) {
                         break;
                     }
                 }
             }
         }
         // save Customer & Payment
         if ($save !== false) {
             foreach ($model->arr_member_list_old as $oldCustomerId) {
                 // save old Customer
                 $oldCustomer = NetCustomer::findOne($oldCustomerId);
                 $oldCustomer->balance = $oldCustomer->balance + $pricePerMemberOld;
                 $save = $oldCustomer->save(false);
                 if ($save === false) {
                     break;
                 }
                 // save old Payment
                 $oldPayment = NetPayment::findOne(['customer_id' => $oldCustomerId, 'order_id' => $model->id]);
                 if (!is_null($oldPayment)) {
                     if ($oldPayment->credit > 0) {
                         $oldPayment->debit = 0;
                         $oldPayment->order_id = 0;
                         $save = $oldPayment->save(false);
                     } else {
                         $save = $oldPayment->delete();
                     }
                     if ($save === false) {
                         break;
                     }
                 }
             }
             if ($save !== false) {
                 foreach ($model->arr_member_list as $customerId) {
                     // save new Customer
                     $customer = NetCustomer::findOne($customerId);
                     $customer->balance = $customer->balance - $pricePerMember;
                     $save = $customer->save(false);
                     if ($save === false) {
                         break;
                     }
                     // save new Payment
                     $payment = NetPayment::findOne(['customer_id' => $customerId, 'entry_date' => $model->bill_date]);
                     if (is_null($payment)) {
                         $payment = new NetPayment();
                         $payment->customer_id = $customerId;
                         $payment->entry_date = $model->bill_date;
                     }
                     $payment->debit = $pricePerMember;
                     $payment->order_id = $model->id;
                     $payment->secret_key = EnDescrypt::encryptSha1($payment->customer_id . $payment->entry_date);
                     $save = $payment->save(false);
                     if ($save === false) {
                         break;
                     }
                 }
             }
         }
     } catch (Exception $e) {
         $save = false;
         $message = Yii::t('common', 'Unable to save {record}.', ['record' => Yii::t('fin.models', 'Bill')]);
     }
     // end transaction
     try {
         if ($save === false) {
             $transaction->rollback();
             return $message;
         } else {
             $transaction->commit();
         }
     } catch (Exception $e) {
         throw Exception(Yii::t('common', 'Unable to excute Transaction.'));
     }
     return true;
 }
Exemplo n.º 6
0
 /**
  * @param OefFundCertificate $condition
  * @param String $fmShortDatePhp
  * @return array
  */
 private function getFundCertificate4Sell($condition, $fmShortDatePhp)
 {
     $condition->sum_sell_certificate = 0;
     $condition->investment = 0;
     $condition->sellable_certificate = 0;
     $condition->revenue = 0;
     $condition->sell_fee = 0;
     $condition->profit_before_taxes = 0;
     $condition->income_tax = 0;
     $condition->profit_after_taxes = 0;
     $condition->investment_result = 0;
     $sqlLimit = 3;
     $sqlOffset = 0;
     $results = [];
     $condition->sell_date_obj = DateTimeUtils::parse($condition->sell_date, $fmShortDatePhp);
     $running = true;
     while ($running) {
         $arrOefPurchase = OefPurchase::find()->where(['delete_flag' => MasterValueUtils::MV_FIN_FLG_DELETE_FALSE])->andWhere('found_stock > found_stock_sold')->addOrderBy(['purchase_date' => SORT_ASC])->offset($sqlOffset)->limit($sqlLimit)->all();
         $running = count($arrOefPurchase) > 0;
         if ($running) {
             foreach ($arrOefPurchase as $oefPurchase) {
                 $result = null;
                 switch ($oefPurchase->purchase_type) {
                     case MasterValueUtils::MV_OEF_PERCHASE_TYPE_NORMAL:
                         $result = new OefFundCertificateNormal();
                         break;
                     case MasterValueUtils::MV_OEF_PERCHASE_TYPE_SIP:
                         $result = new OefFundCertificateSip();
                         break;
                     case MasterValueUtils::MV_OEF_PERCHASE_TYPE_DIVIDEND:
                         $result = new OefFundCertificateDividend();
                         break;
                     case MasterValueUtils::MV_OEF_PERCHASE_TYPE_IPO:
                         $result = new OefFundCertificateIpo();
                         break;
                 }
                 if (!is_null($result)) {
                     $result->initialize($oefPurchase, $condition);
                     $results[] = $result;
                     $condition->investment += $result->investment;
                     $condition->sellable_certificate += $result->sellable_certificate;
                     $condition->sum_sell_certificate += $result->sell_certificate;
                     $condition->revenue += $result->revenue;
                     $condition->sell_fee += $result->sell_fee;
                     $condition->profit_before_taxes += $result->profit_before_taxes;
                     $condition->income_tax += $result->income_tax;
                     $condition->profit_after_taxes += $result->profit_after_taxes;
                     $condition->investment_result += $result->investment_result;
                     $running = $condition->sum_sell_certificate < $condition->sell_certificate;
                     if (!$running) {
                         break;
                     }
                 }
             }
             $sqlOffset += $sqlLimit;
         }
     }
     return $results;
 }
Exemplo n.º 7
0
 public function actionCopy($id)
 {
     // master value
     $fmShortDatePhp = DateTimeUtils::getDateFormat(DateTimeUtils::FM_KEY_PHP, null);
     FinTotalInterestUnit::$_PHP_FM_SHORTDATE = $fmShortDatePhp;
     $this->objectId = $id;
     $model = FinTotalInterestUnit::findOne(['id' => $id]);
     $renderView = 'copy';
     if (is_null($model)) {
         $model = false;
         $renderData = ['model' => $model];
         Yii::$app->session->setFlash(MasterValueUtils::FLASH_ERROR, Yii::t('common', 'The requested {record} does not exist.', ['record' => Yii::t('fin.models', 'Interest Unit')]));
     } else {
         // master value
         $fmShortDateJui = DateTimeUtils::getDateFormat(DateTimeUtils::FM_KEY_JUI, null);
         // modify data for View
         if (empty($model->end_date)) {
             $model->start_date = DateTimeUtils::formatNow($fmShortDatePhp);
         } else {
             $startDate = DateTimeUtils::parse($model->end_date, DateTimeUtils::FM_DB_DATE);
             $model->start_date = DateTimeUtils::addDateTime($startDate, 'P1D', $fmShortDatePhp);
             $model->end_date = null;
             $model->interest_unit = null;
         }
         // submit data
         $postData = Yii::$app->request->post();
         $submitMode = isset($postData[MasterValueUtils::SM_MODE_NAME]) ? $postData[MasterValueUtils::SM_MODE_NAME] : false;
         // populate model attributes with user inputs
         $model->load($postData);
         // init value
         $model->scenario = MasterValueUtils::SCENARIO_COPY;
         $renderData = ['model' => $model, 'fmShortDatePhp' => $fmShortDatePhp, 'fmShortDateJui' => $fmShortDateJui];
         switch ($submitMode) {
             case MasterValueUtils::SM_MODE_INPUT:
                 $isValid = $model->validate();
                 if ($isValid) {
                     $renderView = 'confirm';
                     $renderData['formMode'] = [MasterValueUtils::PG_MODE_NAME => MasterValueUtils::PG_MODE_EDIT];
                 }
                 break;
             case MasterValueUtils::SM_MODE_CONFIRM:
                 $isValid = $model->validate();
                 if ($isValid) {
                     $result = $this->copyInterestUnit($model, $fmShortDatePhp);
                     if ($result === true) {
                         Yii::$app->session->setFlash(MasterValueUtils::FLASH_SUCCESS, Yii::t('common', '{record} has been saved successfully.', ['record' => Yii::t('fin.models', 'Interest Unit')]));
                         return Yii::$app->getResponse()->redirect(Url::to(['index']));
                     } else {
                         // modify data for View
                         $model->start_date = DateTimeUtils::parse($model->start_date, DateTimeUtils::FM_DB_DATE, $fmShortDatePhp);
                         if (!empty($model->end_date)) {
                             $model->end_date = DateTimeUtils::parse($model->end_date, DateTimeUtils::FM_DB_DATE, $fmShortDatePhp);
                         }
                         // render View
                         Yii::$app->session->setFlash(MasterValueUtils::FLASH_ERROR, $result);
                         $renderView = 'confirm';
                         $renderData['formMode'] = [MasterValueUtils::PG_MODE_NAME => MasterValueUtils::PG_MODE_EDIT];
                     }
                 }
                 break;
             case MasterValueUtils::SM_MODE_BACK:
                 break;
             default:
                 break;
         }
     }
     // render GUI
     return $this->render($renderView, $renderData);
 }
Exemplo n.º 8
0
 /**
  * save Nav
  * @param $nav OefNav
  * @param $fmShortDatePhp
  * @throws Exception
  * @return string|true
  */
 private function saveNav($nav, $fmShortDatePhp)
 {
     // modify data for DB
     $nav->trade_date = DateTimeUtils::parse($nav->trade_date, $fmShortDatePhp, DateTimeUtils::FM_DB_DATE);
     $nav->decide_date = DateTimeUtils::parse($nav->decide_date, $fmShortDatePhp, DateTimeUtils::FM_DB_DATE);
     $transaction = Yii::$app->db->beginTransaction();
     $save = true;
     $message = null;
     // begin transaction
     try {
         // save Nav
         $save = $nav->save();
     } catch (Exception $e) {
         $save = false;
         $message = Yii::t('common', 'Unable to save {record}.', ['record' => Yii::t('oef.models', 'Nav')]);
     }
     // end transaction
     try {
         if ($save === false) {
             $transaction->rollback();
             return $message;
         } else {
             $transaction->commit();
         }
     } catch (Exception $e) {
         throw Exception(Yii::t('common', 'Unable to excute Transaction.'));
     }
     return true;
 }
Exemplo n.º 9
0
 /**
  * update Distribute
  * @param $share JarShare
  * @param $arrShareDetail JarShareDetail
  * @param $fmShortDatePhp
  * @throws Exception
  * @return string|true
  */
 private function updateDistribute($share, $arrShareDetail, $fmShortDatePhp)
 {
     // modify data for DB
     $share->share_date = DateTimeUtils::parse($share->share_date, $fmShortDatePhp, DateTimeUtils::FM_DB_DATE);
     $transaction = Yii::$app->db->beginTransaction();
     $save = true;
     $message = null;
     // begin transaction
     try {
         // save JarShare
         $save = $share->save();
         if ($save !== false) {
             foreach ($arrShareDetail as $shareDetail) {
                 // save JarAccount
                 $account = JarAccount::findOne($shareDetail->account_id);
                 $account->real_balance = $account->real_balance - $shareDetail->share_value_old + $shareDetail->share_value;
                 $account->useable_balance = $account->useable_balance - $shareDetail->share_value_old + $shareDetail->share_value;
                 $save = $account->save();
                 if ($save === false) {
                     break;
                 }
                 // save JarPayment
                 $payment = JarPayment::findOne(['account_target' => $shareDetail->account_id, 'share_id' => $share->share_id]);
                 $payment->entry_date = $share->share_date;
                 $payment->entry_value = $shareDetail->share_value;
                 $payment->description = $share->description;
                 $save = $payment->save();
                 if ($save === false) {
                     break;
                 }
             }
         }
     } catch (Exception $e) {
         $save = false;
         $message = Yii::t('common', 'Unable to save {record}.', ['record' => Yii::t('jar.models', 'Distribute')]);
     }
     // end transaction
     try {
         if ($save === false) {
             $transaction->rollback();
             return $message;
         } else {
             $transaction->commit();
         }
     } catch (Exception $e) {
         throw Exception(Yii::t('common', 'Unable to excute Transaction.'));
     }
     return true;
 }
Exemplo n.º 10
0
 /**
  * update a Payment
  * @param $paymentModel
  * @param $fmDateTimePhp
  * @throws Exception
  * @return string|true
  */
 private function updatePayment($paymentModel, $fmDateTimePhp)
 {
     // modify data for DB
     $paymentModel->entry_date = DateTimeUtils::parse($paymentModel->entry_date, $fmDateTimePhp, DateTimeUtils::FM_DB_DATE);
     $transaction = Yii::$app->db->beginTransaction();
     $save = true;
     $message = null;
     // begin transaction
     try {
         // save Customer
         $customer = NetCustomer::findOne(['id' => $paymentModel->customer_id]);
         if ($save !== false && !is_null($customer)) {
             $customer->balance = $customer->balance + $paymentModel->credit - $paymentModel->credit_old;
             $save = $customer->save();
         }
         // save Payment
         if ($paymentModel->entry_date == $paymentModel->entry_date_old) {
             $paymentModel->secret_key = EnDescrypt::encryptSha1($paymentModel->customer_id . $paymentModel->entry_date);
             $save = $paymentModel->save(false);
         } else {
             if ($paymentModel->debit > 0) {
                 // save new Payment
                 $newSecretKey = EnDescrypt::encryptSha1($paymentModel->customer_id . $paymentModel->entry_date);
                 $newPaymentModel = new NetPayment();
                 $newPaymentModel->customer_id = $paymentModel->customer_id;
                 $newPaymentModel->entry_date = $paymentModel->entry_date;
                 $newPaymentModel->credit = $paymentModel->credit;
                 $newPaymentModel->debit = 0;
                 $newPaymentModel->order_id = 0;
                 $newPaymentModel->secret_key = $newSecretKey;
                 $save = $newPaymentModel->save(false);
                 // save old Payment
                 if ($save !== false) {
                     $paymentModel->entry_date = $paymentModel->entry_date_old;
                     $paymentModel->credit = 0;
                     $paymentModel->secret_key = EnDescrypt::encryptSha1($paymentModel->customer_id . $paymentModel->entry_date_old);
                     $save = $paymentModel->save(false);
                     $paymentModel->secret_key = $newSecretKey;
                 }
             } else {
                 $paymentModel->secret_key = EnDescrypt::encryptSha1($paymentModel->customer_id . $paymentModel->entry_date);
                 $save = $paymentModel->save(false);
             }
         }
     } catch (Exception $e) {
         $save = false;
         $message = Yii::t('common', 'Unable to save {record}.', ['record' => Yii::t('fin.models', 'Payment')]);
     }
     // end transaction
     try {
         if ($save === false) {
             $transaction->rollback();
             return $message;
         } else {
             $transaction->commit();
         }
     } catch (Exception $e) {
         throw Exception(Yii::t('common', 'Unable to excute Transaction.'));
     }
     return true;
 }
Exemplo n.º 11
0
use app\components\NumberUtils;
$formModeValue = $formMode[MasterValueUtils::PG_MODE_NAME];
$this->title = Yii::t('fin.interest', 'Create Interest Unit');
if ($formModeValue === MasterValueUtils::PG_MODE_EDIT) {
    $this->title = Yii::t('fin.interest', 'Edit Interest Unit');
} elseif ($formModeValue === MasterValueUtils::PG_MODE_COPY) {
    $this->title = Yii::t('fin.interest', 'Copy Interest Unit');
}
$startDate = DateTimeUtils::parse($model->start_date, $fmShortDatePhp);
$endDateHtml = null;
$endDate = null;
if (empty($model->end_date)) {
    $endDate = DateTimeUtils::getNow();
    $endDateHtml = '<span class="text-fuchsia">' . $endDate->format(DateTimeUtils::FM_VIEW_DATE_WD) . '</span>';
} else {
    $endDate = DateTimeUtils::parse($model->end_date, $fmShortDatePhp);
    $endDateHtml = DateTimeUtils::htmlDateFormat($endDate, DateTimeUtils::FM_VIEW_DATE_WD, null, true);
}
$interval = $endDate->diff($startDate);
$days = ($interval->invert === 1 ? 1 : -1) * $interval->days + 1;
?>

<div class="box box-default">
    <div class="box-header with-border"><h3 class="box-title"><?php 
echo Yii::t('fin.form', 'Confirm Values');
?>
</h3></div>
    <div id="finInterestConfirmForm" class="box-body"><?php 
$form = ActiveForm::begin();
?>
        <div class="row"><div class="col-md-12">
Exemplo n.º 12
0
$this->title = Yii::t('fin.interest', 'Details of Interest Unit');
?>

<?php 
if ($model) {
    ?>
<div class="row"><div class="col-md-12"><div class="box box-widget widget-detail">
    <?php 
    $startDate = DateTimeUtils::parse($model->start_date, DateTimeUtils::FM_DB_DATE);
    $endDateHtml = null;
    $endDate = null;
    if (empty($model->end_date)) {
        $endDate = DateTimeUtils::getNow();
        $endDateHtml = '<span class="text-fuchsia pull-right">' . $endDate->format(DateTimeUtils::FM_VIEW_DATE_WD) . '</span>';
    } else {
        $endDate = DateTimeUtils::parse($model->end_date, DateTimeUtils::FM_DB_DATE);
        $endDateHtml = DateTimeUtils::htmlDateFormat($endDate, DateTimeUtils::FM_VIEW_DATE_WD, null, ['class' => 'pull-right']);
    }
    $interval = $endDate->diff($startDate);
    $days = ($interval->invert === 1 ? 1 : -1) * $interval->days + 1;
    ?>
    <div class="widget-detail-header bg-maroon"><h3 class="widget-detail-title"><?php 
    echo Yii::t('fin.form', 'Details');
    ?>
</h3></div>
    <div class="box-footer">
        <ul class="nav nav-stacked nav-no-padding">
            <li><a href="javascript:void(0);">
                <?php 
    echo $model->getAttributeLabel('id');
    ?>
Exemplo n.º 13
0
 public function actionAssets()
 {
     $model = new FinTotalAssetsMonth();
     $fmShortDatePhp = DateTimeUtils::getDateFormat(DateTimeUtils::FM_KEY_PHP, null);
     $startDateJui = DateTimeUtils::parse('20151101', DateTimeUtils::FM_DEV_DATE, $fmShortDatePhp);
     $fmKeyPhp = DateTimeUtils::getDateFormat(DateTimeUtils::FM_KEY_PHP, null, DateTimeUtils::FM_KEY_FMONTH);
     $fmKeyJui = DateTimeUtils::getDateFormat(DateTimeUtils::FM_KEY_JUI, null, DateTimeUtils::FM_KEY_FMONTH);
     $td = DateTimeUtils::getNow();
     // is get page than reset value
     if (Yii::$app->request->getIsGet()) {
         $tdTimestamp = $td->getTimestamp();
         $tdInfo = getdate($tdTimestamp);
         $thismonth = $td->format($fmKeyPhp);
         // for report Model
         $model->fmonth = $thismonth;
         // for search Model
         $model->fmonth_to = $thismonth;
         $model->fmonth_from = DateTimeUtils::parse($tdInfo[DateTimeUtils::FN_KEY_GETDATE_YEAR] - 1 . '0101', DateTimeUtils::FM_DEV_DATE, $fmKeyPhp);
     } else {
         // submit data
         $postData = Yii::$app->request->post();
         $model->load($postData);
         $submitMode = isset($postData[MasterValueUtils::SM_MODE_NAME]) ? $postData[MasterValueUtils::SM_MODE_NAME] : false;
         switch ($submitMode) {
             case MasterValueUtils::SM_MODE_INPUT:
                 $reportMonthStr = DateTimeUtils::parse($model->fmonth, $fmKeyPhp, DateTimeUtils::FM_DEV_YM) . '01';
                 $reportMonthObj = DateTimeUtils::parse($reportMonthStr, DateTimeUtils::FM_DEV_DATE);
                 $reportMonthInfo = getdate($reportMonthObj->getTimestamp());
                 $year = $reportMonthInfo[DateTimeUtils::FN_KEY_GETDATE_YEAR];
                 $month = $reportMonthInfo[DateTimeUtils::FN_KEY_GETDATE_MONTH_INT];
                 $reportModel = FinTotalAssetsMonth::findOne(['year' => $year, 'month' => $month, 'delete_flag' => MasterValueUtils::MV_FIN_FLG_DELETE_FALSE]);
                 if (is_null($reportModel)) {
                     $reportModel = new FinTotalAssetsMonth();
                     $reportModel->year = $year;
                     $reportModel->month = $month;
                 }
                 $prevReportMonthObj = DateTimeUtils::subDateTime($reportMonthObj, 'P1M');
                 $prevReportMonthInfo = getdate($prevReportMonthObj->getTimestamp());
                 $prevYear = $prevReportMonthInfo[DateTimeUtils::FN_KEY_GETDATE_YEAR];
                 $prevMonth = $prevReportMonthInfo[DateTimeUtils::FN_KEY_GETDATE_MONTH_INT];
                 $prevReportModel = FinTotalAssetsMonth::findOne(['year' => $prevYear, 'month' => $prevMonth, 'delete_flag' => MasterValueUtils::MV_FIN_FLG_DELETE_FALSE]);
                 $prevAssetsValue = is_null($prevReportModel) ? 0 : $prevReportModel->assets_value;
                 $totalEntryMonth = FinTotalEntryMonth::findOne(['year' => $year, 'month' => $month, 'delete_flag' => MasterValueUtils::MV_FIN_FLG_DELETE_FALSE]);
                 $sumdebit = 0;
                 $sumcredit = 0;
                 if (!is_null($totalEntryMonth)) {
                     $sumdebit = is_null($totalEntryMonth->value_out) ? 0 : $totalEntryMonth->value_out;
                     $sumcredit = is_null($totalEntryMonth->value_in) ? 0 : $totalEntryMonth->value_in;
                 }
                 $reportModel->assets_value = $prevAssetsValue + $sumcredit - $sumdebit;
                 $reportModel->save();
                 Yii::$app->session->setFlash(MasterValueUtils::FLASH_SUCCESS, Yii::t('common', 'Monthly Assets Report of {month} has been saved successfully.', ['month' => $model->fmonth]));
                 return Yii::$app->getResponse()->redirect(Url::to(['assets']));
                 break;
             default:
                 break;
         }
     }
     $renderData = ['fmKeyJui' => $fmKeyJui, 'fmKeyPhp' => $fmKeyPhp, 'model' => $model, 'startDateJui' => $startDateJui];
     $fMonthInfo = getdate(DateTimeUtils::parse($model->fmonth_from, $fmKeyPhp)->getTimestamp());
     $tMonthInfo = getdate(DateTimeUtils::parse($model->fmonth_to, $fmKeyPhp)->getTimestamp());
     $fYear = $fMonthInfo[DateTimeUtils::FN_KEY_GETDATE_YEAR];
     $fMonth = $fMonthInfo[DateTimeUtils::FN_KEY_GETDATE_MONTH_INT];
     $fMonthMM = str_pad($fMonth, 2, '0', STR_PAD_LEFT);
     $tYear = $tMonthInfo[DateTimeUtils::FN_KEY_GETDATE_YEAR];
     $tMonth = $tMonthInfo[DateTimeUtils::FN_KEY_GETDATE_MONTH_INT];
     $tMonthMM = str_pad($tMonth, 2, '0', STR_PAD_LEFT);
     $gridData = null;
     $resultModel = FinTotalAssetsMonth::find()->select('t1.*, t2.value_in AS credit, t2.value_out AS debit')->from('fin_total_assets_month t1')->leftJoin('fin_total_entry_month t2', '(t1.year = t2.year AND t1.month = t2.month)')->where(['t1.delete_flag' => MasterValueUtils::MV_FIN_FLG_DELETE_FALSE])->andWhere(['>=', 't1.year', $fYear])->andWhere(['OR', ['>', 't1.year', $fYear], ['>=', 't1.month', $fMonth]])->andWhere(['<=', 't1.year', $tYear])->andWhere(['OR', ['<', 't1.year', $tYear], ['<=', 't1.month', $tMonth]])->orderBy('t1.year, t1.month')->all();
     if (count($resultModel) > 0) {
         // Init data for chart
         $sMonth = $fYear . $fMonthMM . '01';
         $eMonth = $tYear . $tMonthMM . '01';
         $currentMonthObj = DateTimeUtils::parse($sMonth, DateTimeUtils::FM_DEV_DATE);
         $arrDataChartTemp = [];
         while ($sMonth < $eMonth) {
             $sMonth = $currentMonthObj->format(DateTimeUtils::FM_DEV_DATE);
             $arrDataChartTemp[$sMonth] = ['credit' => 0, 'debit' => 0, 'assets' => 0];
             DateTimeUtils::addDateTime($currentMonthObj, 'P1M', null, false);
         }
         $firstResult = $resultModel[0];
         $prevCredit = is_null($firstResult->credit) ? 0 : $firstResult->credit;
         $prevDebit = is_null($firstResult->debit) ? 0 : $firstResult->debit;
         $prevAssets = is_null($firstResult->assets_value) ? 0 : $firstResult->assets_value;
         $gridData = [];
         foreach ($resultModel as $rm) {
             $key = $rm->year . str_pad($rm->month, 2, '0', STR_PAD_LEFT) . '01';
             $tempCredit = is_null($rm->credit) ? 0 : $rm->credit;
             $tempDebit = is_null($rm->debit) ? 0 : $rm->debit;
             $tempAssets = is_null($rm->assets_value) ? 0 : $rm->assets_value;
             $compareCredit = $tempCredit - $prevCredit;
             $compareDebit = $tempDebit - $prevDebit;
             $compareAssets = $tempAssets - $prevAssets;
             $prevCredit = $tempCredit;
             $prevDebit = $tempDebit;
             $prevAssets = $tempAssets;
             $girdRow = ['month' => DateTimeUtils::parse($key, DateTimeUtils::FM_DEV_DATE), 'credit' => $prevCredit, 'debit' => $prevDebit, 'assets' => $prevAssets, 'compareCredit' => $compareCredit, 'compareDebit' => $compareDebit, 'compareAssets' => $compareAssets];
             $gridData[$key] = $girdRow;
             // data for chart
             if (isset($arrDataChartTemp[$key])) {
                 $arrDataChartTemp[$key]['credit'] = $prevCredit;
                 $arrDataChartTemp[$key]['debit'] = $prevDebit;
                 $arrDataChartTemp[$key]['assets'] = $prevAssets;
             }
         }
         // data for chart
         $arrLabelChart = [];
         $arrCreditDataChart = [];
         $arrDebitDataChart = [];
         $arrAssetsDataChart = [];
         $arrCreditAliasDataChart = [];
         $arrDebitAliasDataChart = [];
         $arrAssetsAliasDataChart = [];
         foreach ($arrDataChartTemp as $labelChart => $dataChartTemp) {
             $arrLabelChart[] = DateTimeUtils::parse($labelChart, DateTimeUtils::FM_DEV_DATE, $fmKeyPhp);
             $arrCreditDataChart[] = $dataChartTemp['credit'];
             $arrDebitDataChart[] = $dataChartTemp['debit'];
             $arrAssetsDataChart[] = $dataChartTemp['assets'];
             $arrCreditAliasDataChart[] = NumberUtils::format($dataChartTemp['credit']);
             $arrDebitAliasDataChart[] = NumberUtils::format($dataChartTemp['debit']);
             $arrAssetsAliasDataChart[] = NumberUtils::format($dataChartTemp['assets']);
         }
         $renderData['chartData'] = json_encode(['label' => $arrLabelChart, 'credit' => $arrCreditDataChart, 'creditAlias' => $arrCreditAliasDataChart, 'debit' => $arrDebitDataChart, 'debitAlias' => $arrDebitAliasDataChart, 'assets' => $arrAssetsDataChart, 'assetsAlias' => $arrAssetsAliasDataChart], JSON_NUMERIC_CHECK);
     }
     $renderData['gridData'] = $gridData;
     // sum payment current month
     $beginCurrentMonth = DateTimeUtils::parse($td->format(DateTimeUtils::FM_DEV_YM) . '01', DateTimeUtils::FM_DEV_DATE);
     $endCurrentMonth = DateTimeUtils::addDateTime($beginCurrentMonth, 'P1M');
     DateTimeUtils::subDateTime($endCurrentMonth, 'P1D', null, false);
     $sumCurrentMonthQuery = (new Query())->select(['SUM(IF(account_source > 0, entry_value, 0)) AS debit', 'SUM(IF(account_target > 0, entry_value, 0)) AS credit']);
     $sumCurrentMonthQuery->from('fin_account_entry')->where(['=', 'delete_flag', MasterValueUtils::MV_FIN_FLG_DELETE_FALSE]);
     $sumCurrentMonthQuery->andWhere(['OR', ['=', 'account_source', MasterValueUtils::MV_FIN_ACCOUNT_NONE], ['=', 'account_target', MasterValueUtils::MV_FIN_ACCOUNT_NONE]]);
     $sumCurrentMonthQuery->andWhere(['>=', 'entry_date', $beginCurrentMonth->format(DateTimeUtils::FM_DB_DATE)]);
     $sumCurrentMonthQuery->andWhere(['<=', 'entry_date', $endCurrentMonth->format(DateTimeUtils::FM_DB_DATE)]);
     $sumCurrentAssetsData = $sumCurrentMonthQuery->createCommand()->queryOne();
     // sum Assets current month
     $sumCurrentAssets = 0;
     $arrFinAccount = FinAccount::find()->where(['delete_flag' => 0])->all();
     foreach ($arrFinAccount as $finAccount) {
         $instance = $finAccount->instance();
         $instance->initialize();
         $sumCurrentAssets += $instance->opening_balance;
     }
     $sumCurrentAssetsData['assets'] = $sumCurrentAssets;
     $renderData['sumCurrentAssetsData'] = $sumCurrentAssetsData;
     return $this->render('assets', $renderData);
 }
Exemplo n.º 14
0
    return ['style' => 'vertical-align: middle; text-align: right', 'class' => MasterValueUtils::getColorRow($index)];
}, 'value' => function ($model) {
    return NumberUtils::format($model->interest_unit, 2);
}], ['label' => Yii::t('fin.grid', 'Days'), 'headerOptions' => ['style' => 'text-align: center'], 'contentOptions' => function ($model, $key, $index) {
    return ['style' => 'vertical-align: middle; text-align: center', 'class' => MasterValueUtils::getColorRow($index)];
}, 'value' => function ($model) {
    $startDate = DateTimeUtils::parse($model->start_date, DateTimeUtils::FM_DB_DATE);
    $endDate = is_null($model->end_date) ? DateTimeUtils::getNow() : DateTimeUtils::parse($model->end_date, DateTimeUtils::FM_DB_DATE);
    $interval = $endDate->diff($startDate);
    $days = ($interval->invert === 1 ? 1 : -1) * $interval->days + 1;
    return $days;
}], ['label' => Yii::t('fin.grid', 'Interest'), 'headerOptions' => ['style' => 'text-align: center'], 'contentOptions' => function ($model, $key, $index) {
    return ['style' => 'vertical-align: middle; text-align: right', 'class' => MasterValueUtils::getColorRow($index)];
}, 'value' => function ($model) {
    $startDate = DateTimeUtils::parse($model->start_date, DateTimeUtils::FM_DB_DATE);
    $endDate = is_null($model->end_date) ? DateTimeUtils::getNow() : DateTimeUtils::parse($model->end_date, DateTimeUtils::FM_DB_DATE);
    $interval = $endDate->diff($startDate);
    $days = ($interval->invert === 1 ? 1 : -1) * $interval->days + 1;
    return NumberUtils::format($model->interest_unit * $days, 2);
}], ['label' => Yii::t('fin.grid', 'Action'), 'headerOptions' => ['style' => 'text-align: center; width: 100px;'], 'contentOptions' => function ($model, $key, $index) {
    return ['style' => 'vertical-align: middle; text-align: center', 'class' => MasterValueUtils::getColorRow($index)];
}, 'format' => 'raw', 'value' => function ($model, $key, $index) {
    $btnClass = MasterValueUtils::getColorRow($index);
    $lblView = Yii::t('button', 'View');
    $lblEdit = Yii::t('button', 'Edit');
    $lblCopy = Yii::t('button', 'Copy');
    $arrBtns = [];
    $entryId = $model->id;
    $urlEdit = BaseUrl::toRoute(['interest/update', 'id' => $entryId]);
    $arrBtns[] = StringUtils::format('<li><a href="{0}">{1}</a></li>', [$urlEdit, $lblEdit]);
    $urlView = BaseUrl::toRoute(['interest/view', 'id' => $entryId]);
Exemplo n.º 15
0
 public function actionIndex()
 {
     $searchModel = new FinAccountEntry();
     $phpFmShortDate = DateTimeUtils::getPhpDateFormat();
     $arrFinAccount = ModelUtils::getArrData(FinAccount::find()->select(['account_id', 'account_name'])->where(['delete_flag' => 0])->orderBy('account_type, order_num'), 'account_id', 'account_name');
     $arrEntryLog = MasterValueUtils::getArrData('fin_entry_log');
     // submit data
     $postData = Yii::$app->request->post();
     // populate model attributes with user inputs
     $searchModel->load($postData);
     // init value
     $today = new \DateTime();
     if (Yii::$app->request->getIsGet()) {
         $searchModel->entry_date_to = $today->format($phpFmShortDate);
         $lastMonth = DateTimeUtils::getNow(DateTimeUtils::FM_DEV_YM . '01', DateTimeUtils::FM_DEV_DATE);
         DateTimeUtils::subDateTime($lastMonth, 'P1M', null, false);
         $searchModel->entry_date_from = $lastMonth->format($phpFmShortDate);
     }
     FinAccountEntry::$_PHP_FM_SHORTDATE = $phpFmShortDate;
     $searchModel->scenario = MasterValueUtils::SCENARIO_LIST;
     // sum current month
     $beginMonth = DateTimeUtils::parse($today->format(DateTimeUtils::FM_DEV_YM) . '01', DateTimeUtils::FM_DEV_DATE);
     $endMonth = DateTimeUtils::addDateTime($beginMonth, 'P1M');
     DateTimeUtils::subDateTime($endMonth, 'P1D', null, false);
     $sumCurrentMonthQuery = (new Query())->select(['SUM(IF(account_source > 0, entry_value, 0)) AS debit', 'SUM(IF(account_target > 0, entry_value, 0)) AS credit']);
     $sumCurrentMonthQuery->from('fin_account_entry')->where(['=', 'delete_flag', MasterValueUtils::MV_FIN_FLG_DELETE_FALSE]);
     $sumCurrentMonthQuery->andWhere(['OR', ['=', 'account_source', MasterValueUtils::MV_FIN_ACCOUNT_NONE], ['=', 'account_target', MasterValueUtils::MV_FIN_ACCOUNT_NONE]]);
     $sumCurrentMonthQuery->andWhere(['>=', 'entry_date', $beginMonth->format(DateTimeUtils::FM_DB_DATE)]);
     $sumCurrentMonthQuery->andWhere(['<=', 'entry_date', $endMonth->format(DateTimeUtils::FM_DB_DATE)]);
     $sumCurrentMonthData = $sumCurrentMonthQuery->createCommand()->queryOne();
     // sum Debit Amount & Credit Amount
     $sumEntryValue = false;
     // query for dataprovider
     $dataQuery = null;
     if ($searchModel->validate()) {
         $t2leftJoin = '';
         $t2leftJoin .= ' (';
         $t2leftJoin .= ' t1.entry_date = t2.opening_date AND t2.delete_flag = :deleteFlagFalse';
         $t2leftJoin .= '   AND (';
         $t2leftJoin .= '     (t1.entry_status = :entryTypeDeposit AND t2.add_flag = :trantypeAdding AND t1.account_source = t2.current_assets AND t1.account_target = t2.saving_account)';
         $t2leftJoin .= '     OR';
         $t2leftJoin .= '     (t1.entry_status = :entryTypeDeposit AND t2.add_flag = :trantypeWithdrawal AND t1.account_source = t2.saving_account AND t1.account_target = t2.current_assets)';
         $t2leftJoin .= '     OR';
         $t2leftJoin .= '     (t1.entry_status = :entryTypeInterestDeposit AND t1.account_source = :accountNoneId AND t1.account_target = t2.saving_account)';
         $t2leftJoin .= '   )';
         $t2leftJoin .= ' )';
         $dataQuery = FinAccountEntry::find()->select('t1.*, t2.transactions_id AS time_deposit_tran_id')->from('fin_account_entry t1')->leftJoin('fin_time_deposit_tran t2', $t2leftJoin, ['entryTypeDeposit' => MasterValueUtils::MV_FIN_ENTRY_TYPE_DEPOSIT, 'entryTypeInterestDeposit' => MasterValueUtils::MV_FIN_ENTRY_TYPE_INTEREST_DEPOSIT, 'accountNoneId' => MasterValueUtils::MV_FIN_ACCOUNT_NONE, 'deleteFlagFalse' => MasterValueUtils::MV_FIN_FLG_DELETE_FALSE, 'trantypeAdding' => MasterValueUtils::MV_FIN_TIMEDP_TRANTYPE_ADDING, 'trantypeWithdrawal' => MasterValueUtils::MV_FIN_TIMEDP_TRANTYPE_WITHDRAWAL])->where(['=', 't1.delete_flag', MasterValueUtils::MV_FIN_FLG_DELETE_FALSE]);
         $sumEntryQuery = (new Query())->select(['SUM(IF(account_source > 0, entry_value, 0)) AS entry_source', 'SUM(IF(account_target > 0, entry_value, 0)) AS entry_target']);
         $sumEntryQuery->from('fin_account_entry')->where(['=', 'delete_flag', MasterValueUtils::MV_FIN_FLG_DELETE_FALSE]);
         $sumEntryQuery->andWhere(['OR', ['=', 'account_source', MasterValueUtils::MV_FIN_ACCOUNT_NONE], ['=', 'account_target', MasterValueUtils::MV_FIN_ACCOUNT_NONE]]);
         if (!empty($searchModel->entry_date_from)) {
             $dataQuery->andWhere(['>=', 't1.entry_date', $searchModel->entry_date_from]);
             $sumEntryQuery->andWhere(['>=', 'entry_date', $searchModel->entry_date_from]);
         }
         if (!empty($searchModel->entry_date_to)) {
             $dataQuery->andWhere(['<=', 't1.entry_date', $searchModel->entry_date_to]);
             $sumEntryQuery->andWhere(['<=', 'entry_date', $searchModel->entry_date_to]);
         }
         if ($searchModel->account_source > 0) {
             $dataQuery->andWhere(['=', 't1.account_source', $searchModel->account_source]);
         }
         if ($searchModel->account_target > 0) {
             $dataQuery->andWhere(['=', 't1.account_target', $searchModel->account_target]);
         }
         $dataQuery->orderBy('t1.entry_date DESC, t1.create_date DESC');
         $sumEntryValue = $sumEntryQuery->createCommand()->queryOne();
     } else {
         $dataQuery = FinAccountEntry::find()->where(['entry_id' => -1]);
     }
     // render GUI
     $renderData = ['searchModel' => $searchModel, 'phpFmShortDate' => $phpFmShortDate, 'arrEntryLog' => $arrEntryLog, 'arrFinAccount' => $arrFinAccount, 'dataQuery' => $dataQuery, 'sumEntryValue' => $sumEntryValue, 'sumCurrentMonthData' => $sumCurrentMonthData];
     return $this->render('index', $renderData);
 }