class VoucherSubTypeController {

    @PostMapping("/_create")
    @ResponseStatus(HttpStatus.CREATED)
    public VoucherSubTypeResponse create(
            @RequestBody VoucherSubTypeRequest voucherSubTypeRequest,
            BindingResult errors) {

        ModelMapper model = new ModelMapper();
        VoucherSubTypeResponse voucherSubTypeResponse = new VoucherSubTypeResponse();
        voucherSubTypeResponse
                .setResponseInfo(getResponseInfo(voucherSubTypeRequest
                        .getRequestInfo()));
        List<VoucherSubType> voucherSubTypes = new ArrayList<>();
        VoucherSubType voucherSubType;
        List<VoucherSubTypeContract> voucherSubTypeContracts = new ArrayList<>();
        VoucherSubTypeContract contract;

        voucherSubTypeRequest.getRequestInfo().setAction(
                Constants.ACTION_CREATE);

        for (VoucherSubTypeContract voucherSubTypeContract : voucherSubTypeRequest
                .getVoucherSubTypes()) {
            voucherSubType = new VoucherSubType();
            model.map(voucherSubTypeContract, voucherSubType);
            voucherSubType.setCreatedDate(new Date());
            voucherSubType.setCreatedBy(voucherSubTypeRequest.getRequestInfo()
                    .getUserInfo());
            voucherSubType.setLastModifiedBy(voucherSubTypeRequest
                    .getRequestInfo().getUserInfo());
            voucherSubTypes.add(voucherSubType);
        }

        voucherSubTypes = voucherSubTypeService.create(voucherSubTypes, errors,
                voucherSubTypeRequest.getRequestInfo());

        for (VoucherSubType f : voucherSubTypes) {
            contract = new VoucherSubTypeContract();
            model.map(f, contract);
            voucherSubTypeContracts.add(contract);
        }

        voucherSubTypeResponse.setVoucherSubTypes(voucherSubTypeContracts);

        return voucherSubTypeResponse;
    }

}