Search in sources :

Example 1 with CuAward

use of edu.cornell.kfs.module.cg.businessobject.CuAward in project cu-kfs by CU-CommunityApps.

the class ezraUpdateAwardImplTest method testUpdateAwards.

public void testUpdateAwards() {
    Map fields = new HashMap();
    String awardProjectTitle = "ezraUpdateTest";
    String awardProjectTitleAfter = "";
    Date today = SpringContext.getBean(DateTimeService.class).getCurrentSqlDate();
    Date sqlDate = today;
    Date budgetStartDate = generateYear1970StartDate();
    Date budgetEndDate = generateDateOneDayLater(budgetStartDate);
    Date budgetStartDateAfter = generateDateOneDayLater(budgetEndDate);
    Date budgetEndDateAfter = generateDateOneDayLater(budgetStartDateAfter);
    KualiDecimal budgetTotal = new KualiDecimal(-1);
    KualiDecimal budgetTotalAfter = new KualiDecimal(-2);
    EzraProposalAward ezraAward = null;
    List<EzraProposalAward> awards = ezraAwardProposalDao.getAwardsUpdatedSince(sqlDate);
    int count = 0;
    if (awards.isEmpty()) {
        do {
            count--;
            Calendar c = Calendar.getInstance();
            c.setTime(today);
            c.add(Calendar.DATE, count);
            sqlDate = new java.sql.Date(c.getTimeInMillis());
            awards = ezraAwardProposalDao.getAwardsUpdatedSince(sqlDate);
            if (!awards.isEmpty()) {
                count = -12;
            }
        } while (count > -11);
    }
    LOG.info("The Sql Date is " + sqlDate);
    awards = ezraAwardProposalDao.getAwardsUpdatedSince(sqlDate);
    if (!awards.isEmpty()) {
        ezraAward = awards.get(0);
        fields.clear();
        fields.put("proposalNumber", ezraAward.getProjectId());
        Award award = (CuAward) businessObjectService.findByPrimaryKey(CuAward.class, fields);
        award.setAwardProjectTitle(awardProjectTitle);
        getAwardExtension(award).setBudgetBeginningDate(new Date(budgetStartDate.getTime()));
        getAwardExtension(award).setBudgetEndingDate(new Date(budgetEndDate.getTime()));
        getAwardExtension(award).setBudgetTotalAmount(budgetTotal);
        businessObjectService.save(award);
        assertTrue(ezraService.updateAwardsSince(sqlDate));
        Award awardAfter = (CuAward) businessObjectService.findByPrimaryKey(CuAward.class, fields);
        awardProjectTitleAfter = awardAfter.getAwardProjectTitle();
        budgetStartDateAfter = getAwardExtension(awardAfter).getBudgetBeginningDate();
        budgetEndDateAfter = getAwardExtension(awardAfter).getBudgetEndingDate();
        budgetTotalAfter = getAwardExtension(awardAfter).getBudgetTotalAmount();
        LOG.info("Project Title before update " + awardProjectTitle + " Project Title after update " + awardProjectTitleAfter);
    }
    if (awardProjectTitle.equalsIgnoreCase(awardProjectTitleAfter)) {
        fail("Ezra failed to update Award");
    }
    assertNotEquals("Ezra failed to update Award Budget Start Date", budgetStartDate, budgetStartDateAfter);
    assertNotEquals("Ezra failed to update Award Budget Stop Date", budgetEndDate, budgetEndDateAfter);
    assertNotEquals("Ezra failed to update Award Budget Total Amount", budgetTotal, budgetTotalAfter);
}
Also used : HashMap(java.util.HashMap) Calendar(java.util.Calendar) EzraProposalAward(edu.cornell.kfs.module.ezra.businessobject.EzraProposalAward) Date(java.sql.Date) Date(java.sql.Date) Award(org.kuali.kfs.module.cg.businessobject.Award) EzraProposalAward(edu.cornell.kfs.module.ezra.businessobject.EzraProposalAward) CuAward(edu.cornell.kfs.module.cg.businessobject.CuAward) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) HashMap(java.util.HashMap) Map(java.util.Map) DateTimeService(org.kuali.rice.core.api.datetime.DateTimeService) CuAward(edu.cornell.kfs.module.cg.businessobject.CuAward)

Example 2 with CuAward

use of edu.cornell.kfs.module.cg.businessobject.CuAward in project cu-kfs by CU-CommunityApps.

the class EzraServiceImpl method createAward.

protected Award createAward(Proposal proposal, Award oldAward, EzraProposalAward ezraAward) {
    Award award = new CuAward(proposal);
    award.setProposal(proposal);
    award.setAwardStatusCode(proposal.getProposalStatusCode());
    award.setAwardBeginningDate(proposal.getProposalBeginningDate());
    award.setAwardEndingDate(proposal.getProposalEndingDate());
    award.setAwardDirectCostAmount(proposal.getProposalDirectCostAmount());
    award.setAwardIndirectCostAmount(KualiDecimal.ZERO);
    award.setGrantDescriptionCode(getGrantDescriptionMap().get(ezraAward.getAwardDescriptionCode()));
    award.setAwardEntryDate(dateTimeService.getCurrentSqlDate());
    if (ObjectUtils.isNull(oldAward)) {
        List<AwardAccount> accounts = getAwardAccounts(proposal);
        award.setAwardAccounts(accounts);
        award.setActive(true);
    } else {
        award.setAwardAccounts(oldAward.getAwardAccounts());
        setAwardOrgVersionNumbers(oldAward.getAwardOrganizations(), award.getAwardOrganizations());
        award.setVersionNumber(oldAward.getVersionNumber());
        award.setLetterOfCreditFundCode(oldAward.getLetterOfCreditFundCode());
        ((CuAward) award).setLetterOfCreditFundGroupCode(((CuAward) oldAward).getLetterOfCreditFundGroupCode());
        AwardExtendedAttribute awardEA = (AwardExtendedAttribute) award.getExtension();
        awardEA.setLocAccountId(((AwardExtendedAttribute) oldAward.getExtension()).getLocAccountId());
        award.setActive(oldAward.isActive());
        awardEA.setProposalNumber(((AwardExtendedAttribute) oldAward.getExtension()).getProposalNumber());
        awardEA.setVersionNumber(((AwardExtendedAttribute) oldAward.getExtension()).getVersionNumber());
        awardEA.setEverify(((AwardExtendedAttribute) oldAward.getExtension()).isEverify());
    }
    for (AwardProjectDirector apd : award.getAwardProjectDirectors()) {
        Map primaryKeys = new HashMap();
        primaryKeys.put("principalId", apd.getPrincipalId());
        primaryKeys.put("proposalNumber", apd.getProposalNumber());
        AwardProjectDirector projDir = (AwardProjectDirector) businessObjectService.findByPrimaryKey(AwardProjectDirector.class, primaryKeys);
        if (ObjectUtils.isNotNull(projDir)) {
            apd.setVersionNumber(projDir.getVersionNumber());
        }
    }
    award.refreshReferenceObject("extension");
    Map fieldValues = new HashMap();
    fieldValues.put("projectId", award.getProposalNumber());
    fieldValues.put("deliverableType", 'F');
    fieldValues.put("finalIndicator", 'Y');
    List<Deliverable> deliverables = (List<Deliverable>) businessObjectService.findMatching(Deliverable.class, fieldValues);
    if (deliverables.size() == 1) {
        Deliverable deliverable = deliverables.get(0);
        if (ObjectUtils.isNotNull(deliverable)) {
            AwardExtendedAttribute aea = (AwardExtendedAttribute) award.getExtension();
            aea.setFinalFiscalReportDate(deliverable.getDueDate());
            aea.setFinalFinancialReportRequired(true);
        }
    }
    KualiDecimal costShareRequired = KualiDecimal.ZERO;
    if (ezraAward.getCsVolClg() != null) {
        costShareRequired = costShareRequired.add(ezraAward.getCsVolClg());
    }
    if (ezraAward.getCsVolCntr() != null) {
        costShareRequired = costShareRequired.add(ezraAward.getCsVolCntr());
    }
    if (ezraAward.getCsVolDept() != null) {
        costShareRequired = costShareRequired.add(ezraAward.getCsVolDept());
    }
    if (ezraAward.getCsVolExt() != null) {
        costShareRequired = costShareRequired.add(ezraAward.getCsVolExt());
    }
    if (ezraAward.getCsVolUniv() != null) {
        costShareRequired = costShareRequired.add(ezraAward.getCsVolUniv());
    }
    if (ezraAward.getCsMandClg() != null) {
        costShareRequired = costShareRequired.add(ezraAward.getCsMandClg());
    }
    if (ezraAward.getCsMandCntr() != null) {
        costShareRequired = costShareRequired.add(ezraAward.getCsMandCntr());
    }
    if (ezraAward.getCsMandDept() != null) {
        costShareRequired = costShareRequired.add(ezraAward.getCsMandDept());
    }
    if (ezraAward.getCsMandExt() != null) {
        costShareRequired = costShareRequired.add(ezraAward.getCsMandExt());
    }
    if (ezraAward.getCsMandUniv() != null) {
        costShareRequired = costShareRequired.add(ezraAward.getCsMandUniv());
    }
    AwardExtendedAttribute aea = (AwardExtendedAttribute) award.getExtension();
    if (costShareRequired.isNonZero()) {
        aea.setCostShareRequired(true);
    } else {
        aea.setCostShareRequired(false);
    }
    aea.setBudgetBeginningDate(ezraAward.getBudgetStartDate());
    aea.setBudgetEndingDate(ezraAward.getBudgetStopDate());
    aea.setBudgetTotalAmount(ezraAward.getBudgetAmt());
    Compliance ezraCompliance = getEzraCompliance(ezraAward);
    if (ObjectUtils.isNotNull(ezraCompliance)) {
        boolean everify = Boolean.TRUE.equals(ezraCompliance.getEverify());
        aea.setEverify(everify);
    }
    award.refreshReferenceObject("proposal");
    award.refreshNonUpdateableReferences();
    award.setExtension(aea);
    return award;
}
Also used : AwardProjectDirector(org.kuali.kfs.module.cg.businessobject.AwardProjectDirector) Compliance(edu.cornell.kfs.module.ezra.businessobject.Compliance) HashMap(java.util.HashMap) AwardAccount(org.kuali.kfs.module.cg.businessobject.AwardAccount) AwardExtendedAttribute(edu.cornell.kfs.module.cg.businessobject.AwardExtendedAttribute) Award(org.kuali.kfs.module.cg.businessobject.Award) EzraProposalAward(edu.cornell.kfs.module.ezra.businessobject.EzraProposalAward) CuAward(edu.cornell.kfs.module.cg.businessobject.CuAward) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) CuAward(edu.cornell.kfs.module.cg.businessobject.CuAward) Deliverable(edu.cornell.kfs.module.ezra.businessobject.Deliverable)

Example 3 with CuAward

use of edu.cornell.kfs.module.cg.businessobject.CuAward in project cu-kfs by CU-CommunityApps.

the class EzraServiceImpl method updateAwardsSince.

public boolean updateAwardsSince(Date date) {
    boolean result = true;
    List<EzraProposalAward> awards = ezraAwardProposalDao.getAwardsUpdatedSince(date);
    Map fields = new HashMap();
    LOG.info("Retrieved : " + awards.size() + " Awards to update since " + date.toString());
    for (EzraProposalAward ezraAward : awards) {
        String proposalId = ezraAward.getProjectId();
        fields.clear();
        fields.put("proposalNumber", proposalId);
        Award award = (CuAward) businessObjectService.findByPrimaryKey(CuAward.class, fields);
        if (award == null) {
            LOG.error("Award: " + proposalId + " is null and probably should have already been created");
        } else {
            Proposal proposal = createProposal(ezraAward);
            Award newAward = createAward(proposal, award, ezraAward);
            routeAwardDocument(newAward, award);
        }
    }
    return result;
}
Also used : HashMap(java.util.HashMap) Award(org.kuali.kfs.module.cg.businessobject.Award) EzraProposalAward(edu.cornell.kfs.module.ezra.businessobject.EzraProposalAward) CuAward(edu.cornell.kfs.module.cg.businessobject.CuAward) EzraProposalAward(edu.cornell.kfs.module.ezra.businessobject.EzraProposalAward) HashMap(java.util.HashMap) Map(java.util.Map) Proposal(org.kuali.kfs.module.cg.businessobject.Proposal) CuAward(edu.cornell.kfs.module.cg.businessobject.CuAward)

Aggregations

CuAward (edu.cornell.kfs.module.cg.businessobject.CuAward)3 EzraProposalAward (edu.cornell.kfs.module.ezra.businessobject.EzraProposalAward)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 Award (org.kuali.kfs.module.cg.businessobject.Award)3 KualiDecimal (org.kuali.rice.core.api.util.type.KualiDecimal)2 AwardExtendedAttribute (edu.cornell.kfs.module.cg.businessobject.AwardExtendedAttribute)1 Compliance (edu.cornell.kfs.module.ezra.businessobject.Compliance)1 Deliverable (edu.cornell.kfs.module.ezra.businessobject.Deliverable)1 Date (java.sql.Date)1 ArrayList (java.util.ArrayList)1 Calendar (java.util.Calendar)1 List (java.util.List)1 AwardAccount (org.kuali.kfs.module.cg.businessobject.AwardAccount)1 AwardProjectDirector (org.kuali.kfs.module.cg.businessobject.AwardProjectDirector)1 Proposal (org.kuali.kfs.module.cg.businessobject.Proposal)1 DateTimeService (org.kuali.rice.core.api.datetime.DateTimeService)1