package nc.bs.ic.m4a.sign;


import nc.bs.ic.general.rule.after.UpdateSCOnhandRule;
import nc.bs.ic.general.rule.before.InOutAuditDateCheck;
import nc.bs.ic.general.sign.ISignBP;
import nc.bs.ic.general.sign.ISignRuleProvider;
import nc.bs.ic.general.sign.SignBPTemplate;
import nc.bs.ic.m4a.base.BPPlugInPoint;
import nc.bs.ic.m4a.sign.rule.AfterSignRuleForFinanceProcess;
import nc.bs.ic.m4a.sign.rule.AfterSignRuleForLiabilityProcess;
import nc.bs.ic.m4a.sign.rule.AfterSignRuleSyncInToMesProcess;
import nc.bs.scmpub.rule.VOSagaFrozenValidateRule;
import nc.impl.pubapp.pattern.rule.processer.AroundProcesser;
import nc.vo.ic.m4a.entity.GeneralInVO;

public class SignBP implements ISignBP<GeneralInVO>, ISignRuleProvider<GeneralInVO> {

    public void addAfterRule(GeneralInVO[] vos, AroundProcesser<GeneralInVO> processor) {
        processor.addAfterRule(new UpdateSCOnhandRule(false, true));
        processor.addAfterRule(new AfterSignRuleForFinanceProcess());
        processor.addAfterRule(new AfterSignRuleForLiabilityProcess());
        processor.addAfterRule(new AfterSignRuleSyncInToMesProcess());
    }

    public void addBeforeRule(GeneralInVO[] vos, AroundProcesser<GeneralInVO> processor) {
        processor.addBeforeRule(new VOSagaFrozenValidateRule(true));
        processor.addBeforeRule(new InOutAuditDateCheck());
    }

    public GeneralInVO[] sign(GeneralInVO[] bills) {
        SignBPTemplate<GeneralInVO> insertBP = new SignBPTemplate(BPPlugInPoint.SignAction, this);
        GeneralInVO[] resultVOs = (GeneralInVO[]) insertBP.sign(bills);
        return resultVOs;
    }

}
