use of org.kuali.kfs.core.api.util.type.KualiDecimal in project cu-kfs by CU-CommunityApps.
the class CheckReconciliationImportStep method setCheckReconciliationAttributes.
/**
* Set CheckReconciliation Attributes
*
* @param hash
* @return
* @throws ParseException
*/
private CheckReconciliation setCheckReconciliationAttributes(Map<Integer, String> hash) throws ParseException {
String checkNumber = null;
Date checkDate = null;
KualiDecimal amount = null;
String accountNumber = null;
String status = null;
Date issueDate = null;
String payeeName = "";
String payeeID = "";
// Cornell Columns
Integer payeeNameCol = Integer.parseInt("12");
Integer issueDateCol = Integer.parseInt("7");
Integer payeeIDCol = Integer.parseInt("6");
checkNumber = hash.get(checkNumCol);
String rawCheckDate = hash.get(checkDateCol);
if (rawCheckDate == null || rawCheckDate.equals("") || rawCheckDate.equals("000000"))
rawCheckDate = "991231";
checkDate = getGregorianCalendar(rawCheckDate).getTime();
// checkDate = dateformat.parse(rawCheckDate); //Date Paid
amount = isAmountDecimalValue ? new KualiDecimal(addDecimalPoint(hash.get(amountCol))) : new KualiDecimal(hash.get(amountCol));
if (accountNumCol > 0)
accountNumber = isAccountNumHeaderValue ? getHeaderValue(accountNumCol) : hash.get(accountNumCol);
else
accountNumber = getParameterService().getParameterValueAsString(CheckReconciliationImportStep.class, CRConstants.ACCOUNT_NUM);
status = hash.get(statusCol);
String issueDateRawValue = hash.get(issueDateCol);
payeeName = hash.get(payeeNameCol);
payeeID = hash.get(payeeIDCol);
if (issueDateRawValue == null || issueDateRawValue.equals("") || issueDateRawValue.equals("000000"))
issueDateRawValue = "991231";
// issueDate = dateformat.parse(issueDateRawValue);
issueDate = getGregorianCalendar(issueDateRawValue).getTime();
CheckReconciliation cr = new CheckReconciliation();
cr.setAmount(amount);
cr.setCheckDate(new java.sql.Date(issueDate.getTime()));
cr.setCheckNumber(new KualiInteger(checkNumber));
cr.setBankAccountNumber(accountNumber);
cr.setStatus(status);
cr.setStatusChangeDate(new java.sql.Date(checkDate.getTime()));
cr.setGlTransIndicator(false);
cr.setPayeeName(payeeName);
cr.setPayeeId(payeeID);
return cr;
}
use of org.kuali.kfs.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.kfs.core.api.util.type.KualiDecimal in project cu-kfs by CU-CommunityApps.
the class ConcurCreateCashAdvancePdpFeedFileServiceImpl method buildPdpFeedBaseEntry.
private PdpFeedFileBaseEntry buildPdpFeedBaseEntry(ConcurStandardAccountingExtractFile standardAccountingExtractFile, ConcurSaeRequestedCashAdvanceBatchReportData reportData) {
int totalPdpDetailRecordsCount = 0;
KualiDecimal totalPdpDetailRecordsAmount = KualiDecimal.ZERO;
PdpFeedFileBaseEntry pdpBaseEntry = new PdpFeedFileBaseEntry();
pdpBaseEntry.setHeader(buildPdpFeedHeaderEntry(standardAccountingExtractFile.getBatchDate()));
List<PdpFeedGroupEntry> groupEntries = new ArrayList<PdpFeedGroupEntry>();
for (ConcurStandardAccountingExtractDetailLine detailFileLine : standardAccountingExtractFile.getConcurStandardAccountingExtractDetailLines()) {
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(), standardAccountingExtractFile.getOriginalFileName());
totalPdpDetailRecordsCount++;
totalPdpDetailRecordsAmount = totalPdpDetailRecordsAmount.add(detailFileLine.getCashAdvanceAmount());
}
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.kfs.core.api.util.type.KualiDecimal in project cu-kfs by CU-CommunityApps.
the class ConcurCreateCashAdvancePdpFeedFileServiceImpl method updateReportDataRequestExtractFileTotalCountAndAmountTotals.
private void updateReportDataRequestExtractFileTotalCountAndAmountTotals(ConcurSaeRequestedCashAdvanceBatchReportData reportData, ConcurStandardAccountingExtractDetailLine detailFileLine) {
reportData.getTotalsForFile().incrementRecordCount();
KualiDecimal amountForTotal = ObjectUtils.isNotNull(detailFileLine.getCashAdvanceAmount()) ? detailFileLine.getCashAdvanceAmount() : detailFileLine.getJournalAmount();
reportData.getTotalsForFile().addDollarAmount(amountForTotal);
}
use of org.kuali.kfs.core.api.util.type.KualiDecimal in project cu-kfs by CU-CommunityApps.
the class AssetGlobalServiceImpl method totalPaymentByAsset.
/**
* We need to calculate asset total amount from the sum of its payments. Otherwise, the asset total amount could
* mismatch with the sum of payments.
*/
@Override
public KualiDecimal totalPaymentByAsset(AssetGlobal assetGlobal, boolean lastEntry) {
KualiDecimal assetTotalAmount = KualiDecimal.ZERO;
List<AssetPaymentDetail> assetPaymentDetails = assetGlobal.getAssetPaymentDetails();
int numberOfTotalAsset = assetGlobal.getAssetGlobalDetails().size();
if (numberOfTotalAsset > 0) {
for (AssetPaymentDetail assetPaymentDetail : assetPaymentDetails) {
KualiDecimal assetPaymentUnitCost = assetPaymentDetail.getAmount().divide(new KualiDecimal(numberOfTotalAsset));
if (lastEntry) {
assetPaymentUnitCost = assetPaymentDetail.getAmount().subtract(assetPaymentUnitCost.multiply(new KualiDecimal(numberOfTotalAsset - 1)));
}
assetTotalAmount = assetTotalAmount.add(assetPaymentUnitCost);
}
}
return assetTotalAmount;
}
Aggregations