Search in sources :

Example 1 with FormatProcessSummary

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

the class CuFormatAction method prepare.

@Override
public ActionForward prepare(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    CuFormatForm formatForm = (CuFormatForm) form;
    DateTimeService dateTimeService = SpringContext.getBean(DateTimeService.class);
    if (formatForm.getCampus() == null) {
        return mapping.findForward(PdpConstants.MAPPING_SELECTION);
    }
    // Figure out which ones they have selected
    List selectedCustomers = new ArrayList();
    for (CustomerProfile customer : formatForm.getCustomers()) {
        if (customer.isSelectedForFormat()) {
            selectedCustomers.add(customer);
        }
    }
    Date paymentDate = dateTimeService.convertToSqlDate(formatForm.getPaymentDate());
    Person kualiUser = GlobalVariables.getUserSession().getPerson();
    FormatProcessSummary formatProcessSummary = ((CuFormatService) formatService).startFormatProcess(kualiUser, formatForm.getCampus(), selectedCustomers, paymentDate, formatForm.getPaymentTypes(), formatForm.getPaymentDistribution());
    if (formatProcessSummary.getProcessSummaryList().size() == 0) {
        KNSGlobalVariables.getMessageList().add(PdpKeyConstants.Format.ERROR_PDP_NO_MATCHING_PAYMENT_FOR_FORMAT);
        return mapping.findForward(PdpConstants.MAPPING_SELECTION);
    }
    formatForm.setFormatProcessSummary(formatProcessSummary);
    return mapping.findForward(PdpConstants.MAPPING_CONTINUE);
}
Also used : FormatProcessSummary(org.kuali.kfs.pdp.businessobject.FormatProcessSummary) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) CustomerProfile(org.kuali.kfs.pdp.businessobject.CustomerProfile) DateTimeService(org.kuali.rice.core.api.datetime.DateTimeService) Person(org.kuali.rice.kim.api.identity.Person) Date(java.util.Date) CuFormatService(edu.cornell.kfs.pdp.service.CuFormatService)

Example 2 with FormatProcessSummary

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

the class AchBundlerFormatServiceImpl method performFormat.

/**
 ************************************************************************************************
 *     MODS START HERE
 *************************************************************************************************
 */
/**
 * MOD: Overridden to detect if the Bundle ACH Payments system parameter is on and if so, to
 * call the new helper method
 * @see org.kuali.kfs.pdp.service.FormatService#performFormat(java.lang.Integer)
 */
@Override
public void performFormat(Integer processId) throws FormatException {
    LOG.debug("performFormat() started - ACH Bundler Mod");
    // get the PaymentProcess for the given id
    @SuppressWarnings("rawtypes") Map primaryKeys = new HashMap();
    primaryKeys.put(PdpPropertyConstants.PaymentProcess.PAYMENT_PROCESS_ID, processId);
    PaymentProcess paymentProcess = (PaymentProcess) businessObjectService.findByPrimaryKey(PaymentProcess.class, primaryKeys);
    if (paymentProcess == null) {
        LOG.error("performFormat() Invalid proc ID " + processId);
        throw new RuntimeException("Invalid proc ID");
    }
    String processCampus = paymentProcess.getCampusCode();
    FormatProcessSummary postFormatProcessSummary = new FormatProcessSummary();
    // step 1 get ACH or Check, Bank info, ACH info, sorting
    Iterator<PaymentGroup> paymentGroupIterator = SpringContext.getBean(PaymentGroupService.class).getByProcess(paymentProcess);
    while (paymentGroupIterator.hasNext()) {
        PaymentGroup paymentGroup = paymentGroupIterator.next();
        LOG.debug("performFormat() Step 1 Payment Group ID " + paymentGroup.getId());
        // process payment group data
        boolean groupProcessed = processPaymentGroup(paymentGroup, paymentProcess);
        if (!groupProcessed) {
            throw new FormatException("Error encountered during format");
        }
        // save payment group
        businessObjectService.save(paymentGroup);
        // Add to summary information
        postFormatProcessSummary.add(paymentGroup);
    }
    /**
     * MOD: This mod calls a new method that bundles both Checks
     * and ACHs into single disbursements.
     */
    boolean disbursementNumbersAssigned = false;
    if (getAchBundlerHelperService().shouldBundleAchPayments()) {
        LOG.info("ACH BUNDLER MOD: ACTIVE - bundling ACH payments");
        disbursementNumbersAssigned = assignDisbursementNumbersAndBundle(paymentProcess, postFormatProcessSummary);
    } else {
        // KFSPTS-1460: Our method signature for FormatServiceImpl.assignDisbursementNumbersAndCombineChecks did not
        // match this method call: disbursementNumbersAssigned = assignDisbursementNumbersAndCombineChecks(paymentProcess, postFormatProcessSummary);
        // Added parameter "processCampus" so method signatures matched.
        LOG.info("ACH BUNDLER MOD: NOT Active - ACH payments will NOT be bundled");
        disbursementNumbersAssigned = assignDisbursementNumbersAndCombineChecks(paymentProcess, postFormatProcessSummary);
    }
    if (!disbursementNumbersAssigned) {
        throw new FormatException("Error encountered during format");
    }
    // step 3 save the summarizing info
    LOG.debug("performFormat() Save summarizing information");
    postFormatProcessSummary.save();
    // step 4 set formatted indicator to true and save in the db
    paymentProcess.setFormattedIndicator(true);
    businessObjectService.save(paymentProcess);
    // step 5 end the format process for this campus
    LOG.debug("performFormat() End the format process for this campus");
    endFormatProcess(processCampus);
/**
 * MOD: No longer automatically kick off the extractChecks process.  This has to be scheduled in the batch system or run manually there.
 * Otherwise, may conflict with grouping by payee done.
 */
// step 6 tell the extract batch job to start
// LOG.debug("performFormat() Start extract");
// extractChecks();
}
Also used : PaymentGroup(org.kuali.kfs.pdp.businessobject.PaymentGroup) PaymentProcess(org.kuali.kfs.pdp.businessobject.PaymentProcess) FormatProcessSummary(org.kuali.kfs.pdp.businessobject.FormatProcessSummary) HashMap(java.util.HashMap) HashMap(java.util.HashMap) Map(java.util.Map) PaymentGroupService(org.kuali.kfs.pdp.service.PaymentGroupService) FormatException(org.kuali.kfs.pdp.service.impl.exception.FormatException)

Example 3 with FormatProcessSummary

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

the class FormatAction method prepare.

/**
 * This method marks the payments for format
 *
 * @param mapping
 * @param form
 * @param request
 * @param response
 * @return
 * @throws Exception
 */
public ActionForward prepare(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    FormatForm formatForm = (FormatForm) form;
    DateTimeService dateTimeService = SpringContext.getBean(DateTimeService.class);
    if (formatForm.getCampus() == null) {
        return mapping.findForward(PdpConstants.MAPPING_SELECTION);
    }
    // Figure out which ones they have selected
    List selectedCustomers = new ArrayList();
    for (CustomerProfile customer : formatForm.getCustomers()) {
        if (customer.isSelectedForFormat()) {
            selectedCustomers.add(customer);
        }
    }
    Date paymentDate = dateTimeService.convertToSqlDate(formatForm.getPaymentDate());
    Person kualiUser = GlobalVariables.getUserSession().getPerson();
    FormatProcessSummary formatProcessSummary = formatService.startFormatProcess(kualiUser, formatForm.getCampus(), selectedCustomers, paymentDate, formatForm.getPaymentTypes());
    if (formatProcessSummary.getProcessSummaryList().size() == 0) {
        KNSGlobalVariables.getMessageList().add(PdpKeyConstants.Format.ERROR_PDP_NO_MATCHING_PAYMENT_FOR_FORMAT);
        return mapping.findForward(PdpConstants.MAPPING_SELECTION);
    }
    formatForm.setFormatProcessSummary(formatProcessSummary);
    return mapping.findForward(PdpConstants.MAPPING_CONTINUE);
}
Also used : FormatProcessSummary(org.kuali.kfs.pdp.businessobject.FormatProcessSummary) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) CustomerProfile(org.kuali.kfs.pdp.businessobject.CustomerProfile) DateTimeService(org.kuali.rice.core.api.datetime.DateTimeService) Person(org.kuali.rice.kim.api.identity.Person) Date(java.util.Date)

Example 4 with FormatProcessSummary

use of org.kuali.kfs.pdp.businessobject.FormatProcessSummary 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

FormatProcessSummary (org.kuali.kfs.pdp.businessobject.FormatProcessSummary)4 ArrayList (java.util.ArrayList)3 Date (java.util.Date)3 List (java.util.List)3 CustomerProfile (org.kuali.kfs.pdp.businessobject.CustomerProfile)3 PaymentGroup (org.kuali.kfs.pdp.businessobject.PaymentGroup)2 PaymentProcess (org.kuali.kfs.pdp.businessobject.PaymentProcess)2 DateTimeService (org.kuali.rice.core.api.datetime.DateTimeService)2 Person (org.kuali.rice.kim.api.identity.Person)2 CuFormatPaymentDao (edu.cornell.kfs.pdp.dataaccess.CuFormatPaymentDao)1 CuFormatService (edu.cornell.kfs.pdp.service.CuFormatService)1 Timestamp (java.sql.Timestamp)1 Calendar (java.util.Calendar)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 Map (java.util.Map)1 FormatProcess (org.kuali.kfs.pdp.businessobject.FormatProcess)1 PaymentStatus (org.kuali.kfs.pdp.businessobject.PaymentStatus)1 PaymentGroupService (org.kuali.kfs.pdp.service.PaymentGroupService)1 FormatException (org.kuali.kfs.pdp.service.impl.exception.FormatException)1