class ApplicationFinanceRowServiceImpl extends BaseTransactionalService implements ApplicationFinanceRowService {

    @Override
    @Transactional
    public ServiceResult<FinanceRowItem> update(final long financeRowId, final FinanceRowItem newCostItem) {
        Application application = financeRowRepository.findById(financeRowId).get().getTarget().getApplication();
        return getOpenApplication(application.getId()).andOnSuccess(app ->
                doUpdate(financeRowId, newCostItem).andOnSuccessReturn(cost -> {
                    OrganisationTypeFinanceHandler organisationFinanceHandler = organisationFinanceDelegate.getOrganisationFinanceHandler(((ApplicationFinanceRow) cost).getTarget().getApplication().getCompetition().getId(), ((ApplicationFinanceRow) cost).getTarget().getOrganisation().getOrganisationType().getId());
                    return organisationFinanceHandler.toResource((ApplicationFinanceRow) cost);
                })
        );
    }

}