public function actionCreateMaster($item_id, $sheet_id)
 {
     $item = BalanceItem::findOne($item_id);
     foreach ($item->accounts as $account) {
         $model = new BalanceAmount();
         $model->account_id = $account->id;
         $model->balance_sheet_id = $sheet_id;
         $model->amount = 0;
         $model->save();
     }
     return $this->redirect(['master/index']);
 }
 /**
  * Finds the BalanceItem model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return BalanceItem the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = BalanceItem::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }