示例#1
0
 public function actionTool()
 {
     // master value
     $fmShortDatePhp = DateTimeUtils::getDateFormat(DateTimeUtils::FM_KEY_PHP, null);
     $fmShortDateJui = DateTimeUtils::getDateFormat(DateTimeUtils::FM_KEY_JUI, null);
     $arrPurchaseType = MasterValueUtils::getArrData('oef_purchase_type');
     OefFundCertificate::$_PHP_FM_SHORTDATE = $fmShortDatePhp;
     // 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 = new OefFundCertificate();
     $model->load($postData);
     // init value
     $model->scenario = MasterValueUtils::SCENARIO_TOOL;
     if (Yii::$app->request->getIsGet()) {
         $today = DateTimeUtils::getNow();
         $model->sell_date = $today->format($fmShortDatePhp);
         $model->income_tax_rate = ParamUtils::getIncomeTaxRateSale();
         $sumPurchaseQuery = (new Query())->select(['SUM(found_stock) AS found_stock', 'SUM(found_stock_sold) AS found_stock_sold']);
         $sumPurchaseQuery->from('oef_purchase')->where(['delete_flag' => MasterValueUtils::MV_FIN_FLG_DELETE_FALSE])->andWhere('found_stock > found_stock_sold');
         $sumPurchaseData = $sumPurchaseQuery->createCommand()->queryOne();
         if (!is_null($sumPurchaseData['found_stock']) && !is_null($sumPurchaseData['found_stock_sold'])) {
             $model->sell_certificate = $sumPurchaseData['found_stock'] - $sumPurchaseData['found_stock_sold'];
         }
     }
     $isValidSellDate = $model->validate(['sell_date']);
     if ($isValidSellDate && empty($model->nav)) {
         $sellDate = DateTimeUtils::parse($model->sell_date, $fmShortDatePhp);
         $oefNavModel = OefNav::findOne(['delete_flag' => MasterValueUtils::MV_FIN_FLG_DELETE_FALSE, 'trade_date' => $sellDate->format(DateTimeUtils::FM_DB_DATE)]);
         if (!is_null($oefNavModel)) {
             $model->nav = $oefNavModel->nav_value;
         }
     }
     // render GUI
     $renderView = 'tool';
     $renderData = ['model' => $model, 'fmShortDateJui' => $fmShortDateJui, 'arrPurchaseType' => $arrPurchaseType, 'arrFundCertificate4Sell' => false];
     switch ($submitMode) {
         case MasterValueUtils::SM_MODE_INPUT:
             $isValid = $model->validate();
             if ($isValid) {
                 $arrFundCertificate4Sell = $this->getFundCertificate4Sell($model, $fmShortDatePhp);
                 $renderData['arrFundCertificate4Sell'] = $arrFundCertificate4Sell;
             }
             break;
         default:
             break;
     }
     // render GUI
     return $this->render($renderView, $renderData);
 }
示例#2
0
 public function actionUpdate($id)
 {
     $this->objectId = $id;
     // master value
     $fmShortDatePhp = DateTimeUtils::getDateFormat(DateTimeUtils::FM_KEY_PHP, null);
     $fmShortDateJui = DateTimeUtils::getDateFormat(DateTimeUtils::FM_KEY_JUI, null);
     OefPurchase::$_PHP_FM_SHORTDATE = $fmShortDatePhp;
     $model = OefPurchase::getModel($id);
     $renderView = 'update';
     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('oef.models', 'Purchase')]));
     } else {
         // master value
         $arrPurchaseType = MasterValueUtils::getArrData('oef_purchase_type');
         // 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_UPDATE;
         // render GUI
         $renderData = ['model' => $model, 'fmShortDatePhp' => $fmShortDatePhp, 'fmShortDateJui' => $fmShortDateJui, 'arrPurchaseType' => $arrPurchaseType];
         switch ($submitMode) {
             case MasterValueUtils::SM_MODE_INPUT:
                 $isValid = $model->validate();
                 $model->calculate();
                 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) {
                     $model->calculate();
                     $result = $this->updatePurchase($model, $fmShortDatePhp);
                     if ($result === true) {
                         Yii::$app->session->setFlash(MasterValueUtils::FLASH_SUCCESS, Yii::t('common', '{record} has been saved successfully.', ['record' => Yii::t('oef.models', 'Purchase')]));
                         return Yii::$app->getResponse()->redirect(Url::to(['update', 'id' => $id]));
                     } else {
                         // restore Data for View
                         $model->purchase_date = DateTimeUtils::parse($model->purchase_date, DateTimeUtils::FM_DB_DATE, $fmShortDatePhp);
                         if (!empty($model->sip_date)) {
                             $model->sip_date = DateTimeUtils::parse($model->sip_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);
 }
示例#3
0
 public function actionUpdate($id)
 {
     $this->objectId = $id;
     // master value
     $fmShortDatePhp = DateTimeUtils::getDateFormat(DateTimeUtils::FM_KEY_PHP, null);
     $fmShortDateJui = DateTimeUtils::getDateFormat(DateTimeUtils::FM_KEY_JUI, null);
     JarPayment::$_PHP_FM_SHORTDATE = $fmShortDatePhp;
     $model = JarPayment::findOne(['id' => $id, 'delete_flag' => MasterValueUtils::MV_FIN_FLG_DELETE_FALSE]);
     $renderView = 'update';
     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('jar.models', 'Payment')]));
     } else {
         if ($model->share_id > 0) {
             return Yii::$app->getResponse()->redirect(Url::to(['/jar/distribute/update', 'id' => $model->share_id]));
         }
         // master value
         $arrAccount = ModelUtils::getArrData(JarAccount::find()->select(['account_id', 'account_name'])->where(['delete_flag' => MasterValueUtils::MV_FIN_FLG_DELETE_FALSE])->orderBy('account_type, order_num'), 'account_id', 'account_name');
         $arrEntryLog = MasterValueUtils::getArrData('jar_payment_status');
         // 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_UPDATE;
         // render GUI
         $renderData = ['model' => $model, 'fmShortDatePhp' => $fmShortDatePhp, 'fmShortDateJui' => $fmShortDateJui, 'arrAccount' => $arrAccount, 'arrEntryLog' => $arrEntryLog];
         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->updatePayment($model, $fmShortDatePhp);
                     if ($result === true) {
                         Yii::$app->session->setFlash(MasterValueUtils::FLASH_SUCCESS, Yii::t('common', '{record} has been saved successfully.', ['record' => Yii::t('jar.models', 'Payment')]));
                         return Yii::$app->getResponse()->redirect(Url::to(['update', 'id' => $id]));
                     } else {
                         // restore Data for View
                         $model->entry_date = DateTimeUtils::parse($model->entry_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);
 }
示例#4
0
 public function actionCopy($id)
 {
     $this->objectId = $id;
     $model = FinTimeDepositTran::findOne(['transactions_id' => $id, 'delete_flag' => MasterValueUtils::MV_FIN_FLG_DELETE_FALSE]);
     $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', 'Fixed Deposit')]));
     } else {
         // master value
         $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();
         $submitMode = isset($postData[MasterValueUtils::SM_MODE_NAME]) ? $postData[MasterValueUtils::SM_MODE_NAME] : false;
         // populate model attributes with user inputs
         $model->load($postData);
         // reset value
         if (Yii::$app->request->getIsGet()) {
             $openingDate = DateTimeUtils::getDateFromDB($model->opening_date);
             $closingDate = DateTimeUtils::getDateFromDB($model->closing_date);
             $dateDiff = $closingDate->diff($openingDate);
             $interval = 'P' . $dateDiff->m . 'M';
             DateTimeUtils::addDateTime($closingDate, $interval, null, false);
             $model->opening_date = $model->closing_date;
             $model->closing_date = $closingDate->format(DateTimeUtils::FM_DB_DATE);
             $model->interest_add = 0;
             $model->add_flag = MasterValueUtils::MV_FIN_TIMEDP_TRANTYPE_ADDING;
         }
         // init value
         FinTimeDepositTran::$_PHP_FM_SHORTDATE = $phpFmShortDate;
         FinTimeDepositTran::$_ARR_SAVING_ACOUNT = $arrSavingAccount;
         $model->scenario = MasterValueUtils::SCENARIO_COPY;
         $renderData = ['model' => $model, 'phpFmShortDate' => $phpFmShortDate, 'arrTimedepositTrantype' => $arrTimedepositTrantype, 'arrSavingAccount' => $arrSavingAccount, 'arrCurrentAssets' => $arrCurrentAssets];
         switch ($submitMode) {
             case MasterValueUtils::SM_MODE_INPUT:
                 $isValid = $model->validate();
                 if ($isValid) {
                     $renderView = 'confirm';
                     $renderData['formMode'] = [MasterValueUtils::PG_MODE_NAME => MasterValueUtils::PG_MODE_COPY];
                 }
                 break;
             case MasterValueUtils::SM_MODE_CONFIRM:
                 $isValid = $model->validate();
                 if ($isValid) {
                     $result = $this->copyFixedDeposit($model);
                     if ($result === true) {
                         Yii::$app->session->setFlash(MasterValueUtils::FLASH_SUCCESS, Yii::t('common', '{record} has been saved successfully.', ['record' => Yii::t('fin.models', 'Fixed Deposit')]));
                         return Yii::$app->getResponse()->redirect(Url::to(['index']));
                     } else {
                         Yii::$app->session->setFlash(MasterValueUtils::FLASH_ERROR, $result);
                         $renderView = 'confirm';
                         $renderData['formMode'] = [MasterValueUtils::PG_MODE_NAME => MasterValueUtils::PG_MODE_COPY];
                     }
                 }
                 break;
             case MasterValueUtils::SM_MODE_BACK:
                 break;
             default:
                 break;
         }
     }
     // render GUI
     return $this->render($renderView, $renderData);
 }
示例#5
0
 public function actionUpdate($id)
 {
     $this->objectId = $id;
     $model = NetCustomer::findOne(['id' => $id, 'delete_flag' => MasterValueUtils::MV_FIN_FLG_DELETE_FALSE]);
     $renderView = 'update';
     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('net.models', 'Customer')]));
     } else {
         // master value
         $arrCustomerStatus = MasterValueUtils::getArrData('net_customer_status');
         // 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_UPDATE;
         $renderData = ['model' => $model, 'arrCustomerStatus' => $arrCustomerStatus];
         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->createCustomer($model);
                     if ($result === true) {
                         Yii::$app->session->setFlash(MasterValueUtils::FLASH_SUCCESS, Yii::t('common', '{record} has been saved successfully.', ['record' => Yii::t('net.models', 'Customer')]));
                         return Yii::$app->getResponse()->redirect(Url::to(['update', 'id' => $id]));
                     } else {
                         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);
 }
示例#6
0
 public function actionCopy($id)
 {
     $this->objectId = $id;
     $model = FinAccountEntry::findOne(['entry_id' => $id, 'entry_status' => MasterValueUtils::MV_FIN_ENTRY_TYPE_SIMPLE, 'delete_flag' => MasterValueUtils::MV_FIN_FLG_DELETE_FALSE]);
     $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', 'Payment')]));
     } else {
         // master value
         $phpFmShortDate = DateTimeUtils::getPhpDateFormat();
         $arrFinAccount = ModelUtils::getArrData(FinAccount::find()->select(['account_id', 'account_name'])->where(['delete_flag' => 0, 'account_type' => [1, 2, 3, 5, 6, 7]])->orderBy('account_type, order_num'), 'account_id', 'account_name');
         $arrEntryLog = MasterValueUtils::getArrData('fin_entry_log');
         // reset value
         $model->entry_date = DateTimeUtils::formatNow($phpFmShortDate);
         // 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);
         if (is_null($model->arr_entry_log)) {
             $model->arr_entry_log = StringUtils::unserializeArr($model->description);
         }
         // init value
         FinAccountEntry::$_PHP_FM_SHORTDATE = $phpFmShortDate;
         $model->scenario = MasterValueUtils::SCENARIO_COPY;
         $renderData = ['model' => $model, 'phpFmShortDate' => $phpFmShortDate, 'arrFinAccount' => $arrFinAccount, 'arrEntryLog' => $arrEntryLog];
         switch ($submitMode) {
             case MasterValueUtils::SM_MODE_INPUT:
                 $isValid = $model->validate();
                 if ($isValid) {
                     $renderView = 'confirm';
                     $renderData['formMode'] = [MasterValueUtils::PG_MODE_NAME => MasterValueUtils::PG_MODE_COPY];
                 }
                 break;
             case MasterValueUtils::SM_MODE_CONFIRM:
                 $isValid = $model->validate();
                 if ($isValid) {
                     $result = $this->copyPayment($model);
                     if ($result === true) {
                         Yii::$app->session->setFlash(MasterValueUtils::FLASH_SUCCESS, Yii::t('common', '{record} has been saved successfully.', ['record' => Yii::t('fin.models', 'Payment')]));
                         return Yii::$app->getResponse()->redirect(Url::to(['index']));
                     } else {
                         Yii::$app->session->setFlash(MasterValueUtils::FLASH_ERROR, $result);
                         $renderView = 'confirm';
                         $renderData['formMode'] = [MasterValueUtils::PG_MODE_NAME => MasterValueUtils::PG_MODE_COPY];
                     }
                 }
                 break;
             case MasterValueUtils::SM_MODE_BACK:
                 break;
             default:
                 break;
         }
     }
     // render GUI
     return $this->render($renderView, $renderData);
 }