Search in sources :

Example 11 with NonTransactional

use of org.kuali.kfs.sys.service.NonTransactional in project cu-kfs by CU-CommunityApps.

the class CuElectronicInvoiceHelperServiceImpl method doMatchingProcess.

// end KFSUPGRADE-484
// KFSUPGRADE-485
@Override
@NonTransactional
public boolean doMatchingProcess(ElectronicInvoiceRejectDocument rejectDocument) {
    /**
     * This is needed here since if the user changes the DUNS number.
     */
    validateVendorDetails(rejectDocument);
    Map itemTypeMappings = getItemTypeMappings(rejectDocument.getVendorHeaderGeneratedIdentifier(), rejectDocument.getVendorDetailAssignedIdentifier());
    Map kualiItemTypes = getKualiItemTypes();
    CuElectronicInvoiceOrderHolder rejectDocHolder = new CuElectronicInvoiceOrderHolder(rejectDocument, itemTypeMappings, kualiItemTypes);
    matchingService.doMatchingProcess(rejectDocHolder);
    // KFSPTS-1719 : save the nomatchingitems found during match process.
    ((CuElectronicInvoiceRejectDocument) rejectDocument).setNonMatchItems(((CuElectronicInvoiceOrderHolder) rejectDocHolder).getNonMatchItems());
    /**
     * Once we're through with the matching process, it's needed to check whether it's possible
     * to create PREQ for the reject doc
     */
    if (!rejectDocHolder.isInvoiceRejected()) {
        validateInvoiceOrderValidForPREQCreation(rejectDocHolder);
    }
    // determine which of the reject reasons we should suppress based on the parameter
    List<String> ignoreRejectTypes = new ArrayList<String>(parameterService.getParameterValuesAsString(PurapConstants.PURAP_NAMESPACE, "ElectronicInvoiceReject", "SUPPRESS_REJECT_REASON_CODES_ON_EIRT_APPROVAL"));
    List<ElectronicInvoiceRejectReason> rejectReasonsToDelete = new ArrayList<ElectronicInvoiceRejectReason>();
    for (ElectronicInvoiceRejectReason rejectReason : rejectDocument.getInvoiceRejectReasons()) {
        String rejectedReasonTypeCode = rejectReason.getInvoiceRejectReasonTypeCode();
        if (StringUtils.isNotBlank(rejectedReasonTypeCode)) {
            if (ignoreRejectTypes.contains(rejectedReasonTypeCode)) {
                rejectReasonsToDelete.add(rejectReason);
            }
        }
    }
    // remove the flagged reject reasons
    if (!rejectReasonsToDelete.isEmpty()) {
        rejectDocument.getInvoiceRejectReasons().removeAll(rejectReasonsToDelete);
    }
    // if no reject reasons, then clear error messages
    if (rejectDocument.getInvoiceRejectReasons().isEmpty()) {
        GlobalVariables.getMessageMap().clearErrorMessages();
    }
    // this automatically returns false if there are no reject reasons
    return !rejectDocHolder.isInvoiceRejected();
}
Also used : ArrayList(java.util.ArrayList) CuElectronicInvoiceRejectDocument(edu.cornell.kfs.module.purap.document.CuElectronicInvoiceRejectDocument) ElectronicInvoiceRejectReason(org.kuali.kfs.module.purap.businessobject.ElectronicInvoiceRejectReason) Map(java.util.Map) HashMap(java.util.HashMap) NonTransactional(org.kuali.kfs.sys.service.NonTransactional)

Example 12 with NonTransactional

use of org.kuali.kfs.sys.service.NonTransactional in project cu-kfs by CU-CommunityApps.

the class CuPaymentRequestServiceImpl method populatePaymentRequest.

@Override
@NonTransactional
public void populatePaymentRequest(PaymentRequestDocument paymentRequestDocument) {
    super.populatePaymentRequest(paymentRequestDocument);
    // KFSUPGRADE-779
    // reset bank code
    paymentRequestDocument.setBankCode(null);
    paymentRequestDocument.setBank(null);
    // set bank code to default bank code in the system parameter
    Bank defaultBank = null;
    if (StringUtils.equals(PaymentMethod.PM_CODE_WIRE, ((CuPaymentRequestDocument) paymentRequestDocument).getPaymentMethodCode()) || StringUtils.equals(PaymentMethod.PM_CODE_FOREIGN_DRAFT, ((CuPaymentRequestDocument) paymentRequestDocument).getPaymentMethodCode())) {
        defaultBank = SpringContext.getBean(CUBankService.class).getDefaultBankByDocType(CuPaymentRequestDocument.DOCUMENT_TYPE_NON_CHECK);
    } else if (!StringUtils.equals(PaymentMethod.PM_CODE_INTERNAL_BILLING, ((CuPaymentRequestDocument) paymentRequestDocument).getPaymentMethodCode())) {
        defaultBank = SpringContext.getBean(BankService.class).getDefaultBankByDocType(PaymentRequestDocument.class);
    }
    if (defaultBank != null) {
        paymentRequestDocument.setBankCode(defaultBank.getBankCode());
        paymentRequestDocument.setBank(defaultBank);
    }
}
Also used : CUBankService(edu.cornell.kfs.sys.service.CUBankService) BankService(org.kuali.kfs.sys.service.BankService) Bank(org.kuali.kfs.sys.businessobject.Bank) CuPaymentRequestDocument(edu.cornell.kfs.module.purap.document.CuPaymentRequestDocument) NonTransactional(org.kuali.kfs.sys.service.NonTransactional)

Example 13 with NonTransactional

use of org.kuali.kfs.sys.service.NonTransactional in project cu-kfs by CU-CommunityApps.

the class CuPaymentRequestServiceImpl method calculatePayDate.

/**
 * Overridden to use the Net Due Number for the relevant calculations if the Discount Due Number is zero.
 *
 * @see org.kuali.kfs.module.purap.document.service.PaymentRequestService#calculatePayDate(java.sql.Date,
 *      org.kuali.kfs.vnd.businessobject.PaymentTermType)
 */
@Override
@NonTransactional
public java.sql.Date calculatePayDate(Date invoiceDate, PaymentTermType terms) {
    LOG.debug("calculatePayDate() started");
    // calculate the invoice + processed calendar
    Calendar invoicedDateCalendar = dateTimeService.getCalendar(invoiceDate);
    Calendar processedDateCalendar = dateTimeService.getCurrentCalendar();
    // add default number of days to processed
    String defaultDays = parameterService.getParameterValueAsString(PaymentRequestDocument.class, PurapParameterConstants.PURAP_PREQ_PAY_DATE_DEFAULT_NUMBER_OF_DAYS);
    processedDateCalendar.add(Calendar.DAY_OF_MONTH, Integer.parseInt(defaultDays));
    if (ObjectUtils.isNull(terms) || StringUtils.isEmpty(terms.getVendorPaymentTermsCode())) {
        invoicedDateCalendar.add(Calendar.DAY_OF_MONTH, PurapConstants.PREQ_PAY_DATE_EMPTY_TERMS_DEFAULT_DAYS);
        return returnLaterDate(invoicedDateCalendar, processedDateCalendar);
    }
    // Retrieve pay date variation parameter (currently defined as 2).  See parameter description for explanation of it's use.
    String payDateVariance = parameterService.getParameterValueAsString(PaymentRequestDocument.class, PurapParameterConstants.PURAP_PREQ_PAY_DATE_VARIANCE);
    Integer payDateVarianceInt = Integer.valueOf(payDateVariance);
    Integer discountDueNumber = terms.getVendorDiscountDueNumber();
    Integer netDueNumber = terms.getVendorNetDueNumber();
    // ==== CU Customization: If Discount Due Number is zero, use the Net Due Number instead. ====
    if (ObjectUtils.isNotNull(discountDueNumber) && !discountDueNumber.equals(Integer.valueOf(0))) {
        // Decrease discount due number by the pay date variance
        discountDueNumber -= payDateVarianceInt;
        if (discountDueNumber < 0) {
            discountDueNumber = 0;
        }
        String discountDueTypeDescription = terms.getVendorDiscountDueTypeDescription();
        paymentTermsDateCalculation(discountDueTypeDescription, invoicedDateCalendar, discountDueNumber);
    } else if (ObjectUtils.isNotNull(netDueNumber)) {
        // Decrease net due number by the pay date variance
        netDueNumber -= payDateVarianceInt;
        if (netDueNumber < 0) {
            netDueNumber = 0;
        }
        String netDueTypeDescription = terms.getVendorNetDueTypeDescription();
        paymentTermsDateCalculation(netDueTypeDescription, invoicedDateCalendar, netDueNumber);
    } else {
        throw new RuntimeException("Neither discount or net number were specified for this payment terms type");
    }
    // return the later date
    return returnLaterDate(invoicedDateCalendar, processedDateCalendar);
}
Also used : Calendar(java.util.Calendar) NonTransactional(org.kuali.kfs.sys.service.NonTransactional)

Example 14 with NonTransactional

use of org.kuali.kfs.sys.service.NonTransactional in project cu-kfs by CU-CommunityApps.

the class CuPaymentRequestServiceImpl method requestCancelOnPaymentRequest.

@Override
@NonTransactional
public void requestCancelOnPaymentRequest(PaymentRequestDocument document, String note) throws Exception {
    // save the note
    Note noteObj = documentService.createNoteFromDocument(document, note);
    document.addNote(noteObj);
    noteService.save(noteObj);
    document.setPaymentRequestedCancelIndicator(true);
    document.setLastActionPerformedByPersonId(GlobalVariables.getUserSession().getPerson().getPrincipalId());
    document.setAccountsPayableRequestCancelIdentifier(GlobalVariables.getUserSession().getPerson().getPrincipalId());
    purapService.saveDocumentNoValidation(document);
    // force reindexing
    reIndexDocument(document);
}
Also used : Note(org.kuali.kfs.krad.bo.Note) NonTransactional(org.kuali.kfs.sys.service.NonTransactional)

Example 15 with NonTransactional

use of org.kuali.kfs.sys.service.NonTransactional in project cu-kfs by CU-CommunityApps.

the class CuPaymentRequestServiceImpl method markPaid.

@Override
@NonTransactional
public void markPaid(PaymentRequestDocument pr, Date processDate) {
    LOG.debug("markPaid() started");
    pr.setPaymentPaidTimestamp(new Timestamp(processDate.getTime()));
    purapService.saveDocumentNoValidation(pr);
    // force reindexing
    reIndexDocument(pr);
}
Also used : Timestamp(java.sql.Timestamp) NonTransactional(org.kuali.kfs.sys.service.NonTransactional)

Aggregations

NonTransactional (org.kuali.kfs.sys.service.NonTransactional)16 Note (org.kuali.kfs.krad.bo.Note)6 HashMap (java.util.HashMap)4 CapitalAssetInformation (org.kuali.kfs.fp.businessobject.CapitalAssetInformation)3 CuPaymentRequestDocument (edu.cornell.kfs.module.purap.document.CuPaymentRequestDocument)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 CuElectronicInvoiceRejectDocument (edu.cornell.kfs.module.purap.document.CuElectronicInvoiceRejectDocument)1 CUBankService (edu.cornell.kfs.sys.service.CUBankService)1 Timestamp (java.sql.Timestamp)1 Calendar (java.util.Calendar)1 List (java.util.List)1 MaintenanceDocument (org.kuali.kfs.kns.document.MaintenanceDocument)1 AssetGlobal (org.kuali.kfs.module.cam.businessobject.AssetGlobal)1 AssetPaymentAssetDetail (org.kuali.kfs.module.cam.businessobject.AssetPaymentAssetDetail)1 AssetPaymentDocument (org.kuali.kfs.module.cam.document.AssetPaymentDocument)1 ElectronicInvoiceRejectReason (org.kuali.kfs.module.purap.businessobject.ElectronicInvoiceRejectReason)1 PaymentRequestDocument (org.kuali.kfs.module.purap.document.PaymentRequestDocument)1 CustomerProfile (org.kuali.kfs.pdp.businessobject.CustomerProfile)1 PaymentDetail (org.kuali.kfs.pdp.businessobject.PaymentDetail)1