Search in sources :

Example 6 with RecurringDisbursementVoucherDetail

use of edu.cornell.kfs.fp.businessobject.RecurringDisbursementVoucherDetail in project cu-kfs by CU-CommunityApps.

the class RecurringDisbursementVoucherDocumentServiceImpl method updateRecurringDisbursementVoucherDetails.

@Override
public void updateRecurringDisbursementVoucherDetails(RecurringDisbursementVoucherDocument recurringDisbursementVoucherDocument) {
    if (recurringDisbursementVoucherDocument.getRecurringDisbursementVoucherDetails() == null || recurringDisbursementVoucherDocument.getRecurringDisbursementVoucherDetails().isEmpty()) {
        recurringDisbursementVoucherDocument.setRecurringDisbursementVoucherDetails(new ArrayList<RecurringDisbursementVoucherDetail>());
    } else {
        resetAmounts(recurringDisbursementVoucherDocument.getRecurringDisbursementVoucherDetails());
    }
    int rowId = 0;
    for (Object accountingLine : recurringDisbursementVoucherDocument.getSourceAccountingLines()) {
        ScheduledSourceAccountingLine scheduledAccountingLine = (ScheduledSourceAccountingLine) accountingLine;
        TreeMap<Date, KualiDecimal> datesAndAmounts = getScheduledAccountingLineService().generateDatesAndAmounts(scheduledAccountingLine, rowId);
        for (Date date : datesAndAmounts.keySet()) {
            KualiDecimal amount = datesAndAmounts.get(date);
            RecurringDisbursementVoucherDetail detail = getDetailtem(recurringDisbursementVoucherDocument.getRecurringDisbursementVoucherDetails(), date);
            detail.setDvCheckAmount(amount.add(detail.getDvCheckAmount()));
            detail.setRecurringDVDocumentNumber(recurringDisbursementVoucherDocument.getDocumentNumber());
            if (StringUtils.isEmpty(detail.getDvCheckStub())) {
                detail.setDvCheckStub(recurringDisbursementVoucherDocument.getDisbVchrCheckStubText());
            }
        }
        rowId++;
    }
    recurringDisbursementVoucherDocument.setRecurringDisbursementVoucherDetails(removeZeroAmounts(recurringDisbursementVoucherDocument.getRecurringDisbursementVoucherDetails()));
    Collections.sort(recurringDisbursementVoucherDocument.getRecurringDisbursementVoucherDetails());
}
Also used : KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) RecurringDisbursementVoucherDetail(edu.cornell.kfs.fp.businessobject.RecurringDisbursementVoucherDetail) ScheduledSourceAccountingLine(edu.cornell.kfs.fp.businessobject.ScheduledSourceAccountingLine) Date(java.sql.Date)

Aggregations

RecurringDisbursementVoucherDetail (edu.cornell.kfs.fp.businessobject.RecurringDisbursementVoucherDetail)6 CuDisbursementVoucherDocument (edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument)3 Date (java.sql.Date)3 ScheduledSourceAccountingLine (edu.cornell.kfs.fp.businessobject.ScheduledSourceAccountingLine)2 RecurringDisbursementVoucherDocument (edu.cornell.kfs.fp.document.RecurringDisbursementVoucherDocument)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 DisbursementVoucherDocument (org.kuali.kfs.fp.document.DisbursementVoucherDocument)2 KualiDecimal (org.kuali.rice.core.api.util.type.KualiDecimal)2 WorkflowException (org.kuali.rice.kew.api.exception.WorkflowException)2 RecurringDisbursementVoucherPDPStatus (edu.cornell.kfs.fp.businessobject.RecurringDisbursementVoucherPDPStatus)1 SourceAccountingLine (org.kuali.kfs.sys.businessobject.SourceAccountingLine)1