当前位置: 首页>>代码示例>>Java>>正文


Java KualiDecimal.compareTo方法代码示例

本文整理汇总了Java中org.kuali.rice.core.api.util.type.KualiDecimal.compareTo方法的典型用法代码示例。如果您正苦于以下问题:Java KualiDecimal.compareTo方法的具体用法?Java KualiDecimal.compareTo怎么用?Java KualiDecimal.compareTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.kuali.rice.core.api.util.type.KualiDecimal的用法示例。


在下文中一共展示了KualiDecimal.compareTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:36,代码来源:MultiColumnComparator.java

示例2: validate

import org.kuali.rice.core.api.util.type.KualiDecimal; //导入方法依赖的package包/类
/**
 * Validates that an accounting line does not have a capital object object code
 * <strong>Expects an accounting line as the first a parameter</strong>
 * @see org.kuali.kfs.sys.document.validation.Validation#validate(java.lang.Object[])
 */
public boolean validate(AttributedDocumentEvent event) {
    ProcurementCardDocument pcDocument = (ProcurementCardDocument) getAccountingDocumentForValidation();

    KualiDecimal targetTotal = pcDocument.getTargetTotal();
    KualiDecimal sourceTotal = pcDocument.getSourceTotal();

    boolean isValid = targetTotal.compareTo(sourceTotal) == 0;

    if (!isValid) {
        GlobalVariables.getMessageMap().putError(ACCOUNTING_LINE_ERRORS, ERROR_DOCUMENT_BALANCE_CONSIDERING_SOURCE_AND_TARGET_AMOUNTS, new String[] { sourceTotal.toString(), targetTotal.toString() });
    }

    List<ProcurementCardTransactionDetail> pcTransactionEntries = pcDocument.getTransactionEntries();

    for (ProcurementCardTransactionDetail pcTransactionDetail : pcTransactionEntries) {
        isValid &= isTransactionBalanceValid(pcTransactionDetail);
    }

    return isValid;
}
 
开发者ID:kuali,项目名称:kfs,代码行数:26,代码来源:ProcurementCardBalanceValidation.java

示例3: processDetailSoftEdits

import org.kuali.rice.core.api.util.type.KualiDecimal; //导入方法依赖的package包/类
/**
 * Set default fields on detail line and check amount against customer threshold.
 * 
 * @param paymentFile payment file object
 * @param customer payment customer
 * @param paymentDetail <code>PaymentDetail</code> object to process
 * @param warnings <code>List</code> list of accumulated warning messages
 */
protected void processDetailSoftEdits(PaymentFileLoad paymentFile, CustomerProfile customer, PaymentDetail paymentDetail, List<String> warnings) {
    updateDetailAmounts(paymentDetail);

    // Check net payment amount
    KualiDecimal testAmount = paymentDetail.getNetPaymentAmount();
    if (testAmount.compareTo(customer.getPaymentThresholdAmount()) > 0) {
        addWarningMessage(warnings, PdpKeyConstants.MESSAGE_PAYMENT_LOAD_DETAIL_THRESHOLD, testAmount.toString(), customer.getPaymentThresholdAmount().toString());
        paymentFile.setDetailThreshold(true);
        paymentFile.getThresholdPaymentDetails().add(paymentDetail);
    }

    // set invoice date if it doesn't exist
    if (paymentDetail.getInvoiceDate() == null) {
        paymentDetail.setInvoiceDate(dateTimeService.getCurrentSqlDate());
    }

    if (paymentDetail.getPrimaryCancelledPayment() == null) {
        paymentDetail.setPrimaryCancelledPayment(Boolean.FALSE);
    }

    // do accounting edits
    for (PaymentAccountDetail paymentAccountDetail : paymentDetail.getAccountDetail()) {
        paymentAccountDetail.setPaymentDetailId(paymentDetail.getId());

        processAccountSoftEdits(paymentFile, customer, paymentAccountDetail, warnings);
    }
}
 
开发者ID:VU-libtech,项目名称:OLE-INST,代码行数:36,代码来源:PaymentFileValidationServiceImpl.java

示例4: redistributeAmountsForAccountingsLineForModifyAssets

import org.kuali.rice.core.api.util.type.KualiDecimal; //导入方法依赖的package包/类
/**
 *
 * @param accountingLine
 * @param capitalAssetInformation
 * @param remainingAmountToDistribute
 */
protected void redistributeAmountsForAccountingsLineForModifyAssets(List<CapitalAccountingLines> selectedCapitalAccountingLines, List<CapitalAssetInformation> capitalAssetInformation, KualiDecimal remainingAmountToDistribute) {
    //get the total capital assets quantity
    int totalQuantity = getNumberOfModifiedAssetsExist(selectedCapitalAccountingLines, capitalAssetInformation);
    if (totalQuantity > 0) {
        KualiDecimal equalModifyAssetAmount = remainingAmountToDistribute.divide(new KualiDecimal(totalQuantity), true);

        int lastAssetIndex = 0;
        CapitalAssetInformation lastCapitalAsset = new CapitalAssetInformation();

        if (equalModifyAssetAmount.compareTo(KualiDecimal.ZERO) != 0) {
            for (CapitalAssetInformation capitalAsset : capitalAssetInformation) {
                if (KFSConstants.CapitalAssets.CAPITAL_ASSET_MODIFY_ACTION_INDICATOR.equals(capitalAsset.getCapitalAssetActionIndicator()) &&
                        (ObjectUtils.isNotNull(capitalAsset.getCapitalAssetNumber())) &&
                        (KFSConstants.CapitalAssets.DISTRIBUTE_COST_EQUALLY_CODE.equalsIgnoreCase(capitalAsset.getDistributionAmountCode()))) {
                    if (capitalAssetExists(selectedCapitalAccountingLines, capitalAsset, KFSConstants.CapitalAssets.CAPITAL_ASSET_MODIFY_ACTION_INDICATOR)) {
                        capitalAsset.setCapitalAssetQuantity(1);
                        redistributeEqualAmounts(selectedCapitalAccountingLines, capitalAsset, equalModifyAssetAmount, totalQuantity);
                        lastAssetIndex++;
                        //get a reference to the last capital create asset to fix any variances...
                        lastCapitalAsset = capitalAsset;
                    }
                }
            }
        }

        //apply any variance left to the last
        KualiDecimal varianceForAssets = remainingAmountToDistribute.subtract(equalModifyAssetAmount.multiply(new KualiDecimal(lastAssetIndex)));
        if (varianceForAssets.isNonZero()) {
            lastCapitalAsset.setCapitalAssetLineAmount(lastCapitalAsset.getCapitalAssetLineAmount().add(varianceForAssets));
            redistributeEqualAmountsOnLastCapitalAsset(selectedCapitalAccountingLines, lastCapitalAsset, capitalAssetInformation, KFSConstants.CapitalAssets.CAPITAL_ASSET_MODIFY_ACTION_INDICATOR);
        }
    }
}
 
开发者ID:kuali,项目名称:kfs,代码行数:40,代码来源:CapitalAssetInformationActionBase.java

示例5: validateTotalAmount

import org.kuali.rice.core.api.util.type.KualiDecimal; //导入方法依赖的package包/类
/**
 * Verifies account amounts = item total. If does not equal then validation fails. 
 * @param item
 * @param writeErrorMessage true if error message to be added to global error variables, else false
 * @return true if account amounts sum = item total
 */
public boolean validateTotalAmount(PurApItem item, boolean writeErrorMessage) {
    boolean valid = true;
    
    if (item.getSourceAccountingLines().size() == 0) {
        return valid;
    }
    
    if (item.getItemQuantity() == null || item.getItemUnitPrice() == null || item.getTotalAmount().compareTo(KualiDecimal.ZERO) == 0) {
        //extended cost is not available yet so do not run validations....
        return valid;
    }
    
 // validate that the amount total 
    KualiDecimal totalAmount = KualiDecimal.ZERO;
    
    KualiDecimal desiredAmount = (item.getTotalAmount() == null) ? new KualiDecimal(0) : item.getTotalAmount();
    for (PurApAccountingLine account : item.getSourceAccountingLines()) {
        if (account.getAmount() != null) {
            totalAmount = totalAmount.add(account.getAmount());
        }
        else {
            totalAmount = totalAmount.add(KualiDecimal.ZERO);
        }
    }
    
    if (desiredAmount.compareTo(totalAmount) != 0) {
        if (writeErrorMessage) {
            GlobalVariables.getMessageMap().putError(PurapConstants.ITEM_TAB_ERROR_PROPERTY, PurapKeyConstants.ERROR_ITEM_ACCOUNTING_TOTAL_AMOUNT, item.getItemIdentifierString(),desiredAmount.toString());
        }
        valid = false;
    }

    return valid;
}
 
开发者ID:kuali,项目名称:kfs,代码行数:41,代码来源:PurchasingAccountsPayablesItemPreCalculateValidations.java

示例6: validate

import org.kuali.rice.core.api.util.type.KualiDecimal; //导入方法依赖的package包/类
/**
 * Verifies account percent. If the total percent does not equal 100, the validation fails.
 */
@Override
public boolean validate(AttributedDocumentEvent event) {
    boolean valid = true;

    // validate that the amount total
    KualiDecimal totalAmount = KualiDecimal.ZERO;
    KualiDecimal desiredAmount =
            (itemForValidation.getTotalAmount() == null) ? new KualiDecimal(0) : itemForValidation.getTotalAmount();

    KualiDecimal prorateSurcharge = KualiDecimal.ZERO;
    OlePaymentRequestItem preqItem = (OlePaymentRequestItem) itemForValidation;
    if (preqItem.getItemType().isQuantityBasedGeneralLedgerIndicator() && preqItem.getExtendedPrice() != null && preqItem.getExtendedPrice().compareTo(KualiDecimal.ZERO) != 0) {
        if (preqItem.getItemSurcharge() != null && preqItem.getItemTypeCode().equals("ITEM")) {
            prorateSurcharge = new KualiDecimal(preqItem.getItemSurcharge()).multiply(preqItem.getItemQuantity());
        }
        desiredAmount = desiredAmount.subtract(prorateSurcharge);
    }

    for (PurApAccountingLine account : itemForValidation.getSourceAccountingLines()) {
        if (account.getAmount() != null) {
            totalAmount = totalAmount.add(account.getAmount());
        } else {
            totalAmount = totalAmount.add(KualiDecimal.ZERO);
        }
    }

    if (desiredAmount.compareTo(totalAmount) != 0) {
        GlobalVariables.getMessageMap().putError(PurapConstants.ITEM_TAB_ERROR_PROPERTY, PurapKeyConstants.ERROR_ITEM_ACCOUNTING_TOTAL_AMOUNT, itemForValidation.getItemIdentifierString(), desiredAmount.toString());
        valid = false;
    }


    return valid;
}
 
开发者ID:VU-libtech,项目名称:OLE-INST,代码行数:38,代码来源:PaymentRequestAccountTotalValidation.java

示例7: validate

import org.kuali.rice.core.api.util.type.KualiDecimal; //导入方法依赖的package包/类
/**
 * Validates the total of the monthly amount fields (if not 0) equals the current budget amount. If current budget is 0, then
 * total of monthly fields must be 0.
 * 
 * @see org.kuali.kfs.sys.document.validation.Validation#validate(org.kuali.kfs.sys.document.validation.event.AttributedDocumentEvent)
 */
public boolean validate(AttributedDocumentEvent event) {
    boolean validMonthlyLines = true;

    KualiDecimal monthlyTotal = getAccountingLineForValidation().getMonthlyLinesTotal();
    if (monthlyTotal.isNonZero() && monthlyTotal.compareTo(getAccountingLineForValidation().getCurrentBudgetAdjustmentAmount()) != 0) {
        GlobalVariables.getMessageMap().putError(KFSPropertyConstants.CURRENT_BUDGET_ADJUSTMENT_AMOUNT, KFSKeyConstants.ERROR_DOCUMENT_BA_MONTH_TOTAL_NOT_EQUAL_CURRENT);
        validMonthlyLines = false;
    }

    return validMonthlyLines;
}
 
开发者ID:kuali,项目名称:kfs,代码行数:18,代码来源:BudgetAdjustmentAccountingLineMonthlyLinesValidation.java

示例8: redistributeAmountsForAccountingsLineForModifyAssets

import org.kuali.rice.core.api.util.type.KualiDecimal; //导入方法依赖的package包/类
/**
 *
 * @param accountingLine
 * @param capitalAssetInformation
 * @param remainingAmountToDistribute
 */
protected void redistributeAmountsForAccountingsLineForModifyAssets(List<CapitalAccountingLines> selectedCapitalAccountingLines, List<CapitalAssetInformation> capitalAssetInformation, KualiDecimal remainingAmountToDistribute) {
    //get the total capital assets quantity
    int totalQuantity = getNumberOfModifiedAssetsExist(selectedCapitalAccountingLines, capitalAssetInformation);
    if (totalQuantity > 0) {
        KualiDecimal equalModifyAssetAmount = remainingAmountToDistribute.divide(new KualiDecimal(totalQuantity), true);

    int lastAssetIndex = 0;
    CapitalAssetInformation lastCapitalAsset = new CapitalAssetInformation();

    if (equalModifyAssetAmount.compareTo(KualiDecimal.ZERO) != 0) {
        for (CapitalAssetInformation capitalAsset : capitalAssetInformation) {
            if (OLEConstants.CapitalAssets.CAPITAL_ASSET_MODIFY_ACTION_INDICATOR.equals(capitalAsset.getCapitalAssetActionIndicator()) &&
                        (ObjectUtils.isNotNull(capitalAsset.getCapitalAssetNumber())) &&
                        (OLEConstants.CapitalAssets.DISTRIBUTE_COST_EQUALLY_CODE.equalsIgnoreCase(capitalAsset.getDistributionAmountCode()))) {
                    if (capitalAssetExists(selectedCapitalAccountingLines, capitalAsset, OLEConstants.CapitalAssets.CAPITAL_ASSET_MODIFY_ACTION_INDICATOR)) {
                capitalAsset.setCapitalAssetQuantity(1);
                        redistributeEqualAmounts(selectedCapitalAccountingLines, capitalAsset, equalModifyAssetAmount, totalQuantity);
                lastAssetIndex++;
                //get a reference to the last capital create asset to fix any variances...
                lastCapitalAsset = capitalAsset;
            }
        }
    }
        }

    //apply any variance left to the last
    KualiDecimal varianceForAssets = remainingAmountToDistribute.subtract(equalModifyAssetAmount.multiply(new KualiDecimal(lastAssetIndex)));
    if (varianceForAssets.isNonZero()) {
            lastCapitalAsset.setCapitalAssetLineAmount(lastCapitalAsset.getCapitalAssetLineAmount().add(varianceForAssets));
            redistributeEqualAmountsOnLastCapitalAsset(selectedCapitalAccountingLines, lastCapitalAsset, capitalAssetInformation, OLEConstants.CapitalAssets.CAPITAL_ASSET_MODIFY_ACTION_INDICATOR);
        }
    }
}
 
开发者ID:VU-libtech,项目名称:OLE-INST,代码行数:40,代码来源:CapitalAssetInformationActionBase.java

示例9: validateItemAccounts

import org.kuali.rice.core.api.util.type.KualiDecimal; //导入方法依赖的package包/类
/**
 * Validates the totals for the item by account, that the total by each accounting line for the item, matches
 * the extended price on the item.
 *
 * @param invoiceDocument  - payment request document
 * @param item             - payment request item to validate
 * @param identifierString - identifier string used to mark in an error map
 * @return
 */
public boolean validateItemAccounts(InvoiceDocument invoiceDocument, InvoiceItem item, String identifierString) {
    boolean valid = true;
    List<PurApAccountingLine> accountingLines = item.getSourceAccountingLines();
    KualiDecimal itemTotal = item.getTotalAmount();
    KualiDecimal accountTotal = KualiDecimal.ZERO;
    KualiDecimal prorateSurcharge = KualiDecimal.ZERO;
    OleInvoiceItem invoiceItem = (OleInvoiceItem) item;
    if (invoiceItem.getItemType().isQuantityBasedGeneralLedgerIndicator() && invoiceItem.getExtendedPrice() != null && invoiceItem.getExtendedPrice().compareTo(KualiDecimal.ZERO) != 0) {
        if (invoiceItem.getItemSurcharge() != null && invoiceItem.getItemTypeCode().equals("ITEM")) {
            prorateSurcharge = new KualiDecimal(invoiceItem.getItemSurcharge()).multiply(invoiceItem.getItemQuantity());
        }
        itemTotal = itemTotal.subtract(prorateSurcharge);
    }
    for (PurApAccountingLine accountingLine : accountingLines) {
        if (accountingLine.getAmount().isZero()) {
            if (!canApproveAccountingLinesWithZeroAmount()) {
                GlobalVariables.getMessageMap().putError(PurapConstants.ITEM_TAB_ERROR_PROPERTY, PurapKeyConstants.ERROR_ITEM_ACCOUNTING_AMOUNT_INVALID, itemForValidation.getItemIdentifierString());
                valid &= false;
            }
        }
        valid &= reviewAccountingLineValidation(invoiceDocument, accountingLine);
        accountTotal = accountTotal.add(accountingLine.getAmount());
    }
    if (purapService.isFullDocumentEntryCompleted(invoiceDocument)) {
        // check amounts not percent after full entry
        if (accountTotal.compareTo(itemTotal) != 0) {
            valid = false;
            GlobalVariables.getMessageMap().putError(PurapConstants.ITEM_TAB_ERROR_PROPERTY, PurapKeyConstants.ERROR_ITEM_ACCOUNTING_AMOUNT_TOTAL, identifierString);
        }
    }
    return valid;
}
 
开发者ID:VU-libtech,项目名称:OLE-INST,代码行数:42,代码来源:InvoiceProcessItemValidation.java

示例10: validate

import org.kuali.rice.core.api.util.type.KualiDecimal; //导入方法依赖的package包/类
/**
 * Verifies account percent. If the total percent does not equal 100, the validation fails.
 */
@Override
public boolean validate(AttributedDocumentEvent event) {
    boolean valid = true;

    // validate that the amount total
    KualiDecimal totalAmount = KualiDecimal.ZERO;
    KualiDecimal desiredAmount =
            (itemForValidation.getTotalAmount() == null) ? new KualiDecimal(0) : itemForValidation.getTotalAmount();

    KualiDecimal prorateSurcharge = KualiDecimal.ZERO;
    OleInvoiceItem invoiceItem = (OleInvoiceItem) itemForValidation;
    if (invoiceItem.getItemType().isQuantityBasedGeneralLedgerIndicator() && invoiceItem.getExtendedPrice() != null && invoiceItem.getExtendedPrice().compareTo(KualiDecimal.ZERO) != 0) {
        if (invoiceItem.getItemSurcharge() != null && invoiceItem.getItemTypeCode().equals("ITEM")) {
            prorateSurcharge = new KualiDecimal(invoiceItem.getItemSurcharge()).multiply(invoiceItem.getItemQuantity());
        }
        desiredAmount = desiredAmount.subtract(prorateSurcharge);
    }

    for (PurApAccountingLine account : itemForValidation.getSourceAccountingLines()) {
        if (account.getAmount() != null) {
            totalAmount = totalAmount.add(account.getAmount());
        } else {
            totalAmount = totalAmount.add(KualiDecimal.ZERO);
        }
    }

    if (desiredAmount.compareTo(totalAmount) != 0) {
        GlobalVariables.getMessageMap().putError(PurapConstants.ITEM_TAB_ERROR_PROPERTY, PurapKeyConstants.ERROR_ITEM_ACCOUNTING_TOTAL_AMOUNT, itemForValidation.getItemIdentifierString(), desiredAmount.toString());
        valid = false;
    }


    return valid;
}
 
开发者ID:VU-libtech,项目名称:OLE-INST,代码行数:38,代码来源:InvoiceAccountTotalValidation.java

示例11: validateMinimumOrderAmount

import org.kuali.rice.core.api.util.type.KualiDecimal; //导入方法依赖的package包/类
/**
 * Validates that the minimum order amount is less than the maximum allowed amount.
 *
 * @param vendorDetail The VendorDetail object to be validated
 * @return booelan true if the vendorMinimumOrderAmount is less than the maximum allowed amount.
 */
private boolean validateMinimumOrderAmount(VendorDetail vendorDetail) {
    boolean valid = true;
    KualiDecimal minimumOrderAmount = vendorDetail.getVendorMinimumOrderAmount();
    if (ObjectUtils.isNotNull(minimumOrderAmount)) {
        KualiDecimal VENDOR_MIN_ORDER_AMOUNT = new KualiDecimal(SpringContext.getBean(ParameterService.class).getParameterValueAsString(VendorDetail.class, VendorParameterConstants.VENDOR_MIN_ORDER_AMOUNT));
        if (ObjectUtils.isNotNull(VENDOR_MIN_ORDER_AMOUNT) && (VENDOR_MIN_ORDER_AMOUNT.compareTo(minimumOrderAmount) < 1) || (minimumOrderAmount.isNegative())) {
            putFieldError(VendorPropertyConstants.VENDOR_MIN_ORDER_AMOUNT, VendorKeyConstants.ERROR_VENDOR_MAX_MIN_ORDER_AMOUNT, VENDOR_MIN_ORDER_AMOUNT.toString());
            valid &= false;
        }
    }
    return valid;
}
 
开发者ID:kuali,项目名称:kfs,代码行数:19,代码来源:VendorRule.java

示例12: validate

import org.kuali.rice.core.api.util.type.KualiDecimal; //导入方法依赖的package包/类
/**
 * Validates the total of the monthly amount fields (if not 0) equals the current budget amount. If current budget is 0, then
 * total of monthly fields must be 0.
 * 
 * @see org.kuali.ole.sys.document.validation.Validation#validate(org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent)
 */
public boolean validate(AttributedDocumentEvent event) {
    boolean validMonthlyLines = true;

    KualiDecimal monthlyTotal = getAccountingLineForValidation().getMonthlyLinesTotal();
    if (monthlyTotal.isNonZero() && monthlyTotal.compareTo(getAccountingLineForValidation().getCurrentBudgetAdjustmentAmount()) != 0) {
        GlobalVariables.getMessageMap().putError(OLEPropertyConstants.CURRENT_BUDGET_ADJUSTMENT_AMOUNT, OLEKeyConstants.ERROR_DOCUMENT_BA_MONTH_TOTAL_NOT_EQUAL_CURRENT);
        validMonthlyLines = false;
    }

    return validMonthlyLines;
}
 
开发者ID:VU-libtech,项目名称:OLE-INST,代码行数:18,代码来源:BudgetAdjustmentAccountingLineMonthlyLinesValidation.java

示例13: validate

import org.kuali.rice.core.api.util.type.KualiDecimal; //导入方法依赖的package包/类
/**
 * Generates the GLPEs for a given accounting document and checks that the debits total equals
 * the credits total.
 * <strong>Expects the document to be sent in as a property.</strong>
 * @see org.kuali.kfs.sys.document.validation.GenericValidation#validate(java.lang.Object[])
 */
public boolean validate(AttributedDocumentEvent event) {
    LOG.debug("Validation started");
    
    // generate GLPEs specifically here so that we can compare debits to credits
    if (!SpringContext.getBean(GeneralLedgerPendingEntryService.class).generateGeneralLedgerPendingEntries(accountingDocumentForValidation)) {
        throw new ValidationException("general ledger GLPE generation failed");
    }

    // now loop through all of the GLPEs and calculate buckets for debits and credits
    KualiDecimal creditAmount = KualiDecimal.ZERO;
    KualiDecimal debitAmount = KualiDecimal.ZERO;
    
    List<GeneralLedgerPendingEntry> pendingEntries = accountingDocumentForValidation.getGeneralLedgerPendingEntries();
    for(GeneralLedgerPendingEntry entry : pendingEntries) {
        if(entry.isTransactionEntryOffsetIndicator()) {
            continue;
        }
        
        if (KFSConstants.GL_CREDIT_CODE.equals(entry.getTransactionDebitCreditCode())) {
            creditAmount = creditAmount.add(entry.getTransactionLedgerEntryAmount());
        }
        else {
            debitAmount = debitAmount.add(entry.getTransactionLedgerEntryAmount());
        }           
    }
    
    boolean isValid = debitAmount.compareTo(creditAmount) == 0;

    if (!isValid) {
        GlobalVariables.getMessageMap().putError(KFSConstants.ACCOUNTING_LINE_ERRORS, KFSKeyConstants.ERROR_DOCUMENT_BALANCE);
    }
    
    return isValid;
}
 
开发者ID:kuali,项目名称:kfs,代码行数:41,代码来源:DebitsAndCreditsBalanceValidation.java

示例14: isAccountingLineTotalsMatch

import org.kuali.rice.core.api.util.type.KualiDecimal; //导入方法依赖的package包/类
/**
 * This method checks if the total sum amount of the source accounting line matches the total sum amount of the target
 * accounting line, return true if the totals match, false otherwise.
 * 
 * @param sourceLines
 * @param targetLines
 * @return
 */
public boolean isAccountingLineTotalsMatch(List sourceLines, List targetLines) {
    boolean isValid = true;

    AccountingLine line = null;

    // totals for the from and to lines.
    KualiDecimal sourceLinesAmount = KualiDecimal.ZERO;
    KualiDecimal targetLinesAmount = KualiDecimal.ZERO;

    // sum source lines
    for (Iterator i = sourceLines.iterator(); i.hasNext();) {
        line = (ExpenseTransferAccountingLine) i.next();
        sourceLinesAmount = sourceLinesAmount.add(line.getAmount());
    }

    // sum target lines
    for (Iterator i = targetLines.iterator(); i.hasNext();) {
        line = (ExpenseTransferAccountingLine) i.next();
        targetLinesAmount = targetLinesAmount.add(line.getAmount());
    }

    // if totals don't match, then add error message
    if (sourceLinesAmount.compareTo(targetLinesAmount) != 0) {
        isValid = false;
    }

    return isValid;
}
 
开发者ID:kuali,项目名称:kfs,代码行数:37,代码来源:LaborExpenseTransferAccountLineTotalsMatchValidation.java

示例15: getInternalPurchasingDollarLimit

import org.kuali.rice.core.api.util.type.KualiDecimal; //导入方法依赖的package包/类
/**
 * @see org.kuali.ole.module.purap.document.service.PurchaseOrderService#getInternalPurchasingDollarLimit(org.kuali.ole.module.purap.document.PurchaseOrderDocument)
 */
@Override
public KualiDecimal getInternalPurchasingDollarLimit(PurchaseOrderDocument document) {
    if ((document.getVendorContract() != null) && (document.getContractManager() != null)) {
        KualiDecimal contractDollarLimit = vendorService.getApoLimitFromContract(document.getVendorContract().getVendorContractGeneratedIdentifier(), document.getChartOfAccountsCode(), document.getOrganizationCode());
        // FIXME somehow data fields such as contractManagerDelegationDollarLimit in reference object contractManager didn't get
        // retrieved
        // (are null) as supposed to be (this happens whether or not proxy is set to true), even though contractManager is not
        // null;
        // so here we have to manually refresh the contractManager to retrieve the fields
        if (document.getContractManager().getContractManagerDelegationDollarLimit() == null) {
            document.refreshReferenceObject(PurapPropertyConstants.CONTRACT_MANAGER);
        }
        KualiDecimal contractManagerLimit = document.getContractManager().getContractManagerDelegationDollarLimit();
        if ((contractDollarLimit != null) && (contractManagerLimit != null)) {
            if (contractDollarLimit.compareTo(contractManagerLimit) > 0) {
                return contractDollarLimit;
            } else {
                return contractManagerLimit;
            }
        } else if (contractDollarLimit != null) {
            return contractDollarLimit;
        } else {
            return contractManagerLimit;
        }
    } else if ((document.getVendorContract() == null) && (document.getContractManager() != null)) {
        // FIXME As above, here we have to manually refresh the contractManager to retrieve its field
        if (document.getContractManager().getContractManagerDelegationDollarLimit() == null) {
            document.refreshReferenceObject(PurapPropertyConstants.CONTRACT_MANAGER);
        }
        return document.getContractManager().getContractManagerDelegationDollarLimit();
    } else if ((document.getVendorContract() != null) && (document.getContractManager() == null)) {
        return purapService.getApoLimit(document.getVendorContract().getVendorContractGeneratedIdentifier(), document.getChartOfAccountsCode(), document.getOrganizationCode());
    } else {
        String errorMsg = "No internal purchase order dollar limit found for purchase order '" + document.getPurapDocumentIdentifier() + "'.";
        LOG.warn(errorMsg);
        return null;
    }
}
 
开发者ID:VU-libtech,项目名称:OLE-INST,代码行数:42,代码来源:PurchaseOrderServiceImpl.java


注:本文中的org.kuali.rice.core.api.util.type.KualiDecimal.compareTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。