org.kuali.kfs.fp.document.web.struts
Class VoucherForm

java.lang.Object
  extended by org.apache.struts.action.ActionForm
      extended by org.kuali.rice.kns.web.struts.pojo.PojoFormBase
          extended by org.kuali.rice.kns.web.struts.form.KualiForm
              extended by org.kuali.rice.kns.web.struts.form.KualiDocumentFormBase
                  extended by org.kuali.rice.kns.web.struts.form.KualiTransactionalDocumentFormBase
                      extended by org.kuali.kfs.sys.document.web.struts.FinancialSystemTransactionalDocumentFormBase
                          extended by org.kuali.kfs.sys.web.struts.KualiAccountingDocumentFormBase
                              extended by org.kuali.kfs.fp.document.web.struts.VoucherForm
All Implemented Interfaces:
Serializable, org.kuali.rice.kns.web.struts.pojo.PojoForm
Direct Known Subclasses:
AuxiliaryVoucherForm, JournalVoucherForm

public class VoucherForm
extends KualiAccountingDocumentFormBase

This class is the Struts specific form object that works in conjunction with the pojo utilities to build the UI for Voucher Document instances. This class is unique in that it leverages a helper data structure called the VoucherAccountingLineHelper because Voucher documents, under some/none conditions, presents the user with a debit and credit column for amount entry. New accounting lines use specific credit and debit amount fields b/c the new line is explicitly known; however, already existing accounting lines need to exist within a list with ordering that matches the accounting lines source list.

See Also:
Serialized Form

Field Summary
protected  List accountingPeriods
           
protected  org.kuali.rice.kns.util.KualiDecimal newSourceLineCredit
           
protected  org.kuali.rice.kns.util.KualiDecimal newSourceLineDebit
           
protected  String selectedAccountingPeriod
           
protected  List voucherLineHelpers
           
 
Fields inherited from class org.kuali.kfs.sys.web.struts.KualiAccountingDocumentFormBase
editableAccounts, forcedLookupOptionalFields, hideDetails, LOG, newSourceLine, newTargetLine, sourceFile, targetFile
 
Fields inherited from class org.kuali.rice.kns.web.struts.form.KualiTransactionalDocumentFormBase
forcedReadOnlyFields
 
Fields inherited from class org.kuali.rice.kns.web.struts.form.KualiDocumentFormBase
adHocActionRequestCodes, attachmentFile, documentActions, editingMode, suppressAllButtons
 
Fields inherited from class org.kuali.rice.kns.web.struts.form.KualiForm
extraButtons
 
Fields inherited from class org.kuali.rice.kns.web.struts.pojo.PojoFormBase
requiredNonEditableProperties
 
Fields inherited from class org.apache.struts.action.ActionForm
multipartRequestHandler, servlet
 
Constructor Summary
VoucherForm()
          Supplements a constructor for this voucher class
 
Method Summary
 AccountingPeriod getAccountingPeriod()
           
 List getAccountingPeriods()
          This method retrieves the list of valid accounting periods to display.
 String getCurrencyFormattedCreditTotal()
          This method retrieves the voucher's credit total formatted as currency.
 String getCurrencyFormattedDebitTotal()
          This method retrieves the voucher's debit total formatted as currency.
 String getCurrencyFormattedTotal()
          This method retrieves the voucher's total formatted as currency.
 String getFormattedReversalDate()
          This method returns the reversal date in the format MMM d, yyyy.
 org.kuali.rice.kns.util.KualiDecimal getNewSourceLineCredit()
          This method retrieves the credit amount of the new accounting line that was added.
 org.kuali.rice.kns.util.KualiDecimal getNewSourceLineDebit()
          This method retrieves the debit amount of the new accounting line that was added.
 String getSelectedAccountingPeriod()
          This method retrieves the selectedAccountingPeriod.
protected  String getSelectedPostingPeriodCode()
          util method to get posting period code out of selectedAccountingPeriod
protected  Integer getSelectedPostingYear()
          util method to get postingYear out of selectedAccountingPeriod
 VoucherDocument getVoucherDocument()
          Helper method to make casting easier
 VoucherAccountingLineHelper getVoucherLineHelper(int index)
          This method retrieves the proper voucher helper line data structure at the passed in list index so that it matches up with the correct accounting line at that index.
 List getVoucherLineHelpers()
          Accessor to the list of VoucherAccountingLineHelper instances.
 void populate(javax.servlet.http.HttpServletRequest request)
          Overrides the parent to call super.populate and then to call the two methods that are specific to loading the two select lists on the page.
 void populateAccountingPeriodListForRendering()
          This method retrieves all of the "open for posting" accounting periods and prepares them to be rendered in a dropdown UI component.
protected  void populateCreditAndDebitAmounts()
          If the balance type is an offset generation balance type, then the user is able to enter the amount as either a debit or a credit, otherwise, they only need to deal with the amount field in this case we always need to update the underlying bo so that the debit/credit code along with the amount, is properly set.
 void populateDefaultSelectedAccountingPeriod()
          sets initial selected accounting period to current period
protected  void populateSelectedVoucherAccountingPeriod()
          This method parses the accounting period value from the form and builds a basic AccountingPeriod object so that the voucher is properly persisted with the accounting period set for it.
 void populateSourceAccountingLine(SourceAccountingLine sourceLine, String accountingLinePropertyName, Map parameterMap)
          Override the parent, to push the chosen accounting period and balance type down into the source accounting line object.
protected  boolean processDebitAndCreditForAllSourceLines()
          This method iterates through all of the source accounting lines associated with the voucher doc and accounts for any changes to the credit and debit amounts, populate the source lines' amount and debit/credit code fields appropriately, so that they can be persisted accurately.
protected  boolean processDebitAndCreditForNewSourceLine()
          This method uses the newly entered debit and credit amounts to populate the new source line that is to be added to the voucher document.
protected  boolean processDebitAndCreditForSourceLine(SourceAccountingLine sourceLine, org.kuali.rice.kns.util.KualiDecimal debitAmount, org.kuali.rice.kns.util.KualiDecimal creditAmount, int index)
          This method checks the debit and credit attributes passed in, figures out which one has a value, and sets the source accounting line's amount and debit/credit attribute appropriately.
 void setAccountingPeriods(List accountingPeriods)
          This method sets the list of valid accounting periods to display.
 void setNewSourceLineCredit(org.kuali.rice.kns.util.KualiDecimal newSourceLineCredit)
          This method sets the credit amount of the new accounting line that was added.
 void setNewSourceLineDebit(org.kuali.rice.kns.util.KualiDecimal newSourceLineDebit)
          This method sets the debit amount of the new accounting line that was added.
 void setSelectedAccountingPeriod(String selectedAccountingPeriod)
          This method sets the selectedAccountingPeriod.
 void setVoucherLineHelpers(List voucherLineHelpers)
          This method sets the list of helper lines for the form.
protected  boolean validateCreditAndDebitAmounts(org.kuali.rice.kns.util.KualiDecimal debitAmount, org.kuali.rice.kns.util.KualiDecimal creditAmount, int index)
          This method checks to make sure that there isn't a value in both the credit and debit columns for a given accounting line.
 
Methods inherited from class org.kuali.kfs.sys.web.struts.KualiAccountingDocumentFormBase
createNewSourceAccountingLine, createNewTargetAccountingLine, customInitMaxUploadSizes, getAccountingLineImportInstructionsUrl, getCurrencyFormattedSourceTotal, getCurrencyFormattedTargetTotal, getEditableAccounts, getExcludedmethodToCall, getFinancialDocument, getForcedLookupOptionalFields, getHideDetails, getNewSourceLine, getNewTargetLine, getSourceFile, getTargetFile, harvestAccountingLines, isHideDetails, populateAccountingLine, populateAccountingLines, populateAccountingLinesForResponse, populateTargetAccountingLine, repopulateOverrides, setEditableAccounts, setForcedLookupOptionalFields, setHideDetails, setNewSourceLine, setNewTargetLine, setSourceFile, setTargetFile, shouldMethodToCallParameterBeUsed
 
Methods inherited from class org.kuali.kfs.sys.document.web.struts.FinancialSystemTransactionalDocumentFormBase
extendDocInfoToThreeColumns, generateErrorCorrectionButton, getExtraButtons, populateHeaderFields
 
Methods inherited from class org.kuali.rice.kns.web.struts.form.KualiTransactionalDocumentFormBase
discoverDocumentTypeName, formatReversalDate, getForcedReadOnlyFields, getTransactionalDocument, instantiateTransactionalDocumentByDocumentTypeName, populateEmptyMultiSelect, populateFalseCheckboxes, populationSpecialEmptyFields, setForcedReadOnlyFields
 
Methods inherited from class org.kuali.rice.kns.web.struts.form.KualiDocumentFormBase
addRequiredNonEditableProperties, buildHtmlLink, getAdditionalScriptFile, getAdditionalScriptFiles, getAdHocActionRequestCodes, getAdHocRoutePerson, getAdHocRoutePersons, getAdHocRouteWorkgroup, getAdHocRouteWorkgroups, getAnnotation, getAttachmentFile, getBoNotes, getCommand, getDefaultDocumentTypeName, getDocId, getDocNum, getDocTypeName, getDocument, getDocumentActions, getDocumentHandlerUrl, getEditingMode, getErrorMapFromPreviousRequest, getFormKey, getInitiator, getInitiatorNetworkId, getMessageMapFromPreviousRequest, getNewAdHocRoutePerson, getNewAdHocRouteWorkgroup, getNewNote, getPersonInquiryUrlLink, getStandardHeaderFields, getWorkflowDocument, hasDocumentId, initializeHeaderNavigationTabs, instantiateDocument, isDocumentEnRoute, isFormDocumentInitialized, isHasWorkflowDocument, isReturnToActionList, isSuppressAllButtons, isUserDocumentInitiator, reset, setAdditionalScriptFile, setAdditionalScriptFiles, setAdHocActionRequestCodes, setAdHocRoutePersons, setAdHocRouteWorkgroups, setAnnotation, setAttachmentFile, setBoNotes, setCommand, setDerivedValuesOnForm, setDocId, setDocNum, setDocTypeName, setDocument, setDocumentActions, setEditingMode, setErrorMapFromPreviousRequest, setFormKey, setMessageMapFromPreviousRequest, setNewAdHocRoutePerson, setNewAdHocRouteWorkgroup, setNewNote, setReturnToActionList, setSuppressAllButtons, shouldPropertyBePopulatedInForm, validate
 
Methods inherited from class org.kuali.rice.kns.web.struts.form.KualiForm
clearEditablePropertyInformation, getActionFormUtilMap, getAnchor, getBackLocation, getCurrentTabIndex, getDisplayedErrors, getDisplayedInfo, getDisplayedWarnings, getDocInfo, getExtraButton, getFieldNameToFocusOnAfterSubmit, getHeaderNavigationTabs, getMethodToCall, getNavigationCss, getNextArbitrarilyHighIndex, getNumColumns, getRefreshCaller, getTabState, getTabStates, incrementTabIndex, isFieldLevelHelpEnabled, populateBackLocation, populateFieldLevelHelpEnabled, reset, retrieveFormValueForLookupInquiryParameters, setActionFormUtilMap, setAnchor, setBackLocation, setCurrentTabIndex, setDocInfo, setExtraButton, setExtraButtons, setFieldLevelHelpEnabled, setFieldNameToFocusOnAfterSubmit, setHeaderNavigationTabs, setMethodToCall, setNavigationCss, setNumColumns, setRefreshCaller, setTabStates
 
Methods inherited from class org.kuali.rice.kns.web.struts.pojo.PojoFormBase
addMaxUploadSize, cacheUnconvertedValue, copyPopulateEditablePropertiesToActionEditableProperties, formatterClassForKeypath, formatValue, getActionEditablePropertiesGuid, getEditableProperties, getFormatter, getFormatterTypes, getIsNewForm, getMaxUploadSizes, getMethodToCallsToBypassSessionRetrievalForGETRequests, getParameter, getParameterValues, getPopulateEditableProperties, getPopulateEditablePropertiesGuid, getPropertyType, getRequiredNonEditableProperties, getStrutsActionMappingScope, getUnconvertedValues, getUnknownKeys, initMaxUploadSizes, isPropertyEditable, isPropertyNonEditableButRequired, populateForProperty, postprocessRequestParameters, processValidationFail, registerEditableProperty, registerIsNewForm, registerRequiredNonEditableProperty, registerStrutsActionMappingScope, setActionEditablePropertiesGuid, setFormatterType, setFormatterTypes, setPopulateEditablePropertiesGuid, setUnconvertedValues
 
Methods inherited from class org.apache.struts.action.ActionForm
getMultipartRequestHandler, getServlet, getServletWrapper, setMultipartRequestHandler, setServlet, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

accountingPeriods

protected List accountingPeriods

newSourceLineDebit

protected org.kuali.rice.kns.util.KualiDecimal newSourceLineDebit

newSourceLineCredit

protected org.kuali.rice.kns.util.KualiDecimal newSourceLineCredit

voucherLineHelpers

protected List voucherLineHelpers

selectedAccountingPeriod

protected String selectedAccountingPeriod
Constructor Detail

VoucherForm

public VoucherForm()
Supplements a constructor for this voucher class

Method Detail

populateDefaultSelectedAccountingPeriod

public void populateDefaultSelectedAccountingPeriod()
sets initial selected accounting period to current period


populate

public void populate(javax.servlet.http.HttpServletRequest request)
Overrides the parent to call super.populate and then to call the two methods that are specific to loading the two select lists on the page. In addition, this also makes sure that the credit and debit amounts are filled in for situations where validation errors occur and the page reposts.

Specified by:
populate in interface org.kuali.rice.kns.web.struts.pojo.PojoForm
Overrides:
populate in class KualiAccountingDocumentFormBase
See Also:
PojoForm.populate(javax.servlet.http.HttpServletRequest)

getSelectedPostingYear

protected Integer getSelectedPostingYear()
util method to get postingYear out of selectedAccountingPeriod

Returns:
Integer

getSelectedPostingPeriodCode

protected String getSelectedPostingPeriodCode()
util method to get posting period code out of selectedAccountingPeriod

Returns:
String

getVoucherDocument

public VoucherDocument getVoucherDocument()
Helper method to make casting easier

Returns:
VoucherDocument

populateSourceAccountingLine

public void populateSourceAccountingLine(SourceAccountingLine sourceLine,
                                         String accountingLinePropertyName,
                                         Map parameterMap)
Override the parent, to push the chosen accounting period and balance type down into the source accounting line object. In addition, check the balance type to see if it's the "External Encumbrance" balance and alter the encumbrance update code on the accounting line appropriately.

Overrides:
populateSourceAccountingLine in class KualiAccountingDocumentFormBase
accountingLinePropertyName - the property path from the form to the accounting line
parameterMap - the map of parameters that were sent in with the request
See Also:
org.kuali.rice.kns.web.struts.form.KualiTransactionalDocumentFormBase#populateSourceAccountingLine(org.kuali.rice.kns.bo.SourceAccountingLine)

getAccountingPeriods

public List getAccountingPeriods()
This method retrieves the list of valid accounting periods to display.

Returns:
List

setAccountingPeriods

public void setAccountingPeriods(List accountingPeriods)
This method sets the list of valid accounting periods to display.

Parameters:
accountingPeriods -

getFormattedReversalDate

public String getFormattedReversalDate()
This method returns the reversal date in the format MMM d, yyyy.

Returns:
String

getSelectedAccountingPeriod

public String getSelectedAccountingPeriod()
This method retrieves the selectedAccountingPeriod.

Returns:
String

getAccountingPeriod

public AccountingPeriod getAccountingPeriod()
Returns:
AccountingPeriod associated with the currently selected period

setSelectedAccountingPeriod

public void setSelectedAccountingPeriod(String selectedAccountingPeriod)
This method sets the selectedAccountingPeriod.

Parameters:
selectedAccountingPeriod -

getVoucherLineHelpers

public List getVoucherLineHelpers()
Accessor to the list of VoucherAccountingLineHelper instances. This method retrieves the list of helper line objects for the form.

Returns:
List

getVoucherLineHelper

public VoucherAccountingLineHelper getVoucherLineHelper(int index)
This method retrieves the proper voucher helper line data structure at the passed in list index so that it matches up with the correct accounting line at that index.

Parameters:
index -
Returns:
VoucherAccountingLineHelper

setVoucherLineHelpers

public void setVoucherLineHelpers(List voucherLineHelpers)
This method sets the list of helper lines for the form.

Parameters:
voucherLineHelpers -

getNewSourceLineCredit

public org.kuali.rice.kns.util.KualiDecimal getNewSourceLineCredit()
This method retrieves the credit amount of the new accounting line that was added.

Returns:
KualiDecimal

setNewSourceLineCredit

public void setNewSourceLineCredit(org.kuali.rice.kns.util.KualiDecimal newSourceLineCredit)
This method sets the credit amount of the new accounting line that was added.

Parameters:
newSourceLineCredit -

getNewSourceLineDebit

public org.kuali.rice.kns.util.KualiDecimal getNewSourceLineDebit()
This method retrieves the debit amount of the new accounting line that was added.

Returns:
KualiDecimal

setNewSourceLineDebit

public void setNewSourceLineDebit(org.kuali.rice.kns.util.KualiDecimal newSourceLineDebit)
This method sets the debit amount of the new accounting line that was added.

Parameters:
newSourceLineDebit -

getCurrencyFormattedDebitTotal

public String getCurrencyFormattedDebitTotal()
This method retrieves the voucher's debit total formatted as currency.

Returns:
String

getCurrencyFormattedCreditTotal

public String getCurrencyFormattedCreditTotal()
This method retrieves the voucher's credit total formatted as currency.

Returns:
String

getCurrencyFormattedTotal

public String getCurrencyFormattedTotal()
This method retrieves the voucher's total formatted as currency.

Returns:
String

populateAccountingPeriodListForRendering

public void populateAccountingPeriodListForRendering()
This method retrieves all of the "open for posting" accounting periods and prepares them to be rendered in a dropdown UI component.


populateSelectedVoucherAccountingPeriod

protected void populateSelectedVoucherAccountingPeriod()
This method parses the accounting period value from the form and builds a basic AccountingPeriod object so that the voucher is properly persisted with the accounting period set for it.


populateCreditAndDebitAmounts

protected void populateCreditAndDebitAmounts()
If the balance type is an offset generation balance type, then the user is able to enter the amount as either a debit or a credit, otherwise, they only need to deal with the amount field in this case we always need to update the underlying bo so that the debit/credit code along with the amount, is properly set.


processDebitAndCreditForNewSourceLine

protected boolean processDebitAndCreditForNewSourceLine()
This method uses the newly entered debit and credit amounts to populate the new source line that is to be added to the voucher document.

Returns:
boolean True if the processing was successful, false otherwise.

processDebitAndCreditForAllSourceLines

protected boolean processDebitAndCreditForAllSourceLines()
This method iterates through all of the source accounting lines associated with the voucher doc and accounts for any changes to the credit and debit amounts, populate the source lines' amount and debit/credit code fields appropriately, so that they can be persisted accurately. This accounts for the fact that users may change the amounts and/or flip-flop the credit debit amounts on any accounting line after the initial add of the accounting line.

Returns:
boolean

processDebitAndCreditForSourceLine

protected boolean processDebitAndCreditForSourceLine(SourceAccountingLine sourceLine,
                                                     org.kuali.rice.kns.util.KualiDecimal debitAmount,
                                                     org.kuali.rice.kns.util.KualiDecimal creditAmount,
                                                     int index)
This method checks the debit and credit attributes passed in, figures out which one has a value, and sets the source accounting line's amount and debit/credit attribute appropriately. It assumes that if it finds something in the debit field, it's a debit entry, otherwise it's a credit entry. If a user enters a value into both fields, it will assume the debit value, then when the br eval framework applies the "add" rule, it will bomb out. If first checks to make sure that there isn't a value in both the credit and debit columns.

Parameters:
sourceLine -
debitAmount -
creditAmount -
index - if -1, then its a new line, if not -1 then it's an existing line
Returns:
boolean True if the processing was successful, false otherwise.

validateCreditAndDebitAmounts

protected boolean validateCreditAndDebitAmounts(org.kuali.rice.kns.util.KualiDecimal debitAmount,
                                                org.kuali.rice.kns.util.KualiDecimal creditAmount,
                                                int index)
This method checks to make sure that there isn't a value in both the credit and debit columns for a given accounting line.

Parameters:
creditAmount -
debitAmount -
index - if -1, it's a new line, if not -1, then its an existing line
Returns:
boolean False if both the credit and debit fields have a value, true otherwise.


Copyright © 2005-2012 The Kuali Foundation. All Rights Reserved.