Search in sources :

Example 6 with CuDisbursementVoucherDocument

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

the class RecurringDisbursementVoucherDocumentServiceImpl method getCuDisbursementVoucherDocument.

private CuDisbursementVoucherDocument getCuDisbursementVoucherDocument(List<DisbursementVoucherDocument> generatedDVs, RecurringDisbursementVoucherDocument recurringDV, Date dvCheckDate) throws WorkflowException {
    for (DisbursementVoucherDocument dv : generatedDVs) {
        if (dv.getDisbursementVoucherDueDate().equals(dvCheckDate)) {
            return (CuDisbursementVoucherDocument) dv;
        }
    }
    CuDisbursementVoucherDocument dv = buildCuDisbursementVoucherDocument(recurringDV);
    dv.setDisbursementVoucherDueDate(dvCheckDate);
    dv.setDisbursementVoucherCheckDate(new Timestamp(dvCheckDate.getTime()));
    generatedDVs.add(dv);
    return dv;
}
Also used : CuDisbursementVoucherDocument(edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument) Timestamp(java.sql.Timestamp) RecurringDisbursementVoucherDocument(edu.cornell.kfs.fp.document.RecurringDisbursementVoucherDocument) DisbursementVoucherDocument(org.kuali.kfs.fp.document.DisbursementVoucherDocument) CuDisbursementVoucherDocument(edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument)

Example 7 with CuDisbursementVoucherDocument

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

the class CuDisbursementVoucherPayeeServiceImplTest method testService.

public void testService() {
    Person alumni = null;
    Person student = null;
    Person employee = null;
    boolean isAlumni = false;
    boolean isStudent = false;
    boolean isEmployee = false;
    List alumniResults = unitTestSqlDao.sqlSelect(alumniSql);
    Object aresult = alumniResults.get(0);
    String[] asplit = aresult.toString().split(",");
    String[] aFdocSplit = asplit[0].split("=");
    String aFdoc = aFdocSplit[1].replaceAll(",", "");
    aFdoc = aFdoc.trim();
    String[] aIdSplit = asplit[1].split("=");
    String aentid = aIdSplit[1].replaceAll("}", "");
    aentid = aentid.trim();
    alumniResults.clear();
    List studentResults = unitTestSqlDao.sqlSelect(studentSql);
    Object sresult = studentResults.get(0);
    String[] stSplit = sresult.toString().split(",");
    String[] sFdocSplit = stSplit[0].split("=");
    String sFdoc = sFdocSplit[1].replaceAll(",", "");
    sFdoc = sFdoc.trim();
    String[] sIdSplit = stSplit[1].split("=");
    String sentid = sIdSplit[1].replaceAll("}", "");
    sentid = sentid.trim();
    studentResults.clear();
    List employeeResults = unitTestSqlDao.sqlSelect(employeeSql);
    Object eresult = employeeResults.get(0);
    String[] esplit = eresult.toString().split(",");
    String[] eFdocSplit = esplit[0].split("=");
    String eFdoc = eFdocSplit[1].replaceAll(",", "");
    eFdoc = eFdoc.trim();
    String[] eIdSplit = esplit[1].split("=");
    String emEmpid = eIdSplit[1].replaceAll("}", "");
    emEmpid = emEmpid.trim();
    employeeResults.clear();
    List<Person> people;
    people = personService.findPeople(Collections.singletonMap(KIMPropertyConstants.Person.ENTITY_ID, aentid));
    alumni = people.get(0);
    people.clear();
    people = personService.findPeople(Collections.singletonMap(KIMPropertyConstants.Person.ENTITY_ID, sentid));
    student = people.get(0);
    people.clear();
    people = personService.findPeople(Collections.singletonMap(KIMPropertyConstants.Person.EMPLOYEE_ID, emEmpid));
    employee = people.get(0);
    DisbursementPayee alumniPayee = cuDisbursementVoucherPayeeService.getPayeeFromPerson(alumni);
    CuDisbursementPayee cuAlumniPayee = (CuDisbursementPayee) cuDisbursementVoucherPayeeService.getPayeeFromPerson(alumni, "A");
    DisbursementPayee studentPayee = cuDisbursementVoucherPayeeService.getPayeeFromPerson(student);
    CuDisbursementPayee cuStudentPayee = (CuDisbursementPayee) cuDisbursementVoucherPayeeService.getPayeeFromPerson(student, "S");
    DisbursementPayee employeePayee = cuDisbursementVoucherPayeeService.getPayeeFromPerson(employee);
    CuDisbursementPayee cuEmployeePayee = (CuDisbursementPayee) cuDisbursementVoucherPayeeService.getPayeeFromPerson(employee, employeePayee.getPayeeTypeCode());
    isAlumni = cuDisbursementVoucherPayeeService.isAlumni(cuAlumniPayee);
    isStudent = cuDisbursementVoucherPayeeService.isStudent(cuStudentPayee);
    isEmployee = cuDisbursementVoucherPayeeService.isEmployee(cuEmployeePayee);
    // test affliation check by payee
    assertTrue(isAlumni);
    assertTrue(isStudent);
    assertTrue(isEmployee);
    isAlumni = false;
    isStudent = false;
    isEmployee = false;
    // Test getpayeefrom person sets principal name
    assertTrue(student.getPrincipalName().equalsIgnoreCase(cuStudentPayee.getPrincipalName()));
    assertTrue(alumni.getPrincipalName().equalsIgnoreCase(cuAlumniPayee.getPrincipalName()));
    CuDisbursementVoucherDocument dvA = businessObjectService.findBySinglePrimaryKey(CuDisbursementVoucherDocument.class, aFdoc);
    System.out.println("FDOC number  " + aFdoc);
    System.out.println("DV Payee detail " + dvA.getDvPayeeDetail());
    isAlumni = cuDisbursementVoucherPayeeService.isAlumni(dvA.getDvPayeeDetail());
    CuDisbursementVoucherDocument dvS = businessObjectService.findBySinglePrimaryKey(CuDisbursementVoucherDocument.class, sFdoc);
    isStudent = cuDisbursementVoucherPayeeService.isStudent(dvS.getDvPayeeDetail());
    CuDisbursementVoucherDocument dvE = businessObjectService.findBySinglePrimaryKey(CuDisbursementVoucherDocument.class, eFdoc);
    isEmployee = cuDisbursementVoucherPayeeService.isEmployee(dvE.getDvPayeeDetail());
    // test affliation check by dvpayeedetail
    assertTrue(isAlumni);
    assertTrue(isStudent);
    assertTrue(isEmployee);
}
Also used : CuDisbursementVoucherDocument(edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument) CuDisbursementPayee(edu.cornell.kfs.fp.businessobject.CuDisbursementPayee) List(java.util.List) CuDisbursementPayee(edu.cornell.kfs.fp.businessobject.CuDisbursementPayee) DisbursementPayee(org.kuali.kfs.fp.businessobject.DisbursementPayee) Person(org.kuali.rice.kim.api.identity.Person)

Example 8 with CuDisbursementVoucherDocument

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

the class DebitDeterminerServiceImplTest method test.

public void test() {
    CuDisbursementVoucherDocument dv = null;
    try {
        dv = (CuDisbursementVoucherDocument) SpringContext.getBean(DocumentService.class).getNewDocument(DisbursementVoucherDocument.class);
    } catch (WorkflowException e) {
        throw new RuntimeException("Error creating new disbursement voucher document: " + e.getMessage(), e);
    }
    if (dv != null) {
        dv.getDocumentHeader().setDocumentDescription("Test Document Description");
        dv.getDocumentHeader().setExplanation("Stuff");
        dv.initiateDocument();
        VendorDetail vendor = SpringContext.getBean(VendorService.class).getVendorDetail("13366-0");
        VendorAddress vendoraddress = SpringContext.getBean(VendorService.class).getVendorDefaultAddress(vendor.getVendorHeaderGeneratedIdentifier(), vendor.getVendorDetailAssignedIdentifier(), "RM", "");
        System.out.println(vendoraddress.getVendorCityName() + "\n");
        dv.templateVendor(vendor, vendoraddress);
        dv.setPayeeAssigned(true);
        dv.getDvPayeeDetail().setDisbVchrPaymentReasonCode("S");
        dv.setDisbVchrCheckTotalAmount(new KualiDecimal(86.00));
        dv.setDisbVchrPaymentMethodCode("P");
        dv.setDisbVchrCheckStubText("check text");
        SourceAccountingLine accountingLine = new SourceAccountingLine();
        accountingLine.setChartOfAccountsCode("IT");
        accountingLine.setAccountNumber("G081040");
        accountingLine.setFinancialObjectCode("2045");
        accountingLine.setAmount((new KualiDecimal(-14.00)));
        accountingLine.setPostingYear(dv.getPostingYear());
        accountingLine.setDocumentNumber(dv.getDocumentNumber());
        dv.addSourceAccountingLine(accountingLine);
        SourceAccountingLine accountingLine2 = new SourceAccountingLine();
        accountingLine2.setChartOfAccountsCode("IT");
        accountingLine2.setAccountNumber("1453611");
        accountingLine2.setFinancialObjectCode("8462");
        accountingLine2.setAmount((new KualiDecimal(100.00)));
        accountingLine2.setPostingYear(dv.getPostingYear());
        accountingLine2.setDocumentNumber(dv.getDocumentNumber());
        dv.addSourceAccountingLine(accountingLine2);
        try {
            documentService.saveDocument(dv);
        } catch (WorkflowException e) {
            throw new RuntimeException("Error saving new disbursement voucher document: " + e.getMessage(), e);
        }
    }
    List<GeneralLedgerPendingEntrySourceDetail> glpeS = dv.getGeneralLedgerPendingEntrySourceDetails();
    GeneralLedgerPendingEntrySourceDetail postable = glpeS.get(0);
    System.out.println("GL Detail" + postable.toString() + "\n");
    assertFalse(debitDeterminerService.isDebitConsideringNothingPositiveOnly(dv, postable));
}
Also used : VendorDetail(org.kuali.kfs.vnd.businessobject.VendorDetail) VendorService(org.kuali.kfs.vnd.document.service.VendorService) CuDisbursementVoucherDocument(edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument) GeneralLedgerPendingEntrySourceDetail(org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntrySourceDetail) WorkflowException(org.kuali.rice.kew.api.exception.WorkflowException) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) SourceAccountingLine(org.kuali.kfs.sys.businessobject.SourceAccountingLine) VendorAddress(org.kuali.kfs.vnd.businessobject.VendorAddress) DocumentService(org.kuali.kfs.krad.service.DocumentService)

Example 9 with CuDisbursementVoucherDocument

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

the class RecurringDisbursementVoucherDocumentServiceImpl method generateDisbursementDocumentsFromRecurringDV.

@Override
public List<DisbursementVoucherDocument> generateDisbursementDocumentsFromRecurringDV(RecurringDisbursementVoucherDocument recurringDV) throws WorkflowException {
    List<DisbursementVoucherDocument> generatedDVs = new ArrayList<DisbursementVoucherDocument>();
    int rowId = 0;
    for (Object accountingLine : recurringDV.getSourceAccountingLines()) {
        ScheduledSourceAccountingLine scheduledAccountingLine = (ScheduledSourceAccountingLine) accountingLine;
        TreeMap<Date, KualiDecimal> datesAndAmounts = getScheduledAccountingLineService().generateDatesAndAmounts(scheduledAccountingLine, rowId);
        for (Date date : datesAndAmounts.keySet()) {
            KualiDecimal amount = datesAndAmounts.get(date);
            CuDisbursementVoucherDocument disbursementVoucherDocument = getCuDisbursementVoucherDocument(generatedDVs, recurringDV, date);
            disbursementVoucherDocument.setDisbVchrCheckTotalAmount(calculateDVCheckAmount(amount, disbursementVoucherDocument));
            RecurringDisbursementVoucherDetail dvDetail = getDetailtem(recurringDV.getRecurringDisbursementVoucherDetails(), date);
            dvDetail.setDvDocumentNumber(disbursementVoucherDocument.getDocumentNumber());
            disbursementVoucherDocument.setDisbVchrCheckStubText(dvDetail.getDvCheckStub());
            SourceAccountingLine line = buildSourceAccountingLine(scheduledAccountingLine);
            line.setAmount(amount);
            disbursementVoucherDocument.addSourceAccountingLine(line);
        }
        rowId++;
    }
    saveDisbursementVouchers(generatedDVs, recurringDV);
    return generatedDVs;
}
Also used : CuDisbursementVoucherDocument(edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument) ArrayList(java.util.ArrayList) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) RecurringDisbursementVoucherDetail(edu.cornell.kfs.fp.businessobject.RecurringDisbursementVoucherDetail) ScheduledSourceAccountingLine(edu.cornell.kfs.fp.businessobject.ScheduledSourceAccountingLine) SourceAccountingLine(org.kuali.kfs.sys.businessobject.SourceAccountingLine) ScheduledSourceAccountingLine(edu.cornell.kfs.fp.businessobject.ScheduledSourceAccountingLine) RecurringDisbursementVoucherDocument(edu.cornell.kfs.fp.document.RecurringDisbursementVoucherDocument) DisbursementVoucherDocument(org.kuali.kfs.fp.document.DisbursementVoucherDocument) CuDisbursementVoucherDocument(edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument) Date(java.sql.Date)

Example 10 with CuDisbursementVoucherDocument

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

the class RecurringDisbursementVoucherDocumentServiceImpl method cancelDisbursementVouchersFinalizedNotExtracted.

@Override
public Set<String> cancelDisbursementVouchersFinalizedNotExtracted(RecurringDisbursementVoucherDocument recurringDisbursementVoucherDocument, String cancelMessage) {
    Set<String> canceledDVs = new HashSet<String>();
    for (RecurringDisbursementVoucherDetail detail : recurringDisbursementVoucherDocument.getRecurringDisbursementVoucherDetails()) {
        String dvDocumentNumber = detail.getDvDocumentNumber();
        if (!isDVCancelable(dvDocumentNumber)) {
            CuDisbursementVoucherDocument dv;
            try {
                dv = (CuDisbursementVoucherDocument) getDocumentService().getByDocumentHeaderId(detail.getDvDocumentNumber());
                if (isDvCancelableFromApprovedNotExtracted(dv)) {
                    Date cancelDate = new Date(Calendar.getInstance().getTimeInMillis());
                    dv.setCancelDate(cancelDate);
                    CuDisbursementVoucherDocument cancledDV = (CuDisbursementVoucherDocument) getDocumentService().saveDocument(dv);
                    getCuDisbursementVoucherExtractionHelperService().getPaymentSourceHelperService().handleEntryCancellation(cancledDV, getCuDisbursementVoucherExtractionHelperService());
                    canceledDVs.add(cancledDV.getDocumentNumber());
                }
            } catch (WorkflowException e) {
                throw new RuntimeException(e);
            }
        }
    }
    noteChangeOnRecurringDV(recurringDisbursementVoucherDocument, "The following disbursement vouchers were canceled after it was approved but before payments were created: ", canceledDVs);
    return canceledDVs;
}
Also used : CuDisbursementVoucherDocument(edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument) WorkflowException(org.kuali.rice.kew.api.exception.WorkflowException) RecurringDisbursementVoucherDetail(edu.cornell.kfs.fp.businessobject.RecurringDisbursementVoucherDetail) Date(java.sql.Date) HashSet(java.util.HashSet)

Aggregations

CuDisbursementVoucherDocument (edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument)20 Person (org.kuali.rice.kim.api.identity.Person)7 WorkflowException (org.kuali.rice.kew.api.exception.WorkflowException)5 VendorDetail (org.kuali.kfs.vnd.businessobject.VendorDetail)4 KualiDecimal (org.kuali.rice.core.api.util.type.KualiDecimal)4 CULegacyTravelService (edu.cornell.kfs.fp.document.service.CULegacyTravelService)3 Date (java.sql.Date)3 DocumentService (org.kuali.kfs.krad.service.DocumentService)3 MessageMap (org.kuali.kfs.krad.util.MessageMap)3 SourceAccountingLine (org.kuali.kfs.sys.businessobject.SourceAccountingLine)3 VendorAddress (org.kuali.kfs.vnd.businessobject.VendorAddress)3 PersonService (org.kuali.rice.kim.api.identity.PersonService)3 CuDisbursementVoucherPayeeDetail (edu.cornell.kfs.fp.businessobject.CuDisbursementVoucherPayeeDetail)2 RecurringDisbursementVoucherDetail (edu.cornell.kfs.fp.businessobject.RecurringDisbursementVoucherDetail)2 RecurringDisbursementVoucherDocument (edu.cornell.kfs.fp.document.RecurringDisbursementVoucherDocument)2 IWantDocument (edu.cornell.kfs.module.purap.document.IWantDocument)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 DisbursementVoucherDocument (org.kuali.kfs.fp.document.DisbursementVoucherDocument)2 VendorService (org.kuali.kfs.vnd.document.service.VendorService)2