Ejemplo n.º 1
0
 public function search($params)
 {
     $query = EntriSheetModel::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id_esheet' => $this->id_esheet, 'create_by' => $this->create_by, 'update_by' => $this->update_by]);
     $query->andFilterWhere(['like', 'cd_esheet', $this->cd_esheet])->andFilterWhere(['like', 'nm_esheet', $this->nm_esheet])->andFilterWhere(['like', 'create_at', $this->create_at])->andFilterWhere(['like', 'update_at', $this->update_at]);
     return $dataProvider;
 }
Ejemplo n.º 2
0
 public static function createFromEntrysheet($data, $model = null)
 {
     $es = $data['entry_sheet'];
     if (!$es instanceof EntriSheet) {
         $es = EntriSheet::findOne($es);
     }
     $values = $data['values'];
     unset($data['entry_sheet'], $data['values']);
     $details = [];
     foreach ($es->entriSheetDtls as $esDetail) {
         $nm = $esDetail->cd_esheet_dtl;
         if (isset($values[$nm])) {
             $details[] = ['id_coa' => $esDetail->id_coa, 'amount' => $values[$nm]];
         } else {
             throw new UserException("Required account \"{$nm}\" ");
         }
     }
     $data['details'] = $details;
     return static::create($data, $model);
 }
Ejemplo n.º 3
0
 /**
  *
  * @param  string        $name   Entri Sheet name
  * @param  array         $values
  * @return array
  * @throws UserException
  */
 public static function entriSheetToGlMaps($name, $values)
 {
     $gl_dtls = [];
     $esheet = EntriSheet::findOne(['nm_esheet' => $name]);
     if ($esheet) {
         foreach ($esheet->entriSheetDtls as $eDtl) {
             $coa = $eDtl->id_coa;
             $nm = $eDtl->nm_esheet_dtl;
             $dc = $eDtl->idCoa->normal_balance == 'D' ? 1 : -1;
             if (isset($values[$nm])) {
                 $ammount = $dc * $values[$nm];
             } else {
                 throw new UserException("Required account {$nm} ");
             }
             $gl_dtls[] = ['id_coa' => $coa, 'ammount' => $ammount];
         }
     } else {
         throw new UserException("Entrysheet {$name} not found");
     }
     return $gl_dtls;
 }
 /**
  * Finds the EntriSheet model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param  integer               $id
  * @return EntriSheet            the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = EntriSheet::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Ejemplo n.º 5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getIdEsheet()
 {
     return $this->hasOne(EntriSheet::className(), ['id_esheet' => 'id_esheet']);
 }