本文整理汇总了Java中org.kuali.rice.core.api.util.type.KualiDecimal类的典型用法代码示例。如果您正苦于以下问题:Java KualiDecimal类的具体用法?Java KualiDecimal怎么用?Java KualiDecimal使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
KualiDecimal类属于org.kuali.rice.core.api.util.type包,在下文中一共展示了KualiDecimal类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAsText
import org.kuali.rice.core.api.util.type.KualiDecimal; //导入依赖的package包/类
/**
* This overridden method converts
* <code>org.kuali.rice.core.api.util.type.KualiPercent</code> objects to the
* display string.
*
* @see java.beans.PropertyEditorSupport#getAsText()
*/
@Override
public String getAsText() {
Object value = this.getValue();
// Previously returned N/A
if (value == null)
return "";
String stringValue = "";
try {
if (value instanceof KualiDecimal) {
value = ((KualiDecimal) this.getValue()).bigDecimalValue();
}
BigDecimal bigDecValue = (BigDecimal) value;
bigDecValue = bigDecValue.setScale(PERCENTAGE_SCALE, BigDecimal.ROUND_HALF_UP);
stringValue = NumberFormat.getInstance().format(bigDecValue.doubleValue());
} catch (IllegalArgumentException iae) {
throw new FormatException("formatting", RiceKeyConstants.ERROR_PERCENTAGE, this.getValue().toString(), iae);
}
return stringValue +"%";
}
示例2: getAsText
import org.kuali.rice.core.api.util.type.KualiDecimal; //导入依赖的package包/类
/**
* This overridden method converts
* <code>org.kuali.rice.core.api.util.type.KualiPercent</code> objects to the
* display string.
*
* @see java.beans.PropertyEditorSupport#getAsText()
*/
@Override
public String getAsText() {
Object value = this.getValue();
// Previously returned N/A
if (value == null)
return "";
String stringValue = "";
try {
if (value instanceof KualiDecimal) {
value = ((KualiDecimal) this.getValue()).bigDecimalValue();
}
BigDecimal bigDecValue = (BigDecimal) value;
bigDecValue = bigDecValue.setScale(PERCENTAGE_SCALE, BigDecimal.ROUND_HALF_UP);
stringValue = NumberFormat.getInstance().format(bigDecValue.doubleValue());
} catch (IllegalArgumentException iae) {
throw new FormatException("formatting", RiceKeyConstants.ERROR_PERCENTAGE, this.getValue().toString(), iae);
}
return stringValue;
}
示例3: columnTypeCompare
import org.kuali.rice.core.api.util.type.KualiDecimal; //导入依赖的package包/类
/**
* Compare the string values based on the given sortType, which must match one of the constants
* in {@link org.kuali.rice.krad.uif.UifConstants.TableToolsValues}.
*
* @param val1 The first string value for comparison
* @param val2 The second string value for comparison
* @param sortType the sort type
* @return 0 if the two elements are considered equal, a positive integer if the element at
* index1 is considered greater, else a negative integer
*/
private int columnTypeCompare(String val1, String val2, String sortType) {
final int result;
if (isOneNull(val1, val2)) {
result = compareOneIsNull(val1, val2);
} else if (UifConstants.TableToolsValues.STRING.equals(sortType)) {
result = val1.compareTo(val2);
} else if (UifConstants.TableToolsValues.NUMERIC.equals(sortType)) {
result = NumericValueComparator.getInstance().compare(val1, val2);
} else if (UifConstants.TableToolsValues.PERCENT.equals(sortType)) {
result = NumericValueComparator.getInstance().compare(val1, val2);
} else if (UifConstants.TableToolsValues.DATE.equals(sortType)) {
result = TemporalValueComparator.getInstance().compare(val1, val2);
} else if (UifConstants.TableToolsValues.CURRENCY.equals(sortType)) {
// strip off non-numeric symbols, convert to KualiDecimals, and compare
KualiDecimal decimal1 = new KualiDecimal(val1.replaceAll("[^0-9.]", ""));
KualiDecimal decimal2 = new KualiDecimal(val2.replaceAll("[^0-9.]", ""));
result = decimal1.compareTo(decimal2);
} else {
throw new RuntimeException("unknown sort type: " + sortType);
}
return result;
}
示例4: getSortType
import org.kuali.rice.core.api.util.type.KualiDecimal; //导入依赖的package包/类
private String getSortType(Class<?> dataTypeClass) {
String sortType = UifConstants.TableToolsValues.STRING;
if (ClassUtils.isAssignable(dataTypeClass, KualiPercent.class)) {
sortType = UifConstants.TableToolsValues.PERCENT;
} else if (ClassUtils.isAssignable(dataTypeClass, KualiInteger.class) || ClassUtils.isAssignable(dataTypeClass,
KualiDecimal.class)) {
sortType = UifConstants.TableToolsValues.CURRENCY;
} else if (ClassUtils.isAssignable(dataTypeClass, Timestamp.class)) {
sortType = "date";
} else if (ClassUtils.isAssignable(dataTypeClass, java.sql.Date.class) || ClassUtils.isAssignable(dataTypeClass,
java.util.Date.class)) {
sortType = UifConstants.TableToolsValues.DATE;
} else if (ClassUtils.isAssignable(dataTypeClass, Number.class)) {
sortType = UifConstants.TableToolsValues.NUMERIC;
}
return sortType;
}
示例5: javaToSql
import org.kuali.rice.core.api.util.type.KualiDecimal; //导入依赖的package包/类
/**
* Convert percentages to decimals for proper storage.
*
* @see FieldConversion#javaToSql(Object)
*/
public Object javaToSql(Object source) {
// Convert to BigDecimal using existing conversion.
source = super.javaToSql(source);
// Check for null, and verify object type.
// Do conversion if our type is correct (BigDecimal).
if (source != null && source instanceof BigDecimal) {
BigDecimal converted = (BigDecimal) source;
return converted.divide(oneHundred, 4, KualiDecimal.ROUND_BEHAVIOR);
}
else {
return null;
}
}
示例6: mapBuilderFromContext
import org.kuali.rice.core.api.util.type.KualiDecimal; //导入依赖的package包/类
EntityEmployment.Builder mapBuilderFromContext(DirContextOperations context) {
final String departmentCode = context.getStringAttribute(getConstants().getDepartmentLdapProperty());
if (departmentCode == null) {
return null;
}
final EntityEmployment.Builder employee = EntityEmployment.Builder.create();
employee.setId(context.getStringAttribute(getConstants().getEmployeeIdProperty()));
employee.setEmployeeStatus(
CodedAttribute.Builder.create(context.getStringAttribute(getConstants().getEmployeeStatusProperty())));
//employee.setEmployeeTypeCode(context.getStringAttribute(getConstants().getEmployeeTypeProperty()));
employee.setEmployeeType(CodedAttribute.Builder.create("P"));
employee.setBaseSalaryAmount(KualiDecimal.ZERO);
employee.setActive(true);
return employee;
}
示例7: populateEmploymentInfo
import org.kuali.rice.core.api.util.type.KualiDecimal; //导入依赖的package包/类
protected void populateEmploymentInfo( EntityDefault entity ) {
if(entity!=null){
EntityEmployment employmentInformation = entity.getEmployment();
if ( employmentInformation != null ) {
employeeStatusCode = unNullify( employmentInformation.getEmployeeStatus() != null ? employmentInformation.getEmployeeStatus().getCode() : null);
employeeTypeCode = unNullify( employmentInformation.getEmployeeType() != null ? employmentInformation.getEmployeeType().getCode() : null);
primaryDepartmentCode = unNullify( employmentInformation.getPrimaryDepartmentCode() );
employeeId = unNullify( employmentInformation.getEmployeeId() );
if ( employmentInformation.getBaseSalaryAmount() != null ) {
baseSalaryAmount = employmentInformation.getBaseSalaryAmount();
} else {
baseSalaryAmount = KualiDecimal.ZERO;
}
} else {
employeeStatusCode = "";
employeeTypeCode = "";
primaryDepartmentCode = "";
employeeId = "";
baseSalaryAmount = KualiDecimal.ZERO;
}
}
}
示例8: doProcessingAfterPost
import org.kuali.rice.core.api.util.type.KualiDecimal; //导入依赖的package包/类
@Override
protected void doProcessingAfterPost(KualiForm actionForm, HttpServletRequest request) {
super.doProcessingAfterPost(actionForm, request);
BookOrderForm form = (BookOrderForm) actionForm;
BookOrderDocument document = form.getBookOrderDocument();
for (BookOrder entry : document.getBookOrders()) {
if(entry.getBookId() != null){
Book book = KNSServiceLocator.getBusinessObjectService().findBySinglePrimaryKey(Book.class, entry.getBookId());
entry.setUnitPrice(book.getPrice());
Double totalPrice = 0.0d;
if (book.getPrice() != null && entry.getQuantity() != null) {
totalPrice = book.getPrice().doubleValue() * entry.getQuantity().intValue();
if (entry.getDiscount() != null && entry.getDiscount().doubleValue() > 0) {
totalPrice = totalPrice - (totalPrice * entry.getDiscount().doubleValue() / 100);
}
}
entry.setTotalPrice(new KualiDecimal(totalPrice));
entry.setBook(book);
}
}
}
示例9: format
import org.kuali.rice.core.api.util.type.KualiDecimal; //导入依赖的package包/类
/**
* Returns a string representation of its argument, formatted as a percentage value.
*
* @return a formatted String
*/
@Override
public Object format(Object value) {
if (value == null) {
return "N/A";
}
String stringValue = "";
try {
if (value instanceof KualiDecimal) {
value = ((KualiDecimal)value).bigDecimalValue();
}
BigDecimal bigDecValue = (BigDecimal) value;
bigDecValue = bigDecValue.setScale(PERCENTAGE_SCALE, BigDecimal.ROUND_HALF_UP);
stringValue = NumberFormat.getInstance().format(bigDecValue.doubleValue());
}
catch (IllegalArgumentException iae) {
// begin Kuali Foundation modification
throw new FormatException("formatting", RiceKeyConstants.ERROR_PERCENTAGE, value.toString(), iae);
// end Kuali Foundation modification
}
return stringValue + " percent";
}
示例10: testParseQuantityReqItem
import org.kuali.rice.core.api.util.type.KualiDecimal; //导入依赖的package包/类
/**
* Tests whether parseItem returns successfully with valid quantity-driven Requisition item line as input.
*/
public void testParseQuantityReqItem() {
String itemLine = "3,BX,123,,paper,6";
try {
PurApItem item = parser.parseItem(itemLine, itemClass, documentNumber);
assertEquals(item.getItemQuantity().compareTo(new KualiDecimal(3)), 0);
assertEquals(item.getItemUnitOfMeasureCode(), "BX");
assertEquals(item.getItemCatalogNumber(), "123");
assertEquals(item.getItemDescription(), "paper");
assertEquals(item.getItemUnitPrice().compareTo(new BigDecimal(6)), 0);
assertEquals(item.getItemTypeCode(), PurapConstants.ItemTypeCodes.ITEM_TYPE_ITEM_CODE);
assertTrue(item instanceof RequisitionItem);
assertFalse(((RequisitionItem)item).isItemRestrictedIndicator());
}
catch(ItemParserException e) {
fail("Caught ItemParserException with valid quantity-driven requisition item.");
}
}
示例11: adjustPaymentAmounts
import org.kuali.rice.core.api.util.type.KualiDecimal; //导入依赖的package包/类
/**
* @see org.kuali.kfs.module.cam.document.service.AssetPaymentService#adjustPaymentAmounts(org.kuali.kfs.module.cam.businessobject.AssetPayment,
* boolean, boolean)
*/
public void adjustPaymentAmounts(AssetPayment assetPayment, boolean reverseAmount, boolean nullPeriodDepreciation) throws IllegalAccessException, InvocationTargetException {
LOG.debug("Starting - adjustAmounts() ");
PropertyDescriptor[] propertyDescriptors = PropertyUtils.getPropertyDescriptors(AssetPayment.class);
for (PropertyDescriptor propertyDescriptor : propertyDescriptors) {
Method readMethod = propertyDescriptor.getReadMethod();
if (readMethod != null && propertyDescriptor.getPropertyType() != null && KualiDecimal.class.isAssignableFrom(propertyDescriptor.getPropertyType())) {
KualiDecimal amount = (KualiDecimal) readMethod.invoke(assetPayment);
Method writeMethod = propertyDescriptor.getWriteMethod();
if (writeMethod != null && amount != null) {
// Reset periodic depreciation expenses
if (nullPeriodDepreciation && Pattern.matches(CamsConstants.SET_PERIOD_DEPRECIATION_AMOUNT_REGEX, writeMethod.getName().toLowerCase())) {
Object[] nullVal = new Object[] { null };
writeMethod.invoke(assetPayment, nullVal);
}
else if (reverseAmount) {
// reverse the amounts
writeMethod.invoke(assetPayment, (amount.negated()));
}
}
}
}
LOG.debug("Finished - adjustAmounts()");
}
示例12: getCashSummary
import org.kuali.rice.core.api.util.type.KualiDecimal; //导入依赖的package包/类
/**
* @see org.kuali.module.gl.service.GeneralLedgerPendingEntryService#getCashSummary(java.util.Collection, java.lang.String,
* java.lang.String, boolean)
*/
@Override
public KualiDecimal getCashSummary(List universityFiscalYears, String chartOfAccountsCode, String accountNumber, boolean isDebit) {
LOG.debug("getCashSummary() started");
Chart c = chartService.getByPrimaryId(chartOfAccountsCode);
// Note, we are getting the options from the first fiscal year in the list. We are assuming that the
// balance type code for actual is the same in all the years in the list.
SystemOptions options = optionsService.getOptions((Integer) universityFiscalYears.get(0));
// FIXME! - cache this list - will not change during the lifetime of the server
Collection objectCodes = new ArrayList();
objectCodes.add(c.getFinancialCashObjectCode());
// FIXME! - cache this list - balance type code will not change during the lifetime of the server
Collection balanceTypeCodes = new ArrayList();
balanceTypeCodes.add(options.getActualFinancialBalanceTypeCd());
return generalLedgerPendingEntryDao.getTransactionSummary(universityFiscalYears, chartOfAccountsCode, accountNumber, objectCodes, balanceTypeCodes, isDebit);
}
示例13: createNewModifyCapitalAsset
import org.kuali.rice.core.api.util.type.KualiDecimal; //导入依赖的package包/类
/**
* helper method to add accounting details for this new modify capital asset record
*
* @param capitalAccountingLines
* @param currentCapitalAssetInformation
* @param documentNumber
* @param actionType
* @param nextCapitalAssetLineNumnber
* @param capitalAssetNumber
*/
protected void createNewModifyCapitalAsset(List<CapitalAccountingLines> capitalAccountingLines, List<CapitalAssetInformation> currentCapitalAssetInformation, String documentNumber, String actionType, Integer nextCapitalAssetLineNumber, long capitalAssetNumber) {
CapitalAssetInformation capitalAsset = new CapitalAssetInformation();
capitalAsset.setCapitalAssetNumber(capitalAssetNumber);
capitalAsset.setCapitalAssetLineAmount(KualiDecimal.ZERO);
capitalAsset.setDocumentNumber(documentNumber);
capitalAsset.setCapitalAssetLineNumber(nextCapitalAssetLineNumber);
capitalAsset.setCapitalAssetActionIndicator(actionType);
capitalAsset.setCapitalAssetProcessedIndicator(false);
//now setup the account line information associated with this capital asset
for (CapitalAccountingLines capitalAccountingLine : capitalAccountingLines) {
capitalAsset.setDistributionAmountCode(capitalAccountingLine.getDistributionAmountCode());
createCapitalAssetAccountingLinesDetails(capitalAccountingLine, capitalAsset);
}
currentCapitalAssetInformation.add(capitalAsset);
}
示例14: populateReportDetails
import org.kuali.rice.core.api.util.type.KualiDecimal; //导入依赖的package包/类
/**
* This method populates CustomerOpenItemReportDetails for CustomerCreditMemoDocuments and WriteOffDocuments <=> all documents
* but CustomerInvoiceDocument and PaymentApplicationDocument (Customer History Report).
*
* @param finSysDocHeaderIds <=> documentNumbers of FinancialSystemDocumentHeaders
* @param results <=> CustomerOpenItemReportDetails to display in the report
* @param details <=> <key = documentNumber, value = customerOpenItemReportDetail>
*/
public void populateReportDetails(List<String> finSysDocHeaderIds, List results, Hashtable details) {
Collection<FinancialSystemDocumentHeader> financialSystemDocHeaders = new ArrayList<FinancialSystemDocumentHeader>();
for (String documentNumber : finSysDocHeaderIds) {
FinancialSystemDocumentHeader header = businessObjectService.findBySinglePrimaryKey(FinancialSystemDocumentHeader.class, documentNumber);
if ( header != null ) {
financialSystemDocHeaders.add( header );
}
}
for ( FinancialSystemDocumentHeader fsDocumentHeader : financialSystemDocHeaders ) {
CustomerOpenItemReportDetail detail = (CustomerOpenItemReportDetail) details.get(fsDocumentHeader.getDocumentNumber());
// populate Document Description
detail.setDocumentDescription(StringUtils.trimToEmpty(fsDocumentHeader.getDocumentDescription()));
// populate Document Payment Amount
detail.setDocumentPaymentAmount(fsDocumentHeader.getFinancialDocumentTotalAmount().negated());
// Unpaid/Unapplied Amount
detail.setUnpaidUnappliedAmount(KualiDecimal.ZERO);
results.add(detail);
}
}
示例15: findNominalActivityBalancesForFiscalYear
import org.kuali.rice.core.api.util.type.KualiDecimal; //导入依赖的package包/类
/**
* Finds all of the balances for the fiscal year that should be processed by nominal activity closing
*
* @param year the university fiscal year of balances to find
* @return an Iterator of Balances to process
* @see org.kuali.kfs.gl.dataaccess.BalanceDao#findNominalActivityBalancesForFiscalYear(Integer, List, SystemOptions)
*/
@Override
public Iterator<Balance> findNominalActivityBalancesForFiscalYear(Integer year, Collection<String> nominalActivityObjectTypeCodes, SystemOptions currentYearOptions) {
LOG.debug("findNominalActivityBalancesForFiscalYear() started");
Criteria c = new Criteria();
c.addEqualTo(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR, year);
c.addEqualTo(KFSPropertyConstants.BALANCE_TYPE_CODE, currentYearOptions.getActualFinancialBalanceTypeCd());
c.addIn(KFSPropertyConstants.OBJECT_TYPE_CODE, nominalActivityObjectTypeCodes);
c.addNotEqualTo("accountLineAnnualBalanceAmount", KualiDecimal.ZERO);
QueryByCriteria query = QueryFactory.newQuery(Balance.class, c);
query.addOrderByAscending(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE);
query.addOrderByAscending(KFSPropertyConstants.ACCOUNT_NUMBER);
query.addOrderByAscending(KFSPropertyConstants.SUB_ACCOUNT_NUMBER);
query.addOrderByAscending(KFSPropertyConstants.OBJECT_CODE);
query.addOrderByAscending(KFSPropertyConstants.SUB_OBJECT_CODE);
query.addOrderByAscending(KFSPropertyConstants.BALANCE_TYPE_CODE);
query.addOrderByAscending(KFSPropertyConstants.OBJECT_TYPE_CODE);
return getPersistenceBrokerTemplate().getIteratorByQuery(query);
}