use of edu.cornell.kfs.fp.document.RecurringDisbursementVoucherDocument in project cu-kfs by CU-CommunityApps.
the class CuDisbursementVoucherAccountingLineTotalsValidation method validate.
@Override
public boolean validate(AttributedDocumentEvent event) {
if (LOG.isDebugEnabled()) {
LOG.debug("validate start");
}
DisbursementVoucherDocument dvDocument = (DisbursementVoucherDocument) event.getDocument();
Person financialSystemUser = GlobalVariables.getUserSession().getPerson();
final Set<String> currentEditModes = getEditModesFromDocument(dvDocument, financialSystemUser);
// amounts can only decrease
List<String> candidateEditModes = this.getCandidateEditModes();
if (this.hasRequiredEditMode(currentEditModes, candidateEditModes)) {
// users in foreign or wire workgroup can increase or decrease amounts because of currency conversion
List<String> foreignDraftAndWireTransferEditModes = this.getForeignDraftAndWireTransferEditModes(dvDocument);
if (!this.hasRequiredEditMode(currentEditModes, foreignDraftAndWireTransferEditModes)) {
DisbursementVoucherDocument persistedDocument = (DisbursementVoucherDocument) retrievePersistedDocument(dvDocument);
if (persistedDocument == null) {
handleNonExistentDocumentWhenApproving(dvDocument);
return true;
}
// KFSMI- 5183
if (persistedDocument.getDocumentHeader().getWorkflowDocument().isSaved() && persistedDocument.getDisbVchrCheckTotalAmount().isZero()) {
return true;
}
// check total cannot decrease
if (!persistedDocument.getDocumentHeader().getWorkflowDocument().isCompletionRequested() && (!persistedDocument.getDisbVchrCheckTotalAmount().equals(dvDocument.getDisbVchrCheckTotalAmount()))) {
GlobalVariables.getMessageMap().putError(KFSPropertyConstants.DOCUMENT + "." + KFSPropertyConstants.DISB_VCHR_CHECK_TOTAL_AMOUNT, CUKFSKeyConstants.ERROR_DV_CHECK_TOTAL_NO_CHANGE);
return false;
}
}
return true;
}
// KFSUPGRADE-848 : skip total check here for FO
final WorkflowDocument workflowDocument = dvDocument.getDocumentHeader().getWorkflowDocument();
final Set<String> currentRouteLevels = workflowDocument.getCurrentNodeNames();
if (CollectionUtils.isNotEmpty(currentRouteLevels)) {
if (currentRouteLevels.contains(DisbursementVoucherConstants.RouteLevelNames.ACCOUNT)) {
return true;
}
}
if (dvDocument instanceof RecurringDisbursementVoucherDocument) {
RecurringDisbursementVoucherDocument recurringDV = (RecurringDisbursementVoucherDocument) dvDocument;
if (!doesAccountingLineTotalEqualDVTotalDollarAmount(recurringDV)) {
String propertyName = KFSPropertyConstants.DOCUMENT + "." + KFSPropertyConstants.DISB_VCHR_CHECK_TOTAL_AMOUNT;
GlobalVariables.getMessageMap().putError(propertyName, CUKFSKeyConstants.ERROR_DV_CHECK_TOTAL_MUST_EQUAL_ACCOUNTING_LINE_TOTAL);
return false;
}
if (StringUtils.isEmpty(recurringDV.getDisbVchrCheckStubText()) && !recurringDV.getSourceAccountingLines().isEmpty()) {
String propertyName = KFSPropertyConstants.DOCUMENT + "." + KFSPropertyConstants.DISB_VCHR_CHECK_STUB_TEXT;
GlobalVariables.getMessageMap().putError(propertyName, CUKFSKeyConstants.ERROR_DV_CHECK_STUB_REQUIRED);
return false;
}
if (!isAccountingLineEndDateValid(recurringDV)) {
return false;
}
}
return super.validate(event);
}
use of edu.cornell.kfs.fp.document.RecurringDisbursementVoucherDocument 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.RecurringDisbursementVoucherDocument in project cu-kfs by CU-CommunityApps.
the class RecurringDisbursementVoucherAction method confirmAndCancel.
public ActionForward confirmAndCancel(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
RecurringDisbursementVoucherForm recurringForm = (RecurringDisbursementVoucherForm) form;
RecurringDisbursementVoucherDocument recurringDV = (RecurringDisbursementVoucherDocument) recurringForm.getDocument();
if (StringUtils.isBlank(recurringDV.getPaymentCancelReason())) {
String paymentCancelFieldName = AccountingDocumentRuleBaseConstants.ERROR_PATH.DOCUMENT_ERROR_PREFIX + CUKFSPropertyConstants.RECURRING_DV_PAYMENT_CANCEL_REASON_FIELD_NAME;
GlobalVariables.getMessageMap().putError(paymentCancelFieldName, CUKFSKeyConstants.ERROR_RCDV_PAYMENT_CANCEL_REASON_REQUIRED);
} else {
Set<String> canceledPaymentGroups = getRecurringDisbursementVoucherDocumentService().cancelOpenPDPPayments(recurringDV, recurringDV.getPaymentCancelReason());
Set<String> canceledDVs = getRecurringDisbursementVoucherDocumentService().cancelSavedDisbursementVouchers(recurringDV, recurringDV.getPaymentCancelReason());
Set<String> canceledDVsApprovedNotExtracted = getRecurringDisbursementVoucherDocumentService().cancelDisbursementVouchersFinalizedNotExtracted(recurringDV, recurringDV.getPaymentCancelReason());
canceledDVs.addAll(canceledDVsApprovedNotExtracted);
reportCanceledItemsToBrowser(canceledPaymentGroups, canceledDVs);
forceRefreshOfPDPStatuses(recurringForm);
}
return mapping.findForward(RiceConstants.MAPPING_BASIC);
}
use of edu.cornell.kfs.fp.document.RecurringDisbursementVoucherDocument 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.RecurringDisbursementVoucherDocument in project cu-kfs by CU-CommunityApps.
the class RecurringDisbursementVoucherDocumentServiceImpl method findPdpStatuses.
@Override
public List<RecurringDisbursementVoucherPDPStatus> findPdpStatuses(RecurringDisbursementVoucherDocument recurringDV) {
List<RecurringDisbursementVoucherPDPStatus> pdpStatuses = new ArrayList<RecurringDisbursementVoucherPDPStatus>();
for (RecurringDisbursementVoucherDetail detail : recurringDV.getRecurringDisbursementVoucherDetails()) {
if (StringUtils.isNotEmpty(detail.getDvDocumentNumber())) {
DisbursementVoucherDocument disbursementVoucherDocument;
try {
disbursementVoucherDocument = (DisbursementVoucherDocument) getDocumentService().getByDocumentHeaderId(detail.getDvDocumentNumber());
} catch (WorkflowException e) {
LOG.error("findPdpStatuses: There was a problem getting DV from the recurring DV detail: " + e);
throw new RuntimeException(e);
}
pdpStatuses.add(buildRecurringDisbursementVoucherPDPStatus(disbursementVoucherDocument));
}
}
Collections.sort(pdpStatuses);
return pdpStatuses;
}
Aggregations