class AccountCodePurposeService {

	@Transactional
	public List<AccountCodePurpose> create(List<AccountCodePurpose> accountCodePurposes, BindingResult errors,
			RequestInfo requestInfo) {

		try {

			accountCodePurposes = fetchRelated(accountCodePurposes);

			validate(accountCodePurposes, Constants.ACTION_CREATE, errors);

			if (errors.hasErrors()) {
				throw new CustomBindException(errors);
			}
			for (AccountCodePurpose account : accountCodePurposes) {
				account.setId(accountCodePurposeRepository.getNextSequence());
			}

		} catch (CustomBindException e) {

			throw new CustomBindException(errors);
		}

		return accountCodePurposeRepository.save(accountCodePurposes, requestInfo);

	}

}