use of org.kuali.rice.core.api.util.type.KualiInteger in project cu-kfs by CU-CommunityApps.
the class PayeeACHAccountExtractServiceImpl method addACHAccount.
/**
* Creates and routes a PAAT document to create a new ACH Account of the given payee type.
*/
protected String addACHAccount(Person payee, PayeeACHAccountExtractDetail achDetail, String payeeType) {
// Create and route a new PAAT (Payee ACH Account Maintenance) document.
String processingError = null;
try {
// Create document and set description.
MaintenanceDocument paatDocument = (MaintenanceDocument) documentService.getNewDocument(CUPdpConstants.PAYEE_ACH_ACCOUNT_EXTRACT_MAINT_DOC_TYPE);
paatDocument.getDocumentHeader().setDocumentDescription(getDocumentDescription(payee, PayeeIdTypeCodes.ENTITY.equals(payeeType), true));
// Configure as "New" maintenance and get maintained object.
PayeeACHAccountMaintainableImpl maintainable = (PayeeACHAccountMaintainableImpl) paatDocument.getNewMaintainableObject();
maintainable.setMaintenanceAction(KFSConstants.MAINTENANCE_NEW_ACTION);
PayeeACHAccount achAccount = (PayeeACHAccount) maintainable.getDataObject();
// Setup payee ID and type.
if (PayeeIdTypeCodes.ENTITY.equals(payeeType)) {
achAccount.setPayeeIdNumber(payee.getEntityId());
} else if (PayeeIdTypeCodes.EMPLOYEE.equals(payeeType)) {
achAccount.setPayeeIdNumber(payee.getEmployeeId());
} else {
processingError = new String("addACHAccount: " + achDetail.getLogData() + ": Unexpected payee ID type '" + payeeType + "' for automated Payee during ACH Account creation attempt.");
LOG.error(processingError);
return processingError;
}
achAccount.setPayeeIdentifierTypeCode(payeeType);
// Setup other fields.
achAccount.setAchAccountGeneratedIdentifier(new KualiInteger(sequenceAccessorService.getNextAvailableSequenceNumber(PdpConstants.ACH_ACCOUNT_IDENTIFIER_SEQUENCE_NAME)));
achAccount.setAchTransactionType(getDirectDepositTransactionType());
achAccount.setBankRoutingNumber(achDetail.getBankRoutingNumber());
achAccount.setBankAccountNumber(achDetail.getBankAccountNumber());
achAccount.setBankAccountTypeCode(getACHTransactionCode(achDetail.getBankAccountType()));
if (StringUtils.isNotBlank(payee.getNameUnmasked())) {
achAccount.setPayeeName(payee.getNameUnmasked());
}
if (StringUtils.isNotBlank(payee.getEmailAddressUnmasked())) {
achAccount.setPayeeEmailAddress(payee.getEmailAddressUnmasked());
}
achAccount.setActive(true);
// Add a note indicating that this document was generated by a batch process.
addNote(paatDocument, parameterService.getParameterValueAsString(PayeeACHAccountExtractStep.class, CUPdpParameterConstants.GENERATED_PAYEE_ACH_ACCOUNT_DOC_NOTE_TEXT));
// Route the document and send notifications.
paatDocument = (MaintenanceDocument) documentService.routeDocument(paatDocument, KFSConstants.EMPTY_STRING, null);
sendPayeeACHAccountAddOrUpdateEmail((PayeeACHAccount) paatDocument.getNewMaintainableObject().getDataObject(), payee, getPayeeACHAccountAddOrUpdateEmailSubject(true), getUnresolvedPayeeACHAccountAddOrUpdateEmailBody(true));
} catch (Exception e) {
LOG.error("addACHAccount STE " + e.getStackTrace() + e.toString());
LOG.error(getFailRequestMessage(e));
processingError = new String("addACHAccount: " + achDetail.getLogData() + " STE was generated. " + getFailRequestMessage(e));
}
return processingError;
}
use of org.kuali.rice.core.api.util.type.KualiInteger in project cu-kfs by CU-CommunityApps.
the class CuPaymentMaintenanceServiceImpl method cancelDisbursement.
@Override
public boolean cancelDisbursement(Integer paymentGroupId, Integer paymentDetailId, String note, Person user) {
LOG.debug("cancelDisbursement() started");
if (!pdpAuthorizationService.hasCancelPaymentPermission(user.getPrincipalId())) {
LOG.warn("cancelDisbursement() User " + user.getPrincipalId() + " does not have rights to cancel payments. This should not happen unless user is URL spoofing.");
throw new RuntimeException("cancelDisbursement() User " + user.getPrincipalId() + " does not have rights to cancel payments. This should not happen unless user is URL spoofing.");
}
PaymentGroup paymentGroup = this.paymentGroupService.get(paymentGroupId);
if (paymentGroup == null) {
LOG.debug("cancelDisbursement() Disbursement not found; throw exception.");
GlobalVariables.getMessageMap().putError(KFSConstants.GLOBAL_ERRORS, PdpKeyConstants.PaymentDetail.ErrorMessages.ERROR_DISBURSEMENT_NOT_FOUND);
return false;
}
// get the target PaymentGroup info
PaymentDetail targetPd = getPaymentDetail(paymentDetailId);
KualiInteger targetGroupId = targetPd.getPaymentGroupId();
PaymentGroup targetPg = getPaymentGroup(targetGroupId);
String targetDvTypeCode = targetPg.getDisbursementTypeCode();
String targetDvBankCode = targetPg.getBankCode();
String paymentStatus = paymentGroup.getPaymentStatus().getCode();
if (!(PdpConstants.PaymentStatusCodes.CANCEL_DISBURSEMENT.equals(paymentStatus))) {
if (((PdpConstants.PaymentStatusCodes.EXTRACTED.equals(paymentStatus)) && (ObjectUtils.isNotNull(paymentGroup.getDisbursementDate()))) || (PdpConstants.PaymentStatusCodes.PENDING_ACH.equals(paymentStatus))) {
LOG.debug("cancelDisbursement() Payment status is " + paymentStatus + "; continue with cancel.");
List<PaymentGroup> allDisbursementPaymentGroups = this.paymentGroupService.getByDisbursementNumber(paymentGroup.getDisbursementNbr().intValue());
for (PaymentGroup element : allDisbursementPaymentGroups) {
// should be the same DV type and the same bank
if (!(element.getDisbursementTypeCode().equalsIgnoreCase(targetDvTypeCode) && element.getBankCode().equalsIgnoreCase(targetDvBankCode))) {
continue;
}
PaymentGroupHistory pgh = new PaymentGroupHistory();
if (!element.getPaymentDetails().get(0).isDisbursementActionAllowed()) {
LOG.warn("cancelDisbursement() Payment does not allow disbursement action. This should not happen unless user is URL spoofing.");
throw new RuntimeException("cancelDisbursement() Payment does not allow disbursement action. This should not happen unless user is URL spoofing.");
}
if ((ObjectUtils.isNotNull(element.getDisbursementType())) && (element.getDisbursementType().getCode().equals(PdpConstants.DisbursementTypeCodes.CHECK))) {
pgh.setPmtCancelExtractStat(Boolean.FALSE);
}
changeStatus(element, PdpConstants.PaymentStatusCodes.CANCEL_DISBURSEMENT, PdpConstants.PaymentChangeCodes.CANCEL_DISBURSEMENT, note, user, pgh);
glPendingTransactionService.generateCancellationGeneralLedgerPendingEntry(element);
// set primary cancel indicator for EPIC to use
// these payment details will be canceled when running processPdpCancelAndPaidJOb
Map<String, KualiInteger> primaryKeys = new HashMap<>();
primaryKeys.put(PdpPropertyConstants.PaymentDetail.PAYMENT_DETAIL_PAYMENT_GROUP_ID, element.getId());
// cancel all payment details for payment group
List<PaymentDetail> pds = (List<PaymentDetail>) this.businessObjectService.findMatching(PaymentDetail.class, primaryKeys);
if (pds != null && !pds.isEmpty()) {
for (PaymentDetail pd : pds) {
pd.setPrimaryCancelledPayment(Boolean.TRUE);
this.businessObjectService.save(pd);
}
}
}
LOG.debug("cancelDisbursement() Disbursement cancelled; exit method.");
} else {
if (LOG.isDebugEnabled()) {
LOG.debug("cancelDisbursement() Payment status is " + paymentStatus + " and disbursement date is " + paymentGroup.getDisbursementDate() + "; cannot cancel payment in this status");
}
GlobalVariables.getMessageMap().putError(KFSConstants.GLOBAL_ERRORS, PdpKeyConstants.PaymentDetail.ErrorMessages.ERROR_DISBURSEMENT_INVALID_TO_CANCEL);
return false;
}
} else {
LOG.debug("cancelDisbursement() Disbursement has already been cancelled; exit method.");
}
return true;
}
use of org.kuali.rice.core.api.util.type.KualiInteger in project cu-kfs by CU-CommunityApps.
the class DisbursementVoucherDocumentBatchServiceImpl method getNewDisbursementVoucherBatch.
/**
* Creates and populates a new DisbursementVoucherBatch instance
*
* @return DisbursementVoucherBatch
*/
protected DisbursementVoucherBatch getNewDisbursementVoucherBatch() {
DisbursementVoucherBatch disbursementVoucherBatch = new DisbursementVoucherBatch();
// get next available batch id
KualiInteger batchId = new KualiInteger(sequenceAccessorService.getNextAvailableSequenceNumber(FPConstants.DV_BATCH_ID_SEQUENCE_NAME));
disbursementVoucherBatch.setBatchId(batchId);
disbursementVoucherBatch.setProcessPrincipalId(GlobalVariables.getUserSession().getPerson().getPrincipalId());
disbursementVoucherBatch.setProcessTimestamp(dateTimeService.getCurrentTimestamp());
return disbursementVoucherBatch;
}
use of org.kuali.rice.core.api.util.type.KualiInteger in project cu-kfs by CU-CommunityApps.
the class CheckReconciliationDaoOjb method getNewCheckReconciliations.
/**
* @see com.rsmart.kuali.kfs.cr.dataaccess.CheckReconciliationDao#getNewCheckReconciliations(java.util.Collection)
*/
public Collection<CheckReconciliation> getNewCheckReconciliations(Collection<Bank> banks) {
Collection<CheckReconciliation> data = new ArrayList<CheckReconciliation>();
CheckReconciliation cr = null;
// String sql = "SELECT p.disb_nbr, p.disb_ts, SUM(d.net_pmt_amt), b.bnk_cd,p.pmt_payee_nm, p.payee_id_typ_cd,p.payee_id FROM pdp_pmt_grp_t p, pdp_pmt_dtl_t d, fp_bank_t b WHERE p.bnk_cd = b.bnk_cd AND p.pmt_grp_id = d.pmt_grp_id AND p.disb_typ_cd = 'CHCK' AND NOT EXISTS ( SELECT 'x' from cu_cr_check_recon_t cr WHERE cr.check_nbr = p.disb_nbr AND cr.bank_account_nbr = b.bnk_acct_nbr) GROUP BY p.disb_nbr, p.disb_ts, b.bnk_cd";
String sql = "SELECT p.disb_nbr, p.disb_ts, SUM(d.net_pmt_amt), b.bnk_cd,p.pmt_payee_nm, p.payee_id_typ_cd,p.payee_id FROM pdp_pmt_grp_t p, pdp_pmt_dtl_t d, fp_bank_t b WHERE p.bnk_cd = b.bnk_cd AND p.pmt_grp_id = d.pmt_grp_id AND p.disb_ts is not null AND p.disb_typ_cd = 'CHCK' AND NOT EXISTS ( SELECT 'x' from cu_cr_check_recon_t cr WHERE cr.check_nbr = p.disb_nbr AND cr.bank_account_nbr = b.bnk_acct_nbr) group by p.disb_nbr, p.disb_ts, b.bnk_cd, p.pmt_payee_nm, p.payee_id_typ_cd, p.payee_id";
try {
Connection c = getPersistenceBroker(true).serviceConnectionManager().getConnection();
Statement s = c.createStatement();
ResultSet rs = s.executeQuery(sql);
String bnkCd = null;
while (rs.next()) {
cr = new CheckReconciliation();
cr.setCheckNumber(new KualiInteger(rs.getInt(1)));
// This is last status change date.
cr.setCheckDate(new java.sql.Date(rs.getDate(2).getTime()));
cr.setAmount(new KualiDecimal(rs.getDouble(3)));
bnkCd = rs.getString(4);
cr.setPayeeName(rs.getString(5));
cr.setPayeeType(rs.getString(6));
cr.setPayeeId(rs.getString(7));
for (Bank bank : banks) {
if (bank.getBankCode().equals(bnkCd)) {
cr.setBankAccountNumber(bank.getBankAccountNumber());
}
}
cr.setGlTransIndicator(Boolean.FALSE);
if (cr.getAmount().isZero()) {
cr.setStatus(CRConstants.EXCP);
} else {
cr.setStatus(CRConstants.ISSUED);
}
cr.setSourceCode(CRConstants.PDP_SRC);
cr.setBankCode(bnkCd);
cr.setLastUpdate(new Timestamp(new java.util.Date().getTime()));
data.add(cr);
}
s.close();
} catch (Exception e) {
LOG.error("getNewCheckReconciliations", e);
}
return data;
}
use of org.kuali.rice.core.api.util.type.KualiInteger in project cu-kfs by CU-CommunityApps.
the class GlTransactionServiceImpl method generateGlPendingTransaction.
/**
* Generate GlPendingTransaction
*
* @param paymentGroup
* @param financialDocumentTypeCode
* @param stale
*/
private void generateGlPendingTransaction(PaymentGroup paymentGroup, String financialDocumentTypeCode, boolean stale) {
List<PaymentAccountDetail> accountListings = new ArrayList<PaymentAccountDetail>();
for (PaymentDetail paymentDetail : paymentGroup.getPaymentDetails()) {
accountListings.addAll(paymentDetail.getAccountDetail());
}
GeneralLedgerPendingEntrySequenceHelper sequenceHelper = new GeneralLedgerPendingEntrySequenceHelper();
for (PaymentAccountDetail paymentAccountDetail : accountListings) {
GlPendingTransaction glPendingTransaction = new GlPendingTransaction();
glPendingTransaction.setSequenceNbr(new KualiInteger(sequenceHelper.getSequenceCounter()));
glPendingTransaction.setFdocRefTypCd(paymentAccountDetail.getPaymentDetail().getFinancialDocumentTypeCode());
glPendingTransaction.setFsRefOriginCd(paymentAccountDetail.getPaymentDetail().getFinancialSystemOriginCode());
glPendingTransaction.setFinancialBalanceTypeCode(KFSConstants.BALANCE_TYPE_ACTUAL);
Date transactionTimestamp = new Date(dateTimeService.getCurrentDate().getTime());
glPendingTransaction.setTransactionDt(transactionTimestamp);
AccountingPeriod fiscalPeriod = accountingPeriodService.getByDate(new java.sql.Date(transactionTimestamp.getTime()));
glPendingTransaction.setUniversityFiscalYear(fiscalPeriod.getUniversityFiscalYear());
glPendingTransaction.setUnivFiscalPrdCd(fiscalPeriod.getUniversityFiscalPeriodCode());
glPendingTransaction.setSubAccountNumber(paymentAccountDetail.getSubAccountNbr());
glPendingTransaction.setChartOfAccountsCode(paymentAccountDetail.getFinChartCode());
glPendingTransaction.setFdocNbr(paymentGroup.getDisbursementNbr().toString());
// Set doc type and origin code
glPendingTransaction.setFinancialDocumentTypeCode(financialDocumentTypeCode);
glPendingTransaction.setFsOriginCd(CRConstants.CR_FDOC_ORIGIN_CODE);
String clAcct = parameterService.getParameterValueAsString(CheckReconciliationImportStep.class, CRConstants.CLEARING_ACCOUNT);
String obCode = parameterService.getParameterValueAsString(CheckReconciliationImportStep.class, CRConstants.CLEARING_OBJECT_CODE);
String coaCode = parameterService.getParameterValueAsString(CheckReconciliationImportStep.class, CRConstants.CLEARING_COA);
// Use clearing parameters if stale
String accountNbr = stale ? clAcct : paymentAccountDetail.getAccountNbr();
String finObjectCode = stale ? obCode : paymentAccountDetail.getFinObjectCode();
String finCoaCd = stale ? coaCode : paymentAccountDetail.getFinChartCode();
Boolean relieveLiabilities = paymentGroup.getBatch().getCustomerProfile().getRelieveLiabilities();
if ((relieveLiabilities != null) && (relieveLiabilities.booleanValue()) && paymentAccountDetail.getPaymentDetail().getFinancialDocumentTypeCode() != null) {
OffsetDefinition offsetDefinition = SpringContext.getBean(OffsetDefinitionService.class).getByPrimaryId(glPendingTransaction.getUniversityFiscalYear(), glPendingTransaction.getChartOfAccountsCode(), paymentAccountDetail.getPaymentDetail().getFinancialDocumentTypeCode(), glPendingTransaction.getFinancialBalanceTypeCode());
glPendingTransaction.setAccountNumber(accountNbr);
glPendingTransaction.setChartOfAccountsCode(finCoaCd);
glPendingTransaction.setFinancialObjectCode(offsetDefinition != null ? offsetDefinition.getFinancialObjectCode() : finObjectCode);
glPendingTransaction.setFinancialSubObjectCode(KFSConstants.getDashFinancialSubObjectCode());
} else {
glPendingTransaction.setAccountNumber(accountNbr);
glPendingTransaction.setChartOfAccountsCode(finCoaCd);
glPendingTransaction.setFinancialObjectCode(finObjectCode);
glPendingTransaction.setFinancialSubObjectCode(paymentAccountDetail.getFinSubObjectCode());
}
glPendingTransaction.setProjectCd(paymentAccountDetail.getProjectCode());
if (paymentAccountDetail.getAccountNetAmount().bigDecimalValue().signum() >= 0) {
glPendingTransaction.setDebitCrdtCd(KFSConstants.GL_CREDIT_CODE);
} else {
glPendingTransaction.setDebitCrdtCd(KFSConstants.GL_DEBIT_CODE);
}
glPendingTransaction.setAmount(paymentAccountDetail.getAccountNetAmount().abs());
String trnDesc;
String payeeName = paymentGroup.getPayeeName();
trnDesc = payeeName.length() > 40 ? payeeName.substring(0, 40) : StringUtils.rightPad(payeeName, 40);
String poNbr = paymentAccountDetail.getPaymentDetail().getPurchaseOrderNbr();
if (StringUtils.isNotBlank(poNbr)) {
trnDesc += " " + (poNbr.length() > 9 ? poNbr.substring(0, 9) : StringUtils.rightPad(poNbr, 9));
}
String invoiceNbr = paymentAccountDetail.getPaymentDetail().getInvoiceNbr();
if (StringUtils.isNotBlank(invoiceNbr)) {
trnDesc += " " + (invoiceNbr.length() > 14 ? invoiceNbr.substring(0, 14) : StringUtils.rightPad(invoiceNbr, 14));
}
if (trnDesc.length() > 40) {
trnDesc = trnDesc.substring(0, 40);
}
glPendingTransaction.setDescription(trnDesc);
glPendingTransaction.setOrgDocNbr(paymentAccountDetail.getPaymentDetail().getOrganizationDocNbr());
glPendingTransaction.setOrgReferenceId(paymentAccountDetail.getOrgReferenceId());
glPendingTransaction.setFdocRefNbr(paymentAccountDetail.getPaymentDetail().getCustPaymentDocNbr());
// update the offset account if necessary
SpringContext.getBean(FlexibleOffsetAccountService.class).updateOffset(glPendingTransaction);
this.businessObjectService.save(glPendingTransaction);
sequenceHelper.increment();
}
}
Aggregations