use of edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument in project cu-kfs by CU-CommunityApps.
the class CuDisbursementVoucherAction method createDVFromIWantDoc.
/**
* Creates a DV document based on information on an I Want document.
*
* @param mapping
* @param form
* @param request
* @param response
* @return
* @throws Exception
*/
public ActionForward createDVFromIWantDoc(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
String iWantDocumentNumber = request.getParameter("docId");
CuDisbursementVoucherForm disbursementVoucherForm = (CuDisbursementVoucherForm) form;
IWantDocument iWantDocument = (IWantDocument) getDocumentService().getByDocumentHeaderId(iWantDocumentNumber);
// Do not allow the DV to be created if the IWNT doc is already associated with another DV.
if (iWantDocument != null && (StringUtils.isNotBlank(iWantDocument.getReqsDocId()) || StringUtils.isNotBlank(iWantDocument.getDvDocId()))) {
GlobalVariables.getMessageMap().putError(KFSConstants.GLOBAL_ERRORS, CUPurapKeyConstants.ERROR_DV_OR_REQ_ALREADY_CREATED_FROM_IWNT, iWantDocumentNumber);
return mapping.findForward("error");
}
IWantDocumentService iWantDocumentService = SpringContext.getBean(IWantDocumentService.class);
createDocument(disbursementVoucherForm);
CuDisbursementVoucherDocument disbursementVoucherDocument = (CuDisbursementVoucherDocument) disbursementVoucherForm.getDocument();
iWantDocumentService.setUpDVDetailsFromIWantDoc(iWantDocument, disbursementVoucherDocument, disbursementVoucherForm);
// Set the DV doc ID reference on the IWantDocument.
iWantDocument.setDvDocId(disbursementVoucherDocument.getDocumentNumber());
SpringContext.getBean(PurapService.class).saveDocumentNoValidation(iWantDocument);
return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
use of edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument in project cu-kfs by CU-CommunityApps.
the class CuDisbursementVoucherAction method setupPayeeAsEmployee.
protected void setupPayeeAsEmployee(CuDisbursementVoucherForm dvForm, String payeeIdNumber) {
Person person = (Person) SpringContext.getBean(PersonService.class).getPersonByEmployeeId(payeeIdNumber);
if (person == null) {
person = (Person) SpringContext.getBean(PersonService.class).getPerson(payeeIdNumber);
}
if (person != null) {
((CuDisbursementVoucherDocument) dvForm.getDocument()).templateEmployee(person);
dvForm.setTempPayeeIdNumber(payeeIdNumber);
dvForm.setOldPayeeType(KFSConstants.PaymentPayeeTypes.EMPLOYEE);
} else {
LOG.error("Exception while attempting to retrieve universal user by universal user id " + payeeIdNumber);
}
}
use of edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument in project cu-kfs by CU-CommunityApps.
the class CuDisbursementVoucherAction method setupPayeeAsAlumni.
/**
* setup the payee as an alumni with the given id number
*/
protected void setupPayeeAsAlumni(CuDisbursementVoucherForm dvForm, String payeeIdNumber) {
Person person = (Person) SpringContext.getBean(PersonService.class).getPerson(payeeIdNumber);
if (person != null) {
((CuDisbursementVoucherDocument) dvForm.getDocument()).templateAlumni(person);
dvForm.setTempPayeeIdNumber(payeeIdNumber);
dvForm.setOldPayeeType(CuDisbursementVoucherConstants.DV_PAYEE_TYPE_ALUMNI);
} else {
LOG.error("Exception while attempting to retrieve universal user by universal user id " + payeeIdNumber);
}
}
use of edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument in project cu-kfs by CU-CommunityApps.
the class SubmitTripWebServiceImpl method buildDisbursementVoucher.
/**
* @param dvDescription
* @param dvExplanation
* @param tripNumber
* @param travelerNetId
* @param initiatorNetId
* @param totalAmount
* @param checkStubText
* @return
* @throws Exception
*/
private String buildDisbursementVoucher(String dvDescription, String dvExplanation, String tripNumber, String travelerNetId, String initiatorNetId, double totalAmount, String checkStubText) throws Exception {
try {
if (!isValidDocumentInitiator(initiatorNetId, DISBURSEMENT_VOUCHER)) {
throw new RuntimeException("Initiator identified does not have permission to create a DV.");
}
} catch (Exception ex) {
throw new RuntimeException("Initiator identified does not have permission to create a DV.", ex);
}
// create and route doc as system user
GlobalVariables.setUserSession(new UserSession(initiatorNetId));
MessageMap documentErrorMap = new MessageMap();
GlobalVariables.setMessageMap(documentErrorMap);
// Create document with description provided
CuDisbursementVoucherDocument dvDoc = null;
try {
dvDoc = (CuDisbursementVoucherDocument) SpringContext.getBean(DocumentService.class).getNewDocument(DisbursementVoucherDocument.class);
} catch (WorkflowException e) {
throw new RuntimeException("Error creating new disbursement voucher document: " + e.getMessage(), e);
}
if (dvDoc != null) {
dvDoc.getDocumentHeader().setDocumentDescription(dvDescription);
dvDoc.getDocumentHeader().setExplanation(dvExplanation);
dvDoc.getDocumentHeader().setOrganizationDocumentNumber(tripNumber);
dvDoc.initiateDocument();
// Set vendor to traveler using netID provided
Person traveler = SpringContext.getBean(PersonService.class).getPersonByPrincipalName(travelerNetId);
for (EntityAffiliation entityAffiliation : ((PersonImpl) traveler).getAffiliations()) {
if (entityAffiliation.isDefaultValue()) {
if (StringUtils.equalsIgnoreCase(entityAffiliation.getAffiliationType().getCode(), CuDisbursementVoucherConstants.PayeeAffiliations.STUDENT)) {
dvDoc.templateStudent(traveler);
} else if (StringUtils.equalsIgnoreCase(entityAffiliation.getAffiliationType().getCode(), CuDisbursementVoucherConstants.PayeeAffiliations.ALUMNI)) {
dvDoc.templateAlumni(traveler);
} else if (StringUtils.equalsIgnoreCase(entityAffiliation.getAffiliationType().getCode(), CuDisbursementVoucherConstants.PayeeAffiliations.FACULTY) || StringUtils.equalsIgnoreCase(entityAffiliation.getAffiliationType().getCode(), CuDisbursementVoucherConstants.PayeeAffiliations.STAFF)) {
dvDoc.templateEmployee(traveler);
}
}
}
dvDoc.setPayeeAssigned(true);
dvDoc.getDvPayeeDetail().setDisbVchrPaymentReasonCode("J");
dvDoc.setDisbVchrCheckTotalAmount(new KualiDecimal(totalAmount));
dvDoc.setDisbVchrPaymentMethodCode("P");
dvDoc.setDisbVchrCheckStubText(checkStubText);
dvDoc.setTripId(tripNumber);
dvDoc.setTripAssociationStatusCode(CULegacyTravelServiceImpl.TRIP_ASSOCIATIONS.IS_TRIP_DOC);
// Persist document
SpringContext.getBean(DocumentService.class).saveDocument(dvDoc);
return dvDoc.getDocumentNumber();
} else {
return "";
}
}
use of edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument in project cu-kfs by CU-CommunityApps.
the class CuDisbursementVoucherDocumentPresentationController method addTravelSystemGeneratedEntryMode.
/**
* If the DV was generated from a connection with the Cornell Travel System, enforces special edit rules regarding information on the disbursement voucher.
*
* Added condition that DV is not in the Payment Method Reviewers' queue, as the check amount needs to be editable for that circustance.
*
* @param document the disbursement voucher document authorization is being sought on
* @param editModes the edit modes so far, which can be added to
*/
protected void addTravelSystemGeneratedEntryMode(Document document, Set<String> editModes) {
final CuDisbursementVoucherDocument dvDocument = (CuDisbursementVoucherDocument) document;
final WorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument();
final Set<String> currentRouteLevels = workflowDocument.getCurrentNodeNames();
boolean isAssociatedWithTrip = SpringContext.getBean(CULegacyTravelService.class).isCULegacyTravelIntegrationInterfaceAssociatedWithTrip(dvDocument);
if (isAssociatedWithTrip && !currentRouteLevels.contains(KFSConstants.RouteLevelNames.PAYMENT_METHOD)) {
LOG.info("Checking travel system generated entry permissions.");
editModes.add(CUKFSAuthorizationConstants.DisbursementVoucherEditMode.TRAVEL_SYSTEM_GENERATED_ENTRY);
}
}
Aggregations