class ApplicationFinanceServiceImpl extends AbstractFinanceService<ApplicationFinance, ApplicationFinanceResource> implements ApplicationFinanceService {

    @Override
    @Transactional
    public ServiceResult<ApplicationFinanceResource> financeDetails(long applicationId, long organisationId) {
        Optional<ApplicationFinance> finance = applicationFinanceRepository.findByApplicationIdAndOrganisationId(applicationId, organisationId);
        if (!finance.isPresent()) {
            ServiceResult<ApplicationFinanceResource> result = createApplicationFinance(applicationId, organisationId);
            if (result.isFailure()) {
                return result;
            }
        }
        ApplicationFinanceResourceId applicationFinanceResourceId = new ApplicationFinanceResourceId(applicationId, organisationId);
        return getApplicationFinanceForOrganisation(applicationFinanceResourceId);
    }

}