add display money to account state close, delete ticket on customer tickets

This commit is contained in:
2016-01-10 15:25:25 +01:00
parent 5a98d128bc
commit 7c584a0779
21 changed files with 291 additions and 19 deletions

View File

@@ -12,6 +12,8 @@ use common\models\Account;
use common\components\DailyListing;
use common\models\User;
use common\components\accountstate\AccountStateMail;
use common\models\Transfer;
use common\components\Helper;
/**
* AccountStateController implements the CRUD actions for AccountState model.
@@ -111,6 +113,17 @@ class AccountStateController extends Controller {
$model->type = AccountState::TYPE_CLOSE;
$model->id_user = Yii::$app->user->id;
$model->id_account = Account::readDefault ();
$lastCassaState = AccountState::readLast(null,null, Account::readDefault());
if ( Helper::isAccountStateClosePreloadMoney()){
$model->money = $this->readCassaClose();
}
if ($model->load ( Yii::$app->request->post () ) && $model->save ()) {
@@ -128,11 +141,22 @@ class AccountStateController extends Controller {
return $this->render ( 'close', [
'model' => $model,
'accounts' => $accounts,
'lastStates' => $lastStates
'lastStates' => $lastStates ,
'lastCassaState' => $lastCassaState,
] );
}
}
protected function readCassaClose(){
$total = 0;
$cassaOpen = AccountState::readLast(AccountState::TYPE_OPEN,null, Account::readDefault());
if ( isset($cassaOpen )){
$total += $cassaOpen->money;
}
$total += Transfer::readPaid($cassaOpen->created_at, date('Y-d-m h:i:s'), \Yii::$app->user->id);
return $total;
}
/**
* Finds the AccountState model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.