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;
}
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);
}
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));
}
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;
}
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;
}
Aggregations