Beispiel #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Conteodiario::find();
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id, 'inal1' => $this->inal1, 'inal2' => $this->inal2, 'inal3' => $this->inal3, 'inal4' => $this->inal4, 'inal5' => $this->inal5, 'inal6' => $this->inal6, 'inal7' => $this->inal7, 'inal8' => $this->inal8, 'inal9' => $this->inal9, 'inal10' => $this->inal10, 'inal11' => $this->inal11, 'inal12' => $this->inal12, 'inal13' => $this->inal13, 'inal14' => $this->inal14, 'inal15' => $this->inal15, 'inal16' => $this->inal16, 'iext1' => $this->iext1, 'iext2' => $this->iext2, 'fapertura' => $this->fapertura, 'cnal1' => $this->cnal1, 'cnal2' => $this->cnal2, 'cnal3' => $this->cnal3, 'cnal4' => $this->cnal4, 'cnal5' => $this->cnal5, 'cnal6' => $this->cnal6, 'cnal7' => $this->cnal7, 'cnal8' => $this->cnal8, 'cnal9' => $this->cnal9, 'cnal10' => $this->cnal10, 'cnal11' => $this->cnal11, 'cnal12' => $this->cnal12, 'cnal13' => $this->cnal13, 'cnal14' => $this->cnal14, 'cnal15' => $this->cnal15, 'cnal16' => $this->cnal16, 'cext1' => $this->cext1, 'cext2' => $this->cext2, 'fcierre' => $this->fcierre, 'montoapertura' => $this->montoapertura, 'montocierre' => $this->montocierre, 'arqueo_id' => $this->arqueo_id]);
     $query->andFilterWhere(['like', 'username', $this->username]);
     return $dataProvider;
 }
Beispiel #2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getConteodiarios()
 {
     return $this->hasMany(Conteodiario::className(), ['arqueo_id' => 'id']);
 }
 /**
  * Finds the Conteodiario model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Conteodiario the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Conteodiario::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Beispiel #4
0
 protected function actualizaArqueo($model)
 {
     ## OBTIENE LA CANTIDAD CON LA QUE SE ABRIO Y CERRO EL TURNO EN LA CAJA
     // Obteniendo la info de la apertura
     $apertura = Conteodiario::find()->select(['montoapertura', 'montocierre'])->where(['arqueo_id' => null, 'username' => Yii::$app->user->identity->username])->one();
     // Cantidad que se conto de dinero con que se aperturo la caja
     $model->efectivoapertura = $apertura->montoapertura;
     // Cantidad que se conto de dinero con el que se cerro la caja
     $model->efectivocierre = $apertura->montocierre;
     ## OBTIENE LAS CANTIDADES DE CADA INGRESO O EGRESO PARA HACER LOS CALCULOS
     // Ventas en efectivo reportadas por el SoftRestaurant -- Efectivo Real - Lo que dice la máquina que vendió
     $model->efectivosistema = Conteonotas::find()->select(['cantidad'])->where(['arqueo_id' => $model->id, 'tipo' => 'INGRESO EFECTIVO'])->asArray()->sum('cantidad');
     // Compras realizadas con Tarjeta de Debido o Credito
     $model->dineroelectronico = Conteonotas::find()->select(['cantidad'])->where(['arqueo_id' => $model->id, 'tipo' => 'INGRESO ELECTRONICO'])->asArray()->sum('cantidad');
     // Dinero que se deposito de forma adicional ( de compras u otra cosa que se retiro y no se deposito nuevamente )
     $model->efectivoadeudoanterior = Conteonotas::find()->select(['cantidad'])->where(['arqueo_id' => $model->id, 'tipo' => 'INGRESO ADEUDOS ANTERIORES'])->asArray()->sum('cantidad');
     // Dinero que deposita la empresa para agregar flujo de efectivo ( Cuando se queda sin dinero o cambio la caja)
     $model->depositoempresa = Conteonotas::find()->select(['cantidad'])->where(['arqueo_id' => $model->id, 'tipo' => 'INGRESO EMPRESA'])->asArray()->sum('cantidad');
     // Dinero que se retira de la caja por exceso de efectivo por seguridad
     $model->retiroempresa = Conteonotas::find()->select(['cantidad'])->where(['arqueo_id' => $model->id, 'tipo' => 'RETIRO EMPRESA'])->asArray()->sum('cantidad');
     // Compras realizadas con dinero de la caja
     $model->egresocompras = Conteonotas::find()->select(['cantidad'])->where(['arqueo_id' => $model->id, 'tipo' => 'EGRESO COMPRA'])->asArray()->sum('cantidad');
     // Pagos de servicios con dinero de la caja
     $model->egresocomprasservicio = Conteonotas::find()->select(['cantidad'])->where(['arqueo_id' => $model->id, 'tipo' => 'EGRESO SERVICIO'])->asArray()->sum('cantidad');
     // Efectivo que debe de existir en la caja; debe ser igual a lo que reporto el SoftRestaurant
     $model->efectivofisico = $model->efectivoapertura + $model->efectivosistema + $model->depositoempresa - $model->egresocompras - $model->egresocomprasservicio - $model->retiroempresa;
     $adeudoanterior = Arqueo::find()->select(['adeudoactual'])->where(['username' => Yii::$app->user->identity->username, 'cerrado' => true])->orderBy(['id' => SORT_ASC])->one();
     // Cuanto quedo a deber el cajero el día anterior
     $model->adeudoanterior = empty($adeudoanterior->adeudoactual) ? 0 : $adeudoanterior->adeudoactual;
     // Dinero que quedo a deber el cajero
     if ($model->efectivocierre < $model->efectivofisico) {
         $deuda = $model->efectivofisico - $model->efectivocierre;
     } else {
         $deuda = 0;
     }
     $model->adeudoactual = $deuda + $model->adeudoanterior - $model->efectivoadeudoanterior;
     // Cuanto se vendio en el turno
     $model->ventaturno = $model->efectivosistema + $model->dineroelectronico;
     // Cuando se gasto en el turno
     $model->egresoturno = $model->egresocompras + $model->egresocomprasservicio;
 }