class BankDetailsServiceImpl implements BankDetailsService {

    @Override
    @Transactional
    public ServiceResult<Void> submitBankDetails(ProjectOrganisationCompositeId projectOrganisationCompositeId, BankDetailsResource bankDetailsResource) {
        return bankDetailsDontExist(bankDetailsResource.getProject(), bankDetailsResource.getOrganisation()).
                andOnSuccess(() -> validateBankDetails(bankDetailsResource).
                andOnSuccess(accountDetails -> saveSubmittedBankDetails(accountDetails, bankDetailsResource)).
                andOnSuccess(accountDetails -> {
                    Optional<BankDetails> bankDetails = bankDetailsRepository.findByProjectIdAndOrganisationId(bankDetailsResource.getProject(), bankDetailsResource.getOrganisation());
                    return verifyBankDetails(accountDetails, bankDetails.get());
                }));
    }

}