Search in sources :

Example 1 with FormatProcess

use of org.kuali.kfs.pdp.businessobject.FormatProcess in project cu-kfs by CU-CommunityApps.

the class CuFormatServiceImpl method startFormatProcess.

@Override
public FormatProcessSummary startFormatProcess(Person user, String campus, List<CustomerProfile> customers, Date paydate, String paymentTypes, String paymentDistribution) {
    LOG.debug("startFormatProcess() started");
    for (CustomerProfile element : customers) {
        LOG.debug("startFormatProcess() Customer: " + element);
    }
    // Create the process
    Date d = new Date();
    PaymentProcess paymentProcess = new PaymentProcess();
    paymentProcess.setCampusCode(campus);
    paymentProcess.setProcessUser(user);
    paymentProcess.setProcessTimestamp(new Timestamp(d.getTime()));
    this.businessObjectService.save(paymentProcess);
    // add an entry in the format process table (to lock the format process)
    FormatProcess formatProcess = new FormatProcess();
    formatProcess.setPhysicalCampusProcessCode(campus);
    formatProcess.setBeginFormat(dateTimeService.getCurrentTimestamp());
    formatProcess.setPaymentProcIdentifier(paymentProcess.getId().intValue());
    this.businessObjectService.save(formatProcess);
    Timestamp now = new Timestamp((new Date()).getTime());
    java.sql.Date sqlDate = new java.sql.Date(paydate.getTime());
    Calendar c = Calendar.getInstance();
    c.setTime(sqlDate);
    c.set(Calendar.HOUR, 11);
    c.set(Calendar.MINUTE, 59);
    c.set(Calendar.SECOND, 59);
    c.set(Calendar.MILLISECOND, 59);
    c.set(Calendar.AM_PM, Calendar.PM);
    Timestamp paydateTs = new Timestamp(c.getTime().getTime());
    LOG.debug("startFormatProcess() last update = " + now);
    LOG.debug("startFormatProcess() entered paydate = " + paydate);
    LOG.debug("startFormatProcess() actual paydate = " + paydateTs);
    PaymentStatus format = this.businessObjectService.findBySinglePrimaryKey(PaymentStatus.class, PdpConstants.PaymentStatusCodes.FORMAT);
    List customerIds = new ArrayList();
    for (Iterator iter = customers.iterator(); iter.hasNext(); ) {
        CustomerProfile element = (CustomerProfile) iter.next();
        customerIds.add(element.getId());
    }
    // Mark all of them ready for format
    Iterator groupIterator = ((CuFormatPaymentDao) formatPaymentDao).markPaymentsForFormat(customerIds, paydateTs, paymentTypes, paymentDistribution);
    while (groupIterator.hasNext()) {
        PaymentGroup paymentGroup = (PaymentGroup) groupIterator.next();
        paymentGroup.setLastUpdatedTimestamp(paydateTs);
        paymentGroup.setPaymentStatus(format);
        paymentGroup.setProcess(paymentProcess);
        businessObjectService.save(paymentGroup);
    }
    // summarize them
    FormatProcessSummary preFormatProcessSummary = new FormatProcessSummary();
    Iterator<PaymentGroup> iterator = this.paymentGroupService.getByProcess(paymentProcess);
    while (iterator.hasNext()) {
        PaymentGroup paymentGroup = iterator.next();
        preFormatProcessSummary.add(paymentGroup);
    }
    // if no payments found for format clear the format process
    if (preFormatProcessSummary.getProcessSummaryList().size() == 0) {
        LOG.debug("startFormatProcess() No payments to process.  Format process ending");
        // ?? maybe call end format process
        clearUnfinishedFormat(paymentProcess.getId().intValue());
    }
    return preFormatProcessSummary;
}
Also used : PaymentGroup(org.kuali.kfs.pdp.businessobject.PaymentGroup) Calendar(java.util.Calendar) ArrayList(java.util.ArrayList) CustomerProfile(org.kuali.kfs.pdp.businessobject.CustomerProfile) FormatProcess(org.kuali.kfs.pdp.businessobject.FormatProcess) Timestamp(java.sql.Timestamp) Date(java.util.Date) PaymentProcess(org.kuali.kfs.pdp.businessobject.PaymentProcess) FormatProcessSummary(org.kuali.kfs.pdp.businessobject.FormatProcessSummary) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) CuFormatPaymentDao(edu.cornell.kfs.pdp.dataaccess.CuFormatPaymentDao) PaymentStatus(org.kuali.kfs.pdp.businessobject.PaymentStatus)

Aggregations

CuFormatPaymentDao (edu.cornell.kfs.pdp.dataaccess.CuFormatPaymentDao)1 Timestamp (java.sql.Timestamp)1 ArrayList (java.util.ArrayList)1 Calendar (java.util.Calendar)1 Date (java.util.Date)1 Iterator (java.util.Iterator)1 List (java.util.List)1 CustomerProfile (org.kuali.kfs.pdp.businessobject.CustomerProfile)1 FormatProcess (org.kuali.kfs.pdp.businessobject.FormatProcess)1 FormatProcessSummary (org.kuali.kfs.pdp.businessobject.FormatProcessSummary)1 PaymentGroup (org.kuali.kfs.pdp.businessobject.PaymentGroup)1 PaymentProcess (org.kuali.kfs.pdp.businessobject.PaymentProcess)1 PaymentStatus (org.kuali.kfs.pdp.businessobject.PaymentStatus)1