use of org.kuali.kfs.sys.document.AccountingDocument in project cu-kfs by CU-CommunityApps.
the class KualiAccountingDocumentActionBase method execute.
/**
* Adds check for accountingLine updates, generates and dispatches any events caused by such updates
*
* @see org.apache.struts.action.Action#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm,
* javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
KualiAccountingDocumentFormBase transForm = (KualiAccountingDocumentFormBase) form;
// handle changes to accountingLines
if (transForm.hasDocumentId()) {
AccountingDocument financialDocument = (AccountingDocument) transForm.getDocument();
processAccountingLines(financialDocument, transForm, KFSConstants.SOURCE);
processAccountingLines(financialDocument, transForm, KFSConstants.TARGET);
}
// This is after a potential handleUpdate(), to display automatically cleared overrides following a route or save.
processAccountingLineOverrides(transForm);
// proceed as usual
ActionForward result = super.execute(mapping, form, request, response);
return result;
}
use of org.kuali.kfs.sys.document.AccountingDocument in project cu-kfs by CU-CommunityApps.
the class KualiAccountingDocumentActionBase method deleteTargetLine.
/**
* This method will remove a TargetAccountingLine from a FinancialDocument. This assumes that the user presses the delete button
* for a specific accounting line on the document and that the document is represented by a FinancialDocumentFormBase.
*
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
* @throws Exception
*/
public ActionForward deleteTargetLine(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
KualiAccountingDocumentFormBase financialDocumentForm = (KualiAccountingDocumentFormBase) form;
int deleteIndex = getLineToDelete(request);
String errorPath = KFSConstants.DOCUMENT_PROPERTY_NAME + "." + KFSConstants.EXISTING_TARGET_ACCT_LINE_PROPERTY_NAME + "[" + deleteIndex + "]";
boolean rulePassed = SpringContext.getBean(KualiRuleService.class).applyRules(new DeleteAccountingLineEvent(errorPath, financialDocumentForm.getDocument(), ((AccountingDocument) financialDocumentForm.getDocument()).getTargetAccountingLine(deleteIndex), false));
// if the rule evaluation passed, let's delete it
if (rulePassed) {
deleteAccountingLine(false, financialDocumentForm, deleteIndex);
} else {
String[] errorParams = new String[] { "target", Integer.toString(deleteIndex + 1) };
GlobalVariables.getMessageMap().putError(errorPath, KFSKeyConstants.ERROR_ACCOUNTINGLINE_DELETERULE_INVALIDACCOUNT, errorParams);
}
return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
use of org.kuali.kfs.sys.document.AccountingDocument in project cu-kfs by CU-CommunityApps.
the class KualiAccountingDocumentActionBase method insertTargetLine.
/**
* This method will add a TargetAccountingLine to a FinancialDocument. This assumes that the user presses the add button for a
* specific accounting line on the document and that the document is represented by a FinancialDocumentFormBase. It first
* validates the line for data integrity and then checks appropriate business rules.
*
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
* @throws Exception
*/
public ActionForward insertTargetLine(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
KualiAccountingDocumentFormBase financialDocumentForm = (KualiAccountingDocumentFormBase) form;
TargetAccountingLine line = financialDocumentForm.getNewTargetLine();
// populate chartOfAccountsCode from account number if accounts cant cross chart and Javascript is turned off
// SpringContext.getBean(AccountService.class).populateAccountingLineChartIfNeeded(line);
boolean rulePassed = true;
// before we check the regular rules we need to check the sales tax rules
// TODO: Refactor rules so we no longer have to call this before a copy of the
// accountingLine
rulePassed &= checkSalesTax((AccountingDocument) financialDocumentForm.getDocument(), line, false, true, 0);
// check any business rules
rulePassed &= SpringContext.getBean(KualiRuleService.class).applyRules(new AddAccountingLineEvent(KFSConstants.NEW_TARGET_ACCT_LINE_PROPERTY_NAME, financialDocumentForm.getDocument(), line));
// if the rule evaluation passed, let's add it
if (rulePassed) {
// add accountingLine
SpringContext.getBean(PersistenceService.class).refreshAllNonUpdatingReferences(line);
insertAccountingLine(false, financialDocumentForm, line);
// clear the used newTargetLine
financialDocumentForm.setNewTargetLine(null);
}
return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
use of org.kuali.kfs.sys.document.AccountingDocument in project cu-kfs by CU-CommunityApps.
the class CuAdvanceDepositDocumentPresentationController method getEditModes.
@Override
public Set<String> getEditModes(Document document) {
Set<String> editModes = super.getEditModes(document);
if (document instanceof AmountTotaling) {
editModes.add(KFSConstants.AMOUNT_TOTALING_EDITING_MODE);
}
editModes.add(KFSConstants.BANK_ENTRY_VIEWABLE_EDITING_MODE);
AccountingDocument accountingDocument = (AccountingDocument) document;
WorkflowDocument workflowDocument = accountingDocument.getDocumentHeader().getWorkflowDocument();
if (workflowDocument.isInitiated() || workflowDocument.isSaved()) {
editModes.add(CUKFSAuthorizationConstants.AdvanceDepositEditMode.EDITABLE_ADVANCE_DEPOSITS);
}
return editModes;
}
use of org.kuali.kfs.sys.document.AccountingDocument in project cu-kfs by CU-CommunityApps.
the class CapitalAssetInformationActionBase method copy.
/**
* Overridden to guarantee that form of copied document is set to whatever the entry mode of the document is
*
* @see org.kuali.rice.kns.web.struts.action.KualiTransactionalDocumentActionBase#copy(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
@Override
public ActionForward copy(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
CapitalAccountingLinesFormBase capitalAccountingLinesFormBase = (CapitalAccountingLinesFormBase) form;
;
CapitalAccountingLinesDocumentBase caldb = (CapitalAccountingLinesDocumentBase) capitalAccountingLinesFormBase.getFinancialDocument();
List<CapitalAccountingLines> capitalAccountingLines = caldb.getCapitalAccountingLines();
List<CapitalAccountingLines> copiedCapitalAccountingLines = new ArrayList<>();
for (CapitalAccountingLines capitalAccountingLine : capitalAccountingLines) {
copiedCapitalAccountingLines.add(capitalAccountingLine);
}
capitalAccountingLines.clear();
ActionForward forward = super.copy(mapping, form, request, response);
caldb.setCapitalAccountingLines(copiedCapitalAccountingLines);
// if the copied document has capital asset collection, remove the collection
KualiAccountingDocumentFormBase kualiAccountingDocumentFormBase = (KualiAccountingDocumentFormBase) form;
AccountingDocument document = kualiAccountingDocumentFormBase.getFinancialDocument();
if (document instanceof CapitalAssetEditable) {
CapitalAssetEditable capitalAssetEditable = (CapitalAssetEditable) document;
List<CapitalAssetInformation> capitalAssets = capitalAssetEditable.getCapitalAssetInformation();
for (CapitalAssetInformation capitalAsset : capitalAssets) {
Long capitalAssetNumber = capitalAsset.getCapitalAssetNumber();
resetCapitalAssetInfo(capitalAsset);
// because resetCapitalAssetInfo cleared the value.
if (KFSConstants.CapitalAssets.CAPITAL_ASSET_MODIFY_ACTION_INDICATOR.equalsIgnoreCase(capitalAsset.getCapitalAssetActionIndicator())) {
capitalAsset.setCapitalAssetNumber(capitalAssetNumber);
}
capitalAsset.setCapitalAssetProcessedIndicator(false);
}
}
// setup the initial next sequence number column..
KualiDocumentFormBase kualiDocumentFormBase = (KualiDocumentFormBase) form;
setupIntialNextCapitalAssetLineNumber(kualiDocumentFormBase);
checkCapitalAccountingLinesSelected(capitalAccountingLinesFormBase);
return forward;
}
Aggregations