本文整理汇总了Java中org.kuali.rice.core.api.util.type.KualiDecimal.multiply方法的典型用法代码示例。如果您正苦于以下问题:Java KualiDecimal.multiply方法的具体用法?Java KualiDecimal.multiply怎么用?Java KualiDecimal.multiply使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.kuali.rice.core.api.util.type.KualiDecimal
的用法示例。
在下文中一共展示了KualiDecimal.multiply方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: calculateQuantityChange
import org.kuali.rice.core.api.util.type.KualiDecimal; //导入方法依赖的package包/类
/**
* Calculate quantity change for creating Credit Memo entries
*
* @param cancel Boolean indicating whether entries are for creation or cancellation of credit memo
* @param poItem Purchase Order Item
* @param cmQuantity Quantity on credit memo item
* @return Calculated change
*/
protected KualiDecimal calculateQuantityChange(boolean cancel, PurchaseOrderItem poItem, KualiDecimal cmQuantity) {
LOG.debug("calculateQuantityChange() started");
// Calculate quantity change & adjust invoiced quantity & outstanding encumbered quantity
KualiDecimal encumbranceQuantityChange = null;
if (cancel) {
encumbranceQuantityChange = cmQuantity.multiply(new KualiDecimal("-1"));
} else {
encumbranceQuantityChange = cmQuantity;
}
poItem.setItemInvoicedTotalQuantity(poItem.getItemInvoicedTotalQuantity().subtract(encumbranceQuantityChange));
poItem.setItemOutstandingEncumberedQuantity(poItem.getItemOutstandingEncumberedQuantity().add(encumbranceQuantityChange));
// Check for overflows
if (cancel) {
if (poItem.getItemOutstandingEncumberedQuantity().doubleValue() < 0) {
LOG.debug("calculateQuantityChange() Cancel overflow");
KualiDecimal difference = poItem.getItemOutstandingEncumberedQuantity().abs();
poItem.setItemOutstandingEncumberedQuantity(ZERO);
poItem.setItemInvoicedTotalQuantity(poItem.getItemQuantity());
encumbranceQuantityChange = encumbranceQuantityChange.add(difference);
}
}
// Coomented for JIRA:OLE-5162 as encumbrance get doubled here.
/* else {
if (poItem.getItemInvoicedTotalQuantity().doubleValue() < 0) {
LOG.debug("calculateQuantityChange() Create overflow");
KualiDecimal difference = poItem.getItemInvoicedTotalQuantity().abs();
poItem.setItemOutstandingEncumberedQuantity(poItem.getItemQuantity());
poItem.setItemInvoicedTotalQuantity(ZERO);
encumbranceQuantityChange = encumbranceQuantityChange.add(difference);
}
} */
return encumbranceQuantityChange;
}
示例2: post
import org.kuali.rice.core.api.util.type.KualiDecimal; //导入方法依赖的package包/类
/**
* This posts the effect of the transaction upon the appropriate balance record.
*
* @param t the transaction which is being posted
* @param mode the mode the poster is currently running in
* @param postDate the date this transaction should post to
* @param posterReportWriterService the writer service where the poster is writing its report
* @return the accomplished post type
* @see org.kuali.ole.gl.batch.service.PostTransaction#post(org.kuali.ole.gl.businessobject.Transaction, int, java.util.Date)
*/
public String post(Transaction t, int mode, Date postDate, ReportWriterService posterReportWriterService) {
LOG.debug("post() started");
String postType = "U";
KualiDecimal amount = t.getTransactionLedgerEntryAmount();
// Subtract the amount if offset generation indicator & the debit/credit code isn't the same
// as the one in the object type code table
if (t.getBalanceType().isFinancialOffsetGenerationIndicator()) {
if (!t.getTransactionDebitCreditCode().equals(t.getObjectType().getFinObjectTypeDebitcreditCd())) {
amount = amount.multiply(NEGATIVE_ONE);
}
}
Balance b = accountingCycleCachingService.getBalance(t);
if (b == null) {
postType = "I";
b = new Balance(t);
}
String period = t.getUniversityFiscalPeriodCode();
b.addAmount(period, amount);
if (postType.equals("I")) {
accountingCycleCachingService.insertBalance(b);
} else {
accountingCycleCachingService.updateBalance(b);
}
return postType;
}
示例3: updateBalance
import org.kuali.rice.core.api.util.type.KualiDecimal; //导入方法依赖的package包/类
/**
* @param t
* @param enc
*/
public void updateBalance(Transaction t, Balance b) {
// The pending entries haven't been scrubbed so there could be
// bad data. This won't update a balance if the data it needs
// is invalid
KualiDecimal amount = t.getTransactionLedgerEntryAmount();
if (amount == null) {
amount = KualiDecimal.ZERO;
}
if (t.getObjectType() == null) {
LOG.error("updateBalance() Invalid object type (" + t.getFinancialObjectTypeCode() + ") in pending table");
return;
}
if (t.getBalanceType() == null) {
LOG.error("updateBalance() Invalid balance type (" + t.getFinancialBalanceTypeCode() + ") in pending table");
return;
}
// Subtract the amount if offset generation indicator & the debit/credit code isn't the same
// as the one in the object type code table
if (t.getBalanceType().isFinancialOffsetGenerationIndicator()) {
if (!t.getTransactionDebitCreditCode().equals(t.getObjectType().getFinObjectTypeDebitcreditCd())) {
amount = amount.multiply(new KualiDecimal(-1));
}
}
// update the balance amount of the cooresponding period
String period = t.getUniversityFiscalPeriodCode();
if (period == null) {
UniversityDate currentUniversityDate = SpringContext.getBean(UniversityDateService.class).getCurrentUniversityDate();
period = currentUniversityDate.getUniversityFiscalAccountingPeriod();
}
b.addAmount(period, amount);
}
示例4: getMaximumAmount
import org.kuali.rice.core.api.util.type.KualiDecimal; //导入方法依赖的package包/类
/**
* Get maximum amount
*
* @param actualExpense
* @param document
* @return
*/
protected KualiDecimal getMaximumAmount(ActualExpense actualExpense, TravelDocument document, ExpenseTypeObjectCode expenseTypeObjectCode) {
KualiDecimal maxAmount = KualiDecimal.ZERO;
if (expenseTypeObjectCode != null && expenseTypeObjectCode.getMaximumAmount() != null) {
maxAmount = expenseTypeObjectCode.getMaximumAmount();
}
//add the group traveler list + self (1)
if (actualExpense.getExpenseType().isGroupTravel()) {
KualiDecimal groupTravelMultipier = new KualiDecimal(document.getGroupTravelers().size() + 1);
maxAmount = maxAmount.multiply(groupTravelMultipier);
}
return maxAmount;
}
示例5: getNumericAmount
import org.kuali.rice.core.api.util.type.KualiDecimal; //导入方法依赖的package包/类
/**
* Determine the actual amount based on Debit Credit code. If the code is credit code, then change the sign of the given amount;
* otherwise, do nothing
*
* @param amount the given amount, which can be either negative or positive number.
* @param currentDebitCreditCode the current debit credit code
* @return the actual numeric amount of the given amount
*/
public static KualiDecimal getNumericAmount(KualiDecimal amount, String currentDebitCreditCode) {
KualiDecimal actualAmount = amount;
if (amount == null) {
actualAmount = KualiDecimal.ZERO;
}
else if (KFSConstants.GL_CREDIT_CODE.equals(currentDebitCreditCode)) {
actualAmount = actualAmount.multiply(new KualiDecimal(-1));
}
return actualAmount;
}
示例6: post
import org.kuali.rice.core.api.util.type.KualiDecimal; //导入方法依赖的package包/类
/**
* This posts the effect of the transaction upon the appropriate balance record.
*
* @param t the transaction which is being posted
* @param mode the mode the poster is currently running in
* @param postDate the date this transaction should post to
* @param posterReportWriterService the writer service where the poster is writing its report
* @return the accomplished post type
* @see org.kuali.kfs.gl.batch.service.PostTransaction#post(org.kuali.kfs.gl.businessobject.Transaction, int, java.util.Date)
*/
public String post(Transaction t, int mode, Date postDate, ReportWriterService posterReportWriterService) {
LOG.debug("post() started");
String postType = "U";
KualiDecimal amount = t.getTransactionLedgerEntryAmount();
// Subtract the amount if offset generation indicator & the debit/credit code isn't the same
// as the one in the object type code table
if (t.getBalanceType().isFinancialOffsetGenerationIndicator()) {
if (!t.getTransactionDebitCreditCode().equals(t.getObjectType().getFinObjectTypeDebitcreditCd())) {
amount = amount.multiply(NEGATIVE_ONE);
}
}
Balance b = accountingCycleCachingService.getBalance(t);
if (b == null) {
postType = "I";
b = new Balance(t);
}
String period = t.getUniversityFiscalPeriodCode();
b.addAmount(period, amount);
if (postType.equals("I")) {
accountingCycleCachingService.insertBalance(b);
} else {
accountingCycleCachingService.updateBalance(b);
}
return postType;
}
示例7: allocateByQuantity
import org.kuali.rice.core.api.util.type.KualiDecimal; //导入方法依赖的package包/类
/**
* Allocates evenly a sum of money amongst a number of targets.
* Note:
* 1. This method assumes that the divisor is a positive integer. Validation of the the passed in parameters shall be the caller's responsibility.
* 2. If the sum can't be evenly divided due to limited accuracy, the last few elements will be adjusted (each by 1c) to reflect the round-up difference.
*
* @param amount the total amount to allocate
* @param divisor the number of targets to allocate to
* @return an array of allocated amounts
*/
public static KualiDecimal[] allocateByQuantity(KualiDecimal amount, int divisor) {
if (amount == null || divisor == 0) {
return amount == null ? null : new KualiDecimal[] { amount };
}
// calculate evenly divided amount
KualiDecimal dividedAmount = amount.divide(new KualiDecimal(divisor));
// set the allocated amount into array
KualiDecimal[] amountsArray = new KualiDecimal[divisor];
for (int i = 0; i < divisor; i++) {
amountsArray[i] = dividedAmount;
}
// compute the difference between the original total amount and the allocated total amount, due to round up error in division
KualiDecimal allocatedAmount = dividedAmount.multiply(new KualiDecimal(divisor));
KualiDecimal reminderAmount = amount.subtract(allocatedAmount);
/* Note:
* We choose to distribute 1c to each of the last N elements, instead of putting the total difference into the last one element, because:
* 1. This way the allocation is more even; otherwise the last element may end up taking too much or too little (even negative).
* For ex, suppose amount = $99, and divisor = 10000. So the first 9999 elements would each get 1c, while the last one would get -99c,
* if we dump all of the roundup error into the last element.
* 2. The round up error for each element is less than 1c (in fact, it's less than 0.5c, as KualiDecimal uses ROUND_HALF_UP),
* thus the total error is less than 1c * divisor, which means we can safely distribute 1c to the last N elements, where N < divisor.
*/
// since KualiDecimal has 2 digits after decimal point, multiply it by 100 guarantees that we get an integer number of cents
int n = reminderAmount.abs().multiply(new KualiDecimal(100)).intValue();
KualiDecimal cent = reminderAmount.isPositive() ? new KualiDecimal(0.01) : new KualiDecimal(-0.01);
// compensate the difference by offsetting the last N elements, each by 1c; here N = reminderAmount * 100
for (int i = divisor - 1; i >= divisor - n ; i--) {
amountsArray[i] = dividedAmount.add(cent);
}
return amountsArray;
}
示例8: updateSearchResults
import org.kuali.rice.core.api.util.type.KualiDecimal; //导入方法依赖的package包/类
public List updateSearchResults(List<AccountBalance> fundbBalanceList) {
for (AccountBalance balance : fundbBalanceList) {
OleFundLookup oleFundLookup = new OleFundLookup();
String chartCode = balance.getChartOfAccountsCode();
String accountNumber = balance.getAccountNumber();
String objectCode = balance.getObjectCode();
int fiscalYear = balance.getUniversityFiscalYear();
KualiDecimal encumbranceAmount = balance.getAccountLineEncumbranceBalanceAmount();
KualiDecimal sumPaidInvoice = balance.getAccountLineActualsBalanceAmount();
KualiDecimal sumUnpaidInvoice = KualiDecimal.ZERO;
KualiDecimal budgetIncrease = KualiDecimal.ZERO;
KualiDecimal budgetDecrease = KualiDecimal.ZERO;
KualiDecimal initialBudgetAllocation = balance.getCurrentBudgetLineBalanceAmount();
KualiDecimal netAllocation = balance.getCurrentBudgetLineBalanceAmount();
KualiDecimal encumExpPercentage = ((sumPaidInvoice.add(encumbranceAmount)).multiply(new KualiDecimal(100)));
if(!encumExpPercentage.isZero() && netAllocation.isGreaterThan(KualiDecimal.ZERO)){
encumExpPercentage = encumExpPercentage.divide(netAllocation);
}else{
encumExpPercentage = KualiDecimal.ZERO;
}
KualiDecimal expenPercentage = sumPaidInvoice.multiply(new KualiDecimal(100));
if(!expenPercentage.isZero() && netAllocation.isGreaterThan(KualiDecimal.ZERO)){
expenPercentage = expenPercentage.divide(netAllocation);
}else{
expenPercentage = KualiDecimal.ZERO;
}
oleFundLookup.setChartOfAccountsCode(chartCode);
oleFundLookup.setAccountNumber(accountNumber);
oleFundLookup.setAccountName(getAccountName(accountNumber));
oleFundLookup.setOrganizationCode(getOrganizationCode(accountNumber));
oleFundLookup.setObjectCode(objectCode);
oleFundLookup.setCashBalance(convertNegativeSign(netAllocation.subtract(sumPaidInvoice)));
oleFundLookup.setFreeBalance(convertNegativeSign((netAllocation.subtract(sumPaidInvoice)).subtract(encumbranceAmount)));
oleFundLookup.setIntialBudgetAllocation(initialBudgetAllocation.toString());
oleFundLookup.setNetAllocation(convertNegativeSign(netAllocation));
oleFundLookup.setEncumbrances(convertNegativeSign(encumbranceAmount));
oleFundLookup.setSumPaidInvoice(convertNegativeSign(sumPaidInvoice));
oleFundLookup.setSumUnpaidInvoice(convertNegativeSign(sumUnpaidInvoice));
oleFundLookup.setExpendedPercentage(convertNegativeSign(expenPercentage));
oleFundLookup.setExpenEncumPercentage(convertNegativeSign(encumExpPercentage));
searchEntryList.add(oleFundLookup);
}
return searchEntryList;
}
示例9: getTotal
import org.kuali.rice.core.api.util.type.KualiDecimal; //导入方法依赖的package包/类
/**
* @return the total amount for this item
*/
public KualiDecimal getTotal() {
KualiDecimal total = new KualiDecimal(itemQuantity.toString());
return total.multiply(itemUnitAmount);
}
示例10: calculateMealsAndIncidentalsProrated
import org.kuali.rice.core.api.util.type.KualiDecimal; //导入方法依赖的package包/类
public static KualiDecimal calculateMealsAndIncidentalsProrated(KualiDecimal total, Integer perDiemPercent) {
KualiDecimal percent = new KualiDecimal(perDiemPercent).divide(new KualiDecimal(100));
total = total.multiply(percent);
return total;
}
示例11: convertDecimalIntoInteger
import org.kuali.rice.core.api.util.type.KualiDecimal; //导入方法依赖的package包/类
/**
* Convert the given money amount into an integer string.
*
* <p>
* Since the return string cannot have decimal point, multiplies the amount by 100 so the decimal places
* are not lost, for example, 320.15 is converted into 32015.
* </p>
*
* @param decimalNumber decimal number to be converted
* @return an integer string of the given money amount through multiplying by 100 and removing the fraction
* portion.
*/
public final static String convertDecimalIntoInteger(KualiDecimal decimalNumber) {
KualiDecimal decimalAmount = decimalNumber.multiply(ONE_HUNDRED);
NumberFormat formatter = NumberFormat.getIntegerInstance();
String formattedAmount = formatter.format(decimalAmount);
return StringUtils.replace(formattedAmount, ",", "");
}