package jp.mosp.payroll.common.vo;

import java.sql.SQLException;
import java.util.Date;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import jp.mosp.common.common.MospException;
import jp.mosp.common.common.MospUtility;
import jp.mosp.common.dto.MosPConfDto;
import jp.mosp.common.utils.DateUtil;
import jp.mosp.human.dto.MKojinDto;
import jp.mosp.kintai.common.dto.MKihonDto;
import jp.mosp.legal.LegalConst;
import jp.mosp.payroll.base.CalculateAction;
import jp.mosp.payroll.base.PayrollConst;
import jp.mosp.payroll.bonus.dto.PhBounsDto;
import jp.mosp.payroll.dao.PdPayDeductionDao;
import jp.mosp.payroll.dto.CdAdjustmentDto;
import jp.mosp.payroll.dto.CmIncomeTaxDto;
import jp.mosp.payroll.dto.CmMidwayEnterDto;
import jp.mosp.payroll.dto.DetailMoneyDto;
import jp.mosp.payroll.dto.PhPaymentDto;

/**
 * @author koike
 *
 */
public class AdjustmentReferVo extends AdjustmentListVo {
	
	private static final long	serialVersionUID		= 8773622645784195759L;
	
	// URL、CSS
	private static final String	RETURN_URL				= "/jsp/payroll/common/adjustmentRefer.jsp";
	private static final String	EXTRA_JS				= "/pub/payroll/common/js/adjustmentRefer.js";
	private static final String	EXTRA_CSS				= "/pub/payroll/common/css/adjustmentRefer.css";
	
	// 画面サブタイトル
	public final String			SUB_TITLE				= PayrollConst.NAM_WITHHOLD_BOOK;
	
	public final String			CMD_MENU_PAYROLL		= "P1910";
	
	// フィールド名及び制限
	public static final String	PRM_TXT_CHANGE_K_CODE	= "txtChangeKCode";
	public static final String	PRM_LBL_CHANGE_K_CODE	= "lblChangeKCode";
	public static final String	PRM_HID_ADJUST_YEAR		= "hidAdjustYear";
	public static final String	PRM_HID_K_CODE			= "hidKCode";
	public static final String	PRM_HID_FAMILY_INFO		= "hidFamilyInfo";
	
	// 名称取得用配列
	public String[][]			aryStation;
	public String[][]			aryPosition;
	public String[][]			aryEra;
	public String[][]			aryRelation;
	public String[][]			aryGender;
	
	// 設定テーブル
	public List<MosPConfDto>	listConf;
	
	private int					cntPayment;
	private int					cntBonus;
	
	// フィールド
	private String				lblChangeKCode;
	private int					hidAdjustYear;
	private String				hidKCode;
	private String				lblKName;
	private String				lblStationCode;
	private String				lblStationName;
	private String				lblPositionCode;
	private String				lblPositionName;
	private String				lblEntranceDate;
	private String				lblAdjustStatus;
	
	private String				lblSelfSpHandi;
	private String				lblSelfHandicap;
	private String				lblSelfSpWidow;
	private String				lblSelfWidow;
	private String				lblSelfStudentType;
	
	/* 扶養控除等本人項目 */
	private String				lblSpHandicap;
	private String				lblGeHandicap;
	private String				lblGeWidow;
	private String				lblSpWidow;
	private String				lblWidow;
	private String				lblStudentGeneral;
	/* 扶養控除配偶者項目 */
	private String				lblLwSpHandiEl;
	private String				lblLwSpHandicap;
	private String				lblSpouseEl;
	private String				lblSpouseGe;
	
	private String				lblGeneralDependent;
	private String				lblSpecificDependent;
	private String				lblElderlyDependent;
	private String				lblLiveWithEldRel;
	private String				lblLiveWithHandiGe;
	private String				lblLiveWithHandiSp;
	private String				lblLiveWithHandiEl;
	private String				lblLiveWithHandiEr;
	private String				lblGeneralHandicap;
	private String				lblSpecificHandicap;
	
	private String				lblMidwayType;
	private String				lblFormerIncome;
	private String				lblFormerInsurance;
	private String				lblFormerTax;
	
	private String[]			lblPaymentMonth;
	private String[]			lblPaymentPayDay;
	private String[]			lblPayTotalAllowance;
	private String[]			lblPayTaxFree;
	private String[]			lblPayTaxation;															// 課税支給額
	private String[]			lblPaySocInsDeduction;
	private String[]			lblPayPayInsDeduction;
	private String[]			lblPayIncomeTax;
	private String[]			lblPayAdjCalcGap;															// 年調による過不足
	private String[]			lblPayVariousDeduction;
	private String[]			lblPayPaymentTotal;
	private String[]			lblPayDependentCount;
	private String[]			lblBonusMonth;
	private String[]			lblBonusPayDay;
	private String[]			lblBonTotalAllowance;
	private String[]			lblBonTaxFree;
	private String[]			lblBonTaxation;
	private String[]			lblBonSocInsDeduction;
	private String[]			lblBonPayInsDeduction;
	private String[]			lblBonIncomeTax;
	private String[]			lblBonVariousDeduction;
	private String[]			lblBonPaymentTotal;
	private String[]			lblBonDependentCount;
	private String[]			lblBonAdjCalcGap;															// 年調による過不足
																											
	private String				lblTotalAllowance;
	private String				lblTaxFree;
	private String				lblTaxation;
	private String				lblSocInsDeduction;
	private String				lblTotalPayInsDeduction;
	private String				lblIncomeTax;
	private String				lblVariousDeduction;
	private String				lblPaymentTotal;
	
	private String				lblGeneralLifeIns;															// 一般の生命保険料
	private String				lblPrivatePension;															// 個人年金保険料
	private String				lblLifeInsDeduction;														// 生命保険料控除額
	private String				lbLearthquakeIns;															// 地震保険料
	private String				lblLongTermDamageIns;														// 旧長期損害保険料
	private String				lblDamageInsDeduction;														// 損害保険料控除額
	private String				lblSocialInsDeduction;														// 社会保険料控除額
	private String				lblMutualAidDeduction;														// 小規模企業共済等掛金控除額
	private String				lblSpouseSumIncome;														// 配偶者の本年中の合計所得金額の見積額
	private String				lblSpouseSpDeduction;														// 配偶者特別控除額
	private String				lblHouseLoanDeduction;														// 住宅借入金等特別控除額
	private String				lblAllowanceAdjustment;													// 支給調整額
	private String				lblTaxFreeAdjustment;														// 非課税調整額
	private String				lblSocInsAdjustment;														// 社会保険調整額
	private String				lblTaxIncAdjustment;														// 所得税調整額
	private String				lblWithholdSlipNotes;														// 源泉徴収票摘要欄
	private String				lblPaymentAllowance;														// 給与、手当等金額
	private String				lblPaymentIncomeTax;														// 給与、手当等税額
	private String				lblBonusAllowance;															// 賞与等金額
	private String				lblBonusIncomeTax;															// 賞与等税額
	private String				lblMidwayAdjustIncome;														// 中途、調整収入金額
	private String				lblMidwayAdjustTax;														// 中途、調整収入税額
	private String				lblAfterDeductIncome;														// 給与所得控除後の給与等の金額
	private String				lblPayInsDeduction;														// 社会保険料等給与等からの控除分
	private String				lblDependentsDeduction;													// 配偶者控除額、扶養控除額、基礎控除額及び障害者等の控除額の合計額
	private String				lblCalcTaxedIncome;														// 差引課税給与所得金額
	private String				lblCalcIncomeTax;															// 算出年税額
	private String				lblAdjustedIncomeTax;														// 年調年税額
	private String				lblDeductedIncomeTax;														// 年調定率控除額税額
	private String				lblFinalIncomeTax;															// 年税額
	private String				lblIncomeDeductSum;														// 所得控除額計
	private String				lblTaxGap;																	// 差引税額取得
																											
	private String				lblAdjTotalAllowance;														// 支給金額合計
	private String				lblAdjTotalIncome;															// 所得税額合計
																											
	private String				lblIncomeTaxType;
	private String				lblAdjustmentType;
	
	private String				lblPostalCode;																// 郵便番号
	private String				lblAddress;																// 現住所
	private String				lblBirthDate;																// 生年月日
																											
	
	/**
	 * コンストラクタ
	 */
	public AdjustmentReferVo() {
		super();
		setRetUrl(RETURN_URL);
		setExtraJs(EXTRA_JS);
		setExtraCss(EXTRA_CSS);
		lblPaymentMonth = new String[PayrollConst.CNT_ADJ_PAYMENT_MONTH];
		lblPaymentPayDay = new String[PayrollConst.CNT_ADJ_PAYMENT_MONTH];
		lblPayTotalAllowance = new String[PayrollConst.CNT_ADJ_PAYMENT_MONTH];
		lblPayTaxFree = new String[PayrollConst.CNT_ADJ_PAYMENT_MONTH];
		lblPayTaxation = new String[PayrollConst.CNT_ADJ_PAYMENT_MONTH];
		lblPaySocInsDeduction = new String[PayrollConst.CNT_ADJ_PAYMENT_MONTH];
		lblPayPayInsDeduction = new String[PayrollConst.CNT_ADJ_PAYMENT_MONTH];
		lblPayIncomeTax = new String[PayrollConst.CNT_ADJ_PAYMENT_MONTH];
		lblPayAdjCalcGap = new String[PayrollConst.CNT_ADJ_PAYMENT_MONTH];
		lblPayVariousDeduction = new String[PayrollConst.CNT_ADJ_PAYMENT_MONTH];
		lblPayPaymentTotal = new String[PayrollConst.CNT_ADJ_PAYMENT_MONTH];
		lblPayDependentCount = new String[PayrollConst.CNT_ADJ_PAYMENT_MONTH];
		lblBonusMonth = new String[PayrollConst.CNT_ADJ_BONUS_MONTH];
		lblBonusPayDay = new String[PayrollConst.CNT_ADJ_BONUS_MONTH];
		lblBonTotalAllowance = new String[PayrollConst.CNT_ADJ_BONUS_MONTH];
		lblBonTaxFree = new String[PayrollConst.CNT_ADJ_BONUS_MONTH];
		lblBonTaxation = new String[PayrollConst.CNT_ADJ_BONUS_MONTH];
		lblBonSocInsDeduction = new String[PayrollConst.CNT_ADJ_BONUS_MONTH];
		lblBonPayInsDeduction = new String[PayrollConst.CNT_ADJ_BONUS_MONTH];
		lblBonIncomeTax = new String[PayrollConst.CNT_ADJ_BONUS_MONTH];
		lblBonAdjCalcGap = new String[PayrollConst.CNT_ADJ_BONUS_MONTH];
		lblBonVariousDeduction = new String[PayrollConst.CNT_ADJ_BONUS_MONTH];
		lblBonPaymentTotal = new String[PayrollConst.CNT_ADJ_BONUS_MONTH];
		lblBonDependentCount = new String[PayrollConst.CNT_ADJ_BONUS_MONTH];
	}
	
	/* (non-Javadoc)
	 * @see jp.mosp.payroll.base.PayrollVo#setSubTitle()
	 */
	/*
	@Override
	protected void setSubTitle() {
		super.setSubTitle();
		subTitle = SUB_TITLE;
		addAryMenu("P1001", getName("P_PAYMENT") +
				getName("P_CALCULATE") + getName("C_MENU") + getName("C_TO"));
	}
	*/
	/**
	 * パラメータ設定
	 * @param request リクエスト
	 */
	@Override
	public void setParams(HttpServletRequest request) {
		lblChangeKCode = request.getParameter(PRM_TXT_CHANGE_K_CODE);
		hidAdjustYear = getIntParam(request.getParameter(PRM_HID_ADJUST_YEAR));
		hidKCode = request.getParameter(PRM_HID_K_CODE);
	}
	
	/**
	 * フィールド設定(年末調整データ)
	 * @param uhBasisDto       フィールド取得対象DTO
	 * @param cmIncomeTaxDto   フィールド取得対象DTO
	 * @param cmMidwayEnterDto フィールド取得対象DTO
	 * @param listFamily       フィールド取得対象リスト
	 * @throws MospException 
	 */
	@Override
	public void setFields(CdAdjustmentDto cdAdjustmentDto) {
		if (cdAdjustmentDto != null) {
			lblAdjustStatus = getCodeName(cdAdjustmentDto.getAdjustStatus(), PayrollConst.getAdjuStatusArray());
			lblGeneralLifeIns = insertComma(String.valueOf(cdAdjustmentDto.getGeneralLifeIns()));
			lblPrivatePension = insertComma(String.valueOf(cdAdjustmentDto.getPrivatePension()));
			lblLifeInsDeduction = insertComma(String.valueOf(cdAdjustmentDto.getLifeInsDeduction()));
			lbLearthquakeIns = insertComma(String.valueOf(cdAdjustmentDto.getEarthquakeIns()));
			lblLongTermDamageIns = insertComma(String.valueOf(cdAdjustmentDto.getLongTermDamageIns()));
			lblDamageInsDeduction = insertComma(String.valueOf(cdAdjustmentDto.getDamageInsDeduction()));
			lblSocialInsDeduction = insertComma(String.valueOf(cdAdjustmentDto.getSocialInsDeduction()));
			lblMutualAidDeduction = insertComma(String.valueOf(cdAdjustmentDto.getMutualAidDeduction()));
			lblSpouseSumIncome = insertComma(String.valueOf(cdAdjustmentDto.getSpouseSumIncome()));
			lblSpouseSpDeduction = insertComma(String.valueOf(cdAdjustmentDto.getSpouseSpDeduction()));
			lblHouseLoanDeduction = insertComma(String.valueOf(cdAdjustmentDto.getHouseLoanDeduction()));
			lblAllowanceAdjustment = insertComma(String.valueOf(cdAdjustmentDto.getAllowanceAdjustment()));
			lblTaxFreeAdjustment = insertComma(String.valueOf(cdAdjustmentDto.getTaxFreeAdjustment()));
			lblSocInsAdjustment = insertComma(String.valueOf(cdAdjustmentDto.getSocInsAdjustment()));
			lblTaxIncAdjustment = insertComma(String.valueOf(cdAdjustmentDto.getTaxIncAdjustment()));
			lblWithholdSlipNotes = insertComma(String.valueOf(cdAdjustmentDto.getWithholdSlipNotes()));
			lblPaymentAllowance = insertComma(String.valueOf(cdAdjustmentDto.getPaymentAllowance()));
			lblPaymentIncomeTax = insertComma(String.valueOf(cdAdjustmentDto.getPaymentIncomeTax()));
			lblBonusAllowance = insertComma(String.valueOf(cdAdjustmentDto.getBonusAllowance()));
			lblBonusIncomeTax = insertComma(String.valueOf(cdAdjustmentDto.getBonusIncomeTax()));
			lblMidwayAdjustIncome = insertComma(String.valueOf(cdAdjustmentDto.getMidwayAdjustIncome()));
			lblMidwayAdjustTax = insertComma(String.valueOf(cdAdjustmentDto.getMidwayAdjustTax()));
			lblAfterDeductIncome = insertComma(String.valueOf(cdAdjustmentDto.getAfterDeductIncome()));
			lblPayInsDeduction = insertComma(String.valueOf(cdAdjustmentDto.getPayInsDeduction()));
			lblDependentsDeduction = insertComma(String.valueOf(cdAdjustmentDto.getDependentsDeduction()));
			lblCalcTaxedIncome = insertComma(String.valueOf(cdAdjustmentDto.getCalcTaxedIncome()));
			lblCalcIncomeTax = insertComma(String.valueOf(cdAdjustmentDto.getCalcIncomeTax()));
			lblAdjustedIncomeTax = insertComma(String.valueOf(cdAdjustmentDto.getAdjustedIncomeTax()));
			lblDeductedIncomeTax = insertComma(String.valueOf(cdAdjustmentDto.getDeductedIncomeTax()));
			lblFinalIncomeTax = insertComma(String.valueOf(cdAdjustmentDto.getFinalIncomeTax()));
			lblIncomeDeductSum = insertComma(String.valueOf(cdAdjustmentDto.getIncomeDeductSum()));
			lblTaxGap = insertComma(String.valueOf(cdAdjustmentDto.getTaxGap()));
			lblAdjTotalAllowance = insertComma(String.valueOf(cdAdjustmentDto.getTaxedPaymentSum()));
			lblAdjTotalIncome = insertComma(String.valueOf(cdAdjustmentDto.getIncomeTaxSum()));
		} else {
			// 年末調整データが存在しない場合はデータ未作成
			lblAdjustStatus = PayrollConst.ADJU_STATUS_NON_NAME;
		}
		
	}
	
	/**
	 * フィールド設定(給与、賞与情報)
	 * @param listPaymentData	フィールド取得対象給与DTOリスト
	 * @param pdPayDeductionDao	フィールド住民税取得用DAO（給与明細データ）
	 * @param listBonusData		フィールド取得対象賞与DTOリスト
	 * @param currentPayDto		フィールド取得対象給与DTO
	 * @param currentBonDto		フィールド取得対象賞与DTO
	 * @param cdAdjustmentDto	フィールド取得対象年末調整DTO
	 * @throws IllegalAccessException 
	 * @throws NoSuchFieldException 
	 * @throws SQLException 
	 * @throws MospException 
	 */
	public void setFields(List<PhPaymentDto> listPaymentData, List<PhBounsDto> listBonusData,
			PdPayDeductionDao pdPayDeductionDao, PhPaymentDto currentPayDto, PhBounsDto currentBonDto,
			CdAdjustmentDto cdAdjustmentDto) throws SQLException, NoSuchFieldException, IllegalAccessException {
		
		DetailMoneyDto pdPayDeductionDto;
		cntPayment = listPaymentData.size();
		cntBonus = listBonusData.size();
		
		int totalAllowance = 0;
		int taxFree = 0;
		int taxation = 0;
		int socInsDeduction = 0;
		int payInsDeduction = 0;
		int incomeTax = 0;
		int variousDeduction = 0;
		int paymentTotal = 0;
		int restaxTmp = 0; // 住民税取得用
		
		for (int i = 0; i < PayrollConst.CNT_ADJ_PAYMENT_MONTH; i++) {
			if (i < listPaymentData.size()) {
				PhPaymentDto phPaymentDto = listPaymentData.get(i);
				lblPaymentMonth[i] = String.valueOf(MospUtility.getMonth(phPaymentDto.getPayDate()));
				lblPaymentPayDay[i] = String.valueOf(MospUtility.getDay(phPaymentDto.getPayDate()));
				lblPayTotalAllowance[i] = String.valueOf(phPaymentDto.getAllowanceTotal());
				lblPayTaxFree[i] = String.valueOf(phPaymentDto.getTaxExempt());
				lblPayTaxation[i] = String.valueOf(phPaymentDto.getAmountToTaxation() + phPaymentDto.getSocInsTotal());
				lblPaySocInsDeduction[i] = String.valueOf(phPaymentDto.getSocInsTotal());
				lblPayPayInsDeduction[i] = String.valueOf(phPaymentDto.getAmountToTaxation());
				lblPayDependentCount[i] = String.valueOf(phPaymentDto.getDependent());
				
				// 所得税設定
				lblPayIncomeTax[i] = String.valueOf(phPaymentDto.getIncomeTax());
				lblPayAdjCalcGap[i] = "";
				if (currentPayDto != null) {
					if (currentPayDto.getCalcMonth().compareTo(phPaymentDto.getCalcMonth()) == 0) {
						if (cdAdjustmentDto != null) {
							lblPayAdjCalcGap[i] = String.valueOf(cdAdjustmentDto.getTaxGap());
						} else {
							lblPayAdjCalcGap[i] = "";
						}
					}
				}
				
				//住民税取得
				restaxTmp = 0;
				pdPayDeductionDto = pdPayDeductionDao.findForDetail(phPaymentDto.getKCode(), phPaymentDto
					.getCalcMonth(), PayrollConst.DTL_RESIDENCE_TAX);
				if (pdPayDeductionDto != null) {
					restaxTmp = pdPayDeductionDto.getAmount();
				}
				lblPayVariousDeduction[i] = String.valueOf(
				// 諸控除額 = 総控除額−所得税額−住民税−社会保険料
					phPaymentDto.getDeductionTotal() - phPaymentDto.getIncomeTax() - restaxTmp
							- phPaymentDto.getSocInsTotal());
				lblPayPaymentTotal[i] = String.valueOf(phPaymentDto.getPaymentTotal());
				
				// 合計値設定
				totalAllowance += getIntParam(lblPayTotalAllowance[i]);
				taxFree += getIntParam(lblPayTaxFree[i]);
				taxation += getIntParam(lblPayTaxation[i]);
				socInsDeduction += getIntParam(lblPaySocInsDeduction[i]);
				payInsDeduction += getIntParam(lblPayPayInsDeduction[i]);
				incomeTax += getIntParam(lblPayIncomeTax[i]);
				variousDeduction += getIntParam(lblPayVariousDeduction[i]);
				paymentTotal += getIntParam(lblPayPaymentTotal[i]);
			} else {
				lblPaymentMonth[i] = "";
				lblPaymentPayDay[i] = "";
				lblPayTotalAllowance[i] = "";
				lblPayTaxFree[i] = "";
				lblPayTaxation[i] = "";
				lblPaySocInsDeduction[i] = "";
				lblPayPayInsDeduction[i] = "";
				lblPayDependentCount[i] = "";
				lblPayIncomeTax[i] = "";
				lblPayAdjCalcGap[i] = "";
				lblPayVariousDeduction[i] = "";
				lblPayPaymentTotal[i] = "";
			}
		}
		
		for (int i = 0; i < PayrollConst.CNT_ADJ_BONUS_MONTH; i++) {
			if (i < listBonusData.size()) {
				PhBounsDto udBonusDto = listBonusData.get(i);
				lblBonusMonth[i] = String.valueOf(MospUtility.getMonth(udBonusDto.getPayDate()));
				lblBonusPayDay[i] = String.valueOf(MospUtility.getDay(udBonusDto.getPayDate()));
				lblBonTotalAllowance[i] = String.valueOf(udBonusDto.getAllowanceTotal());
				lblBonTaxFree[i] = String.valueOf(0);
				lblBonTaxation[i] = String.valueOf(udBonusDto.getAllowanceTotal());
				lblBonSocInsDeduction[i] = String.valueOf(udBonusDto.getSocInsTotal());
				lblBonPayInsDeduction[i] = String.valueOf(udBonusDto.getAllowanceTotal() - udBonusDto.getSocInsTotal());
				lblBonDependentCount[i] = String.valueOf(udBonusDto.getDependent());
				
				// 所得税設定
				lblBonIncomeTax[i] = String.valueOf(udBonusDto.getIncomeTax());
				lblBonAdjCalcGap[i] = "";
				if (currentBonDto != null) {
					if (currentBonDto.getPayDate().compareTo(udBonusDto.getPayDate()) == 0) {
						lblBonIncomeTax[i] = String.valueOf(currentBonDto.getIncomeTax());
						if (cdAdjustmentDto != null) {
							lblBonAdjCalcGap[i] = String.valueOf(cdAdjustmentDto.getTaxGap());
						} else {
							lblBonAdjCalcGap[i] = "";
						}
					}
				}
				// 諸控除額 = 総控除額−所得税額−住民税−社会保険料
				lblBonVariousDeduction[i] = String.valueOf(udBonusDto.getDeductionTotal() - udBonusDto.getIncomeTax()
						- udBonusDto.getSocInsTotal());
				
				lblBonPaymentTotal[i] = String.valueOf(udBonusDto.getPaymentTotal());
				
				// 合計値設定
				totalAllowance += getIntParam(lblBonTotalAllowance[i]);
				taxFree += 0;
				taxation += getIntParam(lblBonTaxation[i]);
				socInsDeduction += getIntParam(lblBonSocInsDeduction[i]);
				payInsDeduction += getIntParam(lblBonPayInsDeduction[i]);
				incomeTax += getIntParam(lblBonIncomeTax[i]);
				variousDeduction += getIntParam(lblBonVariousDeduction[i]);
				paymentTotal += getIntParam(lblBonPaymentTotal[i]);
			} else {
				lblBonusMonth[i] = "";
				lblBonusPayDay[i] = "";
				lblBonTotalAllowance[i] = "";
				lblBonTaxFree[i] = "";
				lblBonTaxation[i] = "";
				lblBonSocInsDeduction[i] = "";
				lblBonPayInsDeduction[i] = "";
				lblBonDependentCount[i] = "";
				lblBonIncomeTax[i] = "";
				lblBonAdjCalcGap[i] = "";
				lblBonVariousDeduction[i] = "";
				lblBonPaymentTotal[i] = "";
			}
		}
		
		lblTotalAllowance = String.valueOf(totalAllowance);
		lblTaxFree = String.valueOf(taxFree);
		lblTaxation = String.valueOf(taxation);
		lblSocInsDeduction = String.valueOf(socInsDeduction);
		lblTotalPayInsDeduction = String.valueOf(payInsDeduction);
		lblIncomeTax = String.valueOf(incomeTax);
		lblVariousDeduction = String.valueOf(variousDeduction);
		lblPaymentTotal = String.valueOf(paymentTotal);
		
	}
	
	/**
	 * フィールド設定
	 * @param uhBasisDto       フィールド取得対象DTO
	 * @param cmIncomeTaxDto   フィールド取得対象DTO
	 * @param cmMidwayEnterDto フィールド取得対象DTO
	 * @param listFamily       フィールド取得対象リスト
	 * @throws MospException 
	 */
	public void setFields(MKihonDto mKihonDto, CmIncomeTaxDto cmIncomeTaxDto, CmMidwayEnterDto cmMidwayEnterDto,
			MKojinDto mKojinDto) throws MospException {
		// データの設定
		if (mKihonDto != null) {
			lblChangeKCode = mKihonDto.getKCode();
			hidKCode = mKihonDto.getKCode();
			lblKName = mKihonDto.getSimei();
			lblStationCode = mKihonDto.getSCode();
			lblStationName = getCodeName(lblStationCode, aryStation);
			lblPositionCode = mKihonDto.getYCode();
			lblPositionName = getCodeName(lblPositionCode, aryPosition);
			lblEntranceDate = getDateString(listConf, aryEra, DateUtil.convIntegerDateToDate(mKihonDto.getNyDate()));
		}
		
		// 本人区分を見て判断しアスタリスクを設定		
		if (cmIncomeTaxDto != null) {
			String handicapType = cmIncomeTaxDto.getSelfHandicapType();
			String widowType = cmIncomeTaxDto.getSelfWidowType();
			String studentType = cmIncomeTaxDto.getSelfStudentType();
			
			if (handicapType.equals(LegalConst.HANDICAP_GENERAL)) {
				// 一般障害者
				lblGeHandicap = PayrollConst.ADJ_APPLICABLE;
			} else if (handicapType.equals(LegalConst.HANDICAP_SPECIAL)) {
				// 特別障害者
				lblSpHandicap = PayrollConst.ADJ_APPLICABLE;
			}
			// 寡婦(夫)の場合は性別で判断して設定、設定なしの場合は一般寡婦へ
			if (widowType.equals(LegalConst.WIDOW_GENERAL)) {
				lblWidow = PayrollConst.ADJ_APPLICABLE; // 現在は寡夫（夫）のみ
				
			} else if (widowType.equals(LegalConst.WIDOW_SPECIAL)) {
				// 特別寡婦
				lblSpWidow = PayrollConst.ADJ_APPLICABLE;
			}
			// 本人区分が勤労学生
			if (studentType.equals(LegalConst.STUDENT_GENERAL)) {
				lblStudentGeneral = PayrollConst.ADJ_APPLICABLE;
			}
			lblIncomeTaxType = getCodeName(cmIncomeTaxDto.getIncomeTaxType(), LegalConst.INCOME_TAX_ARRAY);
			lblAdjustmentType = getCodeName(cmIncomeTaxDto.getAdjustmentType(), LegalConst.ADJUSTMENT_ARRAY);
			
			String spouseType = cmIncomeTaxDto.getSpouseIntendType();
			// 配偶者区分が同居特別障害者老人
			if (spouseType.equals(LegalConst.SPOUSE_INTEND_LWSH_EL)) {
				lblLwSpHandiEl = PayrollConst.ADJ_APPLICABLE;
			}
			// 配偶者区分が同居特別障害者
			if (spouseType.equals(LegalConst.SPOUSE_INTEND_LWSH)) {
				lblLwSpHandicap = PayrollConst.ADJ_APPLICABLE;
			}
			// 配偶者区分が老人配偶者
			if (spouseType.equals(LegalConst.SPOUSE_INTEND_ELDERLY)) {
				lblSpouseEl = PayrollConst.ADJ_APPLICABLE;
			}
			// 配偶者区分が老人配偶者
			if (spouseType.equals(LegalConst.SPOUSE_INTEND_GENERAL)) {
				lblSpouseGe = PayrollConst.ADJ_APPLICABLE;
			}
			
			lblSelfStudentType = getCodeName(cmIncomeTaxDto.getSelfStudentType(), LegalConst.STUDENT_ARRAY);
			lblGeneralDependent = cmIncomeTaxDto.getGeneralDependent() + PayrollConst.NAM_COMMON_CNT1;
			lblSpecificDependent = cmIncomeTaxDto.getSpecificDependent() + PayrollConst.NAM_COMMON_CNT1;
			lblElderlyDependent = cmIncomeTaxDto.getElderlyDependent() + PayrollConst.NAM_COMMON_CNT1;
			lblLiveWithEldRel = cmIncomeTaxDto.getLiveWithEldRel() + PayrollConst.NAM_COMMON_CNT1;
			lblLiveWithHandiGe = cmIncomeTaxDto.getLiveWithHandiGe() + PayrollConst.NAM_COMMON_CNT1;
			lblLiveWithHandiSp = cmIncomeTaxDto.getLiveWithHandiSp() + PayrollConst.NAM_COMMON_CNT1;
			lblLiveWithHandiEl = cmIncomeTaxDto.getLiveWithHandiEl() + PayrollConst.NAM_COMMON_CNT1;
			lblLiveWithHandiEr = cmIncomeTaxDto.getLiveWithHandiEr() + PayrollConst.NAM_COMMON_CNT1;
			lblGeneralHandicap = cmIncomeTaxDto.getGeneralHandicap() + PayrollConst.NAM_COMMON_CNT1;
			lblSpecificHandicap = cmIncomeTaxDto.getSpecificHandicap() + PayrollConst.NAM_COMMON_CNT1;
		}
		lblMidwayType = "";
		lblFormerIncome = "";
		lblFormerInsurance = "";
		lblFormerTax = "";
		if (cmMidwayEnterDto != null) {
			if (mKihonDto != null) {
				if (mKihonDto.getNyDate() != 0) {
					// 入社日が対象年
					if (MospUtility.getYear(DateUtil.convIntegerDateToDate(mKihonDto.getNyDate())) == hidAdjustYear) {
						// 中途入社区分が「中途入社」である場合、金額を設定
						if (cmMidwayEnterDto.getMidwayType().equals(LegalConst.MIDWAY_ENTER)) {
							lblMidwayType = getCodeName(cmMidwayEnterDto.getMidwayType(), LegalConst.MIDWAY_ENTER_ARRAY);
							lblFormerIncome = String.valueOf(cmMidwayEnterDto.getFormerIncome());
							lblFormerInsurance = String.valueOf(cmMidwayEnterDto.getFormerInsurance());
							lblFormerTax = String.valueOf(cmMidwayEnterDto.getFormerTax());
						}
					}
				}
			}
		}
		if (mKojinDto != null) {
			lblAddress = CalculateAction.getPrefecture(mKojinDto.getPrefectures()) + mKojinDto.getJyuusyo1()
					+ mKojinDto.getJyuusyo2() + mKojinDto.getJyuusyo3();
			lblBirthDate = getDateString(listConf, aryEra, DateUtil.convIntegerDateToDate(mKojinDto.getSeinenbi()));
			lblPostalCode = mKojinDto.getYubinban();
		}
	}
	
	/**
	 * JavaScript設定
	 * @param cls 情報取得クラス
	 * @throws IllegalAccessException
	 */
	@Override
	public String getDirectJs(Class cls) throws IllegalAccessException {
		StringBuffer sb = new StringBuffer();
		sb.append(super.getDirectJs(cls));
		return sb.toString();
	}
	
	/**
	 * 日付文字列取得(和暦)
	 * @param list 和暦情報リスト
	 * @param date 日
	 * @return 日付文字列
	 * @throws MospException
	 */
	@Override
	protected String getDateString(List<MosPConfDto> list, String[][] aryEra, Date date) throws MospException {
		if (date == null || list == null) {
			return "";
		}
		String[] strDate = getJpImperialCal(list, date);
		strDate[0] = getCodeName(strDate[0], aryEra);
		for (int i = 1; i < strDate.length; i++) {
			strDate[i] = strDate[i].length() < 2 ? PayrollConst.SUPPRESS_DATE + strDate[i] : strDate[i];
		}
		return strDate[0] + strDate[1] + PayrollConst.NAM_YEAR + strDate[2] + PayrollConst.NAM_MONTH + strDate[3]
				+ PayrollConst.NAM_DAY;
	}
	
	// アクセサメソッド
	public String getLblChangeKCode() {
		return escapeHTML(lblChangeKCode);
	}
	
	@Override
	public int getHidAdjustYear() {
		return hidAdjustYear;
	}
	
	@Override
	public String getHidKCode() {
		return escapeHTML(hidKCode);
	}
	
	public String getEscLblChangeKCode() {
		return escapeHTML(lblChangeKCode);
	}
	
	@Override
	public String getEscHidKCode() {
		return escapeHTML(hidKCode);
	}
	
	@Override
	public String getEscLblKName() {
		return escapeHTML(lblKName);
	}
	
	@Override
	public String getEscLblStationCode() {
		return escapeHTML(lblStationCode);
	}
	
	@Override
	public String getEscLblStationName() {
		return escapeHTML(lblStationName);
	}
	
	@Override
	public String getEscLblPositionCode() {
		return escapeHTML(lblPositionCode);
	}
	
	@Override
	public String getEscLblPositionName() {
		return escapeHTML(lblPositionName);
	}
	
	@Override
	public String getEsclblEntranceDate() {
		return escapeHTML(lblEntranceDate);
	}
	
	@Override
	public String getEscLblAdjustStatus() {
		return escapeHTML(lblAdjustStatus);
	}
	
	public String getLblPaymentMonth(int i) {
		return escapeHTML(lblPaymentMonth[i]);
	}
	
	public String getLblPaymentPayDay(int i) {
		return escapeHTML(lblPaymentPayDay[i]);
	}
	
	public String getLblPayTotalAllowance(int i) {
		return escapeHTML(insertComma(lblPayTotalAllowance[i]));
	}
	
	public String getLblPayTaxFree(int i) {
		return escapeHTML(insertComma(lblPayTaxFree[i]));
	}
	
	public String getLblPayTaxation(int i) {
		return escapeHTML(insertComma(lblPayTaxation[i]));
	}
	
	public String getLblPaySocInsDeduction(int i) {
		return escapeHTML(insertComma(lblPaySocInsDeduction[i]));
	}
	
	public String getLblPayPayInsDeduction(int i) {
		return escapeHTML(insertComma(lblPayPayInsDeduction[i]));
	}
	
	public String getLblPayIncomeTax(int i) {
		return escapeHTML(insertComma(lblPayIncomeTax[i]));
	}
	
	public String getLblPayVariousDeduction(int i) {
		return escapeHTML(insertComma(lblPayVariousDeduction[i]));
	}
	
	public String getLblPayPaymentTotal(int i) {
		return escapeHTML(insertComma(lblPayPaymentTotal[i]));
	}
	
	public String getLblPayDependentCount(int i) {
		return escapeHTML(insertComma(lblPayDependentCount[i]));
	}
	
	public String getLblBonusMonth(int i) {
		return escapeHTML(insertComma(lblBonusMonth[i]));
	}
	
	public String getLblBonusPayDay(int i) {
		return escapeHTML(insertComma(lblBonusPayDay[i]));
	}
	
	public String getLblBonTotalAllowance(int i) {
		return escapeHTML(insertComma(lblBonTotalAllowance[i]));
	}
	
	public String getLblBonTaxFree(int i) {
		return escapeHTML(insertComma(lblBonTaxFree[i]));
	}
	
	public String getLblBonTaxation(int i) {
		return escapeHTML(insertComma(lblBonTaxation[i]));
	}
	
	public String getLblBonSocInsDeduction(int i) {
		return escapeHTML(insertComma(lblBonSocInsDeduction[i]));
	}
	
	public String getLblBonPayInsDeduction(int i) {
		return escapeHTML(insertComma(lblBonPayInsDeduction[i]));
	}
	
	public String getLblBonIncomeTax(int i) {
		return escapeHTML(insertComma(lblBonIncomeTax[i]));
	}
	
	public String getLblBonVariousDeduction(int i) {
		return escapeHTML(insertComma(lblBonVariousDeduction[i]));
	}
	
	public String getLblBonPaymentTotal(int i) {
		return escapeHTML(insertComma(lblBonPaymentTotal[i]));
	}
	
	public String getLblBonDependentCount(int i) {
		return escapeHTML(insertComma(lblBonDependentCount[i]));
	}
	
	public String getLblPayAdjCalcGap(int i) {
		return escapeHTML(lblPayAdjCalcGap[i]);
	}
	
	public String getLblBonAdjCalcGap(int i) {
		return escapeHTML(lblBonAdjCalcGap[i]);
	}
	
	public String getEscLblGeneralLifeIns() {
		return escapeHTML(lblGeneralLifeIns);
	}
	
	public String getEscLblPrivatePension() {
		return escapeHTML(lblPrivatePension);
	}
	
	public String getEscLblLifeInsDeduction() {
		return escapeHTML(lblLifeInsDeduction);
	}
	
	public String getEscLblearthquakeIns() {
		return escapeHTML(lbLearthquakeIns);
	}
	
	public String getEscLblLongTermDamageIns() {
		return escapeHTML(lblLongTermDamageIns);
	}
	
	public String getEscLblDamageInsDeduction() {
		return escapeHTML(lblDamageInsDeduction);
	}
	
	public String getEscLblSocialInsDeduction() {
		return escapeHTML(lblSocialInsDeduction);
	}
	
	public String getEscLblMutualAidDeduction() {
		return escapeHTML(lblMutualAidDeduction);
	}
	
	public String getEscLblSpouseSumIncome() {
		return escapeHTML(lblSpouseSumIncome);
	}
	
	public String getEscLblSpouseSpDeduction() {
		return escapeHTML(lblSpouseSpDeduction);
	}
	
	public String getEscLblHouseLoanDeduction() {
		return escapeHTML(lblHouseLoanDeduction);
	}
	
	public String getEscLblAllowanceAdjustment() {
		return escapeHTML(lblAllowanceAdjustment);
	}
	
	public String getEscLblTaxFreeAdjustment() {
		return escapeHTML(lblTaxFreeAdjustment);
	}
	
	public String getEscLblSocInsAdjustment() {
		return escapeHTML(lblSocInsAdjustment);
	}
	
	public String getEscLblTaxIncAdjustment() {
		return escapeHTML(lblTaxIncAdjustment);
	}
	
	public String getEscLblWithholdSlipNotes() {
		return escapeHTML(lblWithholdSlipNotes);
	}
	
	public String getEscLblPaymentAllowance() {
		return escapeHTML(lblPaymentAllowance);
	}
	
	public String getEscLblPaymentIncomeTax() {
		return escapeHTML(lblPaymentIncomeTax);
	}
	
	public String getEscLblBonusAllowance() {
		return escapeHTML(lblBonusAllowance);
	}
	
	public String getEscLblBonusIncomeTax() {
		return escapeHTML(lblBonusIncomeTax);
	}
	
	public String getEscLblMidwayAdjustIncome() {
		return escapeHTML(lblMidwayAdjustIncome);
	}
	
	public String getEscLblMidwayAdjustTax() {
		return escapeHTML(lblMidwayAdjustTax);
	}
	
	public String getEscLblAfterDeductIncome() {
		return escapeHTML(lblAfterDeductIncome);
	}
	
	public String getEscLblPayInsDeduction() {
		return escapeHTML(lblPayInsDeduction);
	}
	
	public String getEscLblDependentsDeduction() {
		return escapeHTML(lblDependentsDeduction);
	}
	
	public String getEscLblCalcTaxedIncome() {
		return escapeHTML(lblCalcTaxedIncome);
	}
	
	public String getEscLblCalcIncomeTax() {
		return escapeHTML(lblCalcIncomeTax);
	}
	
	public String getEscLblAdjustedIncomeTax() {
		return escapeHTML(lblAdjustedIncomeTax);
	}
	
	public String getEscLblDeductedIncomeTax() {
		return escapeHTML(lblDeductedIncomeTax);
	}
	
	public String getEscLblFinalIncomeTax() {
		return escapeHTML(lblFinalIncomeTax);
	}
	
	public String getEscLblTaxGap() {
		return escapeHTML(lblTaxGap);
	}
	
	public String getEscLblAdjTotalAllowance() {
		return escapeHTML(lblAdjTotalAllowance);
	}
	
	public String getEscLblAdjTotalIncome() {
		return escapeHTML(lblAdjTotalIncome);
	}
	
	public String getEscLblSpHandicap() {
		return escapeHTML(lblSpHandicap);
	}
	
	public String getEscLblGeHandicap() {
		return escapeHTML(lblGeHandicap);
	}
	
	public String getEscLblGeWidow() {
		return escapeHTML(lblGeWidow);
	}
	
	public String getEscLblSpWidow() {
		return escapeHTML(lblSpWidow);
	}
	
	public String getEscLblWidow() {
		return escapeHTML(lblWidow);
	}
	
	public String getEscLblStudentGeneral() {
		return escapeHTML(lblStudentGeneral);
	}
	
	public String getEscLblTotalAllowance() {
		return escapeHTML(insertComma(lblTotalAllowance));
	}
	
	public String getEscLblTaxFree() {
		return escapeHTML(insertComma(lblTaxFree));
	}
	
	public String getEscLblTaxation() {
		return escapeHTML(insertComma(lblTaxation));
	}
	
	public String getEscLblSocInsDeduction() {
		return escapeHTML(insertComma(lblSocInsDeduction));
	}
	
	public String getEscLblTotalPayInsDeduction() {
		return escapeHTML(insertComma(lblTotalPayInsDeduction));
	}
	
	public String getEscLblIncomeTax() {
		return escapeHTML(insertComma(lblIncomeTax));
	}
	
	public String getEscLblIncomeDeductSum() {
		return escapeHTML(insertComma(lblIncomeDeductSum));
	}
	
	public String getEscLblVariousDeduction() {
		return escapeHTML(insertComma(lblVariousDeduction));
	}
	
	public String getEscLblPaymentTotal() {
		return escapeHTML(insertComma(lblPaymentTotal));
	}
	
	public String getEscLblSelfSpHandi() {
		return escapeHTML(lblSelfSpHandi);
	}
	
	public String getEscLblSelfHandicap() {
		return escapeHTML(lblSelfHandicap);
	}
	
	public String getEscLblSelfSpWidow() {
		return escapeHTML(lblSelfSpWidow);
	}
	
	public String getEscLblSelfWidow() {
		return escapeHTML(lblSelfWidow);
	}
	
	@Override
	public String getEscLblSelfStudentType() {
		return escapeHTML(lblSelfStudentType);
	}
	
	public String getEscLblLwSpHandiEl() {
		return escapeHTML(lblLwSpHandiEl);
	}
	
	public String getEscLblLwSpHandicap() {
		return escapeHTML(lblLwSpHandicap);
	}
	
	public String getEscLblSpouseEl() {
		return escapeHTML(lblSpouseEl);
	}
	
	public String getEscLblSpouseGe() {
		return escapeHTML(lblSpouseGe);
	}
	
	@Override
	public String getEscLblGeneralDependent() {
		return escapeHTML(lblGeneralDependent);
	}
	
	@Override
	public String getEscLblSpecificDependent() {
		return escapeHTML(lblSpecificDependent);
	}
	
	@Override
	public String getEscLblElderlyDependent() {
		return escapeHTML(lblElderlyDependent);
	}
	
	@Override
	public String getEscLblLiveWithEldRel() {
		return escapeHTML(lblLiveWithEldRel);
	}
	
	@Override
	public String getEscLblLiveWithHandiGe() {
		return escapeHTML(lblLiveWithHandiGe);
	}
	
	@Override
	public String getEscLblLiveWithHandiSp() {
		return escapeHTML(lblLiveWithHandiSp);
	}
	
	@Override
	public String getEscLblLiveWithHandiEl() {
		return escapeHTML(lblLiveWithHandiEl);
	}
	
	@Override
	public String getEscLblLiveWithHandiEr() {
		return escapeHTML(lblLiveWithHandiEr);
	}
	
	@Override
	public String getEscLblGeneralHandicap() {
		return escapeHTML(lblGeneralHandicap);
	}
	
	@Override
	public String getEscLblSpecificHandicap() {
		return escapeHTML(lblSpecificHandicap);
	}
	
	@Override
	public String getEscLblMidwayType() {
		return escapeHTML(lblMidwayType);
	}
	
	@Override
	public String getEscLblFormerIncome() {
		return escapeHTML(insertComma(lblFormerIncome));
	}
	
	@Override
	public String getEscLblFormerInsurance() {
		return escapeHTML(insertComma(lblFormerInsurance));
	}
	
	@Override
	public String getEscLblFormerTax() {
		return escapeHTML(insertComma(lblFormerTax));
	}
	
	public String getEscLblPostalCode() {
		return escapeHTML(lblPostalCode);
	} // 郵便番号
	
	public String getEscLblAddress() {
		return escapeHTML(lblAddress);
	} // 現住所
	
	public String getEscLblBirthDate() {
		return escapeHTML(lblBirthDate);
	} // 生年月日
	
	@Override
	public String getEscLblIncomeTaxType() {
		return escapeHTML(lblIncomeTaxType);
	}
	
	@Override
	public String getEscLblAdjustmentType() {
		return escapeHTML(lblAdjustmentType);
	}
	
	public void setLblChangeKCode(String lblChangeKCode) {
		this.lblChangeKCode = lblChangeKCode;
	}
	
	@Override
	public void setHidAdjustYear(int hidAdjustYear) {
		this.hidAdjustYear = hidAdjustYear;
	}
	
	/**
	 * 
	 * @return
	 */
	public int getCntPayment() {
		return cntPayment;
	}
	
	public int getCntBonus() {
		return cntBonus;
	}
	
}
