コード例 #1
0
ファイル: Helper.php プロジェクト: sangkilsoft/sangkilbiz-3
 /**
  * 
  * @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;
 }
コード例 #2
0
 /**
  * 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.');
     }
 }