package nc.bs.obm.payroll.ace.rule;

import nc.impl.pubapp.pattern.rule.IRule;
import nc.vo.obm.payroll.DfgzBVO;
import nc.vo.obm.payroll.DfgzBillVO;
import nc.vo.obm.payroll.DfgzHVO;
import nc.vo.payroll.ml.MLPayroll;
import nc.vo.pub.ISuperVO;
import nc.vo.pubapp.pattern.exception.ExceptionUtils;
import nc.vo.trade.pub.IBillStatus;

/**
 * 提交前的单据状态检查
 * 
 * @since 6.0
 * @version 2011-7-7 下午03:52:07
 * @author duy
 */
public class AceCommitStatusCheckRule implements IRule<DfgzBillVO> {

    @Override
    public void process(DfgzBillVO[] vos) {
        for (DfgzBillVO vo : vos) {
        	DfgzHVO head = vo.getParentVO();
            if (!Integer.valueOf(IBillStatus.FREE).equals(head.getAttributeValue("vbillstatus"))) {
                ExceptionUtils.wrappBusinessException(MLPayroll.getStr00089()/*"单据状态不正确，不能提交！"*/);
            }
            
            /**
              * @version 2024-06-06
              * @author Yaoy
             */
            ISuperVO[] listDfgzBVO = vo.getChildren(DfgzBVO.class);
            for (int i = 0; i < listDfgzBVO.length; i++) {
            	DfgzBVO dfgzBVO = (DfgzBVO) listDfgzBVO[i];
				String crtaccname = dfgzBVO.getCrtaccname();
				String personname = dfgzBVO.getPersonname();
				if(!crtaccname.equals(personname)) {
					 ExceptionUtils.wrappBusinessException("行"+(i+1)+",员工姓名和户名不一致请检查!");
				}
			}
        }
    }
}
