/*
 * MosP - Mind Open Source Project    http://www.mosp.jp/
 * Copyright (C) MIND Co., Ltd.       http://www.e-mind.co.jp/
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
package jp.mosp.payroll.common.action;

import java.util.Date;

import jp.mosp.common.common.BaseVo;
import jp.mosp.common.common.MospConst;
import jp.mosp.common.common.MospUtility;
import jp.mosp.common.utils.DateUtil;
import jp.mosp.payroll.base.AdjustmentAction;
import jp.mosp.payroll.base.PayrollAction;
import jp.mosp.payroll.base.PayrollConst;
import jp.mosp.payroll.common.vo.InsuranceConfSetVo;

public class InsuranceConfSetAction extends AdjustmentAction {
	
	/**
	 * 画面表示コマンド
	 */
//	public static final String CMD_SHOW	= "P4001";
//	public static final String CMD_SET	= "P4002";
	
	/**
	 * Actionの初期化を行う。<br><br>
	 * 以下の処理を行う。
	 * <ul><li>
	 * {@link PayrollAction#PayrollAction()}
	 * </li></ul>
	 */
	public InsuranceConfSetAction() {
		super();
	}
	
	/* (non-Javadoc)
	 * @see jp.mosp.common.common.BaseAction#getSpecificVo()
	 */
	@Override
	protected BaseVo getSpecificVo() {
		return new InsuranceConfSetVo();
	}
	
	/**
	 * アクション
	 */
	public void action() throws Exception {
		// セッション保持情報の除去
		initStoredData();
		// DBコネクション取得
		getConnection();
		// VOの取得
		InsuranceConfSetVo vo;
		Object obj = session.getAttribute(MospConst.ATT_FORMER_VO);
		if (obj instanceof InsuranceConfSetVo) {
			vo = (InsuranceConfSetVo)obj;
		} else {
			vo = new InsuranceConfSetVo();
		}
		vo.initVo(cfg, msg, cmd, aspUser, user);
		vo.clearMessage();
		vo.clearErrField();
		storeVo(PayrollConst.VO_INSURANCECONF_SET, vo);
		// VO及びフォワード先URLの設定
		setVo(vo);
		setUrl(vo.getRetUrl());
		
		vo.aryEra = getCodeArray(PayrollConst.TID_JAPANESE); // 年号コードテーブル取得  
		vo.listConf = getConfList(PayrollConst.CONF_ID_JP_IMP_CAL); // 和暦テーブル設定取得
		
		Date dateTmp = DateUtil.convIntegerDateToDate((MospUtility.getYear(DateUtil.getSystemDate()) * 10000) + 401);
		vo.setSyoukyuTuki(dateTmp); // 昇（降）給年月初期値設定
		vo.setSyoukyuTukiJp(getJapaneseDate(dateTmp)); // 昇（降）給年月(和暦)設定
		
		// 適用年月初期値設定
		dateTmp = DateUtil.convIntegerDateToDate((MospUtility.getYear(DateUtil.getSystemDate()) * 10000) + 901);
		vo.setTekiyouNenGetu(dateTmp); // 適用年月(和暦)設定
		// 徴収開始月初期値設定
		dateTmp = DateUtil.convIntegerDateToDate((MospUtility.getYear(DateUtil.getSystemDate()) * 10000) + 1001);
		vo.setChousyuKaisiTukiStr(dateTmp); // 徴収開始月（和暦）設定
		vo.initFields(); // VOフィールド初期設定		
	}
}
