class VoucherSubTypeRepository {

    @Transactional
    public List<VoucherSubType> update(List<VoucherSubType> voucherSubTypes,
            RequestInfo requestInfo) {

        ModelMapper mapper = new ModelMapper();
        VoucherSubTypeContract contract;

        if (persistThroughKafka != null && !persistThroughKafka.isEmpty()
                && persistThroughKafka.equalsIgnoreCase("yes")) {

            VoucherSubTypeRequest request = new VoucherSubTypeRequest();
            request.setRequestInfo(requestInfo);
            request.setVoucherSubTypes(new ArrayList<>());

            for (VoucherSubType f : voucherSubTypes) {

                contract = new VoucherSubTypeContract();
                contract.setCreatedDate(new Date());
                mapper.map(f, contract);
                request.getVoucherSubTypes().add(contract);

            }

            addToQue(request);

            return voucherSubTypes;
        } else {

            List<VoucherSubType> resultList = new ArrayList<VoucherSubType>();

            for (VoucherSubType f : voucherSubTypes) {

                resultList.add(update(f));
            }

            VoucherSubTypeRequest request = new VoucherSubTypeRequest();
            request.setRequestInfo(requestInfo);
            request.setVoucherSubTypes(new ArrayList<>());

            for (VoucherSubType f : resultList) {

                contract = new VoucherSubTypeContract();
                contract.setCreatedDate(new Date());
                mapper.map(f, contract);
                request.getVoucherSubTypes().add(contract);

            }

            addToSearchQueue(request);

            return resultList;
        }

    }

    @Autowired public  VoucherSubTypeRepository(
            VoucherSubTypeJdbcRepository voucherSubTypeJdbcRepository,
            FinancialConfigurationContractRepository financialConfigurationContractRepository,
            VoucherSubTypeESRepository voucherSubTypeESRepository,
            VoucherSubTypeQueueRepository voucherSubTypeQueueRepository,
            @Value("${persist.through.kafka}") String persistThroughKafka);

}