use of org.kuali.kfs.pdp.businessobject.AchAccountNumber in project cu-kfs by CU-CommunityApps.
the class CuFormatServiceImpl method populateDisbursementType.
/**
* This method sets the appropriate disbursement type on the Payment Group to either ACH or CHCK.
*
* @param paymentGroup
*/
protected void populateDisbursementType(PaymentGroup paymentGroup) {
DisbursementType disbursementType = null;
if (paymentGroup.isPayableByCheck()) {
disbursementType = (DisbursementType) businessObjectService.findBySinglePrimaryKey(DisbursementType.class, PdpConstants.DisbursementTypeCodes.CHECK);
paymentGroup.setDisbursementType(disbursementType);
paymentGroup.setDisbursementTypeCode(PdpConstants.DisbursementTypeCodes.CHECK);
} else {
disbursementType = (DisbursementType) businessObjectService.findBySinglePrimaryKey(DisbursementType.class, PdpConstants.DisbursementTypeCodes.ACH);
paymentGroup.setDisbursementType(disbursementType);
paymentGroup.setDisbursementTypeCode(PdpConstants.DisbursementTypeCodes.ACH);
CustomerProfile customer = paymentGroup.getBatch().getCustomerProfile();
PayeeACHAccount payeeAchAccount = SpringContext.getBean(AchService.class).getAchInformation(paymentGroup.getPayeeIdTypeCd(), paymentGroup.getPayeeId(), customer.getAchTransactionType());
paymentGroup.setAchBankRoutingNbr(payeeAchAccount.getBankRoutingNumber());
paymentGroup.setAdviceEmailAddress(payeeAchAccount.getPayeeEmailAddress());
paymentGroup.setAchAccountType(payeeAchAccount.getBankAccountTypeCode());
AchAccountNumber achAccountNumber = new AchAccountNumber();
achAccountNumber.setAchBankAccountNbr(payeeAchAccount.getBankAccountNumber());
achAccountNumber.setId(paymentGroup.getId());
paymentGroup.setAchAccountNumber(achAccountNumber);
}
}
use of org.kuali.kfs.pdp.businessobject.AchAccountNumber in project cu-kfs by CU-CommunityApps.
the class CuPaymentMaintenanceServiceImpl method cancelReissueDisbursement.
@Override
public boolean cancelReissueDisbursement(Integer paymentGroupId, String note, Person user) {
LOG.debug("cancelReissueDisbursement() started");
if (!pdpAuthorizationService.hasCancelPaymentPermission(user.getPrincipalId())) {
LOG.warn("cancelReissueDisbursement() User " + user.getPrincipalId() + " does not have rights to cancel payments. This should not happen unless user is URL spoofing.");
throw new RuntimeException("cancelReissueDisbursement() 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("cancelReissueDisbursement() Disbursement not found; throw exception.");
GlobalVariables.getMessageMap().putError(KFSConstants.GLOBAL_ERRORS, PdpKeyConstants.PaymentDetail.ErrorMessages.ERROR_DISBURSEMENT_NOT_FOUND);
return false;
}
String paymentStatus = paymentGroup.getPaymentStatus().getCode();
if (!(PdpConstants.PaymentStatusCodes.OPEN.equals(paymentStatus))) {
if (((PdpConstants.PaymentStatusCodes.EXTRACTED.equals(paymentStatus)) && (ObjectUtils.isNotNull(paymentGroup.getDisbursementDate()))) || (PdpConstants.PaymentStatusCodes.PENDING_ACH.equals(paymentStatus))) {
if (LOG.isDebugEnabled()) {
LOG.debug("cancelReissueDisbursement() Payment status is " + paymentStatus + "; continue with cancel.");
}
List<PaymentGroup> allDisbursementPaymentGroups = this.paymentGroupService.getByDisbursementNumber(paymentGroup.getDisbursementNbr().intValue());
for (PaymentGroup pg : allDisbursementPaymentGroups) {
PaymentGroupHistory pgh = new PaymentGroupHistory();
if (!pg.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(pg.getDisbursementType())) && (pg.getDisbursementType().getCode().equals(PdpConstants.DisbursementTypeCodes.CHECK))) {
pgh.setPmtCancelExtractStat(Boolean.FALSE);
}
pgh.setOrigProcessImmediate(pg.getProcessImmediate());
pgh.setOrigPmtSpecHandling(pg.getPymtSpecialHandling());
pgh.setBank(pg.getBank());
pgh.setOrigPaymentDate(pg.getPaymentDate());
// put a check for null since disbursement date was not set in testMode / dev
if (ObjectUtils.isNotNull(pg.getDisbursementDate())) {
pgh.setOrigDisburseDate(new Timestamp(pg.getDisbursementDate().getTime()));
}
pgh.setOrigAchBankRouteNbr(pg.getAchBankRoutingNbr());
pgh.setOrigDisburseNbr(pg.getDisbursementNbr());
pgh.setOrigAdviceEmail(pg.getAdviceEmailAddress());
pgh.setDisbursementType(pg.getDisbursementType());
pgh.setProcess(pg.getProcess());
glPendingTransactionService.generateReissueGeneralLedgerPendingEntry(pg);
LOG.debug("cancelReissueDisbursement() Status is '" + paymentStatus + "; delete row from AchAccountNumber table.");
AchAccountNumber achAccountNumber = pg.getAchAccountNumber();
if (ObjectUtils.isNotNull(achAccountNumber)) {
this.businessObjectService.delete(achAccountNumber);
pg.setAchAccountNumber(null);
}
// if bank functionality is not enabled or the group bank is inactive clear bank code
if (!bankService.isBankSpecificationEnabled() || !pg.getBank().isActive()) {
pg.setBank(null);
}
pg.setDisbursementDate((java.sql.Date) null);
pg.setAchBankRoutingNbr(null);
pg.setAchAccountType(null);
pg.setPhysCampusProcessCd(null);
pg.setDisbursementNbr((KualiInteger) null);
pg.setAdviceEmailAddress(null);
// KFSPTS-1413 - do not reset the disb type as it prevents these payments from being picked up properly on reissue.
// pg.setDisbursementType(null);
pg.setProcess(null);
pg.setProcessImmediate(false);
changeStatus(pg, PdpConstants.PaymentStatusCodes.OPEN, PdpConstants.PaymentChangeCodes.CANCEL_REISSUE_DISBURSEMENT, note, user, pgh);
}
LOG.debug("cancelReissueDisbursement() Disbursement cancelled and reissued; exit method.");
} else {
LOG.debug("cancelReissueDisbursement() Payment status is " + paymentStatus + " and disbursement date is " + paymentGroup.getDisbursementDate() + "; cannot cancel payment");
GlobalVariables.getMessageMap().putError(KFSConstants.GLOBAL_ERRORS, PdpKeyConstants.PaymentDetail.ErrorMessages.ERROR_DISBURSEMENT_INVALID_TO_CANCEL_AND_REISSUE);
return false;
}
} else {
LOG.debug("cancelReissueDisbursement() Disbursement already cancelled and reissued; exit method.");
}
return true;
}
Aggregations