本文整理汇总了Java中org.kuali.rice.core.api.util.type.KualiDecimal.divide方法的典型用法代码示例。如果您正苦于以下问题:Java KualiDecimal.divide方法的具体用法?Java KualiDecimal.divide怎么用?Java KualiDecimal.divide使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.kuali.rice.core.api.util.type.KualiDecimal
的用法示例。
在下文中一共展示了KualiDecimal.divide方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPretaxAmount
import org.kuali.rice.core.api.util.type.KualiDecimal; //导入方法依赖的package包/类
/**
* This method returns a preTax amount
*
* @param dateOfTransaction
* @param postalCode
* @param amountWithTax
* @return
*/
@Override
public KualiDecimal getPretaxAmount(Date dateOfTransaction, String postalCode, KualiDecimal amountWithTax) {
BigDecimal totalTaxRate = BigDecimal.ZERO;
// there is not tax amount
if (StringUtils.isEmpty(postalCode))
return amountWithTax;
// strip digits from the postal code before passing it to the sales tax regions
// if the parameters indicate to do so.
postalCode = truncatePostalCodeForSalesTaxRegionService(postalCode);
List<TaxRegion> salesTaxRegions = taxRegionService.getSalesTaxRegions(postalCode);
if (salesTaxRegions.size() == 0)
return amountWithTax;
for (TaxRegion taxRegion : salesTaxRegions) {
if (ObjectUtils.isNotNull((taxRegion.getEffectiveTaxRegionRate(dateOfTransaction))))
totalTaxRate = totalTaxRate.add(taxRegion.getEffectiveTaxRegionRate(dateOfTransaction).getTaxRate());
}
KualiDecimal divisor = new KualiDecimal(totalTaxRate.add(BigDecimal.ONE));
KualiDecimal pretaxAmount = amountWithTax.divide(divisor);
return pretaxAmount;
}
示例2: 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);
}
}
}
示例3: redistributeEqualAmounts
import org.kuali.rice.core.api.util.type.KualiDecimal; //导入方法依赖的package包/类
/**
* redistributes the amounts to the capital asset and its related group accounting lines.
* Adjusts any variance to the last capital asset accounting line.
*
* @param selectedCapitalAccountingLines
* @param capitalAsset
* @param amount
* @param totalQuantity
*/
protected void redistributeEqualAmounts(List<CapitalAccountingLines> selectedCapitalAccountingLines, CapitalAssetInformation capitalAsset, KualiDecimal amount, int totalQuantity) {
int assetQuantity = 0;
KualiDecimal totalCapitalAssetQuantity = new KualiDecimal(totalQuantity);
if (ObjectUtils.isNotNull(capitalAsset.getCapitalAssetQuantity())) {
assetQuantity = capitalAsset.getCapitalAssetQuantity();
}
capitalAsset.setCapitalAssetLineAmount(capitalAsset.getCapitalAssetLineAmount().add(amount.multiply(new KualiDecimal(assetQuantity))));
int lastAccountIndex = 0;
KualiDecimal appliedAccountingLinesTotal = KualiDecimal.ZERO;
CapitalAssetAccountsGroupDetails lastLine = new CapitalAssetAccountsGroupDetails();
List<CapitalAssetAccountsGroupDetails> groupAccountLines = capitalAsset.getCapitalAssetAccountsGroupDetails();
for (CapitalAssetAccountsGroupDetails groupAccountLine : groupAccountLines) {
KualiDecimal capitalAccountingLineAmount = getCapitalAssetAccountLineAmount(selectedCapitalAccountingLines, groupAccountLine, capitalAsset);
KualiDecimal calculatedLineAmount = capitalAccountingLineAmount.divide(totalCapitalAssetQuantity, true);
groupAccountLine.setAmount(calculatedLineAmount.multiply(new KualiDecimal(assetQuantity)));
appliedAccountingLinesTotal = appliedAccountingLinesTotal.add(groupAccountLine.getAmount());
lastAccountIndex++;
lastLine = groupAccountLine;
}
//apply any variance left to the last
KualiDecimal varianceForLines = capitalAsset.getCapitalAssetLineAmount().subtract(appliedAccountingLinesTotal);
if (varianceForLines.isNonZero()) {
lastLine.setAmount(lastLine.getAmount().add(varianceForLines));
}
}
示例4: redistributeEqualAmountsForAccountingLineForCreateAssets
import org.kuali.rice.core.api.util.type.KualiDecimal; //导入方法依赖的package包/类
/**
*
* @param capitalAccountingLines
* @param capitalAssetInformation
* @param remainingAmountToDistribute
*/
protected void redistributeEqualAmountsForAccountingLineForCreateAssets(List<CapitalAccountingLines> selectedCapitalAccountingLines, List<CapitalAssetInformation> capitalAssetInformation, KualiDecimal remainingAmountToDistribute) {
//get the total capital assets quantity
int totalQuantity = getTotalQuantityOfCreateAssets(selectedCapitalAccountingLines, capitalAssetInformation);
if (totalQuantity > 0) {
KualiDecimal equalCreateAssetAmount = remainingAmountToDistribute.divide(new KualiDecimal(totalQuantity), true);
int lastAssetIndex = 0;
CapitalAssetInformation lastCapitalAsset = new CapitalAssetInformation();
if (equalCreateAssetAmount.compareTo(KualiDecimal.ZERO) != 0) {
for (CapitalAssetInformation capitalAsset : capitalAssetInformation) {
if (OLEConstants.CapitalAssets.CAPITAL_ASSET_CREATE_ACTION_INDICATOR.equals(capitalAsset.getCapitalAssetActionIndicator()) &&
(OLEConstants.CapitalAssets.DISTRIBUTE_COST_EQUALLY_CODE.equalsIgnoreCase(capitalAsset.getDistributionAmountCode()))) {
if (capitalAssetExists(selectedCapitalAccountingLines, capitalAsset, OLEConstants.CapitalAssets.CAPITAL_ASSET_CREATE_ACTION_INDICATOR)) {
redistributeEqualAmounts(selectedCapitalAccountingLines, capitalAsset, equalCreateAssetAmount, totalQuantity);
if (ObjectUtils.isNotNull(capitalAsset.getCapitalAssetQuantity())) {
lastAssetIndex = lastAssetIndex + capitalAsset.getCapitalAssetQuantity();
}
//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(equalCreateAssetAmount.multiply(new KualiDecimal(lastAssetIndex)));
if (varianceForAssets.isNonZero()) {
lastCapitalAsset.setCapitalAssetLineAmount(lastCapitalAsset.getCapitalAssetLineAmount().add(varianceForAssets));
redistributeEqualAmountsOnLastCapitalAsset(selectedCapitalAccountingLines, lastCapitalAsset, capitalAssetInformation, OLEConstants.CapitalAssets.CAPITAL_ASSET_CREATE_ACTION_INDICATOR);
}
}
}
示例5: setMealsAndIncidentals
import org.kuali.rice.core.api.util.type.KualiDecimal; //导入方法依赖的package包/类
/**
*
* This method split mealsAndIncidentals into breakfast, lunch, dinner and incidentals (overriding the existing breakfast, lunch, dinner and incidentals values).
* @param mealsAndIncidentals
*/
public void setMealsAndIncidentals(KualiDecimal mealsAndIncidentals) {
KualiDecimal meal = mealsAndIncidentals.divide(new KualiDecimal(4));
setBreakfastValue(meal);
setLunchValue(meal);
setDinnerValue(meal);
setIncidentalsValue(mealsAndIncidentals.subtract(getMealsTotal()));
}
示例6: getPretaxAmount
import org.kuali.rice.core.api.util.type.KualiDecimal; //导入方法依赖的package包/类
/**
* This method returns a preTax amount
*
* @param dateOfTransaction
* @param postalCode
* @param amountWithTax
* @return
*/
@Override
public KualiDecimal getPretaxAmount(Date dateOfTransaction, String postalCode, KualiDecimal amountWithTax) {
BigDecimal totalTaxRate = BigDecimal.ZERO;
// there is not tax amount
if (StringUtils.isEmpty(postalCode))
return amountWithTax;
// strip digits from the postal code before passing it to the sales tax regions
// if the parameters indicate to do so.
postalCode = truncatePostalCodeForSalesTaxRegionService(postalCode);
List<TaxRegion> salesTaxRegions = taxRegionService.getSalesTaxRegions(postalCode);
if (salesTaxRegions.size() == 0)
return amountWithTax;
for (TaxRegion taxRegion : salesTaxRegions) {
if (ObjectUtils.isNotNull((taxRegion.getEffectiveTaxRegionRate(dateOfTransaction))))
totalTaxRate = totalTaxRate.add(taxRegion.getEffectiveTaxRegionRate(dateOfTransaction).getTaxRate());
}
KualiDecimal divisor = new KualiDecimal(totalTaxRate.add(BigDecimal.ONE));
KualiDecimal pretaxAmount = amountWithTax.divide(divisor);
return pretaxAmount;
}
示例7: 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);
}
}
}
示例8: redistributeEqualAmountsForAccountingLineForCreateAssets
import org.kuali.rice.core.api.util.type.KualiDecimal; //导入方法依赖的package包/类
/**
*
* @param capitalAccountingLines
* @param capitalAssetInformation
* @param remainingAmountToDistribute
*/
protected void redistributeEqualAmountsForAccountingLineForCreateAssets(List<CapitalAccountingLines> selectedCapitalAccountingLines, List<CapitalAssetInformation> capitalAssetInformation, KualiDecimal remainingAmountToDistribute) {
//get the total capital assets quantity
int totalQuantity = getTotalQuantityOfCreateAssets(selectedCapitalAccountingLines, capitalAssetInformation);
if (totalQuantity > 0) {
KualiDecimal equalCreateAssetAmount = remainingAmountToDistribute.divide(new KualiDecimal(totalQuantity), true);
int lastAssetIndex = 0;
CapitalAssetInformation lastCapitalAsset = new CapitalAssetInformation();
if (equalCreateAssetAmount.compareTo(KualiDecimal.ZERO) != 0) {
for (CapitalAssetInformation capitalAsset : capitalAssetInformation) {
if (KFSConstants.CapitalAssets.CAPITAL_ASSET_CREATE_ACTION_INDICATOR.equals(capitalAsset.getCapitalAssetActionIndicator()) &&
(KFSConstants.CapitalAssets.DISTRIBUTE_COST_EQUALLY_CODE.equalsIgnoreCase(capitalAsset.getDistributionAmountCode()))) {
if (capitalAssetExists(selectedCapitalAccountingLines, capitalAsset, KFSConstants.CapitalAssets.CAPITAL_ASSET_CREATE_ACTION_INDICATOR)) {
redistributeEqualAmounts(selectedCapitalAccountingLines, capitalAsset, equalCreateAssetAmount, totalQuantity);
if (ObjectUtils.isNotNull(capitalAsset.getCapitalAssetQuantity())) {
lastAssetIndex = lastAssetIndex + capitalAsset.getCapitalAssetQuantity();
}
//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(equalCreateAssetAmount.multiply(new KualiDecimal(lastAssetIndex)));
if (varianceForAssets.isNonZero()) {
lastCapitalAsset.setCapitalAssetLineAmount(lastCapitalAsset.getCapitalAssetLineAmount().add(varianceForAssets));
redistributeEqualAmountsOnLastCapitalAsset(selectedCapitalAccountingLines, lastCapitalAsset, capitalAssetInformation, KFSConstants.CapitalAssets.CAPITAL_ASSET_CREATE_ACTION_INDICATOR);
}
}
}
示例9: precalculate
import org.kuali.rice.core.api.util.type.KualiDecimal; //导入方法依赖的package包/类
/**
* Do the calculation.
*/
private void precalculate() {
distributionResult = new HashMap<String, Map<AssetPaymentAssetDetail, KualiDecimal>>();
KualiDecimal total = ZERO;
KualiDecimal distributionAmount = ZERO;
int size = doc.getAssetPaymentAssetDetail().size();
KualiDecimal assetDetailSize = new KualiDecimal(size);
if (assetDetailSize.isNonZero()) {
for (AssetPaymentDetail sourceLine : getAssetPaymentDetailLines()) {
total = sourceLine.getAmount();
distributionAmount = total.divide(assetDetailSize);
Map<AssetPaymentAssetDetail, KualiDecimal> assetDetailMap = new HashMap<AssetPaymentAssetDetail, KualiDecimal>();
for (int i = 0; i < size; i++) {
AssetPaymentAssetDetail assetDetail = doc.getAssetPaymentAssetDetail().get(i);
if (i < size - 1) {
assetDetailMap.put(assetDetail, distributionAmount);
total = total.subtract(distributionAmount);
} else {
assetDetailMap.put(assetDetail, total);
}
}
distributionResult.put(sourceLine.getAssetPaymentDetailKey(), assetDetailMap);
}
}
}
示例10: 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;
}
示例11: 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;
}
示例12: testApprove_updateAccessibleAccount
import org.kuali.rice.core.api.util.type.KualiDecimal; //导入方法依赖的package包/类
@AnnotationTestSuite(CrossSectionSuite.class)
@ConfigureContext(session = khuntley, shouldCommitTransactions = true)
public final void testApprove_updateAccessibleAccount() throws Exception {
// switch user to WESPRICE, build and route document with
// accountingLines
AccountingDocument retrieved;
AccountingDocument original;
String docId;
changeCurrentUser(getInitialUserName());
original = buildDocument();
routeDocument(original, SpringContext.getBean(DocumentService.class));
docId = original.getDocumentNumber();
// switch user to RORENFRO, update sourceAccountingLine for accounts
// controlled by this user
// (and delete update targetAccountingLine, for balance)
changeCurrentUser(getTestUserName());
retrieved = (AccountingDocument) SpringContext.getBean(DocumentService.class).getByDocumentHeaderId(docId);
// make sure totals don't change
KualiDecimal originalSourceLineAmt = retrieved.getSourceAccountingLine(0).getAmount();
KualiDecimal originalTargetLineAmt = retrieved.getTargetAccountingLine(0).getAmount();
KualiDecimal newSourceLineAmt = originalSourceLineAmt.divide(new KualiDecimal(2));
KualiDecimal newTargetLineAmt = originalTargetLineAmt.divide(new KualiDecimal(2));
// update existing lines with new amount which equals orig divided by 2
updateSourceAccountingLine(retrieved, 0, newSourceLineAmt.toString());
updateTargetAccountingLine(retrieved, 0, newTargetLineAmt.toString());
// add in new lines and change amounts
TargetAccountingLine newTargetLine = getTargetAccountingLineAccessibleAccount();
newTargetLine.setAmount(newTargetLineAmt);
SourceAccountingLine newSourceLine = getSourceAccountingLineAccessibleAccount();
newSourceLine.setAmount(newSourceLineAmt);
retrieved.addTargetAccountingLine(newTargetLine);
retrieved.addSourceAccountingLine(newSourceLine);
try {
approveDocument(retrieved, SpringContext.getBean(DocumentService.class));
}
catch (DocumentAuthorizationException dae) {
// this means that the workflow status didn't change in time for the check, so this is
// an expected exception
} catch ( ValidationException ex ) {
fail( "Business Rules Failed: " + dumpMessageMapErrors() );
}
}