Search in sources :

Example 1 with PreEncumbranceDocument

use of edu.cornell.kfs.fp.document.PreEncumbranceDocument in project cu-kfs by CU-CommunityApps.

the class CuPreEncumbranceActionTest method setUp.

@Before
public void setUp() {
    preEncumbranceDocument = createMock(PreEncumbranceDocument.class);
    preEncumbranceDocument.setSourceAccountingLines(new ArrayList());
    kualiAccountingDocumentFormBase = createMock(KualiAccountingDocumentFormBase.class);
    kualiAccountingDocumentFormBase.setTabStates(new HashMap<>());
    kualiAccountingDocumentFormBase.setDocument(preEncumbranceDocument);
    cuPreEncumbranceAction = new CuPreEncumbranceAction();
}
Also used : ArrayList(java.util.ArrayList) KualiAccountingDocumentFormBase(org.kuali.kfs.sys.web.struts.KualiAccountingDocumentFormBase) PreEncumbranceDocument(edu.cornell.kfs.fp.document.PreEncumbranceDocument) Before(org.junit.Before)

Example 2 with PreEncumbranceDocument

use of edu.cornell.kfs.fp.document.PreEncumbranceDocument in project cu-kfs by CU-CommunityApps.

the class PreEncumbranceAutoDisEncumberValidation method validate.

public boolean validate(AttributedDocumentEvent event) {
    boolean success = true;
    ParameterService ps = SpringContext.getBean(ParameterService.class);
    try {
        DateFormat transactionDateFormat = new SimpleDateFormat(TRANSACTION_DATE_FORMAT_STRING);
        annualClosingDate = new Date(transactionDateFormat.parse(ps.getParameterValueAsString(KfsParameterConstants.GENERAL_LEDGER_BATCH.class, GeneralLedgerConstants.ANNUAL_CLOSING_TRANSACTION_DATE_PARM)).getTime());
        // this needs to be changed
        annualClosingDate.setYear(annualClosingDate.getYear() + 1);
        LOG.info("Annual closing Date of: " + annualClosingDate);
    } catch (ParseException e) {
        LOG.error("PreEncumbrance validation nnable to parse transaction date", e);
        throw new IllegalArgumentException("Unable to parse transaction date");
    }
    PreEncumbranceDocument ped = (PreEncumbranceDocument) getAccountingDocumentForValidation();
    Iterator<PreEncumbranceSourceAccountingLine> it = ped.getSourceAccountingLines().iterator();
    while (it.hasNext()) {
        PreEncumbranceSourceAccountingLine pesal = it.next();
        auto = true;
        if (checkMinimumRequirements(pesal) && auto) {
            success &= checkDates(pesal);
            success &= checkGenerationValidity(pesal);
        } else {
            if (auto) {
                success &= false;
            }
        }
    }
    return success;
}
Also used : ParameterService(org.kuali.kfs.coreservice.framework.parameter.ParameterService) PreEncumbranceSourceAccountingLine(edu.cornell.kfs.fp.businessobject.PreEncumbranceSourceAccountingLine) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) KfsParameterConstants(org.kuali.kfs.sys.service.impl.KfsParameterConstants) ParseException(java.text.ParseException) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.sql.Date) PreEncumbranceDocument(edu.cornell.kfs.fp.document.PreEncumbranceDocument)

Aggregations

PreEncumbranceDocument (edu.cornell.kfs.fp.document.PreEncumbranceDocument)2 PreEncumbranceSourceAccountingLine (edu.cornell.kfs.fp.businessobject.PreEncumbranceSourceAccountingLine)1 Date (java.sql.Date)1 DateFormat (java.text.DateFormat)1 ParseException (java.text.ParseException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 Before (org.junit.Before)1 ParameterService (org.kuali.kfs.coreservice.framework.parameter.ParameterService)1 KfsParameterConstants (org.kuali.kfs.sys.service.impl.KfsParameterConstants)1 KualiAccountingDocumentFormBase (org.kuali.kfs.sys.web.struts.KualiAccountingDocumentFormBase)1