use of org.kuali.kfs.pdp.businessobject.CustomerProfile in project cu-kfs by CU-CommunityApps.
the class PaymentFileServiceImpl method createNewBatch.
/**
* Create a new <code>Batch</code> record for the payment file.
*
* @param paymentFile parsed payment file object
* @param fileName payment file name (without path)
* @return <code>Batch<code> object
*/
protected Batch createNewBatch(PaymentFileLoad paymentFile, String fileName) {
Timestamp now = dateTimeService.getCurrentTimestamp();
Calendar nowPlus30 = Calendar.getInstance();
nowPlus30.setTime(now);
nowPlus30.add(Calendar.DATE, 30);
Calendar nowMinus30 = Calendar.getInstance();
nowMinus30.setTime(now);
nowMinus30.add(Calendar.DATE, -30);
Batch batch = new Batch();
CustomerProfile customer = customerProfileService.get(paymentFile.getChart(), paymentFile.getUnit(), paymentFile.getSubUnit());
batch.setCustomerProfile(customer);
batch.setCustomerFileCreateTimestamp(new Timestamp(paymentFile.getCreationDate().getTime()));
batch.setFileProcessTimestamp(now);
batch.setPaymentCount(new KualiInteger(paymentFile.getPaymentCount()));
if (fileName.length() > 30) {
batch.setPaymentFileName(fileName.substring(0, 30));
} else {
batch.setPaymentFileName(fileName);
}
batch.setPaymentTotalAmount(paymentFile.getPaymentTotalAmount());
batch.setSubmiterUserId(GlobalVariables.getUserSession().getPerson().getPrincipalId());
return batch;
}
use of org.kuali.kfs.pdp.businessobject.CustomerProfile in project cu-kfs by CU-CommunityApps.
the class PendingTransactionServiceImpl method populatePaymentGeneralLedgerPendingEntry.
/**
* Populates and stores a new GLPE for each account detail in the payment group.
*
* @param paymentGroup payment group to generate entries for
* @param achFdocTypeCode doc type for ach disbursements
* @param checkFdocTypeCod doc type for check disbursements
* @param reversal boolean indicating if this is a reversal
*/
protected void populatePaymentGeneralLedgerPendingEntry(PaymentGroup paymentGroup, String achFdocTypeCode, String checkFdocTypeCod, boolean reversal) {
List<PaymentAccountDetail> accountListings = new ArrayList<PaymentAccountDetail>();
for (PaymentDetail paymentDetail : paymentGroup.getPaymentDetails()) {
accountListings.addAll(paymentDetail.getAccountDetail());
}
BusinessObjectEntry businessObjectEntry = dataDictionaryService.getDataDictionary().getBusinessObjectEntry(PaymentDetail.class.getName());
AttributeDefinition attributeDefinition = businessObjectEntry.getAttributeDefinition("paymentGroup.payeeName");
AttributeSecurity originalPayeeNameAttributeSecurity = attributeDefinition.getAttributeSecurity();
String maskLiteral = ((MaskFormatterLiteral) originalPayeeNameAttributeSecurity.getMaskFormatter()).getLiteral();
GeneralLedgerPendingEntrySequenceHelper sequenceHelper = new GeneralLedgerPendingEntrySequenceHelper();
for (PaymentAccountDetail paymentAccountDetail : accountListings) {
GlPendingTransaction glPendingTransaction = new GlPendingTransaction();
glPendingTransaction.setSequenceNbr(new KualiInteger(sequenceHelper.getSequenceCounter()));
if (StringUtils.isNotBlank(paymentAccountDetail.getPaymentDetail().getFinancialSystemOriginCode()) && StringUtils.isNotBlank(paymentAccountDetail.getPaymentDetail().getFinancialDocumentTypeCode())) {
glPendingTransaction.setFdocRefTypCd(paymentAccountDetail.getPaymentDetail().getFinancialDocumentTypeCode());
glPendingTransaction.setFsRefOriginCd(paymentAccountDetail.getPaymentDetail().getFinancialSystemOriginCode());
} else {
glPendingTransaction.setFdocRefTypCd(PdpConstants.PDP_FDOC_TYPE_CODE);
glPendingTransaction.setFsRefOriginCd(PdpConstants.PDP_FDOC_ORIGIN_CODE);
}
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.setAccountNumber(paymentAccountDetail.getAccountNbr());
glPendingTransaction.setSubAccountNumber(paymentAccountDetail.getSubAccountNbr());
glPendingTransaction.setChartOfAccountsCode(paymentAccountDetail.getFinChartCode());
if (paymentGroup.getDisbursementType().getCode().equals(PdpConstants.DisbursementTypeCodes.ACH)) {
glPendingTransaction.setFinancialDocumentTypeCode(achFdocTypeCode);
} else if (paymentGroup.getDisbursementType().getCode().equals(PdpConstants.DisbursementTypeCodes.CHECK)) {
glPendingTransaction.setFinancialDocumentTypeCode(checkFdocTypeCod);
}
glPendingTransaction.setFsOriginCd(PdpConstants.PDP_FDOC_ORIGIN_CODE);
glPendingTransaction.setFdocNbr(paymentGroup.getDisbursementNbr().toString());
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.setFinancialObjectCode(offsetDefinition != null ? offsetDefinition.getFinancialObjectCode() : paymentAccountDetail.getFinObjectCode());
glPendingTransaction.setFinancialSubObjectCode(KFSConstants.getDashFinancialSubObjectCode());
} else {
glPendingTransaction.setFinancialObjectCode(paymentAccountDetail.getFinObjectCode());
glPendingTransaction.setFinancialSubObjectCode(paymentAccountDetail.getFinSubObjectCode());
}
glPendingTransaction.setProjectCd(paymentAccountDetail.getProjectCode());
glPendingTransaction.setDebitCrdtCd(pdpUtilService.isDebit(paymentAccountDetail, reversal) ? KFSConstants.GL_DEBIT_CODE : KFSConstants.GL_CREDIT_CODE);
glPendingTransaction.setAmount(paymentAccountDetail.getAccountNetAmount().abs());
// Changes for Research Participant Upload
String trnDesc = StringUtils.EMPTY;
CustomerProfile customerProfile = paymentGroup.getBatch().getCustomerProfile();
if (researchParticipantPaymentValidationService.isResearchParticipantPayment(customerProfile)) {
trnDesc = maskLiteral;
} else {
String payeeName = paymentGroup.getPayeeName();
if (StringUtils.isNotBlank(payeeName)) {
trnDesc = payeeName.length() > 40 ? payeeName.substring(0, 40) : StringUtils.rightPad(payeeName, 40);
}
if (reversal) {
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();
if (bankService.isBankSpecificationEnabled()) {
this.populateBankOffsetEntry(paymentGroup, glPendingTransaction, sequenceHelper);
}
}
}
use of org.kuali.kfs.pdp.businessobject.CustomerProfile in project cu-kfs by CU-CommunityApps.
the class FormatAction method start.
/**
* This method prepares the data for the format process
*
* @param mapping
* @param form
* @param request
* @param response
* @return
* @throws Exception
*/
public ActionForward start(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
FormatForm formatForm = (FormatForm) form;
Person kualiUser = GlobalVariables.getUserSession().getPerson();
FormatSelection formatSelection = formatService.getDataForFormat(kualiUser);
DateTimeService dateTimeService = SpringContext.getBean(DateTimeService.class);
formatForm.setCampus(kualiUser.getCampusCode());
// no data for format because another format process is already running
if (formatSelection.getStartDate() != null) {
GlobalVariables.getMessageMap().putError(KFSConstants.GLOBAL_ERRORS, PdpKeyConstants.Format.ERROR_PDP_FORMAT_PROCESS_ALREADY_RUNNING, dateTimeService.toDateTimeString(formatSelection.getStartDate()));
} else {
List<CustomerProfile> customers = formatSelection.getCustomerList();
for (CustomerProfile element : customers) {
if (formatSelection.getCampus().equals(element.getDefaultPhysicalCampusProcessingCode())) {
element.setSelectedForFormat(Boolean.TRUE);
} else {
element.setSelectedForFormat(Boolean.FALSE);
}
}
formatForm.setPaymentDate(dateTimeService.toDateString(dateTimeService.getCurrentTimestamp()));
formatForm.setPaymentTypes(PdpConstants.PaymentTypes.ALL);
formatForm.setCustomers(customers);
formatForm.setRanges(formatSelection.getRangeList());
}
return mapping.findForward(PdpConstants.MAPPING_SELECTION);
}
use of org.kuali.kfs.pdp.businessobject.CustomerProfile in project cu-kfs by CU-CommunityApps.
the class PaymentSourceExtractionServiceImpl method createBatch.
/**
* This method creates a Batch instance and populates it with the information provided.
*
* @param campusCode The campus code used to retrieve a customer profile to be set on the batch.
* @param orgCode the organization code used to retrieve a customer profile to be set on the batch.
* @param subUnitCode the sub-unit code used to retrieve a customer profile to be set on the batch.
* @param user The user who submitted the batch.
* @param processRunDate The date the batch was submitted and the date the customer profile was generated.
* @return A fully populated batch instance.
*/
protected Batch createBatch(String campusCode, String principalId, Date processRunDate) {
final String orgCode = getPaymentSourceToExtractService().getPreDisbursementCustomerProfileUnit();
final String subUnitCode = getPaymentSourceToExtractService().getPreDisbursementCustomerProfileSubUnit();
CustomerProfile customer = customerProfileService.get(campusCode, orgCode, subUnitCode);
if (customer == null) {
throw new IllegalArgumentException("Unable to find customer profile for " + campusCode + "/" + orgCode + "/" + subUnitCode);
}
// Create the group for this campus
Batch batch = new Batch();
batch.setCustomerProfile(customer);
batch.setCustomerFileCreateTimestamp(new Timestamp(processRunDate.getTime()));
batch.setFileProcessTimestamp(new Timestamp(processRunDate.getTime()));
batch.setPaymentFileName(KFSConstants.DISBURSEMENT_VOUCHER_PDP_EXTRACT_FILE_NAME);
batch.setSubmiterUserId(principalId);
// Set these for now, we will update them later
batch.setPaymentCount(KualiInteger.ZERO);
batch.setPaymentTotalAmount(KualiDecimal.ZERO);
businessObjectService.save(batch);
return batch;
}
use of org.kuali.kfs.pdp.businessobject.CustomerProfile in project cu-kfs by CU-CommunityApps.
the class CuExtractPaymentServiceImpl method writeExtractCheckFile.
@Override
protected void writeExtractCheckFile(PaymentStatus extractedStatus, PaymentProcess p, String filename, Integer processId) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date processDate = dateTimeService.getCurrentDate();
BufferedWriter os = null;
BufferedWriter osI = null;
boolean wroteImmediateHeaderRecords = false;
boolean wroteCheckHeaderRecords = false;
String immediateFilename = filename.replace("check", "check_immediate");
String checkFilename = filename;
boolean first = true;
boolean isImmediate = false;
// customer profile, then change the filename to append the RP-Upload prefix.
if (isResearchParticipantExtractFile(processId)) {
String checkFilePrefix = this.kualiConfigurationService.getPropertyValueAsString(PdpKeyConstants.ExtractPayment.CHECK_FILENAME);
checkFilePrefix = MessageFormat.format(checkFilePrefix, new Object[] { null });
checkFilePrefix = PdpConstants.RESEARCH_PARTICIPANT_FILE_PREFIX + KFSConstants.DASH + checkFilePrefix;
filename = getOutputFile(checkFilePrefix, processDate);
}
try {
List<String> notificationEmailAddresses = this.getBankPaymentFileNotificationEmailAddresses();
writeExtractCheckFileMellonBankFastTrack(extractedStatus, p, filename, processId, notificationEmailAddresses);
List<String> bankCodes = paymentGroupService.getDistinctBankCodesForProcessAndType(processId, PdpConstants.DisbursementTypeCodes.CHECK);
for (String bankCode : bankCodes) {
List<Integer> disbNbrs = paymentGroupService.getDisbursementNumbersByDisbursementTypeAndBankCode(processId, PdpConstants.DisbursementTypeCodes.CHECK, bankCode);
for (Iterator<Integer> iter = disbNbrs.iterator(); iter.hasNext(); ) {
Integer disbursementNbr = iter.next();
first = true;
KualiDecimal totalNetAmount = new KualiDecimal(0);
// this seems wasteful, but since the total net amount is needed on the first payment detail...it's needed
Iterator<PaymentDetail> i2 = paymentDetailService.getByDisbursementNumber(disbursementNbr, processId, PdpConstants.DisbursementTypeCodes.CHECK, bankCode);
while (i2.hasNext()) {
PaymentDetail pd = i2.next();
totalNetAmount = totalNetAmount.add(pd.getNetPaymentAmount());
}
List<KualiInteger> paymentGroupIdsSaved = new ArrayList<KualiInteger>();
Iterator<PaymentDetail> paymentDetails = paymentDetailService.getByDisbursementNumber(disbursementNbr, processId, PdpConstants.DisbursementTypeCodes.CHECK, bankCode);
while (paymentDetails.hasNext()) {
PaymentDetail detail = paymentDetails.next();
PaymentGroup group = detail.getPaymentGroup();
if (!testMode) {
if (!paymentGroupIdsSaved.contains(group.getId())) {
group.setDisbursementDate(new java.sql.Date(processDate.getTime()));
group.setPaymentStatus(extractedStatus);
this.businessObjectService.save(group);
paymentGroupIdsSaved.add(group.getId());
}
}
isImmediate = group.getProcessImmediate();
if (first && !isImmediate) {
if (!wroteCheckHeaderRecords) {
os = new BufferedWriter(new FileWriter(checkFilename));
os.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
writeOpenTagAttribute(os, 0, "checks", "processId", processId.toString(), "campusCode", p.getCampusCode());
wroteCheckHeaderRecords = true;
}
writeOpenTagAttribute(os, 2, "check", "disbursementNbr", group.getDisbursementNbr().toString());
// Write check level information
writeBank(os, 4, group.getBank());
writeTag(os, 4, "disbursementDate", sdf.format(processDate));
writeTag(os, 4, "netAmount", totalNetAmount.toString());
writePayee(os, 4, group);
writeTag(os, 4, "campusAddressIndicator", group.getCampusAddress().booleanValue() ? "Y" : "N");
writeTag(os, 4, "attachmentIndicator", group.getPymtAttachment().booleanValue() ? "Y" : "N");
writeTag(os, 4, "specialHandlingIndicator", group.getPymtSpecialHandling().booleanValue() ? "Y" : "N");
writeTag(os, 4, "immediatePaymentIndicator", group.getProcessImmediate().booleanValue() ? "Y" : "N");
writeTag(os, 4, "customerUnivNbr", group.getCustomerInstitutionNumber());
writeTag(os, 4, "paymentDate", sdf.format(group.getPaymentDate()));
// Write customer profile information
CustomerProfile cp = group.getBatch().getCustomerProfile();
writeCustomerProfile(os, 4, cp);
writeOpenTag(os, 4, "payments");
first = false;
}
if (first && isImmediate) {
if (!wroteImmediateHeaderRecords) {
osI = new BufferedWriter(new FileWriter(immediateFilename));
osI.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
writeOpenTagAttribute(osI, 0, "checks", "processId", processId.toString(), "campusCode", p.getCampusCode());
wroteImmediateHeaderRecords = true;
}
writeOpenTagAttribute(osI, 2, "check", "disbursementNbr", group.getDisbursementNbr().toString());
// Write check level information
writeBank(osI, 4, group.getBank());
writeTag(osI, 4, "disbursementDate", sdf.format(processDate));
writeTag(osI, 4, "netAmount", totalNetAmount.toString());
writePayee(osI, 4, group);
writeTag(osI, 4, "campusAddressIndicator", group.getCampusAddress().booleanValue() ? "Y" : "N");
writeTag(osI, 4, "attachmentIndicator", group.getPymtAttachment().booleanValue() ? "Y" : "N");
writeTag(osI, 4, "specialHandlingIndicator", group.getPymtSpecialHandling().booleanValue() ? "Y" : "N");
writeTag(osI, 4, "immediatePaymentIndicator", group.getProcessImmediate().booleanValue() ? "Y" : "N");
writeTag(osI, 4, "customerUnivNbr", group.getCustomerInstitutionNumber());
writeTag(osI, 4, "paymentDate", sdf.format(group.getPaymentDate()));
// Write customer profile information
CustomerProfile cp = group.getBatch().getCustomerProfile();
writeCustomerProfile(osI, 4, cp);
writeOpenTag(osI, 4, "payments");
first = false;
}
if (!isImmediate && wroteCheckHeaderRecords) {
writeOpenTag(os, 6, "payment");
writeTag(os, 8, "purchaseOrderNbr", detail.getPurchaseOrderNbr());
writeTag(os, 8, "invoiceNbr", detail.getInvoiceNbr());
writeTag(os, 8, "requisitionNbr", detail.getRequisitionNbr());
writeTag(os, 8, "custPaymentDocNbr", detail.getCustPaymentDocNbr());
writeTag(os, 8, "invoiceDate", sdf.format(detail.getInvoiceDate()));
writeTag(os, 8, "origInvoiceAmount", detail.getOrigInvoiceAmount().toString());
writeTag(os, 8, "netPaymentAmount", detail.getNetPaymentAmount().toString());
writeTag(os, 8, "invTotDiscountAmount", detail.getInvTotDiscountAmount().toString());
writeTag(os, 8, "invTotShipAmount", detail.getInvTotShipAmount().toString());
writeTag(os, 8, "invTotOtherDebitAmount", detail.getInvTotOtherDebitAmount().toString());
writeTag(os, 8, "invTotOtherCreditAmount", detail.getInvTotOtherCreditAmount().toString());
writeOpenTag(os, 8, "notes");
for (Iterator ix = detail.getNotes().iterator(); ix.hasNext(); ) {
PaymentNoteText note = (PaymentNoteText) ix.next();
writeTag(os, 10, "note", note.getCustomerNoteText());
}
writeCloseTag(os, 8, "notes");
writeCloseTag(os, 6, "payment");
}
if (isImmediate && wroteImmediateHeaderRecords) {
writeOpenTag(osI, 6, "payment");
writeTag(osI, 8, "purchaseOrderNbr", detail.getPurchaseOrderNbr());
writeTag(osI, 8, "invoiceNbr", detail.getInvoiceNbr());
writeTag(osI, 8, "requisitionNbr", detail.getRequisitionNbr());
writeTag(osI, 8, "custPaymentDocNbr", detail.getCustPaymentDocNbr());
writeTag(osI, 8, "invoiceDate", sdf.format(detail.getInvoiceDate()));
writeTag(osI, 8, "origInvoiceAmount", detail.getOrigInvoiceAmount().toString());
writeTag(osI, 8, "netPaymentAmount", detail.getNetPaymentAmount().toString());
writeTag(osI, 8, "invTotDiscountAmount", detail.getInvTotDiscountAmount().toString());
writeTag(osI, 8, "invTotShipAmount", detail.getInvTotShipAmount().toString());
writeTag(osI, 8, "invTotOtherDebitAmount", detail.getInvTotOtherDebitAmount().toString());
writeTag(osI, 8, "invTotOtherCreditAmount", detail.getInvTotOtherCreditAmount().toString());
writeOpenTag(osI, 8, "notes");
for (Iterator ix = detail.getNotes().iterator(); ix.hasNext(); ) {
PaymentNoteText note = (PaymentNoteText) ix.next();
writeTag(osI, 10, "note", note.getCustomerNoteText());
}
writeCloseTag(osI, 8, "notes");
writeCloseTag(osI, 6, "payment");
}
}
if (wroteCheckHeaderRecords && !isImmediate) {
writeCloseTag(os, 4, "payments");
writeCloseTag(os, 2, "check");
}
if (wroteImmediateHeaderRecords && isImmediate) {
writeCloseTag(osI, 4, "payments");
writeCloseTag(osI, 2, "check");
}
}
}
} catch (IOException ie) {
LOG.error("extractChecks() Problem reading file: " + filename, ie);
throw new IllegalArgumentException("Error writing to output file: " + ie.getMessage());
} finally {
// Close file
if (os != null) {
try {
writeCloseTag(os, 0, "checks");
os.close();
// An XML file containing these records are NEVER sent to anyone at this time.
renameFile(checkFilename, checkFilename + ".NOT_USED");
createDoneFile(checkFilename + ".NOT_USED");
} catch (IOException ie) {
// Not much we can do now
}
}
if (osI != null) {
try {
writeCloseTag(osI, 0, "checks");
osI.close();
// An XML file containing these records are ONLY used for local check printing.
renameFile(immediateFilename, immediateFilename + ".READY");
createDoneFile(immediateFilename + ".READY");
} catch (IOException ie) {
// Not much we can do now
LOG.error("IOException encountered in writeExtractCheckFile. Message is: " + ie.getMessage());
}
}
}
}
Aggregations