use of org.kuali.rice.core.api.util.type.KualiDecimal in project cu-kfs by CU-CommunityApps.
the class CheckReconciliationImportStep method updateCheckStatus.
/**
* Get Check Status and update pdp
*
* @param cr Check Reconciliation Object
* @return String
*/
private String updateCheckStatus(CheckReconciliation cr, Collection<Bank> banks, List<CheckReconError> records) throws Exception {
String defaultStatus = CRConstants.EXCP;
String oldStatus = CRConstants.EXCP;
List<String> bankCodes = new ArrayList<String>();
// Generate list of valid bank codes
for (Bank bank : banks) {
if (bank.getBankAccountNumber().equals(cr.getBankAccountNumber())) {
bankCodes.add(bank.getBankCode());
}
}
if (bankCodes.size() == 0) {
throw new Exception("Invalid Bank Account Number : " + cr.getBankAccountNumber());
}
Collection<PaymentGroup> paymentGroups = glTransactionService.getAllPaymentGroupForSearchCriteria(cr.getCheckNumber(), bankCodes);
KualiDecimal totalNetAmount = getTotalNetAmount(paymentGroups);
for (PaymentGroup paymentGroup : paymentGroups) {
/*
* At Cornell Check amount may consist of one or more payment group amounts.
*
if( !cr.getAmount().equals(paymentGroup.getNetPaymentAmount()) ) {
records.add(getCheckReconError(cr, "The check amount does not match payment net amount."));
}
*/
if (!(totalNetAmount.doubleValue() == cr.getAmount().doubleValue())) {
records.add(getCheckReconError(cr, "The check amount does not match payment net amount from the payment groups."));
}
if (statusMap.get(cr.getStatus()) != null) {
defaultStatus = statusMap.get(cr.getStatus());
oldStatus = paymentGroup.getPaymentStatusCode();
// Update PDP status and save
KualiCode code = businessObjectService.findBySinglePrimaryKey(PaymentStatus.class, defaultStatus);
if (paymentGroup.getPaymentStatus() != ((PaymentStatus) code)) {
paymentGroup.setPaymentStatus((PaymentStatus) code);
paymentGroup.setLastUpdatedTimestamp(new Timestamp(cr.getStatusChangeDate().getTime()));
}
if (defaultStatus.equals(CRConstants.CLEARED)) {
if (PaymentStatusCodes.EXTRACTED.equals(oldStatus)) {
businessObjectService.save(paymentGroup);
LOG.info("Check Status in the bank file is cleared. Updated Payment Group : " + paymentGroup.getId() + " Disbursement " + paymentGroup.getDisbursementNbr());
} else {
LOG.warn("Check Status in the bank file is cleared, but Payment Group " + paymentGroup.getId() + " for Disbursement " + paymentGroup.getDisbursementNbr() + " has a current status of " + oldStatus + " and cannot be cleared.");
}
}
} else {
LOG.warn("Update Payment Group Failed ( " + cr.getStatus() + ") ID : " + paymentGroup.getId());
}
}
if (paymentGroups == null) {
LOG.info("No Payments Found : " + cr.getBankAccountNumber() + "-" + cr.getCheckNumber());
} else if (paymentGroups.size() == 0) {
LOG.info("No Payments Found : " + cr.getBankAccountNumber() + "-" + cr.getCheckNumber());
}
return defaultStatus;
}
use of org.kuali.rice.core.api.util.type.KualiDecimal in project cu-kfs by CU-CommunityApps.
the class ConcurCashAdvancePdpFeedFileServiceImpl method buildPdpFeedBaseEntry.
private PdpFeedFileBaseEntry buildPdpFeedBaseEntry(ConcurRequestExtractFile requestExtractFile, ConcurRequestExtractBatchReportData reportData) {
int totalPdpDetailRecordsCount = 0;
KualiDecimal totalPdpDetailRecordsAmount = KualiDecimal.ZERO;
PdpFeedFileBaseEntry pdpBaseEntry = new PdpFeedFileBaseEntry();
pdpBaseEntry.setHeader(buildPdpFeedHeaderEntry(requestExtractFile.getBatchDate()));
List<PdpFeedGroupEntry> groupEntries = new ArrayList<PdpFeedGroupEntry>();
for (ConcurRequestExtractRequestDetailFileLine detailFileLine : requestExtractFile.getRequestDetails()) {
if (isDetailFileLineValidCashAdvanceRequest(detailFileLine)) {
PdpFeedDetailEntry pdpDetailEntry = buildPdpFeedDetailEntry(detailFileLine, buildPdpFeedAccountingEntry(detailFileLine));
List<PdpFeedDetailEntry> pdpDetailEntries = new ArrayList<PdpFeedDetailEntry>();
pdpDetailEntries.add(pdpDetailEntry);
groupEntries.add(buildPdpFeedGroupEntry(detailFileLine, buildPdpFeedPayeeIdEntry(detailFileLine), pdpDetailEntries));
recordCashAdvanceGenerationInDuplicateTrackingTable(detailFileLine, pdpDetailEntry.getSourceDocNbr(), requestExtractFile.getFileName());
totalPdpDetailRecordsCount++;
totalPdpDetailRecordsAmount = totalPdpDetailRecordsAmount.add(detailFileLine.getRequestAmount());
}
updateReportDataForDetailFileLineBeingProcessed(reportData, detailFileLine, totalPdpDetailRecordsCount, totalPdpDetailRecordsAmount);
}
pdpBaseEntry.setGroup(groupEntries);
pdpBaseEntry.setTrailer(buildPdpFeedTrailerEntry(totalPdpDetailRecordsCount, totalPdpDetailRecordsAmount));
pdpBaseEntry.setVersion(ConcurConstants.FEED_FILE_ENTRY_HEADER_VERSION);
return pdpBaseEntry;
}
use of org.kuali.rice.core.api.util.type.KualiDecimal in project cu-kfs by CU-CommunityApps.
the class SubmitTripWebServiceImpl method buildDisbursementVoucher.
/**
* @param dvDescription
* @param dvExplanation
* @param tripNumber
* @param travelerNetId
* @param initiatorNetId
* @param totalAmount
* @param checkStubText
* @return
* @throws Exception
*/
private String buildDisbursementVoucher(String dvDescription, String dvExplanation, String tripNumber, String travelerNetId, String initiatorNetId, double totalAmount, String checkStubText) throws Exception {
try {
if (!isValidDocumentInitiator(initiatorNetId, DISBURSEMENT_VOUCHER)) {
throw new RuntimeException("Initiator identified does not have permission to create a DV.");
}
} catch (Exception ex) {
throw new RuntimeException("Initiator identified does not have permission to create a DV.", ex);
}
// create and route doc as system user
GlobalVariables.setUserSession(new UserSession(initiatorNetId));
MessageMap documentErrorMap = new MessageMap();
GlobalVariables.setMessageMap(documentErrorMap);
// Create document with description provided
CuDisbursementVoucherDocument dvDoc = null;
try {
dvDoc = (CuDisbursementVoucherDocument) SpringContext.getBean(DocumentService.class).getNewDocument(DisbursementVoucherDocument.class);
} catch (WorkflowException e) {
throw new RuntimeException("Error creating new disbursement voucher document: " + e.getMessage(), e);
}
if (dvDoc != null) {
dvDoc.getDocumentHeader().setDocumentDescription(dvDescription);
dvDoc.getDocumentHeader().setExplanation(dvExplanation);
dvDoc.getDocumentHeader().setOrganizationDocumentNumber(tripNumber);
dvDoc.initiateDocument();
// Set vendor to traveler using netID provided
Person traveler = SpringContext.getBean(PersonService.class).getPersonByPrincipalName(travelerNetId);
for (EntityAffiliationContract entityAffiliation : ((PersonImpl) traveler).getAffiliations()) {
if (entityAffiliation.isDefaultValue()) {
if (StringUtils.equalsIgnoreCase(entityAffiliation.getAffiliationType().getCode(), CuDisbursementVoucherConstants.PayeeAffiliations.STUDENT)) {
dvDoc.templateStudent(traveler);
} else if (StringUtils.equalsIgnoreCase(entityAffiliation.getAffiliationType().getCode(), CuDisbursementVoucherConstants.PayeeAffiliations.ALUMNI)) {
dvDoc.templateAlumni(traveler);
} else if (StringUtils.equalsIgnoreCase(entityAffiliation.getAffiliationType().getCode(), CuDisbursementVoucherConstants.PayeeAffiliations.FACULTY) || StringUtils.equalsIgnoreCase(entityAffiliation.getAffiliationType().getCode(), CuDisbursementVoucherConstants.PayeeAffiliations.STAFF)) {
dvDoc.templateEmployee(traveler);
}
}
}
dvDoc.setPayeeAssigned(true);
dvDoc.getDvPayeeDetail().setDisbVchrPaymentReasonCode("J");
dvDoc.setDisbVchrCheckTotalAmount(new KualiDecimal(totalAmount));
dvDoc.setDisbVchrPaymentMethodCode("P");
dvDoc.setDisbVchrCheckStubText(checkStubText);
dvDoc.setTripId(tripNumber);
dvDoc.setTripAssociationStatusCode(CULegacyTravelServiceImpl.TRIP_ASSOCIATIONS.IS_TRIP_DOC);
// Persist document
SpringContext.getBean(DocumentService.class).saveDocument(dvDoc);
return dvDoc.getDocumentNumber();
} else {
return "";
}
}
use of org.kuali.rice.core.api.util.type.KualiDecimal in project cu-kfs by CU-CommunityApps.
the class CUPaymentMethodGeneralLedgerPendingEntryServiceImpl method generateClearingAccountOffsetEntries.
/**
* When the "A" payment method is used for AP Credit Cards - generate the needed entries in the clearing account.
*
* @param document Document into which to add the generated GL Entries.
* @param sequenceHelper helper class to keep track of GLPE sequence
*/
public boolean generateClearingAccountOffsetEntries(PaymentMethod pm, AccountingDocument document, GeneralLedgerPendingEntrySequenceHelper sequenceHelper, Map<String, KualiDecimal> actualTotalsByChart) {
if (actualTotalsByChart == null) {
actualTotalsByChart = getNonOffsetActualTotalsByChart(document);
}
for (String chart : actualTotalsByChart.keySet()) {
KualiDecimal offsetAmount = actualTotalsByChart.get(chart);
if (!KualiDecimal.ZERO.equals(offsetAmount)) {
PaymentMethodChart pmc = pm.getPaymentMethodChartInfo(chart, new java.sql.Date(document.getDocumentHeader().getWorkflowDocument().getDateCreated().getMillis()));
if (pmc == null) {
LOG.warn("No Applicable PaymentMethodChart found for chart: " + chart + " and date: " + document.getDocumentHeader().getWorkflowDocument().getDateCreated());
// skip this line - still attempt for other charts
continue;
}
String clearingChartCode = pmc.getClearingChartOfAccountsCode();
String clearingAccountNumber = pmc.getClearingAccountNumber();
// liability object code
String clearingObjectCode = pmc.getClearingFinancialObjectCode();
GeneralLedgerPendingEntry apOffsetEntry = new GeneralLedgerPendingEntry(document.getGeneralLedgerPendingEntry(0));
apOffsetEntry.setTransactionLedgerEntrySequenceNumber(new Integer(sequenceHelper.getSequenceCounter()));
apOffsetEntry.setChartOfAccountsCode(clearingChartCode);
apOffsetEntry.setAccountNumber(clearingAccountNumber);
apOffsetEntry.setFinancialObjectCode(clearingObjectCode);
// if internal billing
if (StringUtils.equals(PaymentMethod.PM_CODE_INTERNAL_BILLING, pm.getPaymentMethodCode())) {
apOffsetEntry.setFinancialSubObjectCode(pmc.getClearingFinancialSubObjectCode());
apOffsetEntry.setSubAccountNumber(pmc.getClearingSubAccountNumber());
} else {
apOffsetEntry.setFinancialSubObjectCode(GENERAL_LEDGER_PENDING_ENTRY_CODE.getBlankFinancialSubObjectCode());
apOffsetEntry.setSubAccountNumber(GENERAL_LEDGER_PENDING_ENTRY_CODE.getBlankSubAccountNumber());
}
apOffsetEntry.setProjectCode(GENERAL_LEDGER_PENDING_ENTRY_CODE.getBlankProjectCode());
// retrieve object type
ObjectCode objectCode = getObjectCodeService().getByPrimaryIdForCurrentYear(clearingChartCode, clearingObjectCode);
if (objectCode == null) {
LOG.fatal("Specified offset object code: " + clearingChartCode + "-" + clearingObjectCode + " does not exist - failed to generate CC offset entries", new RuntimeException());
return false;
}
apOffsetEntry.setFinancialObjectTypeCode(objectCode.getFinancialObjectTypeCode());
apOffsetEntry.setTransactionLedgerEntryAmount(offsetAmount.abs());
apOffsetEntry.setTransactionDebitCreditCode(offsetAmount.isNegative() ? KFSConstants.GL_DEBIT_CODE : KFSConstants.GL_CREDIT_CODE);
apOffsetEntry.setFinancialBalanceTypeCode(KFSConstants.BALANCE_TYPE_ACTUAL);
document.addPendingEntry(apOffsetEntry);
sequenceHelper.increment();
// handle the offset entry
GeneralLedgerPendingEntry offsetEntry = new GeneralLedgerPendingEntry(apOffsetEntry);
getGeneralLedgerPendingEntryService().populateOffsetGeneralLedgerPendingEntry(document.getPostingYear(), apOffsetEntry, sequenceHelper, offsetEntry);
document.addPendingEntry(offsetEntry);
sequenceHelper.increment();
}
}
return true;
}
use of org.kuali.rice.core.api.util.type.KualiDecimal in project cu-kfs by CU-CommunityApps.
the class ScheduledAccountingLineServiceImpl method isAccountingLineTotalMoreThanRecurranceTotal.
private boolean isAccountingLineTotalMoreThanRecurranceTotal(ScheduledSourceAccountingLine scheduledAccountingLine) {
KualiDecimal totalAmount = calculateTotalAmount(scheduledAccountingLine.getAmount());
double recurranceTotal = scheduledAccountingLine.getPartialAmount().doubleValue() * Integer.parseInt(scheduledAccountingLine.getPartialTransactionCount());
boolean isAccountingLineTotalMoreThanRecurranceTotal = totalAmount.doubleValue() > recurranceTotal;
if (LOG.isDebugEnabled()) {
LOG.debug("totalAmount = " + totalAmount + " recurranceTotal: " + recurranceTotal + " scheduledAccountingLine.getPartialTransactionCount(): " + scheduledAccountingLine.getPartialTransactionCount() + " isAccountingLineTotalMoreThanRecurranceTotal: " + (isAccountingLineTotalMoreThanRecurranceTotal));
}
return isAccountingLineTotalMoreThanRecurranceTotal;
}
Aggregations