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();
}
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);
}
}
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);
}
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);
}
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);
}
Aggregations