function verifyInput(){ 
    logger.info("Running sc-reference-number");
    
    let counterService = require('./CounterService');
    let deferred = q.defer();
    let tmpStr = field.format;

    let date = new Date();
    let YY = date.getFullYear().toString().substr(2, 3);
    YY = ("0" + YY).slice(-2);
    let MM = date.getMonth() + 1;
    MM = ("0" + MM).slice(-2);
    let DD = date.getDate();
    DD = ("0" + DD).slice(-2);

    tmpStr = tmpStr.replace("YY", YY);
    tmpStr = tmpStr.replace("MM", MM);
    tmpStr = tmpStr.replace("DD", DD);
    
    if (document[field.name]) {
        let msg = "Value exists, exit reference pre process";
        logger.info(msg);
        deferred.resolve(document);
    }
    else if (!field.counterFieldName || !field.counterDocumentId) {
        deferred.reject(new Error("Incorrect reference no. definition. Please add the counterDocumentId and counterFieldName"));
    } else {
        counterService.increase(field.counterDocumentId, field.counterFieldName, userId)
            .then(function successFunc(counterDocument) {
                if(!counterDocument[field.counterFieldName])
                    counterDocument[field.counterFieldName] = 0;
                
                tmpStr = tmpStr.replace("#", counterDocument[field.counterFieldName]);
                document[field.name] = tmpStr;

                deferred.resolve(document);
            }, function errorFunc(err) {
                deferred.reject(err);
            });
    }

    return deferred.promise;
}
module.exports = preProcessor;
