use of org.kuali.rice.core.api.util.type.KualiDecimal in project cu-kfs by CU-CommunityApps.
the class CuLaborPendingEntryGenerator method generateBenefitClearingPendingEntries.
public static List<LaborLedgerPendingEntry> generateBenefitClearingPendingEntries(LaborLedgerPostingDocument document, GeneralLedgerPendingEntrySequenceHelper sequenceHelper, String accountNumber, String chartOfAccountsCode) {
List<LaborLedgerPendingEntry> benefitClearingPendingEntries = new ArrayList<LaborLedgerPendingEntry>();
Map<String, Map<String, KualiDecimal>> sourceLineBenefitAmountSumByObjectCode = new HashMap<String, Map<String, KualiDecimal>>();
List<ExpenseTransferSourceAccountingLine> sourceAccountingLines = document.getSourceAccountingLines();
for (ExpenseTransferSourceAccountingLine accountingLine : sourceAccountingLines) {
updateBenefitAmountSumObject(sourceLineBenefitAmountSumByObjectCode, accountingLine);
}
Map<String, Map<String, KualiDecimal>> targetLineBenefitAmountSumByObjectCode = new HashMap<String, Map<String, KualiDecimal>>();
List<ExpenseTransferTargetAccountingLine> targetAccountingLines = document.getTargetAccountingLines();
for (ExpenseTransferTargetAccountingLine accountingLine : targetAccountingLines) {
updateBenefitAmountSumObject(targetLineBenefitAmountSumByObjectCode, accountingLine);
}
Set<String> benefitTypeCodes = new HashSet<String>();
for (String key : targetLineBenefitAmountSumByObjectCode.keySet()) {
benefitTypeCodes.add(key);
}
for (String key : sourceLineBenefitAmountSumByObjectCode.keySet()) {
benefitTypeCodes.add(key);
}
for (String benefitTypeCode : benefitTypeCodes) {
KualiDecimal targetAmount = KualiDecimal.ZERO;
Map<String, KualiDecimal> targetBenefitSumsByObjectCode = new HashMap<String, KualiDecimal>();
if (targetLineBenefitAmountSumByObjectCode.containsKey(benefitTypeCode)) {
targetBenefitSumsByObjectCode = targetLineBenefitAmountSumByObjectCode.get(benefitTypeCode);
for (String objCode : targetBenefitSumsByObjectCode.keySet()) {
if (targetBenefitSumsByObjectCode.containsKey(objCode)) {
targetAmount = targetAmount.add(targetBenefitSumsByObjectCode.get(objCode));
}
}
}
KualiDecimal sourceAmount = KualiDecimal.ZERO;
Map<String, KualiDecimal> sourceBenefitSumsByObjectCode = new HashMap<String, KualiDecimal>();
if (sourceLineBenefitAmountSumByObjectCode.containsKey(benefitTypeCode)) {
sourceBenefitSumsByObjectCode = sourceLineBenefitAmountSumByObjectCode.get(benefitTypeCode);
for (String objCode : sourceBenefitSumsByObjectCode.keySet()) {
if (sourceBenefitSumsByObjectCode.containsKey(objCode)) {
sourceAmount = sourceAmount.add(sourceBenefitSumsByObjectCode.get(objCode));
}
}
}
KualiDecimal clearingAmount = sourceAmount.subtract(targetAmount);
KualiDecimal amountForObjectCode = KualiDecimal.ZERO;
if (clearingAmount.isNonZero() && ObjectUtils.isNotNull(benefitTypeCode)) {
for (String objCode : sourceBenefitSumsByObjectCode.keySet()) {
amountForObjectCode = sourceBenefitSumsByObjectCode.get(objCode);
benefitClearingPendingEntries.add(((CuLaborPendingEntryConverterServiceImpl) SpringContext.getBean(LaborPendingEntryConverterService.class)).getBenefitClearingPendingEntry(document, sequenceHelper, accountNumber, chartOfAccountsCode, benefitTypeCode, amountForObjectCode, objCode));
}
for (String objCode : targetBenefitSumsByObjectCode.keySet()) {
amountForObjectCode = targetBenefitSumsByObjectCode.get(objCode);
benefitClearingPendingEntries.add(((CuLaborPendingEntryConverterServiceImpl) SpringContext.getBean(LaborPendingEntryConverterService.class)).getBenefitClearingPendingEntry(document, sequenceHelper, accountNumber, chartOfAccountsCode, benefitTypeCode, amountForObjectCode.negated(), objCode));
}
}
}
// refresh nonupdateable references for financial object...
refreshObjectCodeNonUpdateableReferences(benefitClearingPendingEntries);
return benefitClearingPendingEntries;
}
use of org.kuali.rice.core.api.util.type.KualiDecimal in project cu-kfs by CU-CommunityApps.
the class UserFavoriteAccountServiceImpl method populateIWantAccountingLine.
protected void populateIWantAccountingLine(FavoriteAccount account, IWantAccount acctLine) {
final int ONE_HUNDRED = 100;
acctLine.setAccountNumber(account.getAccountNumber());
acctLine.setChartOfAccountsCode(account.getChartOfAccountsCode());
acctLine.setSubAccountNumber(account.getSubAccountNumber());
acctLine.setFinancialObjectCode(account.getFinancialObjectCode());
acctLine.setFinancialSubObjectCode(account.getFinancialSubObjectCode());
acctLine.setProjectCode(account.getProjectCode());
acctLine.setOrganizationReferenceId(account.getOrganizationReferenceId());
acctLine.setUseAmountOrPercent(CUPurapConstants.PERCENT);
acctLine.setAmountOrPercent(new KualiDecimal(ONE_HUNDRED));
}
use of org.kuali.rice.core.api.util.type.KualiDecimal in project cu-kfs by CU-CommunityApps.
the class PaymentGroup method getNetPaymentAmount.
/**
* Get the total of all the detail items
*
* @return
*/
public KualiDecimal getNetPaymentAmount() {
KualiDecimal amt = KualiDecimal.ZERO;
for (Iterator iter = this.getPaymentDetails().iterator(); iter.hasNext(); ) {
PaymentDetail element = (PaymentDetail) iter.next();
amt = amt.add(element.getNetPaymentAmount());
}
return amt;
}
use of org.kuali.rice.core.api.util.type.KualiDecimal in project cu-kfs by CU-CommunityApps.
the class PaymentSourceExtractionServiceImpl method extractImmediatePaymentsForCampus.
/**
* Builds payment batch for Disbursement Vouchers marked as immediate
*
* @param campusCode the campus code the disbursement vouchers should be associated with
* @param user the user responsible building the payment batch (typically the System User, kfs)
* @param processRunDate the time that the job to build immediate payments is run
*/
protected void extractImmediatePaymentsForCampus(String campusCode, String principalId, Date processRunDate, List<? extends PaymentSource> documents) {
LOG.debug("extractImmediatesPaymentsForCampus() started for campus: " + campusCode);
if (!documents.isEmpty()) {
final PaymentSource firstPaymentSource = documents.get(0);
Batch batch = createBatch(campusCode, principalId, processRunDate);
Integer count = 0;
KualiDecimal totalAmount = KualiDecimal.ZERO;
for (PaymentSource document : documents) {
if (getPaymentSourceToExtractService().shouldExtractPayment(document)) {
addPayment(document, batch, processRunDate, false);
count++;
totalAmount = totalAmount.add(getPaymentSourceToExtractService().getPaymentAmount(document));
}
}
batch.setPaymentCount(new KualiInteger(count));
batch.setPaymentTotalAmount(totalAmount);
businessObjectService.save(batch);
paymentFileEmailService.sendLoadEmail(batch);
}
}
use of org.kuali.rice.core.api.util.type.KualiDecimal in project cu-kfs by CU-CommunityApps.
the class PaymentSourceExtractionServiceImpl method extractPaymentsForCampus.
/**
* This method extracts all outstanding payments from all the disbursement vouchers in approved status for a given campus and
* adds these payments to a batch file that is uploaded for processing.
*
* @param campusCode The id code of the campus the payments will be retrieved for.
* @param user The user object used when creating the batch file to upload with outstanding payments.
* @param processRunDate This is the date that the batch file is created, often this value will be today's date.
*/
protected void extractPaymentsForCampus(String campusCode, String principalId, Date processRunDate, List<? extends PaymentSource> documents) {
if (LOG.isDebugEnabled()) {
LOG.debug("extractPaymentsForCampus() started for campus: " + campusCode);
}
Batch batch = createBatch(campusCode, principalId, processRunDate);
Integer count = 0;
KualiDecimal totalAmount = KualiDecimal.ZERO;
for (PaymentSource document : documents) {
if (getPaymentSourceToExtractService().shouldExtractPayment(document)) {
addPayment(document, batch, processRunDate, false);
count++;
totalAmount = totalAmount.add(getPaymentSourceToExtractService().getPaymentAmount(document));
}
}
batch.setPaymentCount(new KualiInteger(count));
batch.setPaymentTotalAmount(totalAmount);
businessObjectService.save(batch);
paymentFileEmailService.sendLoadEmail(batch);
}
Aggregations