use of edu.cornell.kfs.module.purap.util.PurchasingFavoriteAccountLineBuilderForDistribution in project cu-kfs by CU-CommunityApps.
the class PurchasingActionBase method addFavoriteAccount.
/*
* KFSPTS-985 : add favorite account.
* This is a copy from requisitionaction. to be shared by both req & po
*/
public ActionForward addFavoriteAccount(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
PurchasingFormBase poForm = (PurchasingFormBase) form;
PurchasingDocumentBase document = (PurchasingDocumentBase) poForm.getDocument();
int itemIdx = getSelectedLine(request);
final int DISTRIBUTION_INDEX = -2;
PurchasingFavoriteAccountLineBuilderBase<? extends PurApAccountingLine> favoriteAccountBuilder;
// Initialize the correct builder based on whether the Favorite Account is for an item in the list or for account distribution.
if (itemIdx >= 0) {
PurchasingItemBase item = (PurchasingItemBase) document.getItem(itemIdx);
favoriteAccountBuilder = new PurchasingFavoriteAccountLineBuilderForLineItem<PurApAccountingLine>(item, itemIdx, poForm.setupNewPurchasingAccountingLine());
} else if (itemIdx == DISTRIBUTION_INDEX) {
favoriteAccountBuilder = new PurchasingFavoriteAccountLineBuilderForDistribution<PurApAccountingLine>(document, poForm.getAccountDistributionsourceAccountingLines(), poForm.setupNewAccountDistributionAccountingLine());
} else {
return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
// Add a new Favorite-Account-derived accounting line to the list, with errors inserted into the message map as appropriate.
favoriteAccountBuilder.addNewFavoriteAccountLineToListIfPossible();
return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
Aggregations