class AbstractYourProjectCostsFormPopulator {

    public YourProjectCostsForm populateForm(long targetId, long organisationId) {
        YourProjectCostsForm form = new YourProjectCostsForm();
        BaseFinanceResource finance = getFinanceResource(targetId, organisationId);

        form.setOverhead(overhead(finance));
        form.setLabour(labour(finance));
        form.setCapitalUsageRows(toRows(finance, FinanceRowType.CAPITAL_USAGE,
                CapitalUsageRowForm.class, CapitalUsage.class));
        form.setMaterialRows(toRows(finance, FinanceRowType.MATERIALS,
                MaterialRowForm.class, Materials.class));
        form.setOtherRows(toRows(finance, FinanceRowType.OTHER_COSTS,
                OtherCostRowForm.class, OtherCost.class));
        form.setSubcontractingRows(toRows(finance, FinanceRowType.SUBCONTRACTING_COSTS,
                SubcontractingRowForm.class, SubContractingCost.class));
        form.setTravelRows(toRows(finance, FinanceRowType.TRAVEL,
                TravelRowForm.class, TravelCost.class));

        form.setVatForm(vat(finance));
        form.setProcurementOverheadRows(toRows(finance, FinanceRowType.PROCUREMENT_OVERHEADS,
                ProcurementOverheadRowForm.class, ProcurementOverhead.class));

        form.setAssociateSalaryCostRows(associateSalaryCostRows(finance));
        form.setAssociateDevelopmentCostRows(associateDevelopment(finance));
        form.setConsumableCostRows(toRows(finance, FinanceRowType.CONSUMABLES,
                ConsumablesRowForm.class, Consumable.class));
        form.setKnowledgeBaseCostRows(toRows(finance, FinanceRowType.KNOWLEDGE_BASE,
                KnowledgeBaseCostRowForm.class, KnowledgeBaseCost.class,
                numberOfRows(finance, FinanceRowType.KNOWLEDGE_BASE) < 2));
        form.setAssociateSupportCostRows(toRows(finance, FinanceRowType.ASSOCIATE_SUPPORT,
                AssociateSupportCostRowForm.class, AssociateSupportCost.class));
        form.setEstateCostRows(toRows(finance, FinanceRowType.ESTATE_COSTS,
                EstateCostRowForm.class, EstateCost.class));

        form.setKtpTravelCostRows(toRows(finance, FinanceRowType.KTP_TRAVEL,
                KtpTravelRowForm.class, KtpTravelCost.class, Comparator.comparing(cost ->
                        ofNullable(cost.getType()).map(KtpTravelCostType::ordinal).orElse(2))));

        form.setAdditionalCompanyCostForm(additionalCompanyCostForm(finance));

        OrganisationResource organisation = organisationRestService.getOrganisationById(organisationId).getSuccess();

        if (ApplicationFinanceResource.class.equals(finance.getClass()) && organisation.getOrganisationTypeEnum() == OrganisationTypeEnum.KNOWLEDGE_BASE) {
            form.setJustificationForm(justificationForm(finance));
        }

        return form;
    }

}