add display money to account state close, delete ticket on customer tickets
This commit is contained in:
@@ -3,8 +3,8 @@
|
||||
namespace common\models;
|
||||
|
||||
use Yii;
|
||||
use yii\db\QueryBuilder;
|
||||
use yii\helpers\ArrayHelper;
|
||||
use yii\behaviors\TimestampBehavior;
|
||||
|
||||
/**
|
||||
* This is the model class for table "account_state".
|
||||
@@ -38,6 +38,17 @@ class AccountState extends \common\models\BaseFitnessActiveRecord
|
||||
|
||||
public $start_date;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
// public function behaviors()
|
||||
// {
|
||||
// return [[
|
||||
// 'class' => TimestampBehavior::className(),
|
||||
// 'value' => function(){ return date('Y-m-d H:i' ); }
|
||||
// ] ];
|
||||
// }
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@ use common\models\Account;
|
||||
use yii\helpers\ArrayHelper;
|
||||
use common\models\MoneyMovement;
|
||||
use common\components\RoleDefinition;
|
||||
use common\components\Helper;
|
||||
/**
|
||||
* TransferListSearch represents the model behind the search form about `common\models\Transfer`.
|
||||
*/
|
||||
@@ -29,7 +30,10 @@ class TransferListSearch extends Transfer
|
||||
public $timestampEnd;
|
||||
|
||||
|
||||
public $includeCassaOpen = false;
|
||||
public $totalWithCassa;
|
||||
|
||||
public $cassaOpen;
|
||||
// public $totalsCreatedAt = ['total' => 0, 'accounts' =>[] ];
|
||||
// public $totalsCreatedAtNotPaid= ['total' => 0, 'accounts' =>[]];
|
||||
// public $totalsCreatedAtPaid= ['total' => 0, 'accounts' =>[]];
|
||||
@@ -124,6 +128,9 @@ class TransferListSearch extends Transfer
|
||||
public function isModeAdmin(){
|
||||
return $this->mode == 'admin';
|
||||
}
|
||||
public function isModeReception(){
|
||||
return $this->mode == 'reception';
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates data provider instance with search query applied
|
||||
@@ -149,11 +156,20 @@ class TransferListSearch extends Transfer
|
||||
}
|
||||
|
||||
|
||||
|
||||
$this->readTicketMoney();
|
||||
$this->readProductsMoney();
|
||||
$this->readMoneyMovementMoney();
|
||||
$this->calcTotal();
|
||||
|
||||
if ( $this->isModeReception()){
|
||||
if ( Helper::isAccountStateClosePreloadMoney()){
|
||||
$this->readCassaOpen();
|
||||
$this->calcTotalWithCassaOpen();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$this->readProductsByCategory();
|
||||
$this->readProductsByCategoryDetailed();
|
||||
$this->readTicketStas();
|
||||
@@ -179,12 +195,24 @@ class TransferListSearch extends Transfer
|
||||
|
||||
}
|
||||
|
||||
protected function readCassaOpen(){
|
||||
$this->cassaOpen = AccountState::readLast(AccountState::TYPE_OPEN,null,Account::readDefault());
|
||||
}
|
||||
|
||||
protected function calcTotal(){
|
||||
$this->total = 0;
|
||||
$this->total += $this->ticketMoney;
|
||||
$this->total += $this->productMoney;
|
||||
$this->total += $this->moneyMovementMoneis;
|
||||
}
|
||||
protected function calcTotalWithCassaOpen(){
|
||||
$this->totalWithCassa = 0;
|
||||
$this->totalWithCassa += $this->total;
|
||||
if ( isset($this->cassaOpen ) ){
|
||||
$this->totalWithCassa += $this->cassaOpen->money;
|
||||
}
|
||||
|
||||
}
|
||||
protected function calcTotalNetto(){
|
||||
$this->totalNetto = 0;
|
||||
$this->totalNetto += $this->ticketMoney;
|
||||
@@ -437,7 +465,7 @@ class TransferListSearch extends Transfer
|
||||
|
||||
protected function readMoneyMovements(){
|
||||
$query = (new \yii\db\Query());
|
||||
$query->select([ 'user.username as user_name','account.name as account_name', 'transfer.direction as transfer_direction' ,'money_movement.type as money_movement_type', 'transfer.money AS money_movement_money', 'money_movement.name as money_movement_name','transfer.created_at as money_movement_created_at', ]);
|
||||
$query->select([ 'user.username as user_name','account.name as account_name', 'transfer.direction as transfer_direction' ,'money_movement.type as money_movement_type', 'transfer.money AS money_movement_money', 'money_movement.name as money_movement_name','transfer.created_at as money_movement_created_at', 'money_movement.comment as money_movement_comment' ]);
|
||||
$query->from('transfer');
|
||||
$query->andWhere(['transfer.type' => Transfer::TYPE_MONEY_MOVEMENT_OUT]);
|
||||
$query->innerJoin("money_movement", "money_movement.id_money_movement = transfer.id_object");
|
||||
|
||||
Reference in New Issue
Block a user